Plugin Directory

Changeset 3436300


Ignore:
Timestamp:
01/09/2026 09:05:06 PM (3 months ago)
Author:
ash_hitch
Message:

Update to version 5.0.1 from GitHub

Location:
add-wpgraphql-seo
Files:
2 added
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • add-wpgraphql-seo/tags/5.0.1/.husky/pre-commit

    r2740469 r3436300  
    22. "$(dirname -- "$0")/_/husky.sh"
    33
    4 yarn prettier
     4pnpm prettier
  • add-wpgraphql-seo/tags/5.0.1/CHANGELOG.md

    r3364564 r3436300  
    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## [5.0.1] - 2026-01-09
     9
     10### Fixed
     11
     12- Fix naming collision with vip-helpers plugin (#191) (thanks @amanda-t)
     13
     14### Fixed
     15
     16-   Fix undefined function error
    717
    818## [5.0.0] - 2025-04-26
  • add-wpgraphql-seo/tags/5.0.1/includes/helpers/functions.php

    r3364564 r3436300  
    6565        return $image['id'];
    6666    }
    67     return wpcom_vip_attachment_url_to_postid($url);
     67    return wp_gql_seo_attachment_url_to_postid($url);
    6868}
    6969
     
    8686/**
    8787 * Generate cache key for attachment URL.
     88 * Only declare if not already defined (e.g., by VIP platform).
    8889 *
    8990 * @param string $url URL to generate cache key for.
    9091 * @return string
    9192 */
    92 function wpcom_vip_attachment_cache_key($url)
    93 {
    94     return 'wpcom_vip_attachment_url_post_id_' . md5($url);
     93if (!function_exists('wpcom_vip_attachment_cache_key')) {
     94    function wpcom_vip_attachment_cache_key($url)
     95    {
     96        return 'wpcom_vip_attachment_url_post_id_' . md5($url);
     97    }
    9598}
    9699
    97100/**
    98101 * Get post ID from attachment URL with caching.
     102 * Only declare if not already defined (e.g., by VIP platform).
    99103 *
    100104 * @param string $url URL to get post ID for.
    101105 * @return int|null
    102106 */
    103 function wpcom_vip_attachment_url_to_postid($url)
    104 {
    105     $cache_key = wpcom_vip_attachment_cache_key($url);
    106     $id = wp_cache_get($cache_key);
    107     if (false === $id) {
    108         $id = attachment_url_to_postid($url); // phpcs:ignore
    109         if (empty($id)) {
    110             wp_cache_set(
    111                 $cache_key,
    112                 'not_found',
    113                 'default',
    114                 12 * HOUR_IN_SECONDS + mt_rand(0, 4 * HOUR_IN_SECONDS) // phpcs:ignore
    115             );
    116             $id = null; // Set $id to null instead of false
    117         } else {
    118             wp_cache_set(
    119                 $cache_key,
    120                 $id,
    121                 'default',
    122                 24 * HOUR_IN_SECONDS + mt_rand(0, 12 * HOUR_IN_SECONDS) // phpcs:ignore
    123             );
    124         }
    125     } elseif ('not_found' === $id) {
    126         return null; // Return null instead of false
    127     }
    128 
    129     return $id;
     107if (!function_exists('wpcom_vip_attachment_url_to_postid')) {
     108    function wpcom_vip_attachment_url_to_postid($url)
     109    {
     110        $cache_key = wpcom_vip_attachment_cache_key($url);
     111        $id = wp_cache_get($cache_key);
     112        if (false === $id) {
     113            $id = attachment_url_to_postid($url); // phpcs:ignore
     114            if (empty($id)) {
     115                wp_cache_set(
     116                    $cache_key,
     117                    'not_found',
     118                    'default',
     119                    12 * HOUR_IN_SECONDS + mt_rand(0, 4 * HOUR_IN_SECONDS) // phpcs:ignore
     120                );
     121                $id = null; // Set $id to null instead of false
     122            } else {
     123                wp_cache_set(
     124                    $cache_key,
     125                    $id,
     126                    'default',
     127                    24 * HOUR_IN_SECONDS + mt_rand(0, 12 * HOUR_IN_SECONDS) // phpcs:ignore
     128                );
     129            }
     130        } elseif ('not_found' === $id) {
     131            return false;
     132        }
     133
     134        return $id;
     135    }
     136}
     137
     138/**
     139 * Wrapper for wpcom_vip_attachment_url_to_postid that returns null instead of false.
     140 * This is needed for GraphQL compatibility - fixes
     141 * "Cannot return null for non-nullable field 'MediaItem.id'" errors.
     142 *
     143 * @see https://github.com/ashhitch/wp-graphql-yoast-seo/issues/132
     144 * @param string $url URL to get post ID for.
     145 * @return int|null
     146 */
     147function wp_gql_seo_attachment_url_to_postid($url)
     148{
     149    $id = wpcom_vip_attachment_url_to_postid($url);
     150    return (false === $id || empty($id)) ? null : $id;
    130151}
    131152
  • add-wpgraphql-seo/tags/5.0.1/includes/resolvers/post-type.php

    r3364564 r3436300  
    7474            }
    7575
    76             $id = wpcom_vip_attachment_url_to_postid($twitter_image);
     76            $id = wp_gql_seo_attachment_url_to_postid($twitter_image);
    7777
    7878            return $context->get_loader('post')->load_deferred(absint($id));
  • add-wpgraphql-seo/tags/5.0.1/package.json

    r3364564 r3436300  
    11{
    22    "name": "wp-graphql-yoast-seo",
    3     "version": "v5.0.0",
     3    "version": "v5.0.1",
    44    "description": "A WPGraphQL Extension that adds support for Yoast SEO",
    55    "scripts": {
     
    1818    "homepage": "https://github.com/ashhitch/wp-graphql-yoast-seo#readme",
    1919    "devDependencies": {
    20         "@prettier/plugin-php": "^0.22.4",
     20        "@prettier/plugin-php": "^0.24.0",
    2121        "husky": ">=8.0.1",
    2222        "lint-staged": ">=13.0.1",
    23         "prettier": "^2.6.2"
     23        "prettier": "^3.7.4"
    2424    }
    2525}
  • add-wpgraphql-seo/tags/5.0.1/readme.txt

    r3364564 r3436300  
    33Tags: SEO, Yoast, WPGraphQL, GraphQL, Headless WordPress
    44Requires at least: 5.0
    5 Tested up to: 6.8
     5Tested up to: 6.9
    66Requires PHP: 7.1
    7 Stable tag: 5.0.0
     7Stable tag: 5.0.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • add-wpgraphql-seo/tags/5.0.1/wp-graphql-yoast-seo.php

    r3364564 r3436300  
    99 * Text Domain: wp-graphql-yoast-seo
    1010 * Domain Path: /languages
    11  * Version: v5.0.0
     11 * Version: v5.0.1
    1212 * Requires Plugins: wp-graphql, wordpress-seo
    1313 *
  • add-wpgraphql-seo/trunk/.husky/pre-commit

    r2740469 r3436300  
    22. "$(dirname -- "$0")/_/husky.sh"
    33
    4 yarn prettier
     4pnpm prettier
  • add-wpgraphql-seo/trunk/CHANGELOG.md

    r3364564 r3436300  
    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## [5.0.1] - 2026-01-09
     9
     10### Fixed
     11
     12- Fix naming collision with vip-helpers plugin (#191) (thanks @amanda-t)
     13
     14### Fixed
     15
     16-   Fix undefined function error
    717
    818## [5.0.0] - 2025-04-26
  • add-wpgraphql-seo/trunk/includes/helpers/functions.php

    r3364564 r3436300  
    6565        return $image['id'];
    6666    }
    67     return wpcom_vip_attachment_url_to_postid($url);
     67    return wp_gql_seo_attachment_url_to_postid($url);
    6868}
    6969
     
    8686/**
    8787 * Generate cache key for attachment URL.
     88 * Only declare if not already defined (e.g., by VIP platform).
    8889 *
    8990 * @param string $url URL to generate cache key for.
    9091 * @return string
    9192 */
    92 function wpcom_vip_attachment_cache_key($url)
    93 {
    94     return 'wpcom_vip_attachment_url_post_id_' . md5($url);
     93if (!function_exists('wpcom_vip_attachment_cache_key')) {
     94    function wpcom_vip_attachment_cache_key($url)
     95    {
     96        return 'wpcom_vip_attachment_url_post_id_' . md5($url);
     97    }
    9598}
    9699
    97100/**
    98101 * Get post ID from attachment URL with caching.
     102 * Only declare if not already defined (e.g., by VIP platform).
    99103 *
    100104 * @param string $url URL to get post ID for.
    101105 * @return int|null
    102106 */
    103 function wpcom_vip_attachment_url_to_postid($url)
    104 {
    105     $cache_key = wpcom_vip_attachment_cache_key($url);
    106     $id = wp_cache_get($cache_key);
    107     if (false === $id) {
    108         $id = attachment_url_to_postid($url); // phpcs:ignore
    109         if (empty($id)) {
    110             wp_cache_set(
    111                 $cache_key,
    112                 'not_found',
    113                 'default',
    114                 12 * HOUR_IN_SECONDS + mt_rand(0, 4 * HOUR_IN_SECONDS) // phpcs:ignore
    115             );
    116             $id = null; // Set $id to null instead of false
    117         } else {
    118             wp_cache_set(
    119                 $cache_key,
    120                 $id,
    121                 'default',
    122                 24 * HOUR_IN_SECONDS + mt_rand(0, 12 * HOUR_IN_SECONDS) // phpcs:ignore
    123             );
    124         }
    125     } elseif ('not_found' === $id) {
    126         return null; // Return null instead of false
    127     }
    128 
    129     return $id;
     107if (!function_exists('wpcom_vip_attachment_url_to_postid')) {
     108    function wpcom_vip_attachment_url_to_postid($url)
     109    {
     110        $cache_key = wpcom_vip_attachment_cache_key($url);
     111        $id = wp_cache_get($cache_key);
     112        if (false === $id) {
     113            $id = attachment_url_to_postid($url); // phpcs:ignore
     114            if (empty($id)) {
     115                wp_cache_set(
     116                    $cache_key,
     117                    'not_found',
     118                    'default',
     119                    12 * HOUR_IN_SECONDS + mt_rand(0, 4 * HOUR_IN_SECONDS) // phpcs:ignore
     120                );
     121                $id = null; // Set $id to null instead of false
     122            } else {
     123                wp_cache_set(
     124                    $cache_key,
     125                    $id,
     126                    'default',
     127                    24 * HOUR_IN_SECONDS + mt_rand(0, 12 * HOUR_IN_SECONDS) // phpcs:ignore
     128                );
     129            }
     130        } elseif ('not_found' === $id) {
     131            return false;
     132        }
     133
     134        return $id;
     135    }
     136}
     137
     138/**
     139 * Wrapper for wpcom_vip_attachment_url_to_postid that returns null instead of false.
     140 * This is needed for GraphQL compatibility - fixes
     141 * "Cannot return null for non-nullable field 'MediaItem.id'" errors.
     142 *
     143 * @see https://github.com/ashhitch/wp-graphql-yoast-seo/issues/132
     144 * @param string $url URL to get post ID for.
     145 * @return int|null
     146 */
     147function wp_gql_seo_attachment_url_to_postid($url)
     148{
     149    $id = wpcom_vip_attachment_url_to_postid($url);
     150    return (false === $id || empty($id)) ? null : $id;
    130151}
    131152
  • add-wpgraphql-seo/trunk/includes/resolvers/post-type.php

    r3364564 r3436300  
    7474            }
    7575
    76             $id = wpcom_vip_attachment_url_to_postid($twitter_image);
     76            $id = wp_gql_seo_attachment_url_to_postid($twitter_image);
    7777
    7878            return $context->get_loader('post')->load_deferred(absint($id));
  • add-wpgraphql-seo/trunk/package.json

    r3364564 r3436300  
    11{
    22    "name": "wp-graphql-yoast-seo",
    3     "version": "v5.0.0",
     3    "version": "v5.0.1",
    44    "description": "A WPGraphQL Extension that adds support for Yoast SEO",
    55    "scripts": {
     
    1818    "homepage": "https://github.com/ashhitch/wp-graphql-yoast-seo#readme",
    1919    "devDependencies": {
    20         "@prettier/plugin-php": "^0.22.4",
     20        "@prettier/plugin-php": "^0.24.0",
    2121        "husky": ">=8.0.1",
    2222        "lint-staged": ">=13.0.1",
    23         "prettier": "^2.6.2"
     23        "prettier": "^3.7.4"
    2424    }
    2525}
  • add-wpgraphql-seo/trunk/readme.txt

    r3364564 r3436300  
    33Tags: SEO, Yoast, WPGraphQL, GraphQL, Headless WordPress
    44Requires at least: 5.0
    5 Tested up to: 6.8
     5Tested up to: 6.9
    66Requires PHP: 7.1
    7 Stable tag: 5.0.0
     7Stable tag: 5.0.1
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • add-wpgraphql-seo/trunk/wp-graphql-yoast-seo.php

    r3364564 r3436300  
    99 * Text Domain: wp-graphql-yoast-seo
    1010 * Domain Path: /languages
    11  * Version: v5.0.0
     11 * Version: v5.0.1
    1212 * Requires Plugins: wp-graphql, wordpress-seo
    1313 *
Note: See TracChangeset for help on using the changeset viewer.