Plugin Directory

Changeset 2741712


Ignore:
Timestamp:
06/13/2022 02:26:31 PM (4 years ago)
Author:
ash_hitch
Message:

Update to version 4.18.1 from GitHub

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

Legend:

Unmodified
Added
Removed
  • add-wpgraphql-seo/tags/4.18.1/readme.txt

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

    r2740469 r2741712  
    99 * Text Domain:     wp-graphql-yoast-seo
    1010 * Domain Path:     /languages
    11  * Version:         4.18.0
     11 * Version:         4.18.1
    1212 *
    1313 * @package         WP_Graphql_YOAST_SEO
     
    787787            },
    788788        ]);
     789        // TODO connect to content node
     790        // Post Type SEO Data
     791        if (!empty($post_types) && is_array($post_types)) {
     792            foreach ($post_types as $post_type) {
     793                $post_type_object = get_post_type_object($post_type);
     794
     795                if (isset($post_type_object->graphql_single_name)):
     796                    // register field on edge for arch
     797
     798                    $name = 'WP' . ucfirst($post_type_object->graphql_single_name) . 'Info';
     799
     800                    register_graphql_field($name, 'seo', [
     801                        'type' => 'SEOPostTypePageInfo',
     802                        'description' => __(
     803                            'Raw schema for ' . $post_type_object->graphql_single_name,
     804                            'wp-graphql-yoast-seo'
     805                        ),
     806                        'resolve' => function ($item, array $args, AppContext $context) use ($post_type) {
     807                            $schemaArray = YoastSEO()->meta->for_post_type_archive($post_type)->schema;
     808
     809                            return [
     810                                'schema' => [
     811                                    'raw' => json_encode($schemaArray, JSON_UNESCAPED_SLASHES),
     812                                ],
     813                            ];
     814                        },
     815                    ]);
     816
     817                    // Loop each taxonomy to register on the edge if a category is the primary one.
     818                    $taxonomiesPostObj = get_object_taxonomies($post_type, 'objects');
     819
     820                    $postNameKey = wp_gql_seo_get_field_key($post_type_object->graphql_single_name);
     821
     822                    foreach ($taxonomiesPostObj as $tax) {
     823                        if (isset($tax->hierarchical) && isset($tax->graphql_single_name)) {
     824                            $name =
     825                                ucfirst($postNameKey) . 'To' . ucfirst($tax->graphql_single_name) . 'ConnectionEdge';
     826
     827                            register_graphql_field($name, 'isPrimary', [
     828                                'type' => 'Boolean',
     829                                'description' => __('The Yoast SEO Primary ' . $tax->name, 'wp-graphql-yoast-seo'),
     830                                'resolve' => function ($item, array $args, AppContext $context) use ($tax) {
     831                                    $postId = $item['source']->ID;
     832
     833                                    $wpseo_primary_term = new WPSEO_Primary_Term($tax->name, $postId);
     834                                    $primaryTaxId = $wpseo_primary_term->get_primary_term();
     835                                    $termId = $item['node']->term_id;
     836
     837                                    return $primaryTaxId === $termId;
     838                                },
     839                            ]);
     840                        }
     841                    }
     842                endif;
     843            }
     844        }
    789845
    790846        // User SEO Data
  • add-wpgraphql-seo/trunk/readme.txt

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

    r2740469 r2741712  
    99 * Text Domain:     wp-graphql-yoast-seo
    1010 * Domain Path:     /languages
    11  * Version:         4.18.0
     11 * Version:         4.18.1
    1212 *
    1313 * @package         WP_Graphql_YOAST_SEO
     
    787787            },
    788788        ]);
     789        // TODO connect to content node
     790        // Post Type SEO Data
     791        if (!empty($post_types) && is_array($post_types)) {
     792            foreach ($post_types as $post_type) {
     793                $post_type_object = get_post_type_object($post_type);
     794
     795                if (isset($post_type_object->graphql_single_name)):
     796                    // register field on edge for arch
     797
     798                    $name = 'WP' . ucfirst($post_type_object->graphql_single_name) . 'Info';
     799
     800                    register_graphql_field($name, 'seo', [
     801                        'type' => 'SEOPostTypePageInfo',
     802                        'description' => __(
     803                            'Raw schema for ' . $post_type_object->graphql_single_name,
     804                            'wp-graphql-yoast-seo'
     805                        ),
     806                        'resolve' => function ($item, array $args, AppContext $context) use ($post_type) {
     807                            $schemaArray = YoastSEO()->meta->for_post_type_archive($post_type)->schema;
     808
     809                            return [
     810                                'schema' => [
     811                                    'raw' => json_encode($schemaArray, JSON_UNESCAPED_SLASHES),
     812                                ],
     813                            ];
     814                        },
     815                    ]);
     816
     817                    // Loop each taxonomy to register on the edge if a category is the primary one.
     818                    $taxonomiesPostObj = get_object_taxonomies($post_type, 'objects');
     819
     820                    $postNameKey = wp_gql_seo_get_field_key($post_type_object->graphql_single_name);
     821
     822                    foreach ($taxonomiesPostObj as $tax) {
     823                        if (isset($tax->hierarchical) && isset($tax->graphql_single_name)) {
     824                            $name =
     825                                ucfirst($postNameKey) . 'To' . ucfirst($tax->graphql_single_name) . 'ConnectionEdge';
     826
     827                            register_graphql_field($name, 'isPrimary', [
     828                                'type' => 'Boolean',
     829                                'description' => __('The Yoast SEO Primary ' . $tax->name, 'wp-graphql-yoast-seo'),
     830                                'resolve' => function ($item, array $args, AppContext $context) use ($tax) {
     831                                    $postId = $item['source']->ID;
     832
     833                                    $wpseo_primary_term = new WPSEO_Primary_Term($tax->name, $postId);
     834                                    $primaryTaxId = $wpseo_primary_term->get_primary_term();
     835                                    $termId = $item['node']->term_id;
     836
     837                                    return $primaryTaxId === $termId;
     838                                },
     839                            ]);
     840                        }
     841                    }
     842                endif;
     843            }
     844        }
    789845
    790846        // User SEO Data
Note: See TracChangeset for help on using the changeset viewer.