| 1 |
<?php |
| 2 |
/** |
| 3 |
* Bootstrap the application |
| 4 |
*/ |
| 5 |
|
| 6 |
defined('ABSPATH') || die('No direct access.'); |
| 7 |
|
| 8 |
use Extendify\AdminPageRouter; |
| 9 |
use Extendify\Affiliate; |
| 10 |
use Extendify\Assist\Admin as AssistAdmin; |
| 11 |
use Extendify\Config; |
| 12 |
use Extendify\Draft\Admin as DraftAdmin; |
| 13 |
use Extendify\HelpCenter\Admin as HelpCenterAdmin; |
| 14 |
use Extendify\Insights; |
| 15 |
use Extendify\Launch\Admin as LaunchAdmin; |
| 16 |
use Extendify\Library\Admin as LibraryAdmin; |
| 17 |
use Extendify\Library\Frontend as LibraryFrontend; |
| 18 |
use Extendify\PartnerData; |
| 19 |
use Extendify\Shared\Admin as SharedAdmin; |
| 20 |
|
| 21 |
if (!defined('EXTENDIFY_REQUIRED_CAPABILITY')) { |
| 22 |
define('EXTENDIFY_REQUIRED_CAPABILITY', 'manage_options'); |
| 23 |
} |
| 24 |
|
| 25 |
if (!defined('EXTENDIFY_PATH')) { |
| 26 |
define('EXTENDIFY_PATH', \plugin_dir_path(__FILE__)); |
| 27 |
} |
| 28 |
|
| 29 |
if (!defined('EXTENDIFY_URL')) { |
| 30 |
define('EXTENDIFY_URL', \plugin_dir_url(__FILE__)); |
| 31 |
} |
| 32 |
|
| 33 |
if (!defined('EXTENDIFY_PLUGIN_BASENAME')) { |
| 34 |
define('EXTENDIFY_PLUGIN_BASENAME', \plugin_basename(__DIR__ . '/extendify.php')); |
| 35 |
} |
| 36 |
|
| 37 |
if (is_readable(EXTENDIFY_PATH . 'vendor/autoload.php')) { |
| 38 |
require EXTENDIFY_PATH . 'vendor/autoload.php'; |
| 39 |
} |
| 40 |
|
| 41 |
// This file should have no dependencies and always load. |
| 42 |
new LibraryFrontend(); |
| 43 |
// This file hooks into an external task and should always load. |
| 44 |
new Insights(); |
| 45 |
|
| 46 |
if (current_user_can(EXTENDIFY_REQUIRED_CAPABILITY)) { |
| 47 |
// The config class will collect information about the |
| 48 |
// partner and plugin so it's easier to access. |
| 49 |
new Config(); |
| 50 |
if (!defined('EXTENDIFY_DEVMODE')) { |
| 51 |
define('EXTENDIFY_DEVMODE', Config::$environment === 'DEVELOPMENT'); |
| 52 |
} |
| 53 |
|
| 54 |
// This class handles the admin pages required for the plugin. |
| 55 |
new AdminPageRouter(); |
| 56 |
// This class will fetch and cache partner data to be used |
| 57 |
// throughout every class below. |
| 58 |
new PartnerData(); |
| 59 |
// This is a global "loader" class that loads in any assets that are shared everywhere. |
| 60 |
new SharedAdmin(); |
| 61 |
// This class will handle loading library assets. |
| 62 |
new LibraryAdmin(); |
| 63 |
|
| 64 |
// Only load these if the partner ID is set. These are all opt-in features. |
| 65 |
if ((Config::$partnerId && Config::$partnerId !== 'no-partner') || constant('EXTENDIFY_DEVMODE')) { |
| 66 |
// This class will update links based on the partner's specifications. |
| 67 |
new Affiliate(); |
| 68 |
// The remaining classes handle loading assets for each individual products. |
| 69 |
// They are essentially asset loading classes. |
| 70 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 71 |
if (isset($_GET['page']) && $_GET['page'] === 'extendify-assist') { |
| 72 |
// Load only on Assist. |
| 73 |
new AssistAdmin(); |
| 74 |
} |
| 75 |
|
| 76 |
// Don't load on Launch. |
| 77 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 78 |
if (!isset($_GET['page']) || $_GET['page'] !== 'extendify-launch') { |
| 79 |
new HelpCenterAdmin(); |
| 80 |
if (PartnerData::setting('showDraft') || constant('EXTENDIFY_DEVMODE')) { |
| 81 |
new DraftAdmin(); |
| 82 |
} |
| 83 |
} elseif (Config::$showLaunch) { |
| 84 |
new LaunchAdmin(); |
| 85 |
} |
| 86 |
}//end if |
| 87 |
|
| 88 |
// This loads in all the REST API routes used by the plugin. |
| 89 |
require EXTENDIFY_PATH . 'routes/api.php'; |
| 90 |
}//end if |
| 91 |
|
| 92 |
// This file is used to update the plugin and removed before w.org release. |
| 93 |
if (is_readable(EXTENDIFY_PATH . '/updater.php')) { |
| 94 |
require EXTENDIFY_PATH . 'updater.php'; |
| 95 |
} |
| 96 |
|
| 97 |
add_action('init', function () { |
| 98 |
load_plugin_textdomain('extendify-local', false, dirname(plugin_basename(__FILE__)) . '/languages/php'); |
| 99 |
}); |
| 100 |
|
| 101 |
// To cover legacy conflicts. |
| 102 |
// phpcs:ignore |
| 103 |
class ExtendifySdk |
| 104 |
{ |
| 105 |
} |
| 106 |
|