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/clone/wp-conte.../plugins/wordpres.../src/services/health-c...
File: report-builder.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Services\Health_Check;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Provides an interface to build WordPress-friendly health check results.
[5] Fix | Delete
*/
[6] Fix | Delete
class Report_Builder {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Passed health check.
[10] Fix | Delete
*/
[11] Fix | Delete
public const STATUS_GOOD = 'good';
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* Changes are recommended but not necessary.
[15] Fix | Delete
*/
[16] Fix | Delete
public const STATUS_RECOMMENDED = 'recommended';
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Significant issues that the user should consider fixing.
[20] Fix | Delete
*/
[21] Fix | Delete
public const STATUS_CRITICAL = 'critical';
[22] Fix | Delete
[23] Fix | Delete
/**
[24] Fix | Delete
* The user-facing label.
[25] Fix | Delete
*
[26] Fix | Delete
* @var string
[27] Fix | Delete
*/
[28] Fix | Delete
private $label = '';
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* The identifier that WordPress uses for the health check.
[32] Fix | Delete
*
[33] Fix | Delete
* @var string
[34] Fix | Delete
*/
[35] Fix | Delete
private $test_identifier = '';
[36] Fix | Delete
[37] Fix | Delete
/**
[38] Fix | Delete
* The test status (good, recommended, critical).
[39] Fix | Delete
*
[40] Fix | Delete
* @var string
[41] Fix | Delete
*/
[42] Fix | Delete
private $status = '';
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* The short description for the result.
[46] Fix | Delete
*
[47] Fix | Delete
* @var string
[48] Fix | Delete
*/
[49] Fix | Delete
private $description = '';
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Actions that the user can take to solve the health check result.
[53] Fix | Delete
*
[54] Fix | Delete
* @var string
[55] Fix | Delete
*/
[56] Fix | Delete
private $actions = '';
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Sets the label for the health check that the user can see.
[60] Fix | Delete
*
[61] Fix | Delete
* @param string $label The label that the user can see.
[62] Fix | Delete
* @return Report_Builder This builder.
[63] Fix | Delete
*/
[64] Fix | Delete
public function set_label( $label ) {
[65] Fix | Delete
$this->label = $label;
[66] Fix | Delete
return $this;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Sets the name for the test that the plugin uses to identify the test.
[71] Fix | Delete
*
[72] Fix | Delete
* @param string $test_identifier The identifier for the health check.
[73] Fix | Delete
* @return Report_Builder This builder.
[74] Fix | Delete
*/
[75] Fix | Delete
public function set_test_identifier( $test_identifier ) {
[76] Fix | Delete
$this->test_identifier = $test_identifier;
[77] Fix | Delete
return $this;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
/**
[81] Fix | Delete
* Sets the status of the test result to GOOD (green label).
[82] Fix | Delete
*
[83] Fix | Delete
* @return Report_Builder This builder.
[84] Fix | Delete
*/
[85] Fix | Delete
public function set_status_good() {
[86] Fix | Delete
$this->status = self::STATUS_GOOD;
[87] Fix | Delete
return $this;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
/**
[91] Fix | Delete
* Sets the status of the test result to RECOMMENDED (orange label).
[92] Fix | Delete
*
[93] Fix | Delete
* @return Report_Builder This builder.
[94] Fix | Delete
*/
[95] Fix | Delete
public function set_status_recommended() {
[96] Fix | Delete
$this->status = self::STATUS_RECOMMENDED;
[97] Fix | Delete
return $this;
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
/**
[101] Fix | Delete
* Sets the status of the test result to CRITICAL (red label).
[102] Fix | Delete
*
[103] Fix | Delete
* @return Report_Builder This builder.
[104] Fix | Delete
*/
[105] Fix | Delete
public function set_status_critical() {
[106] Fix | Delete
$this->status = self::STATUS_CRITICAL;
[107] Fix | Delete
return $this;
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* Sets a description for the test result. This will be the heading for the result in the user interface.
[112] Fix | Delete
*
[113] Fix | Delete
* @param string $description The description for the test result.
[114] Fix | Delete
* @return Report_Builder This builder.
[115] Fix | Delete
*/
[116] Fix | Delete
public function set_description( $description ) {
[117] Fix | Delete
$this->description = $description;
[118] Fix | Delete
return $this;
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
/**
[122] Fix | Delete
* Sets a text that describes how the user can solve the failed health check.
[123] Fix | Delete
*
[124] Fix | Delete
* @param string $actions The descriptive text.
[125] Fix | Delete
* @return Report_Builder This builder.
[126] Fix | Delete
*/
[127] Fix | Delete
public function set_actions( $actions ) {
[128] Fix | Delete
$this->actions = $actions;
[129] Fix | Delete
return $this;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* Builds an array of strings in the format that WordPress uses to display health checks (https://developer.wordpress.org/reference/hooks/site_status_test_result/).
[134] Fix | Delete
*
[135] Fix | Delete
* @return array The report in WordPress' site status report format.
[136] Fix | Delete
*/
[137] Fix | Delete
public function build() {
[138] Fix | Delete
return [
[139] Fix | Delete
'label' => $this->label,
[140] Fix | Delete
'status' => $this->status,
[141] Fix | Delete
'badge' => $this->get_badge(),
[142] Fix | Delete
'description' => $this->description,
[143] Fix | Delete
'actions' => $this->get_actions_with_signature(),
[144] Fix | Delete
'test' => $this->test_identifier,
[145] Fix | Delete
];
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
/**
[149] Fix | Delete
* Generates a badge that the user can see.
[150] Fix | Delete
*
[151] Fix | Delete
* @return string[] The badge.
[152] Fix | Delete
*/
[153] Fix | Delete
private function get_badge() {
[154] Fix | Delete
return [
[155] Fix | Delete
'label' => $this->get_badge_label(),
[156] Fix | Delete
'color' => $this->get_badge_color(),
[157] Fix | Delete
];
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
/**
[161] Fix | Delete
* Generates the label for a badge.
[162] Fix | Delete
*
[163] Fix | Delete
* @return string The badge label.
[164] Fix | Delete
*/
[165] Fix | Delete
private function get_badge_label() {
[166] Fix | Delete
return \__( 'SEO', 'wordpress-seo' );
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
/**
[170] Fix | Delete
* Generates the color for the badge using the current status.
[171] Fix | Delete
*
[172] Fix | Delete
* @return string The color for the badge's outline.
[173] Fix | Delete
*/
[174] Fix | Delete
private function get_badge_color() {
[175] Fix | Delete
if ( $this->status === self::STATUS_CRITICAL || $this->status === self::STATUS_RECOMMENDED ) {
[176] Fix | Delete
return 'red';
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
return 'blue';
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
/**
[183] Fix | Delete
* Concatenates the set actions with Yoast's signature.
[184] Fix | Delete
*
[185] Fix | Delete
* @return string A string containing the set actions and Yoast's signature.
[186] Fix | Delete
*/
[187] Fix | Delete
private function get_actions_with_signature() {
[188] Fix | Delete
return $this->actions . $this->get_signature();
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
/**
[192] Fix | Delete
* Generates Yoast's signature that's displayed at the bottom of the health check result.
[193] Fix | Delete
*
[194] Fix | Delete
* @return string Yoast's signature as an HTML string.
[195] Fix | Delete
*/
[196] Fix | Delete
private function get_signature() {
[197] Fix | Delete
return \sprintf(
[198] Fix | Delete
/* translators: 1: Start of a paragraph beginning with the Yoast icon, 2: Expands to 'Yoast SEO', 3: Paragraph closing tag. */
[199] Fix | Delete
\esc_html__( '%1$sThis was reported by the %2$s plugin%3$s', 'wordpress-seo' ),
[200] Fix | Delete
'<p class="yoast-site-health__signature"><img src="' . \esc_url( \plugin_dir_url( \WPSEO_FILE ) . 'packages/js/images/Yoast_SEO_Icon.svg' ) . '" alt="" height="20" width="20" class="yoast-site-health__signature-icon">',
[201] Fix | Delete
'Yoast SEO',
[202] Fix | Delete
'</p>'
[203] Fix | Delete
);
[204] Fix | Delete
}
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function