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.../public_h.../wp-conte.../plugins/wordpres.../src/integrat.../front-en...
File: comment-link-fixer.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Integrations\Front_End;
[2] Fix | Delete
[3] Fix | Delete
use Yoast\WP\SEO\Conditionals\Front_End_Conditional;
[4] Fix | Delete
use Yoast\WP\SEO\Helpers\Redirect_Helper;
[5] Fix | Delete
use Yoast\WP\SEO\Helpers\Robots_Helper;
[6] Fix | Delete
use Yoast\WP\SEO\Integrations\Integration_Interface;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Class Comment_Link_Fixer.
[10] Fix | Delete
*/
[11] Fix | Delete
class Comment_Link_Fixer implements Integration_Interface {
[12] Fix | Delete
[13] Fix | Delete
/**
[14] Fix | Delete
* The redirects helper.
[15] Fix | Delete
*
[16] Fix | Delete
* @var Redirect_Helper
[17] Fix | Delete
*/
[18] Fix | Delete
protected $redirect;
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* The robots helper.
[22] Fix | Delete
*
[23] Fix | Delete
* @var Robots_Helper
[24] Fix | Delete
*/
[25] Fix | Delete
protected $robots;
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Returns the conditionals based in which this loadable should be active.
[29] Fix | Delete
*
[30] Fix | Delete
* @return array
[31] Fix | Delete
*/
[32] Fix | Delete
public static function get_conditionals() {
[33] Fix | Delete
return [ Front_End_Conditional::class ];
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Comment_Link_Fixer constructor.
[38] Fix | Delete
*
[39] Fix | Delete
* @codeCoverageIgnore It only sets depedencies.
[40] Fix | Delete
*
[41] Fix | Delete
* @param Redirect_Helper $redirect The redirect helper.
[42] Fix | Delete
* @param Robots_Helper $robots The robots helper.
[43] Fix | Delete
*/
[44] Fix | Delete
public function __construct( Redirect_Helper $redirect, Robots_Helper $robots ) {
[45] Fix | Delete
$this->redirect = $redirect;
[46] Fix | Delete
$this->robots = $robots;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
/**
[50] Fix | Delete
* Initializes the integration.
[51] Fix | Delete
*
[52] Fix | Delete
* This is the place to register hooks and filters.
[53] Fix | Delete
*
[54] Fix | Delete
* @return void
[55] Fix | Delete
*/
[56] Fix | Delete
public function register_hooks() {
[57] Fix | Delete
if ( $this->clean_reply_to_com() ) {
[58] Fix | Delete
\add_filter( 'comment_reply_link', [ $this, 'remove_reply_to_com' ] );
[59] Fix | Delete
\add_action( 'template_redirect', [ $this, 'replytocom_redirect' ], 1 );
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
// When users view a reply to a comment, this URL parameter is set. These should never be indexed separately.
[63] Fix | Delete
if ( $this->get_replytocom_parameter() !== null ) {
[64] Fix | Delete
\add_filter( 'wpseo_robots_array', [ $this->robots, 'set_robots_no_index' ] );
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
/**
[69] Fix | Delete
* Checks if the url contains the ?replytocom query parameter.
[70] Fix | Delete
*
[71] Fix | Delete
* @codeCoverageIgnore Wraps the filter input.
[72] Fix | Delete
*
[73] Fix | Delete
* @return string|null The value of replytocom or null if it does not exist.
[74] Fix | Delete
*/
[75] Fix | Delete
protected function get_replytocom_parameter() {
[76] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
[77] Fix | Delete
if ( isset( $_GET['replytocom'] ) && \is_string( $_GET['replytocom'] ) ) {
[78] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
[79] Fix | Delete
return \sanitize_text_field( \wp_unslash( $_GET['replytocom'] ) );
[80] Fix | Delete
}
[81] Fix | Delete
return null;
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Removes the ?replytocom variable from the link, replacing it with a #comment-<number> anchor.
[86] Fix | Delete
*
[87] Fix | Delete
* @todo Should this function also allow for relative urls ?
[88] Fix | Delete
*
[89] Fix | Delete
* @param string $link The comment link as a string.
[90] Fix | Delete
*
[91] Fix | Delete
* @return string The modified link.
[92] Fix | Delete
*/
[93] Fix | Delete
public function remove_reply_to_com( $link ) {
[94] Fix | Delete
return \preg_replace( '`href=(["\'])(?:.*(?:\?|&|&#038;)replytocom=(\d+)#respond)`', 'href=$1#comment-$2', $link );
[95] Fix | Delete
}
[96] Fix | Delete
[97] Fix | Delete
/**
[98] Fix | Delete
* Redirects out the ?replytocom variables.
[99] Fix | Delete
*
[100] Fix | Delete
* @return bool True when redirect has been done.
[101] Fix | Delete
*/
[102] Fix | Delete
public function replytocom_redirect() {
[103] Fix | Delete
if ( isset( $_GET['replytocom'] ) && \is_singular() ) {
[104] Fix | Delete
$url = \get_permalink( $GLOBALS['post']->ID );
[105] Fix | Delete
$hash = \sanitize_text_field( \wp_unslash( $_GET['replytocom'] ) );
[106] Fix | Delete
$query_string = '';
[107] Fix | Delete
if ( isset( $_SERVER['QUERY_STRING'] ) ) {
[108] Fix | Delete
$query_string = \remove_query_arg( 'replytocom', \sanitize_text_field( \wp_unslash( $_SERVER['QUERY_STRING'] ) ) );
[109] Fix | Delete
}
[110] Fix | Delete
if ( ! empty( $query_string ) ) {
[111] Fix | Delete
$url .= '?' . $query_string;
[112] Fix | Delete
}
[113] Fix | Delete
$url .= '#comment-' . $hash;
[114] Fix | Delete
[115] Fix | Delete
$this->redirect->do_safe_redirect( $url, 301 );
[116] Fix | Delete
[117] Fix | Delete
return true;
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
return false;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* Checks whether we can allow the feature that removes ?replytocom query parameters.
[125] Fix | Delete
*
[126] Fix | Delete
* @codeCoverageIgnore It just wraps a call to a filter.
[127] Fix | Delete
*
[128] Fix | Delete
* @return bool True to remove, false not to remove.
[129] Fix | Delete
*/
[130] Fix | Delete
private function clean_reply_to_com() {
[131] Fix | Delete
/**
[132] Fix | Delete
* Filter: 'wpseo_remove_reply_to_com' - Allow disabling the feature that removes ?replytocom query parameters.
[133] Fix | Delete
*
[134] Fix | Delete
* @param bool $return True to remove, false not to remove.
[135] Fix | Delete
*/
[136] Fix | Delete
return (bool) \apply_filters( 'wpseo_remove_reply_to_com', true );
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function