Ejemplo n.º 1
0
 public function save_post_override_fields($post_id)
 {
     if (!isset($_POST['post_override_fields_nonce'])) {
         return;
     }
     if (!wp_verify_nonce($_POST['post_override_fields_nonce'], 'save_post_override_fields')) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id)) {
             return;
         }
     } else {
         if (!current_user_can('edit_post', $post_id)) {
             return;
         }
     }
     if (!isset($_POST['post_title_override']) || !isset($_POST['post_description_override'])) {
         return;
     }
     $title_override = $_POST['post_title_override'];
     $description_override = $_POST['post_description_override'];
     update_post_meta($post_id, $this->plugin->get_option_prefix() . 'post_title_override', $title_override);
     update_post_meta($post_id, $this->plugin->get_option_prefix() . 'post_description_override', $description_override);
 }
 /**
  * Returns the specified override tag set on the post. Returns an empty string if there is no override set.
  *
  * @since   1.0.0
  * @param   WP_POST  $post      The post object
  * @param   string   $tag_type  The override to retrieve ('post_title' or 'post_description')
  * @return  string              The override value, or an empty string
  */
 private function get_override_tag($post, $tag_type)
 {
     $override_key = $this->plugin->get_plugin_option('custom_' . $tag_type . '_override_field');
     $override_key = $override_key ? $override_key : $this->plugin->get_option_prefix() . $tag_type . '_override';
     return get_post_meta($post->ID, $override_key, true);
 }