Changeset 2149049
- Timestamp:
- 08/31/2019 10:48:10 PM (6 years ago)
- Location:
- recipe-snippets/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
recipe-snippets.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
recipe-snippets/trunk/readme.txt
r1286006 r2149049 1 1 === Plugin Name === 2 2 Contributors: Waterloo Plugins 3 Tags: recipe, recipe snippet, google, seo, bing, yahoo, search engine optimization, rich snippets, food, cook3 Tags: recipe, google, seo, search engine optimization, rich snippets 4 4 Requires at least: 3.0 5 Tested up to: 4.46 Stable tag: 1.0. 05 Tested up to: 5.2.2 6 Stable tag: 1.0.1 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 93 93 == Changelog == 94 94 95 = 1.0.1 = 96 * Clearer instructions 97 95 98 = 1.0 = 96 99 * Initial -
recipe-snippets/trunk/recipe-snippets.php
r1286006 r2149049 6 6 * 7 7 * @recipe-snippets 8 * Plugin Name: GoogleRecipe Snippets8 * Plugin Name: SEO Recipe Snippets 9 9 * Plugin URI: http://wordpress.org/plugins/recipe-snippets/ 10 10 * Description: Add recipe snippets to Google search results for SEO. 11 * Version: 1.0. 011 * Version: 1.0.1 12 12 * Author: Waterloo Plugins 13 13 * Author URI: http://uwaterloo/ … … 16 16 * Text Domain: recipe-snippets 17 17 */ 18 18 error_reporting(E_ALL); 19 19 // If this file is called directly, abort. 20 20 if ( ! defined( 'WPINC' ) ) { … … 25 25 private $props; 26 26 private $showRecipe=false; 27 27 28 28 private function time_to_iso8601_duration($time) { 29 29 $units = array( … … 50 50 } 51 51 } 52 52 53 53 return $str; 54 54 } 55 55 56 56 private function stringToDuration($str) { 57 57 $str=preg_replace('/\band\b/i','',$str); 58 58 59 59 $time=strtotime($str,0); 60 60 61 61 return $this->time_to_iso8601_duration($time); 62 62 } 63 63 64 64 private function format_string($str) { 65 65 $str=preg_replace('/<br\s*\/?>/i',"\n",$str); … … 67 67 return $str; 68 68 } 69 69 70 70 public function __construct() { 71 71 $this->props=array( … … 74 74 ); 75 75 } 76 76 77 77 public function setupPost() { 78 78 if(!is_single()) 79 79 return; 80 80 81 81 global $post; 82 82 $this->props['name']=$post->post_title; … … 85 85 $this->props['image']=wp_get_attachment_url(get_post_thumbnail_id($post->ID)); 86 86 } 87 87 88 88 public function processShortcode($attrs, $content='') { 89 89 if(!isset($attrs['type'])) 90 90 return; 91 91 92 92 $this->showRecipe=true; 93 93 $content=trim($content); 94 94 95 95 $type=$attrs['type']; 96 96 $props=&$this->props; … … 120 120 $props['recipeIngredient'][]=$content; 121 121 } 122 122 123 123 if(!isset($attrs['display'])||$attrs['display']!=='none') 124 124 return $content; 125 125 } 126 126 127 127 public function printData() { 128 128 if(!$this->showRecipe) 129 129 return; 130 130 131 131 $props=$this->props; 132 132 133 133 if(isset($props['ratingValue'])||isset($props['reviewCount'])){ 134 134 $t=array('@type'=>'AggregateRating'); … … 143 143 $props['aggregateRating']=(object)$t; 144 144 } 145 145 146 146 if(isset($props['name'])){ 147 147 ?> … … 149 149 <?php echo json_encode((object) $props); ?> 150 150 </script> 151 <?php 151 <?php 152 152 } 153 } 154 155 function add_action_links($links) { 156 $links[] = '<a href="https://wordpress.org/plugins/recipe-snippets/" target="_blank">Instructions</a>'; 157 return $links; 153 158 } 154 159 } … … 159 164 add_action('wp', array(&$recipeSnippets, 'setupPost')); 160 165 add_action('wp_footer', array(&$recipeSnippets, 'printData')); 166 add_action('plugin_action_links_recipe-snippets/recipe-snippets.php', array(&$recipeSnippets, 'add_action_links'));
Note: See TracChangeset
for help on using the changeset viewer.