version = AIO_VERSION; } else { $this->version = '1.0.0'; } $this->plugin_name = 'aio-tools'; $this->load_dependencies(); $this->set_locale(); $this->init_modules(); $this->define_admin_hooks(); $this->define_public_hooks(); $this->includes(); } /** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - AIO_Tools_Loader. Orchestrates the hooks of the plugin. * - AIO_Tools_i18n. Defines internationalization functionality. * - AIO_Tools_Admin. Defines all hooks for the admin area. * - AIO_Tools_Public. Defines all hooks for the public side of the site. * * Create an instance of the loader which will be used to register the hooks * with WordPress. * * @since 1.0.0 * @access private */ private function load_dependencies() { /** * Load helper files */ require_once AIO_CORE_PATH . 'aio-helpers.php'; /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ require_once AIO_CORE_PATH . 'class-aio-tools-loader.php'; /** * The class responsible for defining internationalization functionality * of the plugin. */ require_once AIO_CORE_PATH . 'class-aio-tools-i18n.php'; /** * The class responsible for defining all actions that occur in the admin area. * Isolated to wp-admin (and admin-ajax/admin-post) to save ~180KB RAM on uncached frontend requests. */ if ( is_admin() ) { require_once AIO_PATH . 'admin/class-aio-tools-admin.php'; } /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ require_once AIO_PATH . 'public/class-aio-tools-public.php'; /** * The class responsible for handling encryption. */ require_once AIO_CORE_PATH . 'class-aio-crypto.php'; require_once AIO_CORE_PATH . 'class-aio-totp.php'; $this->loader = new AIO_Tools_Loader(); } /** * Define the locale for this plugin for internationalization. * * Uses the AIO_Tools_i18n class in order to set the domain and to register the hook * with WordPress. * * @since 1.0.0 * @access private */ private function set_locale() { $plugin_i18n = new AIO_Tools_i18n(); $this->loader->add_action( 'init', $plugin_i18n, 'load_plugin_textdomain', 0 ); } /** * Instantiate all classes. * Every class has inner documentation. */ private function init_modules() { } /** * Register all of the hooks related to the admin area functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_admin_hooks() { if ( is_admin() ) { $plugin_admin = new AIO_Tools_Admin( $this->get_plugin_name(), $this->get_version() ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); } else { // Lazily render AIO Tools quick menu in WP Admin Bar on Frontend ONLY for administrators add_action( 'admin_bar_menu', [ $this, 'maybe_render_frontend_admin_bar' ], 90 ); add_action( 'wp_footer', [ $this, 'maybe_render_frontend_admin_bar_script' ], 99 ); } } /** * Render AIO Tools quick menu in frontend WP Admin Bar without loading heavy admin modules for guests. */ public function maybe_render_frontend_admin_bar( $admin_bar ) { if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { return; } if ( ! class_exists( 'AIO_Tools_Admin' ) ) { require_once AIO_PATH . 'admin/class-aio-tools-admin.php'; } AIO_Tools_Admin::render_smart_admin_bar( $admin_bar ); } /** * Render lightweight AJAX toast handler for frontend WP Admin Bar cache actions. */ public function maybe_render_frontend_admin_bar_script() { if ( ! is_user_logged_in() || ! is_admin_bar_showing() || ! current_user_can( 'manage_options' ) ) { return; } if ( ! class_exists( 'AIO_Tools_Admin' ) ) { require_once AIO_PATH . 'admin/class-aio-tools-admin.php'; } AIO_Tools_Admin::output_admin_bar_ajax_script(); } /** * Register all of the hooks related to the public-facing functionality * of the plugin. * * @since 1.0.0 * @access private */ private function define_public_hooks() { $plugin_public = new AIO_Tools_Public( $this->get_plugin_name(), $this->get_version() ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'aio_public_enqueue_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'aio_public_enqueue_scripts' ); } /** * Run the loader to execute all of the hooks with WordPress. * * @since 1.0.0 */ public function run() { $this->loader->run(); } /** * The name of the plugin used to uniquely identify it within the context of * WordPress and to define internationalization functionality. * * @return string The name of the plugin. * @since 1.0.0 */ public function get_plugin_name() { return $this->plugin_name; } /** * The reference to the class that orchestrates the hooks with the plugin. * * @return AIO_Tools_Loader Orchestrates the hooks of the plugin. * @since 1.0.0 */ public function get_loader() { return $this->loader; } /** * Retrieve the version number of the plugin. * * @return string The version number of the plugin. * @since 1.0.0 */ public function get_version() { return $this->version; } public function includes() { if ( aio_is_module_active( 'opt-module-contact' ) ) { include_once AIO_MODULES_PATH . 'contact-express/public-contact.php'; } if ( aio_is_module_active( 'opt-module-smtp' ) ) { include_once AIO_MODULES_PATH . 'smtp/public-smtp.php'; } if ( aio_is_module_active( 'opt-module-woocommerce' ) ) { include_once AIO_MODULES_PATH . 'woocommerce-boost/public-woocommerce.php'; } if ( aio_is_module_active( 'opt-module-performance' ) ) { include_once AIO_MODULES_PATH . 'performance/public-performance.php'; } if ( aio_is_module_active( 'opt-module-security' ) ) { include_once AIO_MODULES_PATH . 'security/public-security.php'; } if ( aio_is_module_active( 'opt-module-optimizer' ) || aio_is_module_active( 'opt-module-performance' ) ) { include_once AIO_MODULES_PATH . 'optimizer/public-optimizer.php'; } if ( is_admin() || aio_is_module_active( 'opt-module-db-cleaner' ) ) { include_once AIO_MODULES_PATH . 'db-cleaner/public-db-cleaner.php'; } if ( aio_is_module_active( 'opt-module-messenger' ) ) { include_once AIO_MODULES_PATH . 'messenger/public-messenger.php'; } if ( aio_is_module_active( 'opt-module-utility' ) || aio_is_module_active( 'opt-module-optimizer' ) ) { require_once AIO_MODULES_PATH . 'utility/public-utility.php'; } if ( aio_is_module_active( 'opt-module-header-footer' ) ) { include_once AIO_MODULES_PATH . 'header-footer/public-header-footer.php'; } if ( aio_is_module_active( 'opt-module-login-ui' ) ) { include_once AIO_MODULES_PATH . 'login-customizer/public-login.php'; } if ( aio_is_module_active( 'opt-module-social-login' ) ) { include_once AIO_MODULES_PATH . 'social-login/class-aio-social-login.php'; new AIO_Social_Login(); } } }