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.../src/presente.../admin
File: badge-presenter.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Presenters\Admin;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Config\Badge_Group_Names;
[4] Fix | Delete
use Yoast\WP\SEO\Presenters\Abstract_Presenter;
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Represents the presenter class for "New" badges.
[8] Fix | Delete
*/
[9] Fix | Delete
class Badge_Presenter extends Abstract_Presenter {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Identifier of the badge.
[13] Fix | Delete
*
[14] Fix | Delete
* @var string
[15] Fix | Delete
*/
[16] Fix | Delete
private $id;
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Optional link of the badge.
[20] Fix | Delete
*
[21] Fix | Delete
* @var string
[22] Fix | Delete
*/
[23] Fix | Delete
private $link;
[24] Fix | Delete
[25] Fix | Delete
/**
[26] Fix | Delete
* Optional group which the badge belongs to.
[27] Fix | Delete
*
[28] Fix | Delete
* Each group has a fixed period after which the group will no longer be considered new and the badges will disappear.
[29] Fix | Delete
*
[30] Fix | Delete
* @var string
[31] Fix | Delete
*/
[32] Fix | Delete
private $group;
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* Optional object storing the group names and expiration versions.
[36] Fix | Delete
*
[37] Fix | Delete
* The group names set in Yoast SEO are used by default, but they can be overridden to use custom ones for an add-on.
[38] Fix | Delete
*
[39] Fix | Delete
* @var Badge_Group_Names
[40] Fix | Delete
*/
[41] Fix | Delete
private $badge_group_names;
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Badge_Presenter constructor.
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $id Id of the badge.
[47] Fix | Delete
* @param string $link Optional link of the badge.
[48] Fix | Delete
* @param string $group Optional group which the badge belongs to.
[49] Fix | Delete
* @param Badge_Group_Names|null $badge_group_names Optional object storing the group names.
[50] Fix | Delete
*/
[51] Fix | Delete
public function __construct( $id, $link = '', $group = '', $badge_group_names = null ) {
[52] Fix | Delete
$this->id = $id;
[53] Fix | Delete
$this->link = $link;
[54] Fix | Delete
$this->group = $group;
[55] Fix | Delete
[56] Fix | Delete
if ( ! $badge_group_names instanceof Badge_Group_Names ) {
[57] Fix | Delete
$badge_group_names = new Badge_Group_Names();
[58] Fix | Delete
}
[59] Fix | Delete
$this->badge_group_names = $badge_group_names;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
/**
[63] Fix | Delete
* Presents the New Badge. If a link has been passed, the badge is presented with the link.
[64] Fix | Delete
* Otherwise a static badge is presented.
[65] Fix | Delete
*
[66] Fix | Delete
* @return string The styled New Badge.
[67] Fix | Delete
*/
[68] Fix | Delete
public function present() {
[69] Fix | Delete
if ( ! $this->is_group_still_new() ) {
[70] Fix | Delete
return '';
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
if ( $this->link !== '' ) {
[74] Fix | Delete
return \sprintf(
[75] Fix | Delete
'<a class="yoast-badge yoast-badge__is-link yoast-new-badge" id="%1$s-new-badge" href="%2$s">%3$s</a>',
[76] Fix | Delete
\esc_attr( $this->id ),
[77] Fix | Delete
\esc_url( $this->link ),
[78] Fix | Delete
\esc_html__( 'New', 'wordpress-seo' )
[79] Fix | Delete
);
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
return \sprintf(
[83] Fix | Delete
'<span class="yoast-badge yoast-new-badge" id="%1$s-new-badge">%2$s</span>',
[84] Fix | Delete
\esc_attr( $this->id ),
[85] Fix | Delete
\esc_html__( 'New', 'wordpress-seo' )
[86] Fix | Delete
);
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Check whether the new badge should be shown according to the group it is in.
[91] Fix | Delete
*
[92] Fix | Delete
* @return bool True if still new.
[93] Fix | Delete
*/
[94] Fix | Delete
public function is_group_still_new() {
[95] Fix | Delete
// If there's no group configured, the new badge is always active.
[96] Fix | Delete
if ( ! $this->group ) {
[97] Fix | Delete
return true;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
return $this->badge_group_names->is_still_eligible_for_new_badge( $this->group );
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function