'', 'donationboxoff' => '', 'adsboxoff' => '',
'installdate' => date('Y-m-d'), 'installversion' => THEMEVERSION);
add_option('bioship_sidebar_options', $vsidebaroptions);
}
} else {
// 1.8.0: default sidebar ads to off for WordPress.Org guideline compliance
// 1.8.5: switched this to single option array value
if (!is_array(get_option('bioship_sidebar_options'))) {
// 2.0.2: added first installed version record
$vsidebaroptions = array('reportboxoff' => '', 'donationboxoff' => '', 'adsboxoff' => 'checked',
'installdate' => date('Y-m-d'), 'installversion' => THEMEVERSION);
add_option('bioship_sidebar_options', $vsidebaroptions);
}
// 1.8.5: maybe disable directory clearing to keep installed theme bundles?
// ref: http://wordpress.stackexchange.com/a/228798/76440
// TODO: test this out for desired results
// add_filter('bioship_package_options', 'bioship_avoid_deletion', 999);
if (!function_exists('bioship_avoid_deletion')) {
function bioship_avoid_deletion($voptions) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__,func_get_args());}
$vhookextra = $voptions['hook_extra'];
if ( ($vhookextra['type'] == 'theme') && ($vhookextra['action'] == 'update') ) {
if ($vhookextra['theme'] == 'bioship') {
$voptions['clear_destination'] = false;
$voptions['abort_if_destination_exists'] = false;
}
}
return $voptions;
}
}
}
}
}
// ---------------------------
// Theme Settings for Freemius
// ---------------------------
// 2.0.5: added Freemius to theme
if (!function_exists('bioship_admin_freemius')) {
function bioship_admin_freemius() {
global $wordquestplugins, $bioship_freemius; $vpremium = false;
if ($wordquestplugins[THEMEPREFIX]['plan'] == 'premium') {$vpremium = true;}
$vwporg = $wordquestplugins[THEMEPREFIX]['wporg'];
$vhasplans = $wordquestplugins[THEMEPREFIX]['hasplans'];
if (isset($_REQUEST['page'])) {
// external redirect for Support Forum
if ($_REQUEST['page'] == THEMEPREFIX.'-wp-support-forum') {
if (!function_exists('wp_redirect')) {include(ABSPATH.WPINC.'/pluggable.php');}
wp_redirect(THEMESUPPORT.'/quest/quest-category/theme-support/'); exit;
}
// 2.0.7: external redirect for Documentation
if ($_REQUEST['page'] == THEMEPREFIX.'-documentation') {
if (!function_exists('wp_redirect')) {include(ABSPATH.WPINC.'/pluggable.php');}
wp_redirect(THEMEHOMEURL.'/documentation/'); exit;
}
}
if (!isset($bioship_freemius)) {
require_once(dirname(dirname(__FILE__)).'/freemius/start.php');
// set different menu depending on framework
$vmenu = array('contact' => $vpremium);
if (THEMETITAN) {
$vmenu['slug'] = 'bioship-options';
$vmenu['first-path'] = 'admin.php?page=bioship-options&welcome=true';
} elseif (THEMEOPT) {
$vmenu['slug'] = 'theme-options';
$vmenu['first-path'] = 'admin.php?page=options-framework&welcome=true';
} else {
$vmenu['slug'] = 'theme-tools';
$vmenu['parent'] = array('slug' => 'themes.php');
$vmenu['first-path'] = 'themes.php?page=theme-info&welcome=true';
}
$bioship_settings = array(
'id' => '816',
'slug' => 'bioship',
'type' => 'theme',
'public_key' => 'pk_15fe43ecd7c5580cbcbb3484cfa9f',
'is_premium' => $vpremium,
'has_premium_version' => false,
'has_addons' => false,
'has_paid_plans' => $vhasplans,
'is_org_compliant' => $vwporg,
'menu' => $vmenu
);
$bioship_freemius = fs_dynamic_init($bioship_settings);
}
return $bioship_freemius;
}
}
// load Freemius SDK for Theme
// ---------------------------
// 2.0.5: added Freemius loading - not working yet :-/
if (file_exists(dirname(dirname(__FILE__)).'/freemius/start.php')) {
// initialize Freemius object
// --------------------------
$bioship_freemius = bioship_admin_freemius();
// signal that SDK was initiated
bioship_do_action('bioship_loaded');
// customize Freemius Connect Message
// ----------------------------------
if (!function_exists('bioship_admin_freemius_connect')) {
// 'Never miss an important update - opt-in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s.'
$bioship_freemius->add_filter('connect_message', 'bioship_admin_freemius_connect', WP_FS__DEFAULT_PRIORITY, 6);
function bioship_admin_freemius_connect($message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link) {
return sprintf(
__fs('hey-x').' '.
__('Show your appreciation for %1$s by helping us improve it! Opt in to diagnostic tracking and receive security and feature notifications.', 'bioship'),
$user_first_name, ''.$plugin_title.' ', ''.$user_login.' ', $site_link, $freemius_link
);
}
}
// customize Connect on Update Message
// -----------------------------------
if (!function_exists('bioship_admin_freemius_connect_update')) {
// 'Please help us improve %1$s! If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that\'s okay! %1$s will still work just fine.'
$bioship_freemius->add_filter('connect_message_on_update', 'bioship_admin_freemius_connect_update', WP_FS__DEFAULT_PRIORITY, 6);
function bioship_admin_freemius_connect_update($message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link) {
// 2.0.5: keep update message the same for now
return bioship_admin_freemius_connect($message, $user_first_name, $plugin_title, $user_login, $site_link, $freemius_link);
}
}
// license Change Updater
// ----------------------
add_action('fs_after_license_change_bioship', 'bioship_admin_license_change', 10, 2);
if (!function_exists('bioship_admin_license_change')) {
function bioship_admin_license_change($vchange, $vplan) {
global $bioship_freemius;
// none, upgraded, downgraded, changed, cancelled, expired, trial_started, trial_expired
if ($vchange != 'none') {
// 2.0.7: use new prefixed current user function
$current_user = bioship_get_current_user();
$vupdateurl = add_query_arg('email', $current_user->user_email, THEMESUPPORT);
$vupdateurl = add_query_arg('planchange', $vchange, $vupdateurl);
$vupdateurl = add_query_arg('plan', $vplan, $vupdateurl);
echo '';
}
}
}
}
// --------------------
// Admin Notice Helpers
// --------------------
// Admin Notices Output
// --------------------
// 2.0.2: added admin notice output helper
$vadminmessages = array();
if (!function_exists('bioship_admin_notices')) {
function bioship_admin_notices() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
echo "";
global $vadminmessages;
if (count($vadminmessages) > 0) {
foreach ($vadminmessages as $vmessage) {
echo "
';
echo '
▾ '.$vboxtitle.'';
echo '
';
echo '
';
// Admin Notices reinsert themselves magically here after the
tag inside a
// Note: TGM Plugin Activations Notice still disappears from here when dismissed :-(
// FIXME =dismiss_admin_notices should have no effect here (and only here)
echo '
';
// Welcome / Documentation - Wide
// ------------------------------
// 2.0.5: add combined welcome and documentation box
$vboxid = 'documentation';
if ($vwelcome) {$vboxtitle = __('Welcome!','bioship');}
else {$vboxtitle = __('Documentation','bioship');}
echo '
';
echo '
';
echo '';
if ($vwelcome) {echo '▸';} else {echo '▾';}
echo ' '.$vboxtitle.' ';
echo '
';
bioship_admin_documentation_box($vwelcome);
echo ' ';
// Theme Tools - Wide (collapsed)
// ------------------------------
$vboxid = 'themetools'; $vboxtitle = __('Theme Settings Tools','bioship');
echo '
';
echo '
▾ '.$vboxtitle.'';
echo '
';
bioship_admin_theme_tools_forms();
echo ' ';
// Left Column - Links / Extensions
// --------------------------------
echo '
';
// BioShip Theme Links
// -------------------
$vboxid = 'bioshiplinks'; $vboxtitle = __('Theme Links','bioship');
echo '
';
echo '
'.$vboxtitle.' ';
echo '
';
$vbioshiplogo = bioship_file_hierarchy('url', 'bioship.png', $vthemedirs['img']);
echo '
';
echo '
';
// WordQuest Plugins
// -----------------
$vboxid = 'wordquestplugins'; $vboxtitle = __('WordQuest Alliance','bioship');
echo '
';
echo '
'.$vboxtitle.' ';
echo '
';
$vwordquestlogo = bioship_file_hierarchy('url', 'wordquest.png', $vthemedirs['img']);
echo '
';
echo '
';
// Recommended Plugins
// -------------------
// 1.8.5: added recommended box display
$vrecommended = bioship_file_hierarchy('file', 'recommended.php', array('includes'));
if ($vrecommended) {
include($vrecommended);
$vrecommend = bioship_admin_get_recommended();
if ($vrecommend) {
$vboxid = 'recommended'; $vboxtitle = __('Recommended','bioship');
echo '
';
echo '
'.$vboxtitle.' ';
echo '
';
echo $vrecommend;
echo '
';
}
}
echo '
'; // close extend column
// Right Column - Dashboard Feed Widgets
// -------------------------------------
echo '
';
// 1.8.0: allow turning feeds off if being problematic
$vfeeds = true;
if (isset($_REQUEST['loadfeeds'])) {
$vloadfeeds = $_REQUEST['loadfeeds'];
if ( ($vloadfeeds == 'on') || ($vloadfeeds == '1') ) {delete_option('bioship_admin_feed_display');}
if ( ($vloadfeeds == 'off') || ($vloadfeeds == '0') ) {update_option('bioship_admin_feed_display','off');}
if ( ($vloadfeeds == 'no') || ($vloadfeeds == '2') ) {$vfeeds = false;}
}
if (get_option('bioship_admin_feed_display') == 'off') {$vfeeds = false;}
// BioShip Feed
// ------------
$vboxid = 'bioshipfeed'; $vboxtitle = __('BioShip News','bioship');
if ( ($vfeeds) && (function_exists('muscle_bioship_dashboard_feed_widget')) ) {
echo '
';
echo '
'.$vboxtitle.' ';
echo '
';
echo "";
muscle_bioship_dashboard_feed_widget(false,false);
echo "";
echo '
';
}
// WordQuest Feed
// --------------
$vboxid = 'wordquestfeed'; $boxtitle = __('WordQuest News','bioship');
if ( ($vfeeds) && (function_exists('wqhelper_dashboard_feed_widget')) ) {
echo '
';
echo '
'.$boxtitle.' ';
echo '
';
echo "";
wqhelper_dashboard_feed_widget();
echo "";
echo '
';
}
// PluginReview Feed
// -----------------
$vboxid = 'pluginreviewfeed'; $boxtitle = __('Plugin Reviews','bioship');
if ( ($vfeeds) && (function_exists('wqhelper_pluginreview_feed_widget')) ) {
echo '
';
echo '
'.$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
// ---------------
if (!function_exists('bioship_admin_welcome_message')) {
function bioship_admin_welcome_message() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
}
}
// Documentation Box
// -----------------
// 2.0.5: added documentation link box
if (!function_exists('bioship_admin_documentation_box')) {
function bioship_admin_documentation_box($vwelcome) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__,func_get_args());}
global $vthemetemplateurl;
// Load Docs
include(dirname(__FILE__).'/docs.php');
// Welcome Message
if ($vwelcome) {
// 2.0.7: use new prefixed current user function
$current_user = bioship_get_current_user();
$vfirstname = $current_user->user_firstname;
if ($vfirstname != '') {$vfirstname = ', '.$vfirstname;}
echo '
'.__('Welcome aboard','bioship').$vfirstname.'! ';
echo __('And thanks for choosing to pilot BioShip...','bioship').'
';
}
// QuickStart Section
echo '
'.__('QuickStart Guide','bioship').' ';
echo bioship_docs_quickstart(false);
echo '';
// QuickStart Script
echo "";
// QuickStart Links
$vqslinks = '
';
$vqslinks .= '
';
$vqslinks .= '
';
// Documentation Index
$vdocindex = bioship_docs_index(false);
$vdocindex = str_replace('h3>', 'h4>', $vdocindex);
$vdocindex = str_replace('', '
'.$vqslinks, $vdocindex);
$vdocindex = str_replace('', ' ', $vdocindex);
$vdocindex = str_replace('', '
', $vdocindex);
$vdocindex = str_replace('a href="docs.php?page=', 'a class="doc-thickbox" href="#', $vdocindex);
echo $vdocindex;
// Documentation Thickbox Script
$vdocsurl = $vthemetemplateurl.'admin/docs.php';
echo "";
}
}
// ===================================
// Check for Theme Updates HTML Output
// ===================================
// Echo Theme Updates Available
// ----------------------------
// 2.0.5: for admin_notice section
if (!function_exists('bioship_admin_theme_updates_echo')) {
function bioship_admin_theme_updates_echo() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
$vthemeupdates = bioship_admin_theme_updates_available();
// only show updates if there is user capability for it
if ( ($vthemeupdates != '') && (!strstr($vthemeupdates, '')) ) {
global $wp_version;
if (version_compare($wp_version,'3.8', '<')) {$vnagclass = 'updated';} else {$vnagclass = 'update-nag';} // '>
$vthemeupdates = str_replace('
', ' ', $vthemeupdates);
echo '
';
echo $vthemeupdates.'
';
}
}
}
// Generate Theme Updates Available
// --------------------------------
if (!function_exists('bioship_admin_theme_updates_available')) {
function bioship_admin_theme_updates_available() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $wp_version, $vthemename;
$vthemedisplayname = THEMEDISPLAYNAME;
// 2.0.5: use existing THEMESLUG constant
$vupdatehtml = ''; $vthemeslug = THEMESLUG;
// check user capability just in case
if (!current_user_can('update_themes')) {
if (is_child_theme()) {
$vtheme = wp_get_theme(get_stylesheet($vthemeslug));
$vparenttheme = wp_get_theme(get_template($vtheme['Template']));
$vparentversion = $vparenttheme['Version'];
$vupdatehtml = __('Parent Theme','bioship').':
';
$vupdatehtml .= __('BioShip Framework','bioship').' v'.$vparentversion.'
';
}
// else {$vupdatehtml = __('Theme Framework','bioship').' v'.$vthemeversion.'
';}
// 2.0.5: add hidden capability section for admin notices
$vupdatehtml .= '';
return $vupdatehtml;
}
// note: created from modified WP function get_theme_update_available
$vupdatestransient = get_site_transient('update_themes');
$vupdates = $vupdatestransient->response;
if (THEMEDEBUG) {echo "";}
if (is_child_theme()) {
if (isset($vupdates[$vthemeslug])) {
// special: allow for a user specified Child Theme update location
// ie. by calling a new Theme Updater instance in their Child Theme
$vupdate = $vupdates[$vthemeslug];
$vupdate_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&theme='.urlencode($vthemeslug)), 'upgrade-theme_'.$vthemeslug);
$vupdate_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Warning! Updating this Child Theme will lose any file customizations you have made! 'Cancel' to stop, 'OK' to update.",'bioship') ) . '\') ) {return true;} return false;"';
if (!empty($vupdate['package'])) {
// if ( (!is_multisite()) || ( (is_multisite()) && (current_user_can('manage_network_themes')) ) ) {
$vupdatehtml .= sprintf(__( 'New Child Theme available.
View v%4$s Details or
Update Now .
','bioship' ),
$vthemedisplayname, esc_url($vupdate['url']), esc_attr($vthemedisplayname), $vupdate['new_version'], $vupdate_url, $vupdate_onclick );
// }
}
}
// change the info so the parent theme updates are displayed next
$vtheme = wp_get_theme($vthemeslug);
$vparenttheme = wp_get_theme(get_template($vtheme['Template']));
$vthemeslug = $vparenttheme['Stylesheet'];
$vthemedisplayname = $vparenttheme['Stylesheet'];
$vthemeversion = $vparenttheme['Version'];
$vupdatehtml .= __('Parent Theme','bioship').':
';
$vupdatehtml .= __('BioShip Framework','bioship').' v'.$vthemeversion.'
';
if (THEMEDEBUG) {
echo "";
}
}
// output in either case (child theme parent or base framework)
if (isset($vupdates[$vthemeslug])) {
$vupdate = $vupdates[$vthemeslug];
// 2.0.5: recompare versions (as if theme is updated manually transient will be old!)
if (THEMEDEBUG) {
echo "";
}
if (version_compare($vparenttheme['Version'], $vupdate['new_version'], '<')) { // '>
$vupdate_url = wp_nonce_url(admin_url('update.php?action=upgrade-theme&theme='.urlencode($vthemeslug)), 'upgrade-theme_'.$vthemeslug);
$vupdate_onclick = 'onclick="if ( confirm(\'' . esc_js( __("Updating this Theme Framework will lose any file customizations not in your Child Theme. 'Cancel' to stop, 'OK' to update.",'bioship') ) . '\') ) {return true;} return false;"';
if (!empty($vupdate['package'])) {
// if ( (!is_multisite()) || ( (is_multisite()) && (current_user_can('manage_network_themes')) ) ) {
$vupdatehtml .= sprintf(__('New Framework version available!
v%4$s Details or
Update Now .
','bioship'),
$vthemedisplayname, esc_url($vupdate['url']), esc_attr($vthemedisplayname), $vupdate['new_version'], $vupdate_url, $vupdate_onclick );
// }
}
}
}
return $vupdatehtml;
}
}
// =============================
// One-Click Child Theme Install
// =============================
if (!function_exists('bioship_admin_do_install_child')) {
function bioship_admin_do_install_child() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $wp_filesystem; // load WP Filesystem for correct writing permissions
global $vthemetemplatedir, $vthemestyledir; $vmessage = '';
// match new Child Name, allowing for spaces
$vnewchildname = $_REQUEST['newchildname'];
if ($vnewchildname == '') {return __('Error: Child Theme Name cannot be empty.','bioship');}
if (!preg_match('/^[0-9a-z ]+$/i', $vnewchildname)) {return __('Error. Letters, numbers and spaces only please!','bioship');}
$vnewchildslug = preg_replace("/\W/", "-", strtolower($vnewchildname));
// 1.8.0: use directory separator, added debug dir
$vthemesdir = get_theme_root().DIRSEP;
$vchilddir = $vthemesdir.$vnewchildslug.DIRSEP;
$vchildimagedir = $vchilddir.'images'.DIRSEP;
$vchildcssdir = $vchilddir.'styles'.DIRSEP;
$vchildjsdir = $vchilddir.'javascripts'.DIRSEP;
$vchilddebugdir = $vchilddir.'debug'.DIRSEP;
// keeping child theme files to a minimum here...
// 1.8.0: also copy core-styles.css also to avoid using WP Filesystem for it later
// 1.9.0: no longer copy hooks.php or template.php by default, do copy debug/.htaccess
$vchildfiles = array('style.css','core-styles.css','functions.php','filters.php','screenshot.jpg','theme-logo.png','.htaccess');
// Create Child Theme directory
// ----------------------------
if (is_dir($vchilddir)) {
// Do NOT Continue! We must avoid overwriting an existing Child Theme!
$vmessage = __('Aborted! Child Theme directory of that name already exists!','bioship').'
';
$vmessage .= __('Remove or rename the existing directory and try again.','bioship').'
';
return $vmessage;
}
else {
// 1.8.0: fix for correct directory permissions
// ...the old way
// clearstatcache(); $vpermissions = fileperms(get_template_directory()));
// umask(0000); @mkdir($vchilddir,$vpermissions); @mkdir($vchildimagedir,$vpermissions);
// @mkdir($vchildcssdir,$vpermissions); @mkdir($vchildjsdir,$vpermissions); @mkdir($vchilddebugdir,$vpermissions);
// ...the easier way
// wp_mkdir_p($vchilddir); wp_mkdir_p($vchildimagedir); wp_mkdir_p($vchildcssdir);
// wp_mkdir_p($vchildjsdir); wp_mkdir_p($vchilddebugdir);
// the WP Filesystem way
$wp_filesystem->mkdir($vchilddir);
if (!is_dir($vchilddir)) {
$vmessage = __('Aborted: Could not create Child Theme directory.','bioship').'
';
$vmessage .= __('Check your permissions or do a','bioship').'
'.__('manual install','bioship').' .';
return $vmessage;
}
$wp_filesystem->mkdir($vchildimagedir);
$wp_filesystem->mkdir($vchildcssdir);
$wp_filesystem->mkdir($vchildjsdir);
$wp_filesystem->mkdir($vchilddebugdir);
}
// Copy Child Theme files
// ----------------------
$vmissingfiles = array();
foreach ($vchildfiles as $vchildfile) {
// 1.8.5: change 'child-source' directory to 'child'
// 1.9.0: no longer copy hooks.php by default, but copy .htaccess
// 1.9.5: fix to new child theme file destination directories
// exceptions: core-styles.css in css folder, .htaccess is in debug dir
if ($vchildfile == 'core-styles.css') {$vchildsource = $vthemetemplatedir.'styles'.DIRSEP; $vchilddest = $vchildcssdir;}
elseif ($vchildfile == '.htaccess') {$vchildsource = $vthemetemplatedir.'debug'.DIRSEP; $vchilddest = $vchilddebugdir;}
else {$vchildsource = $vthemetemplatedir.'child'.DIRSEP; $vchilddest = $vchilddir;}
// echo $vchildsource.$vchildfile.PHP_EOL; // debug point
if (file_exists($vchildsource.$vchildfile)) {
// 1.8.0: read files using WP Filesystem
$vfilecontents = $wp_filesystem->get_contents($vchildsource.$vchildfile);
// replace the default Child Theme name with the New one in style.css
if ($vchildfile == 'style.css') {
$vfilecontents = str_replace('Theme Name: BioShip Child', 'Theme Name: '.$vnewchildname, $vfilecontents);
// 1.9.5: match the child theme version to the parent version on creation
$vfilecontents = str_replace('1.0.0', THEMEVERSION, $vfilecontents);
}
// 1.8.0: write the file using WP_Filesystem
$wp_filesystem->put_contents($vchilddest.$vchildfile, $vfilecontents, FS_CHMOD_FILE);
}
else {$vmissingfiles[] = $vchildfile;}
}
// 1.8.5: change 'child-source' directory to 'child'
// 2.0.7: fix to changed variable typo (vmissing)
if (count($vmissingfiles) > 0) {
$vmessage .= __('Error: Child Theme source files missing','bioship').':
';
foreach ($vmissingfiles as $vmissingfile) {
// 1.9.5: display correct paths for .htaccess and core-styles.css here too
if ($vmissingfile == '.htaccess') {$vmessage .= '/bioship/debug/'.$vmissingfile.'
';}
elseif ($vmissingfile == 'core-styles.css') {$vmessage .= '/bioship/styles/'.$vmissingfile.'
';}
else {$vmessage .= '/bioship/child/'.$vmissingfile.'
';}
}
}
// Copy existing Parent Theme options to new Child Theme
// -----------------------------------------------------
$vsettingsmessage = '';
// 1.8.0: do check for Titan Framework
// 1.9.5: fix to parent settings framework logic
if (THEMEOPT) {$vparentsettings = get_option('bioship'); $vchildoptionsslug = str_replace('-', '_', $vnewchildslug);}
else {$vparentsettings = get_option('bioship_options'); $vchildoptionsslug = $vnewchildslug.'_options';}
$vexistingsettings = get_option($vchildoptionsslug);
if (!$vexistingsettings) {
delete_option($vchildoptionsslug);
if ( (!$vparentsettings) || ($vparentsettings == '') ) {
// 1.9.5: set to default theme options
$vdefaultsettings = bioship_titan_theme_options(array());
add_option($vchildoptionsslug,$vdefaultsettings);
$vsettingsmessage .= __('No Parent Theme settings! Child Theme set to default settings.','bioship').'
';
$vsettingsmessage .= __('See documentation to manually transfer settings between themes.','bioship').'
';
}
else {
add_option($vchildoptionsslug,$vparentsettings);
$vsettingsmessage .= __('Parent Theme settings transferred to new Child Theme.','bioship').'
';
}
} else {$vmessage .= __('Child Theme settings exist, Parent Theme settings not transferred.','bioship').'
';}
// 1.5.0: copy parent widgets and menus to child theme 'backups'
// in preparation for activation, including menu locations
$vsidebarswidgets = get_option('sidebars_widgets');
$vnavmenus = get_option('nav_menu_options');
$vmenulocations = get_theme_mod('nav_menu_locations');
if (!get_option($vchildoptionsslug.'_widgets_backup')) {
delete_option($vchildoptionsslug.'_widgets_backup');
add_option($vchildoptionsslug.'_widgets_backup', $vsidebarswidgets);
}
if (!get_option($vchildoptionsslug.'_menus_backup')) {
delete_option($vchildoptionsslug.'_menus_backup');
add_option($vchildoptionsslug.'_menus_backup', $vnavmenus);
}
if (!get_option($vchildoptionsslug.'_menu_locations_backup')) {
delete_option($vchildoptionsslug.'_menu_locations_backup');
add_option($vchildoptionsslug.'_menu_locations_backup', $vmenulocations);
}
// Set Child Creation Output Message
// ---------------------------------
// 1.8.0: added translation strings to messages
if ($vmessage != '') {$vcreationresult = '('.__('with errors','bioship').')';}
else {$vcreationresult = __('successfully','bioship').'';}
$vmessage .= $vsettingsmessage;
$vmessage .= __('New Child Theme','bioship').' "'.$vnewchildname.'" '.__('created','bioship').' '.$vcreationresult.'.
';
$vmessage .= __('Base Directory','bioship').': '.ABSPATH.'
';
$vmessage .= __('Theme Subdirectory','bioship').': '.str_replace(ABSPATH, '', $vchilddir).'
';
$vmessage .= __('Activate it on your','bioship').'
'.__('Themes Page','bioship').' .';
// One-Click Activation for New Child Theme
// ----------------------------------------
$vwpnonce = wp_create_nonce('switch-theme_'.$vnewchildslug);
$vactivatelink = 'themes.php?action=activate&stylesheet='.$vnewchildslug.'&_wpnonce='.$vwpnonce;
$vmessage .= '... '.__('or just','bioship').'
'.__('click here to activate it','bioship').' .';
if (function_exists('themedrive_determine_theme')) {
// 1.8.0: link for Titan or Options Framework
// CHECKME:
if (THEMETITAN) {$vchildthemeoptions = 'admin.php?page=bioship_options&theme='.$vnewchildslug;}
else {$vchildthemeoptions = 'themes.php?page=options-framework&theme='.$vnewchildslug;}
$vmessage .= '
('.__('or','bioship').'
'.__('Theme Test Drive options without activating','bioship').' .)';
}
return $vmessage;
}
}
// Clone Child Theme
// -----------------
// 1.9.5: added child theme cloning function
if (!function_exists('bioship_admin_do_install_clone')) {
function bioship_admin_do_install_clone() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $wp_filesystem;
if (!isset($_REQUEST['clonetheme'])) {return __('Error: Source Child Theme not specified.','bioship');}
elseif ($_REQUEST['clonetheme'] == '') {return __('Error: Source Child Theme not specified.','bioship');}
else {$vclonetheme = $_REQUEST['clonetheme'];}
if (THEMEOPT) {$vclonesettings = get_option($vclonetheme);}
else {$vclonesettings = get_option($vclonetheme.'_options');}
if (!$vclonesettings) {return __('Error: Source Child Theme Settings are empty!','bioship');}
$vtheme = wp_get_theme(get_stylesheet($vclonetheme));
if ( (!isset($vtheme['Template'])) || ($vtheme['Template'] != 'bioship') ) {
return __('Cloning Aborted! Child Theme parent must be BioShip!','bioship');
}
$vnewclonename = $_REQUEST['newclonename'];
if ($vnewclonename == '') {return __('Error: New Child Theme Name cannot be empty.','bioship');}
if (!preg_match('/^[0-9a-z ]+$/i', $vnewclonename)) {return __('Error. Letters, numbers and spaces only please!','bioship');}
$vnewcloneslug = preg_replace("/\W/", "-",strtolower($vnewclonename));
if (get_option($vnewcloneslug)) {return __('Aborted! Theme Settings already exist for this name!','bioship');}
$vthemesdir = get_theme_root().DIRSEP;
$vchilddir = $vthemesdir.$vclonetheme.DIRSEP;
$vclonedir = $vthemesdir.$vnewcloneslug.DIRSEP;
if (!is_dir($vchilddir)) {return __('Aborted! Source Child Theme directory does not exist!','bioship');}
if (is_dir($vclonedir)) {
// Do NOT Continue! We must avoid overwriting an existing Child Theme!
$vmessage = __('Aborted! Child Theme directory of that name already exists!','bioship').'
';
$vmessage .= __('Remove or rename the existing directory and try again.','bioship').'
';
return $vmessage;
}
// get and copy all the child theme files to the clone directory recursively...
$vchildfiles = bioship_admin_get_directory_files($vchilddir,true);
foreach ($vchildfiles as $vchildfile) {
$vsourcefile = $vchilddir.$vchildfile; $vdestfile = $vclonedir.$vchildfile;
echo "".PHP_EOL;
if (!is_dir(dirname($vdestfile))) {$wp_filesystem->mkdir(dirname($vdestfile));}
$vfilecontents = $wp_filesystem->get_contents($vsourcefile);
if (substr($vsourcefile,-9,9) == 'style.css') {
$vfilecontents = str_replace('Theme Name: '.THEMEDISPLAYNAME,'Theme Name: '.$vnewclonename,$vfilecontents);
}
$wp_filesystem->put_contents($vdestfile,$vfilecontents,FS_CHMOD_FILE);
}
// oh why not, copy any empty subdirectories too
$vsubdirs = bioship_admin_get_directory_subdirs($vchilddir,true);
echo "";
foreach ($vsubdirs as $vsubdir) {
$vdestdir = $vclonedir.$vsubdir;
if (!is_dir($vdestdir)) {$wp_filesystem->mkdir($vdestdir);}
}
// add a clone stamp file
global $current_user; $current_user = wp_get_current_user();
$vfilecontents = 'Cloned from existing Child Theme: '.THEMEDISPLAYNAME.' ('.$vclonetheme.')'.PHP_EOL;
$vfilecontents .= 'on '.date('d/m/Y').' (timestamp: '.time().') by '.$current_user->user_login.PHP_EOL;
$vfilecontents .= 'Serialized Settings at Clone time after this line ------'.PHP_EOL;
if (is_serialized($vclonesettings)) {$vfilecontents .= $vclonesettings;} else {$vfilecontents .= serialize($vclonesettings);}
$vdestfile = $vclonedir.'clonestamp.txt';
$wp_filesystem->put_contents($vdestfile, $vfilecontents, FS_CHMOD_FILE);
// copy child theme settings
if (THEMEOPT) {$vnewclonekey = $vnewcloneslug;} else {$vnewclonekey = $vnewcloneslug.'_options';}
delete_option($vnewclonekey); add_option($vnewclonekey, $vclonesettings);
// copy all widget / sidebar settings (from active or backups)
if ($vclonetheme == get_stylesheet()) {
$vsidebarswidgets = get_option('sidebars_widgets');
$vnavmenus = get_option('nav_menu_options');
$vmenulocations = get_theme_mod('nav_menu_locations');
} else {
$vsidebarswidgets = get_option($vclonetheme.'_widgets_backup');
$vnavmenus = get_option($vclonetheme.'_menus_backup');
$vmenulocations = get_option($vclonetheme.'_menu_locations_backup');
}
// assume that if the new clone settings were empty / deleted
// copying over these is safe / wanted as well
delete_option($vnewcloneslug.'_widgets_backup');
add_option($vnewcloneslug.'_widgets_backup',$vsidebarswidgets);
delete_option($vnewcloneslug.'_menus_backup');
add_option($vnewcloneslug.'_menus_backup',$vnavmenus);
delete_option($vnewcloneslug.'_menu_locations_backup');
add_option($vnewcloneslug.'_menu_locations_backup',$vmenulocations);
// set Clone Creation Output Message
$vmessage = __('New Child Theme','bioship').' "'.$vnewclonename.'" '.__('cloned successfully.','bioship').'
';
$vmessage .= __('Base Directory','bioship').': '.ABSPATH.'
';
$vmessage .= __('Theme Subdirectory','bioship').': '.str_replace(ABSPATH,'',$vclonedir).'
';
$vmessage .= __('Activate it on your','bioship').'
'.__('Themes Page','bioship').' .';
// One-Click Activation for New Cloned Theme
$vwpnonce = wp_create_nonce('switch-theme_'.$vnewcloneslug);
$vactivatelink = 'themes.php?action=activate&stylesheet='.$vnewcloneslug.'&_wpnonce='.$vwpnonce;
$vmessage .= '... '.__('or just','bioship').'
'.__('click here to activate it','bioship').' .';
if (function_exists('themedrive_determine_theme')) {
if (THEMETITAN) {$vclonethemeoptions = 'admin.php?page=bioship-options&theme='.$vnewcloneslug;}
else {$vclonethemeoptions = 'themes.php?page=options-framework&theme='.$vnewcloneslug;}
$vmessage .= '
('.__('or','bioship').'
'.__('Theme Test Drive options without activating','bioship').' .)';
}
$vmessage .= ""; // result indicator
return $vmessage;
}
}
// Check WP Filesystem Credentials
// -------------------------------
// 1.8.0: for Child Theme creation to pass Theme Check
// ref: http://ottopress.com/2011/tutorial-using-the-wp_filesystem/
// ref: http://www.webdesignerdepot.com/2012/08/wordpress-filesystem-api-the-right-way-to-operate-with-local-files/
if (!function_exists('bioship_admin_check_filesystem_credentials')) {
function bioship_admin_check_filesystem_credentials($vurl, $vmethod, $vcontext, $vextrafields) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $wp_filesystem;
if (empty($wp_filesystem)) {require_once(ABSPATH.'/wp-admin/includes/file.php'); WP_Filesystem();}
$vcredentials = request_filesystem_credentials($vurl, $vmethod, false, $vcontext, $vextrafields);
if ($vcredentials === false) {return false;}
if (!WP_Filesystem($vcredentials)) {request_filesystem_credentials($vurl, $vmethod, true, $vcontext, $vextrafields); return false;}
return true;
}
}
// Get Directory File List with Recursion
// --------------------------------------
if (!function_exists('bioship_admin_get_directory_files')) {
function bioship_admin_get_directory_files($dir, $recursive = true, $basedir = '') {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
if ($dir == '') {return array();} else {$results = array(); $subresults = array();}
if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent
if ($basedir == '') {$basedir = realpath($dir).DIRSEP;}
$files = scandir($dir);
foreach ($files as $key => $value){
if ( ($value != '.') && ($value != '..') ) {
$path = realpath($dir.DIRSEP.$value);
if (is_dir($path)) { // do not combine with the next line or
if ($recursive) { // non-recursive file list includes subdirs
$subdirresults = bioship_admin_get_directory_files($path, $recursive, $basedir);
$results = array_merge($results, $subdirresults);
unset($subdirresults);
}
} else { // strip basedir and add to subarray to separate list
$subresults[] = str_replace($basedir, '', $path);
}
}
}
// merge the subarray to give list of files first, then subdirectory files
if (count($subresults) > 0) {
$results = array_merge($subresults, $results); unset($subresults);
}
return $results;
}
}
// Get Directory SubDirs Recursion
// -------------------------------
if (!function_exists('bioship_admin_get_directory_subdirs')) {
function bioship_admin_get_directory_subdirs($dir, $recursive = true, $basedir = '') {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
if ($dir == '') {return array();} else {$results = array(); $subresults = array();}
if (!is_dir($dir)) {$dir = dirname($dir);} // so a files path can be sent
if ($basedir == '') {$basedir = realpath($dir).DIRSEP;}
$files = scandir($dir);
foreach ($files as $key => $value){
if ( ($value != '.') && ($value != '..') ) {
$path = realpath($dir.DIRSEP.$value);
if (is_dir($path)) {
$results[] = str_replace($basedir,'',$path);
if ($recursive) {
$subdirresults = bioship_admin_get_directory_subdirs($path, $recursive, $basedir);
$results = array_merge($results, $subdirresults);
}
}
}
}
return $results;
}
}
// =========================
// Build Selective Resources
// =========================
// Trigger Build Selective CSS and JS
// ----------------------------------
// this method is for Options Framework
if ( (isset($_GET['page'])) && (isset($_GET['settings-updated'])) ) {
if ( ($_GET['page'] == 'options-framework') && ($_GET['settings-updated'] == 'true') ) {
add_action('admin_notices', 'bioship_admin_build_selective_resources');
}
}
// 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') ) {
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');
// Build Selective CSS and JS
// --------------------------
if (!function_exists('bioship_admin_build_selective_resources')) {
function bioship_admin_build_selective_resources() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $vthemename, $vthemesettings, $vthemedirs;
// Maybe Combine CSS Core On Save
// ------------------------------
if ($vthemesettings['combinecsscore']) {
// reset.css or normalize.css
$vresetoption = $vthemesettings['cssreset'];
if ($vresetoption == 'normalize') {
$vcssfile = bioship_file_hierarchy('file', 'normalize.css', $vthemedirs['css']);
if ($vcssfile) {$vcssreset = bioship_file_get_contents($vcssfile);}
else {echo "
".__('Warning','bioship')." : ".__('CSS Combine could not find','bioship')."
normalize.css ";}
}
if ($vresetoption == 'reset') {
$vcssfile = bioship_file_hierarchy('file', 'reset.css', $vthemedirs['css']);
if ($vcssfile) {$vcssreset = bioship_file_get_contents($vcssfile);}
else {echo "
".__('Warning','bioship')." : ".__('CSS Combine could not find','bioship')."
reset.css ";}
}
// formalize.css
if ($vthemesettings['loadformalize']) {
$vcssfile = bioship_file_hierarchy('file', 'formalize.css', $vthemedirs['css']);
if ($vcssfile) {$vformalize = bioship_file_get_contents($vcssfile);}
else {echo "
".__('Warning','bioship')." : ".__('CSS Combine could not find','bioship')."
formalize.css ";}
}
// mobile.css (previously misnamed layout.css)
$vcssfile = bioship_file_hierarchy('file', 'mobile.css', $vthemedirs['css']);
if ($vcssfile) {$vlayout = bioship_file_get_contents($vcssfile);}
else {echo "
".__('Warning','bioship')." : ".__('CSS Combine could not find','bioship')."
mobile.css ";}
// 1.5.0: these stylesheets are deprecated by grid.php
// skeleton-960.css, skeleton-1120.css, skeleton-1200.css
// skeleton.css (note: this must be *last*, or CSS breaks!?)
$vcssfile = bioship_file_hierarchy('file', 'skeleton.css', $vthemedirs['css']);
if ($vcssfile) {$vskeleton = bioship_file_get_contents($vcssfile);}
else {echo "
".__('Warning','bioship')." : ".__('CSS Combine could not find','bioship')."
skeleton.css ";}
// ...style.css (intentionally not added as breaks stylesheet!)
// ...custom.css (intentionally kept separate here also)
$vcsscontents = $vcssreset.PHP_EOL.PHP_EOL.$vformalize.PHP_EOL.PHP_EOL;
$vcsscontents .= $vlayoutwidth.PHP_EOL.PHP_EOL.$vlayout.PHP_EOL.PHP_EOL;
$vcsscontents .= $vskeleton.PHP_EOL.PHP_EOL.$vstyle.PHP_EOL.PHP_EOL;
$vdatetime = date('H:i:s d/m/Y');
$vcsscontents .= '/* Last Updated: '.$vdatetime.' */';
// note: combined core CSS file written 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
$vcssfile = get_stylesheet_directory($vthemename).DIRSEP.'css'.DIRSEP.'core-styles.css';
if (file_exists($vcssfile)) {bioship_write_to_file($vcssfile, $vcsscontents);}
}
// Build Selective Foundation Javascripts on Save
// -----------------------------------------------
// TODO: build selectives for Foundation 6, this currently only works for Foundation 5
// $vfoundation = $vthemesettings['foundationversion'];
$vfoundation = 'foundation5'; // currently available for Foundation 5 only
if ($vthemesettings['loadfoundation'] == 'selective') {
$vmessage = '';
$vjsfile = bioship_file_hierarchy('file', 'foundation.js', array('javascripts','includes/'.$vfoundation.'/js/foundation'));
$vfoundationjs = bioship_file_get_contents($vjsfile);
$vselected = $vthemesettings['foundationselect'];
foreach ($vselected as $vkey => $vvalue) {
if ($vvalue == '1') {
$vfilename = 'foundation.'.$vkey.'.js';
$vfoundationsourcedir = 'includes/'.$vfoundation.'/js/foundation';
$vjsfile = bioship_file_hierarchy('file', $vfilename, array($vfoundationsourcedir));
if ($vjsfile) {
$vjsdata = bioship_file_get_contents($vjsfile);
// 2.0.7: doubly ensure new line consistency for Theme Check
$vjsdata = str_replace("\r\n", "\n", $vjsdata);
$vfoundationjs .= $vjsdata;
// 1.5.5: fix, use specific matching EOL to pass Theme Check
$vfoundationjs .= "\n"."\n";
}
else {$vmessage .= "
".__('Warning','bioship')." : ".__('Foundation JS Combine could not find','bioship')."
".$vfilename." ";}
}
}
// 1.8.0: added admin warning for missing resources
if ($vmessage != '') {
global $vadminmessages; $vadminmessages[] = $vmessage;
bioship_admin_notices_enqueue();
}
if (strlen($vfoundation) > 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
$vselectedjs = get_template_directory($vthemename).DIRSEP.'javascripts'.DIRSEP.'foundation.selected.js';
bioship_write_to_file($vselectedjs, $vfoundationjs);
}
}
}
}
// ===================
// === Theme Tools ===
// ===================
// Backup/Restore/Import/Export Theme Settings
// Note: No Tracers added to theme tools functions (seems pointless.)
// 1.9.5: changed usage of 'options' to 'settings'
// note: some possible manual querystring usage
// ?backup_theme_settings=yes or admin-ajax.php?action=backup_theme_settings
// ?restore_theme_settings=yes (manual usage deprecated - as requires nonce check)
// ?export_theme_settings=yes or admin-ajax.php?action=export_theme_settings
// ?import_theme_settings=yes (manual usage deprecated - as requires nonce check)
// ?revert_theme_settings=yes (revert to pre-import - manual deprecated requires nonce)
// -----------------
// Theme Tools Forms
// -----------------
// for backup / restore / export / import / revert
// note: AJAX action for backup / export, post refresh for restore / import / revert
if (!function_exists('bioship_admin_theme_tools_forms')) {
function bioship_admin_theme_tools_forms() {
global $vthemesettings, $vthemename;
// Theme Tools Javascript
// ----------------------
$vconfirmrestore = __('Are you sure you want to Restore the Theme Settings Backup?','bioship');
$vconfirmimport = __('Are you sure you want to Import these Theme Settings?','bioship');
$vconfirmrevert = __('Are you sure you want to Revert to Theme Settings prior to Import?','bioship');
$vadminajax = admin_url('admin-ajax.php');
$vactionurl = add_query_arg('page', $_REQUEST['page'], admin_url('admin.php'));
if ( (isset($_REQUEST['theme'])) && ($_REQUEST['theme'] != '') ) {
$vactionurl = add_query_arg('theme', $_REQUEST['theme'], $vactionurl);
}
echo "";
// Theme Tools Form Interface
// --------------------------
echo "
";
// Theme Tools Iframe
// ------------------
echo "
";
}
}
// -------------------------------
// Backup / Restore Theme Settings
// -------------------------------
// Backup via URL querystring or Theme Tools UI
// Restore via Theme Tools UI (requires nonce)
// Backup Theme Options
// --------------------
if (!function_exists('bioship_admin_backup_theme_settings')) {
function bioship_admin_backup_theme_settings() {
$vcurrentsettings = maybe_unserialize(get_option(THEMEKEY));
$vcurrentsettings['backuptime'] = time();
$vbackupkey = THEMEKEY.'_user_backup';
delete_option($vbackupkey); add_option($vbackupkey, $vcurrentsettings);
}
}
// Backup Triggers
// ---------------
add_action('wp_ajax_backup_theme_settings', 'bioship_admin_do_backup_theme_settings');
if ( (isset($_REQUEST['backup_theme_settingss'])) && ($_REQUEST['backup_theme_setttings'] == 'yes') ) {
// 2.0.7: merged repetitive trigger function and use add_action
add_action('init', 'bioship_admin_do_backup_theme_settings');
}
if (!function_exists('bioship_admin_do_backup_theme_settings')) {
function bioship_admin_do_backup_theme_settings() {
if (current_user_can('edit_theme_options')) {
bioship_admin_backup_theme_settings();
$vmessage = __('Current Theme Settings User Backup has been Created!','bioship');
if (defined('DOING_AJAX') && DOING_AJAX) {
echo ""; exit;
} else {
global $vadminmessages; $vadminmessages[] = $vmessage;
bioship_admin_notices_enqueue();
}
}
}
}
// Restore Theme Settings
// ----------------------
if (!function_exists('bioship_admin_restore_theme_settings')) {
function bioship_admin_restore_theme_settings() {
// 1.8.5: fix to incorrect restoretime application
$vcurrentsettings = maybe_unserialize(get_option(THEMEKEY));
$vbackupkey = THEMEKEY.'_user_backup';
$vbackupsettings = maybe_unserialize(get_option($vbackupkey));
$vbackupsettings['restoretime'] = time();
// switch not delete, so as to backs up 'current' options (if not empty)
// 1.9.5: define constant to not trigger force update filter
// 2.0.7: fix by deleting the force update transient and removing filter
delete_transient('force_update_'.THEMEKEY);
remove_filter('pre_option_'.THEMEKEY, 'bioship_get_theme_settings', 10, 2);
delete_option(THEMEKEY); add_option(THEMEKEY, $vbackupsettings);
if ( ($vcurrentsettings != '') && (is_array($vcurrentsettings)) ) {
$vcurrentsettings['backuptime'] = time();
delete_option($vbackupkey); add_option($vbackupkey, $vcurrentsettings);
}
// 1.9.5: update global to continue
global $vthemesettings; $vthemesettings = $vbackupsettings;
}
}
// Restore Trigger
// ---------------
// 1.8.5: added nonce check
if ( (isset($_POST['restore_theme_settings'])) && ($_POST['restore_theme_settings'] == 'yes') ) {
if (current_user_can('edit_theme_options')) {
global $vthemename;
check_admin_referer('restore_theme_settings_'.$vthemename);
bioship_admin_restore_theme_settings();
$vmessage = __('Theme Settings Backup Restored! (You can switch back by using this method again.)','bioship');
global $vadminmessages; $vadminmessages[] = $vmessage;
bioship_admin_notices_enqueue();
}
}
// ----------------------------
// Export/Import Theme Settings
// ----------------------------
// 1.5.0: added export/import/revert triggers
// 1.8.0: changed prefix from muscle to bioship_admin, and restorepreimport to revert
// Export Action Triggers
// ----------------------
add_action('wp_ajax_export_theme_settings', 'bioship_admin_export_theme_settings');
if ( (isset($_REQUEST['export_theme_settings'])) && ($_REQUEST['export_theme_settings'] == 'yes') ) {
add_action('init', 'bioship_admin_export_theme_settings');
}
// Import/Revert Action Triggers
// -----------------------------
if ( (isset($_POST['import_theme_settings'])) && ($_POST['import_theme_settings'] == 'yes') ) {
add_action('init', 'bioship_admin_import_theme_settings');
}
if ( (isset($_POST['revert_theme_settings'])) && ($_POST['revert_theme_settings'] == 'yes') ) {
add_action('init', 'bioship_admin_revert_theme_settings');
}
// Export Theme Settings
// ---------------------
// 1.8.0: renamed from muscle_export_theme_options
// 2.0.7: added serialized format export option
if (!function_exists('bioship_admin_export_theme_settings')) {
function bioship_admin_export_theme_settings() {
if (!current_user_can('edit_theme_options')) {return;}
global $vthemename, $vthemesettings, $vthemestyledir;
// check_admin_referer('export_theme_settings_'.$vthemename);
// add the export time to the array
$vthemesettings['exporttime'] = time();
// print_r($vthemesettings);
$vformat = '';
if (isset($_REQUEST['format'])) {$vformat = $_REQUEST['format'];}
if ($vformat == '') {$vformat = 'json';}
// set the filename
$vdate = date('Y-m-d--H:i:s',time());
$vfilename = $vthemename.'_options--'.$vdate.'.'.$vformat;
if ($vformat == 'json') {
// convert array to JSON data
$vexport = json_encode($vthemesettings);
$vcontenttype = 'text/json';
} elseif ($vformat == 'ser') {
// convert to serialized string
$vexport = serialize($vthemesettings);
$vcontenttype = 'text/plain';
} elseif ($vformat == 'xml') {
// create an XML document
$vxml = new SimpleXMLElement('
');
bioship_admin_array_to_xml($vxml, $vthemesettings);
$vexport = $vxml->asXML();
$vcontenttype = 'text/xml';
// print_r($vexport); exit;
// also add line breaks to make it readable?
// FIXME: this is *not* working any more :-(
// $vdom = new DOMDocument();
// $vdom->formatOutput = true;
// $vdom->loadXML($vexport);
// $vexport = $vdom->saveXML();
// print_r($vexport); exit;
// for export debugging
// $vnewthemeoptions = bioship_admin_xml_to_array($vexportxml);
// print_r($vnewthemeoptions);
// $vdiff = array_diff($vnewthemeoptions,$vthemesettings);
// print_r($vdiff);
}
// save generated export file
$vexportfile = $vthemestyledir.'debug'.DIRSEP.$vfilename;
bioship_write_to_file($vexportfile, $vexport);
// output the XML (force download)
header('Content-disposition: attachment; filename="'.$vfilename.'"');
header('Content-type: '.$vcontenttype);
echo $vexport; exit;
}
}
// Import Theme Settings
// ---------------------
// 1.8.0: renamed from muscle_import_theme_options
if (!function_exists('bioship_admin_import_theme_settings')) {
function bioship_admin_import_theme_settings() {
if (!current_user_can('edit_theme_options')) {return;}
global $vthemename, $vthemesettings;
check_admin_referer('import_theme_settings_'.$vthemename);
bioship_admin_notices_enqueue();
if ($_POST['importmethod'] == 'textarea') {
// import from textarea
$vimportdata = stripslashes(trim($_POST['importtextarea']));
// if (THEMEDEBUG) {echo "";}
if ( (substr($vimportdata,0,1) == '<') && (substr($vimportdata,-1,1) == '>') ) {$vformat = 'xml';}
elseif ( (substr($vimportdata,0,1) == '{') && (substr($vimportdata,-1,1) == '}') ) {$vformat = 'json';}
elseif (is_serialized($vimportdata)) {$vformat = 'serial';}
if (THEMEDEBUG) {echo "";}
if ($vformat == 'json') {
// JSON validator ref: http://stackoverflow.com/a/15198925/5240159
// convert JSON to an array
$vnewthemeoptions = json_decode($vimportdata, true);
} elseif ($vformat == 'xml') {
// convert the XML to an array
$vnewthemeoptions = bioship_admin_xml_to_array($vimportdata);
} elseif ($vformat == 'serial') {
// 2.0.7: unserialize serialized data
$vnewthemeoptions = unserialize($vimportdata);
} else {
// format not recognized error
$vmessage = __('Failed: format not recognized. Please upload valid XML, JSON or Serialized data.','bioship');
}
}
elseif ($_POST['importmethod'] == 'fileupload') {
// import from file upload
$vverifyupload = bioship_admin_verify_file_upload('importthemeoptions');
if (is_wp_error($vverifyupload)) {
$vmessage = __('Upload Error','bioship').": ".$vverifyupload->get_error_message."');";
} else {
$vformat = strtolower($vverifyupload['type']);
$vdata = $vverifyupload['data'];
if (THEMEDEBUG) {echo "";}
if ($vformat == 'json') {$vnewthemeoptions = json_decode($vdata, true);}
elseif ($vformat == 'xml') {$vnewthemeoptions = bioship_admin_xml_to_array($vdata);}
elseif (is_serialized($vdata)) {$vnewthemeoptions = unserialize($vdata);}
}
}
if (THEMEDEBUG) {echo "<-- Uploaded Theme Options: "; print_r($vnewthemeoptions); echo " -->";}
if ( ($vnewthemeoptions) && (is_array($vnewthemeoptions)) ) {
// 2.0.7: fix by deleting the force update transient and removing filter
delete_transient('force_update_'.THEMEKEY);
remove_filter('pre_option_'.THEMEKEY, 'bioship_get_theme_settings', 10, 2);
// add the import time to the array
$vnewthemeoptions['importedtime'] = time();
// backup the existing theme options
$vbackupkey = THEMEKEY.'_import_backup';
delete_option($vbackupkey); add_option($vbackupkey, $vthemesettings);
// 1.8.5: allow selective import, only override new values found
$vchanged = false;
foreach ($vnewthemeoptions as $voptionkey => $voptionvalue) {
if ( (!is_array($voptionvalue)) || (!isset($vthemesettings[$voptionkey])) ) {
$vthemesettings[$voptionkey] = $voptionvalue; $vchanged = true;
} elseif (is_array($voptionvalue)) {
foreach ($voptionvalue as $vsuboptionkey => $vsuboptionvalue) {
$vthemesettings[$voptionkey][$vsuboptionkey] = $vsuboptionvalue;
if (!$vchanged) {$vchanged = true;}
}
}
}
if ($vchanged) {
// change to the newly imported theme options
delete_option(THEMEKEY); add_option(THEMEKEY, $vthemesettings);
$vmessage = __('Theme Settings have been Imported successfully!','bioship');
} else {$vmessage = __('No changed Theme Settings detected in import!','bioship');}
} else {$vmessage = __('Could not convert import data to Theme Settings array.','bioship');}
// 1.9.5: add theme admin message
global $vadminmessages; $vadminmessages[] = $vmessage;
// echo ""; exit;
if (THEMEDEBUG) {
echo "";
ob_start(); print_r($vnewthemeoptions); echo PHP_EOL; print_r($vthemesettings);
$vdebugdata = ob_get_contents(); ob_end_clean();
bioship_write_debug_file('file-upload-import.txt', $vdebugdata);
}
}
}
// Revert to pre-Import Backup
// ---------------------------
// 1.8.0: renamed from muscle_restore_preimport_theme_options
if (!function_exists('function bioship_admin_revert_theme_settings')) {
function bioship_admin_revert_theme_settings() {
if (!current_user_can('edit_theme_options')) {return;}
global $vthemename, $vthemesettings;
check_admin_referer('revert_theme_settings_'.$vthemename);
// switch the preimport backup and existing options
$vbackupkey = THEMEKEY.'_import_backup';
$vbackupoptions = get_option($vbackupkey);
// 2.0.7: fix by deleting the force update transient and removing filter
delete_transient('force_update_'.THEMEKEY);
remove_filter('pre_option_'.THEMEKEY, 'bioship_get_theme_settings', 10, 2);
if ( (!empty($backupoptions)) && (is_array($vbackupoptions)) ) {
delete_option(THEMEKEY); add_option(THEMEKEY, $vbackupoptions);
delete_option($vbackupkey); add_option($vbackupkey, $vthemesettings);
$vmessage = __('Pre-Import Theme Settings have been reverted.','bioship')."
";
$vmessage .= __('(You can switch back to the Imported Settings by using this method again.)','bioship');
} else {
$vmessage = __('Revert Failed! Pre-Import Theme Settings are empty or corrupt!','bioship');
}
// 2.0.5: enqueue admin notice message
global $vadminmessages; $vadminmessages[] = $vmessage;
bioship_admin_notices_enqueue();
}
}
// Array to XML Function (for Export)
// ----------------------------------
// ref: http://stackoverflow.com/questions/1397036/how-to-convert-array-to-simplexml
// answer used: http://stackoverflow.com/a/19987539/5240159
if (!function_exists('bioship_admin_array_to_xml')) {
function bioship_admin_array_to_xml(SimpleXMLElement $vobject, array $vdata) {
foreach ($vdata as $vkey => $vvalue) {
if (is_array($vvalue)) {
$vnewobject = $vobject->addChild($vkey);
bioship_admin_array_to_xml($vnewobject, $vvalue);
}
else {
// added: htmlspecialchars
$vobject->addChild($vkey, htmlspecialchars($vvalue));
}
}
}
}
// XML to Array Function (for Import)
// ----------------------------------
// ref: http://stackoverflow.com/questions/6578832/how-to-convert-xml-into-array-in-php
if (!function_exists('bioship_admin_xml_to_array')) {
function bioship_admin_xml_to_array($vxml) {
$vthemesettings = json_decode(json_encode((array)simplexml_load_string($vxml)),1);
// do htmlspecialchars_decode 2 levels deep
// 1.8.5: okay, make that 3 levels deep then
foreach ($vthemesettings as $vkey => $vvalue) {
if (!is_array($vvalue)) {
$vthemesettings[$vkey] = htmlspecialchars_decode($vvalue);
} elseif ($vvalue == array()) {
// no non-set array values thanks
$vthemesettings[$vkey] = '';
} else {
foreach ($vvalue as $vsubkey => $vsubvalue) {
if (!is_array($vsubvalue)) {$vthemesettings[$vkey][$vsubkey] = htmlspecialchars_decode($vsubvalue);}
elseif (vsubvalue == array()) {$vthemesettings[$vkey][$vsubkey] = '';}
else {
foreach ($vsubvalue as $vsubsubkey => $vsubsubvalue) {
if (!is_array($vsubsubvalue)) {$vthemesettings[$vkey][$vsubkey][$vsubsubkey] = htmlspecialchars_decode($vsubsubvalue);}
elseif ($vsubsubvalue == array()) {$vthemesettings[$vkey][$vsubkey][$vsubsubkey] = '';}
// else {print_r($vsubsubvalue);} // debug point
}
}
}
}
}
return $vthemesettings;
}
}
// Verify Uploaded File
// --------------------
// 1.8.5: added this upload check handler
// ref: http://php.net/manual/en/features.file-upload.php
if (!function_exists('bioship_admin_verify_file_upload')) {
function bioship_admin_verify_file_upload($vinputkey) {
try {
// Undefined | Multiple Files | $_FILES Corruption Attack
// If this request falls under any of them, treat it invalid.
if ( (!isset($_FILES[$vinputkey]['error'])) || (is_array($_FILES[$vinputkey]['error'])) ) {
throw new RuntimeException(__('Invalid parameters.','bioship'));
}
// Check $_FILES[$vinputkey]['error'] value.
switch ($_FILES[$vinputkey]['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
throw new RuntimeException(__('No file sent.','bioship'));
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new RuntimeException(__('Exceeded filesize limit.','bioship'));
default:
throw new RuntimeException(__('Unknown errors.','bioship'));
}
// You should also check filesize here.
if ($_FILES[$vinputkey]['size'] > 1000000) {
throw new RuntimeException(__('Exceeded filesize limit.','bioship'));
} elseif ($_FILES[$vinputkey]['size'] === 0) {
throw new RuntimeException(__('File is empty.','bioship'));
}
// DO NOT TRUST $_FILES['upfile']['mime'] VALUE !!
// Check MIME Type by yourself.
if (class_exists('finfo')) {
$finfo = new finfo(FILEINFO_MIME_TYPE);
if (false === $extension = array_search(
$finfo->file($_FILES[$vinputkey]['tmp_name']),
array('xml' => 'text/xml', 'json' => 'text/json'),
true
)) {
throw new RuntimeException(__('Invalid file format.','bioship'));
}
} else {
if (isset($_FILES[$vinputkey]['mime'])) {
echo "";
}
$vpathinfo = pathinfo($_FILES[$vinputkey]['name']);
echo "";
$vextension = $vpathinfo['extension'];
$vvalid = array('json', 'xml', 'ser');
if (!in_array($vextension, $vvalid)) {
throw new RuntimeException(__('Invalid file extension.','bioship'));
}
}
// You should name it uniquely.
// DO NOT USE $_FILES['upfile']['name'] WITHOUT ANY VALIDATION !!
// On this example, obtain safe unique name from its binary data.
// if (!move_uploaded_file(
// $_FILES[$vinputkey]['tmp_name'],
// sprintf('./uploads/%s.%s',
// sha1_file($_FILES[$vinputkey]['tmp_name']),
// $extension
// )
// )) {
// throw new RuntimeException(__('Failed to move uploaded file.','bioship'));
// }
$vfile['type'] = $vextension;
$vfile['data'] = bioship_file_get_contents($_FILES[$vinputkey]['tmp_name']);
return $vfile;
} catch (RuntimeException $e) {
$error = $e->getMessage();
echo "";
return new WP_Error('failed', $error);
}
}
}
// =================================
// === Activation / Deactivation ===
// =================================
// Save/Restore Widgets/Menus on Deactivation/Activation
// -----------------------------------------------------
// for Parent Theme as Child Theme has different code
// CHECKME: retest activation/deactivation functionality
if (!THEMECHILD) {
$vsaverestorewidgets = bioship_apply_filters('skeleton_theme_widget_backups', true);
if ($vsaverestorewidgets) {
// Backup on Deactivation
// ----------------------
if (!function_exists('bioship_admin_theme_deactivation')) {
add_action('switch_theme', 'bioship_admin_theme_deactivation');
function bioship_admin_theme_deactivation($vnewthemename) {
$vsidebarswidgets = get_option('sidebars_widgets');
delete_option('bioship_widgets_backup');
add_option('bioship_widgets_backup', $vsidebarswidgets);
$vmenusettings = get_option('nav_menu_options');
delete_option('bioship_menus_backup');
add_option('bioship_menus_backup', $vmenusettings);
// not needed: theme mods, as they are theme specific
// (hmmmm 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() {
$vsidebarswidgets = get_option('sidebars_widgets');
$vmenusettings = get_option('nav_menu_options');
$vbioshipwidgets = get_option('bioship_widgets_backup');
$vbioshipmenus = get_option('bioship_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 ($vbioshipwidgets != '') {
update_option('sidebars_widgets', $vbioshipwidgets);
delete_option('old_theme_widgets_backup');
add_option('old_theme_widgets_backup', $vsidebarwidgets);
}
if ($vbioshipmenus != '') {
update_option('nav_menu_options', $vbioshipmenus);
delete_option('old_theme_menus_backup');
add_option('old_theme_menus_backup', $vmenusettings);
}
// 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;}
else {wp_redirect(admin_url('themes.php').'?page=theme-info&welcome=true'); exit;}
}
}
}
}
}
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)
$vsaverestorechildwidgets = bioship_apply_filters('skeleton_childtheme_widget_backups', true);
if ($vsaverestorechildwidgets) {
// get Child Theme Slug
// --------------------
if (!function_exists('bioship_admin_get_child_theme_slug')) {
function bioship_admin_get_child_theme_slug() {
$vthetheme = wp_get_theme();
if ( (!THEMETITAN) && (THEMEOPT) ) {$vchildthemeslug = preg_replace("/\W/", "_", strtolower($vthetheme['Name']));}
else {$vchildthemeslug = preg_replace("/\W/", "-", strtolower($vthetheme['Name']));}
return $vchildthemeslug;
}
}
// Switch Theme Hook (on Deactivation)
// -----------------------------------
add_action('switch_theme', 'bioship_admin_child_theme_deactivation');
if (!function_exists('bioship_admin_child_theme_deactivation')) {
function bioship_admin_child_theme_deactivation($vnewthemename) {
// Backup Child Theme Widgets and Menus
// ------------------------------------
$vchildthemeslug = bioship_admin_get_child_theme_slug();
$vsidebarswidgets = get_option('sidebars_widgets');
delete_option($vchildthemeslug.'_widgets_backup');
add_option($vchildthemeslug.'_widgets_backup', $vsidebarswidgets);
$vmenusettings = get_option('nav_menu_options');
delete_option($vchildthemeslug.'_menus_backup');
add_option($vchildthemeslug.'_menus_backup', $vmenusettings);
}
}
// After Switch Theme Hook (on Activation)
// ---------------------------------------
add_action('after_switch_theme', 'bioship_admin_child_theme_activation');
if (!function_exists('bioship_admin_child_theme_activation')) {
function bioship_admin_child_theme_activation() {
// Restore Child Theme Widgets and Menus
// -------------------------------------
$vchildthemeslug = bioship_admin_get_child_theme_slug();
$vbackupwidgets = get_option($vchildthemeslug.'_widgets_backup');
$vbackupmenus = get_option($vchildthemeslug.'_menus_backup');
if ($vbackupwidgets != '') {update_option('sidebars_widgets',$vbackupwidgets);}
if ($vbackupmenus != '') {update_option('nav_menu_options',$vbackupmenus);}
// Also transfer the menu locations from the backup
$vmenulocations = get_theme_mod('nav_menu_locations');
if (!is_array($vmenulocations)) {
$vmenulocations = get_option($vchildthemeslug.'_menu_locations_backup');
if (is_array($vmenulocations)) {set_theme_mod('nav_menu_locations',$vmenulocations);}
}
// 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) ) {wp_redirect(admin_url('admin.php').'?page=options-framework'); exit;}
elseif ( (THEMETITAN) && (class_exists('TitanFramework')) ) {wp_redirect(admin_url('admin.php').'?page=bioship-options'); exit;}
else {wp_redirect(admin_url('customize.php')); exit;}
}
}
}
}
}
// TODO: Fix/Deprecate? theme mods and menu locations transfer?
// if (get_option('bioship_transfer_widgets_menus') == 'yes') {
// $vtransferwidgets = get_option('bioship_widgets_backup');
// update_option('sidebars_widgets', $vtransferwidgets);
//
// $vtransfermenus = get_option('bioship_menus_backup');
// update_option('nav_menu_options', $vtransfermenus);
//
// $vthememods = get_option('bioship_mods_backup');
// if (count($vthememods) > 0) {
// foreach ($vthememods as $vthememod => $vvalue) {
// set_theme_mod($vthememod,$vvalue);
// }
// }
// // $vmenulocations = get_option('bioship_menu_locations_backup');
// // set_theme_mod('nav_menu_locations', $vmenulocations);
//
// update_option('bioship_transfer_widgets_menus','done');
// }
// =============================
// === Editor Screen Metabox ===
// =============================
// (override value retrieval via muscle_get_display_overrides in muscle.php)
// Perpage Override Metabox
// ------------------------
// Meta Key Notes
// _displayoverrides (array) - header, footer, navigation, secondarynav,
// sidebar, subsidebar, headerwidgets, footerwidgets,
// image, title, subtitle, metatop, metabottom, authorbio
// _filteroverrides (array) - wpautop, wptexturize, convertsmilies, convertchars
// _thumbnailsize (single key) - stores override
// _perpoststyles (single key) - stores style additions
// Add the Perpage Metabox
// -----------------------
// 1.8.0: renamed from muscle_add_metabox
// 2.0.5: move add_action inside for consistency
if (!function_exists('bioship_admin_add_theme_metabox')) {
add_action('admin_init', 'bioship_admin_add_theme_metabox');
function bioship_admin_add_theme_metabox() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
$vcpts = array('post', 'page');
$vargs = array('public'=>true, '_builtin' => false);
$vcptlist = get_post_types($vargs, 'names', 'and');
$vcpts = array_merge($vcpts, $vcptlist);
// 2.0.5: add filter for post types metabox
$vcpts = bioship_apply_filters('admin_theme_metabox_post_types', $vcpts);
foreach ($vcpts as $vcpt) {
add_meta_box('theme_metabox', __('Theme Display Overrides','bioship'), 'bioship_admin_theme_metabox', $vcpt, 'side', 'high');
}
}
}
// PerPage Metabox Checkboxes
// --------------------------
// 1.8.0: renamed from muscle_theme_metabox
// 2.0.0: added missing translation wrappers
if (!function_exists('bioship_admin_theme_metabox')) {
function bioship_admin_theme_metabox() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
global $post, $vthemesettings;
$vpostid = $post->ID; $vposttype = $post->post_type;
// setup available thumbnail sizes
if ($vposttype == 'page') {$vthumbdisplay = __('Featured Image','bioship'); $vthumbdefault = $vthemesettings['pagethumbsize'];}
else {$vthumbdisplay = __('Thumbnail','bioship'); $vthumbdefault = $vthemesettings['postthumbsize'];}
$vthumbarray = array(
'thumbnail' => __('Thumbnail','bioship').' ('.get_option('thumbnail_size_w').' x '.get_option('thumbnail_size_h').')',
'medium' => __('Medium','bioship').' ('.get_option('medium_size_w').' x '.get_option('medium_size_h').')',
'large' => __('Large','bioship').' ('.get_option('large_size_w').' x '.get_option('large_size_h').')',
'full' => __('Full Size','bioship').' ('.__('original','bioship').')'
);
global $_wp_additional_image_sizes;
$image_sizes = get_intermediate_image_sizes();
$voldsizenames = array('squared150', 'squared250', 'video43', 'video169');
foreach ($image_sizes as $size_name) {
if ( ($size_name != 'thumbnail') && ($size_name != 'medium') && ($size_name != 'large') ) {
// 1.9.8: fix to sporadic undefined index warning (huh? size names should match?)
if (isset($_wp_additional_image_sizes[$size_name])) {
// 2.0.5: no longer output old size names as options
if (!in_array($size_name, $voldsizenames)) {
$vthumbarray[$size_name] = $size_name.' ('.$_wp_additional_image_sizes[$size_name]['width'].' x '.$_wp_additional_image_sizes[$size_name]['height'].')';
}
}
}
}
echo "";
// 1.9.5: changed _hide prefix to _display_ prefix for form option names
// Button Tabs
// -----------
// 1.8.0: use separate tab value so only for metabox itself
// 1.9.5: merge filters with content tab and add separate sidebar tab
$vthemesettingstab = get_post_meta($vpostid, '_themeoptionstab', true);
echo "";
echo "
";
echo " ";
echo " ";
echo " ";
echo " ";
echo " ";
echo "
";
// Layout Overrides
// ----------------
$vdisplay = bioship_muscle_get_display_overrides($vpostid);
$voverride = bioship_muscle_get_templating_overrides($vpostid);
$vremovefilters = bioship_muscle_get_content_filter_overrides($vpostid);
echo ""; // debug point
echo ""; // debug point
echo ""; // debug point
echo "";
echo "".__('Layout Display Overrides','bioship')." ";
// 1.8.5: added full width container option (no wrap margins)
echo "".__('No Wrap Margins','bioship')." ";
echo " ";
echo "".__('Hide Header','bioship')." ";
echo " ";
echo "".__('Hide Footer','bioship')." ";
echo " ";
// TODO: general layout displays?
// Header Logo / Title Text / Description / Extras
// Footer Extras / Site Credits
// 1.9.8: fix to headernav and footernav keys
echo " ";
echo "".__('Navigation Display','bioship')." ".__('Hide','bioship')." ";
echo "".__('Main Nav Menu','bioship')." ";
echo " ";
echo "".__('Secondary Nav Menu','bioship')." ";
echo " ";
echo "".__('Header Nav Menu','bioship')." ";
echo " ";
echo "".__('Footer Nav Menu','bioship')." ";
echo " ";
echo "".__('Breadcrumbs','bioship')." ";
echo " ";
echo "".__('Post/Page Navi','bioship')." ";
echo " ";
echo "
";
// Sidebar Overrides
// -----------------
// 1.9.5: separate tab for sidebar overrides
echo "";
// Content Overrides
// -----------------
// 1.8.0: keep individual meta key for this
$vthumbnailsize = get_post_meta($vpostid, '_thumbnailsize', true);
// 2.0.5: convert old size names to prefixed ones and update
$vnewthumbsize = false;
if ($vthumbnailsize == 'squared150') {$vnewthumbsize = 'bioship-150s';}
elseif ($vthumbnailsize == 'squared250') {$vnewthumbsize = 'bioship-250s';}
elseif ($vthumbnailsize == 'video43') {$vnewthumbsize = 'bioship-4-3';}
elseif ($vthumbnailsize == 'video169') {$vnewthumbsize = 'bioship-16-9';}
elseif ($vthumbnailsize == 'opengraph') {$vnewthumbsize = 'bioship-opengraph';}
if ($vnewthumbsize) {
update_post_meta($vpostid, '_thumbnailsize', $vnewthumbsize);
$vthumbnailsize = $vnewthumbsize;
}
echo "";
// Thumbnail Size Override
// 2.0.7: fix to text domin typo (bioship.)
echo " ";
echo "".$vthumbdisplay." ".__('Size','bioship')." (".__('default','bioship')." ".$vthumbdefault.") ";
echo "";
echo "".__('Theme Settings Default','bioship')." ";
echo "".__('No Thumbail Output','bioship')." ";
foreach ($vthumbarray as $vkey => $vvalue) {
echo "".$vvalue." ";
}
echo " ";
echo "".__('Hide','bioship')." ".$vthumbdisplay." ";
// Content Overrides
echo " ";
echo "".__('Content Display','bioship')." ";
echo "".__('Hide','bioship')." ";
echo "".__('Title','bioship')." ";
echo " ";
echo "".__('Subtitle','bioship')." ";
echo " ";
echo "".__('Top Meta','bioship')." ";
echo " ";
echo "".__('Bottom Meta','bioship')." ";
echo " ";
echo "".__('Author Bio','bioship')." ";
echo " ";
// Filter Overrides
// 1.9.5: merge to content from separate filters tab
echo " ";
echo "".__('Content Filter','bioship')." ".__('Disable','bioship')." ";
echo "wpautop ";
echo "wptexturize ";
echo "convert_smilies ";
echo "convert_chars ";
echo "
";
// Style Overrides
// ---------------
// 1.8.0: javascript to expand/collapse style box
echo "";
echo "";
// 1.8.0: keep individual meta key for this
$vperpoststyles = get_post_meta($vpostid, '_perpoststyles', true);
echo "";
// theme options current tab saver
$vthemesettingstab = get_post_meta($vpostid,'_themeoptionstab',true);
echo " ";
echo " ";
echo "";
// 1.9.5: add quicksave perpost CSS form to footer
add_action('admin_footer', 'bioship_admin_quicksave_perpost_css_form');
// 2.0.0: add quicksave perpost settings form to footer (prototype)
add_action('admin_footer', 'bioship_admin_quicksave_perpost_settings_form');
}
}
// Update Metabox Hook
// -------------------
add_action('publish_post', 'bioship_admin_update_metabox_options');
add_action('save_post', 'bioship_admin_update_metabox_options');
// Update Metabox Values
// ---------------------
// 1.8.0: renamed from muscle_update_metabox_options
if (!function_exists('bioship_admin_update_metabox_options')) {
function bioship_admin_update_metabox_options() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
// 1.9.8: return if post is empty
global $post; if (!is_object($post)) {return;}
$vpostid = $post->ID;
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {return $vpostid;}
// 1.8.0: cleaner save logic here
if ( (!current_user_can('edit_posts')) || (!current_user_can('edit_post',$vpostid)) ) {return $vpostid;}
// 1.8.0: grouped display overrides to array
// 1.8.5: added headernav, footernav, breadcrumbs, pagenavi
$vdisplay = array(); $vpostdata = false;
$vdisplaykeys = array(
'wrapper', 'header', 'footer', 'navigation', 'secondarynav', 'headernav', 'footernav',
'sidebar', 'subsidebar', 'headerwidgets', 'footerwidgets', 'footer1', 'footer2', 'footer3', 'footer4',
'image', 'breadcrumb', 'title', 'subtitle', 'metatop', 'metabottom', 'authorbio', 'pagenavi'
);
// 1.9.5: changed _hide prefix to _display_
foreach ($vdisplaykeys as $vkey) {
if (isset($_POST['_display_'.$vkey])) {
if ($_POST['_display_'.$vkey] == '1') {$vdisplay[$vkey] = '1'; $vpostdata = true;}
else {$vdisplay[$vkey] = '';}
} else {$vdisplay[$vkey] = '';}
}
delete_post_meta($vpostid,'_displayoverrides');
// 1.9.9: check and save if new post data
if ($vpostdata) {add_post_meta($vpostid,'_displayoverrides',$vdisplay);}
// 1.9.5: added override keys
$voverride = array(); $vpostdata = false;
$voverridekeys = array(
'contentcolumns', 'sidebarcolumns', 'subsidebarcolumns', 'sidebarposition', 'subsidebarposition',
'sidebartemplate', 'subsidebartemplate', 'sidebarcustom', 'subsidebarcustom'
);
foreach ($voverridekeys as $vkey) {
if (isset($_POST['_'.$vkey])) {$voverride[$vkey] = $_POST['_'.$vkey]; $vpostdata = true;}
else {$voverride[$vkey] = '';}
}
delete_post_meta($vpostid,'_templatingoverrides');
// 1.9.9: check and save if new post data
if ($vpostdata) {add_post_meta($vpostid,'_templatingoverrides',$voverride);}
// 1.8.0: grouped filters to array
// 2.0.0: better checkbox save logic
$vremovefilters = array(); $vpostdata = false;
$vfilters = array('wpautop', 'wptexturize', 'convertsmilies', 'convertchars');
foreach ($vfilters as $vfilter) {
if (isset($_POST['_'.$vfilter])) {
if ($_POST['_'.$vfilter] == '1') {$vremovefilters[$vfilter] = '1'; $vpostdata = true;}
else {$vremovefilters[$vfilter] = '';}
} else {$vremovefilters[$vfilter] = '';}
}
delete_post_meta($vpostid,'_removefilters');
// 1.9.9: check and save if new filters
// 2.0.0: save if post data found
if ($vpostdata) {add_post_meta($vpostid, '_removefilters', $vremovefilters, true);}
// 1.8.0: save individual key values
$voptionkeys = array('_perpoststyles', '_thumbnailsize', '_themeoptionstab');
foreach ($voptionkeys as $voption) {
// 1.9.9: make sure option value is set as metaxbox may be removed
if (isset($_POST[$voption])) {
$voptionvalue = $_POST[$voption]; $voptions[$voption] = $voptionvalue;
if ($voption == '_perpoststyles') {$voptionvalue = stripslashes($voptionvalue);}
delete_post_meta($vpostid, $voption);
// 1.9.5: make cleaner, do not save empty values
if ($voptionvalue != '') {add_post_meta($vpostid, $voption, $voptionvalue, true);}
}
}
// for manually writing a post options debug file on save
$vmetasavedebug = false; // $vmetasavedebug = true;
if ($vmetasavedebug) {
$vdebuginfo = "Override".PHP_EOL; foreach ($voverride as $vkey => $vvalue) {$vdebuginfo .= $vkey.':'.$vvalue.PHP_EOL;}
$vdebuginfo .= "Display".PHP_EOL; foreach ($vdisplay as $vkey => $vvalue) {$vdebuginfo .= $vkey.':'.$vvalue.PHP_EOL;}
$vdebuginfo .= "Filters".PHP_EOL; foreach ($vremovefilters as $vkey => $vvalue) {$vdebuginfo .= $vkey.':'.$vvalue.PHP_EOL;}
$vdebuginfo .= "Options".PHP_EOL; foreach ($voptions as $vkey => $vvalue) {$vdebuginfo .= $vkey.':'.$vvalue.PHP_EOL;}
bioship_write_debug_file('perpost-debug-'.$vpostid.'.txt', $vdebuginfo);
}
}
}
// QuickSave PerPost CSS Form
// --------------------------
// 1.9.5: added this CSS quicksave form
if (!function_exists('bioship_admin_quicksave_perpost_css_form')) {
function bioship_admin_quicksave_perpost_css_form() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
echo "";
global $post; $vpostid = $post->ID;
$vperpoststyles = get_post_meta($vpostid, '_perpoststyles', true);
$vadminajax = admin_url('admin-ajax.php');
echo "
";
wp_nonce_field('quicksave_perpost_css_'.$vpostid);
echo " ";
echo " ";
echo " ";
echo " ";
echo "
";
}
}
// QuickSave PerPost CSS
// ---------------------
// 1.9.5: added this CSS quicksave
add_action('wp_ajax_quicksave_perpost_css', 'bioship_admin_quicksave_perpost_css');
if (!function_exists('bioship_admin_quicksave_perpost_css')) {
function bioship_admin_quicksave_perpost_css() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
if ( (!isset($_POST['postid'])) || (!isset($_POST['newperpoststyles'])) ) {exit;}
$vpostid = $_POST['postid']; if (!is_numeric($vpostid)) {exit;}
$verror = false;
if ( (current_user_can('edit_posts')) && (current_user_can('edit_post',$vpostid)) ) {
// 2.0.0: use wp_verify_nonce instead of check_admin_referer for error message output
$vchecknonce = false;
if (isset($_REQUEST['_wp_nonce'])) {
$vnonce = $_REQUEST['_wp_nonce'];
$vchecknonce = wp_verify_nonce($vnonce, 'quicksave_perpost_css_'.$vpostid);
}
if ($vchecknonce) {
$vnewstyles = stripslashes($_POST['newperpoststyles']);
$vupdatestyles = update_post_meta($vpostid, '_perpoststyles', $vnewstyles);
} else {$verror = __('Whoops! Nonce has expired. Try reloading the page.','bioship');}
} else {$verror = __('Failed. Looks like you may need to login again!','bioship');}
if ($verror) {echo "";}
else {echo "";}
exit;
}
}
// QuickSave PerPost Settings Form
// -------------------------------
// 2.0.0: dummy form copy to save metabox overrides (prototype)
if (!function_exists('bioship_admin_quicksave_perpost_settings_form')) {
function bioship_admin_quicksave_perpost_settings_form() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
// metabox settings keys
$vcheckboxkeys = array(
'display_wrapper', 'display_header', 'display_footer', 'display_navigation', 'display_secondarynav', 'display_headernav', 'display_footernav',
'display_sidebar', 'display_subsidebar', 'display_headerwidgets', 'display_footerwidgets', 'display_footer1', 'display_footer2', 'display_footer3', 'display_footer4',
'display_image', 'display_breadcrumb', 'display_title', 'display_subtitle', 'display_metatop', 'display_metabottom', 'display_authorbio', 'display_pagenavi',
'wpautop', 'wptexturize', 'convertsmilies', 'convertchars' // filter keys
);
$vselectkeys = array(
'contentcolumns', 'sidebarcolumns', 'subsidebarcolumns', 'sidebarposition', 'subsidebarposition',
'sidebartemplate', 'subsidebartemplate', 'thumbnailsize' // *
);
$vtextkeys = array('sidebarcustom', 'subsidebarcustom');
$vi = 0; $vj = 0; $vk = 0;
echo "";
global $post; $vpostid = $post->ID;
$vadminajax = admin_url('admin-ajax.php');
echo "
";
wp_nonce_field('quicksave_perpost_settings_'.$vpostid);
echo " ";
echo " ";
foreach ($vcheckboxkeys as $vkey) {echo " ";}
foreach ($vselectkeys as $vkey) {echo " ";}
foreach ($vtextkeys as $vkey) {echo " ";}
echo " ";
echo "
";
}
}
// QuickSave PerPost Settings
// --------------------------
// 2.0.0: save theme overrides via AJAX trigger (prototype)
if (!function_exists('bioship_admin_update_metabox_settings')) {
add_action('wp_ajax_quicksave_perpost_settings', 'bioship_admin_update_metabox_settings');
function bioship_admin_update_metabox_settings() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
if (!isset($_REQUEST['postid'])) {exit;}
$vpostid = $_REQUEST[$vpostid]; if (!is_numeric($vpostid)) {exit;}
$verror = false;
if ( (current_user_can('edit_posts')) && (current_user_can('edit_post',$vpostid)) ) {
$vchecknonce = false;
if (isset($_REQUEST['_wp_nonce'])) {
$vnonce = $_REQUEST['_wp_nonce'];
$vchecknonce = wp_verify_nonce($vnonce, 'quicksave_perpost_settings_'.$vpostid);
}
if ($vchecknonce) {
global $post; $post = get_post($vpostid);
bioship_admin_update_metabox_options();
} else {$verror = __('Whoops! Nonce has expired. Try reloading the page.','bioship');}
} else {$verror = __('Failed. Looks like you may need to login again!','bioship');}
if ($verror) {echo "";}
else {echo "";}
exit;
}
}
// ===============
// === PLUGINS ===
// ===============
// To Install the Titan Framework Plugin
// -------------------------------------
// 1.8.5: moved here from customizer.php
// 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)
if (isset($_REQUEST['admin_install_titan_framework'])) {
if ($_REQUEST['admin_install_titan_framework'] == 'yes') {
add_action('init', 'bioship_admin_install_titan_framework');
}
}
// Note: Otto's Theme Plugin Dependency Class
// ref: http://ottopress.com/2012/themeplugin-dependencies/
if (!function_exists('bioship_admin_install_titan_framework')) {
function bioship_admin_install_titan_framework() {
if (current_user_can('install_plugins')) {
// TODO: 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
// proceed with Titan Framework installation...
$vtitanslug = 'titan-framework';
$vinstallurl = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$vtitanslug), 'install-plugin_'.$vtitanslug);
wp_redirect($vinstallurl); exit;
}
}
}
// --------------------------
// Load TGM Plugin Activation
// --------------------------
if (!function_exists('tgmpa')) {
$vtgmpa = bioship_file_hierarchy('file', 'class-tgm-plugin-activation.php', array('includes'));
if ($vtgmpa) {require_once($vtgmpa);}
}
// ---------------------------
// === Recommended Plugins ===
// ---------------------------
// 'Required' Plugins
// ------------------
// - Titan Framework
// -- for WP.Org installs
// Recommended Plugins (Theme Supported)
// -------------------------------------
// - AJAX Load More
// - Open Graph Protocol Framework
// - Theme My Login
// ? Theme Test Drive
// - Widget Saver
// - WP PageNavi
// - WP Subtitle
// WordQuest Plugins
// -----------------
// (could handle these differently?)
// - AutoSave Net (released)
// - Content Sidebars (released)
// - FreeStyler
// - PDF Replicator
// - PDF Shuttle
// - Visitor Vortex
// - WarpPress Builder
// - WP AutoMedic
// - WP BugBot
// - WP Email Images
// - WP Infinity Responder
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($vplugins) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
$vthemeupdater = bioship_file_hierarchy('file', 'theme-update-checker.php', array('includes'));
if (!$vthemeupdater) {
$vplugins[] = array(
'name' => 'Titan Framework',
'slug' => 'titan-framework',
'required' => false
);
}
return $vplugins;
}
}
// 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
if ( ($_REQUEST['page'] == 'options-framework')
|| ($_REQUEST['page'] == $vthemename.'-options')
|| ($_REQUEST['page'] == $vthemename.'_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');
}
}
if (!function_exists('bioship_admin_tgm_notice_shift')) {
function bioship_admin_tgm_notice_shift() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
$vid = 'bioship-tgmpa'; // TGM instance id
if (get_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_'.$vid, true)) {
add_user_meta(get_current_user_id(), 'tgmpa_temp_notice_'.$vid, 1);
delete_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_'.$vid);
add_action('all_admin_notices', 'bioship_admin_tgm_notice_unshift', 100);
}
}
}
if (!function_exists('bioship_admin_tgm_notice_unshift')) {
function bioship_admin_tgm_notice_unshift() {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);}
$vid = 'bioship-tgmpa'; // TGM instance id
delete_user_meta(get_current_user_id(), 'tgmpa_temp_'.$vid);
add_user_meta(get_current_user_id(), 'tgmpa_dismissed_notice_'.$vid, 1);
}
}
if (!function_exists('bioship_admin_tgm_dismiss_notice_off')) {
function bioship_admin_tgm_dismiss_notice_off($vconfig) {
if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__,func_get_args());}
// filter the theme page message
$vthememessage = '
'.__('BioShip Theme Framework Recommended Plugins','bioship').' ';
$vthememessage = bioship_apply_filters('tgm_theme_page_message',$vthememessage);
$vconfig['dismissable'] = false;
$vconfig['dismiss_msg'] = $vthememessage;
return $vconfig;
}
}
// 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)
$vplugins = 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,
// 'force_activation' => true
// ),
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: remove as yet unreleased plugin
// 2.0.5: re-add this released plugin
array(
'name' => 'AutoSave Net',
'slug' => 'autosave-net',
'required' => false,
'source' => 'http://wordquest.org/downloads/packages/autosave-net.zip',
'external_url' => 'http://wordquest.org/plugins/autosave-net/'
),
array(
'name' => 'Content Sidebars',
'slug' => 'content-sidebars',
'required' => false,
'source' => 'http://wordquest.org/downloads/packages/content-sidebars.zip',
'external_url' => 'http://wordquest.org/plugins/content-sidebars/'
),
);
// Filter the TGMPA plugins
$vplugins = bioship_apply_filters('tgm_plugins_array', $vplugins);
/*
* TGMPA: Array of configuration settings. Amend each line as needed.
*
*/
// filter the TGM page message
$vtgmpagemessage = '
'.__('BioShip Theme Framework','bioship');
$vtgmpagemessage .= ' - '.__('Recommended Plugins','bioship').' ';
$vtgmpagemessage = bioship_apply_filters('tgm_plugin_page_message', $vtgmpagemessage);
// filter the bundle path
$vbundlespath = get_template_directory().'/includes/plugins/';
$vbundlespath = bioship_apply_filters('tgm_plugin_bundles_path', $vbundlespath);
// note: id (instance) set to bioship-tgmpa to prevent conflicts
$vconfig = array(
'id' => 'bioship-tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => $vbundlespath, // 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' => $vtgmpagemessage, // 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
$vconfig = bioship_apply_filters('tgm_config_array', $vconfig);
// Load TGM Plugin Activation!
// ---------------------------
tgmpa($vplugins, $vconfig);
}
}
}
}
?>