@@ -67,6 +67,9 @@ |
||
67 | 67 | \add_action('admin_init',array($this,'register_scripts')); |
68 | 68 | } |
69 | 69 | |
70 | + /** |
|
71 | + * @param string $path |
|
72 | + */ |
|
70 | 73 | private function get_url( $path ) |
71 | 74 | { |
72 | 75 | $url = str_replace( ABSPATH, '', $path ); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public static function get_instance() |
22 | 22 | { |
23 | - if( null === static::$instance ) |
|
23 | + if (null === static::$instance) |
|
24 | 24 | { |
25 | 25 | static::$instance = new static(); |
26 | 26 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | public function add_page($args) |
31 | 31 | { |
32 | 32 | $slug = $args['slug']; |
33 | - if(array_key_exists($slug,$this->pages)) |
|
33 | + if (array_key_exists($slug, $this->pages)) |
|
34 | 34 | { |
35 | 35 | throw new \RuntimeException("A page with slug '$slug' has already been registered"); |
36 | 36 | } |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | |
45 | 45 | public function register_settings() |
46 | 46 | { |
47 | - register_setting( 'myoption-group', 'new_option_name' ); |
|
48 | - register_setting( 'myoption-group', 'some_other_option' ); |
|
49 | - register_setting( 'myoption-group', 'option_etc' ); |
|
47 | + register_setting('myoption-group', 'new_option_name'); |
|
48 | + register_setting('myoption-group', 'some_other_option'); |
|
49 | + register_setting('myoption-group', 'option_etc'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | */ |
55 | 55 | public function register_scripts() |
56 | 56 | { |
57 | - \wp_register_style('amarkal-settings',$this->get_url(__DIR__.'/assets/css/style.min.css')); |
|
58 | - \wp_register_script('amarkal-settings',$this->get_url(__DIR__.'/assets/js/script.min.js')); |
|
57 | + \wp_register_style('amarkal-settings', $this->get_url(__DIR__.'/assets/css/style.min.css')); |
|
58 | + \wp_register_script('amarkal-settings', $this->get_url(__DIR__.'/assets/js/script.min.js')); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | |
69 | 69 | private function init() |
70 | 70 | { |
71 | - \add_action('admin_init',array($this,'register_scripts')); |
|
71 | + \add_action('admin_init', array($this, 'register_scripts')); |
|
72 | 72 | } |
73 | 73 | |
74 | - private function get_url( $path ) |
|
74 | + private function get_url($path) |
|
75 | 75 | { |
76 | - $url = str_replace( ABSPATH, '', $path ); |
|
77 | - return esc_url_raw( site_url( $url ) ); |
|
76 | + $url = str_replace(ABSPATH, '', $path); |
|
77 | + return esc_url_raw(site_url($url)); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -6,7 +6,7 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct file access |
9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
10 | 10 | |
11 | 11 | // Load module functions |
12 | 12 | require_once 'functions.php'; |
@@ -6,11 +6,11 @@ |
||
6 | 6 | { |
7 | 7 | private $config; |
8 | 8 | |
9 | - public function __construct( array $args = array() ) |
|
9 | + public function __construct(array $args = array()) |
|
10 | 10 | { |
11 | 11 | $this->config = array_merge($this->default_args(), $args); |
12 | 12 | |
13 | - \add_action('admin_menu', array($this,'add_menu_page')); |
|
13 | + \add_action('admin_menu', array($this, 'add_menu_page')); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public function add_menu_page() |
@@ -6,13 +6,13 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct file access |
9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Load module functions. If this amarkal module has not been loaded, |
13 | 13 | * functions.php will not return false. |
14 | 14 | */ |
15 | -if(false !== (require_once 'functions.php')) |
|
15 | +if (false !== (require_once 'functions.php')) |
|
16 | 16 | { |
17 | 17 | // Load required classes if not using composer |
18 | 18 | require_once 'Manager.php'; |
@@ -13,26 +13,26 @@ |
||
13 | 13 | */ |
14 | 14 | |
15 | 15 | // Prevent direct file access |
16 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
16 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Prevent loading the library more than once |
20 | 20 | */ |
21 | -if( defined( 'AMARKAL_SETTINGS' ) ) return false; |
|
22 | -define( 'AMARKAL_SETTINGS', true ); |
|
21 | +if (defined('AMARKAL_SETTINGS')) return false; |
|
22 | +define('AMARKAL_SETTINGS', true); |
|
23 | 23 | |
24 | -if(!function_exists('amarkal_add_settings_page')) |
|
24 | +if (!function_exists('amarkal_add_settings_page')) |
|
25 | 25 | { |
26 | - function amarkal_add_settings_page( $args ) |
|
26 | + function amarkal_add_settings_page($args) |
|
27 | 27 | { |
28 | 28 | $manager = Amarkal\Settings\Manager::get_instance(); |
29 | 29 | $manager->add_page($args); |
30 | 30 | } |
31 | 31 | } |
32 | 32 | |
33 | -if(!function_exists('amarkal_add_settings_subpage')) |
|
33 | +if (!function_exists('amarkal_add_settings_subpage')) |
|
34 | 34 | { |
35 | - function amarkal_add_settings_subpage( $args ) |
|
35 | + function amarkal_add_settings_subpage($args) |
|
36 | 36 | { |
37 | 37 | $manager = Amarkal\Settings\Manager::get_instance(); |
38 | 38 | $manager->add_subpage($args); |
@@ -18,7 +18,9 @@ |
||
18 | 18 | /** |
19 | 19 | * Prevent loading the library more than once |
20 | 20 | */ |
21 | -if( defined( 'AMARKAL_SETTINGS' ) ) return false; |
|
21 | +if( defined( 'AMARKAL_SETTINGS' ) ) { |
|
22 | + return false; |
|
23 | +} |
|
22 | 24 | define( 'AMARKAL_SETTINGS', true ); |
23 | 25 | |
24 | 26 | if(!function_exists('amarkal_add_settings_page')) |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | |
9 | 9 | private $form; |
10 | 10 | |
11 | - public function __construct( array $args = array() ) |
|
11 | + public function __construct(array $args = array()) |
|
12 | 12 | { |
13 | 13 | $this->config = array_merge($this->default_args(), $args); |
14 | 14 | $this->form = new \Amarkal\UI\Form($this->config['fields']); |
15 | 15 | |
16 | - \add_action('admin_menu', array($this,'add_submenu_page')); |
|
17 | - \add_action('admin_enqueue_scripts', array($this,'enqueue_scripts')); |
|
16 | + \add_action('admin_menu', array($this, 'add_submenu_page')); |
|
17 | + \add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function add_submenu_page() |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function enqueue_scripts() |
33 | 33 | { |
34 | 34 | // Only enqueue styles & scripts if this is a settings page |
35 | - if($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
35 | + if ($this->config['slug'] === filter_input(INPUT_GET, 'page')) |
|
36 | 36 | { |
37 | 37 | \wp_enqueue_style('amarkal-settings'); |
38 | 38 | \wp_enqueue_script('amarkal-settings'); |