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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../inc
File: class-addon-manager.php
[500] Fix | Delete
/**
[501] Fix | Delete
* Creates an instance of Yoast_Notification.
[502] Fix | Delete
*
[503] Fix | Delete
* @param string $product_name The product to create the notification for.
[504] Fix | Delete
* @param string $short_link The short link for the addon notification.
[505] Fix | Delete
*
[506] Fix | Delete
* @return Yoast_Notification The created notification.
[507] Fix | Delete
*/
[508] Fix | Delete
protected function create_notification( $product_name, $short_link ) {
[509] Fix | Delete
$notification_options = [
[510] Fix | Delete
'type' => Yoast_Notification::ERROR,
[511] Fix | Delete
'id' => 'wpseo-dismiss-' . sanitize_title_with_dashes( $product_name, null, 'save' ),
[512] Fix | Delete
'capabilities' => 'wpseo_manage_options',
[513] Fix | Delete
];
[514] Fix | Delete
[515] Fix | Delete
return new Yoast_Notification(
[516] Fix | Delete
sprintf(
[517] Fix | Delete
/* translators: %1$s expands to a strong tag, %2$s expands to the product name, %3$s expands to a closing strong tag, %4$s expands to an a tag. %5$s expands to MyYoast, %6$s expands to a closing a tag, %7$s expands to the product name */
[518] Fix | Delete
__( '%1$s %2$s isn\'t working as expected %3$s and you are not receiving updates or support! Make sure to %4$s activate your product subscription in %5$s%6$s to unlock all the features of %7$s.', 'wordpress-seo' ),
[519] Fix | Delete
'<strong>',
[520] Fix | Delete
$product_name,
[521] Fix | Delete
'</strong>',
[522] Fix | Delete
'<a href="' . WPSEO_Shortlinker::get( $short_link ) . '" target="_blank">',
[523] Fix | Delete
'MyYoast',
[524] Fix | Delete
'</a>',
[525] Fix | Delete
$product_name
[526] Fix | Delete
),
[527] Fix | Delete
$notification_options
[528] Fix | Delete
);
[529] Fix | Delete
}
[530] Fix | Delete
[531] Fix | Delete
/**
[532] Fix | Delete
* Checks whether a plugin expiry date has been passed.
[533] Fix | Delete
*
[534] Fix | Delete
* @param stdClass $subscription Plugin subscription.
[535] Fix | Delete
*
[536] Fix | Delete
* @return bool Has the plugin expired.
[537] Fix | Delete
*/
[538] Fix | Delete
protected function has_subscription_expired( $subscription ) {
[539] Fix | Delete
return ( strtotime( $subscription->expiry_date ) - time() ) < 0;
[540] Fix | Delete
}
[541] Fix | Delete
[542] Fix | Delete
/**
[543] Fix | Delete
* Converts a subscription to plugin based format.
[544] Fix | Delete
*
[545] Fix | Delete
* @param stdClass $subscription The subscription to convert.
[546] Fix | Delete
* @param stdClass|null $yoast_free_data The Yoast Free's data.
[547] Fix | Delete
* @param bool $plugin_info Whether we're in the plugin information modal.
[548] Fix | Delete
* @param string $plugin_file The plugin filename.
[549] Fix | Delete
*
[550] Fix | Delete
* @return stdClass The converted subscription.
[551] Fix | Delete
*/
[552] Fix | Delete
protected function convert_subscription_to_plugin( $subscription, $yoast_free_data = null, $plugin_info = false, $plugin_file = '' ) {
[553] Fix | Delete
$changelog = '';
[554] Fix | Delete
if ( isset( $subscription->product->changelog ) ) {
[555] Fix | Delete
// We need to replace h2's and h3's with h4's because the styling expects that.
[556] Fix | Delete
$changelog = str_replace( '</h2', '</h4', str_replace( '<h2', '<h4', $subscription->product->changelog ) );
[557] Fix | Delete
$changelog = str_replace( '</h3', '</h4', str_replace( '<h3', '<h4', $changelog ) );
[558] Fix | Delete
}
[559] Fix | Delete
[560] Fix | Delete
// If we're running this because we want to just show the plugin info in the version details modal, we can fallback to the Yoast Free constants, since that modal will not be accessible anyway in the event that the new Free version increases those constants.
[561] Fix | Delete
$defaults = [
[562] Fix | Delete
// It can be expanded if we have the 'tested' and 'requires_php' data be returned from wp.org in the future.
[563] Fix | Delete
'requires' => ( $plugin_info ) ? YOAST_SEO_WP_REQUIRED : null,
[564] Fix | Delete
];
[565] Fix | Delete
[566] Fix | Delete
return (object) [
[567] Fix | Delete
'new_version' => ( $subscription->product->version ?? '' ),
[568] Fix | Delete
'name' => $subscription->product->name,
[569] Fix | Delete
'slug' => $subscription->product->slug,
[570] Fix | Delete
'plugin' => $plugin_file,
[571] Fix | Delete
'url' => $subscription->product->store_url,
[572] Fix | Delete
'last_update' => $subscription->product->last_updated,
[573] Fix | Delete
'homepage' => $subscription->product->store_url,
[574] Fix | Delete
'download_link' => $subscription->product->download,
[575] Fix | Delete
'package' => $subscription->product->download,
[576] Fix | Delete
'sections' => [
[577] Fix | Delete
'changelog' => $changelog,
[578] Fix | Delete
'support' => $this->get_support_section(),
[579] Fix | Delete
],
[580] Fix | Delete
'icons' => [
[581] Fix | Delete
'2x' => $this->get_icon( $subscription->product->slug ),
[582] Fix | Delete
],
[583] Fix | Delete
'update_supported' => true,
[584] Fix | Delete
'banners' => $this->get_banners( $subscription->product->slug ),
[585] Fix | Delete
// If we have extracted Yoast Free's data before, use that. If not, resort to the defaults.
[586] Fix | Delete
'tested' => YOAST_SEO_WP_TESTED,
[587] Fix | Delete
'requires' => ( $yoast_free_data->requires ?? $defaults['requires'] ),
[588] Fix | Delete
'requires_php' => YOAST_SEO_PHP_REQUIRED,
[589] Fix | Delete
];
[590] Fix | Delete
}
[591] Fix | Delete
[592] Fix | Delete
/**
[593] Fix | Delete
* Returns the plugin's icon URL.
[594] Fix | Delete
*
[595] Fix | Delete
* @param string $slug The plugin slug.
[596] Fix | Delete
*
[597] Fix | Delete
* @return string The icon URL for this plugin.
[598] Fix | Delete
*/
[599] Fix | Delete
protected function get_icon( $slug ) {
[600] Fix | Delete
switch ( $slug ) {
[601] Fix | Delete
case self::LOCAL_SLUG:
[602] Fix | Delete
return 'https://yoa.st/local-seo-icon';
[603] Fix | Delete
case self::NEWS_SLUG:
[604] Fix | Delete
return 'https://yoa.st/news-seo-icon';
[605] Fix | Delete
case self::PREMIUM_SLUG:
[606] Fix | Delete
return 'https://yoa.st/yoast-seo-icon';
[607] Fix | Delete
case self::VIDEO_SLUG:
[608] Fix | Delete
return 'https://yoa.st/video-seo-icon';
[609] Fix | Delete
case self::WOOCOMMERCE_SLUG:
[610] Fix | Delete
return 'https://yoa.st/woo-seo-icon';
[611] Fix | Delete
}
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
/**
[615] Fix | Delete
* Return an array of plugin banner URLs.
[616] Fix | Delete
*
[617] Fix | Delete
* @param string $slug The plugin slug.
[618] Fix | Delete
*
[619] Fix | Delete
* @return string[]
[620] Fix | Delete
*/
[621] Fix | Delete
protected function get_banners( $slug ) {
[622] Fix | Delete
switch ( $slug ) {
[623] Fix | Delete
case self::LOCAL_SLUG:
[624] Fix | Delete
return [
[625] Fix | Delete
'high' => 'https://yoa.st/yoast-seo-banner-local',
[626] Fix | Delete
'low' => 'https://yoa.st/yoast-seo-banner-low-local',
[627] Fix | Delete
];
[628] Fix | Delete
case self::NEWS_SLUG:
[629] Fix | Delete
return [
[630] Fix | Delete
'high' => 'https://yoa.st/yoast-seo-banner-news',
[631] Fix | Delete
'low' => 'https://yoa.st/yoast-seo-banner-low-news',
[632] Fix | Delete
];
[633] Fix | Delete
case self::PREMIUM_SLUG:
[634] Fix | Delete
return [
[635] Fix | Delete
'high' => 'https://yoa.st/yoast-seo-banner-premium',
[636] Fix | Delete
'low' => 'https://yoa.st/yoast-seo-banner-low-premium',
[637] Fix | Delete
];
[638] Fix | Delete
case self::VIDEO_SLUG:
[639] Fix | Delete
return [
[640] Fix | Delete
'high' => 'https://yoa.st/yoast-seo-banner-video',
[641] Fix | Delete
'low' => 'https://yoa.st/yoast-seo-banner-low-video',
[642] Fix | Delete
];
[643] Fix | Delete
case self::WOOCOMMERCE_SLUG:
[644] Fix | Delete
return [
[645] Fix | Delete
'high' => 'https://yoa.st/yoast-seo-banner-woo',
[646] Fix | Delete
'low' => 'https://yoa.st/yoast-seo-banner-low-woo',
[647] Fix | Delete
];
[648] Fix | Delete
}
[649] Fix | Delete
}
[650] Fix | Delete
[651] Fix | Delete
/**
[652] Fix | Delete
* Checks if the given plugin_file belongs to a Yoast addon.
[653] Fix | Delete
*
[654] Fix | Delete
* @param string $plugin_file Path to the plugin.
[655] Fix | Delete
*
[656] Fix | Delete
* @return bool True when plugin file is for a Yoast addon.
[657] Fix | Delete
*/
[658] Fix | Delete
protected function is_yoast_addon( $plugin_file ) {
[659] Fix | Delete
return $this->get_slug_by_plugin_file( $plugin_file ) !== '';
[660] Fix | Delete
}
[661] Fix | Delete
[662] Fix | Delete
/**
[663] Fix | Delete
* Retrieves the addon slug by given plugin file path.
[664] Fix | Delete
*
[665] Fix | Delete
* @param string $plugin_file The file path to the plugin.
[666] Fix | Delete
*
[667] Fix | Delete
* @return string The slug when found or empty string when not.
[668] Fix | Delete
*/
[669] Fix | Delete
protected function get_slug_by_plugin_file( $plugin_file ) {
[670] Fix | Delete
$addons = self::$addons;
[671] Fix | Delete
[672] Fix | Delete
// Yoast SEO Free isn't an addon, but we needed it in Premium to fetch translations.
[673] Fix | Delete
if ( YoastSEO()->helpers->product->is_premium() ) {
[674] Fix | Delete
$addons['wp-seo.php'] = self::FREE_SLUG;
[675] Fix | Delete
}
[676] Fix | Delete
[677] Fix | Delete
foreach ( $addons as $addon => $addon_slug ) {
[678] Fix | Delete
if ( strpos( $plugin_file, $addon ) !== false ) {
[679] Fix | Delete
return $addon_slug;
[680] Fix | Delete
}
[681] Fix | Delete
}
[682] Fix | Delete
[683] Fix | Delete
return '';
[684] Fix | Delete
}
[685] Fix | Delete
[686] Fix | Delete
/**
[687] Fix | Delete
* Retrieves the installed Yoast addons.
[688] Fix | Delete
*
[689] Fix | Delete
* @return array The installed plugins.
[690] Fix | Delete
*/
[691] Fix | Delete
protected function get_installed_addons() {
[692] Fix | Delete
return array_filter( $this->get_plugins(), [ $this, 'is_yoast_addon' ], ARRAY_FILTER_USE_KEY );
[693] Fix | Delete
}
[694] Fix | Delete
[695] Fix | Delete
/**
[696] Fix | Delete
* Retrieves a list of active addons.
[697] Fix | Delete
*
[698] Fix | Delete
* @return array The active addons.
[699] Fix | Delete
*/
[700] Fix | Delete
protected function get_active_addons() {
[701] Fix | Delete
return array_filter( $this->get_installed_addons(), [ $this, 'is_plugin_active' ], ARRAY_FILTER_USE_KEY );
[702] Fix | Delete
}
[703] Fix | Delete
[704] Fix | Delete
/**
[705] Fix | Delete
* Retrieves the current sites from the API.
[706] Fix | Delete
*
[707] Fix | Delete
* @codeCoverageIgnore
[708] Fix | Delete
*
[709] Fix | Delete
* @return bool|stdClass Object when request is successful. False if not.
[710] Fix | Delete
*/
[711] Fix | Delete
protected function request_current_sites() {
[712] Fix | Delete
$api_request = new WPSEO_MyYoast_Api_Request( 'sites/current' );
[713] Fix | Delete
if ( $api_request->fire() ) {
[714] Fix | Delete
return $api_request->get_response();
[715] Fix | Delete
}
[716] Fix | Delete
[717] Fix | Delete
return $this->get_site_information_default();
[718] Fix | Delete
}
[719] Fix | Delete
[720] Fix | Delete
/**
[721] Fix | Delete
* Retrieves the transient value with the site information.
[722] Fix | Delete
*
[723] Fix | Delete
* @codeCoverageIgnore
[724] Fix | Delete
*
[725] Fix | Delete
* @return stdClass|false The transient value.
[726] Fix | Delete
*/
[727] Fix | Delete
protected function get_site_information_transient() {
[728] Fix | Delete
global $pagenow;
[729] Fix | Delete
[730] Fix | Delete
// Force re-check on license & dashboard pages.
[731] Fix | Delete
$current_page = null;
[732] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
[733] Fix | Delete
if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) {
[734] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are not processing form information, We are only strictly comparing and thus no need to sanitize.
[735] Fix | Delete
$current_page = wp_unslash( $_GET['page'] );
[736] Fix | Delete
}
[737] Fix | Delete
[738] Fix | Delete
// Check whether the licenses are valid or whether we need to show notifications.
[739] Fix | Delete
$quick = ( $current_page === 'wpseo_licenses' || $current_page === 'wpseo_dashboard' );
[740] Fix | Delete
[741] Fix | Delete
// Also do a fresh request on Plugins & Core Update pages.
[742] Fix | Delete
$quick = $quick || $pagenow === 'plugins.php';
[743] Fix | Delete
$quick = $quick || $pagenow === 'update-core.php';
[744] Fix | Delete
[745] Fix | Delete
if ( $quick ) {
[746] Fix | Delete
return get_transient( self::SITE_INFORMATION_TRANSIENT_QUICK );
[747] Fix | Delete
}
[748] Fix | Delete
[749] Fix | Delete
return get_transient( self::SITE_INFORMATION_TRANSIENT );
[750] Fix | Delete
}
[751] Fix | Delete
[752] Fix | Delete
/**
[753] Fix | Delete
* Sets the site information transient.
[754] Fix | Delete
*
[755] Fix | Delete
* @codeCoverageIgnore
[756] Fix | Delete
*
[757] Fix | Delete
* @param stdClass $site_information The site information to save.
[758] Fix | Delete
*
[759] Fix | Delete
* @return void
[760] Fix | Delete
*/
[761] Fix | Delete
protected function set_site_information_transient( $site_information ) {
[762] Fix | Delete
set_transient( self::SITE_INFORMATION_TRANSIENT, $site_information, DAY_IN_SECONDS );
[763] Fix | Delete
set_transient( self::SITE_INFORMATION_TRANSIENT_QUICK, $site_information, 60 );
[764] Fix | Delete
}
[765] Fix | Delete
[766] Fix | Delete
/**
[767] Fix | Delete
* Retrieves all installed WordPress plugins.
[768] Fix | Delete
*
[769] Fix | Delete
* @codeCoverageIgnore
[770] Fix | Delete
*
[771] Fix | Delete
* @return array The plugins.
[772] Fix | Delete
*/
[773] Fix | Delete
protected function get_plugins() {
[774] Fix | Delete
if ( ! function_exists( 'get_plugins' ) ) {
[775] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/plugin.php';
[776] Fix | Delete
}
[777] Fix | Delete
[778] Fix | Delete
return get_plugins();
[779] Fix | Delete
}
[780] Fix | Delete
[781] Fix | Delete
/**
[782] Fix | Delete
* Checks if the given plugin file belongs to an active plugin.
[783] Fix | Delete
*
[784] Fix | Delete
* @codeCoverageIgnore
[785] Fix | Delete
*
[786] Fix | Delete
* @param string $plugin_file The file path to the plugin.
[787] Fix | Delete
*
[788] Fix | Delete
* @return bool True when plugin is active.
[789] Fix | Delete
*/
[790] Fix | Delete
protected function is_plugin_active( $plugin_file ) {
[791] Fix | Delete
return is_plugin_active( $plugin_file );
[792] Fix | Delete
}
[793] Fix | Delete
[794] Fix | Delete
/**
[795] Fix | Delete
* Returns an object with no subscriptions.
[796] Fix | Delete
*
[797] Fix | Delete
* @codeCoverageIgnore
[798] Fix | Delete
*
[799] Fix | Delete
* @return stdClass Site information.
[800] Fix | Delete
*/
[801] Fix | Delete
protected function get_site_information_default() {
[802] Fix | Delete
return (object) [
[803] Fix | Delete
'url' => WPSEO_Utils::get_home_url(),
[804] Fix | Delete
'subscriptions' => [],
[805] Fix | Delete
];
[806] Fix | Delete
}
[807] Fix | Delete
[808] Fix | Delete
/**
[809] Fix | Delete
* Maps the plugin API response.
[810] Fix | Delete
*
[811] Fix | Delete
* @param object $site_information Site information as received from the API.
[812] Fix | Delete
*
[813] Fix | Delete
* @return stdClass Mapped site information.
[814] Fix | Delete
*/
[815] Fix | Delete
protected function map_site_information( $site_information ) {
[816] Fix | Delete
return (object) [
[817] Fix | Delete
'url' => $site_information->url,
[818] Fix | Delete
'subscriptions' => array_map( [ $this, 'map_subscription' ], $site_information->subscriptions ),
[819] Fix | Delete
];
[820] Fix | Delete
}
[821] Fix | Delete
[822] Fix | Delete
/**
[823] Fix | Delete
* Maps a plugin subscription.
[824] Fix | Delete
*
[825] Fix | Delete
* @param object $subscription Subscription information as received from the API.
[826] Fix | Delete
*
[827] Fix | Delete
* @return stdClass Mapped subscription.
[828] Fix | Delete
*/
[829] Fix | Delete
protected function map_subscription( $subscription ) {
[830] Fix | Delete
// phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- Not our properties.
[831] Fix | Delete
return (object) [
[832] Fix | Delete
'renewal_url' => $subscription->renewalUrl,
[833] Fix | Delete
'expiry_date' => $subscription->expiryDate,
[834] Fix | Delete
'product' => (object) [
[835] Fix | Delete
'version' => $subscription->product->version,
[836] Fix | Delete
'name' => $subscription->product->name,
[837] Fix | Delete
'slug' => $subscription->product->slug,
[838] Fix | Delete
'last_updated' => $subscription->product->lastUpdated,
[839] Fix | Delete
'store_url' => $subscription->product->storeUrl,
[840] Fix | Delete
// Ternary operator is necessary because download can be undefined.
[841] Fix | Delete
'download' => ( $subscription->product->download ?? null ),
[842] Fix | Delete
'changelog' => $subscription->product->changelog,
[843] Fix | Delete
],
[844] Fix | Delete
];
[845] Fix | Delete
// phpcs:enable
[846] Fix | Delete
}
[847] Fix | Delete
[848] Fix | Delete
/**
[849] Fix | Delete
* Retrieves the site information.
[850] Fix | Delete
*
[851] Fix | Delete
* @return stdClass The site information.
[852] Fix | Delete
*/
[853] Fix | Delete
private function get_site_information() {
[854] Fix | Delete
if ( ! $this->has_installed_addons() ) {
[855] Fix | Delete
return $this->get_site_information_default();
[856] Fix | Delete
}
[857] Fix | Delete
[858] Fix | Delete
return $this->get_myyoast_site_information();
[859] Fix | Delete
}
[860] Fix | Delete
[861] Fix | Delete
/**
[862] Fix | Delete
* Retrieves the contents for the support section.
[863] Fix | Delete
*
[864] Fix | Delete
* @return string The support section content.
[865] Fix | Delete
*/
[866] Fix | Delete
protected function get_support_section() {
[867] Fix | Delete
return '<h4>' . __( 'Need support?', 'wordpress-seo' ) . '</h4>'
[868] Fix | Delete
. '<p>'
[869] Fix | Delete
/* translators: 1: expands to <a> that refers to the help page, 2: </a> closing tag. */
[870] Fix | Delete
. sprintf( __( 'You can probably find an answer to your question in our %1$shelp center%2$s.', 'wordpress-seo' ), '<a href="https://yoast.com/help/">', '</a>' )
[871] Fix | Delete
. ' '
[872] Fix | Delete
/* translators: %s expands to a mailto support link. */
[873] Fix | Delete
. sprintf( __( 'If you still need support and have an active subscription for this product, please email %s.', 'wordpress-seo' ), '<a href="mailto:support@yoast.com">support@yoast.com</a>' )
[874] Fix | Delete
. '</p>';
[875] Fix | Delete
}
[876] Fix | Delete
}
[877] Fix | Delete
[878] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function