/** * Gets instance of class. * * @return WP_Recipe_Cross_Reference_Posts Instance of the class. */ public static function get_instance() { if (null == self::$instance) { self::$instance = new self(); } return self::$instance; }
/** * Renders recipe index item. * * @param $recipe_id string Recipe id. */ public function render($recipe_id) { $wp_recipe = WP_Recipe::get_instance(); $post_meta_key = WP_Recipe_Cross_Reference_Posts::get_instance()->get_post_meta_key(); $post_references = get_post_meta($recipe_id, $post_meta_key); if (empty($post_references)) { return; } $permalink = get_permalink($post_references[0]); $title = get_the_title(); $link_title = __('View recipe for', $wp_recipe->get_slug()) . ' ' . $title; echo '<li>'; echo '<a href="' . $permalink . '" rel="bookmark" title="' . $link_title . '">'; echo $title; echo '</a>'; echo '</li>'; }
/** * 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();