Source of file class-overlord.php
Size: 5,293 Bytes - Last Modified: 2016-01-06T20:25:05-05:00
../src/lib/class-overlord.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
Covered by 1 test(s):
47
Covered by 1 test(s):
48
Covered by 1 test(s):
4950515253545556
Covered by 5 test(s):
57
Covered by 1 test(s):
58
Covered by 1 test(s):
59
Covered by 5 test(s):
606162636465666768
Covered by 3 test(s):
6970717273747576777879
Covered by 1 test(s):
80
Covered by 1 test(s):
818283848586878889
Covered by 1 test(s):
90
Covered by 1 test(s):
9192
Covered by 1 test(s):
93
Covered by 1 test(s):
94
Covered by 1 test(s):
95
Covered by 1 test(s):
96
Covered by 1 test(s):
9798
Covered by 1 test(s):
99100101102103104105106107108
Covered by 1 test(s):
109110
Covered by 1 test(s):
111112113114115116117118119
Covered by 1 test(s):
120
Covered by 1 test(s):
121
Covered by 1 test(s):
122
Covered by 1 test(s):
123
Covered by 1 test(s):
124125
Covered by 1 test(s):
126127128129130131132133134
Covered by 1 test(s):
135
Covered by 1 test(s):
136137
Covered by 1 test(s):
138139
Covered by 1 test(s):
140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
| <?php /** * Overlord Class * * @category PHP * @package WpWodify * @subpackage Overlord * @since File available since release 1.0.x * @author Cory Collier <corycollier@corycollier.com> */ namespace WpWodify; /** * Overlord Class. * * This class serves to oversee all aspects of the implementation. This is the * glue for all of the classes. * * @category PHP * @package WpWodify * @subpackage Overlord * @since Class available since release 1.0.x * @author Cory Collier <corycollier@corycollier.com> */ class Overlord { /** * Singleton property instance. * * @var WpWodify\Overlord */ protected static $instance; /** * Instance of the loader. * * @var WpWodify\Loader */ protected $loader; /** * Privatizing the constructor, to enforce the singleton pattern */ private function __construct() { $loader = new Loader; $this->set_loader($loader); } /** * Gets the singleton instance of self. * * @return WpWodify\Overloard Returns self::$instance */ public static function get_instance() { if (! self::$instance) { self::$instance = new self; } return self::$instance; } /** * Getter for the loader instance. * * @return WpWodify\Loader The loader instance. */ public function get_loader() { return $this->loader; } /** * Setter for the loader instance. * * @param WpWodify\Loader $loader The loader instance * * @return WpWodify\Overlord Returns $this, for object-chaining. */ public function set_loader( $loader ) { $this->loader = $loader; return $this; } /** * Defines which class/callbacks are used for admin hook implementations. * * @return WpWodify\Overlord Returns $this, for object-chaining. */ public function define_admin_hooks() { $is_admin = \is_admin(); $loader = $this->get_loader(); if ( true == $is_admin ) { $loader->add_action( 'admin_init', $this, 'register_settings' ); $loader->add_action( 'admin_menu', $this, 'define_admin_menu_hooks' ); $loader->add_action( 'admin_enqueue_scripts', $this, 'admin_enqueue_scripts' ); } return $this; } /** * Defines which class/callbacks are used for public hook implementations. * * @return WpWodify\Overlord Returns $this, for object-chaining. */ public function define_public_hooks() { $loader = $this->get_loader(); return $this; } /** * Registers all of the needed settings for the plugin. * * @return WpWodify\Overlord Returns $this, for object-chaining. */ public function register_settings() { \register_setting( 'wp-wodify-settings-group', 'wp-wodify-api-key' ); \register_setting( 'wp-wodify-settings-cache', '_wp_wodify_api_cache_classes' ); \register_setting( 'wp-wodify-settings-cache', '_wp_wodify_api_cache_coaches' ); \register_setting( 'wp-wodify-settings-cache', '_wp_wodify_api_cache_locations' ); \register_setting( 'wp-wodify-settings-cache', '_wp_wodify_api_cache_programs' ); return $this; } /** * Main entry point. * * @return WpWodify\Overlord Return $this, for object-chaining. */ public function run() { $this->define_admin_hooks(); $this->define_public_hooks(); $this->get_loader()->run(); return $this; } /** * Defines menu entries for the admin section */ public function define_admin_menu_hooks() { $pages = new Pages; $pages->set_template( new Template ); \add_options_page( 'WP Wodify Options', 'WP Wodify', 'manage_options', 'wp-wodify-administer', array($pages, 'admin_settings') ); // function add_settings_field($id, $title, $callback, $page, $section = 'default', $args = array()) { // $types = array('coaches', 'classes', 'locations', 'programs'); // foreach ($types as $type) { // add_action( 'admin_post_wp_wodify_' . $type . '_sync', 'wp_wodify_get_api_' . $type ); // } } /** * Loads admin scripts * @return bool Returns true */ public function admin_enqueue_scripts() { $plugin_url = plugin_dir_url( __FILE__ ) . '../'; wp_enqueue_script( 'wp_wodify_admin', $plugin_url . '/js/admin.js' ); return true; } } // INIT CODE // add_settings_section( 'section-one' // , 'Section One' // , 'wp_wodify_admin_section_callback' // , 'wp-wodify-administer' // ); // add_settings_field( 'wp-wodify-api-key' // , 'Api Key' // , 'wp_wodify_admin_api_key_field_callback' // , 'wp-wodify-administer' // , 'section-one' // ); // $types = array('coaches', 'classes', 'locations', 'programs'); // foreach ($types as $type) { // add_action( 'admin_post_wp_wodify_' . $type . '_sync', 'wp_wodify_get_api_' . $type ); // } // add_action( 'admin_enqueue_scripts', 'wp_wodify_admin_scripts' ); // } // |