This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Sorts an array of version objects based on their semantic version numbers, including pre-release versions. | |
* | |
* This function parses each version string using a regular expression to extract its numeric, pre-release, | |
* and build components and then compares them to order the array. | |
* | |
* It supports complex version such as (in order) "1.4.9", "1.5.0-alpha", "1.5.0-alpha2", and "1.5.0", ensuring | |
* that pre-release versions are sorted correctly relative to final releases. | |
* | |
* @param {Array<Object>} versions - An array of version objects where each object contains a "version" property of type string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already open | |
// Per email exchange with Renan. | |
add_filter( | |
'the_seo_framework_articles_data', | |
function ( $data ) { | |
if ( in_array( get_post_type(), [ 'post', 'web-story', 'gira' ], true ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already open | |
// Per https://wordpress.org/support/topic/term_title-in-custom-taxonomies-archive-titles/ | |
add_filter( | |
'the_seo_framework_generated_archive_title_items', | |
/** | |
* Filters the generated archive title items. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already opened. | |
add_filter( | |
'the_seo_framework_meta_generator_pools', | |
function ( $generator_pools ) { | |
if ( 'listings' === tsf()->query()->get_post_type_real_id() ) | |
return array_diff( $generator_pools, [ 'Schema' ] ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Don't include the PHP opening tag if PHP is already open. | |
add_filter( 'the_seo_framework_get_excerpt', 'my_tsf_acf_excerpt', 10, 2 ); | |
/** | |
* @param string $excerpt The obtained excerpt. | |
* @param array|null $args The query arguments. Contains 'id', 'tax', 'pta', and 'uid'. | |
* Is null when the query is auto-determined. | |
* @return string The overwritten description. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do not include the PHP opening tag if PHP is already opened. | |
add_filter( | |
'the_seo_framework_title_from_generation', | |
function ( $title, $args ) { | |
$is_product = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( | |
'the_seo_framework_description_excerpt', | |
function ( $excerpt, $args ) { | |
if ( ! strlen( $excerpt ) ) return ''; | |
if ( isset( $args ) ) { | |
$is_term = 'term' === The_SEO_Framework\get_query_type_from_args( $args ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Don't include the PHP opening tag if PHP is already opened in the script. | |
add_filter( 'the_seo_framework_description_excerpt', 'my_custom_meta_description_excerpt', 10, 2 ); | |
/** | |
* @param string $excerpt The excerpt to use. | |
* @param array|null $args The query arguments. Contains 'id', 'tax', 'pta', and 'uid'. | |
* Is null when the query is auto-determined. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin name: test wp_get_wp_version performance. | |
*/ | |
if ( ! function_exists( 'wp_get_wp_version' ) ) { | |
function wp_get_wp_version() { | |
require ABSPATH . WPINC . '/version.php'; | |
return $wp_version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$request = strtok( substr_replace( $_SERVER['REQUEST_URI'], '', 0, strlen( dirname( $_SERVER['PHP_SELF'] ) ) ), '.' ); | |
$r_parts = array_values( array_filter( explode( '/', $request ) ) ); | |
if ( empty( $r_parts[0] ) ) { | |
http_response_code( 400 ); | |
exit; | |
} |
NewerOlder