/** * 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')); } } } } }
* @return void */ public function save_post($post_id, $post = NULL) { // 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, we check the current blog_id // against the hidden post variable for the blog_id. if (!isset($_POST['post_is_translated_blogid']) || $_POST['post_is_translated_blogid'] != get_current_blog_id()) { return; } // If checkbox is not checked, return if (isset($_POST['translate_this_post'])) { return; } delete_post_meta($post_id, 'post_is_translated'); // Well, is this post translated? we just need the single way if (isset($_POST['_post_is_translated']) && 'on' == $_POST['_post_is_translated']) { update_post_meta($post_id, '_post_is_translated', '1'); } else { update_post_meta($post_id, '_post_is_translated', '0'); } } } if (function_exists('add_filter')) { Multilingual_Press_Dashboard_Widget::get_object(); }