예제 #1
0
 /**
  * Save custom values entered in the post edit screen
  *
  * @since 1.0.0
  *
  * @param int $post_id WordPress post identifier
  *
  * @return void
  */
 public static function save($post_id)
 {
     // verify if this is an auto save routine
     // do not take action until the form is submitted
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     // verify nonce
     if (empty($_POST[self::NONCE_NAME]) || !wp_verify_nonce($_POST[self::NONCE_NAME], plugin_basename(__FILE__))) {
         return;
     }
     if (!$post_id) {
         return;
     }
     // does post exist?
     $post = get_post($post_id);
     if (!$post) {
         return;
     }
     // check permissions
     $post_type = get_post_type($post);
     if (!$post_type) {
         return;
     }
     $capability_singular_base = static::postTypeCapabilityBase($post_type);
     if (!($capability_singular_base && current_user_can('edit_' . $capability_singular_base, $post_id))) {
         return;
     }
     \Twitter\WordPress\Admin\Post\TweetIntent::save($post);
     \Twitter\WordPress\Admin\Post\TwitterCard::save($post);
 }