Changeset 1685786
- Timestamp:
- 06/26/2017 09:08:05 PM (9 years ago)
- Location:
- optimality/trunk
- Files:
-
- 9 edited
-
index.php (modified) (3 diffs)
-
markup/html.php (modified) (2 diffs)
-
markup/page.php (modified) (2 diffs)
-
markup/post.php (modified) (2 diffs)
-
markup/section.php (modified) (3 diffs)
-
markup/sitemap.php (modified) (1 diff)
-
markup/term.php (modified) (4 diffs)
-
markup/user.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
optimality/trunk/index.php
r1684796 r1685786 5 5 * Plugin URI: https://wordpress.org/plugins/optimality 6 6 * Description: Optimizes website's content delivery, images, database, permalink structure, search engines and social media markup. 7 * Version: 0. 3.07 * Version: 0.4.0 8 8 * License: GPLv2 or later 9 9 * Author: Optimality … … 18 18 require_once('markup/page.php'); 19 19 require_once('markup/post.php'); 20 require_once('markup/term.php'); 20 21 require_once('markup/section.php'); 21 require_once('markup/term.php');22 22 require_once('markup/user.php'); 23 23 require_once('markup/comment.php'); … … 265 265 $markup = new $markup(get_queried_object()); 266 266 267 if ($target = $markup ->apply(__TARGET__, $this->option))267 if ($target = $markup(__TARGET__, $this->option)) 268 268 { 269 269 wp_redirect($target, 301); exit(); -
optimality/trunk/markup/html.php
r1683276 r1685786 45 45 46 46 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 47 76 function setMeta($handle, $string) 48 77 { … … 184 213 185 214 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 = array196 (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 = array209 (210 __CDNURL__ => $option[static::CDNURL],211 );212 }213 214 215 215 function build($string, $option) 216 216 { -
optimality/trunk/markup/page.php
r1685187 r1685786 33 33 34 34 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) 49 36 { 50 37 if (@$option[static::SEMETA]) … … 72 59 } 73 60 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 ]); 75 75 } 76 76 -
optimality/trunk/markup/post.php
r1684796 r1685786 27 27 28 28 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 29 45 function getJson($option) 30 46 { … … 46 62 'article:tag' => $this->terms, 47 63 ]); 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);64 64 } 65 65 -
optimality/trunk/markup/section.php
r1683276 r1685786 3 3 namespace optimality; 4 4 5 class Section extends Html5 class Section extends Term 6 6 { 7 7 const UNBASE = 'section_unbase'; … … 17 17 { 18 18 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);26 19 } 27 20 28 21 29 function apply($target, $option)22 function __invoke($target, $option) 30 23 { 31 24 if ($option[static::UNBASE]) … … 37 30 } 38 31 39 return parent:: apply($target, $option);32 return parent::__invoke($target, $option); 40 33 } 41 34 -
optimality/trunk/markup/sitemap.php
r1683276 r1685786 49 49 50 50 51 function apply($target, $option)51 function __invoke($target, $option) 52 52 { 53 53 $this->file = array -
optimality/trunk/markup/term.php
r1683276 r1685786 6 6 { 7 7 const DBLINK = 'term_dblink'; 8 9 8 const SEMETA = 'term_semeta'; 10 9 const SENAME = 'term_sename'; … … 14 13 const SMDESC = 'term_smdesc'; 15 14 15 public $items; 16 16 17 17 18 function __construct($object) … … 19 20 parent::__construct($object); 20 21 21 $this->type = ' CollectionPage';22 $this->type = 'ItemList'; 22 23 $this->ruid = $object->term_id; 23 24 $this->slug = $object->slug; … … 25 26 $this->desc = $object->description; 26 27 $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 ]); 27 55 } 28 56 -
optimality/trunk/markup/user.php
r1683276 r1685786 44 44 45 45 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 46 57 function getJson($option) 47 58 { … … 68 79 69 80 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 81 81 static function route($origin, $userid) 82 82 { -
optimality/trunk/readme.txt
r1685450 r1685786 78 78 79 79 = 0.4.0 = 80 * Feature: ItemList schema instead CollectionPage for taxonomies 80 81 * Feature: Remove 'hentry' class from posts to fix Webmaster errors 81 82
Note: See TracChangeset
for help on using the changeset viewer.