Skip to content

Commit

Permalink
CANTINA-985: Add deprecation notice for wpcom_vip_get_page_by_path(),…
Browse files Browse the repository at this point in the history
… wpcom_vip_term_exists() and wpcom_vip_get_page_by_title() (#4992)

CANTINA-985: Add deprecation notice for wpcom_vip_get_page_by_path(), wpcom_vip_term_exists() and wpcom_vip_get_page_by_title()
  • Loading branch information
rebeccahum authored Nov 7, 2023
1 parent 2fdbf32 commit 3ba2acb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion vip-helpers/vip-caching.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ function wp_flush_get_term_by_cache( $term_id, $taxonomy ) {
*/

function wpcom_vip_term_exists( $term, $taxonomy = '', $parent = null ) {
global $wp_version;
if ( version_compare( $wp_version, '6.0', '<' ) ) {
_deprecated_function( __FUNCTION__, '6.0', 'term_exists' );
}

// If $parent is not null, let's skip the cache.
if ( null !== $parent ) {
return term_exists( $term, $taxonomy, $parent );
Expand Down Expand Up @@ -166,6 +171,11 @@ function wpcom_vip_get_term_link( $term, $taxonomy = null ) {
* @link https://docs.wpvip.com/technical-references/caching/uncached-functions/ Uncached Functions
*/
function wpcom_vip_get_page_by_title( $title, $output = OBJECT, $post_type = 'page' ) {
global $wp_version;
if ( version_compare( $wp_version, '6.2', '<' ) ) {
_deprecated_function( __FUNCTION__, '6.2', 'WP_Query' );
}

$cache_key = $post_type . '_' . sanitize_key( $title );
$page_id = wp_cache_get( $cache_key, 'get_page_by_title' );

Expand Down Expand Up @@ -210,7 +220,12 @@ function wpcom_vip_get_page_by_title( $title, $output = OBJECT, $post_type = 'pa
* @link https://docs.wpvip.com/technical-references/caching/uncached-functions/ Uncached Functions
*/
function wpcom_vip_get_page_by_path( $page_path, $output = OBJECT, $post_type = 'page' ) {
// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
global $wp_version;
if ( version_compare( $wp_version, '6.1', '<' ) ) {
_deprecated_function( __FUNCTION__, '6.1', 'get_page_by_path' );
}

// phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize
$cache_key = md5( $page_path . serialize( $post_type ) );
$page_id = wp_cache_get( $cache_key, 'wpcom_vip_get_page_by_path' );

Expand Down

0 comments on commit 3ba2acb

Please sign in to comment.