function gabfire_meta_box_save($post_id) { // Bail if we're doing an auto save if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; } // if our nonce isn't there, or we can't verify it, bail if (!isset($_POST['meta_box_nonce']) || !wp_verify_nonce($_POST['meta_box_nonce'], 'my_meta_box_nonce')) { return; } // if our current user can't edit this post, bail if (!current_user_can('edit_post')) { return; } // now we can actually save the data $allowed = array('a' => array('href' => array())); if (get_current_post_type() == 'doc') { if (isset($_POST['gabfire_doc_product']) && !empty($_POST['gabfire_doc_product'])) { update_post_meta($post_id, 'gabfire_doc_product', esc_attr($_POST['gabfire_doc_product'])); } } if (get_current_post_type() == 'download') { if (isset($_POST['gabfire_product_php_version']) && !empty($_POST['gabfire_product_php_version'])) { update_post_meta($post_id, 'gabfire_product_php_version', esc_attr($_POST['gabfire_product_php_version'])); } } if (get_current_post_type() == 'portfolio' or get_current_post_type() == 'post' or get_current_post_type() == 'page') { if (isset($_POST['iframe']) && !empty($_POST['iframe'])) { update_post_meta($post_id, 'iframe', wp_kses($_POST['iframe'], $allowed)); } if (isset($_POST['gabfire_post_template']) && !empty($_POST['gabfire_post_template'])) { update_post_meta($post_id, 'gabfire_post_template', esc_attr($_POST['gabfire_post_template'])); } if (isset($_POST['subtitle']) && !empty($_POST['subtitle'])) { update_post_meta($post_id, 'subtitle', wp_kses($_POST['subtitle'], $allowed)); } $chk3 = isset($_POST['disable_postslider']) && $_POST['disable_postslider'] ? 'true' : 'false'; update_post_meta($post_id, 'disable_postslider', $chk3); $chk2 = isset($_POST['post_feaimage']) && $_POST['post_feaimage'] ? 'true' : 'false'; update_post_meta($post_id, 'post_feaimage', $chk2); if (isset($_POST['form_id']) && !empty($_POST['form_id'])) { update_post_meta($post_id, 'form_id', wp_kses($_POST['form_id'], $allowed)); } } if (get_current_post_type() == 'portfolio') { if (isset($_POST['technology_1']) && !empty($_POST['technology_1'])) { update_post_meta($post_id, 'technology_1', wp_kses($_POST['technology_1'], $allowed)); } if (isset($_POST['technology_2']) && !empty($_POST['technology_2'])) { update_post_meta($post_id, 'technology_2', wp_kses($_POST['technology_2'], $allowed)); } if (isset($_POST['technology_3']) && !empty($_POST['technology_3'])) { update_post_meta($post_id, 'technology_3', wp_kses($_POST['technology_3'], $allowed)); } if (isset($_POST['technology_4']) && !empty($_POST['technology_4'])) { update_post_meta($post_id, 'technology_4', wp_kses($_POST['technology_4'], $allowed)); } if (isset($_POST['technology_5']) && !empty($_POST['technology_5'])) { update_post_meta($post_id, 'technology_5', wp_kses($_POST['technology_5'], $allowed)); } if (isset($_POST['technology_6']) && !empty($_POST['technology_6'])) { update_post_meta($post_id, 'technology_6', wp_kses($_POST['technology_6'], $allowed)); } if (isset($_POST['client_name']) && !empty($_POST['client_name'])) { update_post_meta($post_id, 'client_name', wp_kses($_POST['client_name'], $allowed)); } if (isset($_POST['project_introduction']) && !empty($_POST['project_introduction'])) { update_post_meta($post_id, 'project_introduction', wp_kses($_POST['project_introduction'], $allowed)); } if (isset($_POST['project_date']) && !empty($_POST['project_date'])) { update_post_meta($post_id, 'project_date', wp_kses($_POST['project_date'], $allowed)); } if (isset($_POST['project_link']) && !empty($_POST['project_link'])) { update_post_meta($post_id, 'project_link', wp_kses($_POST['project_link'], $allowed)); } } if (get_current_post_type() == 'member') { /* Team members field */ if (isset($_POST['position']) && !empty($_POST['position'])) { update_post_meta($post_id, 'position', wp_kses($_POST['position'], $allowed)); } if (isset($_POST['facebook']) && !empty($_POST['facebook'])) { update_post_meta($post_id, 'facebook', wp_kses($_POST['facebook'], $allowed)); } if (isset($_POST['twitter']) && !empty($_POST['twitter'])) { update_post_meta($post_id, 'twitter', wp_kses($_POST['twitter'], $allowed)); } if (isset($_POST['linkedin']) && !empty($_POST['linkedin'])) { update_post_meta($post_id, 'linkedin', wp_kses($_POST['linkedin'], $allowed)); } if (isset($_POST['linkedin']) && !empty($_POST['linkedin'])) { update_post_meta($post_id, 'linkedin', wp_kses($_POST['linkedin'], $allowed)); } if (isset($_POST['phone']) && !empty($_POST['phone'])) { update_post_meta($post_id, 'phone', wp_kses($_POST['phone'], $allowed)); } if (isset($_POST['email']) && !empty($_POST['email'])) { update_post_meta($post_id, 'email', wp_kses($_POST['email'], $allowed)); } if (isset($_POST['skill_1']) && !empty($_POST['skill_1'])) { update_post_meta($post_id, 'skill_1', wp_kses($_POST['skill_1'], $allowed)); } if (isset($_POST['skill_1_percentage']) && !empty($_POST['skill_1_percentage'])) { update_post_meta($post_id, 'skill_1_percentage', wp_kses($_POST['skill_1_percentage'], $allowed)); } if (isset($_POST['skill_2']) && !empty($_POST['skill_2'])) { update_post_meta($post_id, 'skill_2', wp_kses($_POST['skill_2'], $allowed)); } if (isset($_POST['skill_2_percentage']) && !empty($_POST['skill_2_percentage'])) { update_post_meta($post_id, 'skill_2_percentage', wp_kses($_POST['skill_2_percentage'], $allowed)); } if (isset($_POST['skill_3']) && !empty($_POST['skill_3'])) { update_post_meta($post_id, 'skill_3', wp_kses($_POST['skill_3'], $allowed)); } if (isset($_POST['skill_3_percentage']) && !empty($_POST['skill_3_percentage'])) { update_post_meta($post_id, 'skill_3_percentage', wp_kses($_POST['skill_3_percentage'], $allowed)); } if (isset($_POST['skill_4']) && !empty($_POST['skill_4'])) { update_post_meta($post_id, 'skill_4', wp_kses($_POST['skill_4'], $allowed)); } if (isset($_POST['skill_4_percentage']) && !empty($_POST['skill_4_percentage'])) { update_post_meta($post_id, 'skill_4_percentage', wp_kses($_POST['skill_4_percentage'], $allowed)); } if (isset($_POST['skill_5']) && !empty($_POST['skill_5'])) { update_post_meta($post_id, 'skill_5', wp_kses($_POST['skill_5'], $allowed)); } if (isset($_POST['skill_5_percentage']) && !empty($_POST['skill_5_percentage'])) { update_post_meta($post_id, 'skill_5_percentage', wp_kses($_POST['skill_5_percentage'], $allowed)); } if (isset($_POST['skill_6']) && !empty($_POST['skill_6'])) { update_post_meta($post_id, 'skill_6', wp_kses($_POST['skill_6'], $allowed)); } if (isset($_POST['skill_6_percentage']) && !empty($_POST['skill_6_percentage'])) { update_post_meta($post_id, 'skill_6_percentage', wp_kses($_POST['skill_6_percentage'], $allowed)); } if (isset($_POST['additional_info_title']) && !empty($_POST['additional_info_title'])) { update_post_meta($post_id, 'additional_info_title', wp_kses($_POST['additional_info_title'], $allowed)); } if (isset($_POST['additional_info_text']) && !empty($_POST['additional_info_text'])) { update_post_meta($post_id, 'additional_info_text', wp_kses($_POST['additional_info_text'], $allowed)); } if (isset($_POST['experience_1']) && !empty($_POST['experience_1'])) { update_post_meta($post_id, 'experience_1', wp_kses($_POST['experience_1'], $allowed)); } if (isset($_POST['experience_1_period']) && !empty($_POST['experience_1_period'])) { update_post_meta($post_id, 'experience_1_period', wp_kses($_POST['experience_1_period'], $allowed)); } if (isset($_POST['experience_1_decription']) && !empty($_POST['experience_1_decription'])) { update_post_meta($post_id, 'experience_1_decription', wp_kses($_POST['experience_1_decription'], $allowed)); } if (isset($_POST['experience_2']) && !empty($_POST['experience_2'])) { update_post_meta($post_id, 'experience_2', wp_kses($_POST['experience_2'], $allowed)); } if (isset($_POST['experience_2_period']) && !empty($_POST['experience_2_period'])) { update_post_meta($post_id, 'experience_2_period', wp_kses($_POST['experience_2_period'], $allowed)); } if (isset($_POST['experience_2_decription']) && !empty($_POST['experience_2_decription'])) { update_post_meta($post_id, 'experience_2_decription', wp_kses($_POST['experience_2_decription'], $allowed)); } if (isset($_POST['experience_3']) && !empty($_POST['experience_3'])) { update_post_meta($post_id, 'experience_3', wp_kses($_POST['experience_3'], $allowed)); } if (isset($_POST['experience_3_period']) && !empty($_POST['experience_3_period'])) { update_post_meta($post_id, 'experience_3_period', wp_kses($_POST['experience_3_period'], $allowed)); } if (isset($_POST['experience_3_decription']) && !empty($_POST['experience_3_decription'])) { update_post_meta($post_id, 'experience_3_decription', wp_kses($_POST['experience_3_decription'], $allowed)); } if (isset($_POST['experience_4']) && !empty($_POST['experience_4'])) { update_post_meta($post_id, 'experience_4', wp_kses($_POST['experience_4'], $allowed)); } if (isset($_POST['experience_4_period']) && !empty($_POST['experience_4_period'])) { update_post_meta($post_id, 'experience_4_period', wp_kses($_POST['experience_4_period'], $allowed)); } if (isset($_POST['experience_4_decription']) && !empty($_POST['experience_4_decription'])) { update_post_meta($post_id, 'experience_4_decription', wp_kses($_POST['experience_4_decription'], $allowed)); } if (isset($_POST['education_1']) && !empty($_POST['education_1'])) { update_post_meta($post_id, 'education_1', wp_kses($_POST['education_1'], $allowed)); } if (isset($_POST['education_1_period']) && !empty($_POST['education_1_period'])) { update_post_meta($post_id, 'education_1_period', wp_kses($_POST['education_1_period'], $allowed)); } if (isset($_POST['education_1_decription']) && !empty($_POST['education_1_decription'])) { update_post_meta($post_id, 'education_1_decription', wp_kses($_POST['education_1_decription'], $allowed)); } if (isset($_POST['education_2']) && !empty($_POST['education_2'])) { update_post_meta($post_id, 'education_2', wp_kses($_POST['education_2'], $allowed)); } if (isset($_POST['education_2_period']) && !empty($_POST['education_2_period'])) { update_post_meta($post_id, 'education_2_period', wp_kses($_POST['education_2_period'], $allowed)); } if (isset($_POST['education_2_decription']) && !empty($_POST['education_2_decription'])) { update_post_meta($post_id, 'education_2_decription', wp_kses($_POST['education_2_decription'], $allowed)); } if (isset($_POST['education_3']) && !empty($_POST['education_3'])) { update_post_meta($post_id, 'education_3', wp_kses($_POST['education_3'], $allowed)); } if (isset($_POST['education_3_period']) && !empty($_POST['education_3_period'])) { update_post_meta($post_id, 'education_3_period', wp_kses($_POST['education_3_period'], $allowed)); } if (isset($_POST['education_3_decription']) && !empty($_POST['education_3_decription'])) { update_post_meta($post_id, 'education_3_decription', wp_kses($_POST['education_3_decription'], $allowed)); } if (isset($_POST['education_4']) && !empty($_POST['education_4'])) { update_post_meta($post_id, 'education_4', wp_kses($_POST['education_4'], $allowed)); } if (isset($_POST['education_4_period']) && !empty($_POST['education_4_period'])) { update_post_meta($post_id, 'education_4_period', wp_kses($_POST['education_4_period'], $allowed)); } if (isset($_POST['education_4_decription']) && !empty($_POST['education_4_decription'])) { update_post_meta($post_id, 'education_4_decription', wp_kses($_POST['education_4_decription'], $allowed)); } if (isset($_POST['portfolio_tag']) && !empty($_POST['portfolio_tag'])) { update_post_meta($post_id, 'portfolio_tag', wp_kses($_POST['portfolio_tag'], $allowed)); } } }
/** * Admin CSS Modification */ function edd_css() { if (get_current_post_type() !== 'download') { return; } echo "<style>.nosubsub h2{ display: none !important; } .wrap { margin: 0 0 0 20 !important; } </style>"; }
<?php // gets the current post type in the WordPress Admin function get_current_post_type() { global $post, $typenow, $current_screen; //we have a post so we can just get the post type from that if ($post && $post->post_type) { return $post->post_type; } elseif ($typenow) { return $typenow; } elseif ($current_screen && $current_screen->post_type) { return $current_screen->post_type; } elseif (isset($_REQUEST['post_type'])) { return sanitize_key($_REQUEST['post_type']); } //we do not know the post type! return null; } function replace_featured_image_box() { remove_meta_box('postimagediv', 'page', 'side'); add_meta_box('postimagediv', __('Background Image', 'working_one_page'), 'post_thumbnail_meta_box', 'page', 'side', 'low'); } if (get_current_post_type() == 'sections') { add_action('do_meta_boxes', 'replace_featured_image_box'); } ?>
/** * Render Meta Box */ function output_meta_box($post, $args) { if ($this->slug !== get_current_post_type()) { return; } $box_id = $args['id']; $box_args = $this->meta_boxes[$box_id]; extract($box_args); $new_settings = array(); $settings = get_post_custom($post->ID); if (empty($settings)) { $settings = array(); } else { if (isset($meta_key) && !empty($meta_key) && isset($settings[$meta_key])) { $sets = maybe_unserialize($settings[$meta_key][0]); $new_settings = empty($sets) ? array() : $sets; } else { foreach ($settings as $k => $v) { $new_settings[$k] = maybe_unserialize($v[0]); } } } // Start the Engine new SpyropressMetaBoxUi($fields, $box_id, $new_settings, $build_tabs); }
<div class="clear"></div> </div> </div> <!-- /builder-columns-drawer --> <div class="builder-footer"> <a href="#builder-rows" id="builder-row-add" class="button-primary pull-right">New Row</a> <div class="clear"></div> </div> <!-- /builder-footer --> <?php include framework_path() . 'builder/builder-ui-dialogs.php'; ?> <div id="builder-media-toolbar"> <?php if (!$is_content && post_type_supports(get_current_post_type(), 'thumbnail')) { echo '<div id="wp-' . $editor_id . '-editor-tools" class="wp-editor-tools">'; if (!function_exists('media_buttons')) { include ABSPATH . 'wp-admin/includes/media.php'; } echo '<div id="wp-' . $editor_id . '-media-buttons" class="hide-if-no-js wp-media-buttons">'; do_action('media_buttons', $editor_id); echo "</div>\n"; echo "</div>\n"; } ?> </div> <!-- /builder-toolbar --> </div> <!-- /builder-data -->
<div id="builder-error-message"> </div> </div> <div class="builder-popup-footer"> <a href="#" id="builder-error-popup-close" class="builder-popup-close">Close</a> </div> </div> <!-- /builder-error-popup --> <div id="builder-modules" class="builder-popup"> <div class="builder-popup-header"> <h2>Choose a Type of Content</h2> <p>Select a module or widget to add to your content</p> </div> <div class="builder-popup-content"> <?php if (get_current_post_type() == 'template') { ?> <h3 class="module-list-head">Loop Components</h3> <ul class="builder-module-list"> <?php spyropress_builder_render_modules(true); ?> </ul> <?php } ?> <h3 class="module-list-head">Modules</h3> <ul class="builder-module-list">
/** * Add Class to Admin Body tag. */ function admin_body_class() { if ($post_type = get_current_post_type()) { if (in_array($post_type, $this->enabled_post_types)) { return 'builder_enabled '; } } return ''; }
function jc_append_post_status_list() { global $post; $post_type = get_current_post_type(); $complete = ''; $label = ''; if ($post_type == 'policy') { if ($post->post_status == 'approval') { $complete = ' selected="selected"'; $label = '<span id="post-status-display"> Approval</span>'; } ?> <script> jQuery(document).ready(function($){ $("select#post_status").append('<option value="approval" <?php echo $complete; ?> >Submit for approval</option>'); $(".misc-pub-section label").append('<?php echo $label; ?> '); }); </script> <?php } }