/**
  * add the metaboxes on posts and pages
  *
  * @access  public
  * @since   0.1
  * @uses	add_meta_box
  * @global	$post | the current post
  * @return  void
  */
 public function add_meta_boxes($post_type = NULL, $post = NULL)
 {
     $post_types = $this->get_custom_post_types();
     if (is_null($post_type) or is_null($post) or empty($post_types) or empty($post_types[$post_type])) {
         return;
     }
     $options = get_site_option('inpsyde_multilingual_cpt');
     foreach ($post_types as $cpt => $params) {
         if ($cpt == $post_type) {
             if (!empty($options['post_types'][$cpt])) {
                 // Do we have linked elements?
                 $linked = mlp_get_linked_elements($post->ID);
                 if (!$linked) {
                     return add_meta_box('multilingual_press_translate', __(sprintf('Multilingual Press: Translate  %s', $cpt), 'multilingualpress'), array($this, 'display_meta_box_translate'), $cpt, 'normal', 'high');
                 }
                 // Register metaboxes
                 add_meta_box('multilingual_press_link', __(sprintf('Multilingual Press: Linked  %s', $cpt)), array($this, 'display_cpt_meta_box'), $cpt, 'normal', 'high');
             } else {
                 if (is_callable(array('Multilingual_Press_Trasher', 'get_object'))) {
                     remove_filter('post_submitbox_misc_actions', array(Multilingual_Press_Trasher::get_object(), 'post_submitbox_misc_actions'));
                 }
                 if (is_callable(array('Multilingual_Press_Dashboard_Widget', 'get_object'))) {
                     remove_filter('post_submitbox_misc_actions', array(Multilingual_Press_Dashboard_Widget::get_object(), 'post_submitbox_misc_actions'));
                 }
             }
         }
     }
 }
 /**
  * update post meta
  *
  * @since   0.4
  * @access  public
  * @uses	get_post_status, update_post_meta
  * @param   $post_id ID of the post
  * @return  void
  */
 public function save_post($post_id, $post = NULL)
 {
     // leave function if box was not available
     if (!isset($_POST['trasher_box'])) {
         return;
     }
     // We're only interested in published posts at this time
     $post_status = get_post_status($post_id);
     if ('publish' !== $post_status && 'draft' !== $post_status) {
         return;
     }
     // Avoid recursion:
     // wp_insert_post() invokes the save_post hook, so we have to make sure
     // the loop below is only entered once per save action. Therefore we save
     // the source_blog in a static class variable. If it is already set we
     // know the loop has already been entered and we can exit the save action.
     if (NULL === self::$source_blog) {
         self::$source_blog = get_current_blog_id();
     } else {
         return;
     }
     // old key
     delete_post_meta($post_id, 'trash_the_other_posts');
     $trash_the_other_posts = FALSE;
     // Should the other post also been trashed?
     if (isset($_POST['_trash_the_other_posts']) && 'on' == $_POST['_trash_the_other_posts']) {
         update_post_meta($post_id, '_trash_the_other_posts', '1');
         $trash_the_other_posts = TRUE;
     } else {
         update_post_meta($post_id, '_trash_the_other_posts', '0');
     }
     // Get linked posts
     $linked_posts = mlp_get_linked_elements($post_id);
     foreach ($linked_posts as $linked_blog => $linked_post) {
         switch_to_blog($linked_blog);
         delete_post_meta($linked_post, 'trash_the_other_posts');
         // Should the other post also been trashed?
         if ($trash_the_other_posts) {
             update_post_meta($linked_post, '_trash_the_other_posts', '1');
         } else {
             update_post_meta($linked_post, '_trash_the_other_posts', '0');
         }
         restore_current_blog();
     }
 }