/** * 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')); } } } } }
} 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(); } } } if (function_exists('add_filter')) { Multilingual_Press_Trasher::get_object(); }