/**
  * Load post meta boxes and actions after post data loaded if post matches publisher preferences and capabilities.
  *
  * @since 1.2.3
  *
  * @global stdClass|WP_Post $post WordPress post object
  * @return void
  */
 public static function load_post_features()
 {
     global $post;
     if (!isset($post)) {
         return;
     }
     $post_type = get_post_type($post);
     // do not load meta boxes if post type not public or post status is public
     if (!self::post_type_is_public($post_type) || self::post_status_is_public($post->ID)) {
         return;
     }
     $capability_singular_base = self::post_type_capability_base($post_type);
     // unable to verify capability for the post type
     // most likely reason: custom post type incorrectly registered
     if (!$capability_singular_base) {
         return;
     }
     // only display post meta boxes if current user can edit the current post
     if (!current_user_can('edit_' . $capability_singular_base, $post->ID)) {
         return;
     }
     // load page meta box if Facebook Page data saved
     $page_to_publish = self::get_publish_page();
     if (!empty($page_to_publish)) {
         if (!class_exists('Facebook_Social_Publisher_Meta_Box_Page')) {
             require_once dirname(__FILE__) . '/publish-box-page.php';
         }
         Facebook_Social_Publisher_Meta_Box_Page::add_meta_box($post_type, $page_to_publish);
     }
     unset($page_to_publish);
     // does the current post support authorship? can the post author post to Facebook Timeline?
     if (post_type_supports($post_type, 'author') && isset($post->post_author) && self::user_can_publish_to_facebook((int) $post->post_author)) {
         if (!class_exists('Facebook_Social_Publisher_Meta_Box_Profile')) {
             require_once dirname(__FILE__) . '/publish-box-profile.php';
         }
         Facebook_Social_Publisher_Meta_Box_Profile::add_meta_box($post_type);
     }
 }
Example #2
0
 /**
  * Load post meta boxes and actions after post data loaded if post matches publisher preferences and capabilities
  *
  * @since 1.1
  */
 public function load_post_features()
 {
     global $post;
     if (!isset($post)) {
         return;
     }
     $post_type = get_post_type($post);
     if (!$post_type) {
         return;
     }
     $capability_singular_base = self::post_type_capability_base($post_type);
     // unable to verify capability for the post type
     // most likely reason: custom post type incorrectly registered
     if (!$capability_singular_base) {
         return;
     }
     if (current_user_can('publish_' . $capability_singular_base, $post->ID)) {
         $this->user_can_publish_post = true;
     }
     // is the current post already public?
     if (self::post_is_public($post->ID)) {
         $this->post_is_public = true;
     }
     // post to page data exists. load features
     if (!$this->post_is_public && !empty($this->page_to_publish)) {
         if (!class_exists('Facebook_Social_Publisher_Meta_Box_Page')) {
             require_once dirname(__FILE__) . '/publish-box-page.php';
         }
         Facebook_Social_Publisher_Meta_Box_Page::add_meta_box($post_type, $this->page_to_publish);
     }
     // can the current user post to Facebook? Does the current post support authorship?
     if ($this->user_can_publish_post && $this->user_can_facebook_publish && post_type_supports($post_type, 'author')) {
         $current_user = wp_get_current_user();
         if (!isset($post->post_author) || $post->post_author == $current_user->ID) {
             if (!$this->post_is_public) {
                 if (!class_exists('Facebook_Social_Publisher_Meta_Box_Profile')) {
                     require_once dirname(__FILE__) . '/publish-box-profile.php';
                 }
                 Facebook_Social_Publisher_Meta_Box_Profile::add_meta_box($post_type);
             }
             // it does not make sense to re-publish a post with mentions to Facebook but an author may want to show additional mentions in the post after it is published.
             // allow for local mentions not sent to Facebook at the time the post was made public
             if (!class_exists('Facebook_Mentions_Box')) {
                 require_once dirname(__FILE__) . '/mentions/mentions-box.php';
             }
             Facebook_Mentions_Box::after_posts_load($post_type);
         }
     }
 }