Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/extendif...
File: extendify.php
<?php
[0] Fix | Delete
[1] Fix | Delete
// phpcs:disable Generic.Files.LineLength.TooLong
[2] Fix | Delete
/**
[3] Fix | Delete
* Plugin Name: Extendify WordPress Onboarding and AI Assistant
[4] Fix | Delete
* Description: AI-powered WordPress assistant for onboarding and ongoing editing offered exclusively through select WordPress hosting providers.
[5] Fix | Delete
* Plugin URI: https://extendify.com/?utm_source=wp-plugins&utm_campaign=plugin-uri&utm_medium=wp-dash
[6] Fix | Delete
* Author: Extendify
[7] Fix | Delete
* Author URI: https://extendify.com/?utm_source=wp-plugins&utm_campaign=author-uri&utm_medium=wp-dash
[8] Fix | Delete
* Version: 2.4.0
[9] Fix | Delete
* Requires at least: 6.5
[10] Fix | Delete
* Requires PHP: 7.0
[11] Fix | Delete
* License: GPL-2.0-or-later
[12] Fix | Delete
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
[13] Fix | Delete
* Text Domain: extendify-local
[14] Fix | Delete
* Domain Path: /languages
[15] Fix | Delete
*
[16] Fix | Delete
* Extendify is free software: you can redistribute it and/or modify
[17] Fix | Delete
* it under the terms of the GNU General Public License as published by
[18] Fix | Delete
* the Free Software Foundation, either version 2 of the License, or
[19] Fix | Delete
* any later version.
[20] Fix | Delete
*
[21] Fix | Delete
* Extendify is distributed in the hope that it will be useful,
[22] Fix | Delete
* but WITHOUT ANY WARRANTY; without even the implied warranty of
[23] Fix | Delete
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[24] Fix | Delete
* GNU General Public License for more details.
[25] Fix | Delete
*/
[26] Fix | Delete
// phpcs:enable Generic.Files.LineLength.TooLong
[27] Fix | Delete
[28] Fix | Delete
defined('ABSPATH') || exit;
[29] Fix | Delete
[30] Fix | Delete
use Extendify\PartnerData;
[31] Fix | Delete
[32] Fix | Delete
/** ExtendifySdk is the previous class name used */
[33] Fix | Delete
if (!class_exists('ExtendifySdk') && !class_exists('Extendify')) :
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* The Extendify Library
[37] Fix | Delete
*/
[38] Fix | Delete
// phpcs:ignore PSR1.Classes.ClassDeclaration.MissingNamespace
[39] Fix | Delete
final class Extendify
[40] Fix | Delete
{
[41] Fix | Delete
/**
[42] Fix | Delete
* Var to make sure we only load once
[43] Fix | Delete
*
[44] Fix | Delete
* @var boolean $loaded
[45] Fix | Delete
*/
[46] Fix | Delete
public static $loaded = false;
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Set up the Library
[50] Fix | Delete
*
[51] Fix | Delete
* @return void
[52] Fix | Delete
*/
[53] Fix | Delete
public function __invoke()
[54] Fix | Delete
{
[55] Fix | Delete
// Allow users to disable the library. The latter is left in for historical reasons.
[56] Fix | Delete
if (!apply_filters('extendify_load_library', true) || !apply_filters('extendifysdk_load_library', true)) {
[57] Fix | Delete
return;
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
if (version_compare(PHP_VERSION, '7.0', '<') || version_compare($GLOBALS['wp_version'], '6.5', '<')) {
[61] Fix | Delete
return;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
if (!self::$loaded) {
[65] Fix | Delete
self::$loaded = true;
[66] Fix | Delete
require dirname(__FILE__) . '/bootstrap.php';
[67] Fix | Delete
if (!defined('EXTENDIFY_BASE_URL')) {
[68] Fix | Delete
define('EXTENDIFY_BASE_URL', plugin_dir_url(__FILE__));
[69] Fix | Delete
}
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
add_action('plugins_loaded', function () {
[75] Fix | Delete
$extendify = new Extendify();
[76] Fix | Delete
$extendify();
[77] Fix | Delete
});
[78] Fix | Delete
[79] Fix | Delete
add_action('update_option', function ($option) {
[80] Fix | Delete
if (in_array($option, ['WPLANG', 'blogname'], true)) {
[81] Fix | Delete
\delete_transient('extendify_recommendations');
[82] Fix | Delete
\delete_transient('extendify_domains');
[83] Fix | Delete
\delete_transient('extendify_supportArticles');
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
// Delete the partner transient so we can fetch new data when the locale is switched.
[87] Fix | Delete
if (($option === 'WPLANG') && get_transient('extendify_partner_data_cache_check')) {
[88] Fix | Delete
delete_transient('extendify_partner_data_cache_check');
[89] Fix | Delete
PartnerData::getPartnerData();
[90] Fix | Delete
}
[91] Fix | Delete
});
[92] Fix | Delete
[93] Fix | Delete
// Delete the partner transient so we can fetch new data when the locale is switched via WP-CLI.
[94] Fix | Delete
add_action('cli_init', function () {
[95] Fix | Delete
$command = sanitize_text_field(wp_unslash(($_SERVER['argv'][1] ?? '')));
[96] Fix | Delete
if ($command === 'language' && get_transient('extendify_partner_data_cache_check')) {
[97] Fix | Delete
delete_transient('extendify_partner_data_cache_check');
[98] Fix | Delete
PartnerData::getPartnerData();
[99] Fix | Delete
}
[100] Fix | Delete
});
[101] Fix | Delete
[102] Fix | Delete
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
[103] Fix | Delete
add_action('upgrader_process_complete', function ($upgrader, $options) {
[104] Fix | Delete
$updatedExtendify = isset($options['plugins']) && array_filter($options['plugins'], function ($plugin) {
[105] Fix | Delete
return strpos($plugin, 'extendify') !== false;
[106] Fix | Delete
});
[107] Fix | Delete
[108] Fix | Delete
if (!$updatedExtendify) {
[109] Fix | Delete
return;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
\delete_transient('extendify_recommendations');
[113] Fix | Delete
\delete_transient('extendify_domains');
[114] Fix | Delete
\delete_transient('extendify_supportArticles');
[115] Fix | Delete
}, 10, 2);
[116] Fix | Delete
[117] Fix | Delete
// Redirect logins to the Extendify Assist dashboard if they are an admin.
[118] Fix | Delete
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
[119] Fix | Delete
\add_filter('login_redirect', function ($redirectTo, $requestedRedirectTo, $user) {
[120] Fix | Delete
// Only redirect if going to the admin page.
[121] Fix | Delete
if ($redirectTo !== \admin_url()) {
[122] Fix | Delete
return $redirectTo;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
if (!$user || !is_a($user, 'WP_User') || !defined('EXTENDIFY_PARTNER_ID')) {
[126] Fix | Delete
return $redirectTo;
[127] Fix | Delete
}
[128] Fix | Delete
[129] Fix | Delete
$partnerData = get_option('extendify_partner_data_v2', []);
[130] Fix | Delete
if (!$user->has_cap('manage_options') || empty($partnerData)) {
[131] Fix | Delete
return $redirectTo;
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
return \admin_url() . 'admin.php?page=extendify-assist';
[135] Fix | Delete
}, 10, 3);
[136] Fix | Delete
[137] Fix | Delete
// Redirect to a safe place if the user doesn't have access.
[138] Fix | Delete
add_action('admin_page_access_denied', function () {
[139] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[140] Fix | Delete
if (isset($_GET['page']) && strpos(sanitize_text_field(wp_unslash($_GET['page'])), 'extendify') !== false) {
[141] Fix | Delete
wp_safe_redirect(admin_url());
[142] Fix | Delete
exit;
[143] Fix | Delete
}
[144] Fix | Delete
});
[145] Fix | Delete
[146] Fix | Delete
// Allow Extendify requests to have a longer timeout.
[147] Fix | Delete
add_filter('http_request_args', function ($args, $url) {
[148] Fix | Delete
if (strpos($url, 'extendify') !== false) {
[149] Fix | Delete
$args['timeout'] = 45;
[150] Fix | Delete
}
[151] Fix | Delete
[152] Fix | Delete
return $args;
[153] Fix | Delete
}, 100, 2);
[154] Fix | Delete
endif;
[155] Fix | Delete
[156] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function