*/ class Anker_Connect { /** * The loader that's responsible for maintaining and registering all hooks that power * the plugin. * * @since 1.0.0 * @access protected * @var Anker_Connect_Loader $loader Maintains and registers all hooks for the plugin. */ protected $loader; /** * The unique identifier of this plugin. * * @since 1.0.0 * @access protected * @var string $plugin_name The string used to uniquely identify this plugin. */ protected $plugin_name; /** * The current version of the plugin. * * @since 1.0.0 * @access protected * @var string $version The current version of the plugin. */ protected $version; /** * Define the core functionality of the plugin. * * Set the plugin name and the plugin version that can be used throughout the plugin. * Load the dependencies, define the locale, and set the hooks for the admin area and * the public-facing side of the site. * * @since 1.0.0 */ public function __construct() { if ( defined( 'ANKER_CONNECT_VERSION' ) ) { $this->version = ANKER_CONNECT_VERSION; } else { $this->version = '1.0.0'; } $this->plugin_name = '5-anker-connect'; $this->load_dependencies(); $this->set_plugin_settings_link(); $this->set_locale(); $this->load_custom_dependencies(); $this->define_admin_hooks(); $this->define_public_hooks(); } /** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - Anker_Connect_Loader. Orchestrates the hooks of the plugin. * - Anker_Connect_i18n. Defines internationalization functionality. * - Anker_Connect_Admin. Defines all hooks for the admin area. * - Anker_Connect_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() { /** * The class responsible for orchestrating the actions and filters of the * core plugin. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-anker-connect-loader.php'; /** * The class responsible for defining internationalization functionality * of the plugin. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-anker-connect-i18n.php'; /** * The class responsible for defining all actions that occur in the admin area. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-anker-connect-admin.php'; /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-anker-connect-public.php'; $this->loader = new Anker_Connect_Loader(); } /** * Custom Stuff loader */ public function load_custom_dependencies() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/rest.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/cron.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/post-types.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/columns.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/templates.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/widgets.php'; require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/custom/blocks.php'; } /** * */ public function set_plugin_settings_link() { $plugin = $this->get_plugin_name() . '/anker-connect.php'; $this->loader->add_filter( 'plugin_action_links_' . $plugin, $this, 'set_settings_link' ); } /** * @return mixed */ public function set_settings_link( $links ) { $settings_link = '' . __( 'Settings' ) . ''; array_unshift( $links, $settings_link ); return $links; } /** * Define the locale for this plugin for internationalization. * * Uses the Anker_Connect_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 Anker_Connect_i18n(); $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); } /** * 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() { $plugin_admin = new Anker_Connect_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' ); $this->loader->add_action( 'admin_menu', $plugin_admin, 'anker_connect_add_plugin_page' ); $this->loader->add_action( 'admin_init', $plugin_admin, 'anker_connect_page_init' ); } /** * 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 Anker_Connect_Public( $this->get_plugin_name(), $this->get_version() ); $this->loader->add_action( 'wp_head', $plugin_public, 'enqueue_head_config' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); $this->loader->add_action( 'init', $plugin_public, 'add_shortcodes' ); } /** * 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 Anker_Connect_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; } /** * Retrieve Plugin Options * * @return object The Options * @since 1.0.0 */ public static function getOptions() { $settings = array_merge( [ 'private_token' => '', 'public_token' => '', 'config' => '{}', 'basements_uri' => 'marina', 'boats_uri' => 'yacht', 'import' => false, 'index' => false, 'notepad' => false, ], (array) ( get_option( 'connect_options' ) ) ); return (object) $settings; } }