';
echo '
▾ '.esc_attr($boxtitle).'
';
echo '
';
echo '
';
// Admin Notices reinsert themselves magically here after the
tag inside a
// Note: TGM Plugin Activations Notice still disappears from here when dismissed :-(
// TODO: =dismiss_admin_notices should have no effect here (and only here)
echo '
';
// Welcome / Documentation - Wide
// ------------------------------
// 2.0.5: add combined welcome and documentation box
$boxid = 'documentation';
if ($welcome) {$boxtitle = __('Welcome!','bioship');}
else {$boxtitle = __('Documentation','bioship');}
echo '
';
echo '
';
echo '';
if ($welcome) {echo '▸';} else {echo '▾';}
echo ' '.esc_attr($boxtitle).'
';
if (!$welcome) {$hide = ' style="display:none;"';} else {$hide = '';}
echo '
'; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho
bioship_admin_documentation_box($welcome);
echo '';
// Theme Tools - Wide (collapsed)
// ------------------------------
$boxid = 'themetools'; $boxtitle = __('Theme Settings Tools','bioship');
echo '
';
echo '
▾ '.esc_attr($boxtitle).'
';
echo '
';
bioship_admin_theme_tools_forms();
echo '';
// Left Column - Links / Extensions
// --------------------------------
echo '
';
// BioShip Theme Links
// -------------------
$boxid = 'bioshiplinks'; $boxtitle = __('Theme Links','bioship');
echo '
';
echo '
'.esc_attr($boxtitle).'
';
echo '
';
$bioshiplogo = bioship_file_hierarchy('url', 'bioship.png', $vthemedirs['image']);
echo '
';
echo '
';
// WordQuest Plugins
// -----------------
$boxid = 'wordquestplugins'; $boxtitle = __('WordQuest Alliance','bioship');
echo '
';
echo '
'.esc_attr($boxtitle).'
';
echo '
';
$wordquestlogo = bioship_file_hierarchy('url', 'wordquest.png', $vthemedirs['image']);
echo '
';
echo '
';
// Recommended Plugins
// -------------------
// 1.8.5: added recommended box display
$recommended = bioship_file_hierarchy('file', 'recommended.php', array('includes'));
if ($recommended) {
include($recommended);
$recommend = bioship_admin_get_recommended();
if ($recommend) {
$boxid = 'recommended'; $boxtitle = __('Recommended','bioship');
echo '
';
echo '
'.esc_attr($boxtitle).'
';
echo '
';
echo $recommend;
echo '
';
}
}
echo '
'; // close extend column
// Right Column - Dashboard Feed Widgets
// -------------------------------------
echo '
';
// 1.8.0: allow turning feeds off if being problematic
$feeds = true;
if (isset($_REQUEST['loadfeeds'])) {
$loadfeeds = $_REQUEST['loadfeeds'];
if ( ($loadfeeds == 'on') || ($loadfeeds == '1') ) {delete_option('bioship_admin_feed_display');}
if ( ($loadfeeds == 'off') || ($loadfeeds == '0') ) {update_option('bioship_admin_feed_display','off');}
if ( ($loadfeeds == 'no') || ($loadfeeds == '2') ) {$feeds = false;}
}
if (get_option('bioship_admin_feed_display') == 'off') {$feeds = false;}
// BioShip Feed
// ------------
// TODO: move muscle_bioship_dashboard_feed_widget to admin.php
$boxid = 'bioshipfeed'; $boxtitle = __('BioShip News','bioship');
if ($feeds && function_exists('muscle_bioship_dashboard_feed_widget')) {
echo '
';
echo '
'.esc_attr($boxtitle).'
';
echo '
';
echo "";
muscle_bioship_dashboard_feed_widget(false, false);
echo "";
echo '
';
}
// WordQuest Feed
// --------------
$boxid = 'wordquestfeed'; $boxtitle = __('WordQuest News','bioship');
if ($feeds && function_exists('wqhelper_dashboard_feed_widget')) {
echo '
';
echo '
'.esc_attr($boxtitle).'
';
echo '
';
echo "";
wqhelper_dashboard_feed_widget();
echo "";
echo '
';
}
// PluginReview Feed
// -----------------
$boxid = 'pluginreviewfeed'; $boxtitle = __('Plugin Reviews','bioship');
if ($feeds && function_exists('wqhelper_pluginreview_feed_widget')) {
echo '
';
echo '
'.esc_attr($boxtitle).'
';
echo '
';
echo "";
wqhelper_pluginreview_feed_widget();
echo "";
echo '
';
}
// maybe enqueue Feed Loader Javascript
// ------------------------------------
if (!has_action('admin_footer', 'wqhelper_dashboard_feed_javascript')) {
add_action('admin_footer', 'wqhelper_dashboard_feed_javascript');
}
echo '
'; // close feed column
}
}
// ---------------
// Welcome Message
// ---------------
// 2.1.2: added separate (filterable) theme welcome message
if (!function_exists('bioship_admin_welcome_message')) {
function bioship_admin_welcome_message() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
// --- set welcome message ---
$current_user = bioship_get_current_user();
$firstname = $current_user->user_firstname;
if ($firstname != '') {$firstname = ', '.$firstname;}
$message = '
'.esc_attr(__('Welcome aboard','bioship')).' '.esc_attr($firstname).'! ';
$message = esc_attr(__('And thanks for choosing to pilot BioShip...','bioship')).'
';
// --- filter and return ---
$message = bioship_apply_filters('admin_welcome_message', $message);
return $message;
}
}
// -----------------
// Documentation Box
// -----------------
// 2.0.5: added documentation link box
if (!function_exists('bioship_admin_documentation_box')) {
function bioship_admin_documentation_box($welcome) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__,func_get_args());}
global $vthemetemplateurl;
// Load Documentation
// ------------------
include(dirname(__FILE__).'/docs.php');
// Welcome Message
// ---------------
if ($welcome) {
// 2.0.7: use new prefixed current user function
// 2.1.1: move welcome message to separate function
echo bioship_admin_welcome_message();
}
// QuickStart Section
// ------------------
if (!$welcome) {$hide = ' style="display:none;"';} else {$hide = '';}
echo '
'; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho
echo '
'.esc_attr(__('QuickStart Guide','bioship')).'
';
echo bioship_docs_quickstart(false);
echo '';
// QuickStart Scripts
// ------------------
echo "";
// QuickStart Links
// ----------------
if ($welcome) {$hide = ' style="display:none;"';} else {$hide = '';}
$quickstart = '
';
if (!$welcome) {$hide = ' style="display:none;"';} else {$hide = '';}
$quickstart .= '
';
$quickstart .= '
';
// Documentation Index
// -------------------
$docindex = bioship_docs_index(false);
$docindex = str_replace('h3>', 'h4>', $docindex);
$docindex = str_replace('', '
| '.$quickstart, $docindex);
$docindex = str_replace('', ' | | ', $docindex);
$docindex = str_replace('', ' |
', $docindex);
// 2.1.4: fix to documentation thickbox links
global $vthemedoctitles;
foreach ($vthemedoctitles as $key => $title) {
$docindex = str_replace('a href="/documentation/'.$key.'/"', 'a class="doc-thickbox" href="#'.$key.'"', $docindex);
}
echo $docindex; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho
// Documentation Thickbox Script
// -----------------------------
$docsurl = esc_url($vthemetemplateurl.'admin/docs.php');
echo "";
}
}
// ---------------------------------
// === Build Selective Resources ===
// ---------------------------------
// --------------------------
// Build Selective CSS and JS
// --------------------------
// 2.1.4: move trigger conditions internally
if (!function_exists('bioship_admin_build_selective_resources')) {
add_action('admin_notices', 'bioship_admin_build_selective_resources');
// 1.8.0: ...also need to trigger this after a Customizer save...
add_action('customize_save_after', 'bioship_admin_build_selective_resources');
function bioship_admin_build_selective_resources() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $vthemename, $vthemesettings, $vthemedirs;
// --- check build trigger conditions ---
// 2.1.4: move trigger conditions internally
$currentaction = current_action(); $dobuild = false;
if ($currentaction == 'customize_save_after') {$dobuild = true;}
elseif ($currentaction == 'admin_notices') {
// --- Options Framework ---
if (isset($_GET['page']) && isset($_GET['settings-updated'])) {
if ( ($_GET['page'] == 'options-framework') && ($_GET['settings-updated'] == 'true') ) {
$dobuild = true;
}
}
// --- Titan Framework ---
// 1.8.0: need to trigger differently for Titan save
if (isset($_GET['page']) && isset($_GET['message'])) {
if ( ($_GET['page'] == $vthemename.'-options') && ($_GET['message'] == 'saved') ) {
$dobuild = true;
}
}
}
if (!$dobuild) {return;}
// Maybe Combine CSS Core On Save
// ------------------------------
if ($vthemesettings['combinecsscore']) {
// --- reset.css or normalize.css ---
$resetoption = $vthemesettings['cssreset'];
if ($resetoption == 'normalize') {
$cssfile = bioship_file_hierarchy('file', 'normalize.css', $vthemedirs['style']);
if ($cssfile) {$cssreset = bioship_file_get_contents($cssfile);}
else {echo "
".esc_attr(__('Warning','bioship')).": ".esc_attr(__('CSS Combine could not find','bioship'))."
normalize.css";}
}
if ($resetoption == 'reset') {
$cssfile = bioship_file_hierarchy('file', 'reset.css', $vthemedirs['style']);
if ($cssfile) {$cssreset = bioship_file_get_contents($cssfile);}
else {echo "
".esc_attr(__('Warning','bioship')).": ".esc_attr(__('CSS Combine could not find','bioship'))."
reset.css";}
}
// --- formalize.css ---
if ($vthemesettings['loadformalize']) {
$cssfile = bioship_file_hierarchy('file', 'formalize.css', $vthemedirs['style']);
if ($cssfile) {$formalize = bioship_file_get_contents($cssfile);}
else {echo "
".esc_attr(__('Warning','bioship')).": ".esc_attr(__('CSS Combine could not find','bioship'))."
formalize.css";}
}
// --- mobile.css ---
// (previously misnamed layout.css in skeleton theme)
$cssfile = bioship_file_hierarchy('file', 'mobile.css', $vthemedirs['style']);
if ($cssfile) {$mobile = bioship_file_get_contents($cssfile);}
else {echo "
".esc_attr(__('Warning','bioship')).": ".esc_attr(__('CSS Combine could not find','bioship'))."
mobile.css";}
// 1.5.0: [Deprecated] these fixed stylesheet widths are deprecated by grid.php
// skeleton-960.css, skeleton-1120.css, skeleton-1200.css
// --- skeleton.css ---
// (note: this must be last or CSS breaks)
$cssfile = bioship_file_hierarchy('file', 'skeleton.css', $vthemedirs['style']);
if ($cssfile) {$skeleton = bioship_file_get_contents($cssfile);}
else {echo "
".esc_attr(__('Warning','bioship')).": ".esc_attr(__('CSS Combine could not find','bioship'))."
skeleton.css";}
// note: style.css and custom.css are intentionally not added here as it breaks combined stylesheet!
// --- combine the CSS file contents ---
$csscontents = $cssreset.PHP_EOL.PHP_EOL;
$csscontents .= $formalize.PHP_EOL.PHP_EOL;
$csscontents .= $mobile.PHP_EOL.PHP_EOL;
$csscontents .= $skeleton.PHP_EOL.PHP_EOL;
$datetime = date('H:i:s d/m/Y');
$csscontents .= '/* Last Updated: '.esc_attr($datetime).' */';
// --- write combined core CSS file directly ---
// (no need for WP_Filesystem as the file already exists, but used anyway to pass Theme Check)
// ref: http://ottopress.com/2011/tutorial-using-the-wp_filesystem/#comment-10820
// 1.8.0: fix to use directory separator in file path
// --- write selected styles to file ---
// 2.1.1: check alternate style directory paths
$stylepath = get_stylesheet_directory($vthemename).DIRSEP;
foreach ($vthemedirs['style'] as $dir) {
if (is_dir($stylepath.DIRSEP.$dir) && file_exists($stylepath.DIRSEP.$dir.DIRSEP.'core-styles.css')) {
$stylefile .= $stylepath.DIRSEP.$dir.DIRSEP.'core-styles.css'; break;
}
}
if (isset($stylefile)) {bioship_write_to_file($stylefile, $csscontents);}
}
// ----------------------------------------------
// Build Selective Foundation Javascripts on Save
// -----------------------------------------------
// TODO: build selectives for Foundation 6, this currently only works for Foundation 5
// $foundation = $vthemesettings['foundationversion'];
$foundation = 'foundation5'; // currently available for Foundation 5 only
if ($vthemesettings['loadfoundation'] == 'selective') {
$jsfile = bioship_file_hierarchy('file', 'foundation.js', array('javascripts','includes/'.$foundation.'/js/foundation'));
$foundationjs = bioship_file_get_contents($jsfile);
$selected = $vthemesettings['foundationselect'];
$message = '';
foreach ($selected as $key => $value) {
if ($value == '1') {
$filename = 'foundation.'.$key.'.js';
$foundationsourcedir = 'includes/'.$foundation.'/js/foundation';
$jsfile = bioship_file_hierarchy('file', $filename, array($foundationsourcedir));
if ($jsfile) {
$jsdata = bioship_file_get_contents($jsfile);
// 2.0.7: doubly ensure new line consistency for Theme Check
$jsdata = str_replace("\r\n", "\n", $jsdata);
$foundationjs .= $jsdata;
// 1.5.5: fix, use specific matching EOL to pass Theme Check
$foundationjs .= "\n"."\n";
} else {
$message .= "
".esc_attr(__('Warning','bioship')).": ".esc_attr(__('Foundation JS Combine could not find','bioship'))."
".esc_attr($filename)."";
}
}
}
// --- missing resources message ---
// 1.8.0: added admin warning for missing resources
if ($message != '') {
global $vadminmessages; $vadminmessages[] = $message;
bioship_admin_notices_enqueue();
}
// --- write to file ---
if (strlen($foundation) > 0) {
// 1.8.0: write to theme javascripts directory, not foundation/js and fix directory separator
// also, this is written to template directory so as not to overwrite a child version
// (as such it does not need to use WP Filesystem as the file already exists)
// ref: http://ottopress.com/2011/tutorial-using-the-wp_filesystem/#comment-10820
$scriptpath = get_template_directory($vthemename).DIRSEP;
// 2.1.1: check alternate script directory paths
foreach ($vthemedirs['script'] as $dir) {
if (is_dir($scriptpath.DIRSEP.$dir) && file_exists($scriptpath.DIRSEP.$dir.DIRSEP.'foundation.selected.js')) {
$scriptfile = $scriptpath.DIRSEP.$dir.DIRSEP.'foundation.selected.js'; break;
}
}
if (isset($scriptfile)) {bioship_write_to_file($scriptfile, $foundationjs);}
}
}
}
}
// =================================
// === Activation / Deactivation ===
// =================================
// -----------------------------------------------------
// Save/Restore Widgets/Menus on Deactivation/Activation
// -----------------------------------------------------
// TODO: retest activation/deactivation functionality
// (as this was improved in WP Core at some point)
// TEST: if switch_theme/after_switch_theme is triggered when using WP CLI
// (as may not be in admin area and these are loaded via admin.php only,
// so this may need to move out of admin.php if it is still needed)
// ----------------
// For Parent Theme
// ----------------
if (!THEMECHILD) {
$saverestorewidgets = bioship_apply_filters('skeleton_theme_widget_backups', true);
if ($saverestorewidgets) {
// Backup on Deactivation
// ----------------------
if (!function_exists('bioship_admin_theme_deactivation')) {
add_action('switch_theme', 'bioship_admin_theme_deactivation');
function bioship_admin_theme_deactivation($vnewthemename) {
$sidebarswidgets = get_option('sidebars_widgets');
update_option('bioship_widgets_backup', $sidebarswidgets);
$menusettings = get_option('nav_menu_options');
update_option('bioship_menus_backup', $menusettings);
// not needed: theme mods, as they are theme specific
// (hmmmm maybe just how the sidebars/menus should be!)
}
}
// Restore on Activation
// ---------------------
if (!function_exists('bioship_admin_theme_activation')) {
add_action('after_switch_theme', 'bioship_admin_theme_activation');
function bioship_admin_theme_activation() {
// 2.1.1: use THEMEPREFIX constant instead of hardcoding
$sidebarswidgets = get_option('sidebars_widgets');
$menusettings = get_option('nav_menu_options');
$bioshipwidgets = get_option(THEMEPREFIX.'_widgets_backup');
$bioshipmenus = get_option(THEMEPREFIX.'_menus_backup');
// note: no need to restore theme mods as already theme specific
// If there are backed up widgets/menus, restore them now
// ..also be nice and backup the deactivated themes widgets/menus
// (even though note these cannot be automatically restored)
if ($bioshipwidgets != '') {
update_option('sidebars_widgets', $bioshipwidgets);
delete_option('old_theme_widgets_backup');
// 2.0.8: fix to variable typo (vsidebarwidgets)
add_option('old_theme_widgets_backup', $sidebarswidgets);
}
if ($bioshipmenus != '') {
update_option('nav_menu_options', $bioshipmenus);
delete_option('old_theme_menus_backup');
add_option('old_theme_menus_backup', $menusettings);
}
// --- redirect to Theme Options page on activation ---
// 2.0.5: redirect to welcome page section with admin_url
global $pagenow;
if (is_admin() && isset($_GET['activated']) && ($pagenow == 'themes.php')) {
// 1.8.0: Titan Framework Conversion
// 2.0.5: allow for no Titan or Options Framework
if (!THEMETITAN && THEMEOPT) {wp_redirect(admin_url('themes.php').'?page=options-framework&welcome=true'); exit;}
elseif (THEMETITAN && class_exists('TitanFramework')) {wp_redirect(admin_url('admin.php').'?page=bioship-options&welcome=true'); exit;}
// 2.0.8: WordPress.Org versions only - redirection on theme activation not allowed :-/
// else {wp_redirect(admin_url('themes.php').'?page=theme-info&welcome=true'); exit;}
}
}
}
}
}
// ---------------
// For Child Theme
// ---------------
if (THEMECHILD) {
// Save/Restore Child Theme Widgets/Menus on Deactivation/Activation
// -----------------------------------------------------------------
// 1.8.0: moved here from child theme functions.php (cleaner)
// (note: maintain function_exists wrappers for back compat)
// TODO: possibly change this filter name ?
$saverestorechildwidgets = bioship_apply_filters('skeleton_childtheme_widget_backups', true);
if ($saverestorechildwidgets) {
// get Child Theme Slug
// --------------------
if (!function_exists('bioship_admin_get_child_theme_slug')) {
function bioship_admin_get_child_theme_slug() {
$theme = wp_get_theme();
if (!THEMETITAN && THEMEOPT) {$childthemeslug = preg_replace("/\W/", "_", strtolower($theme['Name']));}
else {$childthemeslug = preg_replace("/\W/", "-", strtolower($theme['Name']));}
return $childthemeslug;
}
}
// Switch Theme Hook (on Deactivation)
// -----------------------------------
// 2.1.1: moved add_action internally for consistency
if (!function_exists('bioship_admin_child_theme_deactivation')) {
add_action('switch_theme', 'bioship_admin_child_theme_deactivation');
function bioship_admin_child_theme_deactivation($vnewthemename) {
// Backup Child Theme Widgets and Menus
// ------------------------------------
$childthemeslug = bioship_admin_get_child_theme_slug();
$sidebarswidgets = get_option('sidebars_widgets');
delete_option($childthemeslug.'_widgets_backup');
add_option($childthemeslug.'_widgets_backup', $sidebarswidgets);
$menusettings = get_option('nav_menu_options');
delete_option($childthemeslug.'_menus_backup');
add_option($childthemeslug.'_menus_backup', $menusettings);
}
}
// After Switch Theme Hook (on Activation)
// ---------------------------------------
// 2.1.1: moved add_action internally for consistency
if (!function_exists('bioship_admin_child_theme_activation')) {
add_action('after_switch_theme', 'bioship_admin_child_theme_activation');
function bioship_admin_child_theme_activation() {
// Restore Child Theme Widgets and Menus
// -------------------------------------
$childthemeslug = bioship_admin_get_child_theme_slug();
$backupwidgets = get_option($childthemeslug.'_widgets_backup');
$backupmenus = get_option($childthemeslug.'_menus_backup');
if ($backupwidgets != '') {update_option('sidebars_widgets', $backupwidgets);}
if ($backupmenus != '') {update_option('nav_menu_options', $backupmenus);}
// Also transfer the menu locations from the backup
$menulocations = get_theme_mod('nav_menu_locations');
if (!is_array($menulocations)) {
$menulocations = get_option($childthemeslug.'_menu_locations_backup');
if (is_array($menulocations)) {set_theme_mod('nav_menu_locations', $menulocations);}
}
// Redirect to Theme Options page on theme activation
// --------------------------------------------------
// 1.8.0: redirects to theme options / info page
// 2.0.5: redirect to theme options / customizer with admin_url
global $pagenow;
if (is_admin() && isset($_GET['activated']) && ($pagenow == 'themes.php')) {
if (!THEMETITAN && THEMEOPT) {$url = admin_url('admin.php').'?page=options-framework';}
elseif (THEMETITAN && class_exists('TitanFramework')) {$url = admin_url('admin.php').'?page=bioship-options';}
else {$url = admin_url('customize.php');}
wp_redirect($url); exit;
}
}
}
}
}
// TODO: fix or deprecate? automatic theme mods and menu locations transfer ?
// if (get_option('bioship_transfer_widgets_menus') == 'yes') {
// $transferwidgets = get_option('bioship_widgets_backup');
// update_option('sidebars_widgets', $vtransferwidgets);
//
// $transfermenus = get_option('bioship_menus_backup');
// update_option('nav_menu_options', $transfermenus);
//
// $thememods = get_option('bioship_mods_backup');
// if (count($thememods) > 0) {
// foreach ($thememods as $thememod => $value) {
// set_theme_mod($thememod, $value);
// }
// }
// // $menulocations = get_option('bioship_menu_locations_backup');
// // set_theme_mod('nav_menu_locations', $menulocations);
//
// update_option('bioship_transfer_widgets_menus','done');
// }
// ---------------------
// === Theme Plugins ===
// ---------------------
// ----------------------------------
// Install the Titan Framework Plugin
// ----------------------------------
// this method creates a standalone callable installation link for
// adding Titan Framework to the WordPress.Org version of theme
// (currently done via TGMPA using Titan Checker, rather than here)
// 1.8.5: moved here from customizer.php
// 2.1.1: moved check trigger internally for consistency
// Note: Otto's Theme Plugin Dependency Class
// ref: http://ottopress.com/2012/themeplugin-dependencies/
if (!function_exists('bioship_admin_install_titan_framework')) {
add_action('init', 'bioship_admin_install_titan_framework');
function bioship_admin_install_titan_framework() {
// --- check trigger conditions ---
if (!isset($_REQUEST['admin_install_titan_framework'])) {return;}
if ($_REQUEST['admin_install_titan_framework'] != 'yes') {return;}
// --- check permissions ---
if (!current_user_can('install_plugins')) {return;}
// IDEA: maybe extracting from a bundled zip could work here..?
// eg: http://meta.wordpress.stackexchange.com/questions/4172/script-that-downloads-installs-and-activates-wordpress-plugins?cb=1
// --- install Titan Framework ---
// 2.1.1: use add_query_arg for install URL
$titanslug = 'titan-framework';
$installurl = add_query_arg('action', 'install-plugin', self_admin_url('update.php'));
$installurl = add_query_arg('plugin', $titanslug, $installurl);
$installurl = wp_nonce_url($installurl, 'install-plugin_'.$titanslug);
wp_redirect($installurl); exit;
}
}
// --------------------------
// Load TGM Plugin Activation
// --------------------------
if (!function_exists('tgmpa')) {
$tgmpa = bioship_file_hierarchy('file', 'class-tgm-plugin-activation.php', array('includes'));
if ($tgmpa) {require_once($tgmpa);}
}
// ------------------------
// Recommended Plugins List
// ------------------------
// 'Required' Plugins
// ------------------
// - Titan Framework (better admin theme options interface)
// -- for WordPress.Org installs (not explicitly 'required')
// Recommended Plugins (Theme Supported)
// -------------------------------------
// TODO: retest the need for Widget Saver ?
// TODO: maybe force use of specific TML version ?
// - AJAX Load More
// - Open Graph Protocol Framework
// - Theme My Login
// - Theme Test Drive
// - Widget Saver
// - WP Subtitle
// - WP PageNavi
// WordQuest Plugins
// -----------------
// - AutoSave Net (released)
// - Content Sidebars (released)
// - Guten Free Options (released)
// - WP AutoMedic (released)
// Upcoming WordQuest Plugins
// --------------------------
// - ForceField (pending)
// - Visitor Vortex (pending)
// - RefleXedit (testing)
// - PDF Replicator (testing)
// - PDF Shuttle (testing)
// - WP Infinity Responder (updating)
// ----------------------------------
// Load TGMPA for Recommended Plugins
// ----------------------------------
if (function_exists('tgmpa')) {
// TESTME: this is done separately via Titan Checker now, but this calls
// TGMPA separately as well as a new instance - which may or may not be desirable?
// 1.9.8: recommend Titan Framework plugin for Wordpress.org installs
add_filter('tgm_plugins_array', 'bioship_admin_tgm_titan_framework_check');
if (!function_exists('bioship_admin_tgm_titan_framework_check')) {
function bioship_admin_tgm_titan_framework_check($plugins) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
// 2.0.9: only for WordPress.org version and when Titan Framework is not present
if (!THEMEWPORG || THEMETITAN || class_exists('TitanFramework')) {return $plugins;}
// 2.0.9: fix (override) Titan Framework checker 'required' setting to false
$foundtitan = false;
foreach ($plugins as $i => $plugin) {
if ($plugin['slug'] == 'titan-framework') {
$plugin['required'] = false;
$plugins[$i] = $plugin;
$foundtitan = true;
}
}
if (!$foundtitan) {
$plugins[] = array(
'name' => 'Titan Framework',
'slug' => 'titan-framework',
'required' => false
);
}
return $plugins;
}
}
// TGMPA seems to need at least WP 3.7...
if (!version_compare($wp_version,'3.7','<')) { //'>
// TGMPA Theme Options Page - Notice Display Workaround
// to use the plugin recommendation notice on the theme options page
// - whether it has already been dismissed by the user or not! :-)
if (isset($_REQUEST['page'])) {
// 1.8.0: allow for Titan Framework admin page URL
// 2.0.9: use THEMESLUG constance instead of vthemename
if ( ($_REQUEST['page'] == 'options-framework')
|| ($_REQUEST['page'] == THEMESLUG.'-options')
|| ($_REQUEST['page'] == THEMESLUG.'_options') ) {
// hook in before init as this is when TGM loads
add_action('plugins_loaded', 'bioship_admin_tgm_notice_shift');
// make the notice undismissable on theme page only via config filter
add_filter('tgm_config_array', 'bioship_admin_tgm_dismiss_notice_off');
}
}
// Notice Shift
// ------------
if (!function_exists('bioship_admin_tgm_notice_shift')) {
function bioship_admin_tgm_notice_shift() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
// 2.1.1: use THEMEPREFIX constant instead of hardcoded
$id = THEMESLUG.'-tgmpa'; // TGM instance id
$currentuserid = get_current_user_id();
if (get_user_meta($currentuserid, 'tgmpa_dismissed_notice_'.$id, true)) {
add_user_meta($currentuserid, 'tgmpa_temp_notice_'.$id, 1);
delete_user_meta($currentuserid, 'tgmpa_dismissed_notice_'.$id);
add_action('all_admin_notices', 'bioship_admin_tgm_notice_unshift', 100);
}
}
}
// Notice Unshift
// --------------
if (!function_exists('bioship_admin_tgm_notice_unshift')) {
function bioship_admin_tgm_notice_unshift() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
$id = THEMESLUG.'-tgmpa'; // TGM instance id
$currentuserid = get_current_user_id();
// 2.0.9: fix to match temporary notice key
delete_user_meta($currentuserid, 'tgmpa_temp_notice_'.$id);
add_user_meta($currentuserid, 'tgmpa_dismissed_notice_'.$id, 1);
}
}
// Notice Off
// ----------
if (!function_exists('bioship_admin_tgm_dismiss_notice_off')) {
function bioship_admin_tgm_dismiss_notice_off($config) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__,func_get_args());}
// --- filter the theme page message ---
$message = '
'.esc_attr(__('BioShip Theme Framework Recommended Plugins','bioship')).'
';
$message = bioship_apply_filters('tgm_theme_page_message', $message);
// --- change the existing config ---
$config['dismissable'] = false;
$config['dismiss_msg'] = $message;
return $config;
}
}
// Register Plugins using TGMPA
// ----------------------------
// 1.8.0: renamed from muscle_register_plugins
add_action('tgmpa_register', 'bioship_admin_register_plugins');
// Create an array of plugins and config
// -------------------------------------
// Note: see includes/tgm-examples.php for more detailed plugin examples
// Ref: http://tgmpluginactivation.com/configuration/
if (!function_exists('bioship_admin_register_plugins')) {
function bioship_admin_register_plugins() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
/*
* TGMPA: Array of plugin arrays. Required keys are name and slug.
* If the source is NOT from the .org repo, then source is also required.
*/
// note: Originally recommended by SPML Skeleton Theme: Simple Shortcodes (smpl-shortcodes)
$plugins = array(
array(
'name' => 'AJAX Load More',
'slug' => 'ajax-load-more',
'required' => false,
),
array(
'name' => 'Better WordPress Minify',
'slug' => 'bwp-minify',
'required' => false,
),
array(
'name' => 'Open Graph Protocol Framework',
'slug' => 'open-graph-protocol-framework',
'required' => false,
),
array(
'name' => 'Theme My Login',
'slug' => 'theme-my-login',
'required' => false
),
array(
'name' => 'Theme Test Drive',
'slug' => 'theme-test-drive',
'required' => false,
),
array(
'name' => 'Widget Saver',
'slug' => 'widget-saver',
'required' => false,
),
array(
'name' => 'WP Subtitle',
'slug' => 'wp-subtitle',
'required' => false,
),
array(
'name' => 'WP Pagenavi',
'slug' => 'wp-pagenavi',
'required' => false,
),
// WordQuest (Theme) Plugins
// -------------------------
// 1.9.8: removed unreleased plugins
// 2.0.5: re-added released plugins
// 2.0.9: added WP AutoMedic release
// 2.1.1: added Guten Free Options plugin
// 2.1.1: added wq flag for source handling
// --- AutoSave Net ---
array(
'name' => 'AutoSave Net',
'slug' => 'autosave-net',
'required' => false,
'wq' => true,
),
// --- Content Sidebars ---
array(
'name' => 'Content Sidebars',
'slug' => 'content-sidebars',
'required' => false,
'wq' => true,
),
// --- Guten Free Options ---
array(
'name' => 'Guten Free Options',
'slug' => 'guten-free-options',
'required' => false,
'wq' => true,
),
// --- WP AutoMedic ---
array(
'name' => 'WP AutoMedic',
'slug' => 'wp-automedic',
'required' => false,
'wq' => true,
),
);
// 2.1.1: change plugin source info if not WordPress.Org version
if (!THEMEWPORG) {
$wqurl = 'http://wordquest.org';
foreach ($plugins as $i => $plugin) {
if (isset($plugin['wq']) && $plugin['wq']) {
$plugins[$i]['source'] = $wqurl.'/downloads/packages/'.$plugin['slug'].'.zip';
$plugins[$i]['external_url'] = $wqurl.'/plugins/'.$plugin['slug'].'/';
}
}
}
// --- filter the plugins array ---
$plugins = bioship_apply_filters('tgm_plugins_array', $plugins);
/*
* TGMPA: Array of configuration settings. Amend each line as needed.
*
*/
// --- filter the TGM plugins page message ---
$message = '
'.esc_attr(__('BioShip Theme Framework','bioship'));
$message .= ' - '.esc_attr(__('Recommended Plugins','bioship')).'
';
$message = bioship_apply_filters('tgm_plugin_page_message', $message);
// --- filter the bundle path ---
// 2.0.9: changed from /includes/plugins/ for possible future usage
$bundlespath = get_template_directory().'/includes/bundled/';
$bundlespath = bioship_apply_filters('tgm_plugin_bundles_path', $bundlespath);
// note: id (instance) set to bioship-tgmpa to prevent conflicts
$config = array(
'id' => THEMESLUG.'-tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => $bundlespath, // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => true, // If false, a user cannot dismiss the nag message.
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
'is_automatic' => true, // Automatically activate plugins after installation or not.
'message' => $message, // Message to output right before the plugins table.
'strings' => array(
'page_title' => __( 'Install Recommended Plugins', 'bioship' ),
'menu_title' => __( 'Theme Plugins', 'bioship' ),
'installing' => __( 'Installing Plugin: %s', 'bioship' ), // %s = plugin name.
'oops' => __( 'Something went wrong with the plugin API.', 'bioship' ),
'notice_can_install_required' => _n_noop(
'This theme requires the following plugin: %1$s.',
'This theme requires the following plugins: %1$s.',
'bioship'
), // %1$s = plugin name(s).
'notice_can_install_recommended' => _n_noop(
'This theme recommends the following plugin: %1$s.',
'This theme recommends the following plugins: %1$s.',
'bioship'
), // %1$s = plugin name(s).
'notice_cannot_install' => _n_noop(
'Sorry, but you do not have the correct permissions to install the %1$s plugin.',
'Sorry, but you do not have the correct permissions to install the %1$s plugins.',
'bioship'
), // %1$s = plugin name(s).
'notice_ask_to_update' => _n_noop(
'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
'bioship'
), // %1$s = plugin name(s).
'notice_ask_to_update_maybe' => _n_noop(
'There is a plugin update available for: %1$s.',
'There are updates available for the following plugins: %1$s.',
'bioship'
), // %1$s = plugin name(s).
'notice_cannot_update' => _n_noop(
'Sorry, but you do not have the correct permissions to update the %1$s plugin.',
'Sorry, but you do not have the correct permissions to update the %1$s plugins.',
'bioship'
), // %1$s = plugin name(s).
'notice_can_activate_required' => _n_noop(
'Warning! The following required plugin is currently inactive: %1$s.',
'Warning! The following required plugins are currently inactive: %1$s.',
'bioship'
), // %1$s = plugin name(s).
'notice_can_activate_recommended' => _n_noop(
'The following recommended plugin is currently inactive: %1$s.',
'The following recommended plugins are currently inactive: %1$s.',
'bioship'
), // %1$s = plugin name(s).
'notice_cannot_activate' => _n_noop(
'Sorry, but you do not have the correct permissions to activate the %1$s plugin.',
'Sorry, but you do not have the correct permissions to activate the %1$s plugins.',
'bioship'
), // %1$s = plugin name(s).
'install_link' => _n_noop('Begin installing plugin', 'Begin installing plugins', 'bioship') ,
'update_link' => _n_noop('Begin updating plugin', 'Begin updating plugins', 'bioship' ),
'activate_link' => _n_noop('Begin activating plugin', 'Begin activating plugins', 'bioship' ),
'return' => __( 'Return to Recommended Plugins Installer', 'bioship' ),
'plugin_activated' => __( 'Plugin activated successfully.', 'bioship' ),
'activated_successfully' => __( 'The following plugin was activated successfully:', 'bioship' ),
'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'bioship' ), // %1$s = plugin name(s).
'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'bioship' ), // %1$s = plugin name(s).
'complete' => __( 'All plugins installed and activated successfully. %1$s', 'bioship' ), // %s = dashboard link.
'contact_admin' => __( 'Please contact the administrator of this site for help.', 'bioship' ),
'nag_type' => 'updated', // Determines admin notice type - can only be 'updated', 'update-nag' or 'error'.
),
);
// --- filter the TGMPA config ---
$config = bioship_apply_filters('tgm_config_array', $config);
// --- load TGM Plugin Activation ---
tgmpa($plugins, $config);
}
}
}
}