images
6 years ago
class-firebase-authentication-activator.php
6 years ago
class-firebase-authentication-deactivator.php
6 years ago
class-firebase-authentication-i18n.php
6 years ago
class-firebase-authentication-loader.php
6 years ago
class-firebase-authentication.php
6 years ago
index.php
6 years ago
class-firebase-authentication.php
232 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * The file that defines the core plugin class |
| 5 | * |
| 6 | * A class definition that includes attributes and functions used across both the |
| 7 | * public-facing side of the site and the admin area. |
| 8 | * |
| 9 | * @link https://miniorange.com |
| 10 | * @since 1.0.0 |
| 11 | * |
| 12 | * @package Firebase_Authentication |
| 13 | * @subpackage Firebase_Authentication/includes |
| 14 | */ |
| 15 | |
| 16 | /** |
| 17 | * The core plugin class. |
| 18 | * |
| 19 | * This is used to define internationalization, admin-specific hooks, and |
| 20 | * public-facing site hooks. |
| 21 | * |
| 22 | * Also maintains the unique identifier of this plugin as well as the current |
| 23 | * version of the plugin. |
| 24 | * |
| 25 | * @since 1.0.0 |
| 26 | * @package Firebase_Authentication |
| 27 | * @subpackage Firebase_Authentication/includes |
| 28 | * @author miniOrange <info@miniorange.com> |
| 29 | */ |
| 30 | class MO_Firebase_Authentication { |
| 31 | |
| 32 | /** |
| 33 | * The loader that's responsible for maintaining and registering all hooks that power |
| 34 | * the plugin. |
| 35 | * |
| 36 | * @since 1.0.0 |
| 37 | * @access protected |
| 38 | * @var MO_Firebase_Authentication_Loader $loader Maintains and registers all hooks for the plugin. |
| 39 | */ |
| 40 | protected $loader; |
| 41 | |
| 42 | /** |
| 43 | * The unique identifier of this plugin. |
| 44 | * |
| 45 | * @since 1.0.0 |
| 46 | * @access protected |
| 47 | * @var string $plugin_name The string used to uniquely identify this plugin. |
| 48 | */ |
| 49 | protected $plugin_name; |
| 50 | |
| 51 | /** |
| 52 | * The current version of the plugin. |
| 53 | * |
| 54 | * @since 1.0.0 |
| 55 | * @access protected |
| 56 | * @var string $version The current version of the plugin. |
| 57 | */ |
| 58 | protected $version; |
| 59 | |
| 60 | /** |
| 61 | * Define the core functionality of the plugin. |
| 62 | * |
| 63 | * Set the plugin name and the plugin version that can be used throughout the plugin. |
| 64 | * Load the dependencies, define the locale, and set the hooks for the admin area and |
| 65 | * the public-facing side of the site. |
| 66 | * |
| 67 | * @since 1.0.0 |
| 68 | */ |
| 69 | public function __construct() { |
| 70 | if ( defined( 'MO_FIREBASE_AUTHENTICATION_VERSION' ) ) { |
| 71 | $this->version = MO_FIREBASE_AUTHENTICATION_VERSION; |
| 72 | } else { |
| 73 | $this->version = '1.0.0'; |
| 74 | } |
| 75 | update_option( "mo_firebase_authentication_current_plugin_version ", $this->version ); |
| 76 | $this->plugin_name = 'firebase-authentication'; |
| 77 | |
| 78 | $this->load_dependencies(); |
| 79 | $this->set_locale(); |
| 80 | $this->define_admin_hooks(); |
| 81 | //$this->define_public_hooks(); |
| 82 | |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Load the required dependencies for this plugin. |
| 87 | * |
| 88 | * Include the following files that make up the plugin: |
| 89 | * |
| 90 | * - MO_Firebase_Authentication_Loader. Orchestrates the hooks of the plugin. |
| 91 | * - MO_Firebase_Authentication_i18n. Defines internationalization functionality. |
| 92 | * - MO_Firebase_Authentication_Admin. Defines all hooks for the admin area. |
| 93 | * - MO_Firebase_Authentication_Public. Defines all hooks for the public side of the site. |
| 94 | * |
| 95 | * Create an instance of the loader which will be used to register the hooks |
| 96 | * with WordPress. |
| 97 | * |
| 98 | * @since 1.0.0 |
| 99 | * @access private |
| 100 | */ |
| 101 | private function load_dependencies() { |
| 102 | |
| 103 | /** |
| 104 | * The class responsible for orchestrating the actions and filters of the |
| 105 | * core plugin. |
| 106 | */ |
| 107 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-firebase-authentication-loader.php'; |
| 108 | |
| 109 | /** |
| 110 | * The class responsible for defining internationalization functionality |
| 111 | * of the plugin. |
| 112 | */ |
| 113 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-firebase-authentication-i18n.php'; |
| 114 | |
| 115 | /** |
| 116 | * The class responsible for defining all actions that occur in the admin area. |
| 117 | */ |
| 118 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-firebase-authentication-admin.php'; |
| 119 | |
| 120 | /** |
| 121 | * The class responsible for defining all actions that occur in the public-facing |
| 122 | * side of the site. |
| 123 | */ |
| 124 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-firebase-authentication-public.php'; |
| 125 | |
| 126 | $this->loader = new MO_Firebase_Authentication_Loader(); |
| 127 | |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Define the locale for this plugin for internationalization. |
| 132 | * |
| 133 | * Uses the MO_Firebase_Authentication_i18n class in order to set the domain and to register the hook |
| 134 | * with WordPress. |
| 135 | * |
| 136 | * @since 1.0.0 |
| 137 | * @access private |
| 138 | */ |
| 139 | private function set_locale() { |
| 140 | |
| 141 | $plugin_i18n = new MO_Firebase_Authentication_i18n(); |
| 142 | |
| 143 | $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); |
| 144 | |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Register all of the hooks related to the admin area functionality |
| 149 | * of the plugin. |
| 150 | * |
| 151 | * @since 1.0.0 |
| 152 | * @access private |
| 153 | */ |
| 154 | private function define_admin_hooks() { |
| 155 | |
| 156 | $plugin_admin = new MO_Firebase_Authentication_Admin( $this->get_plugin_name(), $this->get_version() ); |
| 157 | add_action( 'admin_menu', array( $this, 'miniorange_firebase_menu' ) ); |
| 158 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); |
| 159 | $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); |
| 160 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_admin, 'enqueue_firebase_scripts' ); |
| 161 | $this->loader->add_action( 'login_footer', $plugin_admin, 'enqueue_firebase_wp_login_scripts' ); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * Register all of the hooks related to the public-facing functionality |
| 167 | * of the plugin. |
| 168 | * |
| 169 | * @since 1.0.0 |
| 170 | * @access private |
| 171 | */ |
| 172 | /*private function define_public_hooks() { |
| 173 | |
| 174 | $plugin_public = new MO_Firebase_Authentication_Public( $this->get_plugin_name(), $this->get_version() ); |
| 175 | |
| 176 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); |
| 177 | $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' ); |
| 178 | |
| 179 | }*/ |
| 180 | |
| 181 | function miniorange_firebase_menu() { |
| 182 | //Add miniOrange plugin to the menu |
| 183 | $page = add_menu_page("Configuration", "Firebase Authentication","manage_options", "mo_firebase_authentication",array($this, 'mo_firebase_auth_options') ,plugin_dir_url(__FILE__) . '../public/images/miniorange.png' ); |
| 184 | } |
| 185 | |
| 186 | function mo_firebase_auth_options() { |
| 187 | $plugin_admin = new MO_Firebase_Authentication_Admin( $this->get_plugin_name(), $this->get_version() ); |
| 188 | $plugin_admin->mo_firebase_auth_page(); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Run the loader to execute all of the hooks with WordPress. |
| 193 | * |
| 194 | * @since 1.0.0 |
| 195 | */ |
| 196 | public function run() { |
| 197 | $this->loader->run(); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * The name of the plugin used to uniquely identify it within the context of |
| 202 | * WordPress and to define internationalization functionality. |
| 203 | * |
| 204 | * @since 1.0.0 |
| 205 | * @return string The name of the plugin. |
| 206 | */ |
| 207 | public function get_plugin_name() { |
| 208 | return $this->plugin_name; |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * The reference to the class that orchestrates the hooks with the plugin. |
| 213 | * |
| 214 | * @since 1.0.0 |
| 215 | * @return MO_Firebase_Authentication_Loader Orchestrates the hooks of the plugin. |
| 216 | */ |
| 217 | public function get_loader() { |
| 218 | return $this->loader; |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Retrieve the version number of the plugin. |
| 223 | * |
| 224 | * @since 1.0.0 |
| 225 | * @return string The version number of the plugin. |
| 226 | */ |
| 227 | public function get_version() { |
| 228 | return $this->version; |
| 229 | } |
| 230 | |
| 231 | } |
| 232 |