Changeset 2741712
- Timestamp:
- 06/13/2022 02:26:31 PM (4 years ago)
- Location:
- add-wpgraphql-seo
- Files:
-
- 4 edited
- 1 copied
-
tags/4.18.1 (copied) (copied from add-wpgraphql-seo/trunk)
-
tags/4.18.1/readme.txt (modified) (1 diff)
-
tags/4.18.1/wp-graphql-yoast-seo.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-graphql-yoast-seo.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
add-wpgraphql-seo/tags/4.18.1/readme.txt
r2740469 r2741712 5 5 Tested up to: 5.7 6 6 Requires PHP: 7.1 7 Stable tag: 4.18. 07 Stable tag: 4.18.1 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
add-wpgraphql-seo/tags/4.18.1/wp-graphql-yoast-seo.php
r2740469 r2741712 9 9 * Text Domain: wp-graphql-yoast-seo 10 10 * Domain Path: /languages 11 * Version: 4.18. 011 * Version: 4.18.1 12 12 * 13 13 * @package WP_Graphql_YOAST_SEO … … 787 787 }, 788 788 ]); 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 } 789 845 790 846 // User SEO Data -
add-wpgraphql-seo/trunk/readme.txt
r2740469 r2741712 5 5 Tested up to: 5.7 6 6 Requires PHP: 7.1 7 Stable tag: 4.18. 07 Stable tag: 4.18.1 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
add-wpgraphql-seo/trunk/wp-graphql-yoast-seo.php
r2740469 r2741712 9 9 * Text Domain: wp-graphql-yoast-seo 10 10 * Domain Path: /languages 11 * Version: 4.18. 011 * Version: 4.18.1 12 12 * 13 13 * @package WP_Graphql_YOAST_SEO … … 787 787 }, 788 788 ]); 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 } 789 845 790 846 // User SEO Data
Note: See TracChangeset
for help on using the changeset viewer.