@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | public function required_arguments() |
| 23 | 23 | { |
| 24 | - return array('name','data'); |
|
| 24 | + return array('name', 'data'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function get_template_path() |
@@ -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'; |
| 13 | 13 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * @param array $props |
| 21 | 21 | * @return AbstractComponent |
| 22 | 22 | */ |
| 23 | - public static function create( $type, array $props ) |
|
| 23 | + public static function create($type, array $props) |
|
| 24 | 24 | { |
| 25 | 25 | try { |
| 26 | 26 | $component = self::create_registered_component($type, $props); |
@@ -41,9 +41,9 @@ discard block |
||
| 41 | 41 | * @param string $class_name |
| 42 | 42 | * @throws \RuntimeException |
| 43 | 43 | */ |
| 44 | - public static function register( $type, $class_name ) |
|
| 44 | + public static function register($type, $class_name) |
|
| 45 | 45 | { |
| 46 | - if( !in_array($type, self::$registered_components) ) |
|
| 46 | + if (!in_array($type, self::$registered_components)) |
|
| 47 | 47 | { |
| 48 | 48 | self::$registered_components[$type] = $class_name; |
| 49 | 49 | } |
@@ -56,15 +56,15 @@ discard block |
||
| 56 | 56 | * @param type $props |
| 57 | 57 | * @throws \RuntimeException |
| 58 | 58 | */ |
| 59 | - private static function create_core_component( $type, $props ) |
|
| 59 | + private static function create_core_component($type, $props) |
|
| 60 | 60 | { |
| 61 | 61 | $file_name = __DIR__."/components/$type/controller.php"; |
| 62 | 62 | $class_name = 'Amarkal\\UI\\Component_'.$type; |
| 63 | 63 | |
| 64 | 64 | // Load one of the core components |
| 65 | - if(!class_exists($class_name)) |
|
| 65 | + if (!class_exists($class_name)) |
|
| 66 | 66 | { |
| 67 | - if( file_exists( $file_name ) ) |
|
| 67 | + if (file_exists($file_name)) |
|
| 68 | 68 | { |
| 69 | 69 | require_once $file_name; |
| 70 | 70 | } |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | * @param type $props |
| 84 | 84 | * @throws \RuntimeException |
| 85 | 85 | */ |
| 86 | - private static function create_registered_component( $type, $props ) |
|
| 86 | + private static function create_registered_component($type, $props) |
|
| 87 | 87 | { |
| 88 | - if(in_array($type, self::$registered_components)) |
|
| 88 | + if (in_array($type, self::$registered_components)) |
|
| 89 | 89 | { |
| 90 | 90 | $class_name = self::$registered_components[$type]; |
| 91 | 91 | return new $class_name($props); |
@@ -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 'AbstractComponent.php'; |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | 'required' => false, |
| 28 | 28 | 'readonly' => false, |
| 29 | 29 | 'default' => null, |
| 30 | - 'filter' => array( $this, 'filter' ), |
|
| 31 | - 'validation' => array( $this, 'validation' ) |
|
| 30 | + 'filter' => array($this, 'filter'), |
|
| 31 | + 'validation' => array($this, 'validation') |
|
| 32 | 32 | ); |
| 33 | 33 | } |
| 34 | 34 | |
@@ -37,19 +37,19 @@ discard block |
||
| 37 | 37 | return floatval($v); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - public function validation($v,&$e) |
|
| 40 | + public function validation($v, &$e) |
|
| 41 | 41 | { |
| 42 | 42 | $max = $this->max; |
| 43 | 43 | $min = $this->min; |
| 44 | 44 | |
| 45 | - if(null !== $max && $v > $max) |
|
| 45 | + if (null !== $max && $v > $max) |
|
| 46 | 46 | { |
| 47 | - $e = sprintf( __("Value must be less than %d",'amarkal'), $max); |
|
| 47 | + $e = sprintf(__("Value must be less than %d", 'amarkal'), $max); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(null !== $min && $v < $min) |
|
| 50 | + if (null !== $min && $v < $min) |
|
| 51 | 51 | { |
| 52 | - $e = sprintf( __("Value must be greater than %d",'amarkal'), $min); |
|
| 52 | + $e = sprintf(__("Value must be greater than %d", 'amarkal'), $min); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $e ? false : true; |
@@ -25,13 +25,13 @@ |
||
| 25 | 25 | 'min' => null, |
| 26 | 26 | 'max' => null, |
| 27 | 27 | 'step' => 1, |
| 28 | - 'filter' => array( $this, 'filter' ) |
|
| 28 | + 'filter' => array($this, 'filter') |
|
| 29 | 29 | ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function required_arguments() |
| 33 | 33 | { |
| 34 | - return array('name','min','max'); |
|
| 34 | + return array('name', 'min', 'max'); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function get_template_path() |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | public function required_arguments() |
| 31 | 31 | { |
| 32 | - return array('request_url','label_start'); |
|
| 32 | + return array('request_url', 'label_start'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function get_template_path() |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | 'disabled' => false, |
| 22 | 22 | 'readonly' => false, |
| 23 | 23 | 'default' => null, |
| 24 | - 'filter' => array( $this, 'filter' ) |
|
| 24 | + 'filter' => array($this, 'filter') |
|
| 25 | 25 | ); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public function filter($v) |
| 48 | 48 | { |
| 49 | - if($v !== 'on') return 'off'; |
|
| 49 | + if ($v !== 'on') return 'off'; |
|
| 50 | 50 | return 'on'; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | \ No newline at end of file |
@@ -12,15 +12,15 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | // Prevent direct file access |
| 15 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
| 15 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Prevent loading the library more than once |
| 19 | 19 | */ |
| 20 | -if( defined( 'AMARKAL_UI' ) ) return false; |
|
| 21 | -define( 'AMARKAL_UI', true ); |
|
| 20 | +if (defined('AMARKAL_UI')) return false; |
|
| 21 | +define('AMARKAL_UI', true); |
|
| 22 | 22 | |
| 23 | -if(!function_exists('amarkal_ui_render')) |
|
| 23 | +if (!function_exists('amarkal_ui_render')) |
|
| 24 | 24 | { |
| 25 | 25 | /** |
| 26 | 26 | * Render a UI component. |
@@ -30,14 +30,14 @@ discard block |
||
| 30 | 30 | * @param array $props The component's properties |
| 31 | 31 | * @return string The rendered HTML |
| 32 | 32 | */ |
| 33 | - function amarkal_ui_render( $type, array $props = array() ) |
|
| 33 | + function amarkal_ui_render($type, array $props = array()) |
|
| 34 | 34 | { |
| 35 | - $component = Amarkal\UI\ComponentFactory::create( $type, $props ); |
|
| 35 | + $component = Amarkal\UI\ComponentFactory::create($type, $props); |
|
| 36 | 36 | return $component->render(); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | -if(!function_exists('amarkal_ui_register_component')) |
|
| 40 | +if (!function_exists('amarkal_ui_register_component')) |
|
| 41 | 41 | { |
| 42 | 42 | /** |
| 43 | 43 | * Register a custom UI component. The registered component's class should |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | * to one of the core component's type, it will override the core component. |
| 48 | 48 | * @param string $class_name The component's class name. |
| 49 | 49 | */ |
| 50 | - function amarkal_ui_register_component( $type, $class_name ) |
|
| 50 | + function amarkal_ui_register_component($type, $class_name) |
|
| 51 | 51 | { |
| 52 | - Amarkal\UI\ComponentFactory::register( $type, $class_name ); |
|
| 52 | + Amarkal\UI\ComponentFactory::register($type, $class_name); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -if(!function_exists('amarkal_ui_register_scripts')) |
|
| 56 | +if (!function_exists('amarkal_ui_register_scripts')) |
|
| 57 | 57 | { |
| 58 | 58 | /** |
| 59 | 59 | * Register Amarkal UI styles & scripts. These scripts are later enqueued by |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | function amarkal_ui_register_scripts() |
| 63 | 63 | { |
| 64 | - \wp_register_script('amarkal-ui',Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/js/dist/amarkal-ui.min.js'),array('jquery'),false,true); |
|
| 65 | - \wp_register_script('ace-editor','https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.8/ace.js',array('jquery'),false,true); |
|
| 66 | - \wp_register_style('amarkal-ui',Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-ui.min.css'),array()); |
|
| 64 | + \wp_register_script('amarkal-ui', Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/js/dist/amarkal-ui.min.js'), array('jquery'), false, true); |
|
| 65 | + \wp_register_script('ace-editor', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.8/ace.js', array('jquery'), false, true); |
|
| 66 | + \wp_register_style('amarkal-ui', Amarkal\Core\Utility::path_to_url(__DIR__.'/assets/css/dist/amarkal-ui.min.css'), array()); |
|
| 67 | 67 | } |
| 68 | - \add_action('admin_init','amarkal_ui_register_scripts'); |
|
| 68 | + \add_action('admin_init', 'amarkal_ui_register_scripts'); |
|
| 69 | 69 | } |
| 70 | 70 | \ No newline at end of file |