Changeset 2697321
- Timestamp:
- 03/21/2022 09:00:57 PM (4 years ago)
- Location:
- add-wpgraphql-seo
- Files:
-
- 6 edited
- 1 copied
-
tags/4.16.2 (copied) (copied from add-wpgraphql-seo/trunk)
-
tags/4.16.2/CHANGELOG.md (modified) (1 diff)
-
tags/4.16.2/readme.txt (modified) (1 diff)
-
tags/4.16.2/wp-graphql-yoast-seo.php (modified) (8 diffs)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-graphql-yoast-seo.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
add-wpgraphql-seo/tags/4.16.2/CHANGELOG.md
r2678268 r2697321 5 5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 6 and 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) 7 15 8 16 ## [4.16.1] - 2022-01-23 -
add-wpgraphql-seo/tags/4.16.2/readme.txt
r2678268 r2697321 5 5 Tested up to: 5.7 6 6 Requires PHP: 7.1 7 Stable tag: 4.16. 17 Stable tag: 4.16.2 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html -
add-wpgraphql-seo/tags/4.16.2/wp-graphql-yoast-seo.php
r2678268 r2697321 9 9 * Text Domain: wp-graphql-yoast-seo 10 10 * Domain Path: /languages 11 * Version: 4.16. 111 * Version: 4.16.2 12 12 * 13 13 * @package WP_Graphql_YOAST_SEO … … 83 83 $image['url'] 84 84 ); 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 } 85 89 return wpcom_vip_attachment_url_to_postid($url); 86 90 } … … 147 151 } 148 152 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 ''; 149 168 } 150 169 … … 726 745 $all['company_name'] 727 746 ), 728 'personName' => wp_gql_seo_format_string(729 $user->user_nicename730 ),747 'personName' => !empty($user) 748 ? wp_gql_seo_format_string($user->user_nicename) 749 : null, 731 750 'companyLogo' => $context 732 751 ->get_loader('post') … … 814 833 '@context' => 'context', 815 834 ]; 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 : []; 819 838 820 839 // 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 : []; 823 841 824 842 // Get data 825 843 $seo = [ 826 844 'title' => wp_gql_seo_format_string( 827 YoastSEO()->meta->for_post($post->ID)->title845 $meta !== false ? $meta->title : '' 828 846 ), 829 847 'metaDesc' => wp_gql_seo_format_string( 830 YoastSEO()->meta->for_post($post->ID) 831 ->description 848 $meta !== false ? $meta->description : '' 832 849 ), 833 850 'focuskw' => wp_gql_seo_format_string( … … 845 862 ) 846 863 ), 847 'metaRobotsNoindex' => $robots['index'] ,848 'metaRobotsNofollow' => $robots['follow'] ,864 'metaRobotsNoindex' => $robots['index'] ?? '', 865 'metaRobotsNofollow' => $robots['follow'] ?? '', 849 866 '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 : '' 852 870 ), 853 871 'opengraphUrl' => wp_gql_seo_format_string( 854 YoastSEO()->meta->for_post($post->ID) 855 ->open_graph_url 872 $meta !== false ? $meta->open_graph_url : '' 856 873 ), 857 874 '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 : '' 860 878 ), 861 879 'opengraphType' => wp_gql_seo_format_string( 862 YoastSEO()->meta->for_post($post->ID) 863 ->open_graph_type 880 $meta !== false ? $meta->open_graph_type : '' 864 881 ), 865 882 '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 : '' 868 886 ), 869 887 '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 : '' 872 891 ), 873 892 '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 : '' 876 896 ), 877 897 '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 : '' 880 901 ), 881 902 '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 : '' 884 906 ), 885 907 'opengraphImage' => function () use ( 886 908 $post, 887 $context 909 $context, 910 $meta 888 911 ) { 889 912 $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 : [] 892 916 ); 893 917 … … 897 921 }, 898 922 'twitterCardType' => wp_gql_seo_format_string( 899 YoastSEO()->meta->for_post($post->ID) 900 ->twitter_card 923 $meta !== false ? $meta->twitter_card : '' 901 924 ), 902 925 'twitterTitle' => wp_gql_seo_format_string( 903 YoastSEO()->meta->for_post($post->ID) 904 ->twitter_title 926 $meta !== false ? $meta->twitter_title : '' 905 927 ), 906 928 'twitterDescription' => wp_gql_seo_format_string( 907 YoastSEO()->meta->for_post($post->ID) 908 ->twitter_description 929 $meta !== false 930 ? $meta->twitter_description 931 : '' 909 932 ), 910 933 'twitterImage' => function () use ( 911 934 $post, 912 $context 935 $context, 936 $meta 913 937 ) { 938 $twitter_image = $meta->twitter_image; 939 940 if (empty($twitter_image)) { 941 return __return_empty_string(); 942 } 943 914 944 $id = wpcom_vip_attachment_url_to_postid( 915 YoastSEO()->meta->for_post($post->ID) 916 ->twitter_image 945 $twitter_image 917 946 ); 918 947 … … 922 951 }, 923 952 'canonical' => wp_gql_seo_format_string( 924 YoastSEO()->meta->for_post($post->ID) 925 ->canonical 953 $meta !== false ? $meta->canonical : '' 926 954 ), 927 955 '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? 934 963 '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), 949 969 '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 : [], 964 980 'raw' => json_encode( 965 981 $schemaArray, -
add-wpgraphql-seo/trunk/CHANGELOG.md
r2678268 r2697321 5 5 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 6 and 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) 7 15 8 16 ## [4.16.1] - 2022-01-23 -
add-wpgraphql-seo/trunk/readme.txt
r2678268 r2697321 5 5 Tested up to: 5.7 6 6 Requires PHP: 7.1 7 Stable tag: 4.16. 17 Stable tag: 4.16.2 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
r2678268 r2697321 9 9 * Text Domain: wp-graphql-yoast-seo 10 10 * Domain Path: /languages 11 * Version: 4.16. 111 * Version: 4.16.2 12 12 * 13 13 * @package WP_Graphql_YOAST_SEO … … 83 83 $image['url'] 84 84 ); 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 } 85 89 return wpcom_vip_attachment_url_to_postid($url); 86 90 } … … 147 151 } 148 152 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 ''; 149 168 } 150 169 … … 726 745 $all['company_name'] 727 746 ), 728 'personName' => wp_gql_seo_format_string(729 $user->user_nicename730 ),747 'personName' => !empty($user) 748 ? wp_gql_seo_format_string($user->user_nicename) 749 : null, 731 750 'companyLogo' => $context 732 751 ->get_loader('post') … … 814 833 '@context' => 'context', 815 834 ]; 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 : []; 819 838 820 839 // 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 : []; 823 841 824 842 // Get data 825 843 $seo = [ 826 844 'title' => wp_gql_seo_format_string( 827 YoastSEO()->meta->for_post($post->ID)->title845 $meta !== false ? $meta->title : '' 828 846 ), 829 847 'metaDesc' => wp_gql_seo_format_string( 830 YoastSEO()->meta->for_post($post->ID) 831 ->description 848 $meta !== false ? $meta->description : '' 832 849 ), 833 850 'focuskw' => wp_gql_seo_format_string( … … 845 862 ) 846 863 ), 847 'metaRobotsNoindex' => $robots['index'] ,848 'metaRobotsNofollow' => $robots['follow'] ,864 'metaRobotsNoindex' => $robots['index'] ?? '', 865 'metaRobotsNofollow' => $robots['follow'] ?? '', 849 866 '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 : '' 852 870 ), 853 871 'opengraphUrl' => wp_gql_seo_format_string( 854 YoastSEO()->meta->for_post($post->ID) 855 ->open_graph_url 872 $meta !== false ? $meta->open_graph_url : '' 856 873 ), 857 874 '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 : '' 860 878 ), 861 879 'opengraphType' => wp_gql_seo_format_string( 862 YoastSEO()->meta->for_post($post->ID) 863 ->open_graph_type 880 $meta !== false ? $meta->open_graph_type : '' 864 881 ), 865 882 '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 : '' 868 886 ), 869 887 '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 : '' 872 891 ), 873 892 '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 : '' 876 896 ), 877 897 '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 : '' 880 901 ), 881 902 '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 : '' 884 906 ), 885 907 'opengraphImage' => function () use ( 886 908 $post, 887 $context 909 $context, 910 $meta 888 911 ) { 889 912 $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 : [] 892 916 ); 893 917 … … 897 921 }, 898 922 'twitterCardType' => wp_gql_seo_format_string( 899 YoastSEO()->meta->for_post($post->ID) 900 ->twitter_card 923 $meta !== false ? $meta->twitter_card : '' 901 924 ), 902 925 'twitterTitle' => wp_gql_seo_format_string( 903 YoastSEO()->meta->for_post($post->ID) 904 ->twitter_title 926 $meta !== false ? $meta->twitter_title : '' 905 927 ), 906 928 'twitterDescription' => wp_gql_seo_format_string( 907 YoastSEO()->meta->for_post($post->ID) 908 ->twitter_description 929 $meta !== false 930 ? $meta->twitter_description 931 : '' 909 932 ), 910 933 'twitterImage' => function () use ( 911 934 $post, 912 $context 935 $context, 936 $meta 913 937 ) { 938 $twitter_image = $meta->twitter_image; 939 940 if (empty($twitter_image)) { 941 return __return_empty_string(); 942 } 943 914 944 $id = wpcom_vip_attachment_url_to_postid( 915 YoastSEO()->meta->for_post($post->ID) 916 ->twitter_image 945 $twitter_image 917 946 ); 918 947 … … 922 951 }, 923 952 'canonical' => wp_gql_seo_format_string( 924 YoastSEO()->meta->for_post($post->ID) 925 ->canonical 953 $meta !== false ? $meta->canonical : '' 926 954 ), 927 955 '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? 934 963 '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), 949 969 '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 : [], 964 980 'raw' => json_encode( 965 981 $schemaArray,
Note: See TracChangeset
for help on using the changeset viewer.