Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/extendif...
File: bootstrap.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Bootstrap the application
[3] Fix | Delete
*/
[4] Fix | Delete
[5] Fix | Delete
defined('ABSPATH') || die('No direct access.');
[6] Fix | Delete
[7] Fix | Delete
use Extendify\AdminPageRouter;
[8] Fix | Delete
use Extendify\Assist\Admin as AssistAdmin;
[9] Fix | Delete
use Extendify\Agent\Admin as AgentAdmin;
[10] Fix | Delete
use Extendify\Config;
[11] Fix | Delete
use Extendify\Draft\Admin as DraftAdmin;
[12] Fix | Delete
use Extendify\HelpCenter\Admin as HelpCenterAdmin;
[13] Fix | Delete
use Extendify\Insights;
[14] Fix | Delete
use Extendify\Launch\Admin as LaunchAdmin;
[15] Fix | Delete
use Extendify\AutoLaunch\Admin as AutoLaunchAdmin;
[16] Fix | Delete
use Extendify\Library\Admin as LibraryAdmin;
[17] Fix | Delete
use Extendify\Library\Frontend as LibraryFrontend;
[18] Fix | Delete
use Extendify\Agent\Frontend as AgentFrontend;
[19] Fix | Delete
use Extendify\PageCreator\Admin as PageCreatorAdmin;
[20] Fix | Delete
use Extendify\PartnerData;
[21] Fix | Delete
use Extendify\Recommendations\Admin as RecommendationsAdmin;
[22] Fix | Delete
use Extendify\Shared\Admin as SharedAdmin;
[23] Fix | Delete
use Extendify\Shared\DataProvider\ResourceData;
[24] Fix | Delete
use Extendify\Shared\Services\Import\ImagesImporter;
[25] Fix | Delete
use Extendify\Shared\Services\VersionMigrator;
[26] Fix | Delete
[27] Fix | Delete
if (!defined('EXTENDIFY_REQUIRED_CAPABILITY')) {
[28] Fix | Delete
define('EXTENDIFY_REQUIRED_CAPABILITY', 'manage_options');
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
if (!defined('EXTENDIFY_PATH')) {
[32] Fix | Delete
define('EXTENDIFY_PATH', \plugin_dir_path(__FILE__));
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
if (!defined('EXTENDIFY_URL')) {
[36] Fix | Delete
define('EXTENDIFY_URL', \plugin_dir_url(__FILE__));
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
if (!defined('EXTENDIFY_PLUGIN_BASENAME')) {
[40] Fix | Delete
define('EXTENDIFY_PLUGIN_BASENAME', \plugin_basename(__DIR__ . '/extendify.php'));
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
if (is_readable(EXTENDIFY_PATH . 'vendor/autoload.php')) {
[44] Fix | Delete
require EXTENDIFY_PATH . 'vendor/autoload.php';
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
if (!defined('EXTENDIFY_IS_THEME_EXTENDABLE')) {
[48] Fix | Delete
define('EXTENDIFY_IS_THEME_EXTENDABLE', get_option('stylesheet') === 'extendable');
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
(static function () {
[52] Fix | Delete
// This file should have no dependencies and always load.
[53] Fix | Delete
new LibraryFrontend();
[54] Fix | Delete
// This file hooks into an external task and should always load.
[55] Fix | Delete
new Insights();
[56] Fix | Delete
// This class set up the image import check scheduler.
[57] Fix | Delete
new ImagesImporter();
[58] Fix | Delete
[59] Fix | Delete
// Run various database updates depending on the plugin version.
[60] Fix | Delete
new VersionMigrator();
[61] Fix | Delete
[62] Fix | Delete
// This class will fetch and cache partner data to be used
[63] Fix | Delete
// throughout every class below. If opt in.
[64] Fix | Delete
new PartnerData();
[65] Fix | Delete
[66] Fix | Delete
// Set up scheduled cache (if opt-in and active).
[67] Fix | Delete
if (!PartnerData::setting('deactivated')) {
[68] Fix | Delete
ResourceData::scheduleCache();
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
if (!current_user_can(EXTENDIFY_REQUIRED_CAPABILITY)) {
[72] Fix | Delete
return;
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
// The config class will collect information about the
[76] Fix | Delete
// partner and plugin, so it's easier to access.
[77] Fix | Delete
new Config();
[78] Fix | Delete
if (!defined('EXTENDIFY_DEVMODE')) {
[79] Fix | Delete
define('EXTENDIFY_DEVMODE', Config::$environment === 'DEVELOPMENT');
[80] Fix | Delete
}
[81] Fix | Delete
[82] Fix | Delete
// This is a global "loader" class that loads in any assets that are shared everywhere.
[83] Fix | Delete
new SharedAdmin();
[84] Fix | Delete
// This class will handle loading library assets.
[85] Fix | Delete
new LibraryAdmin();
[86] Fix | Delete
[87] Fix | Delete
// Only load these if the partner ID is set. These are all opt-in features.
[88] Fix | Delete
if (!Config::$partnerId && !constant('EXTENDIFY_DEVMODE')) {
[89] Fix | Delete
return;
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
if (PartnerData::setting('deactivated')) {
[93] Fix | Delete
return;
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
// This class handles the admin pages required for the plugin.
[97] Fix | Delete
new AdminPageRouter();
[98] Fix | Delete
[99] Fix | Delete
// This class will handle loading page creator assets.
[100] Fix | Delete
if (PartnerData::setting('showAIPageCreation') || constant('EXTENDIFY_DEVMODE')) {
[101] Fix | Delete
new PageCreatorAdmin();
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
[105] Fix | Delete
$page = sanitize_text_field(wp_unslash($_GET['page'] ?? ''));
[106] Fix | Delete
[107] Fix | Delete
if ($page === 'extendify-launch') {
[108] Fix | Delete
new LaunchAdmin();
[109] Fix | Delete
return;
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
if ($page === 'extendify-auto-launch') {
[113] Fix | Delete
new AutoLaunchAdmin();
[114] Fix | Delete
return;
[115] Fix | Delete
}
[116] Fix | Delete
[117] Fix | Delete
// The remaining classes handle loading assets for each individual products.
[118] Fix | Delete
// They are essentially asset loading classes.
[119] Fix | Delete
if ($page === 'extendify-assist') {
[120] Fix | Delete
new AssistAdmin();
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
$extendifyShowAgent = constant('EXTENDIFY_IS_THEME_EXTENDABLE')
[124] Fix | Delete
&& Config::$launchCompleted
[125] Fix | Delete
&& (PartnerData::setting('showAIAgents') || Config::preview('ai-agent'));
[126] Fix | Delete
[127] Fix | Delete
if (!$extendifyShowAgent) {
[128] Fix | Delete
new HelpCenterAdmin();
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
if (PartnerData::setting('showProductRecommendations') || constant('EXTENDIFY_DEVMODE')) {
[132] Fix | Delete
new RecommendationsAdmin();
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
if (PartnerData::setting('showDraft') || constant('EXTENDIFY_DEVMODE')) {
[136] Fix | Delete
new DraftAdmin();
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
if ($extendifyShowAgent || constant('EXTENDIFY_DEVMODE')) {
[140] Fix | Delete
new AgentAdmin();
[141] Fix | Delete
new AgentFrontend();
[142] Fix | Delete
}
[143] Fix | Delete
})();
[144] Fix | Delete
[145] Fix | Delete
(static function () {
[146] Fix | Delete
if (!current_user_can(EXTENDIFY_REQUIRED_CAPABILITY)) {
[147] Fix | Delete
return;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
// This loads in all the REST API routes used by the plugin.
[151] Fix | Delete
require EXTENDIFY_PATH . 'routes/api.php';
[152] Fix | Delete
})();
[153] Fix | Delete
[154] Fix | Delete
// This file is used to update the plugin and removed before w.org release.
[155] Fix | Delete
if (is_readable(EXTENDIFY_PATH . '/updater.php')) {
[156] Fix | Delete
require EXTENDIFY_PATH . 'updater.php';
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
add_action('init', function () {
[160] Fix | Delete
load_plugin_textdomain('extendify-local', false, dirname(plugin_basename(__FILE__)) . '/languages/php');
[161] Fix | Delete
});
[162] Fix | Delete
[163] Fix | Delete
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter
[164] Fix | Delete
add_filter('load_script_translation_file', function ($file, $handle, $domain) {
[165] Fix | Delete
if ($domain !== 'extendify-local') {
[166] Fix | Delete
return $file;
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
return extendifyResolveFallbackLocaleFile($file);
[170] Fix | Delete
}, 10, 3);
[171] Fix | Delete
[172] Fix | Delete
add_filter('load_textdomain_mofile', function ($mofile, $domain) {
[173] Fix | Delete
if ($domain !== 'extendify-local') {
[174] Fix | Delete
return $mofile;
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
return extendifyResolveFallbackLocaleFile($mofile);
[178] Fix | Delete
}, 10, 2);
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Resolves a fallback translation file path if the requested locale is unsupported.
[182] Fix | Delete
*
[183] Fix | Delete
* This function checks if the current file path includes an unsupported locale
[184] Fix | Delete
* and replaces it with a supported fallback (e.g. es_AR → es_ES),
[185] Fix | Delete
* as long as the fallback file exists on disk.
[186] Fix | Delete
*
[187] Fix | Delete
* @param string $filepath The original .mo or .json translation file path.
[188] Fix | Delete
* @return string The fallback file path if it exists, or the original one.
[189] Fix | Delete
*/
[190] Fix | Delete
[191] Fix | Delete
function extendifyResolveFallbackLocaleFile($filepath)
[192] Fix | Delete
{
[193] Fix | Delete
if (str_contains($filepath, '-es_') && !file_exists($filepath)) {
[194] Fix | Delete
$fallbackFile = preg_replace('/-es_[A-Z]{2}/', '-es_ES', $filepath);
[195] Fix | Delete
if ($fallbackFile && file_exists($fallbackFile)) {
[196] Fix | Delete
return $fallbackFile;
[197] Fix | Delete
}
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
return $filepath;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
// To cover legacy conflicts.
[204] Fix | Delete
// phpcs:ignore
[205] Fix | Delete
class ExtendifySdk
[206] Fix | Delete
{
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function