*/ if ( ! defined( 'ABSPATH' ) ) { exit; } class Group107_AccessibleDocs { /** * The loader that's responsible for maintaining and registering all hooks that power * the plugin. * * @since 1.0.0 * @access protected * @var Group107_AccessibleDocs_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( 'ACCESSIBLE_DOCS_VERSION' ) ) { $this->version = ACCESSIBLE_DOCS_VERSION; } else { $this->version = '1.0.0'; } $this->plugin_name = 'accessible-docs'; $this->load_dependencies(); $this->set_locale(); $this->define_admin_hooks(); $this->define_public_hooks(); } /** * Load the required dependencies for this plugin. * * Include the following files that make up the plugin: * * - Group107_AccessibleDocs_Loader. Orchestrates the hooks of the plugin. * - Group107_AccessibleDocs_i18n. Defines internationalization functionality. * - Group107_AccessibleDocs_Options. Defines functions to get specific options for the AccessibleDocs plugin * - Group107_AccessibleDocs_Ajax_Handler. Defines handle AJAX requests. * - Group107_AccessibleDocs_Db_Handler. Defines functions to interact with the database for the accessible_docs table. * - Group107_AccessibleDocs_API_Handler. Defines handle API requests for accessible-docs * - Group107_AccessibleDocs_Admin. Defines all hooks for the admin area. * - Group107_AccessibleDocs_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 ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-loader.php'; /** * The class responsible for defining internationalization functionality * of the plugin. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-i18n.php'; /** * This class provides utility functions to get specific options for the AccessibleDocs plugin. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-options.php'; /** * The class responsible for defining ajax actions of the plugin. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-ajax-handler.php'; /** * Class to interact with the database for the accessible_docs table. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-db-handler.php'; /** * CClass to handle API requests for accessible-docs. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-api-handler.php'; require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'includes/class-accessible-docs-cron.php'; /** * The class responsible for defining all actions that occur in the admin area. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'admin/class-accessible-docs-admin.php'; /** * The class responsible for defining all actions that occur in the public-facing * side of the site. */ require_once ACCESSIBLE_DOCS_PLUGIN_PATH . 'public/class-accessible-docs-public.php'; $this->loader = new Group107_AccessibleDocs_Loader(); } /** * Define the locale for this plugin for internationalization. * * Uses the Group107_AccessibleDocs_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() { // Translations are automatically loaded by WordPress.org } /** * 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 Group107_AccessibleDocs_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' ); // Documents List actions (admins only, checked in the handler). $accessible_docs_ajax_actions = new Group107_AccessibleDocs_Ajax_Handler(); $this->loader->add_action( 'wp_ajax_accessible_docs_clear_table', $accessible_docs_ajax_actions, 'accessible_docs_clear_table' ); $this->loader->add_action( 'wp_ajax_accessible_docs_delete_selected', $accessible_docs_ajax_actions, 'accessible_docs_delete_selected' ); // Make sure the table exists on this site (network activation, new network sites, updates). add_action( 'init', array( 'Group107_AccessibleDocs_Db_Handler', 'maybe_create_table' ) ); // Hourly status sync. add_action( Group107_AccessibleDocs_Cron::HOOK, array( 'Group107_AccessibleDocs_Cron', 'sync_statuses' ) ); add_action( 'init', array( 'Group107_AccessibleDocs_Cron', 'schedule' ) ); // New credentials: drop the cached API token. add_action( 'update_option_accessible_docs_settings', array( 'Group107_AccessibleDocs_API_Handler', 'clear_access_token' ) ); } /** * 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() { // Check if email and password are set; if not, skip define_public_hooks $settings = get_option('accessible_docs_settings'); $email = $settings['email'] ?? ''; $password = $settings['password'] ?? ''; // Check if email and password and popup is enabled are set; if not, skip initializing public hooks if (empty($email) || empty($password) ) { add_action('admin_notices', function () { $settings_url = admin_url('admin.php?page=accessible-docs'); // Update with your actual settings page slug /* translators: %s is the URL to the plugin settings page. */ $message_text = __('AccessibleDocs plugin is not fully configured. Please set the email and password in the plugin settings.', 'accessible-docs'); $message = sprintf($message_text, esc_url($settings_url)); $allowed_html = array( 'a' => array( 'href' => array(), 'target' => array(), ), ); echo '
' . wp_kses($message, $allowed_html) . '