From 08dea6f747202995e344000dcc79d32d2fd6e6ee Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Fri, 18 Oct 2019 11:37:12 -0400 Subject: [PATCH] moving the glm-theme-options to the root, reforming the defines class with built-in constants --- admin/enqueue.php | 8 ++- admin/glm-theme-options-init.php | 58 ++++++++++++++++++++++ admin/glm-theme-options.php | 85 -------------------------------- admin/includes/glma-addons.php | 16 +++++- admin/menus.php | 6 +-- admin/utility.php | 6 ++- functions.php | 4 +- includes/defines.php | 9 ++-- includes/glm-theme-options.php | 44 +++++++++++++++++ package-lock.json | 38 ++++++++++++++ 10 files changed, 169 insertions(+), 105 deletions(-) create mode 100644 admin/glm-theme-options-init.php delete mode 100644 admin/glm-theme-options.php create mode 100644 includes/glm-theme-options.php diff --git a/admin/enqueue.php b/admin/enqueue.php index 8074fa8..7e7df25 100644 --- a/admin/enqueue.php +++ b/admin/enqueue.php @@ -1,16 +1,14 @@ glma_addons = new Addons\GlmaAddons(); + $this->glm_theme_options = new Options\GlmThemeOptions(); + } + + public function get_instance(){ + if (self::$instance === null){ + self::$instance = new GlmThemeOptionsInit(); + }else{ + throw new exception('Class Already Instantiated'); + } + return self::$instance; + } + + + public function init(){ + require_once 'enqueue.php'; + require_once 'menus.php'; + $this->glm_theme_options->glm_init_theme_options(); + $this->glm_theme_options->glm_create_ajax_actions(); + // $this->glma_addons->glm_load_addons(); + } + } +} +$glmThemeOptionsInit = (new GlmThemeOptionsInit)->get_instance(); +$glmThemeOptionsInit->init(); \ No newline at end of file diff --git a/admin/glm-theme-options.php b/admin/glm-theme-options.php deleted file mode 100644 index 37c1d63..0000000 --- a/admin/glm-theme-options.php +++ /dev/null @@ -1,85 +0,0 @@ -utility = new GlmThemeUtility(); - $this->defines = new Glm\GlmThemeOptions\Defines\Defines(); - $this->glma_addons = new Glm\GlmThemeOptions\GlmaAddons\GlmaAddons(); - $this->glm_theme_options = $this->defines::$glm_theme_options; - } - - public function get_instance(){ - if (self::$instance === null){ - self::$instance = new GlmThemOptions(); - }else{ - throw new exception('Class Already Instantiated'); - } - return self::$instance; - } - private function glm_init_theme_options(){ - if( !get_option( $this->glm_theme_options ) ){ - update_option( $this->glm_theme_options, json_encode("{}") ); - } - } - public function glm_update_theme_options() { - $data = $_REQUEST['theme_options']; - if( get_option( $this->glm_theme_options ) ){ - $this->utility::log($data); - update_option( $this->glm_theme_options , $data ); - } - // $this->utility::log( get_option($this->glm_theme_options )); - } - public function glm_get_theme_options() { - - if( get_option( $this->glm_theme_options ) ){ - $data = get_option( $this->glm_theme_options ); - echo stripslashes($data); - } - wp_die(); - // $this->utility::log( get_option($this->glm_theme_options )); - } - private function glm_create_ajax_actions(){ - - add_action( 'wp_ajax_glm_update_theme_options', array($this,'glm_update_theme_options') ); - add_action( 'wp_ajax_glm_get_theme_options', array($this,'glm_get_theme_options') ); - // add_action( 'wp_ajax_nopriv_glm_theme_options', 'glm_update_theme_options' ); - } - public function init(){ - require_once 'enqueue.php'; - require_once 'menus.php'; - $this->glm_init_theme_options(); - $this->glm_create_ajax_actions(); - $this->glma_addons->glm_load_addons(); - } - } -} -$glmThemeOptions = (new GlmThemOptions)->get_instance(); -$glmThemeOptions->init(); \ No newline at end of file diff --git a/admin/includes/glma-addons.php b/admin/includes/glma-addons.php index 800ce85..53077bb 100644 --- a/admin/includes/glma-addons.php +++ b/admin/includes/glma-addons.php @@ -1,19 +1,31 @@ glm_addons_installed() ){ $this->glma_addons = apply_filters("glm_list_addons",''); + foreach($this->glma_addons as $addon=>$data){ + Utility\GlmThemeUtility::log($addon); + } } } diff --git a/admin/menus.php b/admin/menus.php index 3b72798..405cd46 100644 --- a/admin/menus.php +++ b/admin/menus.php @@ -2,18 +2,16 @@ /** * Register the main options menu */ -use Glm\GlmThemeOptions\Defines; +use Glm\GlmThemeOptions\Defines as Defines; function register_glm_options_menu() { - $defines = new Glm\GlmThemeOptions\Defines\Defines(); - $plugin_url = $defines::$glm_options_url; add_menu_page( __( 'GLM Theme Options', 'textdomain' ), 'GLM Theme', 'manage_options', 'glm-theme-options', 'glm_theme_options_view', - $plugin_url.'/assets/logo.png', + Defines\Defines::GLM_THEME_OPTIONS_URI.'/assets/logo.png', 6 ); } diff --git a/admin/utility.php b/admin/utility.php index 073fdc8..139837e 100644 --- a/admin/utility.php +++ b/admin/utility.php @@ -1,8 +1,10 @@