Plugin Directory

Changeset 1688778


Ignore:
Timestamp:
07/01/2017 03:57:07 PM (9 years ago)
Author:
optimality
Message:

Category name fix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • optimality/trunk/markup/post.php

    r1688504 r1688778  
    1515    const SMDESC = 'post_smdesc';
    1616
     17    public $section;
     18
    1719
    1820    function __construct($object)
     
    2224
    2325
     26    function __invoke($target, $option)
     27    {
     28        if (count($object = get_the_terms($this->proto, 'category')))
     29        {
     30            $this->section = $object[0]->name;
     31        }
     32
     33        return parent::__invoke($target, $option);
     34    }
     35
     36
    2437    function getMeta($option)
    2538    {
    26         $object = get_the_terms($this->proto, 'category');
    27 
    2839        return array_merge(parent::getMeta($option),
    2940        [
    30             'article:section' => empty($object) ? NULL : $object[0]->name,
     41            'article:section' => $this->section,
    3142            'article:tag'     => array_map(function($object)
    3243            {
     
    4051    function getJson($option)
    4152    {
    42         $object = get_the_terms($this->proto, 'category');
    43 
    4453        return array_merge(parent::getJson($option),
    4554        [
    4655            '@type'           => 'Article',
    47             'articleSection'  => empty($object) ? NULL : $object[0]->name,
     56            'articleSection'  => $this->section,
    4857            'keywords'        => implode(',', array_map(function($object)
    4958            {
Note: See TracChangeset for help on using the changeset viewer.