/** * Gets instance of class. * * @return WP_Recipe_Cross_Reference_Recipes Instance of the class. */ public static function get_instance() { if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Saves data. */ public function __save() { global $post; if (empty($post) || !array_key_exists('content', $_POST)) { return; } $post_id = $post->ID; $wp_recipe = WP_Recipe::get_instance(); $wp_recipe_util = WP_Recipe_Util::get_instance(); $post_references = WP_Recipe_Cross_Reference_Posts::get_instance(); $recipe_references = WP_Recipe_Cross_Reference_Recipes::get_instance(); /* * Need to grab the content from `$_POST` and not the `global post` because * the `global post` contains the existing post information and the `$_POST` * contains the new information being saved. */ $shortcode = $wp_recipe_util->get_shortcode($wp_recipe->get_slug()); $recipe_ids = $wp_recipe_util->get_shortcode_attribute_values($_POST['content'], $shortcode, 'id'); $post_references->update($post_id, $recipe_ids); $recipe_references->update($post_id, $recipe_ids); }
<?php WP_Recipe_Cross_Reference_Posts::get_instance(); WP_Recipe_Cross_Reference_Recipes::get_instance(); WP_Recipe_Cross_References::get_instance(); WP_Recipe_Description::get_instance(); WP_Recipe_Difficulty::get_instance(); WP_Recipe_Directions::get_instance(); WP_Recipe_Enqueue_Admin_Scripts::get_instance(); WP_Recipe_Enqueue_Admin_Styles::get_instance(); WP_Recipe_Enqueue_Scripts::get_instance(); WP_Recipe_Enqueue_Styles::get_instance(); WP_Recipe_Grunticon::get_instance(); WP_Recipe_Id::get_instance(); WP_Recipe_Ingredients::get_instance(); WP_Recipe_Post_Type::get_instance(); WP_Recipe_Post_Type_Columns::get_instance(); WP_Recipe_Post_Type_Remove_Default_Views::get_instance(); WP_Recipe_Query::get_instance(); WP_Recipe_Search_Results::get_instance(); WP_Recipe_Shortcode::get_instance(); WP_Recipe_Taxonomies::get_instance(); WP_Recipe_Tips::get_instance(); WP_Recipe_Yield::get_instance();
/** * Gets recipes removed from post. * * @param string $post_id Post id. * @param array $recipe_ids_used_in_post Recipe ids used in the post. * * @return array Recipes removed from post. */ private function get_recipes_removed_from_post($post_id, $recipe_ids_used_in_post) { $previous_recipe_ids_used_in_post = get_post_meta($post_id, WP_Recipe_Cross_Reference_Recipes::get_instance()->get_post_meta_key()); return array_diff($previous_recipe_ids_used_in_post, $recipe_ids_used_in_post); }