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.../admin
File: class-admin-recommended-replace-vars.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Determines the recommended replacement variables based on the context.
[8] Fix | Delete
*/
[9] Fix | Delete
class WPSEO_Admin_Recommended_Replace_Vars {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* The recommended replacement variables.
[13] Fix | Delete
*
[14] Fix | Delete
* @var array
[15] Fix | Delete
*/
[16] Fix | Delete
protected $recommended_replace_vars = [
[17] Fix | Delete
// Posts types.
[18] Fix | Delete
'page' => [ 'sitename', 'title', 'sep', 'primary_category' ],
[19] Fix | Delete
'post' => [ 'sitename', 'title', 'sep', 'primary_category' ],
[20] Fix | Delete
// Homepage.
[21] Fix | Delete
'homepage' => [ 'sitename', 'sitedesc', 'sep' ],
[22] Fix | Delete
// Custom post type.
[23] Fix | Delete
'custom_post_type' => [ 'sitename', 'title', 'sep' ],
[24] Fix | Delete
[25] Fix | Delete
// Taxonomies.
[26] Fix | Delete
'category' => [ 'sitename', 'term_title', 'sep', 'term_hierarchy' ],
[27] Fix | Delete
'post_tag' => [ 'sitename', 'term_title', 'sep' ],
[28] Fix | Delete
'post_format' => [ 'sitename', 'term_title', 'sep', 'page' ],
[29] Fix | Delete
[30] Fix | Delete
// Custom taxonomy.
[31] Fix | Delete
'term-in-custom-taxonomy' => [ 'sitename', 'term_title', 'sep', 'term_hierarchy' ],
[32] Fix | Delete
[33] Fix | Delete
// Settings - archive pages.
[34] Fix | Delete
'author_archive' => [ 'sitename', 'title', 'sep', 'page' ],
[35] Fix | Delete
'date_archive' => [ 'sitename', 'sep', 'date', 'page' ],
[36] Fix | Delete
'custom-post-type_archive' => [ 'sitename', 'title', 'sep', 'page' ],
[37] Fix | Delete
[38] Fix | Delete
// Settings - special pages.
[39] Fix | Delete
'search' => [ 'sitename', 'searchphrase', 'sep', 'page' ],
[40] Fix | Delete
'404' => [ 'sitename', 'sep' ],
[41] Fix | Delete
];
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Determines the page type of the current term.
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $taxonomy The taxonomy name.
[47] Fix | Delete
*
[48] Fix | Delete
* @return string The page type.
[49] Fix | Delete
*/
[50] Fix | Delete
public function determine_for_term( $taxonomy ) {
[51] Fix | Delete
$recommended_replace_vars = $this->get_recommended_replacevars();
[52] Fix | Delete
if ( array_key_exists( $taxonomy, $recommended_replace_vars ) ) {
[53] Fix | Delete
return $taxonomy;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
return 'term-in-custom-taxonomy';
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
/**
[60] Fix | Delete
* Determines the page type of the current post.
[61] Fix | Delete
*
[62] Fix | Delete
* @param WP_Post $post A WordPress post instance.
[63] Fix | Delete
*
[64] Fix | Delete
* @return string The page type.
[65] Fix | Delete
*/
[66] Fix | Delete
public function determine_for_post( $post ) {
[67] Fix | Delete
if ( $post instanceof WP_Post === false ) {
[68] Fix | Delete
return 'post';
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
if ( $post->post_type === 'page' && $this->is_homepage( $post ) ) {
[72] Fix | Delete
return 'homepage';
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
$recommended_replace_vars = $this->get_recommended_replacevars();
[76] Fix | Delete
if ( array_key_exists( $post->post_type, $recommended_replace_vars ) ) {
[77] Fix | Delete
return $post->post_type;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
return 'custom_post_type';
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
/**
[84] Fix | Delete
* Determines the page type for a post type.
[85] Fix | Delete
*
[86] Fix | Delete
* @param string $post_type The name of the post_type.
[87] Fix | Delete
* @param string $fallback The page type to fall back to.
[88] Fix | Delete
*
[89] Fix | Delete
* @return string The page type.
[90] Fix | Delete
*/
[91] Fix | Delete
public function determine_for_post_type( $post_type, $fallback = 'custom_post_type' ) {
[92] Fix | Delete
$page_type = $post_type;
[93] Fix | Delete
$recommended_replace_vars = $this->get_recommended_replacevars();
[94] Fix | Delete
$has_recommended_replacevars = $this->has_recommended_replace_vars( $recommended_replace_vars, $page_type );
[95] Fix | Delete
[96] Fix | Delete
if ( ! $has_recommended_replacevars ) {
[97] Fix | Delete
return $fallback;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
return $page_type;
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
/**
[104] Fix | Delete
* Determines the page type for an archive page.
[105] Fix | Delete
*
[106] Fix | Delete
* @param string $name The name of the archive.
[107] Fix | Delete
* @param string $fallback The page type to fall back to.
[108] Fix | Delete
*
[109] Fix | Delete
* @return string The page type.
[110] Fix | Delete
*/
[111] Fix | Delete
public function determine_for_archive( $name, $fallback = 'custom-post-type_archive' ) {
[112] Fix | Delete
$page_type = $name . '_archive';
[113] Fix | Delete
$recommended_replace_vars = $this->get_recommended_replacevars();
[114] Fix | Delete
$has_recommended_replacevars = $this->has_recommended_replace_vars( $recommended_replace_vars, $page_type );
[115] Fix | Delete
[116] Fix | Delete
if ( ! $has_recommended_replacevars ) {
[117] Fix | Delete
return $fallback;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
return $page_type;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Retrieves the recommended replacement variables for the given page type.
[125] Fix | Delete
*
[126] Fix | Delete
* @param string $page_type The page type.
[127] Fix | Delete
*
[128] Fix | Delete
* @return array The recommended replacement variables.
[129] Fix | Delete
*/
[130] Fix | Delete
public function get_recommended_replacevars_for( $page_type ) {
[131] Fix | Delete
$recommended_replace_vars = $this->get_recommended_replacevars();
[132] Fix | Delete
$has_recommended_replace_vars = $this->has_recommended_replace_vars( $recommended_replace_vars, $page_type );
[133] Fix | Delete
[134] Fix | Delete
if ( ! $has_recommended_replace_vars ) {
[135] Fix | Delete
return [];
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
return $recommended_replace_vars[ $page_type ];
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
/**
[142] Fix | Delete
* Retrieves the recommended replacement variables.
[143] Fix | Delete
*
[144] Fix | Delete
* @return array The recommended replacement variables.
[145] Fix | Delete
*/
[146] Fix | Delete
public function get_recommended_replacevars() {
[147] Fix | Delete
/**
[148] Fix | Delete
* Filter: Adds the possibility to add extra recommended replacement variables.
[149] Fix | Delete
*
[150] Fix | Delete
* @param array $additional_replace_vars Empty array to add the replacevars to.
[151] Fix | Delete
*/
[152] Fix | Delete
$recommended_replace_vars = apply_filters( 'wpseo_recommended_replace_vars', $this->recommended_replace_vars );
[153] Fix | Delete
[154] Fix | Delete
if ( ! is_array( $recommended_replace_vars ) ) {
[155] Fix | Delete
return $this->recommended_replace_vars;
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
return $recommended_replace_vars;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
/**
[162] Fix | Delete
* Returns whether the given page type has recommended replace vars.
[163] Fix | Delete
*
[164] Fix | Delete
* @param array $recommended_replace_vars The recommended replace vars
[165] Fix | Delete
* to check in.
[166] Fix | Delete
* @param string $page_type The page type to check.
[167] Fix | Delete
*
[168] Fix | Delete
* @return bool True if there are associated recommended replace vars.
[169] Fix | Delete
*/
[170] Fix | Delete
private function has_recommended_replace_vars( $recommended_replace_vars, $page_type ) {
[171] Fix | Delete
if ( ! isset( $recommended_replace_vars[ $page_type ] ) ) {
[172] Fix | Delete
return false;
[173] Fix | Delete
}
[174] Fix | Delete
[175] Fix | Delete
if ( ! is_array( $recommended_replace_vars[ $page_type ] ) ) {
[176] Fix | Delete
return false;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
return true;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Determines whether or not a post is the homepage.
[184] Fix | Delete
*
[185] Fix | Delete
* @param WP_Post $post The WordPress global post object.
[186] Fix | Delete
*
[187] Fix | Delete
* @return bool True if the given post is the homepage.
[188] Fix | Delete
*/
[189] Fix | Delete
private function is_homepage( $post ) {
[190] Fix | Delete
if ( $post instanceof WP_Post === false ) {
[191] Fix | Delete
return false;
[192] Fix | Delete
}
[193] Fix | Delete
[194] Fix | Delete
/*
[195] Fix | Delete
* The page on front returns a string with normal WordPress interaction, while the post ID is an int.
[196] Fix | Delete
* This way we make sure we always compare strings.
[197] Fix | Delete
*/
[198] Fix | Delete
$post_id = (int) $post->ID;
[199] Fix | Delete
$page_on_front = (int) get_option( 'page_on_front' );
[200] Fix | Delete
[201] Fix | Delete
return get_option( 'show_on_front' ) === 'page' && $page_on_front === $post_id;
[202] Fix | Delete
}
[203] Fix | Delete
}
[204] Fix | Delete
[205] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function