true, '_builtin' => false); $cptlist = get_post_types($args, 'names', 'and'); $cpts = array_merge($cpts, $cptlist); // 2.0.5: add filter for post types metabox $cpts = bioship_apply_filters('admin_theme_metabox_post_types', $cpts); // --- metabox position --- // 2.1.1: added filter for metabox priority position $priority = bioship_apply_filters('admin_theme_metabox_priority', 'high'); // --- add metaboxes --- foreach ($cpts as $cpt) { add_meta_box('theme_metabox', __('Theme Display Overrides','bioship'), 'bioship_admin_theme_metabox', $cpt, 'side', $priority); } } } // ---------------------------- // Editor Theme Options Metabox // ---------------------------- // 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 $vthemesettings; // --- get post data --- // 2.1.1: handle new post (no post ID) global $post; if (is_object($post)) {$postid = $post->ID; $posttype = $post->post_type;} else { $postid = ''; $posttype = 'post'; if (isset($_REQUEST['post_type'])) {$posttype = $_REQUEST['post_type'];} } // --- get current override values --- $display = bioship_muscle_get_display_overrides($postid); $override = bioship_muscle_get_templating_overrides($postid); $removefilters = bioship_muscle_get_content_filter_overrides($postid); if (THEMEDEBUG) { bioship_debug("Post ID", $postid); bioship_debug("Display Overrides", $display); bioship_debug("Templating Overrides", $override); bioship_debug("Filter Overrides", $removefilters); } // --- option tab script --- echo ""; // Button Tabs // ----------- // 1.9.5: merged filters with content tab and add separate sidebar tab // 1.9.5: changed _hide prefix to _display_ prefix for form option names // --- get current options tab --- // 1.8.0: use separate tab value so only for metabox itself // 2.1.1: use prefixed post meta key for theme options tab $settingstab = ''; // empty default if ($postid != '') {$tab = get_post_meta($postid, '_'.THEMEPREFIX.'_themeoptionstab', true);} if ($tab) {$settingstab = $tab;} // --- tab button styles --- // 2.1.1: added a tag text decoration style echo ""; // --- theme options tab buttons --- // 2.1.0: removed filters tab cell/button remnant // TODO: maybe convert a tags to input buttons ? echo "
"; // --- content tab button --- if ($settingstab == 'content') {$bgcolor = " style='background-color:#DDD;'";} else {$bgcolor = '';} echo ""; // --- sidebar tab button --- if ($settingstab == 'sidebar') {$bgcolor = " style='background-color:#DDD;'";} else {$bgcolor = '';} echo ""; // --- layout tab button --- if ($settingstab == 'layout') {$bgcolor = " style='background-color:#DDD;'";} else {$bgcolor = '';} echo ""; // --- styles tab button --- // 2.1.4: fix to echo instead of setting variable if ($settingstab == 'styles') {$bgcolor = " style='background-color:#DDD;'";} else {$bgcolor = '';} echo ""; echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; echo esc_attr(__('Content','bioship')).""; echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; echo esc_attr(__('Sidebars','bioship')).""; echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; echo esc_attr(__('Layout','bioship')).""; echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; echo esc_attr(__('Styles','bioship')).""; echo "
"; // Content Override Tab // -------------------- if ($settingstab != 'content') {$hide = " style='display:none;'";} else {$hide = '';} echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; // Thumbnail Size Override // ----------------------- // --- setup available thumbnail sizes --- if ($posttype == 'page') {$thumbdisplay = esc_attr(__('Featured Image','bioship')); $thumbdefault = $vthemesettings['pagethumbsize'];} else {$thumbdisplay = esc_attr(__('Thumbnail','bioship')); $thumbdefault = $vthemesettings['postthumbsize'];} $thumbarray = array( 'thumbnail' => esc_attr(__('Thumbnail','bioship')).' ('.get_option('thumbnail_size_w').' x '.get_option('thumbnail_size_h').')', 'medium' => esc_attr(__('Medium','bioship')).' ('.get_option('medium_size_w').' x '.get_option('medium_size_h').')', 'large' => esc_attr(__('Large','bioship')).' ('.get_option('large_size_w').' x '.get_option('large_size_h').')', 'full' => esc_attr(__('Full Size','bioship')).' ('.esc_attr(__('original','bioship')).')' ); // --- get additional image sizes --- global $_wp_additional_image_sizes; $image_sizes = get_intermediate_image_sizes(); $oldsizenames = 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, $oldsizenames)) { $thumbarray[$size_name] = $size_name.' ('.$_wp_additional_image_sizes[$size_name]['width'].' x '.$_wp_additional_image_sizes[$size_name]['height'].')'; } } } } // --- get thumbnail size override --- // 1.8.0: keep individual meta key for this // 2.1.1: added theme prefix to thumbnail size metakey $thumbnailsize = ''; if ($postid != '') {$thumbnailsize = get_post_meta($postid, '_'.THEMEPREFIX.'_thumbnailsize', true);} // --- maybe convert old thumbnail size names --- // 2.0.5: maybe convert to prefixed names and update meta $newthumbsize = false; if ($thumbnailsize == 'squared150') {$newthumbsize = 'bioship-150s';} elseif ($thumbnailsize == 'squared250') {$newthumbsize = 'bioship-250s';} elseif ($thumbnailsize == 'video43') {$newthumbsize = 'bioship-4-3';} elseif ($thumbnailsize == 'video169') {$newthumbsize = 'bioship-16-9';} elseif ($thumbnailsize == 'opengraph') {$newthumbsize = 'bioship-opengraph';} if ($newthumbsize) { update_post_meta($postid, '_'.THEMEPREFIX.'_thumbnailsize', $newthumbsize); $thumbnailsize = $newthumbsize; } // --- thumbnail size override selector --- // 2.0.7: fix to text domin typo (bioship.) echo ""; echo ""; // --- hide thumbnail --- // 2.1.1.: added missing id for checkbox field echo ""; // Content Display Overrides // ------------------------- // --- content override headings --- echo ""; echo ""; echo ""; // --- content title --- echo ""; // ---- content subtitle --- echo ""; // --- content meta top --- echo ""; // --- content meta bottom --- echo ""; // --- author bio box --- echo ""; // Filter Overrides // ---------------- // 1.9.5: merged to content tab from separate filters tab // --- content filters heading --- echo ""; echo ""; echo ""; // --- wpautop filter --- echo ""; // --- wptexturize filter --- echo ""; // --- convert_smilies filter --- echo ""; // --- convert_chars filter --- echo ""; // --- quicksave settings button --- echo ""; // --- close content tab --- echo "
"; echo "".$thumbdisplay." "; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo esc_attr(__('Size','bioship'))." (".esc_attr(__('default','bioship'))." ".esc_attr($thumbdefault).")
"; echo ""; echo "
".__('Hide','bioship')." ".$thumbdisplay.""; if ($display['image'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; echo "
".esc_attr(__('Content Display','bioship'))."".esc_attr(__('Hide','bioship'))."
".esc_attr(__('Title','bioship')).""; if ($display['title'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Subtitle','bioship')).""; if ($display['subtitle'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Top Meta','bioship')).""; if ($display['metatop'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Bottom Meta','bioship')).""; if ($display['metabottom'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Author Bio','bioship')).""; if ($display['authorbio'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Content Filter','bioship'))."".esc_attr(__('Disable','bioship'))."
wpautop"; if (isset($removefilters['wpautop']) && ($removefilters['wpautop'] == '1') ) {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
wptexturize"; if (isset($removefilters['wptexturize']) && ($removefilters['wptexturize'] == '1') ) {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
convert_smilies"; if (isset($removefilters['convertsmilies']) && ($removefilters['convertsmilies'] == '1') ) {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
convert_chars"; if (isset($removefilters['convertchars']) && ($removefilters['convertchars'] == '1') ) {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
"; echo "
".esc_attr(__('Saved!','bioship'))."
"; echo "
"; echo ""; echo "
"; // Sidebar Overrides // ----------------- // TODO: add display of total column width ? // 1.9.5: separate tab for sidebar overrides if ($settingstab != 'sidebar') {$hide = " style='display:none;'";} else {$hide = '';} echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; // -- set column options --- $subsidebarcolumns = array( '' => esc_attr(__('Default','bioship')), 'one' => ' '.__('1','bioship').' ', 'two' => ' '.__('2','bioship').' ', 'three' => ' '.__('3','bioship').' ', 'four' => ' '.__('4','bioship').' ', 'five' => ' '.__('5','bioship').' ', 'six' => ' '.__('6','bioship').' ', 'seven' => ' '.__('7','bioship').' ', 'eight' => ' '.__('8','bioship').' ', ); $sidebarcolumns = array_merge($subsidebarcolumns, array( 'nine' => ' '.__('9','bioship').' ', 'ten' => __('10','bioship').' ', 'eleven' => __('11','bioship').' ', 'twelve' => __('12','bioship').' ', ) ); $contentcolumns = array_merge($sidebarcolumns, array( 'thirteen' => __('13','bioship').' ', 'fourteen' => __('14','bioship').' ', 'fifteen' => __('15','bioship').' ', 'sixteen' => __('16','bioship').' ', 'seventeen' => __('17','bioship').' ', 'eighteen' => __('18','bioship').' ', 'nineteen' => __('19','bioship').' ', 'twenty' => __('20','bioship').' ', 'twentyone' => __('21','bioship').' ', 'twentytwo' => __('22','bioship').' ', 'twentythree' => __('23','bioship').' ', 'twentyfour' => __('24','bioship').' ' ) ); // --- content columns --- echo ""; // --- column headings --- echo ""; echo ""; echo ""; echo ""; // --- sidebar columns --- echo ""; // --- subsidebar columns --- echo ""; // Sidebar Templates // ----------------- $sidebartemplates = array( '' => esc_attr(__('Default','bioship')), 'off' => esc_attr(__('None','bioship')), 'blank' => esc_attr(__('Blank','bioship')), 'primary' => esc_attr(__('Primary','bioship')) ); $subsidebartemplates = array( '' => esc_attr(__('Default','bioship')), 'off' => esc_attr(__('None','bioship')), 'subblank' => esc_attr(__('Blank','bioship')), 'subsidiary' => esc_attr(__('Subsidiary','bioship')) ); // TODO: use the new sidebar template search function here ? // (bioship_get_sidebar_templates_info in skull.php) ? $templates = array( 'page' => esc_attr(__('Page','bioship')), 'post' => esc_attr(__('Post','bioship')), 'front' => esc_attr(__('Front','bioship')), 'home' => esc_attr(__('Home','bioship')), 'archive' => esc_attr(__('Archive','bioship')), 'category' => esc_attr(__('Category','bioship')), 'taxonomy' => esc_attr(__('Taxonomy','bioship')), 'tag' => esc_attr(__('Tag','bioship')), 'author' => esc_attr(__('Author','bioship')), 'date' => esc_attr(__('Date','bioship')), 'search' => esc_attr(__('Search','bioship')), 'notfound' => esc_attr(__('NotFound','bioship')) ); $sidebartemplates = array_merge($sidebartemplates, $templates); foreach ($templates as $key => $label) {$subsidebartemplates['sub'.$key] = $label;} $sidebartemplates['custom'] = $subsidebartemplates['custom'] = esc_attr(__('Custom','bioship')); // --- sidebar template headings --- // 2.1.1: added missing translation wrappers echo ""; // --- sidebar template --- // 2.1.1: remove duplicate id attribute from select echo ""; // --- subsidebar template --- // 2.1.1: remove duplicate id attribute from select echo ""; // --- main sidebar position --- $sidebarpositions = array( '' => esc_attr(__('Default','bioship')), 'left' => esc_attr(__('Left','bioship')), 'right' => esc_attr(__('Right','bioship')) ); echo ""; // --- subsidebar position --- $subsidebarpositions = array( '' => esc_attr(__('Default','bioship')), 'opposite' => esc_attr(__('Opposite','bioship')), 'internal' => esc_attr(__('Internal','bioship')), 'external' => esc_attr(__('External','bioship')) ); echo ""; echo "
"; echo ""; echo "
".esc_attr(__('Content Columns','bioship')).""; echo ""; echo "
"; echo "
".esc_attr(__('Sidebar','bioship'))."".esc_attr(__('SubSidebar','bioship'))."
".esc_attr(__('Columns','bioship')).""; echo ""; echo ""; echo ""; echo "
"; echo esc_attr(__('Template','bioship'))."
"; if ( ($override['sidebartemplate'] != 'custom') && ($override['subsidebartemplate'] != 'custom') ) {$hide = "display:none;";} else {$hide = '';} echo "
".esc_attr(__('Slug','bioship')).":
"; echo "
"; echo "
"; // --- custom sidebar template --- if ($override['sidebartemplate'] != 'custom') {$hide = " style='display:none;'";} else {$hide = '';} echo "
"; // 2.1.1: added missing id attribute for input echo ""; echo "
"; echo "
"; echo "
"; // --- custom subsidebar template --- if ($override['subsidebartemplate'] != 'custom') {$hide = " style='display:none;'";} else {$hide = '';} echo "
"; // 2.1.1: added missing id attribute for input echo ""; echo "
"; echo "
"; // 2.1.1: added missing translation wrapper echo esc_attr(__('Position','bioship')); echo ""; echo ""; echo ""; // 2.1.1: added missing id field for subsidebar position echo ""; echo "
"; // --- sidebar display headings --- echo ""; echo ""; echo ""; // --- main sidebar hide --- echo ""; // --- subsidebar hide --- echo ""; // --- header widgets hide --- echo ""; // --- footer widgets hide --- echo ""; // --- footer widget area 1 --- echo ""; // --- footer widget area 2 --- echo ""; // --- footer widget area 3 --- echo ""; // --- footer widget area 4 ---- echo ""; // --- quicksave settings button --- echo ""; // --- close sidebar overrides tab --- echo "
".esc_attr(__('Sidebar Display','bioship'))."".esc_attr(__('Hide','bioship'))."
".esc_attr(__('Main Sidebar','bioship')).""; if ($display['sidebar'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('SubSidebar','bioship')).""; if ($display['subsidebar'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Header Widgets','bioship')).""; if ($display['headerwidgets'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Footer Widgets','bioship')).""; if ($display['footerwidgets'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Footer Area','bioship'))." 1"; if ($display['footer1'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".__('Footer Area','bioship')." 2"; if ($display['footer2'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Footer Area','bioship'))." 3"; if ($display['footer3'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Footer Area','bioship'))." 4"; if ($display['footer4'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
"; echo "
".esc_attr(__('Saved!','bioship'))."
"; echo "
"; echo ""; echo "
"; // Layout Overrides // ---------------- if ($settingstab != 'layout') {$hide = " style='display:none;'";} else {$hide = '';} echo "
"; echo ""; // --- layout overrides heading --- echo ""; // --- no wrap margins (full width) --- // 1.8.5: added full width container option (no wrap margins) echo ""; // --- hide header --- echo ""; // --- hide footer --- echo ""; // TODO: general layout displays? // Header Logo / Title Text / Description / Extras // Footer Extras / Site Credits // --- navigation display headings --- // 1.9.8: fix to headernav and footernav keys echo ""; echo ""; echo ""; // --- main navigation menu --- echo ""; // --- secondary navigation --- echo ""; // --- header navigation menu --- echo ""; // --- footer navigation menu --- echo ""; // --- breadcrumbs --- echo ""; // --- page navi --- echo ""; // --- quicksave settings button --- echo ""; // --- close layout override tab --- echo "
"; echo "".esc_attr(__('Layout Display Overrides','bioship')).""; echo "
".esc_attr(__('No Wrap Margins','bioship')).""; if ($display['wrapper'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Hide Header','bioship')).""; if ($display['header'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Hide Footer','bioship')).""; if ($display['footer'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Navigation Display','bioship'))."".esc_attr(__('Hide','bioship'))."
".esc_attr(__('Main Nav Menu','bioship')).""; if ($display['navigation'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Secondary Nav Menu','bioship')).""; if ($display['secondarynav'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Header Nav Menu','bioship')).""; if ($display['headernav'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Footer Nav Menu','bioship')).""; if ($display['footernav'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Breadcrumbs','bioship')).""; if ($display['breadcrumb'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
".esc_attr(__('Post/Page Navi','bioship')).""; if ($display['pagenavi'] == '1') {$checked = ' checked';} else {$checked = '';} echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
"; echo "
".esc_attr(__('Saved!','bioship'))."
"; echo "
"; echo ""; echo "
"; // Style Overrides // --------------- // 1.8.0: javascript to expand/collapse style box // 2.1.1: added marginTop to help prevent editor overlay echo ""; // 2.1.1: added .quicksavesettings class echo ""; // --- get per post styles --- // 1.8.0: keep individual meta key for this // 2.1.1: added theme prefix to post metakey $perpoststyles = ''; if ($postid != '') {$perpoststyles = get_post_meta($postid, '_'.THEMEPREFIX.'_perpoststyles', true);} // --- per post styles tab --- if ($settingstab != 'styles') {$hide = " style='display:none;'";} else {$hide = '';} echo "
"; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo ""; // --- style textarea --- echo ""; echo ""; echo ""; // --- quicksave CSS button --- echo ""; echo ""; // --- close style override tab --- echo "
".esc_attr(__('Post Specific CSS Style Rules','bioship'))."
"; echo "
"; echo "
".esc_attr(__('CSS Saved!','bioship'))."
"; // --- end tabs output --- echo "
"; // --- theme options current tab saver --- echo ""; echo ""; // --- enqueue quicksave forms --- // 1.9.5: added quicksave perpost CSS form to footer add_action('admin_footer', 'bioship_admin_quicksave_perpost_css_form'); // 2.0.0: added quicksave perpost settings form to footer (prototype) add_action('admin_footer', 'bioship_admin_quicksave_perpost_settings_form'); // 2.1.1: added quicksave cyclic nonce refresher add_action('admin_footer', 'bioship_admin_quicksave_nonce_refresher'); } } // --------------------- // Update Metabox Values // --------------------- add_action('publish_post', 'bioship_admin_update_metabox_options'); add_action('save_post', 'bioship_admin_update_metabox_options'); // 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__);} // --- check post values --- // 1.9.8: return if post is empty global $post; if (!is_object($post)) {return;} $postid = $post->ID; // --- check for autosave --- if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {return;} // --- check user capabilities --- // 1.8.0: cleaner save logic here if (!current_user_can('edit_posts') || !current_user_can('edit_post', $postid)) {return $postid;} // --- save display overrides -- // 1.8.0: grouped display overrides to array // 1.8.5: added headernav, footernav, breadcrumbs, pagenavi $display = array(); $postdata = false; $displaykeys = 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 ($displaykeys as $key) { if (!isset($_POST['_display_'.$key])) {$display[$key] = '';} elseif ($_POST['_display_'.$key] == '1') {$display[$key] = '1'; $postdata = true;} else {$display[$key] = '';} } // 1.9.9: check and save only if new post data // 2.1.1: use prefixed metakey for saving // 2.1.1: set unique argument to true here delete_post_meta($postid, '_'.THEMEPREFIX.'_display_overrides'); if ($postdata) {add_post_meta($postid, '_'.THEMEPREFIX.'_display_overrides', $display, true);} // --- save layout overrides --- // 1.9.5: added override keys $override = array(); $postdata = false; $overridekeys = array( 'contentcolumns', 'sidebarcolumns', 'subsidebarcolumns', 'sidebarposition', 'subsidebarposition', 'sidebartemplate', 'subsidebartemplate', 'sidebarcustom', 'subsidebarcustom' ); foreach ($overridekeys as $key) { if (!isset($_POST['_'.$key])) {$override[$key] = '';} else {$override[$key] = $_POST['_'.$key]; $postdata = true;} } delete_post_meta($postid, '_'.THEMEPREFIX.'_templating_overrides'); // 1.9.9: check and save if new post data // 2.1.1: use prefixed metakey for saving if ($postdata) {add_post_meta($postid, '_'.THEMEPREFIX.'_templating_overrides', $override);} // --- save filter overrides --- // 1.8.0: grouped filters to array // 2.0.0: better checkbox save logic $removefilters = array(); $postdata = false; $filters = array('wpautop', 'wptexturize', 'convertsmilies', 'convertchars'); foreach ($filters as $filter) { if (!isset($_POST['_'.$filter])) {$removefilters[$filter] = '';} else { if ($_POST['_'.$filter] == '1') {$removefilters[$filter] = '1'; $postdata = true;} else {$removefilters[$filter] = '';} } } delete_post_meta($postid, '_'.THEMEPREFIX.'_removefilters'); // 1.9.9: check and save if new filters // 2.0.0: save if post data found // 2.1.1: use prefixed metakey for saving if ($postdata) {add_post_meta($postid, '_'.THEMEPREFIX.'_removefilters', $removefilters, true);} // --- save individual options --- // 1.8.0: save individual key values $optionkeys = array('_perpoststyles', '_thumbnailsize', '_themeoptionstab'); foreach ($optionkeys as $option) { // 1.9.9: make sure option value is actually set (as metabox may be removed) if (isset($_POST[$option])) { $optionvalue = $_POST[$option]; if ($option == '_perpoststyles') {$optionvalue = stripslashes($optionvalue);} // 2.1.1: use prefixed metakey for saving $option = str_replace('_', '_'.THEMEPREFIX.'_', $option); delete_post_meta($postid, $option); // 1.9.5: to make cleaner, do not save empty values if (trim($optionvalue) != '') {add_post_meta($postid, $option, $optionvalue, true);} $options[$option] = $optionvalue; } } // --- for manual debug of per post options --- $metasavedebug = false; // $metasavedebug = true; if ($metasavedebug) { $debuginfo = PHP_EOL." Saved Post ".$postid." at ".date('j/m/d H:i:s', time()).PHP_EOL; $debuginfo .= "--- Override ---".PHP_EOL; foreach ($override as $key => $value) {$debuginfo .= $key.': '.$value.PHP_EOL;} $debuginfo .= "--- Display ---".PHP_EOL; foreach ($display as $key => $value) {$debuginfo .= $key.': '.$value.PHP_EOL;} $debuginfo .= "--- Filters ---".PHP_EOL; foreach ($removefilters as $key => $value) {$debuginfo .= $key.': '.$value.PHP_EOL;} // 2.1.2: fix for possible undefined variable warning if (isset($options)) {$debuginfo .= "--- Options ---".PHP_EOL; foreach ($options as $key => $value) {$debuginfo .= $key.': '.print_r($value,true).PHP_EOL;} } // $debuginfo .= "--- Posted ---".PHP_EOL; foreach ($posted as $key => $value) {$debuginfo .= $key.': '.print_r($value,true).PHP_EOL;} bioship_write_debug_file('perpost-debug-'.$postid.'.txt', $debuginfo); } } } // ------------------ // === QuickSaves === // ------------------ // -------------------------- // 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__);} // --- quicksave CSS scripts --- // 2.1.2: moved quicksave show fadeout to AJAX action echo ""; // --- get perpost styles --- global $post; $postid = $post->ID; // 2.0.8: use prefixed post meta key // 2.1.1: do not convert old values here $perpoststyles = get_post_meta($postid, '_'.THEMEPREFIX.'_perpoststyles', true); // --- perpost styles form --- // 2.1.1: use wp_create_nonce instead of wp_nonce_field $adminajax = admin_url('admin-ajax.php'); echo "
"; $nonce = wp_create_nonce('quicksave-perpost-css-'.$postid); echo ""; echo ""; echo ""; echo ""; // phpcs:ignore WordPress.Security.OutputNotEscaped,WordPress.Security.OutputNotEscapedShortEcho echo "
"; // --- perpost styles saving iframe --- echo ""; } } // --------------------- // QuickSave PerPost CSS // --------------------- // 1.9.5: added this CSS quicksave if (!function_exists('bioship_admin_quicksave_perpost_css')) { add_action('wp_ajax_quicksave_perpost_css', 'bioship_admin_quicksave_perpost_css'); // 2.1.1: also trigger for not logged in for logged out alert message display add_action('wp_ajax_nopriv_quicksave_perpost_css', 'bioship_admin_quicksave_perpost_css'); function bioship_admin_quicksave_perpost_css() { if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);} // --- get edit post ID --- if (!isset($_POST['postid']) || !isset($_POST['newperpoststyles'])) {exit;} $postid = $_POST['postid']; if (!is_numeric($postid)) {exit;} // --- check if logged in --- // 2.1.1: added user logged in check if (is_user_logged_in()) { // --- check edit permissions --- if (current_user_can('edit_posts') && current_user_can('edit_post', $postid)) { // --- check nonce --- // 2.0.0: use wp_verify_nonce instead of check_admin_referer for error message output $checknonce = false; if (isset($_POST['_wpnonce'])) { $nonce = $_POST['_wpnonce']; $checknonce = wp_verify_nonce($nonce, 'quicksave-perpost-css-'.$postid); } // --- update perpost styles --- if ($checknonce) { $newstyles = stripslashes($_POST['newperpoststyles']); // 2.1.1: use prefixed perpost styles metakey update_post_meta($postid, '_'.THEMEPREFIX.'_perpoststyles', $newstyles); } else {$error = __('Whoops! Nonce has expired. Try reloading the page.','bioship');} // --- update current tab to styles --- update_post_meta($postid, '_'.THEMEPREFIX.'_themeoptionstab', 'styles'); } else {$error = __('Failed! You do not have permission to edit this post.','bioship');} } else {$error = __('Failed. Looks like you may need to login again!','bioship');} // --- script output and exit --- if (isset($error)) {echo "";} else {echo "";} exit; } } // ------------------------------- // QuickSave PerPost Settings Form // ------------------------------- // 2.0.0: dummy form copy to save all metabox theme option 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__);} // --- set perpost metabox settings keys --- $checkboxkeys = 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 ); $selectkeys = array( 'contentcolumns', 'sidebarcolumns', 'subsidebarcolumns', 'sidebarposition', 'subsidebarposition', 'sidebartemplate', 'subsidebartemplate', 'thumbnailsize' // * ); $textkeys = array('sidebarcustom', 'subsidebarcustom'); // --- convert settings inputs to javascript arrays --- $settingskeys = ''; foreach ($checkboxkeys as $i => $key) {$settingskeys .= "checkboxkeys[".esc_js($i)."] = '".esc_js($key)."'; "; $i++;} $settingskeys .= PHP_EOL; foreach ($selectkeys as $j => $key) {$settingskeys .= "selectkeys[".esc_js($j)."] = '".esc_js($key)."'; "; $j++;} $settingskeys .= PHP_EOL; foreach ($textkeys as $k => $key) {$settingskeys .= "textkeys[".esc_js($k)."] = '".esc_js($key)."'; "; $k++;} $settingskeys .= PHP_EOL; // --- output settings save script --- // 2.1.1: added tab for displaying message and saving current tab echo ""; // --- quicksave settings form --- // 2.1.1: added buttonid and tab fields // 2.1.1: use wp_create_nonce instead of wp_nonce_field global $post; $postid = $post->ID; $adminajax = admin_url('admin-ajax.php'); echo "
"; $nonce = wp_create_nonce('quicksave-perpost-settings-'.$postid); echo ""; echo ""; echo ""; echo ""; foreach ($checkboxkeys as $key) {echo "";} foreach ($selectkeys as $key) {echo "";} foreach ($textkeys as $key) {echo "";} echo "
"; // --- quicksave settings iframe --- 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'); // 2.1.1: also trigger for not logged in for logged out alert message display add_action('wp_ajax_nopriv_quicksave_perpost_settings', 'bioship_admin_update_metabox_settings'); function bioship_admin_update_metabox_settings() { if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);} // --- check trigger conditions if (!isset($_REQUEST['postid'])) {exit;} $postid = $_REQUEST['postid']; if (!is_numeric($postid)) {exit;} $error = false; // --- check if logged in --- // 2.1.1: added user logged in check if (is_user_logged_in()) { // --- check permissions --- if (current_user_can('edit_posts') && current_user_can('edit_post', $postid)) { // --- check nonce --- $checknonce = false; if (isset($_POST['_wpnonce'])) { $nonce = $_POST['_wpnonce']; $checknonce = wp_verify_nonce($nonce, 'quicksave-perpost-settings-'.$postid); } if ($checknonce) { global $post; $post = get_post($postid); bioship_admin_update_metabox_options(); } else {$error = __('Whoops! Nonce has expired. Try reloading the page.','bioship');} // --- update current options tab // 2.1.1: added saving of current tab $tab = $_POST['tab']; update_post_meta($postid, '_'.THEMEPREFIX.'_themeoptionstab', $tab); } else {$error = __('Failed! You do not have permission to edit this post.','bioship');} } else {$error = __('Failed! Looks like you may need to login again!','bioship');} // --- output script and exit --- // 2.1.1: added tab argument for saved message display if ($error) {echo "";} else {echo "";} exit; } } // -------------------------------- // QuickSave Cyclic Nonce Refresher // -------------------------------- if (!function_exists('bioship_admin_quicksave_nonce_refresher')) { function bioship_admin_quicksave_nonce_refresher() { if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);} // --- output cyclic nonce refresh script --- global $post; $postid = $post->ID; $adminajax = admin_url('admin-ajax.php'); echo ""; // --- hidden doing refresh input --- // 2.1.1: added input to prevent possible multiple alerts echo ""; // --- quicksave nonce refresh iframe --- echo ""; } } // ---------------------------- // AJAX Update Quicksave Nonces // ---------------------------- if (!function_exists('bioship_admin_update_quicksave_nonces')) { add_action('wp_ajax_quicksave_update_nonces', 'bioship_admin_update_quicksave_nonces'); // 2.1.1: also trigger for not logged in for logged out alert message display add_action('wp_ajax_nopriv_update_nonces', 'bioship_admin_update_quicksave_nonces'); function bioship_admin_update_quicksave_nonces() { if (THEMETRACE) {bioship_trace('F',__FUNCTION__,__FILE__);} // --- get post ID --- $postid = $_REQUEST['postid']; if (!isset($_REQUEST['postid'])) {exit;} $postid = $_REQUEST['postid']; if (!is_numeric($postid)) {exit;} // --- session timeout message --- // 2.1.1: added alert message to inform of session timeout // TODO: trigger showing of popup interim login thickbox ? if (!is_user_logged_in()) { $message = __('Your session has timed out. Please Login again to continue editing.','bioship'); echo ""; exit; } // --- check edit permissions --- if (!current_user_can('edit_posts') || !current_user_can('edit_post', $postid)) {exit;} // --- create new nonces --- $settingsnonce = wp_create_nonce('quicksave-perpost-settings-'.$postid); $cssnonce = wp_create_nonce('quicksave-perpost-css-'.$postid); // --- send new nonces back to parent window --- // 2.1.1: reset doing nonce refresh flag on refresh echo ""; exit; } }