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/helpers
File: short-link-helper.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Yoast\WP\SEO\Helpers;
[2] Fix | Delete
[3] Fix | Delete
/**
[4] Fix | Delete
* Helper to get shortlinks for Yoast SEO.
[5] Fix | Delete
*/
[6] Fix | Delete
class Short_Link_Helper {
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* The options helper.
[10] Fix | Delete
*
[11] Fix | Delete
* @var Options_Helper
[12] Fix | Delete
*/
[13] Fix | Delete
protected $options_helper;
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* The product helper.
[17] Fix | Delete
*
[18] Fix | Delete
* @var Product_Helper
[19] Fix | Delete
*/
[20] Fix | Delete
protected $product_helper;
[21] Fix | Delete
[22] Fix | Delete
/**
[23] Fix | Delete
* Short_Link_Helper constructor.
[24] Fix | Delete
*
[25] Fix | Delete
* @param Options_Helper $options_helper The options helper.
[26] Fix | Delete
* @param Product_Helper $product_helper The product helper.
[27] Fix | Delete
*/
[28] Fix | Delete
public function __construct(
[29] Fix | Delete
Options_Helper $options_helper,
[30] Fix | Delete
Product_Helper $product_helper
[31] Fix | Delete
) {
[32] Fix | Delete
$this->options_helper = $options_helper;
[33] Fix | Delete
$this->product_helper = $product_helper;
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
/**
[37] Fix | Delete
* Builds a URL to use in the plugin as shortlink.
[38] Fix | Delete
*
[39] Fix | Delete
* @param string $url The URL to build upon.
[40] Fix | Delete
*
[41] Fix | Delete
* @return string The final URL.
[42] Fix | Delete
*/
[43] Fix | Delete
public function build( $url ) {
[44] Fix | Delete
return \add_query_arg( $this->collect_additional_shortlink_data(), $url );
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Returns a version of the URL with a utm_content with the current version.
[49] Fix | Delete
*
[50] Fix | Delete
* @param string $url The URL to build upon.
[51] Fix | Delete
*
[52] Fix | Delete
* @return string The final URL.
[53] Fix | Delete
*/
[54] Fix | Delete
public function get( $url ) {
[55] Fix | Delete
return $this->build( $url );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
/**
[59] Fix | Delete
* Echoes a version of the URL with a utm_content with the current version.
[60] Fix | Delete
*
[61] Fix | Delete
* @param string $url The URL to build upon.
[62] Fix | Delete
*
[63] Fix | Delete
* @return void
[64] Fix | Delete
*/
[65] Fix | Delete
public function show( $url ) {
[66] Fix | Delete
echo \esc_url( $this->get( $url ) );
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
/**
[70] Fix | Delete
* Gets the shortlink's query params.
[71] Fix | Delete
*
[72] Fix | Delete
* @return array The shortlink's query params.
[73] Fix | Delete
*/
[74] Fix | Delete
public function get_query_params() {
[75] Fix | Delete
return $this->collect_additional_shortlink_data();
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
/**
[79] Fix | Delete
* Gets the current site's PHP version, without the extra info.
[80] Fix | Delete
*
[81] Fix | Delete
* @return string The PHP version.
[82] Fix | Delete
*/
[83] Fix | Delete
private function get_php_version() {
[84] Fix | Delete
$version = \explode( '.', \PHP_VERSION );
[85] Fix | Delete
[86] Fix | Delete
return (int) $version[0] . '.' . (int) $version[1];
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
/**
[90] Fix | Delete
* Gets the current site's platform version.
[91] Fix | Delete
*
[92] Fix | Delete
* @return string The wp_version.
[93] Fix | Delete
*/
[94] Fix | Delete
protected function get_platform_version() {
[95] Fix | Delete
return $GLOBALS['wp_version'];
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Collects the additional data necessary for the shortlink.
[100] Fix | Delete
*
[101] Fix | Delete
* @return array The shortlink data.
[102] Fix | Delete
*/
[103] Fix | Delete
protected function collect_additional_shortlink_data() {
[104] Fix | Delete
$data = [
[105] Fix | Delete
'php_version' => $this->get_php_version(),
[106] Fix | Delete
'platform' => 'wordpress',
[107] Fix | Delete
'platform_version' => $this->get_platform_version(),
[108] Fix | Delete
'software' => $this->get_software(),
[109] Fix | Delete
'software_version' => \WPSEO_VERSION,
[110] Fix | Delete
'days_active' => $this->get_days_active(),
[111] Fix | Delete
'user_language' => \get_user_locale(),
[112] Fix | Delete
];
[113] Fix | Delete
[114] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
[115] Fix | Delete
if ( isset( $_GET['page'] ) && \is_string( $_GET['page'] ) ) {
[116] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
[117] Fix | Delete
$admin_page = \sanitize_text_field( \wp_unslash( $_GET['page'] ) );
[118] Fix | Delete
if ( ! empty( $admin_page ) ) {
[119] Fix | Delete
$data['screen'] = $admin_page;
[120] Fix | Delete
}
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
return $data;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
/**
[127] Fix | Delete
* Get our software and whether it's active or not.
[128] Fix | Delete
*
[129] Fix | Delete
* @return string The software name.
[130] Fix | Delete
*/
[131] Fix | Delete
protected function get_software() {
[132] Fix | Delete
if ( $this->product_helper->is_premium() ) {
[133] Fix | Delete
return 'premium';
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
return 'free';
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
/**
[140] Fix | Delete
* Gets the number of days the plugin has been active.
[141] Fix | Delete
*
[142] Fix | Delete
* @return int The number of days the plugin is active.
[143] Fix | Delete
*/
[144] Fix | Delete
protected function get_days_active() {
[145] Fix | Delete
$date_activated = $this->options_helper->get( 'first_activated_on' );
[146] Fix | Delete
$datediff = ( \time() - $date_activated );
[147] Fix | Delete
[148] Fix | Delete
return (int) \round( $datediff / \DAY_IN_SECONDS );
[149] Fix | Delete
}
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function