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: class-wpseo-primary-term.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Represents a post's primary term.
[8] Fix | Delete
*/
[9] Fix | Delete
class WPSEO_Primary_Term {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Taxonomy name for the term.
[13] Fix | Delete
*
[14] Fix | Delete
* @var string
[15] Fix | Delete
*/
[16] Fix | Delete
protected $taxonomy_name;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Post ID for the term.
[20] Fix | Delete
*
[21] Fix | Delete
* @var int
[22] Fix | Delete
*/
[23] Fix | Delete
protected $post_ID;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* The taxonomy this term is part of.
[27] Fix | Delete
*
[28] Fix | Delete
* @param string $taxonomy_name Taxonomy name for the term.
[29] Fix | Delete
* @param int $post_id Post ID for the term.
[30] Fix | Delete
*/
[31] Fix | Delete
public function __construct( $taxonomy_name, $post_id ) {
[32] Fix | Delete
$this->taxonomy_name = $taxonomy_name;
[33] Fix | Delete
$this->post_ID = $post_id;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Returns the primary term ID.
[38] Fix | Delete
*
[39] Fix | Delete
* @return int|bool
[40] Fix | Delete
*/
[41] Fix | Delete
public function get_primary_term() {
[42] Fix | Delete
$primary_term = get_post_meta( $this->post_ID, WPSEO_Meta::$meta_prefix . 'primary_' . $this->taxonomy_name, true );
[43] Fix | Delete
[44] Fix | Delete
if ( ! $primary_term ) {
[45] Fix | Delete
return false;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
$terms = $this->get_terms();
[49] Fix | Delete
[50] Fix | Delete
if ( ! in_array( (int) $primary_term, wp_list_pluck( $terms, 'term_id' ), true ) ) {
[51] Fix | Delete
$primary_term = false;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
$primary_term = (int) $primary_term;
[55] Fix | Delete
return ( $primary_term ) ? ( $primary_term ) : false;
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Sets the new primary term ID.
[60] Fix | Delete
*
[61] Fix | Delete
* @param int $new_primary_term New primary term ID.
[62] Fix | Delete
*
[63] Fix | Delete
* @return void
[64] Fix | Delete
*/
[65] Fix | Delete
public function set_primary_term( $new_primary_term ) {
[66] Fix | Delete
update_post_meta( $this->post_ID, WPSEO_Meta::$meta_prefix . 'primary_' . $this->taxonomy_name, $new_primary_term );
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Get the terms for the current post ID.
[71] Fix | Delete
* When $terms is not an array, set $terms to an array.
[72] Fix | Delete
*
[73] Fix | Delete
* @return array
[74] Fix | Delete
*/
[75] Fix | Delete
protected function get_terms() {
[76] Fix | Delete
$terms = get_the_terms( $this->post_ID, $this->taxonomy_name );
[77] Fix | Delete
[78] Fix | Delete
if ( ! is_array( $terms ) ) {
[79] Fix | Delete
$terms = [];
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
return $terms;
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function