public function filter_json_data_https_schema_org_thing($json_data, $mod, $mt_og, $type_id, $is_main) { if ($this->p->debug->enabled) { $this->p->debug->mark(); } $lca = $this->p->cf['lca']; $type_url = $this->p->schema->get_schema_type_url($type_id); $ret = WpssoSchema::get_schema_type_context($type_url); /* * Property: * url */ WpssoSchema::add_data_itemprop_from_assoc($ret, $mt_og, array('url' => 'og:url')); /* * Property: * name * */ $ret['name'] = $this->p->webpage->get_title($this->p->options['og_title_len'], '...', $mod, true, false, true, 'schema_title'); /* * Property: * description * */ $ret['description'] = $this->p->webpage->get_description($this->p->options['schema_desc_len'], '...', $mod, true, false, true, 'schema_desc'); return WpssoSchema::return_data_from_filter($json_data, $ret, $is_main); }
public static function add_single_video_data(&$json_data, $opts, $prefix = 'og:video', $list_element = true) { $wpsso =& Wpsso::get_instance(); if (empty($opts) || !is_array($opts)) { if ($wpsso->debug->enabled) { $wpsso->debug->log('exiting early: options array is empty or not an array'); } return 0; // return count of videos added } $media_url = SucomUtil::get_mt_media_url($opts, $prefix); if (empty($media_url)) { if ($ngfb->debug->enabled) { $ngfb->debug->log('exiting early: ' . $prefix . ' URL values are empty'); } return 0; // return count of videos added } $ret = array('@context' => 'https://schema.org', '@type' => 'VideoObject', 'url' => esc_url($media_url)); WpssoSchema::add_data_itemprop_from_assoc($ret, $opts, array('name' => $prefix . ':title', 'description' => $prefix . ':description', 'fileFormat' => $prefix . ':type', 'width' => $prefix . ':width', 'height' => $prefix . ':height', 'duration' => $prefix . ':duration', 'uploadDate' => $prefix . ':upload_date', 'thumbnailUrl' => $prefix . ':thumbnail_url', 'embedUrl' => $prefix . ':embed_url')); if (!empty($opts[$prefix . ':has_image'])) { if (!WpssoSchema::add_single_image_data($ret['thumbnail'], $opts, 'og:image', false)) { // list_element = false unset($ret['thumbnail']); } } if (empty($list_element)) { $json_data = $ret; } else { $json_data[] = $ret; } // add an item to the list return 1; // return count of videos added }
public function filter_json_data_https_schema_org_webpage($json_data, $mod, $mt_og, $type_id, $is_main) { if ($this->p->debug->enabled) { $this->p->debug->mark(); } $ret = array(); $lca = $this->p->cf['lca']; // blogposting is a child of article // use the article image size and add the headline property if ($this->p->schema->is_schema_type_child_of($type_id, 'article')) { $org_logo_key = 'org_banner_url'; // use a banner for all article sub-types $size_name = $this->p->cf['lca'] . '-schema-article'; // same size, but minimum width is 696px /* * Property: * headline */ $headline_max_len = WpssoJsonConfig::$cf['schema']['article']['headline']['max_len']; $ret['headline'] = $this->p->webpage->get_title($headline_max_len, '...', $mod); } else { $org_logo_key = 'org_logo_url'; $size_name = $this->p->cf['lca'] . '-schema'; } /* * Property: * datepublished * datemodified */ WpssoSchema::add_data_itemprop_from_assoc($ret, $mt_og, array('datepublished' => 'article:published_time', 'datemodified' => 'article:modified_time')); /* * Property: * inLanguage */ $ret['inLanguage'] = get_locale(); /* * Property: * publisher as https://schema.org/Organization */ $org_id = is_object($mod['obj']) ? $mod['obj']->get_options($mod['id'], 'schema_pub_org_id') : false; // null, false, 'none', 'site', or number (including 0) if ($this->p->debug->enabled) { $this->p->debug->log('publisher / organization id is ' . (empty($org_id) ? 'empty' : $org_id)); } WpssoSchema::add_single_organization_data($ret['publisher'], $mod, $org_id, $org_logo_key, false); // $list_element = false /* * Property: * author as https://schema.org/Person * contributor as https://schema.org/Person */ WpssoSchema::add_author_coauthor_data($ret, $mod); /* * Property: * image as https://schema.org/ImageObject * video as https://schema.org/VideoObject */ WpssoJsonSchema::add_media_data($ret, $mod, $mt_og, $size_name); if (empty($ret['image'])) { if ($this->p->debug->enabled) { $this->p->debug->log('creativework image is missing and required'); } if (is_admin() && (!$mod['is_post'] || $mod['post_status'] === 'publish')) { $this->p->notice->err($this->p->msgs->get('notice-missing-schema-image')); } } return WpssoSchema::return_data_from_filter($json_data, $ret); }