Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wordpres.../inc
File: wpseo-functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Internals
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if ( ! defined( 'WPSEO_VERSION' ) ) {
[7] Fix | Delete
header( 'Status: 403 Forbidden' );
[8] Fix | Delete
header( 'HTTP/1.1 403 Forbidden' );
[9] Fix | Delete
exit();
[10] Fix | Delete
}
[11] Fix | Delete
[12] Fix | Delete
if ( ! function_exists( 'yoast_breadcrumb' ) ) {
[13] Fix | Delete
/**
[14] Fix | Delete
* Template tag for breadcrumbs.
[15] Fix | Delete
*
[16] Fix | Delete
* @param string $before What to show before the breadcrumb.
[17] Fix | Delete
* @param string $after What to show after the breadcrumb.
[18] Fix | Delete
* @param bool $display Whether to display the breadcrumb (true) or return it (false).
[19] Fix | Delete
*
[20] Fix | Delete
* @return string
[21] Fix | Delete
*/
[22] Fix | Delete
function yoast_breadcrumb( $before = '', $after = '', $display = true ) {
[23] Fix | Delete
$breadcrumbs_enabled = current_theme_supports( 'yoast-seo-breadcrumbs' );
[24] Fix | Delete
if ( ! $breadcrumbs_enabled ) {
[25] Fix | Delete
$breadcrumbs_enabled = WPSEO_Options::get( 'breadcrumbs-enable', false );
[26] Fix | Delete
}
[27] Fix | Delete
[28] Fix | Delete
if ( $breadcrumbs_enabled ) {
[29] Fix | Delete
return WPSEO_Breadcrumbs::breadcrumb( $before, $after, $display );
[30] Fix | Delete
}
[31] Fix | Delete
}
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
if ( ! function_exists( 'yoast_get_primary_term_id' ) ) {
[35] Fix | Delete
/**
[36] Fix | Delete
* Get the primary term ID.
[37] Fix | Delete
*
[38] Fix | Delete
* @param string $taxonomy Optional. The taxonomy to get the primary term ID for. Defaults to category.
[39] Fix | Delete
* @param int|WP_Post|null $post Optional. Post to get the primary term ID for.
[40] Fix | Delete
*
[41] Fix | Delete
* @return bool|int
[42] Fix | Delete
*/
[43] Fix | Delete
function yoast_get_primary_term_id( $taxonomy = 'category', $post = null ) {
[44] Fix | Delete
$post = get_post( $post );
[45] Fix | Delete
[46] Fix | Delete
$primary_term = new WPSEO_Primary_Term( $taxonomy, $post->ID );
[47] Fix | Delete
return $primary_term->get_primary_term();
[48] Fix | Delete
}
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
if ( ! function_exists( 'yoast_get_primary_term' ) ) {
[52] Fix | Delete
/**
[53] Fix | Delete
* Get the primary term name.
[54] Fix | Delete
*
[55] Fix | Delete
* @param string $taxonomy Optional. The taxonomy to get the primary term for. Defaults to category.
[56] Fix | Delete
* @param int|WP_Post|null $post Optional. Post to get the primary term for.
[57] Fix | Delete
*
[58] Fix | Delete
* @return string Name of the primary term.
[59] Fix | Delete
*/
[60] Fix | Delete
function yoast_get_primary_term( $taxonomy = 'category', $post = null ) {
[61] Fix | Delete
$primary_term_id = yoast_get_primary_term_id( $taxonomy, $post );
[62] Fix | Delete
[63] Fix | Delete
$term = get_term( $primary_term_id );
[64] Fix | Delete
if ( ! is_wp_error( $term ) && ! empty( $term ) ) {
[65] Fix | Delete
return $term->name;
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
return '';
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
/**
[73] Fix | Delete
* Replace `%%variable_placeholders%%` with their real value based on the current requested page/post/cpt.
[74] Fix | Delete
*
[75] Fix | Delete
* @param string $text The string to replace the variables in.
[76] Fix | Delete
* @param object $args The object some of the replacement values might come from,
[77] Fix | Delete
* could be a post, taxonomy or term.
[78] Fix | Delete
* @param array $omit Variables that should not be replaced by this function.
[79] Fix | Delete
*
[80] Fix | Delete
* @return string
[81] Fix | Delete
*/
[82] Fix | Delete
function wpseo_replace_vars( $text, $args, $omit = [] ) {
[83] Fix | Delete
$replacer = new WPSEO_Replace_Vars();
[84] Fix | Delete
[85] Fix | Delete
return $replacer->replace( $text, $args, $omit );
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Register a new variable replacement.
[90] Fix | Delete
*
[91] Fix | Delete
* This function is for use by other plugins/themes to easily add their own additional variables to replace.
[92] Fix | Delete
* This function should be called from a function on the 'wpseo_register_extra_replacements' action hook.
[93] Fix | Delete
* The use of this function is preferred over the older 'wpseo_replacements' filter as a way to add new replacements.
[94] Fix | Delete
* The 'wpseo_replacements' filter should still be used to adjust standard WPSEO replacement values.
[95] Fix | Delete
* The function can not be used to replace standard WPSEO replacement value functions and will thrown a warning
[96] Fix | Delete
* if you accidently try.
[97] Fix | Delete
* To avoid conflicts with variables registered by WPSEO and other themes/plugins, try and make the
[98] Fix | Delete
* name of your variable unique. Variable names also can not start with "%%cf_" or "%%ct_" as these are reserved
[99] Fix | Delete
* for the standard WPSEO variable variables 'cf_<custom-field-name>', 'ct_<custom-tax-name>' and
[100] Fix | Delete
* 'ct_desc_<custom-tax-name>'.
[101] Fix | Delete
* The replacement function will be passed the undelimited name (i.e. stripped of the %%) of the variable
[102] Fix | Delete
* to replace in case you need it.
[103] Fix | Delete
*
[104] Fix | Delete
* Example code:
[105] Fix | Delete
* <code>
[106] Fix | Delete
* <?php
[107] Fix | Delete
* function retrieve_var1_replacement( $var1 ) {
[108] Fix | Delete
* return 'your replacement value';
[109] Fix | Delete
* }
[110] Fix | Delete
*
[111] Fix | Delete
* function register_my_plugin_extra_replacements() {
[112] Fix | Delete
* wpseo_register_var_replacement( '%%myvar1%%', 'retrieve_var1_replacement', 'advanced', 'this is a help text for myvar1' );
[113] Fix | Delete
* wpseo_register_var_replacement( 'myvar2', array( 'class', 'method_name' ), 'basic', 'this is a help text for myvar2' );
[114] Fix | Delete
* }
[115] Fix | Delete
* add_action( 'wpseo_register_extra_replacements', 'register_my_plugin_extra_replacements' );
[116] Fix | Delete
* ?>
[117] Fix | Delete
* </code>
[118] Fix | Delete
*
[119] Fix | Delete
* @since 1.5.4
[120] Fix | Delete
*
[121] Fix | Delete
* @param string $replacevar_name The name of the variable to replace, i.e. '%%var%%'.
[122] Fix | Delete
* Note: the surrounding %% are optional, name can only contain [A-Za-z0-9_-].
[123] Fix | Delete
* @param mixed $replace_function Function or method to call to retrieve the replacement value for the variable.
[124] Fix | Delete
* Uses the same format as add_filter/add_action function parameter and
[125] Fix | Delete
* should *return* the replacement value. DON'T echo it.
[126] Fix | Delete
* @param string $type Type of variable: 'basic' or 'advanced', defaults to 'advanced'.
[127] Fix | Delete
* @param string $help_text Help text to be added to the help tab for this variable.
[128] Fix | Delete
*
[129] Fix | Delete
* @return bool Whether the replacement function was successfully registered.
[130] Fix | Delete
*/
[131] Fix | Delete
function wpseo_register_var_replacement( $replacevar_name, $replace_function, $type = 'advanced', $help_text = '' ) {
[132] Fix | Delete
return WPSEO_Replace_Vars::register_replacement( $replacevar_name, $replace_function, $type, $help_text );
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
/**
[136] Fix | Delete
* WPML plugin support: Set titles for custom types / taxonomies as translatable.
[137] Fix | Delete
*
[138] Fix | Delete
* It adds new keys to a wpml-config.xml file for a custom post type title, metadesc,
[139] Fix | Delete
* title-ptarchive and metadesc-ptarchive fields translation.
[140] Fix | Delete
* Documentation: http://wpml.org/documentation/support/language-configuration-files/
[141] Fix | Delete
*
[142] Fix | Delete
* @global $sitepress
[143] Fix | Delete
*
[144] Fix | Delete
* @param array $config WPML configuration data to filter.
[145] Fix | Delete
*
[146] Fix | Delete
* @return array
[147] Fix | Delete
*/
[148] Fix | Delete
function wpseo_wpml_config( $config ) {
[149] Fix | Delete
global $sitepress;
[150] Fix | Delete
[151] Fix | Delete
if ( ( is_array( $config ) && isset( $config['wpml-config']['admin-texts']['key'] ) ) && ( is_array( $config['wpml-config']['admin-texts']['key'] ) && $config['wpml-config']['admin-texts']['key'] !== [] ) ) {
[152] Fix | Delete
$admin_texts = $config['wpml-config']['admin-texts']['key'];
[153] Fix | Delete
foreach ( $admin_texts as $k => $val ) {
[154] Fix | Delete
if ( $val['attr']['name'] === 'wpseo_titles' ) {
[155] Fix | Delete
$translate_cp = array_keys( $sitepress->get_translatable_documents() );
[156] Fix | Delete
if ( is_array( $translate_cp ) && $translate_cp !== [] ) {
[157] Fix | Delete
foreach ( $translate_cp as $post_type ) {
[158] Fix | Delete
$admin_texts[ $k ]['key'][]['attr']['name'] = 'title-' . $post_type;
[159] Fix | Delete
$admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-' . $post_type;
[160] Fix | Delete
$admin_texts[ $k ]['key'][]['attr']['name'] = 'title-ptarchive-' . $post_type;
[161] Fix | Delete
$admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-ptarchive-' . $post_type;
[162] Fix | Delete
[163] Fix | Delete
$translate_tax = $sitepress->get_translatable_taxonomies( false, $post_type );
[164] Fix | Delete
if ( is_array( $translate_tax ) && $translate_tax !== [] ) {
[165] Fix | Delete
foreach ( $translate_tax as $taxonomy ) {
[166] Fix | Delete
$admin_texts[ $k ]['key'][]['attr']['name'] = 'title-tax-' . $taxonomy;
[167] Fix | Delete
$admin_texts[ $k ]['key'][]['attr']['name'] = 'metadesc-tax-' . $taxonomy;
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
break;
[173] Fix | Delete
}
[174] Fix | Delete
}
[175] Fix | Delete
$config['wpml-config']['admin-texts']['key'] = $admin_texts;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
return $config;
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
add_filter( 'icl_wpml_config_array', 'wpseo_wpml_config' );
[182] Fix | Delete
[183] Fix | Delete
if ( ! function_exists( 'ctype_digit' ) ) {
[184] Fix | Delete
/**
[185] Fix | Delete
* Emulate PHP native ctype_digit() function for when the ctype extension would be disabled *sigh*.
[186] Fix | Delete
* Only emulates the behaviour for when the input is a string, does not handle integer input as ascii value.
[187] Fix | Delete
*
[188] Fix | Delete
* @param string $text String input to validate.
[189] Fix | Delete
*
[190] Fix | Delete
* @return bool
[191] Fix | Delete
*/
[192] Fix | Delete
function ctype_digit( $text ) {
[193] Fix | Delete
$return = false;
[194] Fix | Delete
if ( ( is_string( $text ) && $text !== '' ) && preg_match( '`^\d+$`', $text ) === 1 ) {
[195] Fix | Delete
$return = true;
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
return $return;
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* Makes sure the taxonomy meta is updated when a taxonomy term is split.
[204] Fix | Delete
*
[205] Fix | Delete
* @link https://make.wordpress.org/core/2015/02/16/taxonomy-term-splitting-in-4-2-a-developer-guide/ Article explaining the taxonomy term splitting in WP 4.2.
[206] Fix | Delete
*
[207] Fix | Delete
* @param string $old_term_id Old term id of the taxonomy term that was splitted.
[208] Fix | Delete
* @param string $new_term_id New term id of the taxonomy term that was splitted.
[209] Fix | Delete
* @param string $term_taxonomy_id Term taxonomy id for the taxonomy that was affected.
[210] Fix | Delete
* @param string $taxonomy The taxonomy that the taxonomy term was splitted for.
[211] Fix | Delete
*
[212] Fix | Delete
* @return void
[213] Fix | Delete
*/
[214] Fix | Delete
function wpseo_split_shared_term( $old_term_id, $new_term_id, $term_taxonomy_id, $taxonomy ) {
[215] Fix | Delete
$tax_meta = get_option( 'wpseo_taxonomy_meta', [] );
[216] Fix | Delete
[217] Fix | Delete
if ( ! empty( $tax_meta[ $taxonomy ][ $old_term_id ] ) ) {
[218] Fix | Delete
$tax_meta[ $taxonomy ][ $new_term_id ] = $tax_meta[ $taxonomy ][ $old_term_id ];
[219] Fix | Delete
unset( $tax_meta[ $taxonomy ][ $old_term_id ] );
[220] Fix | Delete
update_option( 'wpseo_taxonomy_meta', $tax_meta );
[221] Fix | Delete
}
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
add_action( 'split_shared_term', 'wpseo_split_shared_term', 10, 4 );
[225] Fix | Delete
[226] Fix | Delete
/**
[227] Fix | Delete
* Get all WPSEO related capabilities.
[228] Fix | Delete
*
[229] Fix | Delete
* @since 8.3
[230] Fix | Delete
* @return array
[231] Fix | Delete
*/
[232] Fix | Delete
function wpseo_get_capabilities() {
[233] Fix | Delete
if ( ! did_action( 'wpseo_register_capabilities' ) ) {
[234] Fix | Delete
do_action( 'wpseo_register_capabilities' );
[235] Fix | Delete
}
[236] Fix | Delete
return WPSEO_Capability_Manager_Factory::get()->get_capabilities();
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function