Plugin Directory

Changeset 2697321


Ignore:
Timestamp:
03/21/2022 09:00:57 PM (4 years ago)
Author:
ash_hitch
Message:

Update to version 4.16.2 from GitHub

Location:
add-wpgraphql-seo
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • add-wpgraphql-seo/tags/4.16.2/CHANGELOG.md

    r2678268 r2697321  
    55The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
    66and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     7
     8## [4.16.2] - 2022-03-231
     9
     10### Changed
     11
     12-   Image optimize perf (thanks @kent1D )
     13-   Add guard against undefined user object (thanks @rodrigo-arias)
     14-   PostTypeSEO improvements: More defensive programming (thanks @matthewgrzegorczyk)
    715
    816## [4.16.1] - 2022-01-23
  • add-wpgraphql-seo/tags/4.16.2/readme.txt

    r2678268 r2697321  
    55Tested up to: 5.7
    66Requires PHP: 7.1
    7 Stable tag: 4.16.1
     7Stable tag: 4.16.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • add-wpgraphql-seo/tags/4.16.2/wp-graphql-yoast-seo.php

    r2678268 r2697321  
    99 * Text Domain:     wp-graphql-yoast-seo
    1010 * Domain Path:     /languages
    11  * Version:         4.16.1
     11 * Version:         4.16.2
    1212 *
    1313 * @package         WP_Graphql_YOAST_SEO
     
    8383                $image['url']
    8484            );
     85            // If the image is equal as the original and the original has an id, return this ID
     86            if (isset($image['id']) && $url === $image['url']) {
     87                return $image['id'];
     88            }
    8589            return wpcom_vip_attachment_url_to_postid($url);
    8690        }
     
    147151        }
    148152        return $carry;
     153    }
     154
     155    /**
     156     * @param \Yoast\WP\SEO\Surfaces\Values\Meta|bool $metaForPost
     157     * @return string
     158     */
     159    function wp_gql_seo_get_full_head($metaForPost)
     160    {
     161        if ($metaForPost !== false) {
     162            $head = $metaForPost->get_head();
     163
     164            return is_string($head) ? $head : $head->html;
     165        }
     166
     167        return '';
    149168    }
    150169
     
    726745                            $all['company_name']
    727746                        ),
    728                         'personName' => wp_gql_seo_format_string(
    729                             $user->user_nicename
    730                         ),
     747                        'personName' => !empty($user)
     748                            ? wp_gql_seo_format_string($user->user_nicename)
     749                            : null,
    731750                        'companyLogo' => $context
    732751                            ->get_loader('post')
     
    814833                                    '@context' => 'context',
    815834                                ];
    816 
    817                                 $schemaArray = YoastSEO()->meta->for_post($post->ID)
    818                                     ->schema;
     835                                $meta = YoastSEO()->meta->for_post($post->ID);
     836
     837                                $schemaArray = $meta !== false ? $meta->schema : [];
    819838
    820839                                // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/
    821                                 $robots = YoastSEO()->meta->for_post($post->ID)
    822                                     ->robots;
     840                                $robots = $meta !== false ? $meta->robots : [];
    823841
    824842                                // Get data
    825843                                $seo = [
    826844                                    'title' => wp_gql_seo_format_string(
    827                                         YoastSEO()->meta->for_post($post->ID)->title
     845                                        $meta !== false ? $meta->title : ''
    828846                                    ),
    829847                                    'metaDesc' => wp_gql_seo_format_string(
    830                                         YoastSEO()->meta->for_post($post->ID)
    831                                             ->description
     848                                        $meta !== false ? $meta->description : ''
    832849                                    ),
    833850                                    'focuskw' => wp_gql_seo_format_string(
     
    845862                                        )
    846863                                    ),
    847                                     'metaRobotsNoindex' => $robots['index'],
    848                                     'metaRobotsNofollow' => $robots['follow'],
     864                                    'metaRobotsNoindex' => $robots['index'] ?? '',
     865                                    'metaRobotsNofollow' => $robots['follow'] ?? '',
    849866                                    'opengraphTitle' => wp_gql_seo_format_string(
    850                                         YoastSEO()->meta->for_post($post->ID)
    851                                             ->open_graph_title
     867                                        $meta !== false
     868                                            ? $meta->open_graph_title
     869                                            : ''
    852870                                    ),
    853871                                    'opengraphUrl' => wp_gql_seo_format_string(
    854                                         YoastSEO()->meta->for_post($post->ID)
    855                                             ->open_graph_url
     872                                        $meta !== false ? $meta->open_graph_url : ''
    856873                                    ),
    857874                                    'opengraphSiteName' => wp_gql_seo_format_string(
    858                                         YoastSEO()->meta->for_post($post->ID)
    859                                             ->open_graph_site_name
     875                                        $meta !== false
     876                                            ? $meta->open_graph_site_name
     877                                            : ''
    860878                                    ),
    861879                                    'opengraphType' => wp_gql_seo_format_string(
    862                                         YoastSEO()->meta->for_post($post->ID)
    863                                             ->open_graph_type
     880                                        $meta !== false ? $meta->open_graph_type : ''
    864881                                    ),
    865882                                    'opengraphAuthor' => wp_gql_seo_format_string(
    866                                         YoastSEO()->meta->for_post($post->ID)
    867                                             ->open_graph_article_author
     883                                        $meta !== false
     884                                            ? $meta->open_graph_article_author
     885                                            : ''
    868886                                    ),
    869887                                    'opengraphPublisher' => wp_gql_seo_format_string(
    870                                         YoastSEO()->meta->for_post($post->ID)
    871                                             ->open_graph_article_publisher
     888                                        $meta !== false
     889                                            ? $meta->open_graph_article_publisher
     890                                            : ''
    872891                                    ),
    873892                                    'opengraphPublishedTime' => wp_gql_seo_format_string(
    874                                         YoastSEO()->meta->for_post($post->ID)
    875                                             ->open_graph_article_published_time
     893                                        $meta !== false
     894                                            ? $meta->open_graph_article_published_time
     895                                            : ''
    876896                                    ),
    877897                                    'opengraphModifiedTime' => wp_gql_seo_format_string(
    878                                         YoastSEO()->meta->for_post($post->ID)
    879                                             ->open_graph_article_modified_time
     898                                        $meta !== false
     899                                            ? $meta->open_graph_article_modified_time
     900                                            : ''
    880901                                    ),
    881902                                    'opengraphDescription' => wp_gql_seo_format_string(
    882                                         YoastSEO()->meta->for_post($post->ID)
    883                                             ->open_graph_description
     903                                        $meta !== false
     904                                            ? $meta->open_graph_description
     905                                            : ''
    884906                                    ),
    885907                                    'opengraphImage' => function () use (
    886908                                        $post,
    887                                         $context
     909                                        $context,
     910                                        $meta
    888911                                    ) {
    889912                                        $id = wp_gql_seo_get_og_image(
    890                                             YoastSEO()->meta->for_post($post->ID)
    891                                                 ->open_graph_images
     913                                            $meta !== false
     914                                                ? $meta->open_graph_images
     915                                                : []
    892916                                        );
    893917
     
    897921                                    },
    898922                                    'twitterCardType' => wp_gql_seo_format_string(
    899                                         YoastSEO()->meta->for_post($post->ID)
    900                                             ->twitter_card
     923                                        $meta !== false ? $meta->twitter_card : ''
    901924                                    ),
    902925                                    'twitterTitle' => wp_gql_seo_format_string(
    903                                         YoastSEO()->meta->for_post($post->ID)
    904                                             ->twitter_title
     926                                        $meta !== false ? $meta->twitter_title : ''
    905927                                    ),
    906928                                    'twitterDescription' => wp_gql_seo_format_string(
    907                                         YoastSEO()->meta->for_post($post->ID)
    908                                             ->twitter_description
     929                                        $meta !== false
     930                                            ? $meta->twitter_description
     931                                            : ''
    909932                                    ),
    910933                                    'twitterImage' => function () use (
    911934                                        $post,
    912                                         $context
     935                                        $context,
     936                                        $meta
    913937                                    ) {
     938                                        $twitter_image = $meta->twitter_image;
     939
     940                                        if (empty($twitter_image)) {
     941                                            return __return_empty_string();
     942                                        }
     943
    914944                                        $id = wpcom_vip_attachment_url_to_postid(
    915                                             YoastSEO()->meta->for_post($post->ID)
    916                                                 ->twitter_image
     945                                            $twitter_image
    917946                                        );
    918947
     
    922951                                    },
    923952                                    'canonical' => wp_gql_seo_format_string(
    924                                         YoastSEO()->meta->for_post($post->ID)
    925                                             ->canonical
     953                                        $meta !== false ? $meta->canonical : ''
    926954                                    ),
    927955                                    'readingTime' => floatval(
    928                                         YoastSEO()->meta->for_post($post->ID)
    929                                             ->estimated_reading_time_minutes
    930                                     ),
    931                                     'breadcrumbs' => YoastSEO()->meta->for_post(
    932                                         $post->ID
    933                                     )->breadcrumbs,
     956                                        $meta !== false
     957                                            ? $meta->estimated_reading_time_minutes
     958                                            : ''
     959                                    ),
     960                                    'breadcrumbs' =>
     961                                        $meta !== false ? $meta->breadcrumbs : [],
     962                                    // TODO: Default should be true or false?
    934963                                    'cornerstone' => boolval(
    935                                         YoastSEO()->meta->for_post($post->ID)
    936                                             ->indexable->is_cornerstone
    937                                     ),
    938                                     'fullHead' => is_string(
    939                                         YoastSEO()
    940                                             ->meta->for_post($post->ID)
    941                                             ->get_head()
    942                                     )
    943                                         ? YoastSEO()
    944                                             ->meta->for_post($post->ID)
    945                                             ->get_head()
    946                                         : YoastSEO()
    947                                             ->meta->for_post($post->ID)
    948                                             ->get_head()->html,
     964                                        $meta !== false
     965                                            ? $meta->indexable->is_cornerstone
     966                                            : false
     967                                    ),
     968                                    'fullHead' => wp_gql_seo_get_full_head($meta),
    949969                                    'schema' => [
    950                                         'pageType' => is_array(
    951                                             YoastSEO()->meta->for_post($post->ID)
    952                                                 ->schema_page_type
    953                                         )
    954                                             ? YoastSEO()->meta->for_post($post->ID)
    955                                                 ->schema_page_type
    956                                             : [],
    957                                         'articleType' => is_array(
    958                                             YoastSEO()->meta->for_post($post->ID)
    959                                                 ->schema_article_type
    960                                         )
    961                                             ? YoastSEO()->meta->for_post($post->ID)
    962                                                 ->schema_article_type
    963                                             : [],
     970                                        'pageType' =>
     971                                            $meta !== false &&
     972                                            is_array($meta->schema_page_type)
     973                                                ? $meta->schema_page_type
     974                                                : [],
     975                                        'articleType' =>
     976                                            $meta !== false &&
     977                                            is_array($meta->schema_article_type)
     978                                                ? $meta->schema_article_type
     979                                                : [],
    964980                                        'raw' => json_encode(
    965981                                            $schemaArray,
  • add-wpgraphql-seo/trunk/CHANGELOG.md

    r2678268 r2697321  
    55The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
    66and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
     7
     8## [4.16.2] - 2022-03-231
     9
     10### Changed
     11
     12-   Image optimize perf (thanks @kent1D )
     13-   Add guard against undefined user object (thanks @rodrigo-arias)
     14-   PostTypeSEO improvements: More defensive programming (thanks @matthewgrzegorczyk)
    715
    816## [4.16.1] - 2022-01-23
  • add-wpgraphql-seo/trunk/readme.txt

    r2678268 r2697321  
    55Tested up to: 5.7
    66Requires PHP: 7.1
    7 Stable tag: 4.16.1
     7Stable tag: 4.16.2
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • add-wpgraphql-seo/trunk/wp-graphql-yoast-seo.php

    r2678268 r2697321  
    99 * Text Domain:     wp-graphql-yoast-seo
    1010 * Domain Path:     /languages
    11  * Version:         4.16.1
     11 * Version:         4.16.2
    1212 *
    1313 * @package         WP_Graphql_YOAST_SEO
     
    8383                $image['url']
    8484            );
     85            // If the image is equal as the original and the original has an id, return this ID
     86            if (isset($image['id']) && $url === $image['url']) {
     87                return $image['id'];
     88            }
    8589            return wpcom_vip_attachment_url_to_postid($url);
    8690        }
     
    147151        }
    148152        return $carry;
     153    }
     154
     155    /**
     156     * @param \Yoast\WP\SEO\Surfaces\Values\Meta|bool $metaForPost
     157     * @return string
     158     */
     159    function wp_gql_seo_get_full_head($metaForPost)
     160    {
     161        if ($metaForPost !== false) {
     162            $head = $metaForPost->get_head();
     163
     164            return is_string($head) ? $head : $head->html;
     165        }
     166
     167        return '';
    149168    }
    150169
     
    726745                            $all['company_name']
    727746                        ),
    728                         'personName' => wp_gql_seo_format_string(
    729                             $user->user_nicename
    730                         ),
     747                        'personName' => !empty($user)
     748                            ? wp_gql_seo_format_string($user->user_nicename)
     749                            : null,
    731750                        'companyLogo' => $context
    732751                            ->get_loader('post')
     
    814833                                    '@context' => 'context',
    815834                                ];
    816 
    817                                 $schemaArray = YoastSEO()->meta->for_post($post->ID)
    818                                     ->schema;
     835                                $meta = YoastSEO()->meta->for_post($post->ID);
     836
     837                                $schemaArray = $meta !== false ? $meta->schema : [];
    819838
    820839                                // https://developer.yoast.com/blog/yoast-seo-14-0-using-yoast-seo-surfaces/
    821                                 $robots = YoastSEO()->meta->for_post($post->ID)
    822                                     ->robots;
     840                                $robots = $meta !== false ? $meta->robots : [];
    823841
    824842                                // Get data
    825843                                $seo = [
    826844                                    'title' => wp_gql_seo_format_string(
    827                                         YoastSEO()->meta->for_post($post->ID)->title
     845                                        $meta !== false ? $meta->title : ''
    828846                                    ),
    829847                                    'metaDesc' => wp_gql_seo_format_string(
    830                                         YoastSEO()->meta->for_post($post->ID)
    831                                             ->description
     848                                        $meta !== false ? $meta->description : ''
    832849                                    ),
    833850                                    'focuskw' => wp_gql_seo_format_string(
     
    845862                                        )
    846863                                    ),
    847                                     'metaRobotsNoindex' => $robots['index'],
    848                                     'metaRobotsNofollow' => $robots['follow'],
     864                                    'metaRobotsNoindex' => $robots['index'] ?? '',
     865                                    'metaRobotsNofollow' => $robots['follow'] ?? '',
    849866                                    'opengraphTitle' => wp_gql_seo_format_string(
    850                                         YoastSEO()->meta->for_post($post->ID)
    851                                             ->open_graph_title
     867                                        $meta !== false
     868                                            ? $meta->open_graph_title
     869                                            : ''
    852870                                    ),
    853871                                    'opengraphUrl' => wp_gql_seo_format_string(
    854                                         YoastSEO()->meta->for_post($post->ID)
    855                                             ->open_graph_url
     872                                        $meta !== false ? $meta->open_graph_url : ''
    856873                                    ),
    857874                                    'opengraphSiteName' => wp_gql_seo_format_string(
    858                                         YoastSEO()->meta->for_post($post->ID)
    859                                             ->open_graph_site_name
     875                                        $meta !== false
     876                                            ? $meta->open_graph_site_name
     877                                            : ''
    860878                                    ),
    861879                                    'opengraphType' => wp_gql_seo_format_string(
    862                                         YoastSEO()->meta->for_post($post->ID)
    863                                             ->open_graph_type
     880                                        $meta !== false ? $meta->open_graph_type : ''
    864881                                    ),
    865882                                    'opengraphAuthor' => wp_gql_seo_format_string(
    866                                         YoastSEO()->meta->for_post($post->ID)
    867                                             ->open_graph_article_author
     883                                        $meta !== false
     884                                            ? $meta->open_graph_article_author
     885                                            : ''
    868886                                    ),
    869887                                    'opengraphPublisher' => wp_gql_seo_format_string(
    870                                         YoastSEO()->meta->for_post($post->ID)
    871                                             ->open_graph_article_publisher
     888                                        $meta !== false
     889                                            ? $meta->open_graph_article_publisher
     890                                            : ''
    872891                                    ),
    873892                                    'opengraphPublishedTime' => wp_gql_seo_format_string(
    874                                         YoastSEO()->meta->for_post($post->ID)
    875                                             ->open_graph_article_published_time
     893                                        $meta !== false
     894                                            ? $meta->open_graph_article_published_time
     895                                            : ''
    876896                                    ),
    877897                                    'opengraphModifiedTime' => wp_gql_seo_format_string(
    878                                         YoastSEO()->meta->for_post($post->ID)
    879                                             ->open_graph_article_modified_time
     898                                        $meta !== false
     899                                            ? $meta->open_graph_article_modified_time
     900                                            : ''
    880901                                    ),
    881902                                    'opengraphDescription' => wp_gql_seo_format_string(
    882                                         YoastSEO()->meta->for_post($post->ID)
    883                                             ->open_graph_description
     903                                        $meta !== false
     904                                            ? $meta->open_graph_description
     905                                            : ''
    884906                                    ),
    885907                                    'opengraphImage' => function () use (
    886908                                        $post,
    887                                         $context
     909                                        $context,
     910                                        $meta
    888911                                    ) {
    889912                                        $id = wp_gql_seo_get_og_image(
    890                                             YoastSEO()->meta->for_post($post->ID)
    891                                                 ->open_graph_images
     913                                            $meta !== false
     914                                                ? $meta->open_graph_images
     915                                                : []
    892916                                        );
    893917
     
    897921                                    },
    898922                                    'twitterCardType' => wp_gql_seo_format_string(
    899                                         YoastSEO()->meta->for_post($post->ID)
    900                                             ->twitter_card
     923                                        $meta !== false ? $meta->twitter_card : ''
    901924                                    ),
    902925                                    'twitterTitle' => wp_gql_seo_format_string(
    903                                         YoastSEO()->meta->for_post($post->ID)
    904                                             ->twitter_title
     926                                        $meta !== false ? $meta->twitter_title : ''
    905927                                    ),
    906928                                    'twitterDescription' => wp_gql_seo_format_string(
    907                                         YoastSEO()->meta->for_post($post->ID)
    908                                             ->twitter_description
     929                                        $meta !== false
     930                                            ? $meta->twitter_description
     931                                            : ''
    909932                                    ),
    910933                                    'twitterImage' => function () use (
    911934                                        $post,
    912                                         $context
     935                                        $context,
     936                                        $meta
    913937                                    ) {
     938                                        $twitter_image = $meta->twitter_image;
     939
     940                                        if (empty($twitter_image)) {
     941                                            return __return_empty_string();
     942                                        }
     943
    914944                                        $id = wpcom_vip_attachment_url_to_postid(
    915                                             YoastSEO()->meta->for_post($post->ID)
    916                                                 ->twitter_image
     945                                            $twitter_image
    917946                                        );
    918947
     
    922951                                    },
    923952                                    'canonical' => wp_gql_seo_format_string(
    924                                         YoastSEO()->meta->for_post($post->ID)
    925                                             ->canonical
     953                                        $meta !== false ? $meta->canonical : ''
    926954                                    ),
    927955                                    'readingTime' => floatval(
    928                                         YoastSEO()->meta->for_post($post->ID)
    929                                             ->estimated_reading_time_minutes
    930                                     ),
    931                                     'breadcrumbs' => YoastSEO()->meta->for_post(
    932                                         $post->ID
    933                                     )->breadcrumbs,
     956                                        $meta !== false
     957                                            ? $meta->estimated_reading_time_minutes
     958                                            : ''
     959                                    ),
     960                                    'breadcrumbs' =>
     961                                        $meta !== false ? $meta->breadcrumbs : [],
     962                                    // TODO: Default should be true or false?
    934963                                    'cornerstone' => boolval(
    935                                         YoastSEO()->meta->for_post($post->ID)
    936                                             ->indexable->is_cornerstone
    937                                     ),
    938                                     'fullHead' => is_string(
    939                                         YoastSEO()
    940                                             ->meta->for_post($post->ID)
    941                                             ->get_head()
    942                                     )
    943                                         ? YoastSEO()
    944                                             ->meta->for_post($post->ID)
    945                                             ->get_head()
    946                                         : YoastSEO()
    947                                             ->meta->for_post($post->ID)
    948                                             ->get_head()->html,
     964                                        $meta !== false
     965                                            ? $meta->indexable->is_cornerstone
     966                                            : false
     967                                    ),
     968                                    'fullHead' => wp_gql_seo_get_full_head($meta),
    949969                                    'schema' => [
    950                                         'pageType' => is_array(
    951                                             YoastSEO()->meta->for_post($post->ID)
    952                                                 ->schema_page_type
    953                                         )
    954                                             ? YoastSEO()->meta->for_post($post->ID)
    955                                                 ->schema_page_type
    956                                             : [],
    957                                         'articleType' => is_array(
    958                                             YoastSEO()->meta->for_post($post->ID)
    959                                                 ->schema_article_type
    960                                         )
    961                                             ? YoastSEO()->meta->for_post($post->ID)
    962                                                 ->schema_article_type
    963                                             : [],
     970                                        'pageType' =>
     971                                            $meta !== false &&
     972                                            is_array($meta->schema_page_type)
     973                                                ? $meta->schema_page_type
     974                                                : [],
     975                                        'articleType' =>
     976                                            $meta !== false &&
     977                                            is_array($meta->schema_article_type)
     978                                                ? $meta->schema_article_type
     979                                                : [],
    964980                                        'raw' => json_encode(
    965981                                            $schemaArray,
Note: See TracChangeset for help on using the changeset viewer.