CatchThemesThemePlugin.php
4 months ago
class-catch-scroll-progress-bar-activator.php
4 months ago
class-catch-scroll-progress-bar-deactivator.php
4 months ago
class-catch-scroll-progress-bar-i18n.php
4 months ago
class-catch-scroll-progress-bar-loader.php
4 months ago
class-catch-scroll-progress-bar.php
4 months ago
ctp-tabs-removal.php
4 months ago
index.php
4 months ago
class-catch-scroll-progress-bar.php
213 lines
| 1 | <?php |
| 2 | |
| 3 | // Exit if accessed directly |
| 4 | if (! defined('ABSPATH')) exit; |
| 5 | |
| 6 | /** |
| 7 | * The core plugin class. |
| 8 | * |
| 9 | * Also maintains the unique identifier of this plugin as well as the current |
| 10 | * version of the plugin. |
| 11 | * |
| 12 | * @since 1.0.0 |
| 13 | * @package Catch_Scroll_Progress_Bar |
| 14 | * @subpackage Catch_Scroll_Progress_Bar/includes |
| 15 | * @author Catch Plugins <www.catchplugins.com> |
| 16 | */ |
| 17 | class Catch_Scroll_Progress_Bar |
| 18 | { |
| 19 | |
| 20 | /** |
| 21 | * The loader that's responsible for maintaining and registering all hooks that power |
| 22 | * the plugin. |
| 23 | * |
| 24 | * @since 1.0.0 |
| 25 | * @access protected |
| 26 | * @var Catch_Progress_Bar_Loader $loader Maintains and registers all hooks for the plugin. |
| 27 | */ |
| 28 | protected $loader; |
| 29 | |
| 30 | /** |
| 31 | * The unique identifier of this plugin. |
| 32 | * |
| 33 | * @since 1.0.0 |
| 34 | * @access protected |
| 35 | * @var string $plugin_name The string used to uniquely identify this plugin. |
| 36 | */ |
| 37 | protected $plugin_name; |
| 38 | |
| 39 | /** |
| 40 | * The current version of the plugin. |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | * @access protected |
| 44 | * @var string $version The current version of the plugin. |
| 45 | */ |
| 46 | protected $version; |
| 47 | |
| 48 | /** |
| 49 | * Define the core functionality of the plugin. |
| 50 | * |
| 51 | * Set the plugin name and the plugin version that can be used throughout the plugin. |
| 52 | * Load the dependencies, define the locale, and set the hooks for the admin area and |
| 53 | * the public-facing side of the site. |
| 54 | * |
| 55 | * @since 1.0.0 |
| 56 | */ |
| 57 | public function __construct() |
| 58 | { |
| 59 | |
| 60 | $this->version = CATCH_SCROLL_PROGRESS_BAR_VERSION; |
| 61 | |
| 62 | $this->plugin_name = 'catch-scroll-progress-bar'; |
| 63 | |
| 64 | $this->load_dependencies(); |
| 65 | $this->set_locale(); |
| 66 | $this->define_admin_hooks(); |
| 67 | $this->define_public_hooks(); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Load the required dependencies for this plugin. |
| 72 | * |
| 73 | * Include the following files that make up the plugin: |
| 74 | * |
| 75 | * - Catch_Scroll_Progress_Bar_Loader. Orchestrates the hooks of the plugin. |
| 76 | * - Catch_Scroll_Progress_Bar_i18n. Defines internationalization functionality. |
| 77 | * - Catch_Scroll_Progress_Bar_Admin. Defines all hooks for the admin area. |
| 78 | * - Catch_Scroll_Progress_Bar_Public. Defines all hooks for the public side of the site. |
| 79 | * |
| 80 | * Create an instance of the loader which will be used to register the hooks |
| 81 | * with WordPress. |
| 82 | * |
| 83 | * @since 1.0.0 |
| 84 | * @access private |
| 85 | */ |
| 86 | private function load_dependencies() |
| 87 | { |
| 88 | |
| 89 | /** |
| 90 | * The class responsible for orchestrating the actions and filters of the |
| 91 | * core plugin. |
| 92 | */ |
| 93 | require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-catch-scroll-progress-bar-loader.php'; |
| 94 | |
| 95 | /** |
| 96 | * The class responsible for defining internationalization functionality |
| 97 | * of the plugin. |
| 98 | */ |
| 99 | require_once plugin_dir_path(dirname(__FILE__)) . 'includes/class-catch-scroll-progress-bar-i18n.php'; |
| 100 | |
| 101 | /** |
| 102 | * The class responsible for defining all actions that occur in the admin area. |
| 103 | */ |
| 104 | require_once plugin_dir_path(dirname(__FILE__)) . 'admin/class-catch-scroll-progress-bar-admin.php'; |
| 105 | |
| 106 | /** |
| 107 | * The class responsible for defining all actions that occur in the public-facing |
| 108 | * side of the site. |
| 109 | */ |
| 110 | require_once plugin_dir_path(dirname(__FILE__)) . 'public/class-catch-scroll-progress-bar-public.php'; |
| 111 | |
| 112 | $this->loader = new Catch_Scroll_Progress_Bar_Loader(); |
| 113 | } |
| 114 | |
| 115 | /** |
| 116 | * Define the locale for this plugin for internationalization. |
| 117 | * |
| 118 | * Uses the Catch_Scroll_Progress_Bar_i18n class in order to set the domain and to register the hook |
| 119 | * with WordPress. |
| 120 | * |
| 121 | * @since 1.0.0 |
| 122 | * @access private |
| 123 | */ |
| 124 | private function set_locale() |
| 125 | { |
| 126 | |
| 127 | $plugin_i18n = new Catch_Scroll_Progress_Bar_i18n(); |
| 128 | |
| 129 | $this->loader->add_action('plugins_loaded', $plugin_i18n, 'load_plugin_textdomain'); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Register all of the hooks related to the admin area functionality |
| 134 | * of the plugin. |
| 135 | * |
| 136 | * @since 1.0.0 |
| 137 | * @access private |
| 138 | */ |
| 139 | private function define_admin_hooks() |
| 140 | { |
| 141 | |
| 142 | $plugin_admin = new Catch_Scroll_Progress_Bar_Admin($this->get_plugin_name(), $this->get_version()); |
| 143 | |
| 144 | $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles'); |
| 145 | $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts'); |
| 146 | $this->loader->add_action('admin_menu', $plugin_admin, 'add_plugin_settings_menu'); |
| 147 | $this->loader->add_action('admin_init', $plugin_admin, 'register_settings'); |
| 148 | $this->loader->add_filter('plugin_action_links', $plugin_admin, 'action_links', 10, 2); |
| 149 | $this->loader->add_filter('plugin_row_meta', $plugin_admin, 'add_plugin_meta_links', 10, 2); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * Register all of the hooks related to the public-facing functionality |
| 154 | * of the plugin. |
| 155 | * |
| 156 | * @since 1.0.0 |
| 157 | * @access private |
| 158 | */ |
| 159 | private function define_public_hooks() |
| 160 | { |
| 161 | |
| 162 | $plugin_public = new Catch_Scroll_Progress_Bar_Public($this->get_plugin_name(), $this->get_version()); |
| 163 | |
| 164 | $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_styles'); |
| 165 | $this->loader->add_action('wp_enqueue_scripts', $plugin_public, 'enqueue_scripts'); |
| 166 | $this->loader->add_action('wp_footer', $plugin_public, 'show_it'); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * Run the loader to execute all of the hooks with WordPress. |
| 171 | * |
| 172 | * @since 1.0.0 |
| 173 | */ |
| 174 | public function run() |
| 175 | { |
| 176 | $this->loader->run(); |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * The name of the plugin used to uniquely identify it within the context of |
| 181 | * WordPress and to define internationalization functionality. |
| 182 | * |
| 183 | * @since 1.0.0 |
| 184 | * @return string The name of the plugin. |
| 185 | */ |
| 186 | public function get_plugin_name() |
| 187 | { |
| 188 | return $this->plugin_name; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * The reference to the class that orchestrates the hooks with the plugin. |
| 193 | * |
| 194 | * @since 1.0.0 |
| 195 | * @return Catch_Scroll_Progress_Bar_Loader Orchestrates the hooks of the plugin. |
| 196 | */ |
| 197 | public function get_loader() |
| 198 | { |
| 199 | return $this->loader; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Retrieve the version number of the plugin. |
| 204 | * |
| 205 | * @since 1.0.0 |
| 206 | * @return string The version number of the plugin. |
| 207 | */ |
| 208 | public function get_version() |
| 209 | { |
| 210 | return $this->version; |
| 211 | } |
| 212 | } |
| 213 |