@@ -7,23 +7,23 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | 13 | |
14 | -if ( ! empty( $required ) ) { |
|
14 | +if (!empty($required)) { |
|
15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
16 | 16 | } |
17 | 17 | |
18 | 18 | echo aui()->input( |
19 | 19 | array( |
20 | - 'name' => esc_attr( $id ), |
|
21 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
22 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
23 | - 'required' => ! empty( $required ), |
|
20 | + 'name' => esc_attr($id), |
|
21 | + 'id' => esc_attr($id) . uniqid('_'), |
|
22 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
23 | + 'required' => !empty($required), |
|
24 | 24 | 'label' => $label, |
25 | 25 | 'label_type' => 'vertical', |
26 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
26 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
27 | 27 | 'type' => 'email', |
28 | 28 | ) |
29 | 29 | ); |
@@ -7,23 +7,23 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | 13 | |
14 | -if ( ! empty( $required ) ) { |
|
14 | +if (!empty($required)) { |
|
15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
16 | 16 | } |
17 | 17 | |
18 | 18 | echo aui()->input( |
19 | 19 | array( |
20 | - 'name' => esc_attr( $id ), |
|
21 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
22 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
23 | - 'required' => ! empty( $required ), |
|
20 | + 'name' => esc_attr($id), |
|
21 | + 'id' => esc_attr($id) . uniqid('_'), |
|
22 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
23 | + 'required' => !empty($required), |
|
24 | 24 | 'label' => $label, |
25 | 25 | 'label_type' => 'vertical', |
26 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
26 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
27 | 27 | 'type' => 'time', |
28 | 28 | ) |
29 | 29 | ); |
@@ -7,22 +7,22 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | 13 | |
14 | -if ( ! empty( $required ) ) { |
|
14 | +if (!empty($required)) { |
|
15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
16 | 16 | } |
17 | 17 | |
18 | 18 | echo aui()->input( |
19 | 19 | array( |
20 | - 'name' => esc_attr( $id ), |
|
21 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
22 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
23 | - 'required' => ! empty( $required ), |
|
20 | + 'name' => esc_attr($id), |
|
21 | + 'id' => esc_attr($id) . uniqid('_'), |
|
22 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
23 | + 'required' => !empty($required), |
|
24 | 24 | 'label' => $label, |
25 | 25 | 'label_type' => 'vertical', |
26 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
26 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
27 | 27 | ) |
28 | 28 | ); |
@@ -7,22 +7,22 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | 13 | |
14 | -if ( ! empty( $required ) ) { |
|
14 | +if (!empty($required)) { |
|
15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
16 | 16 | } |
17 | 17 | |
18 | 18 | echo aui()->textarea( |
19 | 19 | array( |
20 | - 'name' => esc_attr( $id ), |
|
21 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
22 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
23 | - 'required' => ! empty( $required ), |
|
20 | + 'name' => esc_attr($id), |
|
21 | + 'id' => esc_attr($id) . uniqid('_'), |
|
22 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
23 | + 'required' => !empty($required), |
|
24 | 24 | 'label' => $label, |
25 | 25 | 'label_type' => 'vertical', |
26 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
26 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
27 | 27 | ) |
28 | 28 | ); |
@@ -7,22 +7,22 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$label = empty( $label ) ? '' : wp_kses_post( $label ); |
|
12 | +$label = empty($label) ? '' : wp_kses_post($label); |
|
13 | 13 | |
14 | -if ( ! empty( $required ) ) { |
|
14 | +if (!empty($required)) { |
|
15 | 15 | $label .= "<span class='text-danger'> *</span>"; |
16 | 16 | } |
17 | 17 | |
18 | 18 | echo aui()->input( |
19 | 19 | array( |
20 | 20 | 'type' => 'checkbox', |
21 | - 'name' => esc_attr( $id ), |
|
22 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
23 | - 'required' => ! empty( $required ), |
|
21 | + 'name' => esc_attr($id), |
|
22 | + 'id' => esc_attr($id) . uniqid('_'), |
|
23 | + 'required' => !empty($required), |
|
24 | 24 | 'label' => $label, |
25 | - 'value' => esc_attr__( 'Yes', 'invoicing' ), |
|
26 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
25 | + 'value' => esc_attr__('Yes', 'invoicing'), |
|
26 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
27 | 27 | ) |
28 | 28 | ); |
@@ -126,8 +126,12 @@ discard block |
||
126 | 126 | public function constants(){ |
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) { |
|
130 | + define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + if (!defined('AUI_SECONDARY_COLOR')) { |
|
133 | + define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
134 | + } |
|
131 | 135 | } |
132 | 136 | |
133 | 137 | /** |
@@ -822,12 +826,12 @@ discard block |
||
822 | 826 | is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
823 | 827 | $script = $this->inline_script(); |
824 | 828 | wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
825 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
829 | + } elseif($this->settings[$js_setting]=='popper'){ |
|
826 | 830 | $url = $this->url.'assets/js/popper.min.js'; |
827 | 831 | wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
828 | 832 | wp_enqueue_script( 'bootstrap-js-popper' ); |
829 | 833 | $load_inline = true; |
830 | - }else{ |
|
834 | + } else{ |
|
831 | 835 | $load_inline = true; |
832 | 836 | } |
833 | 837 |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
16 | - exit; |
|
16 | + exit; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -21,202 +21,202 @@ discard block |
||
21 | 21 | */ |
22 | 22 | if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
23 | 23 | |
24 | - /** |
|
25 | - * A Class to be able to change settings for Font Awesome. |
|
26 | - * |
|
27 | - * Class AyeCode_UI_Settings |
|
28 | - * @ver 1.0.0 |
|
29 | - * @todo decide how to implement textdomain |
|
30 | - */ |
|
31 | - class AyeCode_UI_Settings { |
|
32 | - |
|
33 | - /** |
|
34 | - * Class version version. |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - public $version = '1.0.1'; |
|
39 | - |
|
40 | - /** |
|
41 | - * Class textdomain. |
|
42 | - * |
|
43 | - * @var string |
|
44 | - */ |
|
45 | - public $textdomain = 'aui'; |
|
46 | - |
|
47 | - /** |
|
48 | - * Latest version of Bootstrap at time of publish published. |
|
49 | - * |
|
50 | - * @var string |
|
51 | - */ |
|
52 | - public $latest = "4.5.3"; |
|
53 | - |
|
54 | - /** |
|
55 | - * Current version of select2 being used. |
|
56 | - * |
|
57 | - * @var string |
|
58 | - */ |
|
59 | - public $select2_version = "4.0.11"; |
|
60 | - |
|
61 | - /** |
|
62 | - * The title. |
|
63 | - * |
|
64 | - * @var string |
|
65 | - */ |
|
66 | - public $name = 'AyeCode UI'; |
|
67 | - |
|
68 | - /** |
|
69 | - * The relative url to the assets. |
|
70 | - * |
|
71 | - * @var string |
|
72 | - */ |
|
73 | - public $url = ''; |
|
74 | - |
|
75 | - /** |
|
76 | - * Holds the settings values. |
|
77 | - * |
|
78 | - * @var array |
|
79 | - */ |
|
80 | - private $settings; |
|
81 | - |
|
82 | - /** |
|
83 | - * AyeCode_UI_Settings instance. |
|
84 | - * |
|
85 | - * @access private |
|
86 | - * @since 1.0.0 |
|
87 | - * @var AyeCode_UI_Settings There can be only one! |
|
88 | - */ |
|
89 | - private static $instance = null; |
|
90 | - |
|
91 | - /** |
|
92 | - * Main AyeCode_UI_Settings Instance. |
|
93 | - * |
|
94 | - * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | - * |
|
96 | - * @since 1.0.0 |
|
97 | - * @static |
|
98 | - * @return AyeCode_UI_Settings - Main instance. |
|
99 | - */ |
|
100 | - public static function instance() { |
|
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | - |
|
103 | - self::$instance = new AyeCode_UI_Settings; |
|
104 | - |
|
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
106 | - |
|
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
110 | - |
|
111 | - // Maybe show example page |
|
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | - } |
|
24 | + /** |
|
25 | + * A Class to be able to change settings for Font Awesome. |
|
26 | + * |
|
27 | + * Class AyeCode_UI_Settings |
|
28 | + * @ver 1.0.0 |
|
29 | + * @todo decide how to implement textdomain |
|
30 | + */ |
|
31 | + class AyeCode_UI_Settings { |
|
32 | + |
|
33 | + /** |
|
34 | + * Class version version. |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + public $version = '1.0.1'; |
|
39 | + |
|
40 | + /** |
|
41 | + * Class textdomain. |
|
42 | + * |
|
43 | + * @var string |
|
44 | + */ |
|
45 | + public $textdomain = 'aui'; |
|
46 | + |
|
47 | + /** |
|
48 | + * Latest version of Bootstrap at time of publish published. |
|
49 | + * |
|
50 | + * @var string |
|
51 | + */ |
|
52 | + public $latest = "4.5.3"; |
|
53 | + |
|
54 | + /** |
|
55 | + * Current version of select2 being used. |
|
56 | + * |
|
57 | + * @var string |
|
58 | + */ |
|
59 | + public $select2_version = "4.0.11"; |
|
60 | + |
|
61 | + /** |
|
62 | + * The title. |
|
63 | + * |
|
64 | + * @var string |
|
65 | + */ |
|
66 | + public $name = 'AyeCode UI'; |
|
67 | + |
|
68 | + /** |
|
69 | + * The relative url to the assets. |
|
70 | + * |
|
71 | + * @var string |
|
72 | + */ |
|
73 | + public $url = ''; |
|
74 | + |
|
75 | + /** |
|
76 | + * Holds the settings values. |
|
77 | + * |
|
78 | + * @var array |
|
79 | + */ |
|
80 | + private $settings; |
|
81 | + |
|
82 | + /** |
|
83 | + * AyeCode_UI_Settings instance. |
|
84 | + * |
|
85 | + * @access private |
|
86 | + * @since 1.0.0 |
|
87 | + * @var AyeCode_UI_Settings There can be only one! |
|
88 | + */ |
|
89 | + private static $instance = null; |
|
90 | + |
|
91 | + /** |
|
92 | + * Main AyeCode_UI_Settings Instance. |
|
93 | + * |
|
94 | + * Ensures only one instance of AyeCode_UI_Settings is loaded or can be loaded. |
|
95 | + * |
|
96 | + * @since 1.0.0 |
|
97 | + * @static |
|
98 | + * @return AyeCode_UI_Settings - Main instance. |
|
99 | + */ |
|
100 | + public static function instance() { |
|
101 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
102 | + |
|
103 | + self::$instance = new AyeCode_UI_Settings; |
|
104 | + |
|
105 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
106 | + |
|
107 | + if ( is_admin() ) { |
|
108 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
110 | + |
|
111 | + // Maybe show example page |
|
112 | + add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
113 | + } |
|
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | - |
|
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | - } |
|
119 | - |
|
120 | - return self::$instance; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Setup some constants. |
|
125 | - */ |
|
126 | - public function constants(){ |
|
127 | - define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | - define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | - if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | - if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Initiate the settings and add the required action hooks. |
|
135 | - */ |
|
136 | - public function init() { |
|
137 | - $this->constants(); |
|
138 | - $this->settings = $this->get_settings(); |
|
139 | - $this->url = $this->get_url(); |
|
140 | - |
|
141 | - /** |
|
142 | - * Maybe load CSS |
|
143 | - * |
|
144 | - * We load super early in case there is a theme version that might change the colors |
|
145 | - */ |
|
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | - } |
|
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | - } |
|
152 | - |
|
153 | - // maybe load JS |
|
154 | - if ( $this->settings['js'] ) { |
|
155 | - $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | - } |
|
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | - } |
|
161 | - |
|
162 | - // Maybe set the HTML font size |
|
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Check if we should load the admin scripts or not. |
|
172 | - * |
|
173 | - * @return bool |
|
174 | - */ |
|
175 | - public function load_admin_scripts(){ |
|
176 | - $result = true; |
|
177 | - |
|
178 | - if(!empty($this->settings['disable_admin'])){ |
|
179 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
180 | - foreach($url_parts as $part){ |
|
181 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
182 | - return false; // return early, no point checking further |
|
183 | - } |
|
184 | - } |
|
185 | - } |
|
115 | + add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
116 | + |
|
117 | + do_action( 'ayecode_ui_settings_loaded' ); |
|
118 | + } |
|
119 | + |
|
120 | + return self::$instance; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Setup some constants. |
|
125 | + */ |
|
126 | + public function constants(){ |
|
127 | + define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
|
128 | + define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
|
129 | + if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
|
130 | + if (!defined('AUI_SECONDARY_COLOR')) define('AUI_SECONDARY_COLOR', AUI_SECONDARY_COLOR_ORIGINAL); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Initiate the settings and add the required action hooks. |
|
135 | + */ |
|
136 | + public function init() { |
|
137 | + $this->constants(); |
|
138 | + $this->settings = $this->get_settings(); |
|
139 | + $this->url = $this->get_url(); |
|
140 | + |
|
141 | + /** |
|
142 | + * Maybe load CSS |
|
143 | + * |
|
144 | + * We load super early in case there is a theme version that might change the colors |
|
145 | + */ |
|
146 | + if ( $this->settings['css'] ) { |
|
147 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
148 | + } |
|
149 | + if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
151 | + } |
|
152 | + |
|
153 | + // maybe load JS |
|
154 | + if ( $this->settings['js'] ) { |
|
155 | + $priority = $this->is_bs3_compat() ? 100 : 1; |
|
156 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
157 | + } |
|
158 | + if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
160 | + } |
|
161 | + |
|
162 | + // Maybe set the HTML font size |
|
163 | + if ( $this->settings['html_font_size'] ) { |
|
164 | + add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Check if we should load the admin scripts or not. |
|
172 | + * |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | + public function load_admin_scripts(){ |
|
176 | + $result = true; |
|
177 | + |
|
178 | + if(!empty($this->settings['disable_admin'])){ |
|
179 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
180 | + foreach($url_parts as $part){ |
|
181 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
182 | + return false; // return early, no point checking further |
|
183 | + } |
|
184 | + } |
|
185 | + } |
|
186 | 186 | |
187 | - return $result; |
|
188 | - } |
|
187 | + return $result; |
|
188 | + } |
|
189 | 189 | |
190 | - /** |
|
191 | - * Add a html font size to the footer. |
|
192 | - */ |
|
193 | - public function html_font_size(){ |
|
194 | - $this->settings = $this->get_settings(); |
|
195 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | - } |
|
190 | + /** |
|
191 | + * Add a html font size to the footer. |
|
192 | + */ |
|
193 | + public function html_font_size(){ |
|
194 | + $this->settings = $this->get_settings(); |
|
195 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Adds the styles. |
|
200 | - */ |
|
201 | - public function enqueue_style() { |
|
198 | + /** |
|
199 | + * Adds the styles. |
|
200 | + */ |
|
201 | + public function enqueue_style() { |
|
202 | 202 | |
203 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
203 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
204 | 204 | |
205 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
205 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
206 | 206 | |
207 | - if($this->settings[$css_setting]){ |
|
208 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
209 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
210 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
211 | - wp_enqueue_style( 'ayecode-ui' ); |
|
207 | + if($this->settings[$css_setting]){ |
|
208 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
209 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
210 | + wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
211 | + wp_enqueue_style( 'ayecode-ui' ); |
|
212 | 212 | |
213 | - // flatpickr |
|
214 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
213 | + // flatpickr |
|
214 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
215 | 215 | |
216 | 216 | |
217 | - // fix some wp-admin issues |
|
218 | - if(is_admin()){ |
|
219 | - $custom_css = " |
|
217 | + // fix some wp-admin issues |
|
218 | + if(is_admin()){ |
|
219 | + $custom_css = " |
|
220 | 220 | body{ |
221 | 221 | background-color: #f1f1f1; |
222 | 222 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -252,29 +252,29 @@ discard block |
||
252 | 252 | } |
253 | 253 | "; |
254 | 254 | |
255 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
256 | - $custom_css .= " |
|
255 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
256 | + $custom_css .= " |
|
257 | 257 | .edit-post-sidebar input[type=color].components-text-control__input{ |
258 | 258 | padding: 0; |
259 | 259 | } |
260 | 260 | "; |
261 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
262 | - } |
|
261 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
262 | + } |
|
263 | 263 | |
264 | - // custom changes |
|
265 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
264 | + // custom changes |
|
265 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
266 | 266 | |
267 | - } |
|
268 | - } |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Get inline script used if bootstrap enqueued |
|
272 | - * |
|
273 | - * If this remains small then its best to use this than to add another JS file. |
|
274 | - */ |
|
275 | - public function inline_script(){ |
|
276 | - ob_start(); |
|
277 | - ?> |
|
270 | + /** |
|
271 | + * Get inline script used if bootstrap enqueued |
|
272 | + * |
|
273 | + * If this remains small then its best to use this than to add another JS file. |
|
274 | + */ |
|
275 | + public function inline_script(){ |
|
276 | + ob_start(); |
|
277 | + ?> |
|
278 | 278 | <script> |
279 | 279 | |
280 | 280 | /** |
@@ -766,27 +766,27 @@ discard block |
||
766 | 766 | |
767 | 767 | </script> |
768 | 768 | <?php |
769 | - $output = ob_get_clean(); |
|
769 | + $output = ob_get_clean(); |
|
770 | 770 | |
771 | - /* |
|
771 | + /* |
|
772 | 772 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
773 | 773 | */ |
774 | - return str_replace( array( |
|
775 | - '<script>', |
|
776 | - '</script>' |
|
777 | - ), '', $output ); |
|
778 | - } |
|
779 | - |
|
780 | - |
|
781 | - /** |
|
782 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
783 | - * |
|
784 | - * @TODO we may need this when other conflicts arrise. |
|
785 | - * @return mixed |
|
786 | - */ |
|
787 | - public static function bs3_compat_js() { |
|
788 | - ob_start(); |
|
789 | - ?> |
|
774 | + return str_replace( array( |
|
775 | + '<script>', |
|
776 | + '</script>' |
|
777 | + ), '', $output ); |
|
778 | + } |
|
779 | + |
|
780 | + |
|
781 | + /** |
|
782 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
783 | + * |
|
784 | + * @TODO we may need this when other conflicts arrise. |
|
785 | + * @return mixed |
|
786 | + */ |
|
787 | + public static function bs3_compat_js() { |
|
788 | + ob_start(); |
|
789 | + ?> |
|
790 | 790 | <script> |
791 | 791 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
792 | 792 | /* With Avada builder */ |
@@ -794,20 +794,20 @@ discard block |
||
794 | 794 | <?php } ?> |
795 | 795 | </script> |
796 | 796 | <?php |
797 | - return str_replace( array( |
|
798 | - '<script>', |
|
799 | - '</script>' |
|
800 | - ), '', ob_get_clean()); |
|
801 | - } |
|
802 | - |
|
803 | - /** |
|
804 | - * Get inline script used if bootstrap file browser enqueued. |
|
805 | - * |
|
806 | - * If this remains small then its best to use this than to add another JS file. |
|
807 | - */ |
|
808 | - public function inline_script_file_browser(){ |
|
809 | - ob_start(); |
|
810 | - ?> |
|
797 | + return str_replace( array( |
|
798 | + '<script>', |
|
799 | + '</script>' |
|
800 | + ), '', ob_get_clean()); |
|
801 | + } |
|
802 | + |
|
803 | + /** |
|
804 | + * Get inline script used if bootstrap file browser enqueued. |
|
805 | + * |
|
806 | + * If this remains small then its best to use this than to add another JS file. |
|
807 | + */ |
|
808 | + public function inline_script_file_browser(){ |
|
809 | + ob_start(); |
|
810 | + ?> |
|
811 | 811 | <script> |
812 | 812 | // run on doc ready |
813 | 813 | jQuery(document).ready(function () { |
@@ -815,184 +815,184 @@ discard block |
||
815 | 815 | }); |
816 | 816 | </script> |
817 | 817 | <?php |
818 | - $output = ob_get_clean(); |
|
818 | + $output = ob_get_clean(); |
|
819 | 819 | |
820 | - /* |
|
820 | + /* |
|
821 | 821 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
822 | 822 | */ |
823 | - return str_replace( array( |
|
824 | - '<script>', |
|
825 | - '</script>' |
|
826 | - ), '', $output ); |
|
827 | - } |
|
828 | - |
|
829 | - /** |
|
830 | - * Adds the Font Awesome JS. |
|
831 | - */ |
|
832 | - public function enqueue_scripts() { |
|
833 | - |
|
834 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
835 | - |
|
836 | - // select2 |
|
837 | - wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
838 | - |
|
839 | - // flatpickr |
|
840 | - wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
841 | - |
|
842 | - // Bootstrap file browser |
|
843 | - wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
844 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
845 | - |
|
846 | - $load_inline = false; |
|
847 | - |
|
848 | - if($this->settings[$js_setting]=='core-popper'){ |
|
849 | - // Bootstrap bundle |
|
850 | - $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
851 | - wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest, $this->is_bs3_compat() ); |
|
852 | - // if in admin then add to footer for compatibility. |
|
853 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
854 | - $script = $this->inline_script(); |
|
855 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
856 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
857 | - $url = $this->url.'assets/js/popper.min.js'; |
|
858 | - wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
|
859 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
860 | - $load_inline = true; |
|
861 | - }else{ |
|
862 | - $load_inline = true; |
|
863 | - } |
|
864 | - |
|
865 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
866 | - if($load_inline){ |
|
867 | - wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') ); |
|
868 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
869 | - $script = $this->inline_script(); |
|
870 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
871 | - } |
|
872 | - |
|
873 | - } |
|
874 | - |
|
875 | - /** |
|
876 | - * Enqueue flatpickr if called. |
|
877 | - */ |
|
878 | - public function enqueue_flatpickr(){ |
|
879 | - wp_enqueue_style( 'flatpickr' ); |
|
880 | - wp_enqueue_script( 'flatpickr' ); |
|
881 | - } |
|
882 | - |
|
883 | - /** |
|
884 | - * Get the url path to the current folder. |
|
885 | - * |
|
886 | - * @return string |
|
887 | - */ |
|
888 | - public function get_url() { |
|
889 | - |
|
890 | - $url = ''; |
|
891 | - // check if we are inside a plugin |
|
892 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
893 | - |
|
894 | - // add check in-case user has changed wp-content dir name. |
|
895 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
896 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
897 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
898 | - |
|
899 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
900 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
901 | - } |
|
902 | - |
|
903 | - return $url; |
|
904 | - } |
|
905 | - |
|
906 | - /** |
|
907 | - * Register the database settings with WordPress. |
|
908 | - */ |
|
909 | - public function register_settings() { |
|
910 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
911 | - } |
|
912 | - |
|
913 | - /** |
|
914 | - * Add the WordPress settings menu item. |
|
915 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
916 | - */ |
|
917 | - public function menu_item() { |
|
918 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
919 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
920 | - $this, |
|
921 | - 'settings_page' |
|
922 | - ) ); |
|
923 | - } |
|
924 | - |
|
925 | - /** |
|
926 | - * Get a list of themes and their default JS settings. |
|
927 | - * |
|
928 | - * @return array |
|
929 | - */ |
|
930 | - public function theme_js_settings(){ |
|
931 | - return array( |
|
932 | - 'ayetheme' => 'popper', |
|
933 | - 'listimia' => 'required', |
|
934 | - 'listimia_backend' => 'core-popper', |
|
935 | - 'avada' => 'required', |
|
936 | - ); |
|
937 | - } |
|
938 | - |
|
939 | - /** |
|
940 | - * Get the current Font Awesome output settings. |
|
941 | - * |
|
942 | - * @return array The array of settings. |
|
943 | - */ |
|
944 | - public function get_settings() { |
|
945 | - |
|
946 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
947 | - $js_default = 'core-popper'; |
|
948 | - $js_default_backend = $js_default; |
|
949 | - |
|
950 | - // maybe set defaults (if no settings set) |
|
951 | - if(empty($db_settings)){ |
|
952 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
953 | - $theme_js_settings = self::theme_js_settings(); |
|
954 | - if(isset($theme_js_settings[$active_theme])){ |
|
955 | - $js_default = $theme_js_settings[$active_theme]; |
|
956 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
957 | - } |
|
958 | - } |
|
959 | - |
|
960 | - $defaults = array( |
|
961 | - 'css' => 'compatibility', // core, compatibility |
|
962 | - 'js' => $js_default, // js to load, core-popper, popper |
|
963 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
964 | - 'css_backend' => 'compatibility', // core, compatibility |
|
965 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
966 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
967 | - ); |
|
968 | - |
|
969 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
970 | - |
|
971 | - /** |
|
972 | - * Filter the Bootstrap settings. |
|
973 | - * |
|
974 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
975 | - */ |
|
976 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
977 | - } |
|
978 | - |
|
979 | - |
|
980 | - /** |
|
981 | - * The settings page html output. |
|
982 | - */ |
|
983 | - public function settings_page() { |
|
984 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
985 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
986 | - } |
|
987 | - ?> |
|
823 | + return str_replace( array( |
|
824 | + '<script>', |
|
825 | + '</script>' |
|
826 | + ), '', $output ); |
|
827 | + } |
|
828 | + |
|
829 | + /** |
|
830 | + * Adds the Font Awesome JS. |
|
831 | + */ |
|
832 | + public function enqueue_scripts() { |
|
833 | + |
|
834 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
835 | + |
|
836 | + // select2 |
|
837 | + wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
838 | + |
|
839 | + // flatpickr |
|
840 | + wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
841 | + |
|
842 | + // Bootstrap file browser |
|
843 | + wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
844 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
845 | + |
|
846 | + $load_inline = false; |
|
847 | + |
|
848 | + if($this->settings[$js_setting]=='core-popper'){ |
|
849 | + // Bootstrap bundle |
|
850 | + $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
851 | + wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest, $this->is_bs3_compat() ); |
|
852 | + // if in admin then add to footer for compatibility. |
|
853 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
854 | + $script = $this->inline_script(); |
|
855 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
856 | + }elseif($this->settings[$js_setting]=='popper'){ |
|
857 | + $url = $this->url.'assets/js/popper.min.js'; |
|
858 | + wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
|
859 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
860 | + $load_inline = true; |
|
861 | + }else{ |
|
862 | + $load_inline = true; |
|
863 | + } |
|
864 | + |
|
865 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
866 | + if($load_inline){ |
|
867 | + wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') ); |
|
868 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
869 | + $script = $this->inline_script(); |
|
870 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
871 | + } |
|
872 | + |
|
873 | + } |
|
874 | + |
|
875 | + /** |
|
876 | + * Enqueue flatpickr if called. |
|
877 | + */ |
|
878 | + public function enqueue_flatpickr(){ |
|
879 | + wp_enqueue_style( 'flatpickr' ); |
|
880 | + wp_enqueue_script( 'flatpickr' ); |
|
881 | + } |
|
882 | + |
|
883 | + /** |
|
884 | + * Get the url path to the current folder. |
|
885 | + * |
|
886 | + * @return string |
|
887 | + */ |
|
888 | + public function get_url() { |
|
889 | + |
|
890 | + $url = ''; |
|
891 | + // check if we are inside a plugin |
|
892 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
893 | + |
|
894 | + // add check in-case user has changed wp-content dir name. |
|
895 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
896 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
897 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
898 | + |
|
899 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
900 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
901 | + } |
|
902 | + |
|
903 | + return $url; |
|
904 | + } |
|
905 | + |
|
906 | + /** |
|
907 | + * Register the database settings with WordPress. |
|
908 | + */ |
|
909 | + public function register_settings() { |
|
910 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
911 | + } |
|
912 | + |
|
913 | + /** |
|
914 | + * Add the WordPress settings menu item. |
|
915 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
916 | + */ |
|
917 | + public function menu_item() { |
|
918 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
919 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
920 | + $this, |
|
921 | + 'settings_page' |
|
922 | + ) ); |
|
923 | + } |
|
924 | + |
|
925 | + /** |
|
926 | + * Get a list of themes and their default JS settings. |
|
927 | + * |
|
928 | + * @return array |
|
929 | + */ |
|
930 | + public function theme_js_settings(){ |
|
931 | + return array( |
|
932 | + 'ayetheme' => 'popper', |
|
933 | + 'listimia' => 'required', |
|
934 | + 'listimia_backend' => 'core-popper', |
|
935 | + 'avada' => 'required', |
|
936 | + ); |
|
937 | + } |
|
938 | + |
|
939 | + /** |
|
940 | + * Get the current Font Awesome output settings. |
|
941 | + * |
|
942 | + * @return array The array of settings. |
|
943 | + */ |
|
944 | + public function get_settings() { |
|
945 | + |
|
946 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
947 | + $js_default = 'core-popper'; |
|
948 | + $js_default_backend = $js_default; |
|
949 | + |
|
950 | + // maybe set defaults (if no settings set) |
|
951 | + if(empty($db_settings)){ |
|
952 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
953 | + $theme_js_settings = self::theme_js_settings(); |
|
954 | + if(isset($theme_js_settings[$active_theme])){ |
|
955 | + $js_default = $theme_js_settings[$active_theme]; |
|
956 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
957 | + } |
|
958 | + } |
|
959 | + |
|
960 | + $defaults = array( |
|
961 | + 'css' => 'compatibility', // core, compatibility |
|
962 | + 'js' => $js_default, // js to load, core-popper, popper |
|
963 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
964 | + 'css_backend' => 'compatibility', // core, compatibility |
|
965 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
966 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
967 | + ); |
|
968 | + |
|
969 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
970 | + |
|
971 | + /** |
|
972 | + * Filter the Bootstrap settings. |
|
973 | + * |
|
974 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
975 | + */ |
|
976 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
977 | + } |
|
978 | + |
|
979 | + |
|
980 | + /** |
|
981 | + * The settings page html output. |
|
982 | + */ |
|
983 | + public function settings_page() { |
|
984 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
985 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
986 | + } |
|
987 | + ?> |
|
988 | 988 | <div class="wrap"> |
989 | 989 | <h1><?php echo $this->name; ?></h1> |
990 | 990 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p> |
991 | 991 | <form method="post" action="options.php"> |
992 | 992 | <?php |
993 | - settings_fields( 'ayecode-ui-settings' ); |
|
994 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
995 | - ?> |
|
993 | + settings_fields( 'ayecode-ui-settings' ); |
|
994 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
995 | + ?> |
|
996 | 996 | |
997 | 997 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
998 | 998 | <table class="form-table wpbs-table-settings"> |
@@ -1072,60 +1072,60 @@ discard block |
||
1072 | 1072 | </table> |
1073 | 1073 | |
1074 | 1074 | <?php |
1075 | - submit_button(); |
|
1076 | - ?> |
|
1075 | + submit_button(); |
|
1076 | + ?> |
|
1077 | 1077 | </form> |
1078 | 1078 | |
1079 | 1079 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
1080 | 1080 | </div> |
1081 | 1081 | |
1082 | 1082 | <?php |
1083 | - } |
|
1084 | - |
|
1085 | - public function customizer_settings($wp_customize){ |
|
1086 | - $wp_customize->add_section('aui_settings', array( |
|
1087 | - 'title' => __('AyeCode UI','aui'), |
|
1088 | - 'priority' => 120, |
|
1089 | - )); |
|
1090 | - |
|
1091 | - // ============================= |
|
1092 | - // = Color Picker = |
|
1093 | - // ============================= |
|
1094 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1095 | - 'default' => AUI_PRIMARY_COLOR, |
|
1096 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1097 | - 'capability' => 'edit_theme_options', |
|
1098 | - 'type' => 'option', |
|
1099 | - 'transport' => 'refresh', |
|
1100 | - )); |
|
1101 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1102 | - 'label' => __('Primary Color','aui'), |
|
1103 | - 'section' => 'aui_settings', |
|
1104 | - 'settings' => 'aui_options[color_primary]', |
|
1105 | - ))); |
|
1106 | - |
|
1107 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1108 | - 'default' => '#6c757d', |
|
1109 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1110 | - 'capability' => 'edit_theme_options', |
|
1111 | - 'type' => 'option', |
|
1112 | - 'transport' => 'refresh', |
|
1113 | - )); |
|
1114 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1115 | - 'label' => __('Secondary Color','aui'), |
|
1116 | - 'section' => 'aui_settings', |
|
1117 | - 'settings' => 'aui_options[color_secondary]', |
|
1118 | - ))); |
|
1119 | - } |
|
1120 | - |
|
1121 | - /** |
|
1122 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1123 | - * |
|
1124 | - * @return mixed |
|
1125 | - */ |
|
1126 | - public static function bs3_compat_css() { |
|
1127 | - ob_start(); |
|
1128 | - ?> |
|
1083 | + } |
|
1084 | + |
|
1085 | + public function customizer_settings($wp_customize){ |
|
1086 | + $wp_customize->add_section('aui_settings', array( |
|
1087 | + 'title' => __('AyeCode UI','aui'), |
|
1088 | + 'priority' => 120, |
|
1089 | + )); |
|
1090 | + |
|
1091 | + // ============================= |
|
1092 | + // = Color Picker = |
|
1093 | + // ============================= |
|
1094 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1095 | + 'default' => AUI_PRIMARY_COLOR, |
|
1096 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1097 | + 'capability' => 'edit_theme_options', |
|
1098 | + 'type' => 'option', |
|
1099 | + 'transport' => 'refresh', |
|
1100 | + )); |
|
1101 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1102 | + 'label' => __('Primary Color','aui'), |
|
1103 | + 'section' => 'aui_settings', |
|
1104 | + 'settings' => 'aui_options[color_primary]', |
|
1105 | + ))); |
|
1106 | + |
|
1107 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1108 | + 'default' => '#6c757d', |
|
1109 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1110 | + 'capability' => 'edit_theme_options', |
|
1111 | + 'type' => 'option', |
|
1112 | + 'transport' => 'refresh', |
|
1113 | + )); |
|
1114 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1115 | + 'label' => __('Secondary Color','aui'), |
|
1116 | + 'section' => 'aui_settings', |
|
1117 | + 'settings' => 'aui_options[color_secondary]', |
|
1118 | + ))); |
|
1119 | + } |
|
1120 | + |
|
1121 | + /** |
|
1122 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1123 | + * |
|
1124 | + * @return mixed |
|
1125 | + */ |
|
1126 | + public static function bs3_compat_css() { |
|
1127 | + ob_start(); |
|
1128 | + ?> |
|
1129 | 1129 | <style> |
1130 | 1130 | /* Bootstrap 3 compatibility */ |
1131 | 1131 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1151,464 +1151,464 @@ discard block |
||
1151 | 1151 | <?php } ?> |
1152 | 1152 | </style> |
1153 | 1153 | <?php |
1154 | - return str_replace( array( |
|
1155 | - '<style>', |
|
1156 | - '</style>' |
|
1157 | - ), '', ob_get_clean()); |
|
1158 | - } |
|
1154 | + return str_replace( array( |
|
1155 | + '<style>', |
|
1156 | + '</style>' |
|
1157 | + ), '', ob_get_clean()); |
|
1158 | + } |
|
1159 | 1159 | |
1160 | 1160 | |
1161 | - public static function custom_css($compatibility = true) { |
|
1162 | - $settings = get_option('aui_options'); |
|
1161 | + public static function custom_css($compatibility = true) { |
|
1162 | + $settings = get_option('aui_options'); |
|
1163 | 1163 | |
1164 | - ob_start(); |
|
1164 | + ob_start(); |
|
1165 | 1165 | |
1166 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1167 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1168 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
1169 | - ?> |
|
1166 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1167 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1168 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
1169 | + ?> |
|
1170 | 1170 | <style> |
1171 | 1171 | <?php |
1172 | 1172 | |
1173 | - // BS v3 compat |
|
1174 | - if( self::is_bs3_compat() ){ |
|
1175 | - echo self::bs3_compat_css(); |
|
1176 | - } |
|
1173 | + // BS v3 compat |
|
1174 | + if( self::is_bs3_compat() ){ |
|
1175 | + echo self::bs3_compat_css(); |
|
1176 | + } |
|
1177 | 1177 | |
1178 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1179 | - echo self::css_primary($primary_color,$compatibility); |
|
1180 | - } |
|
1178 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1179 | + echo self::css_primary($primary_color,$compatibility); |
|
1180 | + } |
|
1181 | 1181 | |
1182 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1183 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1184 | - } |
|
1182 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1183 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1184 | + } |
|
1185 | 1185 | ?> |
1186 | 1186 | </style> |
1187 | 1187 | <?php |
1188 | 1188 | |
1189 | 1189 | |
1190 | - /* |
|
1190 | + /* |
|
1191 | 1191 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1192 | 1192 | */ |
1193 | - return str_replace( array( |
|
1194 | - '<style>', |
|
1195 | - '</style>' |
|
1196 | - ), '', ob_get_clean()); |
|
1197 | - } |
|
1198 | - |
|
1199 | - /** |
|
1200 | - * Check if we should add booststrap 3 compatibility changes. |
|
1201 | - * |
|
1202 | - * @return bool |
|
1203 | - */ |
|
1204 | - public static function is_bs3_compat(){ |
|
1205 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1206 | - } |
|
1207 | - |
|
1208 | - public static function css_primary($color_code,$compatibility){; |
|
1209 | - $color_code = sanitize_hex_color($color_code); |
|
1210 | - if(!$color_code){return '';} |
|
1211 | - /** |
|
1212 | - * c = color, b = background color, o = border-color, f = fill |
|
1213 | - */ |
|
1214 | - $selectors = array( |
|
1215 | - 'a' => array('c'), |
|
1216 | - '.btn-primary' => array('b','o'), |
|
1217 | - '.btn-primary.disabled' => array('b','o'), |
|
1218 | - '.btn-primary:disabled' => array('b','o'), |
|
1219 | - '.btn-outline-primary' => array('c','o'), |
|
1220 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1221 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1222 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1223 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1224 | - '.btn-link' => array('c'), |
|
1225 | - '.dropdown-item.active' => array('b'), |
|
1226 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1227 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1193 | + return str_replace( array( |
|
1194 | + '<style>', |
|
1195 | + '</style>' |
|
1196 | + ), '', ob_get_clean()); |
|
1197 | + } |
|
1198 | + |
|
1199 | + /** |
|
1200 | + * Check if we should add booststrap 3 compatibility changes. |
|
1201 | + * |
|
1202 | + * @return bool |
|
1203 | + */ |
|
1204 | + public static function is_bs3_compat(){ |
|
1205 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1206 | + } |
|
1207 | + |
|
1208 | + public static function css_primary($color_code,$compatibility){; |
|
1209 | + $color_code = sanitize_hex_color($color_code); |
|
1210 | + if(!$color_code){return '';} |
|
1211 | + /** |
|
1212 | + * c = color, b = background color, o = border-color, f = fill |
|
1213 | + */ |
|
1214 | + $selectors = array( |
|
1215 | + 'a' => array('c'), |
|
1216 | + '.btn-primary' => array('b','o'), |
|
1217 | + '.btn-primary.disabled' => array('b','o'), |
|
1218 | + '.btn-primary:disabled' => array('b','o'), |
|
1219 | + '.btn-outline-primary' => array('c','o'), |
|
1220 | + '.btn-outline-primary:hover' => array('b','o'), |
|
1221 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1222 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1223 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1224 | + '.btn-link' => array('c'), |
|
1225 | + '.dropdown-item.active' => array('b'), |
|
1226 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1227 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1228 | 1228 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1229 | 1229 | // '.custom-range::-moz-range-thumb' => array('b'), |
1230 | 1230 | // '.custom-range::-ms-thumb' => array('b'), |
1231 | - '.nav-pills .nav-link.active' => array('b'), |
|
1232 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1233 | - '.page-link' => array('c'), |
|
1234 | - '.page-item.active .page-link' => array('b','o'), |
|
1235 | - '.badge-primary' => array('b'), |
|
1236 | - '.alert-primary' => array('b','o'), |
|
1237 | - '.progress-bar' => array('b'), |
|
1238 | - '.list-group-item.active' => array('b','o'), |
|
1239 | - '.bg-primary' => array('b','f'), |
|
1240 | - '.btn-link.btn-primary' => array('c'), |
|
1241 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1242 | - ); |
|
1243 | - |
|
1244 | - $important_selectors = array( |
|
1245 | - '.bg-primary' => array('b','f'), |
|
1246 | - '.border-primary' => array('o'), |
|
1247 | - '.text-primary' => array('c'), |
|
1248 | - ); |
|
1249 | - |
|
1250 | - $color = array(); |
|
1251 | - $color_i = array(); |
|
1252 | - $background = array(); |
|
1253 | - $background_i = array(); |
|
1254 | - $border = array(); |
|
1255 | - $border_i = array(); |
|
1256 | - $fill = array(); |
|
1257 | - $fill_i = array(); |
|
1258 | - |
|
1259 | - $output = ''; |
|
1260 | - |
|
1261 | - // build rules into each type |
|
1262 | - foreach($selectors as $selector => $types){ |
|
1263 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1264 | - $types = array_combine($types,$types); |
|
1265 | - if(isset($types['c'])){$color[] = $selector;} |
|
1266 | - if(isset($types['b'])){$background[] = $selector;} |
|
1267 | - if(isset($types['o'])){$border[] = $selector;} |
|
1268 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1269 | - } |
|
1270 | - |
|
1271 | - // build rules into each type |
|
1272 | - foreach($important_selectors as $selector => $types){ |
|
1273 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1274 | - $types = array_combine($types,$types); |
|
1275 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1276 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1277 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1278 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1279 | - } |
|
1280 | - |
|
1281 | - // add any color rules |
|
1282 | - if(!empty($color)){ |
|
1283 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1284 | - } |
|
1285 | - if(!empty($color_i)){ |
|
1286 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1287 | - } |
|
1288 | - |
|
1289 | - // add any background color rules |
|
1290 | - if(!empty($background)){ |
|
1291 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1292 | - } |
|
1293 | - if(!empty($background_i)){ |
|
1294 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1295 | - } |
|
1296 | - |
|
1297 | - // add any border color rules |
|
1298 | - if(!empty($border)){ |
|
1299 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1300 | - } |
|
1301 | - if(!empty($border_i)){ |
|
1302 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1303 | - } |
|
1304 | - |
|
1305 | - // add any fill color rules |
|
1306 | - if(!empty($fill)){ |
|
1307 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1308 | - } |
|
1309 | - if(!empty($fill_i)){ |
|
1310 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1315 | - |
|
1316 | - // darken |
|
1317 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1318 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1319 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1320 | - |
|
1321 | - // lighten |
|
1322 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1323 | - |
|
1324 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1325 | - $op_25 = $color_code."40"; // 25% opacity |
|
1326 | - |
|
1327 | - |
|
1328 | - // button states |
|
1329 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1330 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1331 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1332 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1333 | - |
|
1334 | - |
|
1335 | - // dropdown's |
|
1336 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1337 | - |
|
1338 | - |
|
1339 | - // input states |
|
1340 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1341 | - |
|
1342 | - // page link |
|
1343 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1344 | - |
|
1345 | - return $output; |
|
1346 | - } |
|
1347 | - |
|
1348 | - public static function css_secondary($color_code,$compatibility){; |
|
1349 | - $color_code = sanitize_hex_color($color_code); |
|
1350 | - if(!$color_code){return '';} |
|
1351 | - /** |
|
1352 | - * c = color, b = background color, o = border-color, f = fill |
|
1353 | - */ |
|
1354 | - $selectors = array( |
|
1355 | - '.btn-secondary' => array('b','o'), |
|
1356 | - '.btn-secondary.disabled' => array('b','o'), |
|
1357 | - '.btn-secondary:disabled' => array('b','o'), |
|
1358 | - '.btn-outline-secondary' => array('c','o'), |
|
1359 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1360 | - '.btn-outline-secondary.disabled' => array('c'), |
|
1361 | - '.btn-outline-secondary:disabled' => array('c'), |
|
1362 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1363 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1364 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1365 | - '.badge-secondary' => array('b'), |
|
1366 | - '.alert-secondary' => array('b','o'), |
|
1367 | - '.btn-link.btn-secondary' => array('c'), |
|
1368 | - ); |
|
1369 | - |
|
1370 | - $important_selectors = array( |
|
1371 | - '.bg-secondary' => array('b','f'), |
|
1372 | - '.border-secondary' => array('o'), |
|
1373 | - '.text-secondary' => array('c'), |
|
1374 | - ); |
|
1375 | - |
|
1376 | - $color = array(); |
|
1377 | - $color_i = array(); |
|
1378 | - $background = array(); |
|
1379 | - $background_i = array(); |
|
1380 | - $border = array(); |
|
1381 | - $border_i = array(); |
|
1382 | - $fill = array(); |
|
1383 | - $fill_i = array(); |
|
1384 | - |
|
1385 | - $output = ''; |
|
1386 | - |
|
1387 | - // build rules into each type |
|
1388 | - foreach($selectors as $selector => $types){ |
|
1389 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1390 | - $types = array_combine($types,$types); |
|
1391 | - if(isset($types['c'])){$color[] = $selector;} |
|
1392 | - if(isset($types['b'])){$background[] = $selector;} |
|
1393 | - if(isset($types['o'])){$border[] = $selector;} |
|
1394 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1395 | - } |
|
1396 | - |
|
1397 | - // build rules into each type |
|
1398 | - foreach($important_selectors as $selector => $types){ |
|
1399 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1400 | - $types = array_combine($types,$types); |
|
1401 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1402 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1403 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1404 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1405 | - } |
|
1406 | - |
|
1407 | - // add any color rules |
|
1408 | - if(!empty($color)){ |
|
1409 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1410 | - } |
|
1411 | - if(!empty($color_i)){ |
|
1412 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1413 | - } |
|
1414 | - |
|
1415 | - // add any background color rules |
|
1416 | - if(!empty($background)){ |
|
1417 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1418 | - } |
|
1419 | - if(!empty($background_i)){ |
|
1420 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1421 | - } |
|
1422 | - |
|
1423 | - // add any border color rules |
|
1424 | - if(!empty($border)){ |
|
1425 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1426 | - } |
|
1427 | - if(!empty($border_i)){ |
|
1428 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1429 | - } |
|
1430 | - |
|
1431 | - // add any fill color rules |
|
1432 | - if(!empty($fill)){ |
|
1433 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1434 | - } |
|
1435 | - if(!empty($fill_i)){ |
|
1436 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1437 | - } |
|
1438 | - |
|
1439 | - |
|
1440 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1441 | - |
|
1442 | - // darken |
|
1443 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1444 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1445 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1446 | - |
|
1447 | - // lighten |
|
1448 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1449 | - |
|
1450 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1451 | - $op_25 = $color_code."40"; // 25% opacity |
|
1452 | - |
|
1453 | - |
|
1454 | - // button states |
|
1455 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1456 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1457 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1458 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1459 | - |
|
1460 | - |
|
1461 | - return $output; |
|
1462 | - } |
|
1463 | - |
|
1464 | - /** |
|
1465 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1466 | - * |
|
1467 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1468 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1469 | - * |
|
1470 | - * @return string |
|
1471 | - */ |
|
1472 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1473 | - $hexCode = ltrim($hexCode, '#'); |
|
1474 | - |
|
1475 | - if (strlen($hexCode) == 3) { |
|
1476 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1477 | - } |
|
1478 | - |
|
1479 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1480 | - |
|
1481 | - foreach ($hexCode as & $color) { |
|
1482 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1483 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1484 | - |
|
1485 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1486 | - } |
|
1487 | - |
|
1488 | - return '#' . implode($hexCode); |
|
1489 | - } |
|
1490 | - |
|
1491 | - /** |
|
1492 | - * Check if we should display examples. |
|
1493 | - */ |
|
1494 | - public function maybe_show_examples(){ |
|
1495 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1496 | - echo "<head>"; |
|
1497 | - wp_head(); |
|
1498 | - echo "</head>"; |
|
1499 | - echo "<body>"; |
|
1500 | - echo $this->get_examples(); |
|
1501 | - echo "</body>"; |
|
1502 | - exit; |
|
1503 | - } |
|
1504 | - } |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * Get developer examples. |
|
1508 | - * |
|
1509 | - * @return string |
|
1510 | - */ |
|
1511 | - public function get_examples(){ |
|
1512 | - $output = ''; |
|
1513 | - |
|
1514 | - |
|
1515 | - // open form |
|
1516 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1517 | - |
|
1518 | - // input example |
|
1519 | - $output .= aui()->input(array( |
|
1520 | - 'type' => 'text', |
|
1521 | - 'id' => 'text-example', |
|
1522 | - 'name' => 'text-example', |
|
1523 | - 'placeholder' => 'text placeholder', |
|
1524 | - 'title' => 'Text input example', |
|
1525 | - 'value' => '', |
|
1526 | - 'required' => false, |
|
1527 | - 'help_text' => 'help text', |
|
1528 | - 'label' => 'Text input example label' |
|
1529 | - )); |
|
1530 | - |
|
1531 | - // input example |
|
1532 | - $output .= aui()->input(array( |
|
1533 | - 'type' => 'url', |
|
1534 | - 'id' => 'text-example2', |
|
1535 | - 'name' => 'text-example', |
|
1536 | - 'placeholder' => 'url placeholder', |
|
1537 | - 'title' => 'Text input example', |
|
1538 | - 'value' => '', |
|
1539 | - 'required' => false, |
|
1540 | - 'help_text' => 'help text', |
|
1541 | - 'label' => 'Text input example label' |
|
1542 | - )); |
|
1543 | - |
|
1544 | - // checkbox example |
|
1545 | - $output .= aui()->input(array( |
|
1546 | - 'type' => 'checkbox', |
|
1547 | - 'id' => 'checkbox-example', |
|
1548 | - 'name' => 'checkbox-example', |
|
1549 | - 'placeholder' => 'checkbox-example', |
|
1550 | - 'title' => 'Checkbox example', |
|
1551 | - 'value' => '1', |
|
1552 | - 'checked' => true, |
|
1553 | - 'required' => false, |
|
1554 | - 'help_text' => 'help text', |
|
1555 | - 'label' => 'Checkbox checked' |
|
1556 | - )); |
|
1557 | - |
|
1558 | - // checkbox example |
|
1559 | - $output .= aui()->input(array( |
|
1560 | - 'type' => 'checkbox', |
|
1561 | - 'id' => 'checkbox-example2', |
|
1562 | - 'name' => 'checkbox-example2', |
|
1563 | - 'placeholder' => 'checkbox-example', |
|
1564 | - 'title' => 'Checkbox example', |
|
1565 | - 'value' => '1', |
|
1566 | - 'checked' => false, |
|
1567 | - 'required' => false, |
|
1568 | - 'help_text' => 'help text', |
|
1569 | - 'label' => 'Checkbox un-checked' |
|
1570 | - )); |
|
1571 | - |
|
1572 | - // switch example |
|
1573 | - $output .= aui()->input(array( |
|
1574 | - 'type' => 'checkbox', |
|
1575 | - 'id' => 'switch-example', |
|
1576 | - 'name' => 'switch-example', |
|
1577 | - 'placeholder' => 'checkbox-example', |
|
1578 | - 'title' => 'Switch example', |
|
1579 | - 'value' => '1', |
|
1580 | - 'checked' => true, |
|
1581 | - 'switch' => true, |
|
1582 | - 'required' => false, |
|
1583 | - 'help_text' => 'help text', |
|
1584 | - 'label' => 'Switch on' |
|
1585 | - )); |
|
1586 | - |
|
1587 | - // switch example |
|
1588 | - $output .= aui()->input(array( |
|
1589 | - 'type' => 'checkbox', |
|
1590 | - 'id' => 'switch-example2', |
|
1591 | - 'name' => 'switch-example2', |
|
1592 | - 'placeholder' => 'checkbox-example', |
|
1593 | - 'title' => 'Switch example', |
|
1594 | - 'value' => '1', |
|
1595 | - 'checked' => false, |
|
1596 | - 'switch' => true, |
|
1597 | - 'required' => false, |
|
1598 | - 'help_text' => 'help text', |
|
1599 | - 'label' => 'Switch off' |
|
1600 | - )); |
|
1601 | - |
|
1602 | - // close form |
|
1603 | - $output .= "</form>"; |
|
1604 | - |
|
1605 | - return $output; |
|
1606 | - } |
|
1607 | - |
|
1608 | - } |
|
1609 | - |
|
1610 | - /** |
|
1611 | - * Run the class if found. |
|
1612 | - */ |
|
1613 | - AyeCode_UI_Settings::instance(); |
|
1231 | + '.nav-pills .nav-link.active' => array('b'), |
|
1232 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1233 | + '.page-link' => array('c'), |
|
1234 | + '.page-item.active .page-link' => array('b','o'), |
|
1235 | + '.badge-primary' => array('b'), |
|
1236 | + '.alert-primary' => array('b','o'), |
|
1237 | + '.progress-bar' => array('b'), |
|
1238 | + '.list-group-item.active' => array('b','o'), |
|
1239 | + '.bg-primary' => array('b','f'), |
|
1240 | + '.btn-link.btn-primary' => array('c'), |
|
1241 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1242 | + ); |
|
1243 | + |
|
1244 | + $important_selectors = array( |
|
1245 | + '.bg-primary' => array('b','f'), |
|
1246 | + '.border-primary' => array('o'), |
|
1247 | + '.text-primary' => array('c'), |
|
1248 | + ); |
|
1249 | + |
|
1250 | + $color = array(); |
|
1251 | + $color_i = array(); |
|
1252 | + $background = array(); |
|
1253 | + $background_i = array(); |
|
1254 | + $border = array(); |
|
1255 | + $border_i = array(); |
|
1256 | + $fill = array(); |
|
1257 | + $fill_i = array(); |
|
1258 | + |
|
1259 | + $output = ''; |
|
1260 | + |
|
1261 | + // build rules into each type |
|
1262 | + foreach($selectors as $selector => $types){ |
|
1263 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1264 | + $types = array_combine($types,$types); |
|
1265 | + if(isset($types['c'])){$color[] = $selector;} |
|
1266 | + if(isset($types['b'])){$background[] = $selector;} |
|
1267 | + if(isset($types['o'])){$border[] = $selector;} |
|
1268 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1269 | + } |
|
1270 | + |
|
1271 | + // build rules into each type |
|
1272 | + foreach($important_selectors as $selector => $types){ |
|
1273 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1274 | + $types = array_combine($types,$types); |
|
1275 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1276 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1277 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1278 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1279 | + } |
|
1280 | + |
|
1281 | + // add any color rules |
|
1282 | + if(!empty($color)){ |
|
1283 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1284 | + } |
|
1285 | + if(!empty($color_i)){ |
|
1286 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1287 | + } |
|
1288 | + |
|
1289 | + // add any background color rules |
|
1290 | + if(!empty($background)){ |
|
1291 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1292 | + } |
|
1293 | + if(!empty($background_i)){ |
|
1294 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1295 | + } |
|
1296 | + |
|
1297 | + // add any border color rules |
|
1298 | + if(!empty($border)){ |
|
1299 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1300 | + } |
|
1301 | + if(!empty($border_i)){ |
|
1302 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1303 | + } |
|
1304 | + |
|
1305 | + // add any fill color rules |
|
1306 | + if(!empty($fill)){ |
|
1307 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1308 | + } |
|
1309 | + if(!empty($fill_i)){ |
|
1310 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1315 | + |
|
1316 | + // darken |
|
1317 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1318 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1319 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1320 | + |
|
1321 | + // lighten |
|
1322 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1323 | + |
|
1324 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1325 | + $op_25 = $color_code."40"; // 25% opacity |
|
1326 | + |
|
1327 | + |
|
1328 | + // button states |
|
1329 | + $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1330 | + $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1331 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1332 | + $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1333 | + |
|
1334 | + |
|
1335 | + // dropdown's |
|
1336 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1337 | + |
|
1338 | + |
|
1339 | + // input states |
|
1340 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1341 | + |
|
1342 | + // page link |
|
1343 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1344 | + |
|
1345 | + return $output; |
|
1346 | + } |
|
1347 | + |
|
1348 | + public static function css_secondary($color_code,$compatibility){; |
|
1349 | + $color_code = sanitize_hex_color($color_code); |
|
1350 | + if(!$color_code){return '';} |
|
1351 | + /** |
|
1352 | + * c = color, b = background color, o = border-color, f = fill |
|
1353 | + */ |
|
1354 | + $selectors = array( |
|
1355 | + '.btn-secondary' => array('b','o'), |
|
1356 | + '.btn-secondary.disabled' => array('b','o'), |
|
1357 | + '.btn-secondary:disabled' => array('b','o'), |
|
1358 | + '.btn-outline-secondary' => array('c','o'), |
|
1359 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
1360 | + '.btn-outline-secondary.disabled' => array('c'), |
|
1361 | + '.btn-outline-secondary:disabled' => array('c'), |
|
1362 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1363 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1364 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1365 | + '.badge-secondary' => array('b'), |
|
1366 | + '.alert-secondary' => array('b','o'), |
|
1367 | + '.btn-link.btn-secondary' => array('c'), |
|
1368 | + ); |
|
1369 | + |
|
1370 | + $important_selectors = array( |
|
1371 | + '.bg-secondary' => array('b','f'), |
|
1372 | + '.border-secondary' => array('o'), |
|
1373 | + '.text-secondary' => array('c'), |
|
1374 | + ); |
|
1375 | + |
|
1376 | + $color = array(); |
|
1377 | + $color_i = array(); |
|
1378 | + $background = array(); |
|
1379 | + $background_i = array(); |
|
1380 | + $border = array(); |
|
1381 | + $border_i = array(); |
|
1382 | + $fill = array(); |
|
1383 | + $fill_i = array(); |
|
1384 | + |
|
1385 | + $output = ''; |
|
1386 | + |
|
1387 | + // build rules into each type |
|
1388 | + foreach($selectors as $selector => $types){ |
|
1389 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1390 | + $types = array_combine($types,$types); |
|
1391 | + if(isset($types['c'])){$color[] = $selector;} |
|
1392 | + if(isset($types['b'])){$background[] = $selector;} |
|
1393 | + if(isset($types['o'])){$border[] = $selector;} |
|
1394 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1395 | + } |
|
1396 | + |
|
1397 | + // build rules into each type |
|
1398 | + foreach($important_selectors as $selector => $types){ |
|
1399 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1400 | + $types = array_combine($types,$types); |
|
1401 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1402 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1403 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1404 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1405 | + } |
|
1406 | + |
|
1407 | + // add any color rules |
|
1408 | + if(!empty($color)){ |
|
1409 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1410 | + } |
|
1411 | + if(!empty($color_i)){ |
|
1412 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1413 | + } |
|
1414 | + |
|
1415 | + // add any background color rules |
|
1416 | + if(!empty($background)){ |
|
1417 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1418 | + } |
|
1419 | + if(!empty($background_i)){ |
|
1420 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1421 | + } |
|
1422 | + |
|
1423 | + // add any border color rules |
|
1424 | + if(!empty($border)){ |
|
1425 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1426 | + } |
|
1427 | + if(!empty($border_i)){ |
|
1428 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1429 | + } |
|
1430 | + |
|
1431 | + // add any fill color rules |
|
1432 | + if(!empty($fill)){ |
|
1433 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1434 | + } |
|
1435 | + if(!empty($fill_i)){ |
|
1436 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1437 | + } |
|
1438 | + |
|
1439 | + |
|
1440 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1441 | + |
|
1442 | + // darken |
|
1443 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1444 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1445 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1446 | + |
|
1447 | + // lighten |
|
1448 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1449 | + |
|
1450 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1451 | + $op_25 = $color_code."40"; // 25% opacity |
|
1452 | + |
|
1453 | + |
|
1454 | + // button states |
|
1455 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1456 | + $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1457 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1458 | + $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1459 | + |
|
1460 | + |
|
1461 | + return $output; |
|
1462 | + } |
|
1463 | + |
|
1464 | + /** |
|
1465 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1466 | + * |
|
1467 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1468 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1469 | + * |
|
1470 | + * @return string |
|
1471 | + */ |
|
1472 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1473 | + $hexCode = ltrim($hexCode, '#'); |
|
1474 | + |
|
1475 | + if (strlen($hexCode) == 3) { |
|
1476 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1477 | + } |
|
1478 | + |
|
1479 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1480 | + |
|
1481 | + foreach ($hexCode as & $color) { |
|
1482 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1483 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1484 | + |
|
1485 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1486 | + } |
|
1487 | + |
|
1488 | + return '#' . implode($hexCode); |
|
1489 | + } |
|
1490 | + |
|
1491 | + /** |
|
1492 | + * Check if we should display examples. |
|
1493 | + */ |
|
1494 | + public function maybe_show_examples(){ |
|
1495 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1496 | + echo "<head>"; |
|
1497 | + wp_head(); |
|
1498 | + echo "</head>"; |
|
1499 | + echo "<body>"; |
|
1500 | + echo $this->get_examples(); |
|
1501 | + echo "</body>"; |
|
1502 | + exit; |
|
1503 | + } |
|
1504 | + } |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * Get developer examples. |
|
1508 | + * |
|
1509 | + * @return string |
|
1510 | + */ |
|
1511 | + public function get_examples(){ |
|
1512 | + $output = ''; |
|
1513 | + |
|
1514 | + |
|
1515 | + // open form |
|
1516 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1517 | + |
|
1518 | + // input example |
|
1519 | + $output .= aui()->input(array( |
|
1520 | + 'type' => 'text', |
|
1521 | + 'id' => 'text-example', |
|
1522 | + 'name' => 'text-example', |
|
1523 | + 'placeholder' => 'text placeholder', |
|
1524 | + 'title' => 'Text input example', |
|
1525 | + 'value' => '', |
|
1526 | + 'required' => false, |
|
1527 | + 'help_text' => 'help text', |
|
1528 | + 'label' => 'Text input example label' |
|
1529 | + )); |
|
1530 | + |
|
1531 | + // input example |
|
1532 | + $output .= aui()->input(array( |
|
1533 | + 'type' => 'url', |
|
1534 | + 'id' => 'text-example2', |
|
1535 | + 'name' => 'text-example', |
|
1536 | + 'placeholder' => 'url placeholder', |
|
1537 | + 'title' => 'Text input example', |
|
1538 | + 'value' => '', |
|
1539 | + 'required' => false, |
|
1540 | + 'help_text' => 'help text', |
|
1541 | + 'label' => 'Text input example label' |
|
1542 | + )); |
|
1543 | + |
|
1544 | + // checkbox example |
|
1545 | + $output .= aui()->input(array( |
|
1546 | + 'type' => 'checkbox', |
|
1547 | + 'id' => 'checkbox-example', |
|
1548 | + 'name' => 'checkbox-example', |
|
1549 | + 'placeholder' => 'checkbox-example', |
|
1550 | + 'title' => 'Checkbox example', |
|
1551 | + 'value' => '1', |
|
1552 | + 'checked' => true, |
|
1553 | + 'required' => false, |
|
1554 | + 'help_text' => 'help text', |
|
1555 | + 'label' => 'Checkbox checked' |
|
1556 | + )); |
|
1557 | + |
|
1558 | + // checkbox example |
|
1559 | + $output .= aui()->input(array( |
|
1560 | + 'type' => 'checkbox', |
|
1561 | + 'id' => 'checkbox-example2', |
|
1562 | + 'name' => 'checkbox-example2', |
|
1563 | + 'placeholder' => 'checkbox-example', |
|
1564 | + 'title' => 'Checkbox example', |
|
1565 | + 'value' => '1', |
|
1566 | + 'checked' => false, |
|
1567 | + 'required' => false, |
|
1568 | + 'help_text' => 'help text', |
|
1569 | + 'label' => 'Checkbox un-checked' |
|
1570 | + )); |
|
1571 | + |
|
1572 | + // switch example |
|
1573 | + $output .= aui()->input(array( |
|
1574 | + 'type' => 'checkbox', |
|
1575 | + 'id' => 'switch-example', |
|
1576 | + 'name' => 'switch-example', |
|
1577 | + 'placeholder' => 'checkbox-example', |
|
1578 | + 'title' => 'Switch example', |
|
1579 | + 'value' => '1', |
|
1580 | + 'checked' => true, |
|
1581 | + 'switch' => true, |
|
1582 | + 'required' => false, |
|
1583 | + 'help_text' => 'help text', |
|
1584 | + 'label' => 'Switch on' |
|
1585 | + )); |
|
1586 | + |
|
1587 | + // switch example |
|
1588 | + $output .= aui()->input(array( |
|
1589 | + 'type' => 'checkbox', |
|
1590 | + 'id' => 'switch-example2', |
|
1591 | + 'name' => 'switch-example2', |
|
1592 | + 'placeholder' => 'checkbox-example', |
|
1593 | + 'title' => 'Switch example', |
|
1594 | + 'value' => '1', |
|
1595 | + 'checked' => false, |
|
1596 | + 'switch' => true, |
|
1597 | + 'required' => false, |
|
1598 | + 'help_text' => 'help text', |
|
1599 | + 'label' => 'Switch off' |
|
1600 | + )); |
|
1601 | + |
|
1602 | + // close form |
|
1603 | + $output .= "</form>"; |
|
1604 | + |
|
1605 | + return $output; |
|
1606 | + } |
|
1607 | + |
|
1608 | + } |
|
1609 | + |
|
1610 | + /** |
|
1611 | + * Run the class if found. |
|
1612 | + */ |
|
1613 | + AyeCode_UI_Settings::instance(); |
|
1614 | 1614 | } |
1615 | 1615 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'AyeCode_UI_Settings' ) ) { |
|
22 | +if (!class_exists('AyeCode_UI_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -98,23 +98,23 @@ discard block |
||
98 | 98 | * @return AyeCode_UI_Settings - Main instance. |
99 | 99 | */ |
100 | 100 | public static function instance() { |
101 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof AyeCode_UI_Settings ) ) { |
|
101 | + if (!isset(self::$instance) && !(self::$instance instanceof AyeCode_UI_Settings)) { |
|
102 | 102 | |
103 | 103 | self::$instance = new AyeCode_UI_Settings; |
104 | 104 | |
105 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
105 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
106 | 106 | |
107 | - if ( is_admin() ) { |
|
108 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
109 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
107 | + if (is_admin()) { |
|
108 | + add_action('admin_menu', array(self::$instance, 'menu_item')); |
|
109 | + add_action('admin_init', array(self::$instance, 'register_settings')); |
|
110 | 110 | |
111 | 111 | // Maybe show example page |
112 | - add_action( 'template_redirect', array( self::$instance,'maybe_show_examples' ) ); |
|
112 | + add_action('template_redirect', array(self::$instance, 'maybe_show_examples')); |
|
113 | 113 | } |
114 | 114 | |
115 | - add_action( 'customize_register', array( self::$instance, 'customizer_settings' )); |
|
115 | + add_action('customize_register', array(self::$instance, 'customizer_settings')); |
|
116 | 116 | |
117 | - do_action( 'ayecode_ui_settings_loaded' ); |
|
117 | + do_action('ayecode_ui_settings_loaded'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | return self::$instance; |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** |
124 | 124 | * Setup some constants. |
125 | 125 | */ |
126 | - public function constants(){ |
|
126 | + public function constants() { |
|
127 | 127 | define('AUI_PRIMARY_COLOR_ORIGINAL', "#1e73be"); |
128 | 128 | define('AUI_SECONDARY_COLOR_ORIGINAL', '#6c757d'); |
129 | 129 | if (!defined('AUI_PRIMARY_COLOR')) define('AUI_PRIMARY_COLOR', AUI_PRIMARY_COLOR_ORIGINAL); |
@@ -143,25 +143,25 @@ discard block |
||
143 | 143 | * |
144 | 144 | * We load super early in case there is a theme version that might change the colors |
145 | 145 | */ |
146 | - if ( $this->settings['css'] ) { |
|
147 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
146 | + if ($this->settings['css']) { |
|
147 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
148 | 148 | } |
149 | - if ( $this->settings['css_backend'] && $this->load_admin_scripts() ) { |
|
150 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 1 ); |
|
149 | + if ($this->settings['css_backend'] && $this->load_admin_scripts()) { |
|
150 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 1); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // maybe load JS |
154 | - if ( $this->settings['js'] ) { |
|
154 | + if ($this->settings['js']) { |
|
155 | 155 | $priority = $this->is_bs3_compat() ? 100 : 1; |
156 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), $priority ); |
|
156 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), $priority); |
|
157 | 157 | } |
158 | - if ( $this->settings['js_backend'] && $this->load_admin_scripts() ) { |
|
159 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 1 ); |
|
158 | + if ($this->settings['js_backend'] && $this->load_admin_scripts()) { |
|
159 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 1); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | // Maybe set the HTML font size |
163 | - if ( $this->settings['html_font_size'] ) { |
|
164 | - add_action( 'wp_footer', array( $this, 'html_font_size' ), 10 ); |
|
163 | + if ($this->settings['html_font_size']) { |
|
164 | + add_action('wp_footer', array($this, 'html_font_size'), 10); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function load_admin_scripts(){ |
|
175 | + public function load_admin_scripts() { |
|
176 | 176 | $result = true; |
177 | 177 | |
178 | - if(!empty($this->settings['disable_admin'])){ |
|
179 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
180 | - foreach($url_parts as $part){ |
|
181 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
178 | + if (!empty($this->settings['disable_admin'])) { |
|
179 | + $url_parts = explode("\n", $this->settings['disable_admin']); |
|
180 | + foreach ($url_parts as $part) { |
|
181 | + if (strpos($_SERVER['REQUEST_URI'], trim($part)) !== false) { |
|
182 | 182 | return false; // return early, no point checking further |
183 | 183 | } |
184 | 184 | } |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | /** |
191 | 191 | * Add a html font size to the footer. |
192 | 192 | */ |
193 | - public function html_font_size(){ |
|
193 | + public function html_font_size() { |
|
194 | 194 | $this->settings = $this->get_settings(); |
195 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
195 | + echo "<style>html{font-size:" . absint($this->settings['html_font_size']) . "px;}</style>"; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -204,18 +204,18 @@ discard block |
||
204 | 204 | |
205 | 205 | $rtl = is_rtl() ? '-rtl' : ''; |
206 | 206 | |
207 | - if($this->settings[$css_setting]){ |
|
208 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
209 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
210 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
211 | - wp_enqueue_style( 'ayecode-ui' ); |
|
207 | + if ($this->settings[$css_setting]) { |
|
208 | + $compatibility = $this->settings[$css_setting] == 'core' ? false : true; |
|
209 | + $url = $this->settings[$css_setting] == 'core' ? $this->url . 'assets/css/ayecode-ui' . $rtl . '.css' : $this->url . 'assets/css/ayecode-ui-compatibility' . $rtl . '.css'; |
|
210 | + wp_register_style('ayecode-ui', $url, array(), $this->latest); |
|
211 | + wp_enqueue_style('ayecode-ui'); |
|
212 | 212 | |
213 | 213 | // flatpickr |
214 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
214 | + wp_register_style('flatpickr', $this->url . 'assets/css/flatpickr.min.css', array(), $this->latest); |
|
215 | 215 | |
216 | 216 | |
217 | 217 | // fix some wp-admin issues |
218 | - if(is_admin()){ |
|
218 | + if (is_admin()) { |
|
219 | 219 | $custom_css = " |
220 | 220 | body{ |
221 | 221 | background-color: #f1f1f1; |
@@ -258,11 +258,11 @@ discard block |
||
258 | 258 | padding: 0; |
259 | 259 | } |
260 | 260 | "; |
261 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
261 | + wp_add_inline_style('ayecode-ui', $custom_css); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | // custom changes |
265 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
265 | + wp_add_inline_style('ayecode-ui', self::custom_css($compatibility)); |
|
266 | 266 | |
267 | 267 | } |
268 | 268 | } |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * |
273 | 273 | * If this remains small then its best to use this than to add another JS file. |
274 | 274 | */ |
275 | - public function inline_script(){ |
|
275 | + public function inline_script() { |
|
276 | 276 | ob_start(); |
277 | 277 | ?> |
278 | 278 | <script> |
@@ -771,10 +771,10 @@ discard block |
||
771 | 771 | /* |
772 | 772 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
773 | 773 | */ |
774 | - return str_replace( array( |
|
774 | + return str_replace(array( |
|
775 | 775 | '<script>', |
776 | 776 | '</script>' |
777 | - ), '', $output ); |
|
777 | + ), '', $output); |
|
778 | 778 | } |
779 | 779 | |
780 | 780 | |
@@ -788,13 +788,13 @@ discard block |
||
788 | 788 | ob_start(); |
789 | 789 | ?> |
790 | 790 | <script> |
791 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
791 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
792 | 792 | /* With Avada builder */ |
793 | 793 | |
794 | 794 | <?php } ?> |
795 | 795 | </script> |
796 | 796 | <?php |
797 | - return str_replace( array( |
|
797 | + return str_replace(array( |
|
798 | 798 | '<script>', |
799 | 799 | '</script>' |
800 | 800 | ), '', ob_get_clean()); |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | * |
806 | 806 | * If this remains small then its best to use this than to add another JS file. |
807 | 807 | */ |
808 | - public function inline_script_file_browser(){ |
|
808 | + public function inline_script_file_browser() { |
|
809 | 809 | ob_start(); |
810 | 810 | ?> |
811 | 811 | <script> |
@@ -820,10 +820,10 @@ discard block |
||
820 | 820 | /* |
821 | 821 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
822 | 822 | */ |
823 | - return str_replace( array( |
|
823 | + return str_replace(array( |
|
824 | 824 | '<script>', |
825 | 825 | '</script>' |
826 | - ), '', $output ); |
|
826 | + ), '', $output); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -834,40 +834,40 @@ discard block |
||
834 | 834 | $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
835 | 835 | |
836 | 836 | // select2 |
837 | - wp_register_script( 'select2', $this->url.'assets/js/select2.min.js', array('jquery'), $this->select2_version ); |
|
837 | + wp_register_script('select2', $this->url . 'assets/js/select2.min.js', array('jquery'), $this->select2_version); |
|
838 | 838 | |
839 | 839 | // flatpickr |
840 | - wp_register_script( 'flatpickr', $this->url.'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
840 | + wp_register_script('flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest); |
|
841 | 841 | |
842 | 842 | // Bootstrap file browser |
843 | - wp_register_script( 'aui-custom-file-input', $url = $this->url.'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version ); |
|
844 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
843 | + wp_register_script('aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array('jquery'), $this->select2_version); |
|
844 | + wp_add_inline_script('aui-custom-file-input', $this->inline_script_file_browser()); |
|
845 | 845 | |
846 | 846 | $load_inline = false; |
847 | 847 | |
848 | - if($this->settings[$js_setting]=='core-popper'){ |
|
848 | + if ($this->settings[$js_setting] == 'core-popper') { |
|
849 | 849 | // Bootstrap bundle |
850 | - $url = $this->url.'assets/js/bootstrap.bundle.min.js'; |
|
851 | - wp_register_script( 'bootstrap-js-bundle', $url, array('select2','jquery'), $this->latest, $this->is_bs3_compat() ); |
|
850 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
851 | + wp_register_script('bootstrap-js-bundle', $url, array('select2', 'jquery'), $this->latest, $this->is_bs3_compat()); |
|
852 | 852 | // if in admin then add to footer for compatibility. |
853 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle'); |
|
853 | + is_admin() ? wp_enqueue_script('bootstrap-js-bundle', '', null, null, true) : wp_enqueue_script('bootstrap-js-bundle'); |
|
854 | 854 | $script = $this->inline_script(); |
855 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
856 | - }elseif($this->settings[$js_setting]=='popper'){ |
|
857 | - $url = $this->url.'assets/js/popper.min.js'; |
|
858 | - wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest ); |
|
859 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
855 | + wp_add_inline_script('bootstrap-js-bundle', $script); |
|
856 | + }elseif ($this->settings[$js_setting] == 'popper') { |
|
857 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
858 | + wp_register_script('bootstrap-js-popper', $url, array('select2', 'jquery'), $this->latest); |
|
859 | + wp_enqueue_script('bootstrap-js-popper'); |
|
860 | 860 | $load_inline = true; |
861 | - }else{ |
|
861 | + } else { |
|
862 | 862 | $load_inline = true; |
863 | 863 | } |
864 | 864 | |
865 | 865 | // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
866 | - if($load_inline){ |
|
867 | - wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') ); |
|
868 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
866 | + if ($load_inline) { |
|
867 | + wp_register_script('bootstrap-dummy', '', array('select2', 'jquery')); |
|
868 | + wp_enqueue_script('bootstrap-dummy'); |
|
869 | 869 | $script = $this->inline_script(); |
870 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
870 | + wp_add_inline_script('bootstrap-dummy', $script); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | } |
@@ -875,9 +875,9 @@ discard block |
||
875 | 875 | /** |
876 | 876 | * Enqueue flatpickr if called. |
877 | 877 | */ |
878 | - public function enqueue_flatpickr(){ |
|
879 | - wp_enqueue_style( 'flatpickr' ); |
|
880 | - wp_enqueue_script( 'flatpickr' ); |
|
878 | + public function enqueue_flatpickr() { |
|
879 | + wp_enqueue_style('flatpickr'); |
|
880 | + wp_enqueue_script('flatpickr'); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -889,15 +889,15 @@ discard block |
||
889 | 889 | |
890 | 890 | $url = ''; |
891 | 891 | // check if we are inside a plugin |
892 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
892 | + $file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__))); |
|
893 | 893 | |
894 | 894 | // add check in-case user has changed wp-content dir name. |
895 | 895 | $wp_content_folder_name = basename(WP_CONTENT_DIR); |
896 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
897 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
896 | + $dir_parts = explode("/$wp_content_folder_name/", $file_dir); |
|
897 | + $url_parts = explode("/$wp_content_folder_name/", plugins_url()); |
|
898 | 898 | |
899 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
900 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
899 | + if (!empty($url_parts[0]) && !empty($dir_parts[1])) { |
|
900 | + $url = trailingslashit($url_parts[0] . "/$wp_content_folder_name/" . $dir_parts[1]); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | return $url; |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | * Register the database settings with WordPress. |
908 | 908 | */ |
909 | 909 | public function register_settings() { |
910 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
910 | + register_setting('ayecode-ui-settings', 'ayecode-ui-settings'); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -916,10 +916,10 @@ discard block |
||
916 | 916 | */ |
917 | 917 | public function menu_item() { |
918 | 918 | $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
919 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
919 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
920 | 920 | $this, |
921 | 921 | 'settings_page' |
922 | - ) ); |
|
922 | + )); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | /** |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | * |
928 | 928 | * @return array |
929 | 929 | */ |
930 | - public function theme_js_settings(){ |
|
930 | + public function theme_js_settings() { |
|
931 | 931 | return array( |
932 | 932 | 'ayetheme' => 'popper', |
933 | 933 | 'listimia' => 'required', |
@@ -943,17 +943,17 @@ discard block |
||
943 | 943 | */ |
944 | 944 | public function get_settings() { |
945 | 945 | |
946 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
946 | + $db_settings = get_option('ayecode-ui-settings'); |
|
947 | 947 | $js_default = 'core-popper'; |
948 | 948 | $js_default_backend = $js_default; |
949 | 949 | |
950 | 950 | // maybe set defaults (if no settings set) |
951 | - if(empty($db_settings)){ |
|
952 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
951 | + if (empty($db_settings)) { |
|
952 | + $active_theme = strtolower(get_template()); // active parent theme. |
|
953 | 953 | $theme_js_settings = self::theme_js_settings(); |
954 | - if(isset($theme_js_settings[$active_theme])){ |
|
954 | + if (isset($theme_js_settings[$active_theme])) { |
|
955 | 955 | $js_default = $theme_js_settings[$active_theme]; |
956 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
956 | + $js_default_backend = isset($theme_js_settings[$active_theme . "_backend"]) ? $theme_js_settings[$active_theme . "_backend"] : $js_default; |
|
957 | 957 | } |
958 | 958 | } |
959 | 959 | |
@@ -966,14 +966,14 @@ discard block |
||
966 | 966 | 'disable_admin' => '', // URL snippets to disable loading on admin |
967 | 967 | ); |
968 | 968 | |
969 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
969 | + $settings = wp_parse_args($db_settings, $defaults); |
|
970 | 970 | |
971 | 971 | /** |
972 | 972 | * Filter the Bootstrap settings. |
973 | 973 | * |
974 | 974 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
975 | 975 | */ |
976 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
976 | + return $this->settings = apply_filters('ayecode-ui-settings', $settings, $db_settings, $defaults); |
|
977 | 977 | } |
978 | 978 | |
979 | 979 | |
@@ -981,90 +981,90 @@ discard block |
||
981 | 981 | * The settings page html output. |
982 | 982 | */ |
983 | 983 | public function settings_page() { |
984 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
985 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
984 | + if (!current_user_can('manage_options')) { |
|
985 | + wp_die(__('You do not have sufficient permissions to access this page.', 'aui')); |
|
986 | 986 | } |
987 | 987 | ?> |
988 | 988 | <div class="wrap"> |
989 | 989 | <h1><?php echo $this->name; ?></h1> |
990 | - <p><?php _e("Here you can adjust settings if you are having compatibility issues.","aui");?></p> |
|
990 | + <p><?php _e("Here you can adjust settings if you are having compatibility issues.", "aui"); ?></p> |
|
991 | 991 | <form method="post" action="options.php"> |
992 | 992 | <?php |
993 | - settings_fields( 'ayecode-ui-settings' ); |
|
994 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
993 | + settings_fields('ayecode-ui-settings'); |
|
994 | + do_settings_sections('ayecode-ui-settings'); |
|
995 | 995 | ?> |
996 | 996 | |
997 | - <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
|
997 | + <h2><?php _e('Frontend', 'aui'); ?></h2> |
|
998 | 998 | <table class="form-table wpbs-table-settings"> |
999 | 999 | <tr valign="top"> |
1000 | 1000 | <th scope="row"><label |
1001 | - for="wpbs-css"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1001 | + for="wpbs-css"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1002 | 1002 | <td> |
1003 | 1003 | <select name="ayecode-ui-settings[css]" id="wpbs-css"> |
1004 | - <option value="compatibility" <?php selected( $this->settings['css'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1005 | - <option value="core" <?php selected( $this->settings['css'], 'core' ); ?>><?php _e( 'Full Mode', 'aui' ); ?></option> |
|
1006 | - <option value="" <?php selected( $this->settings['css'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1004 | + <option value="compatibility" <?php selected($this->settings['css'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1005 | + <option value="core" <?php selected($this->settings['css'], 'core'); ?>><?php _e('Full Mode', 'aui'); ?></option> |
|
1006 | + <option value="" <?php selected($this->settings['css'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1007 | 1007 | </select> |
1008 | 1008 | </td> |
1009 | 1009 | </tr> |
1010 | 1010 | |
1011 | 1011 | <tr valign="top"> |
1012 | 1012 | <th scope="row"><label |
1013 | - for="wpbs-js"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1013 | + for="wpbs-js"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1014 | 1014 | <td> |
1015 | 1015 | <select name="ayecode-ui-settings[js]" id="wpbs-js"> |
1016 | - <option value="core-popper" <?php selected( $this->settings['js'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1017 | - <option value="popper" <?php selected( $this->settings['js'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1018 | - <option value="required" <?php selected( $this->settings['js'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1019 | - <option value="" <?php selected( $this->settings['js'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1016 | + <option value="core-popper" <?php selected($this->settings['js'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1017 | + <option value="popper" <?php selected($this->settings['js'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1018 | + <option value="required" <?php selected($this->settings['js'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1019 | + <option value="" <?php selected($this->settings['js'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1020 | 1020 | </select> |
1021 | 1021 | </td> |
1022 | 1022 | </tr> |
1023 | 1023 | |
1024 | 1024 | <tr valign="top"> |
1025 | 1025 | <th scope="row"><label |
1026 | - for="wpbs-font_size"><?php _e( 'HTML Font Size (px)', 'aui' ); ?></label></th> |
|
1026 | + for="wpbs-font_size"><?php _e('HTML Font Size (px)', 'aui'); ?></label></th> |
|
1027 | 1027 | <td> |
1028 | - <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint( $this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1029 | - <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.","aui");?></p> |
|
1028 | + <input type="number" name="ayecode-ui-settings[html_font_size]" id="wpbs-font_size" value="<?php echo absint($this->settings['html_font_size']); ?>" placeholder="16" /> |
|
1029 | + <p class="description" ><?php _e("Our font sizing is rem (responsive based) here you can set the html font size in-case your theme is setting it too low.", "aui"); ?></p> |
|
1030 | 1030 | </td> |
1031 | 1031 | </tr> |
1032 | 1032 | |
1033 | 1033 | </table> |
1034 | 1034 | |
1035 | - <h2><?php _e( 'Backend', 'aui' ); ?> (wp-admin)</h2> |
|
1035 | + <h2><?php _e('Backend', 'aui'); ?> (wp-admin)</h2> |
|
1036 | 1036 | <table class="form-table wpbs-table-settings"> |
1037 | 1037 | <tr valign="top"> |
1038 | 1038 | <th scope="row"><label |
1039 | - for="wpbs-css-admin"><?php _e( 'Load CSS', 'aui' ); ?></label></th> |
|
1039 | + for="wpbs-css-admin"><?php _e('Load CSS', 'aui'); ?></label></th> |
|
1040 | 1040 | <td> |
1041 | 1041 | <select name="ayecode-ui-settings[css_backend]" id="wpbs-css-admin"> |
1042 | - <option value="compatibility" <?php selected( $this->settings['css_backend'], 'compatibility' ); ?>><?php _e( 'Compatibility Mode (default)', 'aui' ); ?></option> |
|
1043 | - <option value="core" <?php selected( $this->settings['css_backend'], 'core' ); ?>><?php _e( 'Full Mode (will cause style issues)', 'aui' ); ?></option> |
|
1044 | - <option value="" <?php selected( $this->settings['css_backend'], '' ); ?>><?php _e( 'Disabled', 'aui' ); ?></option> |
|
1042 | + <option value="compatibility" <?php selected($this->settings['css_backend'], 'compatibility'); ?>><?php _e('Compatibility Mode (default)', 'aui'); ?></option> |
|
1043 | + <option value="core" <?php selected($this->settings['css_backend'], 'core'); ?>><?php _e('Full Mode (will cause style issues)', 'aui'); ?></option> |
|
1044 | + <option value="" <?php selected($this->settings['css_backend'], ''); ?>><?php _e('Disabled', 'aui'); ?></option> |
|
1045 | 1045 | </select> |
1046 | 1046 | </td> |
1047 | 1047 | </tr> |
1048 | 1048 | |
1049 | 1049 | <tr valign="top"> |
1050 | 1050 | <th scope="row"><label |
1051 | - for="wpbs-js-admin"><?php _e( 'Load JS', 'aui' ); ?></label></th> |
|
1051 | + for="wpbs-js-admin"><?php _e('Load JS', 'aui'); ?></label></th> |
|
1052 | 1052 | <td> |
1053 | 1053 | <select name="ayecode-ui-settings[js_backend]" id="wpbs-js-admin"> |
1054 | - <option value="core-popper" <?php selected( $this->settings['js_backend'], 'core-popper' ); ?>><?php _e( 'Core + Popper (default)', 'aui' ); ?></option> |
|
1055 | - <option value="popper" <?php selected( $this->settings['js_backend'], 'popper' ); ?>><?php _e( 'Popper', 'aui' ); ?></option> |
|
1056 | - <option value="required" <?php selected( $this->settings['js_backend'], 'required' ); ?>><?php _e( 'Required functions only', 'aui' ); ?></option> |
|
1057 | - <option value="" <?php selected( $this->settings['js_backend'], '' ); ?>><?php _e( 'Disabled (not recommended)', 'aui' ); ?></option> |
|
1054 | + <option value="core-popper" <?php selected($this->settings['js_backend'], 'core-popper'); ?>><?php _e('Core + Popper (default)', 'aui'); ?></option> |
|
1055 | + <option value="popper" <?php selected($this->settings['js_backend'], 'popper'); ?>><?php _e('Popper', 'aui'); ?></option> |
|
1056 | + <option value="required" <?php selected($this->settings['js_backend'], 'required'); ?>><?php _e('Required functions only', 'aui'); ?></option> |
|
1057 | + <option value="" <?php selected($this->settings['js_backend'], ''); ?>><?php _e('Disabled (not recommended)', 'aui'); ?></option> |
|
1058 | 1058 | </select> |
1059 | 1059 | </td> |
1060 | 1060 | </tr> |
1061 | 1061 | |
1062 | 1062 | <tr valign="top"> |
1063 | 1063 | <th scope="row"><label |
1064 | - for="wpbs-disable-admin"><?php _e( 'Disable load on URL', 'aui' ); ?></label></th> |
|
1064 | + for="wpbs-disable-admin"><?php _e('Disable load on URL', 'aui'); ?></label></th> |
|
1065 | 1065 | <td> |
1066 | - <p><?php _e( 'If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui' ); ?></p> |
|
1067 | - <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin'];?></textarea> |
|
1066 | + <p><?php _e('If you have backend conflict you can enter a partial URL argument that will disable the loading of AUI on those pages. Add each argument on a new line.', 'aui'); ?></p> |
|
1067 | + <textarea name="ayecode-ui-settings[disable_admin]" rows="10" cols="50" id="wpbs-disable-admin" class="large-text code" spellcheck="false" placeholder="myplugin.php action=go"><?php echo $this->settings['disable_admin']; ?></textarea> |
|
1068 | 1068 | |
1069 | 1069 | </td> |
1070 | 1070 | </tr> |
@@ -1082,9 +1082,9 @@ discard block |
||
1082 | 1082 | <?php |
1083 | 1083 | } |
1084 | 1084 | |
1085 | - public function customizer_settings($wp_customize){ |
|
1085 | + public function customizer_settings($wp_customize) { |
|
1086 | 1086 | $wp_customize->add_section('aui_settings', array( |
1087 | - 'title' => __('AyeCode UI','aui'), |
|
1087 | + 'title' => __('AyeCode UI', 'aui'), |
|
1088 | 1088 | 'priority' => 120, |
1089 | 1089 | )); |
1090 | 1090 | |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | 'type' => 'option', |
1099 | 1099 | 'transport' => 'refresh', |
1100 | 1100 | )); |
1101 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1102 | - 'label' => __('Primary Color','aui'), |
|
1101 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1102 | + 'label' => __('Primary Color', 'aui'), |
|
1103 | 1103 | 'section' => 'aui_settings', |
1104 | 1104 | 'settings' => 'aui_options[color_primary]', |
1105 | 1105 | ))); |
@@ -1111,8 +1111,8 @@ discard block |
||
1111 | 1111 | 'type' => 'option', |
1112 | 1112 | 'transport' => 'refresh', |
1113 | 1113 | )); |
1114 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1115 | - 'label' => __('Secondary Color','aui'), |
|
1114 | + $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1115 | + 'label' => __('Secondary Color', 'aui'), |
|
1116 | 1116 | 'section' => 'aui_settings', |
1117 | 1117 | 'settings' => 'aui_options[color_secondary]', |
1118 | 1118 | ))); |
@@ -1138,12 +1138,12 @@ discard block |
||
1138 | 1138 | .collapse.show:not(.in){display: inherit;} |
1139 | 1139 | .fade.show{opacity: 1;} |
1140 | 1140 | |
1141 | - <?php if( defined( 'SVQ_THEME_VERSION' ) ){ ?> |
|
1141 | + <?php if (defined('SVQ_THEME_VERSION')) { ?> |
|
1142 | 1142 | /* KLEO theme specific */ |
1143 | 1143 | .kleo-main-header .navbar-collapse.collapse.show:not(.in){display: inherit !important;} |
1144 | 1144 | <?php } ?> |
1145 | 1145 | |
1146 | - <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
|
1146 | + <?php if (defined('FUSION_BUILDER_VERSION')) { ?> |
|
1147 | 1147 | /* With Avada builder */ |
1148 | 1148 | body.modal-open .modal.in {opacity:1;z-index: 99999} |
1149 | 1149 | body.modal-open .modal.bsui.in .modal-content {box-shadow: none;} |
@@ -1151,7 +1151,7 @@ discard block |
||
1151 | 1151 | <?php } ?> |
1152 | 1152 | </style> |
1153 | 1153 | <?php |
1154 | - return str_replace( array( |
|
1154 | + return str_replace(array( |
|
1155 | 1155 | '<style>', |
1156 | 1156 | '</style>' |
1157 | 1157 | ), '', ob_get_clean()); |
@@ -1171,16 +1171,16 @@ discard block |
||
1171 | 1171 | <?php |
1172 | 1172 | |
1173 | 1173 | // BS v3 compat |
1174 | - if( self::is_bs3_compat() ){ |
|
1174 | + if (self::is_bs3_compat()) { |
|
1175 | 1175 | echo self::bs3_compat_css(); |
1176 | 1176 | } |
1177 | 1177 | |
1178 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1179 | - echo self::css_primary($primary_color,$compatibility); |
|
1178 | + if (!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL) { |
|
1179 | + echo self::css_primary($primary_color, $compatibility); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1183 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1182 | + if (!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL) { |
|
1183 | + echo self::css_secondary($settings['color_secondary'], $compatibility); |
|
1184 | 1184 | } |
1185 | 1185 | ?> |
1186 | 1186 | </style> |
@@ -1190,7 +1190,7 @@ discard block |
||
1190 | 1190 | /* |
1191 | 1191 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1192 | 1192 | */ |
1193 | - return str_replace( array( |
|
1193 | + return str_replace(array( |
|
1194 | 1194 | '<style>', |
1195 | 1195 | '</style>' |
1196 | 1196 | ), '', ob_get_clean()); |
@@ -1201,48 +1201,48 @@ discard block |
||
1201 | 1201 | * |
1202 | 1202 | * @return bool |
1203 | 1203 | */ |
1204 | - public static function is_bs3_compat(){ |
|
1204 | + public static function is_bs3_compat() { |
|
1205 | 1205 | return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
1206 | 1206 | } |
1207 | 1207 | |
1208 | - public static function css_primary($color_code,$compatibility){; |
|
1208 | + public static function css_primary($color_code, $compatibility) {; |
|
1209 | 1209 | $color_code = sanitize_hex_color($color_code); |
1210 | - if(!$color_code){return '';} |
|
1210 | + if (!$color_code) {return ''; } |
|
1211 | 1211 | /** |
1212 | 1212 | * c = color, b = background color, o = border-color, f = fill |
1213 | 1213 | */ |
1214 | 1214 | $selectors = array( |
1215 | 1215 | 'a' => array('c'), |
1216 | - '.btn-primary' => array('b','o'), |
|
1217 | - '.btn-primary.disabled' => array('b','o'), |
|
1218 | - '.btn-primary:disabled' => array('b','o'), |
|
1219 | - '.btn-outline-primary' => array('c','o'), |
|
1220 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1221 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1222 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1223 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1216 | + '.btn-primary' => array('b', 'o'), |
|
1217 | + '.btn-primary.disabled' => array('b', 'o'), |
|
1218 | + '.btn-primary:disabled' => array('b', 'o'), |
|
1219 | + '.btn-outline-primary' => array('c', 'o'), |
|
1220 | + '.btn-outline-primary:hover' => array('b', 'o'), |
|
1221 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1222 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1223 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b', 'o'), |
|
1224 | 1224 | '.btn-link' => array('c'), |
1225 | 1225 | '.dropdown-item.active' => array('b'), |
1226 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1227 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1226 | + '.custom-control-input:checked~.custom-control-label::before' => array('b', 'o'), |
|
1227 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b', 'o'), |
|
1228 | 1228 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1229 | 1229 | // '.custom-range::-moz-range-thumb' => array('b'), |
1230 | 1230 | // '.custom-range::-ms-thumb' => array('b'), |
1231 | 1231 | '.nav-pills .nav-link.active' => array('b'), |
1232 | 1232 | '.nav-pills .show>.nav-link' => array('b'), |
1233 | 1233 | '.page-link' => array('c'), |
1234 | - '.page-item.active .page-link' => array('b','o'), |
|
1234 | + '.page-item.active .page-link' => array('b', 'o'), |
|
1235 | 1235 | '.badge-primary' => array('b'), |
1236 | - '.alert-primary' => array('b','o'), |
|
1236 | + '.alert-primary' => array('b', 'o'), |
|
1237 | 1237 | '.progress-bar' => array('b'), |
1238 | - '.list-group-item.active' => array('b','o'), |
|
1239 | - '.bg-primary' => array('b','f'), |
|
1238 | + '.list-group-item.active' => array('b', 'o'), |
|
1239 | + '.bg-primary' => array('b', 'f'), |
|
1240 | 1240 | '.btn-link.btn-primary' => array('c'), |
1241 | 1241 | '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
1242 | 1242 | ); |
1243 | 1243 | |
1244 | 1244 | $important_selectors = array( |
1245 | - '.bg-primary' => array('b','f'), |
|
1245 | + '.bg-primary' => array('b', 'f'), |
|
1246 | 1246 | '.border-primary' => array('o'), |
1247 | 1247 | '.text-primary' => array('c'), |
1248 | 1248 | ); |
@@ -1259,116 +1259,116 @@ discard block |
||
1259 | 1259 | $output = ''; |
1260 | 1260 | |
1261 | 1261 | // build rules into each type |
1262 | - foreach($selectors as $selector => $types){ |
|
1263 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1264 | - $types = array_combine($types,$types); |
|
1265 | - if(isset($types['c'])){$color[] = $selector;} |
|
1266 | - if(isset($types['b'])){$background[] = $selector;} |
|
1267 | - if(isset($types['o'])){$border[] = $selector;} |
|
1268 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1262 | + foreach ($selectors as $selector => $types) { |
|
1263 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1264 | + $types = array_combine($types, $types); |
|
1265 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1266 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1267 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1268 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1269 | 1269 | } |
1270 | 1270 | |
1271 | 1271 | // build rules into each type |
1272 | - foreach($important_selectors as $selector => $types){ |
|
1273 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1274 | - $types = array_combine($types,$types); |
|
1275 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1276 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1277 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1278 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1272 | + foreach ($important_selectors as $selector => $types) { |
|
1273 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1274 | + $types = array_combine($types, $types); |
|
1275 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1276 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1277 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1278 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | // add any color rules |
1282 | - if(!empty($color)){ |
|
1283 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1282 | + if (!empty($color)) { |
|
1283 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1284 | 1284 | } |
1285 | - if(!empty($color_i)){ |
|
1286 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1285 | + if (!empty($color_i)) { |
|
1286 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | // add any background color rules |
1290 | - if(!empty($background)){ |
|
1291 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1290 | + if (!empty($background)) { |
|
1291 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1292 | 1292 | } |
1293 | - if(!empty($background_i)){ |
|
1294 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1293 | + if (!empty($background_i)) { |
|
1294 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1295 | 1295 | } |
1296 | 1296 | |
1297 | 1297 | // add any border color rules |
1298 | - if(!empty($border)){ |
|
1299 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1298 | + if (!empty($border)) { |
|
1299 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1300 | 1300 | } |
1301 | - if(!empty($border_i)){ |
|
1302 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1301 | + if (!empty($border_i)) { |
|
1302 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1303 | 1303 | } |
1304 | 1304 | |
1305 | 1305 | // add any fill color rules |
1306 | - if(!empty($fill)){ |
|
1307 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1306 | + if (!empty($fill)) { |
|
1307 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1308 | 1308 | } |
1309 | - if(!empty($fill_i)){ |
|
1310 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1309 | + if (!empty($fill_i)) { |
|
1310 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
1314 | 1314 | $prefix = $compatibility ? ".bsui " : ""; |
1315 | 1315 | |
1316 | 1316 | // darken |
1317 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1318 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1319 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1317 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1318 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1319 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1320 | 1320 | |
1321 | 1321 | // lighten |
1322 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1322 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1323 | 1323 | |
1324 | 1324 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1325 | - $op_25 = $color_code."40"; // 25% opacity |
|
1325 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1326 | 1326 | |
1327 | 1327 | |
1328 | 1328 | // button states |
1329 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1330 | - $output .= $prefix ." .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1331 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1332 | - $output .= $prefix ." .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1329 | + $output .= $prefix . " .btn-primary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1330 | + $output .= $prefix . " .btn-outline-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-primary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1331 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active, $prefix .btn-primary:not(:disabled):not(.disabled).active, .show>$prefix .btn-primary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1332 | + $output .= $prefix . " .btn-primary:not(:disabled):not(.disabled):active:focus, $prefix .btn-primary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-primary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1333 | 1333 | |
1334 | 1334 | |
1335 | 1335 | // dropdown's |
1336 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1336 | + $output .= $prefix . " .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1337 | 1337 | |
1338 | 1338 | |
1339 | 1339 | // input states |
1340 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1340 | + $output .= $prefix . " .form-control:focus{border-color: " . $lighten_25 . ";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1341 | 1341 | |
1342 | 1342 | // page link |
1343 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1343 | + $output .= $prefix . " .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1344 | 1344 | |
1345 | 1345 | return $output; |
1346 | 1346 | } |
1347 | 1347 | |
1348 | - public static function css_secondary($color_code,$compatibility){; |
|
1348 | + public static function css_secondary($color_code, $compatibility) {; |
|
1349 | 1349 | $color_code = sanitize_hex_color($color_code); |
1350 | - if(!$color_code){return '';} |
|
1350 | + if (!$color_code) {return ''; } |
|
1351 | 1351 | /** |
1352 | 1352 | * c = color, b = background color, o = border-color, f = fill |
1353 | 1353 | */ |
1354 | 1354 | $selectors = array( |
1355 | - '.btn-secondary' => array('b','o'), |
|
1356 | - '.btn-secondary.disabled' => array('b','o'), |
|
1357 | - '.btn-secondary:disabled' => array('b','o'), |
|
1358 | - '.btn-outline-secondary' => array('c','o'), |
|
1359 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1355 | + '.btn-secondary' => array('b', 'o'), |
|
1356 | + '.btn-secondary.disabled' => array('b', 'o'), |
|
1357 | + '.btn-secondary:disabled' => array('b', 'o'), |
|
1358 | + '.btn-outline-secondary' => array('c', 'o'), |
|
1359 | + '.btn-outline-secondary:hover' => array('b', 'o'), |
|
1360 | 1360 | '.btn-outline-secondary.disabled' => array('c'), |
1361 | 1361 | '.btn-outline-secondary:disabled' => array('c'), |
1362 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1363 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1364 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1362 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b', 'o'), |
|
1363 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b', 'o'), |
|
1364 | + '.btn-outline-secondary.dropdown-toggle' => array('b', 'o'), |
|
1365 | 1365 | '.badge-secondary' => array('b'), |
1366 | - '.alert-secondary' => array('b','o'), |
|
1366 | + '.alert-secondary' => array('b', 'o'), |
|
1367 | 1367 | '.btn-link.btn-secondary' => array('c'), |
1368 | 1368 | ); |
1369 | 1369 | |
1370 | 1370 | $important_selectors = array( |
1371 | - '.bg-secondary' => array('b','f'), |
|
1371 | + '.bg-secondary' => array('b', 'f'), |
|
1372 | 1372 | '.border-secondary' => array('o'), |
1373 | 1373 | '.text-secondary' => array('c'), |
1374 | 1374 | ); |
@@ -1385,77 +1385,77 @@ discard block |
||
1385 | 1385 | $output = ''; |
1386 | 1386 | |
1387 | 1387 | // build rules into each type |
1388 | - foreach($selectors as $selector => $types){ |
|
1389 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1390 | - $types = array_combine($types,$types); |
|
1391 | - if(isset($types['c'])){$color[] = $selector;} |
|
1392 | - if(isset($types['b'])){$background[] = $selector;} |
|
1393 | - if(isset($types['o'])){$border[] = $selector;} |
|
1394 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1388 | + foreach ($selectors as $selector => $types) { |
|
1389 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1390 | + $types = array_combine($types, $types); |
|
1391 | + if (isset($types['c'])) {$color[] = $selector; } |
|
1392 | + if (isset($types['b'])) {$background[] = $selector; } |
|
1393 | + if (isset($types['o'])) {$border[] = $selector; } |
|
1394 | + if (isset($types['f'])) {$fill[] = $selector; } |
|
1395 | 1395 | } |
1396 | 1396 | |
1397 | 1397 | // build rules into each type |
1398 | - foreach($important_selectors as $selector => $types){ |
|
1399 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1400 | - $types = array_combine($types,$types); |
|
1401 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1402 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1403 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1404 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1398 | + foreach ($important_selectors as $selector => $types) { |
|
1399 | + $selector = $compatibility ? ".bsui " . $selector : $selector; |
|
1400 | + $types = array_combine($types, $types); |
|
1401 | + if (isset($types['c'])) {$color_i[] = $selector; } |
|
1402 | + if (isset($types['b'])) {$background_i[] = $selector; } |
|
1403 | + if (isset($types['o'])) {$border_i[] = $selector; } |
|
1404 | + if (isset($types['f'])) {$fill_i[] = $selector; } |
|
1405 | 1405 | } |
1406 | 1406 | |
1407 | 1407 | // add any color rules |
1408 | - if(!empty($color)){ |
|
1409 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1408 | + if (!empty($color)) { |
|
1409 | + $output .= implode(",", $color) . "{color: $color_code;} "; |
|
1410 | 1410 | } |
1411 | - if(!empty($color_i)){ |
|
1412 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1411 | + if (!empty($color_i)) { |
|
1412 | + $output .= implode(",", $color_i) . "{color: $color_code !important;} "; |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | 1415 | // add any background color rules |
1416 | - if(!empty($background)){ |
|
1417 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1416 | + if (!empty($background)) { |
|
1417 | + $output .= implode(",", $background) . "{background-color: $color_code;} "; |
|
1418 | 1418 | } |
1419 | - if(!empty($background_i)){ |
|
1420 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1419 | + if (!empty($background_i)) { |
|
1420 | + $output .= implode(",", $background_i) . "{background-color: $color_code !important;} "; |
|
1421 | 1421 | } |
1422 | 1422 | |
1423 | 1423 | // add any border color rules |
1424 | - if(!empty($border)){ |
|
1425 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1424 | + if (!empty($border)) { |
|
1425 | + $output .= implode(",", $border) . "{border-color: $color_code;} "; |
|
1426 | 1426 | } |
1427 | - if(!empty($border_i)){ |
|
1428 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1427 | + if (!empty($border_i)) { |
|
1428 | + $output .= implode(",", $border_i) . "{border-color: $color_code !important;} "; |
|
1429 | 1429 | } |
1430 | 1430 | |
1431 | 1431 | // add any fill color rules |
1432 | - if(!empty($fill)){ |
|
1433 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1432 | + if (!empty($fill)) { |
|
1433 | + $output .= implode(",", $fill) . "{fill: $color_code;} "; |
|
1434 | 1434 | } |
1435 | - if(!empty($fill_i)){ |
|
1436 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1435 | + if (!empty($fill_i)) { |
|
1436 | + $output .= implode(",", $fill_i) . "{fill: $color_code !important;} "; |
|
1437 | 1437 | } |
1438 | 1438 | |
1439 | 1439 | |
1440 | 1440 | $prefix = $compatibility ? ".bsui " : ""; |
1441 | 1441 | |
1442 | 1442 | // darken |
1443 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1444 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1445 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1443 | + $darker_075 = self::css_hex_lighten_darken($color_code, "-0.075"); |
|
1444 | + $darker_10 = self::css_hex_lighten_darken($color_code, "-0.10"); |
|
1445 | + $darker_125 = self::css_hex_lighten_darken($color_code, "-0.125"); |
|
1446 | 1446 | |
1447 | 1447 | // lighten |
1448 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1448 | + $lighten_25 = self::css_hex_lighten_darken($color_code, "0.25"); |
|
1449 | 1449 | |
1450 | 1450 | // opacity see https://css-tricks.com/8-digit-hex-codes/ |
1451 | - $op_25 = $color_code."40"; // 25% opacity |
|
1451 | + $op_25 = $color_code . "40"; // 25% opacity |
|
1452 | 1452 | |
1453 | 1453 | |
1454 | 1454 | // button states |
1455 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1456 | - $output .= $prefix ." .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1457 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: ".$darker_10."; border-color: ".$darker_125.";} "; |
|
1458 | - $output .= $prefix ." .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1455 | + $output .= $prefix . " .btn-secondary:hover{background-color: " . $darker_075 . "; border-color: " . $darker_10 . ";} "; |
|
1456 | + $output .= $prefix . " .btn-outline-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-outline-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-outline-secondary.dropdown-toggle:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1457 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active, $prefix .btn-secondary:not(:disabled):not(.disabled).active, .show>$prefix .btn-secondary.dropdown-toggle{background-color: " . $darker_10 . "; border-color: " . $darker_125 . ";} "; |
|
1458 | + $output .= $prefix . " .btn-secondary:not(:disabled):not(.disabled):active:focus, $prefix .btn-secondary:not(:disabled):not(.disabled).active:focus, .show>$prefix .btn-secondary.dropdown-toggle:focus {box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1459 | 1459 | |
1460 | 1460 | |
1461 | 1461 | return $output; |
@@ -1491,8 +1491,8 @@ discard block |
||
1491 | 1491 | /** |
1492 | 1492 | * Check if we should display examples. |
1493 | 1493 | */ |
1494 | - public function maybe_show_examples(){ |
|
1495 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1494 | + public function maybe_show_examples() { |
|
1495 | + if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) { |
|
1496 | 1496 | echo "<head>"; |
1497 | 1497 | wp_head(); |
1498 | 1498 | echo "</head>"; |
@@ -1508,7 +1508,7 @@ discard block |
||
1508 | 1508 | * |
1509 | 1509 | * @return string |
1510 | 1510 | */ |
1511 | - public function get_examples(){ |
|
1511 | + public function get_examples() { |
|
1512 | 1512 | $output = ''; |
1513 | 1513 | |
1514 | 1514 |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | global $wpi_invoice; |
3 | 3 | |
4 | 4 | // Backwards compatibility. |
5 | -if ( empty( $invoice ) ) { |
|
5 | +if (empty($invoice)) { |
|
6 | 6 | $invoice = $wpi_invoice; |
7 | 7 | } |
8 | 8 | |
9 | 9 | $success_page_uri = wpinv_get_success_page_uri(); |
10 | -if ( ! empty( $invoice ) ) { |
|
10 | +if (!empty($invoice)) { |
|
11 | 11 | $success_page_uri = $invoice->get_receipt_url(); |
12 | 12 | } |
13 | 13 | ?> |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | <?php |
18 | 18 | echo |
19 | 19 | wp_sprintf( |
20 | - __( 'Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing' ), |
|
21 | - esc_url( $success_page_uri ) |
|
20 | + __('Your payment is processing. This page will reload automatically in 10 seconds. If it does not, click <a href="%s">here</a>.', 'invoicing'), |
|
21 | + esc_url($success_page_uri) |
|
22 | 22 | ); |
23 | 23 | ?> |
24 | 24 | <i class="fa fa-spin fa-refresh"></i> |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | <script type="text/javascript"> |
28 | 28 | setTimeout( |
29 | 29 | function(){ |
30 | - window.location = '<?php echo esc_url( $success_page_uri ); ?>'; |
|
30 | + window.location = '<?php echo esc_url($success_page_uri); ?>'; |
|
31 | 31 | }, |
32 | 32 | 10000 |
33 | 33 | ); |
@@ -7,14 +7,14 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div v-if='!is_default'> |
15 | - <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here. Click to set items.', 'invoicing' ) ?></div> |
|
15 | + <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here. Click to set items.', 'invoicing') ?></div> |
|
16 | 16 | </div> |
17 | 17 | |
18 | 18 | <div v-if='is_default'> |
19 | - <div class='alert alert-info' role='alert'><?php _e( 'Item totals will appear here.', 'invoicing' ) ?></div> |
|
19 | + <div class='alert alert-info' role='alert'><?php _e('Item totals will appear here.', 'invoicing') ?></div> |
|
20 | 20 | </div> |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @var array $fee |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
@@ -19,61 +19,61 @@ discard block |
||
19 | 19 | |
20 | 20 | <div class="form-row"> |
21 | 21 | |
22 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
22 | + <?php foreach (array_keys($columns) as $column): ?> |
|
23 | 23 | |
24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
25 | 25 | |
26 | 26 | <?php |
27 | 27 | |
28 | 28 | // Fires before printing a fee item column. |
29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
30 | 30 | |
31 | 31 | // Item name. |
32 | - if ( 'name' == $column ) { |
|
32 | + if ('name' == $column) { |
|
33 | 33 | |
34 | 34 | // Display the name. |
35 | - echo '<div class="mb-1">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
35 | + echo '<div class="mb-1">' . sanitize_text_field($fee['name']) . '</div>'; |
|
36 | 36 | |
37 | 37 | // And an optional description. |
38 | - $description = esc_html__( 'Fee', 'invoicing' ); |
|
38 | + $description = esc_html__('Fee', 'invoicing'); |
|
39 | 39 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Item price. |
44 | - if ( 'price' == $column ) { |
|
44 | + if ('price' == $column) { |
|
45 | 45 | |
46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
48 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
48 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
49 | 49 | } else { |
50 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
50 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo "—"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Item sub total. |
61 | - if ( 'subtotal' == $column ) { |
|
61 | + if ('subtotal' == $column) { |
|
62 | 62 | |
63 | 63 | // Display the item price (or recurring price if this is a renewal invoice) |
64 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
65 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
64 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
65 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
66 | 66 | } else { |
67 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
67 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Fires when printing a fee item column. |
73 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
73 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
74 | 74 | |
75 | 75 | // Fires after printing a fee item column. |
76 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
76 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
77 | 77 | |
78 | 78 | ?> |
79 | 79 |