Plugin Directory

Changeset 1685786


Ignore:
Timestamp:
06/26/2017 09:08:05 PM (9 years ago)
Author:
optimality
Message:

Changes towards 0.4.0

Location:
optimality/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • optimality/trunk/index.php

    r1684796 r1685786  
    55 * Plugin URI:  https://wordpress.org/plugins/optimality
    66 * Description: Optimizes website's content delivery, images, database, permalink structure, search engines and social media markup.
    7  * Version:     0.3.0
     7 * Version:     0.4.0
    88 * License:     GPLv2 or later
    99 * Author:      Optimality
     
    1818require_once('markup/page.php');
    1919require_once('markup/post.php');
     20require_once('markup/term.php');
    2021require_once('markup/section.php');
    21 require_once('markup/term.php');
    2222require_once('markup/user.php');
    2323require_once('markup/comment.php');
     
    265265            $markup = new $markup(get_queried_object());
    266266
    267             if ($target = $markup->apply(__TARGET__, $this->option))
     267            if ($target = $markup(__TARGET__, $this->option))
    268268            {
    269269                wp_redirect($target, 301); exit();
  • optimality/trunk/markup/html.php

    r1683276 r1685786  
    4545
    4646
     47    function __invoke($target, $option)
     48    {
     49        $this->site = $this->site ?: new Site();
     50
     51        if ($this->user && is_numeric($this->user))
     52        {
     53            $this->user = new User(get_userdata($this->user));
     54        }
     55
     56        $this->attr = array
     57        (
     58            ':name'        => $this->name,
     59            ':tagline'     => $this->lead,
     60            ':excerpt'     => $this->lead,
     61            ':caption'     => $this->lead,
     62            ':category'    => @$this->section,
     63            ':biography'   => $this->desc,
     64            ':description' => $this->desc,
     65            'site:name'    => @$this->site->name,
     66            'site:tagline' => @$this->site->lead,
     67        );
     68
     69        $this->file = array
     70        (
     71            __CDNURL__ => $option[static::CDNURL],
     72        );
     73    }
     74
     75
    4776    function setMeta($handle, $string)
    4877    {
     
    184213
    185214
    186     function apply($target, $option)
    187     {
    188         $this->site = $this->site ?: new Site();
    189 
    190         if ($this->user && is_numeric($this->user))
    191         {
    192             $this->user = new User(get_userdata($this->user));
    193         }
    194 
    195         $this->attr = array
    196         (
    197             ':name'        => $this->name,
    198             ':tagline'     => $this->lead,
    199             ':excerpt'     => $this->lead,
    200             ':caption'     => $this->lead,
    201             ':category'    => @$this->section,
    202             ':biography'   => $this->desc,
    203             ':description' => $this->desc,
    204             'site:name'    => @$this->site->name,
    205             'site:tagline' => @$this->site->lead,
    206         );
    207 
    208         $this->file = array
    209         (
    210             __CDNURL__ => $option[static::CDNURL],
    211         );
    212     }
    213 
    214 
    215215    function build($string, $option)
    216216    {
  • optimality/trunk/markup/page.php

    r1685187 r1685786  
    3333
    3434
    35     function getMeta($option)
    36     {
    37         return array_merge(parent::getMeta($option),
    38         [
    39             'og:type'                => 'article',
    40             'article:published_time' => $this->date,
    41             'article:modified_time'  => $this->edit,
    42             'article:author'         => $this->user->face,
    43             'article:publisher'      => $this->site->face,
    44         ]);
    45     }
    46 
    47 
    48     function apply($target, $option)
     35    function __invoke($target, $option)
    4936    {
    5037        if (@$option[static::SEMETA])
     
    7259        }
    7360
    74         return parent::apply($target, $option);
     61        return parent::__invoke($target, $option);
     62    }
     63
     64
     65    function getMeta($option)
     66    {
     67        return array_merge(parent::getMeta($option),
     68        [
     69            'og:type'                => 'article',
     70            'article:published_time' => $this->date,
     71            'article:modified_time'  => $this->edit,
     72            'article:author'         => $this->user->face,
     73            'article:publisher'      => $this->site->face,
     74        ]);
    7575    }
    7676
  • optimality/trunk/markup/post.php

    r1684796 r1685786  
    2727
    2828
     29    function __invoke($target, $option)
     30    {
     31        if (is_array($result = get_the_terms($this->ruid, 'category')))
     32        {
     33            $this->section = @$result[0]->name;
     34        }
     35
     36        if (is_array($result = get_the_terms($this->ruid, 'post_tag')))
     37        {
     38            foreach ($result as $object) $this->terms[] = $object->name;
     39        }
     40
     41        return parent::__invoke($target, $option);
     42    }
     43
     44
    2945    function getJson($option)
    3046    {
     
    4662            'article:tag'            => $this->terms,
    4763        ]);
    48     }
    49 
    50 
    51     function apply($target, $option)
    52     {
    53         if (is_array($result = get_the_terms($this->ruid, 'category')))
    54         {
    55             $this->section = @$result[0]->name;
    56         }
    57 
    58         if (is_array($result = get_the_terms($this->ruid, 'post_tag')))
    59         {
    60             foreach ($result as $object) $this->terms[] = $object->name;
    61         }
    62 
    63         return parent::apply($target, $option);
    6464    }
    6565
  • optimality/trunk/markup/section.php

    r1683276 r1685786  
    33namespace optimality;
    44
    5 class Section extends Html
     5class Section extends Term
    66{
    77    const UNBASE = 'section_unbase';
     
    1717    {
    1818        parent::__construct($object);
    19 
    20         $this->type  = 'CollectionPage';
    21         $this->ruid  = $object->term_id;
    22         $this->slug  = $object->slug;
    23         $this->name  = $object->name;
    24         $this->desc  = $object->description;
    25         $this->route = get_term_link($object);
    2619    }
    2720
    2821
    29     function apply($target, $option)
     22    function __invoke($target, $option)
    3023    {
    3124        if ($option[static::UNBASE])
     
    3730        }
    3831
    39         return parent::apply($target, $option);
     32        return parent::__invoke($target, $option);
    4033    }
    4134
  • optimality/trunk/markup/sitemap.php

    r1683276 r1685786  
    4949
    5050
    51     function apply($target, $option)
     51    function __invoke($target, $option)
    5252    {
    5353        $this->file = array
  • optimality/trunk/markup/term.php

    r1683276 r1685786  
    66{
    77    const DBLINK = 'term_dblink';
    8 
    98    const SEMETA = 'term_semeta';
    109    const SENAME = 'term_sename';
     
    1413    const SMDESC = 'term_smdesc';
    1514
     15    public $items;
     16
    1617
    1718    function __construct($object)
     
    1920        parent::__construct($object);
    2021
    21         $this->type  = 'CollectionPage';
     22        $this->type  = 'ItemList';
    2223        $this->ruid  = $object->term_id;
    2324        $this->slug  = $object->slug;
     
    2526        $this->desc  = $object->description;
    2627        $this->route = get_term_link($object);
     28        $this->items = [ ];
     29    }
     30
     31
     32    function __invoke($target, $option)
     33    {
     34        foreach (@$GLOBALS['wp_query']->posts ?: [] as $offset => $object)
     35        {
     36            $this->items[] = array
     37            (
     38                '@type'    => 'ListItem',
     39                'position' => $offset + 1,
     40                'url'      => get_permalink($object),
     41            );
     42        }
     43
     44        return parent::__invoke($target, $option);
     45    }
     46
     47
     48    function getJson($option)
     49    {
     50        return array_merge(parent::getJson($option),
     51        [
     52            'numberOfItems'   => count($this->items),
     53            'itemListElement' => $this->items,
     54        ]);
    2755    }
    2856
  • optimality/trunk/markup/user.php

    r1683276 r1685786  
    4444
    4545
     46    function __invoke($target, $option)
     47    {
     48        if (@$option[static::UNLINK])
     49        {
     50            return static::route($target, NULL);
     51        }
     52
     53        return parent::__invoke($target, $option);
     54    }
     55
     56
    4657    function getJson($option)
    4758    {
     
    6879
    6980
    70     function apply($target, $option)
    71     {
    72         if (@$option[static::UNLINK])
    73         {
    74             return static::route($target, NULL);
    75         }
    76 
    77         return parent::apply($target, $option);
    78     }
    79 
    80 
    8181    static function route($origin, $userid)
    8282    {
  • optimality/trunk/readme.txt

    r1685450 r1685786  
    7878
    7979= 0.4.0 =
     80* Feature: ItemList schema instead CollectionPage for taxonomies
    8081* Feature: Remove 'hentry' class from posts to fix Webmaster errors
    8182
Note: See TracChangeset for help on using the changeset viewer.