Plugin Directory

Changeset 2149049


Ignore:
Timestamp:
08/31/2019 10:48:10 PM (6 years ago)
Author:
Waterloo Plugins
Message:

Updated

Location:
recipe-snippets/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • recipe-snippets/trunk/readme.txt

    r1286006 r2149049  
    11=== Plugin Name ===
    22Contributors: Waterloo Plugins
    3 Tags: recipe, recipe snippet, google, seo, bing, yahoo, search engine optimization, rich snippets, food, cook
     3Tags: recipe, google, seo, search engine optimization, rich snippets
    44Requires at least: 3.0
    5 Tested up to: 4.4
    6 Stable tag: 1.0.0
     5Tested up to: 5.2.2
     6Stable tag: 1.0.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    9393== Changelog ==
    9494
     95= 1.0.1 =
     96* Clearer instructions
     97
    9598= 1.0 =
    9699* Initial
  • recipe-snippets/trunk/recipe-snippets.php

    r1286006 r2149049  
    66 *
    77 * @recipe-snippets
    8  * Plugin Name:       Google Recipe Snippets
     8 * Plugin Name:       SEO Recipe Snippets
    99 * Plugin URI:        http://wordpress.org/plugins/recipe-snippets/
    1010 * Description:       Add recipe snippets to Google search results for SEO.
    11  * Version:           1.0.0
     11 * Version:           1.0.1
    1212 * Author:            Waterloo Plugins
    1313 * Author URI:        http://uwaterloo/
     
    1616 * Text Domain:       recipe-snippets
    1717 */
    18 
     18error_reporting(E_ALL);
    1919// If this file is called directly, abort.
    2020if ( ! defined( 'WPINC' ) ) {
     
    2525    private $props;
    2626    private $showRecipe=false;
    27    
     27
    2828    private function time_to_iso8601_duration($time) {
    2929        $units = array(
     
    5050            }
    5151        }
    52        
     52
    5353        return $str;
    5454    }
    55    
     55
    5656    private function stringToDuration($str) {
    5757        $str=preg_replace('/\band\b/i','',$str);
    58        
     58
    5959        $time=strtotime($str,0);
    60        
     60
    6161        return $this->time_to_iso8601_duration($time);
    6262    }
    63    
     63
    6464    private function format_string($str) {
    6565        $str=preg_replace('/<br\s*\/?>/i',"\n",$str);
     
    6767        return $str;
    6868    }
    69    
     69
    7070    public function __construct() {
    7171        $this->props=array(
     
    7474        );
    7575    }
    76    
     76
    7777    public function setupPost() {
    7878        if(!is_single())
    7979            return;
    80        
     80
    8181        global $post;
    8282        $this->props['name']=$post->post_title;
     
    8585            $this->props['image']=wp_get_attachment_url(get_post_thumbnail_id($post->ID));
    8686    }
    87    
     87
    8888    public function processShortcode($attrs, $content='') {
    8989        if(!isset($attrs['type']))
    9090            return;
    91        
     91
    9292        $this->showRecipe=true;
    9393        $content=trim($content);
    94        
     94
    9595        $type=$attrs['type'];
    9696        $props=&$this->props;
     
    120120            $props['recipeIngredient'][]=$content;
    121121        }
    122        
     122
    123123        if(!isset($attrs['display'])||$attrs['display']!=='none')
    124124            return $content;
    125125    }
    126    
     126
    127127    public function printData() {
    128128        if(!$this->showRecipe)
    129129            return;
    130        
     130
    131131        $props=$this->props;
    132        
     132
    133133        if(isset($props['ratingValue'])||isset($props['reviewCount'])){
    134134            $t=array('@type'=>'AggregateRating');
     
    143143            $props['aggregateRating']=(object)$t;
    144144        }
    145        
     145
    146146        if(isset($props['name'])){
    147147            ?>
     
    149149            <?php echo json_encode((object) $props); ?>
    150150            </script>
    151             <?php   
     151            <?php
    152152        }
     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;
    153158    }
    154159}
     
    159164add_action('wp', array(&$recipeSnippets, 'setupPost'));
    160165add_action('wp_footer', array(&$recipeSnippets, 'printData'));
     166add_action('plugin_action_links_recipe-snippets/recipe-snippets.php', array(&$recipeSnippets, 'add_action_links'));
Note: See TracChangeset for help on using the changeset viewer.