@@ -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,236 +21,236 @@ 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 = '0.1.49'; |
|
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 | - |
|
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 | - // check if specifically disabled |
|
179 | - if(!empty($this->settings['disable_admin'])){ |
|
180 | - $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | - foreach($url_parts as $part){ |
|
182 | - if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
183 | - return false; // return early, no point checking further |
|
184 | - } |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - return $result; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Add a html font size to the footer. |
|
193 | - */ |
|
194 | - public function html_font_size(){ |
|
195 | - $this->settings = $this->get_settings(); |
|
196 | - echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | - } |
|
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 = '0.1.49'; |
|
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 | + } |
|
198 | 114 | |
199 | - /** |
|
200 | - * Check if the current admin screen should load scripts. |
|
201 | - * |
|
202 | - * @return bool |
|
203 | - */ |
|
204 | - public function is_aui_screen(){ |
|
205 | - $load = false; |
|
206 | - // check if we should load or not |
|
207 | - if ( is_admin() ) { |
|
208 | - // Only enable on set pages |
|
209 | - $aui_screens = array( |
|
210 | - 'page', |
|
211 | - 'post', |
|
212 | - 'settings_page_ayecode-ui-settings', |
|
213 | - 'appearance_page_gutenberg-widgets' |
|
214 | - ); |
|
215 | - $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | - |
|
217 | - $screen = get_current_screen(); |
|
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 | + // check if specifically disabled |
|
179 | + if(!empty($this->settings['disable_admin'])){ |
|
180 | + $url_parts = explode("\n",$this->settings['disable_admin']); |
|
181 | + foreach($url_parts as $part){ |
|
182 | + if( strpos($_SERVER['REQUEST_URI'], trim($part)) !== false ){ |
|
183 | + return false; // return early, no point checking further |
|
184 | + } |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + return $result; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * Add a html font size to the footer. |
|
193 | + */ |
|
194 | + public function html_font_size(){ |
|
195 | + $this->settings = $this->get_settings(); |
|
196 | + echo "<style>html{font-size:".absint($this->settings['html_font_size'])."px;}</style>"; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Check if the current admin screen should load scripts. |
|
201 | + * |
|
202 | + * @return bool |
|
203 | + */ |
|
204 | + public function is_aui_screen(){ |
|
205 | + $load = false; |
|
206 | + // check if we should load or not |
|
207 | + if ( is_admin() ) { |
|
208 | + // Only enable on set pages |
|
209 | + $aui_screens = array( |
|
210 | + 'page', |
|
211 | + 'post', |
|
212 | + 'settings_page_ayecode-ui-settings', |
|
213 | + 'appearance_page_gutenberg-widgets' |
|
214 | + ); |
|
215 | + $screen_ids = apply_filters( 'aui_screen_ids', $aui_screens ); |
|
216 | + |
|
217 | + $screen = get_current_screen(); |
|
218 | 218 | |
219 | 219 | // echo '###'.$screen->id; |
220 | 220 | |
221 | - if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | - $load = true; |
|
223 | - } |
|
224 | - } |
|
221 | + if ( $screen && in_array( $screen->id, $screen_ids ) ) { |
|
222 | + $load = true; |
|
223 | + } |
|
224 | + } |
|
225 | 225 | |
226 | - return $load; |
|
227 | - } |
|
226 | + return $load; |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * Adds the styles. |
|
231 | - */ |
|
232 | - public function enqueue_style() { |
|
229 | + /** |
|
230 | + * Adds the styles. |
|
231 | + */ |
|
232 | + public function enqueue_style() { |
|
233 | 233 | |
234 | - if( is_admin() && !$this->is_aui_screen()){ |
|
235 | - // don't add wp-admin scripts if not requested to |
|
236 | - }else{ |
|
237 | - $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
234 | + if( is_admin() && !$this->is_aui_screen()){ |
|
235 | + // don't add wp-admin scripts if not requested to |
|
236 | + }else{ |
|
237 | + $css_setting = current_action() == 'wp_enqueue_scripts' ? 'css' : 'css_backend'; |
|
238 | 238 | |
239 | - $rtl = is_rtl() ? '-rtl' : ''; |
|
239 | + $rtl = is_rtl() ? '-rtl' : ''; |
|
240 | 240 | |
241 | - if($this->settings[$css_setting]){ |
|
242 | - $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | - $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | - wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | - wp_enqueue_style( 'ayecode-ui' ); |
|
241 | + if($this->settings[$css_setting]){ |
|
242 | + $compatibility = $this->settings[$css_setting]=='core' ? false : true; |
|
243 | + $url = $this->settings[$css_setting]=='core' ? $this->url.'assets/css/ayecode-ui'.$rtl.'.css' : $this->url.'assets/css/ayecode-ui-compatibility'.$rtl.'.css'; |
|
244 | + wp_register_style( 'ayecode-ui', $url, array(), $this->latest ); |
|
245 | + wp_enqueue_style( 'ayecode-ui' ); |
|
246 | 246 | |
247 | - // flatpickr |
|
248 | - wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
247 | + // flatpickr |
|
248 | + wp_register_style( 'flatpickr', $this->url.'assets/css/flatpickr.min.css', array(), $this->latest ); |
|
249 | 249 | |
250 | 250 | |
251 | - // fix some wp-admin issues |
|
252 | - if(is_admin()){ |
|
253 | - $custom_css = " |
|
251 | + // fix some wp-admin issues |
|
252 | + if(is_admin()){ |
|
253 | + $custom_css = " |
|
254 | 254 | body{ |
255 | 255 | background-color: #f1f1f1; |
256 | 256 | font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif; |
@@ -292,35 +292,35 @@ discard block |
||
292 | 292 | } |
293 | 293 | "; |
294 | 294 | |
295 | - // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
296 | - $custom_css .= " |
|
295 | + // @todo, remove once fixed :: fix for this bug https://github.com/WordPress/gutenberg/issues/14377 |
|
296 | + $custom_css .= " |
|
297 | 297 | .edit-post-sidebar input[type=color].components-text-control__input{ |
298 | 298 | padding: 0; |
299 | 299 | } |
300 | 300 | "; |
301 | - wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
302 | - } |
|
301 | + wp_add_inline_style( 'ayecode-ui', $custom_css ); |
|
302 | + } |
|
303 | 303 | |
304 | - // custom changes |
|
305 | - wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
304 | + // custom changes |
|
305 | + wp_add_inline_style( 'ayecode-ui', self::custom_css($compatibility) ); |
|
306 | 306 | |
307 | - } |
|
308 | - } |
|
307 | + } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Get inline script used if bootstrap enqueued |
|
315 | + * |
|
316 | + * If this remains small then its best to use this than to add another JS file. |
|
317 | + */ |
|
318 | + public function inline_script() { |
|
319 | + // Flatpickr calendar locale |
|
320 | + $flatpickr_locale = self::flatpickr_locale(); |
|
312 | 321 | |
313 | - /** |
|
314 | - * Get inline script used if bootstrap enqueued |
|
315 | - * |
|
316 | - * If this remains small then its best to use this than to add another JS file. |
|
317 | - */ |
|
318 | - public function inline_script() { |
|
319 | - // Flatpickr calendar locale |
|
320 | - $flatpickr_locale = self::flatpickr_locale(); |
|
321 | - |
|
322 | - ob_start(); |
|
323 | - ?> |
|
322 | + ob_start(); |
|
323 | + ?> |
|
324 | 324 | <script> |
325 | 325 | /** |
326 | 326 | * An AUI bootstrap adaptation of GreedyNav.js ( by Luke Jackson ). |
@@ -985,29 +985,29 @@ discard block |
||
985 | 985 | |
986 | 986 | </script> |
987 | 987 | <?php |
988 | - $output = ob_get_clean(); |
|
988 | + $output = ob_get_clean(); |
|
989 | 989 | |
990 | 990 | |
991 | 991 | |
992 | - /* |
|
992 | + /* |
|
993 | 993 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
994 | 994 | */ |
995 | - return str_replace( array( |
|
996 | - '<script>', |
|
997 | - '</script>' |
|
998 | - ), '', self::minify_js($output) ); |
|
999 | - } |
|
1000 | - |
|
1001 | - |
|
1002 | - /** |
|
1003 | - * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1004 | - * |
|
1005 | - * @TODO we may need this when other conflicts arrise. |
|
1006 | - * @return mixed |
|
1007 | - */ |
|
1008 | - public static function bs3_compat_js() { |
|
1009 | - ob_start(); |
|
1010 | - ?> |
|
995 | + return str_replace( array( |
|
996 | + '<script>', |
|
997 | + '</script>' |
|
998 | + ), '', self::minify_js($output) ); |
|
999 | + } |
|
1000 | + |
|
1001 | + |
|
1002 | + /** |
|
1003 | + * JS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1004 | + * |
|
1005 | + * @TODO we may need this when other conflicts arrise. |
|
1006 | + * @return mixed |
|
1007 | + */ |
|
1008 | + public static function bs3_compat_js() { |
|
1009 | + ob_start(); |
|
1010 | + ?> |
|
1011 | 1011 | <script> |
1012 | 1012 | <?php if( defined( 'FUSION_BUILDER_VERSION' ) ){ ?> |
1013 | 1013 | /* With Avada builder */ |
@@ -1015,20 +1015,20 @@ discard block |
||
1015 | 1015 | <?php } ?> |
1016 | 1016 | </script> |
1017 | 1017 | <?php |
1018 | - return str_replace( array( |
|
1019 | - '<script>', |
|
1020 | - '</script>' |
|
1021 | - ), '', ob_get_clean()); |
|
1022 | - } |
|
1023 | - |
|
1024 | - /** |
|
1025 | - * Get inline script used if bootstrap file browser enqueued. |
|
1026 | - * |
|
1027 | - * If this remains small then its best to use this than to add another JS file. |
|
1028 | - */ |
|
1029 | - public function inline_script_file_browser(){ |
|
1030 | - ob_start(); |
|
1031 | - ?> |
|
1018 | + return str_replace( array( |
|
1019 | + '<script>', |
|
1020 | + '</script>' |
|
1021 | + ), '', ob_get_clean()); |
|
1022 | + } |
|
1023 | + |
|
1024 | + /** |
|
1025 | + * Get inline script used if bootstrap file browser enqueued. |
|
1026 | + * |
|
1027 | + * If this remains small then its best to use this than to add another JS file. |
|
1028 | + */ |
|
1029 | + public function inline_script_file_browser(){ |
|
1030 | + ob_start(); |
|
1031 | + ?> |
|
1032 | 1032 | <script> |
1033 | 1033 | // run on doc ready |
1034 | 1034 | jQuery(document).ready(function () { |
@@ -1036,192 +1036,192 @@ discard block |
||
1036 | 1036 | }); |
1037 | 1037 | </script> |
1038 | 1038 | <?php |
1039 | - $output = ob_get_clean(); |
|
1039 | + $output = ob_get_clean(); |
|
1040 | 1040 | |
1041 | - /* |
|
1041 | + /* |
|
1042 | 1042 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1043 | 1043 | */ |
1044 | - return str_replace( array( |
|
1045 | - '<script>', |
|
1046 | - '</script>' |
|
1047 | - ), '', $output ); |
|
1048 | - } |
|
1049 | - |
|
1050 | - /** |
|
1051 | - * Adds the Font Awesome JS. |
|
1052 | - */ |
|
1053 | - public function enqueue_scripts() { |
|
1054 | - |
|
1055 | - if( is_admin() && !$this->is_aui_screen()){ |
|
1056 | - // don't add wp-admin scripts if not requested to |
|
1057 | - }else { |
|
1058 | - |
|
1059 | - $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1060 | - |
|
1061 | - // select2 |
|
1062 | - wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1063 | - |
|
1064 | - // flatpickr |
|
1065 | - wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1066 | - |
|
1067 | - // Bootstrap file browser |
|
1068 | - wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1069 | - wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1070 | - |
|
1071 | - $load_inline = false; |
|
1072 | - |
|
1073 | - if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1074 | - // Bootstrap bundle |
|
1075 | - $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1076 | - wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1077 | - 'select2', |
|
1078 | - 'jquery' |
|
1079 | - ), $this->latest, $this->is_bs3_compat() ); |
|
1080 | - // if in admin then add to footer for compatibility. |
|
1081 | - is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1082 | - $script = $this->inline_script(); |
|
1083 | - wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1084 | - } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1085 | - $url = $this->url . 'assets/js/popper.min.js'; |
|
1086 | - wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1087 | - wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1088 | - $load_inline = true; |
|
1089 | - } else { |
|
1090 | - $load_inline = true; |
|
1091 | - } |
|
1092 | - |
|
1093 | - // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
1094 | - if ( $load_inline ) { |
|
1095 | - wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1096 | - wp_enqueue_script( 'bootstrap-dummy' ); |
|
1097 | - $script = $this->inline_script(); |
|
1098 | - wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1099 | - } |
|
1100 | - } |
|
1101 | - |
|
1102 | - } |
|
1103 | - |
|
1104 | - /** |
|
1105 | - * Enqueue flatpickr if called. |
|
1106 | - */ |
|
1107 | - public function enqueue_flatpickr(){ |
|
1108 | - wp_enqueue_style( 'flatpickr' ); |
|
1109 | - wp_enqueue_script( 'flatpickr' ); |
|
1110 | - } |
|
1111 | - |
|
1112 | - /** |
|
1113 | - * Get the url path to the current folder. |
|
1114 | - * |
|
1115 | - * @return string |
|
1116 | - */ |
|
1117 | - public function get_url() { |
|
1118 | - |
|
1119 | - $url = ''; |
|
1120 | - // check if we are inside a plugin |
|
1121 | - $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1122 | - |
|
1123 | - // add check in-case user has changed wp-content dir name. |
|
1124 | - $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
1125 | - $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1126 | - $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1127 | - |
|
1128 | - if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1129 | - $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1130 | - } |
|
1131 | - |
|
1132 | - return $url; |
|
1133 | - } |
|
1134 | - |
|
1135 | - /** |
|
1136 | - * Register the database settings with WordPress. |
|
1137 | - */ |
|
1138 | - public function register_settings() { |
|
1139 | - register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1140 | - } |
|
1141 | - |
|
1142 | - /** |
|
1143 | - * Add the WordPress settings menu item. |
|
1144 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1145 | - */ |
|
1146 | - public function menu_item() { |
|
1147 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
1148 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1149 | - $this, |
|
1150 | - 'settings_page' |
|
1151 | - ) ); |
|
1152 | - } |
|
1153 | - |
|
1154 | - /** |
|
1155 | - * Get a list of themes and their default JS settings. |
|
1156 | - * |
|
1157 | - * @return array |
|
1158 | - */ |
|
1159 | - public function theme_js_settings(){ |
|
1160 | - return array( |
|
1161 | - 'ayetheme' => 'popper', |
|
1162 | - 'listimia' => 'required', |
|
1163 | - 'listimia_backend' => 'core-popper', |
|
1164 | - //'avada' => 'required', // removed as we now add compatibility |
|
1165 | - ); |
|
1166 | - } |
|
1167 | - |
|
1168 | - /** |
|
1169 | - * Get the current Font Awesome output settings. |
|
1170 | - * |
|
1171 | - * @return array The array of settings. |
|
1172 | - */ |
|
1173 | - public function get_settings() { |
|
1174 | - |
|
1175 | - $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1176 | - $js_default = 'core-popper'; |
|
1177 | - $js_default_backend = $js_default; |
|
1178 | - |
|
1179 | - // maybe set defaults (if no settings set) |
|
1180 | - if(empty($db_settings)){ |
|
1181 | - $active_theme = strtolower( get_template() ); // active parent theme. |
|
1182 | - $theme_js_settings = self::theme_js_settings(); |
|
1183 | - if(isset($theme_js_settings[$active_theme])){ |
|
1184 | - $js_default = $theme_js_settings[$active_theme]; |
|
1185 | - $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1186 | - } |
|
1187 | - } |
|
1188 | - |
|
1189 | - $defaults = array( |
|
1190 | - 'css' => 'compatibility', // core, compatibility |
|
1191 | - 'js' => $js_default, // js to load, core-popper, popper |
|
1192 | - 'html_font_size' => '16', // js to load, core-popper, popper |
|
1193 | - 'css_backend' => 'compatibility', // core, compatibility |
|
1194 | - 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1195 | - 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1196 | - ); |
|
1197 | - |
|
1198 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
1199 | - |
|
1200 | - /** |
|
1201 | - * Filter the Bootstrap settings. |
|
1202 | - * |
|
1203 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1204 | - */ |
|
1205 | - return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1206 | - } |
|
1207 | - |
|
1044 | + return str_replace( array( |
|
1045 | + '<script>', |
|
1046 | + '</script>' |
|
1047 | + ), '', $output ); |
|
1048 | + } |
|
1049 | + |
|
1050 | + /** |
|
1051 | + * Adds the Font Awesome JS. |
|
1052 | + */ |
|
1053 | + public function enqueue_scripts() { |
|
1054 | + |
|
1055 | + if( is_admin() && !$this->is_aui_screen()){ |
|
1056 | + // don't add wp-admin scripts if not requested to |
|
1057 | + }else { |
|
1058 | + |
|
1059 | + $js_setting = current_action() == 'wp_enqueue_scripts' ? 'js' : 'js_backend'; |
|
1060 | + |
|
1061 | + // select2 |
|
1062 | + wp_register_script( 'select2', $this->url . 'assets/js/select2.min.js', array( 'jquery' ), $this->select2_version ); |
|
1063 | + |
|
1064 | + // flatpickr |
|
1065 | + wp_register_script( 'flatpickr', $this->url . 'assets/js/flatpickr.min.js', array(), $this->latest ); |
|
1066 | + |
|
1067 | + // Bootstrap file browser |
|
1068 | + wp_register_script( 'aui-custom-file-input', $url = $this->url . 'assets/js/bs-custom-file-input.min.js', array( 'jquery' ), $this->select2_version ); |
|
1069 | + wp_add_inline_script( 'aui-custom-file-input', $this->inline_script_file_browser() ); |
|
1070 | + |
|
1071 | + $load_inline = false; |
|
1072 | + |
|
1073 | + if ( $this->settings[ $js_setting ] == 'core-popper' ) { |
|
1074 | + // Bootstrap bundle |
|
1075 | + $url = $this->url . 'assets/js/bootstrap.bundle.min.js'; |
|
1076 | + wp_register_script( 'bootstrap-js-bundle', $url, array( |
|
1077 | + 'select2', |
|
1078 | + 'jquery' |
|
1079 | + ), $this->latest, $this->is_bs3_compat() ); |
|
1080 | + // if in admin then add to footer for compatibility. |
|
1081 | + is_admin() ? wp_enqueue_script( 'bootstrap-js-bundle', '', null, null, true ) : wp_enqueue_script( 'bootstrap-js-bundle' ); |
|
1082 | + $script = $this->inline_script(); |
|
1083 | + wp_add_inline_script( 'bootstrap-js-bundle', $script ); |
|
1084 | + } elseif ( $this->settings[ $js_setting ] == 'popper' ) { |
|
1085 | + $url = $this->url . 'assets/js/popper.min.js'; |
|
1086 | + wp_register_script( 'bootstrap-js-popper', $url, array( 'select2', 'jquery' ), $this->latest ); |
|
1087 | + wp_enqueue_script( 'bootstrap-js-popper' ); |
|
1088 | + $load_inline = true; |
|
1089 | + } else { |
|
1090 | + $load_inline = true; |
|
1091 | + } |
|
1208 | 1092 | |
1209 | - /** |
|
1210 | - * The settings page html output. |
|
1211 | - */ |
|
1212 | - public function settings_page() { |
|
1213 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
1214 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1215 | - } |
|
1216 | - ?> |
|
1093 | + // Load needed inline scripts by faking the loading of a script if the main script is not being loaded |
|
1094 | + if ( $load_inline ) { |
|
1095 | + wp_register_script( 'bootstrap-dummy', '', array( 'select2', 'jquery' ) ); |
|
1096 | + wp_enqueue_script( 'bootstrap-dummy' ); |
|
1097 | + $script = $this->inline_script(); |
|
1098 | + wp_add_inline_script( 'bootstrap-dummy', $script ); |
|
1099 | + } |
|
1100 | + } |
|
1101 | + |
|
1102 | + } |
|
1103 | + |
|
1104 | + /** |
|
1105 | + * Enqueue flatpickr if called. |
|
1106 | + */ |
|
1107 | + public function enqueue_flatpickr(){ |
|
1108 | + wp_enqueue_style( 'flatpickr' ); |
|
1109 | + wp_enqueue_script( 'flatpickr' ); |
|
1110 | + } |
|
1111 | + |
|
1112 | + /** |
|
1113 | + * Get the url path to the current folder. |
|
1114 | + * |
|
1115 | + * @return string |
|
1116 | + */ |
|
1117 | + public function get_url() { |
|
1118 | + |
|
1119 | + $url = ''; |
|
1120 | + // check if we are inside a plugin |
|
1121 | + $file_dir = str_replace( "/includes","", wp_normalize_path( dirname( __FILE__ ) ) ); |
|
1122 | + |
|
1123 | + // add check in-case user has changed wp-content dir name. |
|
1124 | + $wp_content_folder_name = basename(WP_CONTENT_DIR); |
|
1125 | + $dir_parts = explode("/$wp_content_folder_name/",$file_dir); |
|
1126 | + $url_parts = explode("/$wp_content_folder_name/",plugins_url()); |
|
1127 | + |
|
1128 | + if(!empty($url_parts[0]) && !empty($dir_parts[1])){ |
|
1129 | + $url = trailingslashit( $url_parts[0]."/$wp_content_folder_name/".$dir_parts[1] ); |
|
1130 | + } |
|
1131 | + |
|
1132 | + return $url; |
|
1133 | + } |
|
1134 | + |
|
1135 | + /** |
|
1136 | + * Register the database settings with WordPress. |
|
1137 | + */ |
|
1138 | + public function register_settings() { |
|
1139 | + register_setting( 'ayecode-ui-settings', 'ayecode-ui-settings' ); |
|
1140 | + } |
|
1141 | + |
|
1142 | + /** |
|
1143 | + * Add the WordPress settings menu item. |
|
1144 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
1145 | + */ |
|
1146 | + public function menu_item() { |
|
1147 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
1148 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'ayecode-ui-settings', array( |
|
1149 | + $this, |
|
1150 | + 'settings_page' |
|
1151 | + ) ); |
|
1152 | + } |
|
1153 | + |
|
1154 | + /** |
|
1155 | + * Get a list of themes and their default JS settings. |
|
1156 | + * |
|
1157 | + * @return array |
|
1158 | + */ |
|
1159 | + public function theme_js_settings(){ |
|
1160 | + return array( |
|
1161 | + 'ayetheme' => 'popper', |
|
1162 | + 'listimia' => 'required', |
|
1163 | + 'listimia_backend' => 'core-popper', |
|
1164 | + //'avada' => 'required', // removed as we now add compatibility |
|
1165 | + ); |
|
1166 | + } |
|
1167 | + |
|
1168 | + /** |
|
1169 | + * Get the current Font Awesome output settings. |
|
1170 | + * |
|
1171 | + * @return array The array of settings. |
|
1172 | + */ |
|
1173 | + public function get_settings() { |
|
1174 | + |
|
1175 | + $db_settings = get_option( 'ayecode-ui-settings' ); |
|
1176 | + $js_default = 'core-popper'; |
|
1177 | + $js_default_backend = $js_default; |
|
1178 | + |
|
1179 | + // maybe set defaults (if no settings set) |
|
1180 | + if(empty($db_settings)){ |
|
1181 | + $active_theme = strtolower( get_template() ); // active parent theme. |
|
1182 | + $theme_js_settings = self::theme_js_settings(); |
|
1183 | + if(isset($theme_js_settings[$active_theme])){ |
|
1184 | + $js_default = $theme_js_settings[$active_theme]; |
|
1185 | + $js_default_backend = isset($theme_js_settings[$active_theme."_backend"]) ? $theme_js_settings[$active_theme."_backend"] : $js_default; |
|
1186 | + } |
|
1187 | + } |
|
1188 | + |
|
1189 | + $defaults = array( |
|
1190 | + 'css' => 'compatibility', // core, compatibility |
|
1191 | + 'js' => $js_default, // js to load, core-popper, popper |
|
1192 | + 'html_font_size' => '16', // js to load, core-popper, popper |
|
1193 | + 'css_backend' => 'compatibility', // core, compatibility |
|
1194 | + 'js_backend' => $js_default_backend, // js to load, core-popper, popper |
|
1195 | + 'disable_admin' => '', // URL snippets to disable loading on admin |
|
1196 | + ); |
|
1197 | + |
|
1198 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
1199 | + |
|
1200 | + /** |
|
1201 | + * Filter the Bootstrap settings. |
|
1202 | + * |
|
1203 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
1204 | + */ |
|
1205 | + return $this->settings = apply_filters( 'ayecode-ui-settings', $settings, $db_settings, $defaults ); |
|
1206 | + } |
|
1207 | + |
|
1208 | + |
|
1209 | + /** |
|
1210 | + * The settings page html output. |
|
1211 | + */ |
|
1212 | + public function settings_page() { |
|
1213 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
1214 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'aui' ) ); |
|
1215 | + } |
|
1216 | + ?> |
|
1217 | 1217 | <div class="wrap"> |
1218 | 1218 | <h1><?php echo $this->name; ?></h1> |
1219 | 1219 | <p><?php _e("Here you can adjust settings if you are having compatibility issues.",'aui');?></p> |
1220 | 1220 | <form method="post" action="options.php"> |
1221 | 1221 | <?php |
1222 | - settings_fields( 'ayecode-ui-settings' ); |
|
1223 | - do_settings_sections( 'ayecode-ui-settings' ); |
|
1224 | - ?> |
|
1222 | + settings_fields( 'ayecode-ui-settings' ); |
|
1223 | + do_settings_sections( 'ayecode-ui-settings' ); |
|
1224 | + ?> |
|
1225 | 1225 | |
1226 | 1226 | <h2><?php _e( 'Frontend', 'aui' ); ?></h2> |
1227 | 1227 | <table class="form-table wpbs-table-settings"> |
@@ -1301,60 +1301,60 @@ discard block |
||
1301 | 1301 | </table> |
1302 | 1302 | |
1303 | 1303 | <?php |
1304 | - submit_button(); |
|
1305 | - ?> |
|
1304 | + submit_button(); |
|
1305 | + ?> |
|
1306 | 1306 | </form> |
1307 | 1307 | |
1308 | 1308 | <div id="wpbs-version"><?php echo $this->version; ?></div> |
1309 | 1309 | </div> |
1310 | 1310 | |
1311 | 1311 | <?php |
1312 | - } |
|
1313 | - |
|
1314 | - public function customizer_settings($wp_customize){ |
|
1315 | - $wp_customize->add_section('aui_settings', array( |
|
1316 | - 'title' => __('AyeCode UI','aui'), |
|
1317 | - 'priority' => 120, |
|
1318 | - )); |
|
1319 | - |
|
1320 | - // ============================= |
|
1321 | - // = Color Picker = |
|
1322 | - // ============================= |
|
1323 | - $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1324 | - 'default' => AUI_PRIMARY_COLOR, |
|
1325 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1326 | - 'capability' => 'edit_theme_options', |
|
1327 | - 'type' => 'option', |
|
1328 | - 'transport' => 'refresh', |
|
1329 | - )); |
|
1330 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1331 | - 'label' => __('Primary Color','aui'), |
|
1332 | - 'section' => 'aui_settings', |
|
1333 | - 'settings' => 'aui_options[color_primary]', |
|
1334 | - ))); |
|
1335 | - |
|
1336 | - $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1337 | - 'default' => '#6c757d', |
|
1338 | - 'sanitize_callback' => 'sanitize_hex_color', |
|
1339 | - 'capability' => 'edit_theme_options', |
|
1340 | - 'type' => 'option', |
|
1341 | - 'transport' => 'refresh', |
|
1342 | - )); |
|
1343 | - $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1344 | - 'label' => __('Secondary Color','aui'), |
|
1345 | - 'section' => 'aui_settings', |
|
1346 | - 'settings' => 'aui_options[color_secondary]', |
|
1347 | - ))); |
|
1348 | - } |
|
1349 | - |
|
1350 | - /** |
|
1351 | - * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1352 | - * |
|
1353 | - * @return mixed |
|
1354 | - */ |
|
1355 | - public static function bs3_compat_css() { |
|
1356 | - ob_start(); |
|
1357 | - ?> |
|
1312 | + } |
|
1313 | + |
|
1314 | + public function customizer_settings($wp_customize){ |
|
1315 | + $wp_customize->add_section('aui_settings', array( |
|
1316 | + 'title' => __('AyeCode UI','aui'), |
|
1317 | + 'priority' => 120, |
|
1318 | + )); |
|
1319 | + |
|
1320 | + // ============================= |
|
1321 | + // = Color Picker = |
|
1322 | + // ============================= |
|
1323 | + $wp_customize->add_setting('aui_options[color_primary]', array( |
|
1324 | + 'default' => AUI_PRIMARY_COLOR, |
|
1325 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1326 | + 'capability' => 'edit_theme_options', |
|
1327 | + 'type' => 'option', |
|
1328 | + 'transport' => 'refresh', |
|
1329 | + )); |
|
1330 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_primary', array( |
|
1331 | + 'label' => __('Primary Color','aui'), |
|
1332 | + 'section' => 'aui_settings', |
|
1333 | + 'settings' => 'aui_options[color_primary]', |
|
1334 | + ))); |
|
1335 | + |
|
1336 | + $wp_customize->add_setting('aui_options[color_secondary]', array( |
|
1337 | + 'default' => '#6c757d', |
|
1338 | + 'sanitize_callback' => 'sanitize_hex_color', |
|
1339 | + 'capability' => 'edit_theme_options', |
|
1340 | + 'type' => 'option', |
|
1341 | + 'transport' => 'refresh', |
|
1342 | + )); |
|
1343 | + $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'color_secondary', array( |
|
1344 | + 'label' => __('Secondary Color','aui'), |
|
1345 | + 'section' => 'aui_settings', |
|
1346 | + 'settings' => 'aui_options[color_secondary]', |
|
1347 | + ))); |
|
1348 | + } |
|
1349 | + |
|
1350 | + /** |
|
1351 | + * CSS to help with conflict issues with other plugins and themes using bootstrap v3. |
|
1352 | + * |
|
1353 | + * @return mixed |
|
1354 | + */ |
|
1355 | + public static function bs3_compat_css() { |
|
1356 | + ob_start(); |
|
1357 | + ?> |
|
1358 | 1358 | <style> |
1359 | 1359 | /* Bootstrap 3 compatibility */ |
1360 | 1360 | body.modal-open .modal-backdrop.show:not(.in) {opacity:0.5;} |
@@ -1380,579 +1380,579 @@ discard block |
||
1380 | 1380 | <?php } ?> |
1381 | 1381 | </style> |
1382 | 1382 | <?php |
1383 | - return str_replace( array( |
|
1384 | - '<style>', |
|
1385 | - '</style>' |
|
1386 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1387 | - } |
|
1383 | + return str_replace( array( |
|
1384 | + '<style>', |
|
1385 | + '</style>' |
|
1386 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1387 | + } |
|
1388 | 1388 | |
1389 | 1389 | |
1390 | - public static function custom_css($compatibility = true) { |
|
1391 | - $settings = get_option('aui_options'); |
|
1390 | + public static function custom_css($compatibility = true) { |
|
1391 | + $settings = get_option('aui_options'); |
|
1392 | 1392 | |
1393 | - ob_start(); |
|
1393 | + ob_start(); |
|
1394 | 1394 | |
1395 | - $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1396 | - $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1397 | - //AUI_PRIMARY_COLOR_ORIGINAL |
|
1398 | - ?> |
|
1395 | + $primary_color = !empty($settings['color_primary']) ? $settings['color_primary'] : AUI_PRIMARY_COLOR; |
|
1396 | + $secondary_color = !empty($settings['color_secondary']) ? $settings['color_secondary'] : AUI_SECONDARY_COLOR; |
|
1397 | + //AUI_PRIMARY_COLOR_ORIGINAL |
|
1398 | + ?> |
|
1399 | 1399 | <style> |
1400 | 1400 | <?php |
1401 | 1401 | |
1402 | - // BS v3 compat |
|
1403 | - if( self::is_bs3_compat() ){ |
|
1404 | - echo self::bs3_compat_css(); |
|
1405 | - } |
|
1402 | + // BS v3 compat |
|
1403 | + if( self::is_bs3_compat() ){ |
|
1404 | + echo self::bs3_compat_css(); |
|
1405 | + } |
|
1406 | 1406 | |
1407 | - if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1408 | - echo self::css_primary($primary_color,$compatibility); |
|
1409 | - } |
|
1407 | + if(!is_admin() && $primary_color != AUI_PRIMARY_COLOR_ORIGINAL){ |
|
1408 | + echo self::css_primary($primary_color,$compatibility); |
|
1409 | + } |
|
1410 | 1410 | |
1411 | - if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1412 | - echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1413 | - } |
|
1411 | + if(!is_admin() && $secondary_color != AUI_SECONDARY_COLOR_ORIGINAL){ |
|
1412 | + echo self::css_secondary($settings['color_secondary'],$compatibility); |
|
1413 | + } |
|
1414 | 1414 | |
1415 | - // Set admin bar z-index lower when modal is open. |
|
1416 | - echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1415 | + // Set admin bar z-index lower when modal is open. |
|
1416 | + echo ' body.modal-open #wpadminbar{z-index:999}'; |
|
1417 | 1417 | ?> |
1418 | 1418 | </style> |
1419 | 1419 | <?php |
1420 | 1420 | |
1421 | 1421 | |
1422 | - /* |
|
1422 | + /* |
|
1423 | 1423 | * We only add the <script> tags for code highlighting, so we strip them from the output. |
1424 | 1424 | */ |
1425 | - return str_replace( array( |
|
1426 | - '<style>', |
|
1427 | - '</style>' |
|
1428 | - ), '', self::minify_css( ob_get_clean() ) ); |
|
1429 | - } |
|
1430 | - |
|
1431 | - /** |
|
1432 | - * Check if we should add booststrap 3 compatibility changes. |
|
1433 | - * |
|
1434 | - * @return bool |
|
1435 | - */ |
|
1436 | - public static function is_bs3_compat(){ |
|
1437 | - return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1438 | - } |
|
1439 | - |
|
1440 | - public static function css_primary($color_code,$compatibility){; |
|
1441 | - $color_code = sanitize_hex_color($color_code); |
|
1442 | - if(!$color_code){return '';} |
|
1443 | - /** |
|
1444 | - * c = color, b = background color, o = border-color, f = fill |
|
1445 | - */ |
|
1446 | - $selectors = array( |
|
1447 | - 'a' => array('c'), |
|
1448 | - '.btn-primary' => array('b','o'), |
|
1449 | - '.btn-primary.disabled' => array('b','o'), |
|
1450 | - '.btn-primary:disabled' => array('b','o'), |
|
1451 | - '.btn-outline-primary' => array('c','o'), |
|
1452 | - '.btn-outline-primary:hover' => array('b','o'), |
|
1453 | - '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1454 | - '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1455 | - '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1456 | - '.btn-link' => array('c'), |
|
1457 | - '.dropdown-item.active' => array('b'), |
|
1458 | - '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1459 | - '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1425 | + return str_replace( array( |
|
1426 | + '<style>', |
|
1427 | + '</style>' |
|
1428 | + ), '', self::minify_css( ob_get_clean() ) ); |
|
1429 | + } |
|
1430 | + |
|
1431 | + /** |
|
1432 | + * Check if we should add booststrap 3 compatibility changes. |
|
1433 | + * |
|
1434 | + * @return bool |
|
1435 | + */ |
|
1436 | + public static function is_bs3_compat(){ |
|
1437 | + return defined('AYECODE_UI_BS3_COMPAT') || defined('SVQ_THEME_VERSION') || defined('FUSION_BUILDER_VERSION'); |
|
1438 | + } |
|
1439 | + |
|
1440 | + public static function css_primary($color_code,$compatibility){; |
|
1441 | + $color_code = sanitize_hex_color($color_code); |
|
1442 | + if(!$color_code){return '';} |
|
1443 | + /** |
|
1444 | + * c = color, b = background color, o = border-color, f = fill |
|
1445 | + */ |
|
1446 | + $selectors = array( |
|
1447 | + 'a' => array('c'), |
|
1448 | + '.btn-primary' => array('b','o'), |
|
1449 | + '.btn-primary.disabled' => array('b','o'), |
|
1450 | + '.btn-primary:disabled' => array('b','o'), |
|
1451 | + '.btn-outline-primary' => array('c','o'), |
|
1452 | + '.btn-outline-primary:hover' => array('b','o'), |
|
1453 | + '.btn-outline-primary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1454 | + '.btn-outline-primary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1455 | + '.show>.btn-outline-primary.dropdown-toggle' => array('b','o'), |
|
1456 | + '.btn-link' => array('c'), |
|
1457 | + '.dropdown-item.active' => array('b'), |
|
1458 | + '.custom-control-input:checked~.custom-control-label::before' => array('b','o'), |
|
1459 | + '.custom-checkbox .custom-control-input:indeterminate~.custom-control-label::before' => array('b','o'), |
|
1460 | 1460 | // '.custom-range::-webkit-slider-thumb' => array('b'), // these break the inline rules... |
1461 | 1461 | // '.custom-range::-moz-range-thumb' => array('b'), |
1462 | 1462 | // '.custom-range::-ms-thumb' => array('b'), |
1463 | - '.nav-pills .nav-link.active' => array('b'), |
|
1464 | - '.nav-pills .show>.nav-link' => array('b'), |
|
1465 | - '.page-link' => array('c'), |
|
1466 | - '.page-item.active .page-link' => array('b','o'), |
|
1467 | - '.badge-primary' => array('b'), |
|
1468 | - '.alert-primary' => array('b','o'), |
|
1469 | - '.progress-bar' => array('b'), |
|
1470 | - '.list-group-item.active' => array('b','o'), |
|
1471 | - '.bg-primary' => array('b','f'), |
|
1472 | - '.btn-link.btn-primary' => array('c'), |
|
1473 | - '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1474 | - ); |
|
1475 | - |
|
1476 | - $important_selectors = array( |
|
1477 | - '.bg-primary' => array('b','f'), |
|
1478 | - '.border-primary' => array('o'), |
|
1479 | - '.text-primary' => array('c'), |
|
1480 | - ); |
|
1481 | - |
|
1482 | - $color = array(); |
|
1483 | - $color_i = array(); |
|
1484 | - $background = array(); |
|
1485 | - $background_i = array(); |
|
1486 | - $border = array(); |
|
1487 | - $border_i = array(); |
|
1488 | - $fill = array(); |
|
1489 | - $fill_i = array(); |
|
1490 | - |
|
1491 | - $output = ''; |
|
1492 | - |
|
1493 | - // build rules into each type |
|
1494 | - foreach($selectors as $selector => $types){ |
|
1495 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1496 | - $types = array_combine($types,$types); |
|
1497 | - if(isset($types['c'])){$color[] = $selector;} |
|
1498 | - if(isset($types['b'])){$background[] = $selector;} |
|
1499 | - if(isset($types['o'])){$border[] = $selector;} |
|
1500 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1501 | - } |
|
1502 | - |
|
1503 | - // build rules into each type |
|
1504 | - foreach($important_selectors as $selector => $types){ |
|
1505 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1506 | - $types = array_combine($types,$types); |
|
1507 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1508 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1509 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1510 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1511 | - } |
|
1512 | - |
|
1513 | - // add any color rules |
|
1514 | - if(!empty($color)){ |
|
1515 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1516 | - } |
|
1517 | - if(!empty($color_i)){ |
|
1518 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1519 | - } |
|
1520 | - |
|
1521 | - // add any background color rules |
|
1522 | - if(!empty($background)){ |
|
1523 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1524 | - } |
|
1525 | - if(!empty($background_i)){ |
|
1526 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1527 | - } |
|
1528 | - |
|
1529 | - // add any border color rules |
|
1530 | - if(!empty($border)){ |
|
1531 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1532 | - } |
|
1533 | - if(!empty($border_i)){ |
|
1534 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1535 | - } |
|
1536 | - |
|
1537 | - // add any fill color rules |
|
1538 | - if(!empty($fill)){ |
|
1539 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1540 | - } |
|
1541 | - if(!empty($fill_i)){ |
|
1542 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1543 | - } |
|
1544 | - |
|
1545 | - |
|
1546 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1547 | - |
|
1548 | - // darken |
|
1549 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1550 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1551 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1552 | - |
|
1553 | - // lighten |
|
1554 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1555 | - |
|
1556 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1557 | - $op_25 = $color_code."40"; // 25% opacity |
|
1558 | - |
|
1559 | - |
|
1560 | - // button states |
|
1561 | - $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1562 | - $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;} "; |
|
1563 | - $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.";} "; |
|
1564 | - $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;} "; |
|
1565 | - |
|
1566 | - |
|
1567 | - // dropdown's |
|
1568 | - $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1569 | - |
|
1570 | - |
|
1571 | - // input states |
|
1572 | - $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | - |
|
1574 | - // page link |
|
1575 | - $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1576 | - |
|
1577 | - return $output; |
|
1578 | - } |
|
1579 | - |
|
1580 | - public static function css_secondary($color_code,$compatibility){; |
|
1581 | - $color_code = sanitize_hex_color($color_code); |
|
1582 | - if(!$color_code){return '';} |
|
1583 | - /** |
|
1584 | - * c = color, b = background color, o = border-color, f = fill |
|
1585 | - */ |
|
1586 | - $selectors = array( |
|
1587 | - '.btn-secondary' => array('b','o'), |
|
1588 | - '.btn-secondary.disabled' => array('b','o'), |
|
1589 | - '.btn-secondary:disabled' => array('b','o'), |
|
1590 | - '.btn-outline-secondary' => array('c','o'), |
|
1591 | - '.btn-outline-secondary:hover' => array('b','o'), |
|
1592 | - '.btn-outline-secondary.disabled' => array('c'), |
|
1593 | - '.btn-outline-secondary:disabled' => array('c'), |
|
1594 | - '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1595 | - '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1596 | - '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1597 | - '.badge-secondary' => array('b'), |
|
1598 | - '.alert-secondary' => array('b','o'), |
|
1599 | - '.btn-link.btn-secondary' => array('c'), |
|
1600 | - ); |
|
1601 | - |
|
1602 | - $important_selectors = array( |
|
1603 | - '.bg-secondary' => array('b','f'), |
|
1604 | - '.border-secondary' => array('o'), |
|
1605 | - '.text-secondary' => array('c'), |
|
1606 | - ); |
|
1607 | - |
|
1608 | - $color = array(); |
|
1609 | - $color_i = array(); |
|
1610 | - $background = array(); |
|
1611 | - $background_i = array(); |
|
1612 | - $border = array(); |
|
1613 | - $border_i = array(); |
|
1614 | - $fill = array(); |
|
1615 | - $fill_i = array(); |
|
1616 | - |
|
1617 | - $output = ''; |
|
1618 | - |
|
1619 | - // build rules into each type |
|
1620 | - foreach($selectors as $selector => $types){ |
|
1621 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1622 | - $types = array_combine($types,$types); |
|
1623 | - if(isset($types['c'])){$color[] = $selector;} |
|
1624 | - if(isset($types['b'])){$background[] = $selector;} |
|
1625 | - if(isset($types['o'])){$border[] = $selector;} |
|
1626 | - if(isset($types['f'])){$fill[] = $selector;} |
|
1627 | - } |
|
1628 | - |
|
1629 | - // build rules into each type |
|
1630 | - foreach($important_selectors as $selector => $types){ |
|
1631 | - $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1632 | - $types = array_combine($types,$types); |
|
1633 | - if(isset($types['c'])){$color_i[] = $selector;} |
|
1634 | - if(isset($types['b'])){$background_i[] = $selector;} |
|
1635 | - if(isset($types['o'])){$border_i[] = $selector;} |
|
1636 | - if(isset($types['f'])){$fill_i[] = $selector;} |
|
1637 | - } |
|
1638 | - |
|
1639 | - // add any color rules |
|
1640 | - if(!empty($color)){ |
|
1641 | - $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1642 | - } |
|
1643 | - if(!empty($color_i)){ |
|
1644 | - $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1645 | - } |
|
1646 | - |
|
1647 | - // add any background color rules |
|
1648 | - if(!empty($background)){ |
|
1649 | - $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1650 | - } |
|
1651 | - if(!empty($background_i)){ |
|
1652 | - $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1653 | - } |
|
1654 | - |
|
1655 | - // add any border color rules |
|
1656 | - if(!empty($border)){ |
|
1657 | - $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1658 | - } |
|
1659 | - if(!empty($border_i)){ |
|
1660 | - $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1661 | - } |
|
1662 | - |
|
1663 | - // add any fill color rules |
|
1664 | - if(!empty($fill)){ |
|
1665 | - $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1666 | - } |
|
1667 | - if(!empty($fill_i)){ |
|
1668 | - $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1669 | - } |
|
1670 | - |
|
1671 | - |
|
1672 | - $prefix = $compatibility ? ".bsui " : ""; |
|
1673 | - |
|
1674 | - // darken |
|
1675 | - $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1676 | - $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1677 | - $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1678 | - |
|
1679 | - // lighten |
|
1680 | - $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1681 | - |
|
1682 | - // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1683 | - $op_25 = $color_code."40"; // 25% opacity |
|
1684 | - |
|
1685 | - |
|
1686 | - // button states |
|
1687 | - $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1688 | - $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;} "; |
|
1689 | - $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.";} "; |
|
1690 | - $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;} "; |
|
1691 | - |
|
1692 | - |
|
1693 | - return $output; |
|
1694 | - } |
|
1695 | - |
|
1696 | - /** |
|
1697 | - * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1698 | - * |
|
1699 | - * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1700 | - * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1701 | - * |
|
1702 | - * @return string |
|
1703 | - */ |
|
1704 | - public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1705 | - $hexCode = ltrim($hexCode, '#'); |
|
1706 | - |
|
1707 | - if (strlen($hexCode) == 3) { |
|
1708 | - $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1709 | - } |
|
1710 | - |
|
1711 | - $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1712 | - |
|
1713 | - foreach ($hexCode as & $color) { |
|
1714 | - $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1715 | - $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1716 | - |
|
1717 | - $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1718 | - } |
|
1719 | - |
|
1720 | - return '#' . implode($hexCode); |
|
1721 | - } |
|
1722 | - |
|
1723 | - /** |
|
1724 | - * Check if we should display examples. |
|
1725 | - */ |
|
1726 | - public function maybe_show_examples(){ |
|
1727 | - if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1728 | - echo "<head>"; |
|
1729 | - wp_head(); |
|
1730 | - echo "</head>"; |
|
1731 | - echo "<body>"; |
|
1732 | - echo $this->get_examples(); |
|
1733 | - echo "</body>"; |
|
1734 | - exit; |
|
1735 | - } |
|
1736 | - } |
|
1737 | - |
|
1738 | - /** |
|
1739 | - * Get developer examples. |
|
1740 | - * |
|
1741 | - * @return string |
|
1742 | - */ |
|
1743 | - public function get_examples(){ |
|
1744 | - $output = ''; |
|
1745 | - |
|
1746 | - |
|
1747 | - // open form |
|
1748 | - $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1749 | - |
|
1750 | - // input example |
|
1751 | - $output .= aui()->input(array( |
|
1752 | - 'type' => 'text', |
|
1753 | - 'id' => 'text-example', |
|
1754 | - 'name' => 'text-example', |
|
1755 | - 'placeholder' => 'text placeholder', |
|
1756 | - 'title' => 'Text input example', |
|
1757 | - 'value' => '', |
|
1758 | - 'required' => false, |
|
1759 | - 'help_text' => 'help text', |
|
1760 | - 'label' => 'Text input example label' |
|
1761 | - )); |
|
1762 | - |
|
1763 | - // input example |
|
1764 | - $output .= aui()->input(array( |
|
1765 | - 'type' => 'url', |
|
1766 | - 'id' => 'text-example2', |
|
1767 | - 'name' => 'text-example', |
|
1768 | - 'placeholder' => 'url placeholder', |
|
1769 | - 'title' => 'Text input example', |
|
1770 | - 'value' => '', |
|
1771 | - 'required' => false, |
|
1772 | - 'help_text' => 'help text', |
|
1773 | - 'label' => 'Text input example label' |
|
1774 | - )); |
|
1775 | - |
|
1776 | - // checkbox example |
|
1777 | - $output .= aui()->input(array( |
|
1778 | - 'type' => 'checkbox', |
|
1779 | - 'id' => 'checkbox-example', |
|
1780 | - 'name' => 'checkbox-example', |
|
1781 | - 'placeholder' => 'checkbox-example', |
|
1782 | - 'title' => 'Checkbox example', |
|
1783 | - 'value' => '1', |
|
1784 | - 'checked' => true, |
|
1785 | - 'required' => false, |
|
1786 | - 'help_text' => 'help text', |
|
1787 | - 'label' => 'Checkbox checked' |
|
1788 | - )); |
|
1789 | - |
|
1790 | - // checkbox example |
|
1791 | - $output .= aui()->input(array( |
|
1792 | - 'type' => 'checkbox', |
|
1793 | - 'id' => 'checkbox-example2', |
|
1794 | - 'name' => 'checkbox-example2', |
|
1795 | - 'placeholder' => 'checkbox-example', |
|
1796 | - 'title' => 'Checkbox example', |
|
1797 | - 'value' => '1', |
|
1798 | - 'checked' => false, |
|
1799 | - 'required' => false, |
|
1800 | - 'help_text' => 'help text', |
|
1801 | - 'label' => 'Checkbox un-checked' |
|
1802 | - )); |
|
1803 | - |
|
1804 | - // switch example |
|
1805 | - $output .= aui()->input(array( |
|
1806 | - 'type' => 'checkbox', |
|
1807 | - 'id' => 'switch-example', |
|
1808 | - 'name' => 'switch-example', |
|
1809 | - 'placeholder' => 'checkbox-example', |
|
1810 | - 'title' => 'Switch example', |
|
1811 | - 'value' => '1', |
|
1812 | - 'checked' => true, |
|
1813 | - 'switch' => true, |
|
1814 | - 'required' => false, |
|
1815 | - 'help_text' => 'help text', |
|
1816 | - 'label' => 'Switch on' |
|
1817 | - )); |
|
1818 | - |
|
1819 | - // switch example |
|
1820 | - $output .= aui()->input(array( |
|
1821 | - 'type' => 'checkbox', |
|
1822 | - 'id' => 'switch-example2', |
|
1823 | - 'name' => 'switch-example2', |
|
1824 | - 'placeholder' => 'checkbox-example', |
|
1825 | - 'title' => 'Switch example', |
|
1826 | - 'value' => '1', |
|
1827 | - 'checked' => false, |
|
1828 | - 'switch' => true, |
|
1829 | - 'required' => false, |
|
1830 | - 'help_text' => 'help text', |
|
1831 | - 'label' => 'Switch off' |
|
1832 | - )); |
|
1833 | - |
|
1834 | - // close form |
|
1835 | - $output .= "</form>"; |
|
1836 | - |
|
1837 | - return $output; |
|
1838 | - } |
|
1839 | - |
|
1840 | - /** |
|
1841 | - * Calendar params. |
|
1842 | - * |
|
1843 | - * @since 0.1.44 |
|
1844 | - * |
|
1845 | - * @return array Calendar params. |
|
1846 | - */ |
|
1847 | - public static function calendar_params() { |
|
1848 | - $params = array( |
|
1849 | - 'month_long_1' => __( 'January', 'aui' ), |
|
1850 | - 'month_long_2' => __( 'February', 'aui' ), |
|
1851 | - 'month_long_3' => __( 'March', 'aui' ), |
|
1852 | - 'month_long_4' => __( 'April', 'aui' ), |
|
1853 | - 'month_long_5' => __( 'May', 'aui' ), |
|
1854 | - 'month_long_6' => __( 'June', 'aui' ), |
|
1855 | - 'month_long_7' => __( 'July', 'aui' ), |
|
1856 | - 'month_long_8' => __( 'August', 'aui' ), |
|
1857 | - 'month_long_9' => __( 'September', 'aui' ), |
|
1858 | - 'month_long_10' => __( 'October', 'aui' ), |
|
1859 | - 'month_long_11' => __( 'November', 'aui' ), |
|
1860 | - 'month_long_12' => __( 'December', 'aui' ), |
|
1861 | - 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1862 | - 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1863 | - 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1864 | - 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1865 | - 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1866 | - 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1867 | - 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1868 | - 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1869 | - 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1870 | - 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1871 | - 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1872 | - 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1873 | - 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1874 | - 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1875 | - 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1876 | - 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1877 | - 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1878 | - 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1879 | - 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1880 | - 'day_s2_1' => __( 'Su', 'aui' ), |
|
1881 | - 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1882 | - 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1883 | - 'day_s2_4' => __( 'We', 'aui' ), |
|
1884 | - 'day_s2_5' => __( 'Th', 'aui' ), |
|
1885 | - 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1886 | - 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1887 | - 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1888 | - 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1889 | - 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1890 | - 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1891 | - 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1892 | - 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1893 | - 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1894 | - 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1895 | - 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1896 | - 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1897 | - 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1898 | - 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1899 | - 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1900 | - 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1901 | - 'am_lower' => __( 'am', 'aui' ), |
|
1902 | - 'pm_lower' => __( 'pm', 'aui' ), |
|
1903 | - 'am_upper' => __( 'AM', 'aui' ), |
|
1904 | - 'pm_upper' => __( 'PM', 'aui' ), |
|
1905 | - 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1906 | - 'time_24hr' => false, |
|
1907 | - 'year' => __( 'Year', 'aui' ), |
|
1908 | - 'hour' => __( 'Hour', 'aui' ), |
|
1909 | - 'minute' => __( 'Minute', 'aui' ), |
|
1910 | - 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1911 | - 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1912 | - 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1913 | - 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1914 | - ); |
|
1915 | - |
|
1916 | - return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1917 | - } |
|
1918 | - |
|
1919 | - /** |
|
1920 | - * Flatpickr calendar localize. |
|
1921 | - * |
|
1922 | - * @since 0.1.44 |
|
1923 | - * |
|
1924 | - * @return string Calendar locale. |
|
1925 | - */ |
|
1926 | - public static function flatpickr_locale() { |
|
1927 | - $params = self::calendar_params(); |
|
1928 | - |
|
1929 | - if ( is_string( $params ) ) { |
|
1930 | - $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1931 | - } else { |
|
1932 | - foreach ( (array) $params as $key => $value ) { |
|
1933 | - if ( ! is_scalar( $value ) ) { |
|
1934 | - continue; |
|
1935 | - } |
|
1936 | - |
|
1937 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1938 | - } |
|
1939 | - } |
|
1463 | + '.nav-pills .nav-link.active' => array('b'), |
|
1464 | + '.nav-pills .show>.nav-link' => array('b'), |
|
1465 | + '.page-link' => array('c'), |
|
1466 | + '.page-item.active .page-link' => array('b','o'), |
|
1467 | + '.badge-primary' => array('b'), |
|
1468 | + '.alert-primary' => array('b','o'), |
|
1469 | + '.progress-bar' => array('b'), |
|
1470 | + '.list-group-item.active' => array('b','o'), |
|
1471 | + '.bg-primary' => array('b','f'), |
|
1472 | + '.btn-link.btn-primary' => array('c'), |
|
1473 | + '.select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true]' => array('b'), |
|
1474 | + ); |
|
1475 | + |
|
1476 | + $important_selectors = array( |
|
1477 | + '.bg-primary' => array('b','f'), |
|
1478 | + '.border-primary' => array('o'), |
|
1479 | + '.text-primary' => array('c'), |
|
1480 | + ); |
|
1481 | + |
|
1482 | + $color = array(); |
|
1483 | + $color_i = array(); |
|
1484 | + $background = array(); |
|
1485 | + $background_i = array(); |
|
1486 | + $border = array(); |
|
1487 | + $border_i = array(); |
|
1488 | + $fill = array(); |
|
1489 | + $fill_i = array(); |
|
1490 | + |
|
1491 | + $output = ''; |
|
1492 | + |
|
1493 | + // build rules into each type |
|
1494 | + foreach($selectors as $selector => $types){ |
|
1495 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1496 | + $types = array_combine($types,$types); |
|
1497 | + if(isset($types['c'])){$color[] = $selector;} |
|
1498 | + if(isset($types['b'])){$background[] = $selector;} |
|
1499 | + if(isset($types['o'])){$border[] = $selector;} |
|
1500 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1501 | + } |
|
1502 | + |
|
1503 | + // build rules into each type |
|
1504 | + foreach($important_selectors as $selector => $types){ |
|
1505 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1506 | + $types = array_combine($types,$types); |
|
1507 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1508 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1509 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1510 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1511 | + } |
|
1512 | + |
|
1513 | + // add any color rules |
|
1514 | + if(!empty($color)){ |
|
1515 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1516 | + } |
|
1517 | + if(!empty($color_i)){ |
|
1518 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1519 | + } |
|
1520 | + |
|
1521 | + // add any background color rules |
|
1522 | + if(!empty($background)){ |
|
1523 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1524 | + } |
|
1525 | + if(!empty($background_i)){ |
|
1526 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1527 | + } |
|
1528 | + |
|
1529 | + // add any border color rules |
|
1530 | + if(!empty($border)){ |
|
1531 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1532 | + } |
|
1533 | + if(!empty($border_i)){ |
|
1534 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1535 | + } |
|
1536 | + |
|
1537 | + // add any fill color rules |
|
1538 | + if(!empty($fill)){ |
|
1539 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1540 | + } |
|
1541 | + if(!empty($fill_i)){ |
|
1542 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1543 | + } |
|
1544 | + |
|
1545 | + |
|
1546 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1547 | + |
|
1548 | + // darken |
|
1549 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1550 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1551 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1552 | + |
|
1553 | + // lighten |
|
1554 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1555 | + |
|
1556 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1557 | + $op_25 = $color_code."40"; // 25% opacity |
|
1558 | + |
|
1559 | + |
|
1560 | + // button states |
|
1561 | + $output .= $prefix ." .btn-primary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1562 | + $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;} "; |
|
1563 | + $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.";} "; |
|
1564 | + $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;} "; |
|
1565 | + |
|
1566 | + |
|
1567 | + // dropdown's |
|
1568 | + $output .= $prefix ." .dropdown-item.active, $prefix .dropdown-item:active{background-color: $color_code;} "; |
|
1569 | + |
|
1570 | + |
|
1571 | + // input states |
|
1572 | + $output .= $prefix ." .form-control:focus{border-color: ".$lighten_25.";box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1573 | + |
|
1574 | + // page link |
|
1575 | + $output .= $prefix ." .page-link:focus{box-shadow: 0 0 0 0.2rem $op_25;} "; |
|
1576 | + |
|
1577 | + return $output; |
|
1578 | + } |
|
1579 | + |
|
1580 | + public static function css_secondary($color_code,$compatibility){; |
|
1581 | + $color_code = sanitize_hex_color($color_code); |
|
1582 | + if(!$color_code){return '';} |
|
1583 | + /** |
|
1584 | + * c = color, b = background color, o = border-color, f = fill |
|
1585 | + */ |
|
1586 | + $selectors = array( |
|
1587 | + '.btn-secondary' => array('b','o'), |
|
1588 | + '.btn-secondary.disabled' => array('b','o'), |
|
1589 | + '.btn-secondary:disabled' => array('b','o'), |
|
1590 | + '.btn-outline-secondary' => array('c','o'), |
|
1591 | + '.btn-outline-secondary:hover' => array('b','o'), |
|
1592 | + '.btn-outline-secondary.disabled' => array('c'), |
|
1593 | + '.btn-outline-secondary:disabled' => array('c'), |
|
1594 | + '.btn-outline-secondary:not(:disabled):not(.disabled):active' => array('b','o'), |
|
1595 | + '.btn-outline-secondary:not(:disabled):not(.disabled).active' => array('b','o'), |
|
1596 | + '.btn-outline-secondary.dropdown-toggle' => array('b','o'), |
|
1597 | + '.badge-secondary' => array('b'), |
|
1598 | + '.alert-secondary' => array('b','o'), |
|
1599 | + '.btn-link.btn-secondary' => array('c'), |
|
1600 | + ); |
|
1601 | + |
|
1602 | + $important_selectors = array( |
|
1603 | + '.bg-secondary' => array('b','f'), |
|
1604 | + '.border-secondary' => array('o'), |
|
1605 | + '.text-secondary' => array('c'), |
|
1606 | + ); |
|
1607 | + |
|
1608 | + $color = array(); |
|
1609 | + $color_i = array(); |
|
1610 | + $background = array(); |
|
1611 | + $background_i = array(); |
|
1612 | + $border = array(); |
|
1613 | + $border_i = array(); |
|
1614 | + $fill = array(); |
|
1615 | + $fill_i = array(); |
|
1616 | + |
|
1617 | + $output = ''; |
|
1618 | + |
|
1619 | + // build rules into each type |
|
1620 | + foreach($selectors as $selector => $types){ |
|
1621 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1622 | + $types = array_combine($types,$types); |
|
1623 | + if(isset($types['c'])){$color[] = $selector;} |
|
1624 | + if(isset($types['b'])){$background[] = $selector;} |
|
1625 | + if(isset($types['o'])){$border[] = $selector;} |
|
1626 | + if(isset($types['f'])){$fill[] = $selector;} |
|
1627 | + } |
|
1628 | + |
|
1629 | + // build rules into each type |
|
1630 | + foreach($important_selectors as $selector => $types){ |
|
1631 | + $selector = $compatibility ? ".bsui ".$selector : $selector; |
|
1632 | + $types = array_combine($types,$types); |
|
1633 | + if(isset($types['c'])){$color_i[] = $selector;} |
|
1634 | + if(isset($types['b'])){$background_i[] = $selector;} |
|
1635 | + if(isset($types['o'])){$border_i[] = $selector;} |
|
1636 | + if(isset($types['f'])){$fill_i[] = $selector;} |
|
1637 | + } |
|
1638 | + |
|
1639 | + // add any color rules |
|
1640 | + if(!empty($color)){ |
|
1641 | + $output .= implode(",",$color) . "{color: $color_code;} "; |
|
1642 | + } |
|
1643 | + if(!empty($color_i)){ |
|
1644 | + $output .= implode(",",$color_i) . "{color: $color_code !important;} "; |
|
1645 | + } |
|
1646 | + |
|
1647 | + // add any background color rules |
|
1648 | + if(!empty($background)){ |
|
1649 | + $output .= implode(",",$background) . "{background-color: $color_code;} "; |
|
1650 | + } |
|
1651 | + if(!empty($background_i)){ |
|
1652 | + $output .= implode(",",$background_i) . "{background-color: $color_code !important;} "; |
|
1653 | + } |
|
1654 | + |
|
1655 | + // add any border color rules |
|
1656 | + if(!empty($border)){ |
|
1657 | + $output .= implode(",",$border) . "{border-color: $color_code;} "; |
|
1658 | + } |
|
1659 | + if(!empty($border_i)){ |
|
1660 | + $output .= implode(",",$border_i) . "{border-color: $color_code !important;} "; |
|
1661 | + } |
|
1662 | + |
|
1663 | + // add any fill color rules |
|
1664 | + if(!empty($fill)){ |
|
1665 | + $output .= implode(",",$fill) . "{fill: $color_code;} "; |
|
1666 | + } |
|
1667 | + if(!empty($fill_i)){ |
|
1668 | + $output .= implode(",",$fill_i) . "{fill: $color_code !important;} "; |
|
1669 | + } |
|
1670 | + |
|
1671 | + |
|
1672 | + $prefix = $compatibility ? ".bsui " : ""; |
|
1673 | + |
|
1674 | + // darken |
|
1675 | + $darker_075 = self::css_hex_lighten_darken($color_code,"-0.075"); |
|
1676 | + $darker_10 = self::css_hex_lighten_darken($color_code,"-0.10"); |
|
1677 | + $darker_125 = self::css_hex_lighten_darken($color_code,"-0.125"); |
|
1678 | + |
|
1679 | + // lighten |
|
1680 | + $lighten_25 = self::css_hex_lighten_darken($color_code,"0.25"); |
|
1681 | + |
|
1682 | + // opacity see https://css-tricks.com/8-digit-hex-codes/ |
|
1683 | + $op_25 = $color_code."40"; // 25% opacity |
|
1684 | + |
|
1685 | + |
|
1686 | + // button states |
|
1687 | + $output .= $prefix ." .btn-secondary:hover{background-color: ".$darker_075."; border-color: ".$darker_10.";} "; |
|
1688 | + $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;} "; |
|
1689 | + $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.";} "; |
|
1690 | + $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;} "; |
|
1691 | + |
|
1692 | + |
|
1693 | + return $output; |
|
1694 | + } |
|
1695 | + |
|
1696 | + /** |
|
1697 | + * Increases or decreases the brightness of a color by a percentage of the current brightness. |
|
1698 | + * |
|
1699 | + * @param string $hexCode Supported formats: `#FFF`, `#FFFFFF`, `FFF`, `FFFFFF` |
|
1700 | + * @param float $adjustPercent A number between -1 and 1. E.g. 0.3 = 30% lighter; -0.4 = 40% darker. |
|
1701 | + * |
|
1702 | + * @return string |
|
1703 | + */ |
|
1704 | + public static function css_hex_lighten_darken($hexCode, $adjustPercent) { |
|
1705 | + $hexCode = ltrim($hexCode, '#'); |
|
1706 | + |
|
1707 | + if (strlen($hexCode) == 3) { |
|
1708 | + $hexCode = $hexCode[0] . $hexCode[0] . $hexCode[1] . $hexCode[1] . $hexCode[2] . $hexCode[2]; |
|
1709 | + } |
|
1710 | + |
|
1711 | + $hexCode = array_map('hexdec', str_split($hexCode, 2)); |
|
1712 | + |
|
1713 | + foreach ($hexCode as & $color) { |
|
1714 | + $adjustableLimit = $adjustPercent < 0 ? $color : 255 - $color; |
|
1715 | + $adjustAmount = ceil($adjustableLimit * $adjustPercent); |
|
1716 | + |
|
1717 | + $color = str_pad(dechex($color + $adjustAmount), 2, '0', STR_PAD_LEFT); |
|
1718 | + } |
|
1719 | + |
|
1720 | + return '#' . implode($hexCode); |
|
1721 | + } |
|
1722 | + |
|
1723 | + /** |
|
1724 | + * Check if we should display examples. |
|
1725 | + */ |
|
1726 | + public function maybe_show_examples(){ |
|
1727 | + if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){ |
|
1728 | + echo "<head>"; |
|
1729 | + wp_head(); |
|
1730 | + echo "</head>"; |
|
1731 | + echo "<body>"; |
|
1732 | + echo $this->get_examples(); |
|
1733 | + echo "</body>"; |
|
1734 | + exit; |
|
1735 | + } |
|
1736 | + } |
|
1737 | + |
|
1738 | + /** |
|
1739 | + * Get developer examples. |
|
1740 | + * |
|
1741 | + * @return string |
|
1742 | + */ |
|
1743 | + public function get_examples(){ |
|
1744 | + $output = ''; |
|
1745 | + |
|
1746 | + |
|
1747 | + // open form |
|
1748 | + $output .= "<form class='p-5 m-5 border rounded'>"; |
|
1749 | + |
|
1750 | + // input example |
|
1751 | + $output .= aui()->input(array( |
|
1752 | + 'type' => 'text', |
|
1753 | + 'id' => 'text-example', |
|
1754 | + 'name' => 'text-example', |
|
1755 | + 'placeholder' => 'text placeholder', |
|
1756 | + 'title' => 'Text input example', |
|
1757 | + 'value' => '', |
|
1758 | + 'required' => false, |
|
1759 | + 'help_text' => 'help text', |
|
1760 | + 'label' => 'Text input example label' |
|
1761 | + )); |
|
1762 | + |
|
1763 | + // input example |
|
1764 | + $output .= aui()->input(array( |
|
1765 | + 'type' => 'url', |
|
1766 | + 'id' => 'text-example2', |
|
1767 | + 'name' => 'text-example', |
|
1768 | + 'placeholder' => 'url placeholder', |
|
1769 | + 'title' => 'Text input example', |
|
1770 | + 'value' => '', |
|
1771 | + 'required' => false, |
|
1772 | + 'help_text' => 'help text', |
|
1773 | + 'label' => 'Text input example label' |
|
1774 | + )); |
|
1775 | + |
|
1776 | + // checkbox example |
|
1777 | + $output .= aui()->input(array( |
|
1778 | + 'type' => 'checkbox', |
|
1779 | + 'id' => 'checkbox-example', |
|
1780 | + 'name' => 'checkbox-example', |
|
1781 | + 'placeholder' => 'checkbox-example', |
|
1782 | + 'title' => 'Checkbox example', |
|
1783 | + 'value' => '1', |
|
1784 | + 'checked' => true, |
|
1785 | + 'required' => false, |
|
1786 | + 'help_text' => 'help text', |
|
1787 | + 'label' => 'Checkbox checked' |
|
1788 | + )); |
|
1789 | + |
|
1790 | + // checkbox example |
|
1791 | + $output .= aui()->input(array( |
|
1792 | + 'type' => 'checkbox', |
|
1793 | + 'id' => 'checkbox-example2', |
|
1794 | + 'name' => 'checkbox-example2', |
|
1795 | + 'placeholder' => 'checkbox-example', |
|
1796 | + 'title' => 'Checkbox example', |
|
1797 | + 'value' => '1', |
|
1798 | + 'checked' => false, |
|
1799 | + 'required' => false, |
|
1800 | + 'help_text' => 'help text', |
|
1801 | + 'label' => 'Checkbox un-checked' |
|
1802 | + )); |
|
1803 | + |
|
1804 | + // switch example |
|
1805 | + $output .= aui()->input(array( |
|
1806 | + 'type' => 'checkbox', |
|
1807 | + 'id' => 'switch-example', |
|
1808 | + 'name' => 'switch-example', |
|
1809 | + 'placeholder' => 'checkbox-example', |
|
1810 | + 'title' => 'Switch example', |
|
1811 | + 'value' => '1', |
|
1812 | + 'checked' => true, |
|
1813 | + 'switch' => true, |
|
1814 | + 'required' => false, |
|
1815 | + 'help_text' => 'help text', |
|
1816 | + 'label' => 'Switch on' |
|
1817 | + )); |
|
1818 | + |
|
1819 | + // switch example |
|
1820 | + $output .= aui()->input(array( |
|
1821 | + 'type' => 'checkbox', |
|
1822 | + 'id' => 'switch-example2', |
|
1823 | + 'name' => 'switch-example2', |
|
1824 | + 'placeholder' => 'checkbox-example', |
|
1825 | + 'title' => 'Switch example', |
|
1826 | + 'value' => '1', |
|
1827 | + 'checked' => false, |
|
1828 | + 'switch' => true, |
|
1829 | + 'required' => false, |
|
1830 | + 'help_text' => 'help text', |
|
1831 | + 'label' => 'Switch off' |
|
1832 | + )); |
|
1833 | + |
|
1834 | + // close form |
|
1835 | + $output .= "</form>"; |
|
1836 | + |
|
1837 | + return $output; |
|
1838 | + } |
|
1839 | + |
|
1840 | + /** |
|
1841 | + * Calendar params. |
|
1842 | + * |
|
1843 | + * @since 0.1.44 |
|
1844 | + * |
|
1845 | + * @return array Calendar params. |
|
1846 | + */ |
|
1847 | + public static function calendar_params() { |
|
1848 | + $params = array( |
|
1849 | + 'month_long_1' => __( 'January', 'aui' ), |
|
1850 | + 'month_long_2' => __( 'February', 'aui' ), |
|
1851 | + 'month_long_3' => __( 'March', 'aui' ), |
|
1852 | + 'month_long_4' => __( 'April', 'aui' ), |
|
1853 | + 'month_long_5' => __( 'May', 'aui' ), |
|
1854 | + 'month_long_6' => __( 'June', 'aui' ), |
|
1855 | + 'month_long_7' => __( 'July', 'aui' ), |
|
1856 | + 'month_long_8' => __( 'August', 'aui' ), |
|
1857 | + 'month_long_9' => __( 'September', 'aui' ), |
|
1858 | + 'month_long_10' => __( 'October', 'aui' ), |
|
1859 | + 'month_long_11' => __( 'November', 'aui' ), |
|
1860 | + 'month_long_12' => __( 'December', 'aui' ), |
|
1861 | + 'month_s_1' => _x( 'Jan', 'January abbreviation', 'aui' ), |
|
1862 | + 'month_s_2' => _x( 'Feb', 'February abbreviation', 'aui' ), |
|
1863 | + 'month_s_3' => _x( 'Mar', 'March abbreviation', 'aui' ), |
|
1864 | + 'month_s_4' => _x( 'Apr', 'April abbreviation', 'aui' ), |
|
1865 | + 'month_s_5' => _x( 'May', 'May abbreviation', 'aui' ), |
|
1866 | + 'month_s_6' => _x( 'Jun', 'June abbreviation', 'aui' ), |
|
1867 | + 'month_s_7' => _x( 'Jul', 'July abbreviation', 'aui' ), |
|
1868 | + 'month_s_8' => _x( 'Aug', 'August abbreviation', 'aui' ), |
|
1869 | + 'month_s_9' => _x( 'Sep', 'September abbreviation', 'aui' ), |
|
1870 | + 'month_s_10' => _x( 'Oct', 'October abbreviation', 'aui' ), |
|
1871 | + 'month_s_11' => _x( 'Nov', 'November abbreviation', 'aui' ), |
|
1872 | + 'month_s_12' => _x( 'Dec', 'December abbreviation', 'aui' ), |
|
1873 | + 'day_s1_1' => _x( 'S', 'Sunday initial', 'aui' ), |
|
1874 | + 'day_s1_2' => _x( 'M', 'Monday initial', 'aui' ), |
|
1875 | + 'day_s1_3' => _x( 'T', 'Tuesday initial', 'aui' ), |
|
1876 | + 'day_s1_4' => _x( 'W', 'Wednesday initial', 'aui' ), |
|
1877 | + 'day_s1_5' => _x( 'T', 'Friday initial', 'aui' ), |
|
1878 | + 'day_s1_6' => _x( 'F', 'Thursday initial', 'aui' ), |
|
1879 | + 'day_s1_7' => _x( 'S', 'Saturday initial', 'aui' ), |
|
1880 | + 'day_s2_1' => __( 'Su', 'aui' ), |
|
1881 | + 'day_s2_2' => __( 'Mo', 'aui' ), |
|
1882 | + 'day_s2_3' => __( 'Tu', 'aui' ), |
|
1883 | + 'day_s2_4' => __( 'We', 'aui' ), |
|
1884 | + 'day_s2_5' => __( 'Th', 'aui' ), |
|
1885 | + 'day_s2_6' => __( 'Fr', 'aui' ), |
|
1886 | + 'day_s2_7' => __( 'Sa', 'aui' ), |
|
1887 | + 'day_s3_1' => __( 'Sun', 'aui' ), |
|
1888 | + 'day_s3_2' => __( 'Mon', 'aui' ), |
|
1889 | + 'day_s3_3' => __( 'Tue', 'aui' ), |
|
1890 | + 'day_s3_4' => __( 'Wed', 'aui' ), |
|
1891 | + 'day_s3_5' => __( 'Thu', 'aui' ), |
|
1892 | + 'day_s3_6' => __( 'Fri', 'aui' ), |
|
1893 | + 'day_s3_7' => __( 'Sat', 'aui' ), |
|
1894 | + 'day_s5_1' => __( 'Sunday', 'aui' ), |
|
1895 | + 'day_s5_2' => __( 'Monday', 'aui' ), |
|
1896 | + 'day_s5_3' => __( 'Tuesday', 'aui' ), |
|
1897 | + 'day_s5_4' => __( 'Wednesday', 'aui' ), |
|
1898 | + 'day_s5_5' => __( 'Thursday', 'aui' ), |
|
1899 | + 'day_s5_6' => __( 'Friday', 'aui' ), |
|
1900 | + 'day_s5_7' => __( 'Saturday', 'aui' ), |
|
1901 | + 'am_lower' => __( 'am', 'aui' ), |
|
1902 | + 'pm_lower' => __( 'pm', 'aui' ), |
|
1903 | + 'am_upper' => __( 'AM', 'aui' ), |
|
1904 | + 'pm_upper' => __( 'PM', 'aui' ), |
|
1905 | + 'firstDayOfWeek' => (int) get_option( 'start_of_week' ), |
|
1906 | + 'time_24hr' => false, |
|
1907 | + 'year' => __( 'Year', 'aui' ), |
|
1908 | + 'hour' => __( 'Hour', 'aui' ), |
|
1909 | + 'minute' => __( 'Minute', 'aui' ), |
|
1910 | + 'weekAbbreviation' => __( 'Wk', 'aui' ), |
|
1911 | + 'rangeSeparator' => __( ' to ', 'aui' ), |
|
1912 | + 'scrollTitle' => __( 'Scroll to increment', 'aui' ), |
|
1913 | + 'toggleTitle' => __( 'Click to toggle', 'aui' ) |
|
1914 | + ); |
|
1915 | + |
|
1916 | + return apply_filters( 'ayecode_ui_calendar_params', $params ); |
|
1917 | + } |
|
1918 | + |
|
1919 | + /** |
|
1920 | + * Flatpickr calendar localize. |
|
1921 | + * |
|
1922 | + * @since 0.1.44 |
|
1923 | + * |
|
1924 | + * @return string Calendar locale. |
|
1925 | + */ |
|
1926 | + public static function flatpickr_locale() { |
|
1927 | + $params = self::calendar_params(); |
|
1928 | + |
|
1929 | + if ( is_string( $params ) ) { |
|
1930 | + $params = html_entity_decode( $params, ENT_QUOTES, 'UTF-8' ); |
|
1931 | + } else { |
|
1932 | + foreach ( (array) $params as $key => $value ) { |
|
1933 | + if ( ! is_scalar( $value ) ) { |
|
1934 | + continue; |
|
1935 | + } |
|
1936 | + |
|
1937 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
1938 | + } |
|
1939 | + } |
|
1940 | 1940 | |
1941 | - $day_s3 = array(); |
|
1942 | - $day_s5 = array(); |
|
1941 | + $day_s3 = array(); |
|
1942 | + $day_s5 = array(); |
|
1943 | 1943 | |
1944 | - for ( $i = 1; $i <= 7; $i ++ ) { |
|
1945 | - $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1946 | - $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1947 | - } |
|
1944 | + for ( $i = 1; $i <= 7; $i ++ ) { |
|
1945 | + $day_s3[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1946 | + $day_s5[] = addslashes( $params[ 'day_s3_' . $i ] ); |
|
1947 | + } |
|
1948 | 1948 | |
1949 | - $month_s = array(); |
|
1950 | - $month_long = array(); |
|
1949 | + $month_s = array(); |
|
1950 | + $month_long = array(); |
|
1951 | 1951 | |
1952 | - for ( $i = 1; $i <= 12; $i ++ ) { |
|
1953 | - $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1954 | - $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1955 | - } |
|
1952 | + for ( $i = 1; $i <= 12; $i ++ ) { |
|
1953 | + $month_s[] = addslashes( $params[ 'month_s_' . $i ] ); |
|
1954 | + $month_long[] = addslashes( $params[ 'month_long_' . $i ] ); |
|
1955 | + } |
|
1956 | 1956 | |
1957 | 1957 | ob_start(); |
1958 | 1958 | if ( 0 ) { ?><script><?php } ?> |
@@ -1994,184 +1994,184 @@ discard block |
||
1994 | 1994 | } |
1995 | 1995 | <?php if ( 0 ) { ?></script><?php } ?> |
1996 | 1996 | <?php |
1997 | - $locale = ob_get_clean(); |
|
1998 | - |
|
1999 | - return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2000 | - } |
|
2001 | - |
|
2002 | - /** |
|
2003 | - * Select2 JS params. |
|
2004 | - * |
|
2005 | - * @since 0.1.44 |
|
2006 | - * |
|
2007 | - * @return array Select2 JS params. |
|
2008 | - */ |
|
2009 | - public static function select2_params() { |
|
2010 | - $params = array( |
|
2011 | - 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2012 | - 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2013 | - 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2014 | - 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2015 | - 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2016 | - 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2017 | - 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2018 | - 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2019 | - 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2020 | - 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2021 | - 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2022 | - ); |
|
2023 | - |
|
2024 | - return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2025 | - } |
|
2026 | - |
|
2027 | - /** |
|
2028 | - * Select2 JS localize. |
|
2029 | - * |
|
2030 | - * @since 0.1.44 |
|
2031 | - * |
|
2032 | - * @return string Select2 JS locale. |
|
2033 | - */ |
|
2034 | - public static function select2_locale() { |
|
2035 | - $params = self::select2_params(); |
|
2036 | - |
|
2037 | - foreach ( (array) $params as $key => $value ) { |
|
2038 | - if ( ! is_scalar( $value ) ) { |
|
2039 | - continue; |
|
2040 | - } |
|
2041 | - |
|
2042 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2043 | - } |
|
2044 | - |
|
2045 | - $locale = json_encode( $params ); |
|
2046 | - |
|
2047 | - return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2048 | - } |
|
2049 | - |
|
2050 | - /** |
|
2051 | - * Time ago JS localize. |
|
2052 | - * |
|
2053 | - * @since 0.1.47 |
|
2054 | - * |
|
2055 | - * @return string Time ago JS locale. |
|
2056 | - */ |
|
2057 | - public static function timeago_locale() { |
|
2058 | - $params = array( |
|
2059 | - 'prefix_ago' => '', |
|
2060 | - 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2061 | - 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2062 | - 'suffix_after' => '', |
|
2063 | - 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2064 | - 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2065 | - 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2066 | - 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2067 | - 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2068 | - 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2069 | - 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2070 | - 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2071 | - 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2072 | - 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2073 | - 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2074 | - ); |
|
2075 | - |
|
2076 | - $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2077 | - |
|
2078 | - foreach ( (array) $params as $key => $value ) { |
|
2079 | - if ( ! is_scalar( $value ) ) { |
|
2080 | - continue; |
|
2081 | - } |
|
2082 | - |
|
2083 | - $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2084 | - } |
|
2085 | - |
|
2086 | - $locale = json_encode( $params ); |
|
2087 | - |
|
2088 | - return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2089 | - } |
|
2090 | - |
|
2091 | - /** |
|
2092 | - * JavaScript Minifier |
|
2093 | - * |
|
2094 | - * @param $input |
|
2095 | - * |
|
2096 | - * @return mixed |
|
2097 | - */ |
|
2098 | - public static function minify_js($input) { |
|
2099 | - if(trim($input) === "") return $input; |
|
2100 | - return preg_replace( |
|
2101 | - array( |
|
2102 | - // Remove comment(s) |
|
2103 | - '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2104 | - // Remove white-space(s) outside the string and regex |
|
2105 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2106 | - // Remove the last semicolon |
|
2107 | - '#;+\}#', |
|
2108 | - // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2109 | - '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2110 | - // --ibid. From `foo['bar']` to `foo.bar` |
|
2111 | - '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2112 | - ), |
|
2113 | - array( |
|
2114 | - '$1', |
|
2115 | - '$1$2', |
|
2116 | - '}', |
|
2117 | - '$1$3', |
|
2118 | - '$1.$3' |
|
2119 | - ), |
|
2120 | - $input); |
|
2121 | - } |
|
1997 | + $locale = ob_get_clean(); |
|
1998 | + |
|
1999 | + return apply_filters( 'ayecode_ui_flatpickr_locale', trim( $locale ) ); |
|
2000 | + } |
|
2001 | + |
|
2002 | + /** |
|
2003 | + * Select2 JS params. |
|
2004 | + * |
|
2005 | + * @since 0.1.44 |
|
2006 | + * |
|
2007 | + * @return array Select2 JS params. |
|
2008 | + */ |
|
2009 | + public static function select2_params() { |
|
2010 | + $params = array( |
|
2011 | + 'i18n_select_state_text' => esc_attr__( 'Select an option…', 'aui' ), |
|
2012 | + 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'aui' ), |
|
2013 | + 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'aui' ), |
|
2014 | + 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'aui' ), |
|
2015 | + 'i18n_input_too_short_n' => _x( 'Please enter %item% or more characters', 'enhanced select', 'aui' ), |
|
2016 | + 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'aui' ), |
|
2017 | + 'i18n_input_too_long_n' => _x( 'Please delete %item% characters', 'enhanced select', 'aui' ), |
|
2018 | + 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'aui' ), |
|
2019 | + 'i18n_selection_too_long_n' => _x( 'You can only select %item% items', 'enhanced select', 'aui' ), |
|
2020 | + 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'aui' ), |
|
2021 | + 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'aui' ) |
|
2022 | + ); |
|
2023 | + |
|
2024 | + return apply_filters( 'ayecode_ui_select2_params', $params ); |
|
2025 | + } |
|
2026 | + |
|
2027 | + /** |
|
2028 | + * Select2 JS localize. |
|
2029 | + * |
|
2030 | + * @since 0.1.44 |
|
2031 | + * |
|
2032 | + * @return string Select2 JS locale. |
|
2033 | + */ |
|
2034 | + public static function select2_locale() { |
|
2035 | + $params = self::select2_params(); |
|
2036 | + |
|
2037 | + foreach ( (array) $params as $key => $value ) { |
|
2038 | + if ( ! is_scalar( $value ) ) { |
|
2039 | + continue; |
|
2040 | + } |
|
2122 | 2041 | |
2123 | - /** |
|
2124 | - * Minify CSS |
|
2125 | - * |
|
2126 | - * @param $input |
|
2127 | - * |
|
2128 | - * @return mixed |
|
2129 | - */ |
|
2130 | - public static function minify_css($input) { |
|
2131 | - if(trim($input) === "") return $input; |
|
2132 | - return preg_replace( |
|
2133 | - array( |
|
2134 | - // Remove comment(s) |
|
2135 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2136 | - // Remove unused white-space(s) |
|
2137 | - '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2138 | - // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2139 | - '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2140 | - // Replace `:0 0 0 0` with `:0` |
|
2141 | - '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2142 | - // Replace `background-position:0` with `background-position:0 0` |
|
2143 | - '#(background-position):0(?=[;\}])#si', |
|
2144 | - // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2145 | - '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2146 | - // Minify string value |
|
2147 | - '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2148 | - '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2149 | - // Minify HEX color code |
|
2150 | - '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2151 | - // Replace `(border|outline):none` with `(border|outline):0` |
|
2152 | - '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2153 | - // Remove empty selector(s) |
|
2154 | - '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2155 | - ), |
|
2156 | - array( |
|
2157 | - '$1', |
|
2158 | - '$1$2$3$4$5$6$7', |
|
2159 | - '$1', |
|
2160 | - ':0', |
|
2161 | - '$1:0 0', |
|
2162 | - '.$1', |
|
2163 | - '$1$3', |
|
2164 | - '$1$2$4$5', |
|
2165 | - '$1$2$3', |
|
2166 | - '$1:0', |
|
2167 | - '$1$2' |
|
2168 | - ), |
|
2169 | - $input); |
|
2170 | - } |
|
2171 | - } |
|
2042 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2043 | + } |
|
2044 | + |
|
2045 | + $locale = json_encode( $params ); |
|
2046 | + |
|
2047 | + return apply_filters( 'ayecode_ui_select2_locale', trim( $locale ) ); |
|
2048 | + } |
|
2049 | + |
|
2050 | + /** |
|
2051 | + * Time ago JS localize. |
|
2052 | + * |
|
2053 | + * @since 0.1.47 |
|
2054 | + * |
|
2055 | + * @return string Time ago JS locale. |
|
2056 | + */ |
|
2057 | + public static function timeago_locale() { |
|
2058 | + $params = array( |
|
2059 | + 'prefix_ago' => '', |
|
2060 | + 'suffix_ago' => ' ' . _x( 'ago', 'time ago', 'aui' ), |
|
2061 | + 'prefix_after' => _x( 'after', 'time ago', 'aui' ) . ' ', |
|
2062 | + 'suffix_after' => '', |
|
2063 | + 'seconds' => _x( 'less than a minute', 'time ago', 'aui' ), |
|
2064 | + 'minute' => _x( 'about a minute', 'time ago', 'aui' ), |
|
2065 | + 'minutes' => _x( '%d minutes', 'time ago', 'aui' ), |
|
2066 | + 'hour' => _x( 'about an hour', 'time ago', 'aui' ), |
|
2067 | + 'hours' => _x( 'about %d hours', 'time ago', 'aui' ), |
|
2068 | + 'day' => _x( 'a day', 'time ago', 'aui' ), |
|
2069 | + 'days' => _x( '%d days', 'time ago', 'aui' ), |
|
2070 | + 'month' => _x( 'about a month', 'time ago', 'aui' ), |
|
2071 | + 'months' => _x( '%d months', 'time ago', 'aui' ), |
|
2072 | + 'year' => _x( 'about a year', 'time ago', 'aui' ), |
|
2073 | + 'years' => _x( '%d years', 'time ago', 'aui' ), |
|
2074 | + ); |
|
2075 | + |
|
2076 | + $params = apply_filters( 'ayecode_ui_timeago_params', $params ); |
|
2077 | + |
|
2078 | + foreach ( (array) $params as $key => $value ) { |
|
2079 | + if ( ! is_scalar( $value ) ) { |
|
2080 | + continue; |
|
2081 | + } |
|
2172 | 2082 | |
2173 | - /** |
|
2174 | - * Run the class if found. |
|
2175 | - */ |
|
2176 | - AyeCode_UI_Settings::instance(); |
|
2083 | + $params[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); |
|
2084 | + } |
|
2085 | + |
|
2086 | + $locale = json_encode( $params ); |
|
2087 | + |
|
2088 | + return apply_filters( 'ayecode_ui_timeago_locale', trim( $locale ) ); |
|
2089 | + } |
|
2090 | + |
|
2091 | + /** |
|
2092 | + * JavaScript Minifier |
|
2093 | + * |
|
2094 | + * @param $input |
|
2095 | + * |
|
2096 | + * @return mixed |
|
2097 | + */ |
|
2098 | + public static function minify_js($input) { |
|
2099 | + if(trim($input) === "") return $input; |
|
2100 | + return preg_replace( |
|
2101 | + array( |
|
2102 | + // Remove comment(s) |
|
2103 | + '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@cc_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', |
|
2104 | + // Remove white-space(s) outside the string and regex |
|
2105 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', |
|
2106 | + // Remove the last semicolon |
|
2107 | + '#;+\}#', |
|
2108 | + // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` |
|
2109 | + '#([\{,])([\'])(\d+|[a-z_][a-z0-9_]*)\2(?=\:)#i', |
|
2110 | + // --ibid. From `foo['bar']` to `foo.bar` |
|
2111 | + '#([a-z0-9_\)\]])\[([\'"])([a-z_][a-z0-9_]*)\2\]#i' |
|
2112 | + ), |
|
2113 | + array( |
|
2114 | + '$1', |
|
2115 | + '$1$2', |
|
2116 | + '}', |
|
2117 | + '$1$3', |
|
2118 | + '$1.$3' |
|
2119 | + ), |
|
2120 | + $input); |
|
2121 | + } |
|
2122 | + |
|
2123 | + /** |
|
2124 | + * Minify CSS |
|
2125 | + * |
|
2126 | + * @param $input |
|
2127 | + * |
|
2128 | + * @return mixed |
|
2129 | + */ |
|
2130 | + public static function minify_css($input) { |
|
2131 | + if(trim($input) === "") return $input; |
|
2132 | + return preg_replace( |
|
2133 | + array( |
|
2134 | + // Remove comment(s) |
|
2135 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', |
|
2136 | + // Remove unused white-space(s) |
|
2137 | + '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~]|\s(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', |
|
2138 | + // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` |
|
2139 | + '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', |
|
2140 | + // Replace `:0 0 0 0` with `:0` |
|
2141 | + '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', |
|
2142 | + // Replace `background-position:0` with `background-position:0 0` |
|
2143 | + '#(background-position):0(?=[;\}])#si', |
|
2144 | + // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space |
|
2145 | + '#(?<=[\s:,\-])0+\.(\d+)#s', |
|
2146 | + // Minify string value |
|
2147 | + '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si', |
|
2148 | + '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', |
|
2149 | + // Minify HEX color code |
|
2150 | + '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', |
|
2151 | + // Replace `(border|outline):none` with `(border|outline):0` |
|
2152 | + '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', |
|
2153 | + // Remove empty selector(s) |
|
2154 | + '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s' |
|
2155 | + ), |
|
2156 | + array( |
|
2157 | + '$1', |
|
2158 | + '$1$2$3$4$5$6$7', |
|
2159 | + '$1', |
|
2160 | + ':0', |
|
2161 | + '$1:0 0', |
|
2162 | + '.$1', |
|
2163 | + '$1$3', |
|
2164 | + '$1$2$4$5', |
|
2165 | + '$1$2$3', |
|
2166 | + '$1:0', |
|
2167 | + '$1$2' |
|
2168 | + ), |
|
2169 | + $input); |
|
2170 | + } |
|
2171 | + } |
|
2172 | + |
|
2173 | + /** |
|
2174 | + * Run the class if found. |
|
2175 | + */ |
|
2176 | + AyeCode_UI_Settings::instance(); |
|
2177 | 2177 | } |
2178 | 2178 | \ No newline at end of file |
@@ -7,40 +7,40 @@ |
||
7 | 7 | * Bail if we are not in WP. |
8 | 8 | */ |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; |
|
10 | + exit; |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Set the version only if its the current newest while loading. |
15 | 15 | */ |
16 | 16 | add_action('after_setup_theme', function () { |
17 | - global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | - $this_version = "0.1.49"; |
|
19 | - if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | - $ayecode_ui_version = $this_version ; |
|
21 | - $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | - } |
|
17 | + global $ayecode_ui_version,$ayecode_ui_file_key; |
|
18 | + $this_version = "0.1.49"; |
|
19 | + if(version_compare($this_version , $ayecode_ui_version, '>')){ |
|
20 | + $ayecode_ui_version = $this_version ; |
|
21 | + $ayecode_ui_file_key = wp_hash( __FILE__ ); |
|
22 | + } |
|
23 | 23 | },0); |
24 | 24 | |
25 | 25 | /** |
26 | 26 | * Load this version of WP Bootstrap Settings only if the file hash is the current one. |
27 | 27 | */ |
28 | 28 | add_action('after_setup_theme', function () { |
29 | - global $ayecode_ui_file_key; |
|
30 | - if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | - include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | - include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | - } |
|
29 | + global $ayecode_ui_file_key; |
|
30 | + if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){ |
|
31 | + include_once( dirname( __FILE__ ) . '/includes/class-aui.php' ); |
|
32 | + include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' ); |
|
33 | + } |
|
34 | 34 | },1); |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Add the function that calls the class. |
38 | 38 | */ |
39 | 39 | if(!function_exists('aui')){ |
40 | - function aui(){ |
|
41 | - if(!class_exists("AUI",false)){ |
|
42 | - return false; |
|
43 | - } |
|
44 | - return AUI::instance(); |
|
45 | - } |
|
40 | + function aui(){ |
|
41 | + if(!class_exists("AUI",false)){ |
|
42 | + return false; |
|
43 | + } |
|
44 | + return AUI::instance(); |
|
45 | + } |
|
46 | 46 | } |
47 | 47 | \ No newline at end of file |
@@ -12,8 +12,8 @@ discard block |
||
12 | 12 | class InstalledVersions |
13 | 13 | { |
14 | 14 | private static $installed = array ( |
15 | - 'root' => |
|
16 | - array ( |
|
15 | + 'root' => |
|
16 | + array ( |
|
17 | 17 | 'pretty_version' => 'dev-master', |
18 | 18 | 'version' => 'dev-master', |
19 | 19 | 'aliases' => |
@@ -21,87 +21,87 @@ discard block |
||
21 | 21 | ), |
22 | 22 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
23 | 23 | 'name' => 'ayecode/invoicing', |
24 | - ), |
|
25 | - 'versions' => |
|
26 | - array ( |
|
24 | + ), |
|
25 | + 'versions' => |
|
26 | + array ( |
|
27 | 27 | 'ayecode/ayecode-connect-helper' => |
28 | 28 | array ( |
29 | - 'pretty_version' => '1.0.3', |
|
30 | - 'version' => '1.0.3.0', |
|
31 | - 'aliases' => |
|
32 | - array ( |
|
33 | - ), |
|
34 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
29 | + 'pretty_version' => '1.0.3', |
|
30 | + 'version' => '1.0.3.0', |
|
31 | + 'aliases' => |
|
32 | + array ( |
|
33 | + ), |
|
34 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
35 | 35 | ), |
36 | 36 | 'ayecode/invoicing' => |
37 | 37 | array ( |
38 | - 'pretty_version' => 'dev-master', |
|
39 | - 'version' => 'dev-master', |
|
40 | - 'aliases' => |
|
41 | - array ( |
|
42 | - ), |
|
43 | - 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
38 | + 'pretty_version' => 'dev-master', |
|
39 | + 'version' => 'dev-master', |
|
40 | + 'aliases' => |
|
41 | + array ( |
|
42 | + ), |
|
43 | + 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
44 | 44 | ), |
45 | 45 | 'ayecode/wp-ayecode-ui' => |
46 | 46 | array ( |
47 | - 'pretty_version' => '0.1.49', |
|
48 | - 'version' => '0.1.49.0', |
|
49 | - 'aliases' => |
|
50 | - array ( |
|
51 | - ), |
|
52 | - 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
47 | + 'pretty_version' => '0.1.49', |
|
48 | + 'version' => '0.1.49.0', |
|
49 | + 'aliases' => |
|
50 | + array ( |
|
51 | + ), |
|
52 | + 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
53 | 53 | ), |
54 | 54 | 'ayecode/wp-font-awesome-settings' => |
55 | 55 | array ( |
56 | - 'pretty_version' => '1.0.12', |
|
57 | - 'version' => '1.0.12.0', |
|
58 | - 'aliases' => |
|
59 | - array ( |
|
60 | - ), |
|
61 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
56 | + 'pretty_version' => '1.0.12', |
|
57 | + 'version' => '1.0.12.0', |
|
58 | + 'aliases' => |
|
59 | + array ( |
|
60 | + ), |
|
61 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
62 | 62 | ), |
63 | 63 | 'ayecode/wp-super-duper' => |
64 | 64 | array ( |
65 | - 'pretty_version' => '1.0.26', |
|
66 | - 'version' => '1.0.26.0', |
|
67 | - 'aliases' => |
|
68 | - array ( |
|
69 | - ), |
|
70 | - 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
65 | + 'pretty_version' => '1.0.26', |
|
66 | + 'version' => '1.0.26.0', |
|
67 | + 'aliases' => |
|
68 | + array ( |
|
69 | + ), |
|
70 | + 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
71 | 71 | ), |
72 | 72 | 'composer/installers' => |
73 | 73 | array ( |
74 | - 'pretty_version' => 'v1.11.0', |
|
75 | - 'version' => '1.11.0.0', |
|
76 | - 'aliases' => |
|
77 | - array ( |
|
78 | - ), |
|
79 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
74 | + 'pretty_version' => 'v1.11.0', |
|
75 | + 'version' => '1.11.0.0', |
|
76 | + 'aliases' => |
|
77 | + array ( |
|
78 | + ), |
|
79 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
80 | 80 | ), |
81 | 81 | 'maxmind-db/reader' => |
82 | 82 | array ( |
83 | - 'pretty_version' => 'v1.6.0', |
|
84 | - 'version' => '1.6.0.0', |
|
85 | - 'aliases' => |
|
86 | - array ( |
|
87 | - ), |
|
88 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
83 | + 'pretty_version' => 'v1.6.0', |
|
84 | + 'version' => '1.6.0.0', |
|
85 | + 'aliases' => |
|
86 | + array ( |
|
87 | + ), |
|
88 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
89 | 89 | ), |
90 | 90 | 'roundcube/plugin-installer' => |
91 | 91 | array ( |
92 | - 'replaced' => |
|
93 | - array ( |
|
92 | + 'replaced' => |
|
93 | + array ( |
|
94 | 94 | 0 => '*', |
95 | - ), |
|
95 | + ), |
|
96 | 96 | ), |
97 | 97 | 'shama/baton' => |
98 | 98 | array ( |
99 | - 'replaced' => |
|
100 | - array ( |
|
99 | + 'replaced' => |
|
100 | + array ( |
|
101 | 101 | 0 => '*', |
102 | - ), |
|
102 | + ), |
|
103 | + ), |
|
103 | 104 | ), |
104 | - ), |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php return array ( |
2 | - 'root' => |
|
3 | - array ( |
|
2 | + 'root' => |
|
3 | + array ( |
|
4 | 4 | 'pretty_version' => 'dev-master', |
5 | 5 | 'version' => 'dev-master', |
6 | 6 | 'aliases' => |
@@ -8,85 +8,85 @@ discard block |
||
8 | 8 | ), |
9 | 9 | 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
10 | 10 | 'name' => 'ayecode/invoicing', |
11 | - ), |
|
12 | - 'versions' => |
|
13 | - array ( |
|
11 | + ), |
|
12 | + 'versions' => |
|
13 | + array ( |
|
14 | 14 | 'ayecode/ayecode-connect-helper' => |
15 | 15 | array ( |
16 | - 'pretty_version' => '1.0.3', |
|
17 | - 'version' => '1.0.3.0', |
|
18 | - 'aliases' => |
|
19 | - array ( |
|
20 | - ), |
|
21 | - 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
16 | + 'pretty_version' => '1.0.3', |
|
17 | + 'version' => '1.0.3.0', |
|
18 | + 'aliases' => |
|
19 | + array ( |
|
20 | + ), |
|
21 | + 'reference' => '1af7cdefdbd20d4443a3ab4834e4c1cd8fe57fb4', |
|
22 | 22 | ), |
23 | 23 | 'ayecode/invoicing' => |
24 | 24 | array ( |
25 | - 'pretty_version' => 'dev-master', |
|
26 | - 'version' => 'dev-master', |
|
27 | - 'aliases' => |
|
28 | - array ( |
|
29 | - ), |
|
30 | - 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
25 | + 'pretty_version' => 'dev-master', |
|
26 | + 'version' => 'dev-master', |
|
27 | + 'aliases' => |
|
28 | + array ( |
|
29 | + ), |
|
30 | + 'reference' => '7382ee9010a937feb1a5f52ade4e45a6b171565e', |
|
31 | 31 | ), |
32 | 32 | 'ayecode/wp-ayecode-ui' => |
33 | 33 | array ( |
34 | - 'pretty_version' => '0.1.49', |
|
35 | - 'version' => '0.1.49.0', |
|
36 | - 'aliases' => |
|
37 | - array ( |
|
38 | - ), |
|
39 | - 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
34 | + 'pretty_version' => '0.1.49', |
|
35 | + 'version' => '0.1.49.0', |
|
36 | + 'aliases' => |
|
37 | + array ( |
|
38 | + ), |
|
39 | + 'reference' => '00082d05acd50d4ce103e054f483ca24f106f93c', |
|
40 | 40 | ), |
41 | 41 | 'ayecode/wp-font-awesome-settings' => |
42 | 42 | array ( |
43 | - 'pretty_version' => '1.0.12', |
|
44 | - 'version' => '1.0.12.0', |
|
45 | - 'aliases' => |
|
46 | - array ( |
|
47 | - ), |
|
48 | - 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
43 | + 'pretty_version' => '1.0.12', |
|
44 | + 'version' => '1.0.12.0', |
|
45 | + 'aliases' => |
|
46 | + array ( |
|
47 | + ), |
|
48 | + 'reference' => '754cca6fda775f3e0b56b90a810dfcaea62ea288', |
|
49 | 49 | ), |
50 | 50 | 'ayecode/wp-super-duper' => |
51 | 51 | array ( |
52 | - 'pretty_version' => '1.0.26', |
|
53 | - 'version' => '1.0.26.0', |
|
54 | - 'aliases' => |
|
55 | - array ( |
|
56 | - ), |
|
57 | - 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
52 | + 'pretty_version' => '1.0.26', |
|
53 | + 'version' => '1.0.26.0', |
|
54 | + 'aliases' => |
|
55 | + array ( |
|
56 | + ), |
|
57 | + 'reference' => '9f0c4fc4ff5fc3ffbe3346ae9964ae11b7032131', |
|
58 | 58 | ), |
59 | 59 | 'composer/installers' => |
60 | 60 | array ( |
61 | - 'pretty_version' => 'v1.11.0', |
|
62 | - 'version' => '1.11.0.0', |
|
63 | - 'aliases' => |
|
64 | - array ( |
|
65 | - ), |
|
66 | - 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
61 | + 'pretty_version' => 'v1.11.0', |
|
62 | + 'version' => '1.11.0.0', |
|
63 | + 'aliases' => |
|
64 | + array ( |
|
65 | + ), |
|
66 | + 'reference' => 'ae03311f45dfe194412081526be2e003960df74b', |
|
67 | 67 | ), |
68 | 68 | 'maxmind-db/reader' => |
69 | 69 | array ( |
70 | - 'pretty_version' => 'v1.6.0', |
|
71 | - 'version' => '1.6.0.0', |
|
72 | - 'aliases' => |
|
73 | - array ( |
|
74 | - ), |
|
75 | - 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
70 | + 'pretty_version' => 'v1.6.0', |
|
71 | + 'version' => '1.6.0.0', |
|
72 | + 'aliases' => |
|
73 | + array ( |
|
74 | + ), |
|
75 | + 'reference' => 'febd4920bf17c1da84cef58e56a8227dfb37fbe4', |
|
76 | 76 | ), |
77 | 77 | 'roundcube/plugin-installer' => |
78 | 78 | array ( |
79 | - 'replaced' => |
|
80 | - array ( |
|
79 | + 'replaced' => |
|
80 | + array ( |
|
81 | 81 | 0 => '*', |
82 | - ), |
|
82 | + ), |
|
83 | 83 | ), |
84 | 84 | 'shama/baton' => |
85 | 85 | array ( |
86 | - 'replaced' => |
|
87 | - array ( |
|
86 | + 'replaced' => |
|
87 | + array ( |
|
88 | 88 | 0 => '*', |
89 | - ), |
|
89 | + ), |
|
90 | + ), |
|
90 | 91 | ), |
91 | - ), |
|
92 | 92 | ); |
@@ -276,26 +276,26 @@ discard block |
||
276 | 276 | } |
277 | 277 | |
278 | 278 | function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
279 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
279 | + $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
280 | 280 | |
281 | 281 | $chosen = false; |
282 | 282 | if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
283 | 283 | $chosen = $invoice->get_gateway(); |
284 | 284 | } |
285 | 285 | |
286 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
286 | + $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
287 | 287 | |
288 | - if ( false !== $chosen ) { |
|
289 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
290 | - } |
|
288 | + if ( false !== $chosen ) { |
|
289 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
290 | + } |
|
291 | 291 | |
292 | - if ( ! empty ( $chosen ) ) { |
|
293 | - $enabled_gateway = urldecode( $chosen ); |
|
294 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
295 | - $enabled_gateway = 'manual'; |
|
296 | - } else { |
|
297 | - $enabled_gateway = wpinv_get_default_gateway(); |
|
298 | - } |
|
292 | + if ( ! empty ( $chosen ) ) { |
|
293 | + $enabled_gateway = urldecode( $chosen ); |
|
294 | + } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
295 | + $enabled_gateway = 'manual'; |
|
296 | + } else { |
|
297 | + $enabled_gateway = wpinv_get_default_gateway(); |
|
298 | + } |
|
299 | 299 | |
300 | 300 | if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
301 | 301 | if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | |
307 | 307 | } |
308 | 308 | |
309 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
309 | + return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | function wpinv_record_gateway_error( $title = '', $message = '' ) { |
@@ -314,21 +314,21 @@ discard block |
||
314 | 314 | } |
315 | 315 | |
316 | 316 | function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
317 | - $ret = 0; |
|
318 | - $args = array( |
|
319 | - 'meta_key' => '_wpinv_gateway', |
|
320 | - 'meta_value' => $gateway_id, |
|
321 | - 'nopaging' => true, |
|
322 | - 'post_type' => 'wpi_invoice', |
|
323 | - 'post_status' => $status, |
|
324 | - 'fields' => 'ids' |
|
325 | - ); |
|
326 | - |
|
327 | - $payments = new WP_Query( $args ); |
|
328 | - |
|
329 | - if( $payments ) |
|
330 | - $ret = $payments->post_count; |
|
331 | - return $ret; |
|
317 | + $ret = 0; |
|
318 | + $args = array( |
|
319 | + 'meta_key' => '_wpinv_gateway', |
|
320 | + 'meta_value' => $gateway_id, |
|
321 | + 'nopaging' => true, |
|
322 | + 'post_type' => 'wpi_invoice', |
|
323 | + 'post_status' => $status, |
|
324 | + 'fields' => 'ids' |
|
325 | + ); |
|
326 | + |
|
327 | + $payments = new WP_Query( $args ); |
|
328 | + |
|
329 | + if( $payments ) |
|
330 | + $ret = $payments->post_count; |
|
331 | + return $ret; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -13,94 +13,94 @@ discard block |
||
13 | 13 | class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway { |
14 | 14 | |
15 | 15 | /** |
16 | - * Payment method id. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Payment method id. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id = 'paypal'; |
21 | 21 | |
22 | 22 | /** |
23 | - * An array of features that this gateway supports. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
23 | + * An array of features that this gateway supports. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | 27 | protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' ); |
28 | 28 | |
29 | 29 | /** |
30 | - * Payment method order. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
30 | + * Payment method order. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | 34 | public $order = 1; |
35 | 35 | |
36 | 36 | /** |
37 | - * Stores line items to send to PayPal. |
|
38 | - * |
|
39 | - * @var array |
|
40 | - */ |
|
37 | + * Stores line items to send to PayPal. |
|
38 | + * |
|
39 | + * @var array |
|
40 | + */ |
|
41 | 41 | protected $line_items = array(); |
42 | 42 | |
43 | 43 | /** |
44 | - * Endpoint for requests from PayPal. |
|
45 | - * |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - protected $notify_url; |
|
49 | - |
|
50 | - /** |
|
51 | - * Endpoint for requests to PayPal. |
|
52 | - * |
|
53 | - * @var string |
|
54 | - */ |
|
44 | + * Endpoint for requests from PayPal. |
|
45 | + * |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + protected $notify_url; |
|
49 | + |
|
50 | + /** |
|
51 | + * Endpoint for requests to PayPal. |
|
52 | + * |
|
53 | + * @var string |
|
54 | + */ |
|
55 | 55 | protected $endpoint; |
56 | 56 | |
57 | 57 | /** |
58 | - * Currencies this gateway is allowed for. |
|
59 | - * |
|
60 | - * @var array |
|
61 | - */ |
|
62 | - public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
58 | + * Currencies this gateway is allowed for. |
|
59 | + * |
|
60 | + * @var array |
|
61 | + */ |
|
62 | + public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ); |
|
63 | 63 | |
64 | 64 | /** |
65 | - * URL to view a transaction. |
|
66 | - * |
|
67 | - * @var string |
|
68 | - */ |
|
65 | + * URL to view a transaction. |
|
66 | + * |
|
67 | + * @var string |
|
68 | + */ |
|
69 | 69 | public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s'; |
70 | 70 | |
71 | 71 | /** |
72 | - * URL to view a subscription. |
|
73 | - * |
|
74 | - * @var string |
|
75 | - */ |
|
76 | - public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
72 | + * URL to view a subscription. |
|
73 | + * |
|
74 | + * @var string |
|
75 | + */ |
|
76 | + public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s'; |
|
77 | 77 | |
78 | 78 | /** |
79 | - * Class constructor. |
|
80 | - */ |
|
81 | - public function __construct() { |
|
79 | + * Class constructor. |
|
80 | + */ |
|
81 | + public function __construct() { |
|
82 | 82 | |
83 | 83 | $this->title = __( 'PayPal Standard', 'invoicing' ); |
84 | 84 | $this->method_title = __( 'PayPal Standard', 'invoicing' ); |
85 | 85 | $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' ); |
86 | 86 | $this->notify_url = wpinv_get_ipn_url( $this->id ); |
87 | 87 | |
88 | - add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
88 | + add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 ); |
|
89 | 89 | add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) ); |
90 | 90 | |
91 | 91 | parent::__construct(); |
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
95 | - * Process Payment. |
|
96 | - * |
|
97 | - * |
|
98 | - * @param WPInv_Invoice $invoice Invoice. |
|
99 | - * @param array $submission_data Posted checkout fields. |
|
100 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
101 | - * @return array |
|
102 | - */ |
|
103 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
95 | + * Process Payment. |
|
96 | + * |
|
97 | + * |
|
98 | + * @param WPInv_Invoice $invoice Invoice. |
|
99 | + * @param array $submission_data Posted checkout fields. |
|
100 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
101 | + * @return array |
|
102 | + */ |
|
103 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
104 | 104 | |
105 | 105 | // Get redirect url. |
106 | 106 | $paypal_redirect = $this->get_request_url( $invoice ); |
@@ -123,15 +123,15 @@ discard block |
||
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | - * Get the PayPal request URL for an invoice. |
|
127 | - * |
|
128 | - * @param WPInv_Invoice $invoice Invoice object. |
|
129 | - * @return string |
|
130 | - */ |
|
131 | - public function get_request_url( $invoice ) { |
|
126 | + * Get the PayPal request URL for an invoice. |
|
127 | + * |
|
128 | + * @param WPInv_Invoice $invoice Invoice object. |
|
129 | + * @return string |
|
130 | + */ |
|
131 | + public function get_request_url( $invoice ) { |
|
132 | 132 | |
133 | 133 | // Endpoint for this request |
134 | - $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
134 | + $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?'; |
|
135 | 135 | |
136 | 136 | // Retrieve paypal args. |
137 | 137 | $paypal_args = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' ); |
@@ -144,44 +144,44 @@ discard block |
||
144 | 144 | |
145 | 145 | return add_query_arg( $paypal_args, $this->endpoint ); |
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | 149 | /** |
150 | - * Get PayPal Args for passing to PP. |
|
151 | - * |
|
152 | - * @param WPInv_Invoice $invoice Invoice object. |
|
153 | - * @return array |
|
154 | - */ |
|
155 | - protected function get_paypal_args( $invoice ) { |
|
150 | + * Get PayPal Args for passing to PP. |
|
151 | + * |
|
152 | + * @param WPInv_Invoice $invoice Invoice object. |
|
153 | + * @return array |
|
154 | + */ |
|
155 | + protected function get_paypal_args( $invoice ) { |
|
156 | 156 | |
157 | 157 | // Whether or not to send the line items as one item. |
158 | - $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
159 | - |
|
160 | - if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
161 | - $force_one_line_item = true; |
|
162 | - } |
|
163 | - |
|
164 | - $paypal_args = apply_filters( |
|
165 | - 'getpaid_paypal_args', |
|
166 | - array_merge( |
|
167 | - $this->get_transaction_args( $invoice ), |
|
168 | - $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
169 | - ), |
|
170 | - $invoice |
|
171 | - ); |
|
172 | - |
|
173 | - return $this->fix_request_length( $invoice, $paypal_args ); |
|
158 | + $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice ); |
|
159 | + |
|
160 | + if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) { |
|
161 | + $force_one_line_item = true; |
|
162 | + } |
|
163 | + |
|
164 | + $paypal_args = apply_filters( |
|
165 | + 'getpaid_paypal_args', |
|
166 | + array_merge( |
|
167 | + $this->get_transaction_args( $invoice ), |
|
168 | + $this->get_line_item_args( $invoice, $force_one_line_item ) |
|
169 | + ), |
|
170 | + $invoice |
|
171 | + ); |
|
172 | + |
|
173 | + return $this->fix_request_length( $invoice, $paypal_args ); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
177 | - * Get transaction args for paypal request. |
|
178 | - * |
|
179 | - * @param WPInv_Invoice $invoice Invoice object. |
|
180 | - * @return array |
|
181 | - */ |
|
182 | - protected function get_transaction_args( $invoice ) { |
|
183 | - |
|
184 | - return array( |
|
177 | + * Get transaction args for paypal request. |
|
178 | + * |
|
179 | + * @param WPInv_Invoice $invoice Invoice object. |
|
180 | + * @return array |
|
181 | + */ |
|
182 | + protected function get_transaction_args( $invoice ) { |
|
183 | + |
|
184 | + return array( |
|
185 | 185 | 'cmd' => '_cart', |
186 | 186 | 'business' => wpinv_get_option( 'paypal_email', false ), |
187 | 187 | 'no_shipping' => '1', |
@@ -206,16 +206,16 @@ discard block |
||
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
209 | - * Get line item args for paypal request. |
|
210 | - * |
|
211 | - * @param WPInv_Invoice $invoice Invoice object. |
|
212 | - * @param bool $force_one_line_item Create only one item for this invoice. |
|
213 | - * @return array |
|
214 | - */ |
|
215 | - protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
209 | + * Get line item args for paypal request. |
|
210 | + * |
|
211 | + * @param WPInv_Invoice $invoice Invoice object. |
|
212 | + * @param bool $force_one_line_item Create only one item for this invoice. |
|
213 | + * @return array |
|
214 | + */ |
|
215 | + protected function get_line_item_args( $invoice, $force_one_line_item = false ) { |
|
216 | 216 | |
217 | 217 | // Maybe send invoice as a single item. |
218 | - if ( $force_one_line_item ) { |
|
218 | + if ( $force_one_line_item ) { |
|
219 | 219 | return $this->get_line_item_args_single_item( $invoice ); |
220 | 220 | } |
221 | 221 | |
@@ -235,129 +235,129 @@ discard block |
||
235 | 235 | $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 ); |
236 | 236 | } |
237 | 237 | |
238 | - return array_merge( $line_item_args, $this->get_line_items() ); |
|
238 | + return array_merge( $line_item_args, $this->get_line_items() ); |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | - * Get line item args for paypal request as a single line item. |
|
244 | - * |
|
245 | - * @param WPInv_Invoice $invoice Invoice object. |
|
246 | - * @return array |
|
247 | - */ |
|
248 | - protected function get_line_item_args_single_item( $invoice ) { |
|
249 | - $this->delete_line_items(); |
|
243 | + * Get line item args for paypal request as a single line item. |
|
244 | + * |
|
245 | + * @param WPInv_Invoice $invoice Invoice object. |
|
246 | + * @return array |
|
247 | + */ |
|
248 | + protected function get_line_item_args_single_item( $invoice ) { |
|
249 | + $this->delete_line_items(); |
|
250 | 250 | |
251 | 251 | $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() ); |
252 | - $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
252 | + $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() ); |
|
253 | 253 | |
254 | - return $this->get_line_items(); |
|
254 | + return $this->get_line_items(); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | - * Return all line items. |
|
259 | - */ |
|
260 | - protected function get_line_items() { |
|
261 | - return $this->line_items; |
|
262 | - } |
|
258 | + * Return all line items. |
|
259 | + */ |
|
260 | + protected function get_line_items() { |
|
261 | + return $this->line_items; |
|
262 | + } |
|
263 | 263 | |
264 | 264 | /** |
265 | - * Remove all line items. |
|
266 | - */ |
|
267 | - protected function delete_line_items() { |
|
268 | - $this->line_items = array(); |
|
265 | + * Remove all line items. |
|
266 | + */ |
|
267 | + protected function delete_line_items() { |
|
268 | + $this->line_items = array(); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
272 | - * Prepare line items to send to paypal. |
|
273 | - * |
|
274 | - * @param WPInv_Invoice $invoice Invoice object. |
|
275 | - */ |
|
276 | - protected function prepare_line_items( $invoice ) { |
|
277 | - $this->delete_line_items(); |
|
278 | - |
|
279 | - // Items. |
|
280 | - foreach ( $invoice->get_items() as $item ) { |
|
281 | - $amount = $item->get_price(); |
|
282 | - $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
283 | - $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
272 | + * Prepare line items to send to paypal. |
|
273 | + * |
|
274 | + * @param WPInv_Invoice $invoice Invoice object. |
|
275 | + */ |
|
276 | + protected function prepare_line_items( $invoice ) { |
|
277 | + $this->delete_line_items(); |
|
278 | + |
|
279 | + // Items. |
|
280 | + foreach ( $invoice->get_items() as $item ) { |
|
281 | + $amount = $item->get_price(); |
|
282 | + $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(); |
|
283 | + $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() ); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Fees. |
287 | - foreach ( $invoice->get_fees() as $fee => $data ) { |
|
287 | + foreach ( $invoice->get_fees() as $fee => $data ) { |
|
288 | 288 | $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) ); |
289 | 289 | } |
290 | 290 | |
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
294 | - * Add PayPal Line Item. |
|
295 | - * |
|
296 | - * @param string $item_name Item name. |
|
297 | - * @param float $quantity Item quantity. |
|
298 | - * @param float $amount Amount. |
|
299 | - * @param string $item_number Item number. |
|
300 | - */ |
|
301 | - protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
302 | - $index = ( count( $this->line_items ) / 4 ) + 1; |
|
303 | - |
|
304 | - $item = apply_filters( |
|
305 | - 'getpaid_paypal_line_item', |
|
306 | - array( |
|
307 | - 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
308 | - 'quantity' => (float) $quantity, |
|
309 | - 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
310 | - 'item_number' => $item_number, |
|
311 | - ), |
|
312 | - $item_name, |
|
313 | - $quantity, |
|
314 | - $amount, |
|
315 | - $item_number |
|
316 | - ); |
|
317 | - |
|
318 | - $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
294 | + * Add PayPal Line Item. |
|
295 | + * |
|
296 | + * @param string $item_name Item name. |
|
297 | + * @param float $quantity Item quantity. |
|
298 | + * @param float $amount Amount. |
|
299 | + * @param string $item_number Item number. |
|
300 | + */ |
|
301 | + protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) { |
|
302 | + $index = ( count( $this->line_items ) / 4 ) + 1; |
|
303 | + |
|
304 | + $item = apply_filters( |
|
305 | + 'getpaid_paypal_line_item', |
|
306 | + array( |
|
307 | + 'item_name' => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ), |
|
308 | + 'quantity' => (float) $quantity, |
|
309 | + 'amount' => wpinv_sanitize_amount( (float) $amount, 2 ), |
|
310 | + 'item_number' => $item_number, |
|
311 | + ), |
|
312 | + $item_name, |
|
313 | + $quantity, |
|
314 | + $amount, |
|
315 | + $item_number |
|
316 | + ); |
|
317 | + |
|
318 | + $this->line_items[ 'item_name_' . $index ] = getpaid_limit_length( $item['item_name'], 127 ); |
|
319 | 319 | $this->line_items[ 'quantity_' . $index ] = $item['quantity']; |
320 | 320 | |
321 | 321 | // The price or amount of the product, service, or contribution, not including shipping, handling, or tax. |
322 | - $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
323 | - $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
322 | + $this->line_items[ 'amount_' . $index ] = $item['amount'] * $item['quantity']; |
|
323 | + $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 ); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | - * If the default request with line items is too long, generate a new one with only one line item. |
|
328 | - * |
|
329 | - * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
330 | - * |
|
331 | - * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
332 | - * @param array $paypal_args Arguments sent to Paypal in the request. |
|
333 | - * @return array |
|
334 | - */ |
|
335 | - protected function fix_request_length( $invoice, $paypal_args ) { |
|
336 | - $max_paypal_length = 2083; |
|
337 | - $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
338 | - |
|
339 | - if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
340 | - return $paypal_args; |
|
341 | - } |
|
342 | - |
|
343 | - return apply_filters( |
|
344 | - 'getpaid_paypal_args', |
|
345 | - array_merge( |
|
346 | - $this->get_transaction_args( $invoice ), |
|
347 | - $this->get_line_item_args( $invoice, true ) |
|
348 | - ), |
|
349 | - $invoice |
|
350 | - ); |
|
327 | + * If the default request with line items is too long, generate a new one with only one line item. |
|
328 | + * |
|
329 | + * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer. |
|
330 | + * |
|
331 | + * @param WPInv_Invoice $invoice Invoice to be sent to Paypal. |
|
332 | + * @param array $paypal_args Arguments sent to Paypal in the request. |
|
333 | + * @return array |
|
334 | + */ |
|
335 | + protected function fix_request_length( $invoice, $paypal_args ) { |
|
336 | + $max_paypal_length = 2083; |
|
337 | + $query_candidate = http_build_query( $paypal_args, '', '&' ); |
|
338 | + |
|
339 | + if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) { |
|
340 | + return $paypal_args; |
|
341 | + } |
|
342 | + |
|
343 | + return apply_filters( |
|
344 | + 'getpaid_paypal_args', |
|
345 | + array_merge( |
|
346 | + $this->get_transaction_args( $invoice ), |
|
347 | + $this->get_line_item_args( $invoice, true ) |
|
348 | + ), |
|
349 | + $invoice |
|
350 | + ); |
|
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
355 | - * Processes recurring invoices. |
|
356 | - * |
|
357 | - * @param array $paypal_args PayPal args. |
|
358 | - * @param WPInv_Invoice $invoice Invoice object. |
|
359 | - */ |
|
360 | - public function process_subscription( $paypal_args, $invoice ) { |
|
355 | + * Processes recurring invoices. |
|
356 | + * |
|
357 | + * @param array $paypal_args PayPal args. |
|
358 | + * @param WPInv_Invoice $invoice Invoice object. |
|
359 | + */ |
|
360 | + public function process_subscription( $paypal_args, $invoice ) { |
|
361 | 361 | |
362 | 362 | // Make sure this is a subscription. |
363 | 363 | if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) { |
@@ -382,11 +382,11 @@ discard block |
||
382 | 382 | |
383 | 383 | $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount; |
384 | 384 | |
385 | - // Trial period length. |
|
386 | - $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
385 | + // Trial period length. |
|
386 | + $paypal_args['p1'] = $subscription_item->get_trial_interval(); |
|
387 | 387 | |
388 | - // Trial period. |
|
389 | - $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
388 | + // Trial period. |
|
389 | + $paypal_args['t1'] = $subscription_item->get_trial_period(); |
|
390 | 390 | |
391 | 391 | } else if ( $initial_amount != $recurring_amount ) { |
392 | 392 | |
@@ -409,40 +409,40 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | // We have a recurring payment |
412 | - if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
412 | + if ( ! isset( $param_number ) || 1 == $param_number ) { |
|
413 | 413 | |
414 | - // Subscription price |
|
415 | - $paypal_args['a3'] = $recurring_amount; |
|
414 | + // Subscription price |
|
415 | + $paypal_args['a3'] = $recurring_amount; |
|
416 | 416 | |
417 | - // Subscription duration |
|
418 | - $paypal_args['p3'] = $interval; |
|
417 | + // Subscription duration |
|
418 | + $paypal_args['p3'] = $interval; |
|
419 | 419 | |
420 | - // Subscription period |
|
421 | - $paypal_args['t3'] = $period; |
|
420 | + // Subscription period |
|
421 | + $paypal_args['t3'] = $period; |
|
422 | 422 | |
423 | 423 | } |
424 | 424 | |
425 | 425 | // Recurring payments |
426 | - if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
426 | + if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) { |
|
427 | 427 | |
428 | - // Non-recurring payments |
|
429 | - $paypal_args['src'] = 0; |
|
428 | + // Non-recurring payments |
|
429 | + $paypal_args['src'] = 0; |
|
430 | 430 | |
431 | - } else { |
|
431 | + } else { |
|
432 | 432 | |
433 | - $paypal_args['src'] = 1; |
|
433 | + $paypal_args['src'] = 1; |
|
434 | 434 | |
435 | - if ( $bill_times > 0 ) { |
|
435 | + if ( $bill_times > 0 ) { |
|
436 | 436 | |
437 | - // An initial period is being used to charge a sign-up fee |
|
438 | - if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
439 | - $bill_times--; |
|
440 | - } |
|
437 | + // An initial period is being used to charge a sign-up fee |
|
438 | + if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) { |
|
439 | + $bill_times--; |
|
440 | + } |
|
441 | 441 | |
442 | 442 | // Make sure it's not over the max of 52 |
443 | 443 | $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 ); |
444 | 444 | |
445 | - } |
|
445 | + } |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | // Force return URL so that order description & instructions display |
@@ -458,19 +458,19 @@ discard block |
||
458 | 458 | } |
459 | 459 | |
460 | 460 | return apply_filters( |
461 | - 'getpaid_paypal_subscription_args', |
|
462 | - $paypal_args, |
|
463 | - $invoice |
|
461 | + 'getpaid_paypal_subscription_args', |
|
462 | + $paypal_args, |
|
463 | + $invoice |
|
464 | 464 | ); |
465 | 465 | |
466 | 466 | } |
467 | 467 | |
468 | 468 | /** |
469 | - * Processes ipns and marks payments as complete. |
|
470 | - * |
|
471 | - * @return void |
|
472 | - */ |
|
473 | - public function verify_ipn() { |
|
469 | + * Processes ipns and marks payments as complete. |
|
470 | + * |
|
471 | + * @return void |
|
472 | + */ |
|
473 | + public function verify_ipn() { |
|
474 | 474 | new GetPaid_Paypal_Gateway_IPN_Handler( $this ); |
475 | 475 | } |
476 | 476 | |
@@ -480,19 +480,19 @@ discard block |
||
480 | 480 | public function sandbox_notice() { |
481 | 481 | |
482 | 482 | return sprintf( |
483 | - __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
484 | - '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
|
485 | - '</a>' |
|
486 | - ); |
|
483 | + __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
484 | + '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">', |
|
485 | + '</a>' |
|
486 | + ); |
|
487 | 487 | |
488 | 488 | } |
489 | 489 | |
490 | - /** |
|
491 | - * Filters the gateway settings. |
|
492 | - * |
|
493 | - * @param array $admin_settings |
|
494 | - */ |
|
495 | - public function admin_settings( $admin_settings ) { |
|
490 | + /** |
|
491 | + * Filters the gateway settings. |
|
492 | + * |
|
493 | + * @param array $admin_settings |
|
494 | + */ |
|
495 | + public function admin_settings( $admin_settings ) { |
|
496 | 496 | |
497 | 497 | $currencies = sprintf( |
498 | 498 | __( 'Supported Currencies: %s', 'invoicing' ), |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | 'readonly' => true, |
519 | 519 | ); |
520 | 520 | |
521 | - return $admin_settings; |
|
522 | - } |
|
521 | + return $admin_settings; |
|
522 | + } |
|
523 | 523 | |
524 | 524 | } |
@@ -13,464 +13,464 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | - } |
|
152 | - |
|
153 | - // Invoice addons. |
|
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | - } |
|
157 | - |
|
158 | - // Gateway settings. |
|
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | + add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | + } |
|
152 | + |
|
153 | + // Invoice addons. |
|
154 | + if ( $this->supports( 'addons' ) ) { |
|
155 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | + } |
|
157 | + |
|
158 | + // Gateway settings. |
|
159 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | 160 | |
161 | 161 | |
162 | - // Gateway checkout fiellds. |
|
163 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
164 | - |
|
165 | - // Process payment. |
|
166 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
167 | - |
|
168 | - // Change the checkout button text. |
|
169 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
170 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
171 | - } |
|
172 | - |
|
173 | - // Check if a gateway is valid for a given currency. |
|
174 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
175 | - |
|
176 | - // Generate the transaction url. |
|
177 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
178 | - |
|
179 | - // Generate the subscription url. |
|
180 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
181 | - |
|
182 | - // Confirm payments. |
|
183 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
184 | - |
|
185 | - // Verify IPNs. |
|
186 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
187 | - |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Checks if this gateway is a given gateway. |
|
192 | - * |
|
193 | - * @since 1.0.19 |
|
194 | - * @return bool |
|
195 | - */ |
|
196 | - public function is( $gateway ) { |
|
197 | - return $gateway == $this->id; |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Returns a users saved tokens for this gateway. |
|
202 | - * |
|
203 | - * @since 1.0.19 |
|
204 | - * @return array |
|
205 | - */ |
|
206 | - public function get_tokens( $sandbox = null ) { |
|
207 | - |
|
208 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
209 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
210 | - |
|
211 | - if ( is_array( $tokens ) ) { |
|
212 | - $this->tokens = $tokens; |
|
213 | - } |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - if ( ! is_bool( $sandbox ) ) { |
|
218 | - return $this->tokens; |
|
219 | - } |
|
220 | - |
|
221 | - // Filter tokens. |
|
222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | - return wp_list_filter( $this->tokens, $args ); |
|
224 | - |
|
225 | - } |
|
226 | - |
|
227 | - /** |
|
228 | - * Saves a token for this gateway. |
|
229 | - * |
|
230 | - * @since 1.0.19 |
|
231 | - */ |
|
232 | - public function save_token( $token ) { |
|
233 | - |
|
234 | - $tokens = $this->get_tokens(); |
|
235 | - $tokens[] = $token; |
|
236 | - |
|
237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
238 | - |
|
239 | - $this->tokens = $tokens; |
|
240 | - |
|
241 | - } |
|
242 | - |
|
243 | - /** |
|
244 | - * Return the title for admin screens. |
|
245 | - * |
|
246 | - * @return string |
|
247 | - */ |
|
248 | - public function get_method_title() { |
|
249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Return the description for admin screens. |
|
254 | - * |
|
255 | - * @return string |
|
256 | - */ |
|
257 | - public function get_method_description() { |
|
258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
259 | - } |
|
260 | - |
|
261 | - /** |
|
262 | - * Get the success url. |
|
263 | - * |
|
264 | - * @param WPInv_Invoice $invoice Invoice object. |
|
265 | - * @return string |
|
266 | - */ |
|
267 | - public function get_return_url( $invoice ) { |
|
268 | - |
|
269 | - // Payment success url |
|
270 | - $return_url = add_query_arg( |
|
271 | - array( |
|
272 | - 'payment-confirm' => $this->id, |
|
273 | - 'invoice_key' => $invoice->get_key(), |
|
274 | - 'utm_nooverride' => 1 |
|
275 | - ), |
|
276 | - wpinv_get_success_page_uri() |
|
277 | - ); |
|
278 | - |
|
279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
280 | - } |
|
281 | - |
|
282 | - /** |
|
283 | - * Confirms payments when rendering the success page. |
|
284 | - * |
|
285 | - * @param string $content Success page content. |
|
286 | - * @return string |
|
287 | - */ |
|
288 | - public function confirm_payment( $content ) { |
|
289 | - |
|
290 | - // Retrieve the invoice. |
|
291 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
293 | - |
|
294 | - // Ensure that it exists and that it is pending payment. |
|
295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
296 | - return $content; |
|
297 | - } |
|
298 | - |
|
299 | - // Can the user view this invoice?? |
|
300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
301 | - return $content; |
|
302 | - } |
|
303 | - |
|
304 | - // Show payment processing indicator. |
|
305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Processes ipns and marks payments as complete. |
|
310 | - * |
|
311 | - * @return void |
|
312 | - */ |
|
313 | - public function verify_ipn() {} |
|
314 | - |
|
315 | - /** |
|
316 | - * Processes invoice addons. |
|
317 | - * |
|
318 | - * @param WPInv_Invoice $invoice |
|
319 | - * @param GetPaid_Form_Item[] $items |
|
320 | - * @return WPInv_Invoice |
|
321 | - */ |
|
322 | - public function process_addons( $invoice, $items ) { |
|
323 | - |
|
324 | - } |
|
325 | - |
|
326 | - /** |
|
327 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
328 | - * |
|
329 | - * @param string $transaction_url transaction url. |
|
330 | - * @param WPInv_Invoice $invoice Invoice object. |
|
331 | - * @return string transaction URL, or empty string. |
|
332 | - */ |
|
333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
334 | - |
|
335 | - $transaction_id = $invoice->get_transaction_id(); |
|
336 | - |
|
337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
341 | - } |
|
342 | - |
|
343 | - return $transaction_url; |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
348 | - * |
|
349 | - * @param string $subscription_url transaction url. |
|
350 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
351 | - * @return string subscription URL, or empty string. |
|
352 | - */ |
|
353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
354 | - |
|
355 | - $profile_id = $subscription->get_profile_id(); |
|
356 | - |
|
357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
358 | - |
|
359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
362 | - |
|
363 | - } |
|
364 | - |
|
365 | - return $subscription_url; |
|
366 | - } |
|
367 | - |
|
368 | - /** |
|
369 | - * Check if the gateway is available for use. |
|
370 | - * |
|
371 | - * @return bool |
|
372 | - */ |
|
373 | - public function is_available() { |
|
374 | - return ! empty( $this->enabled ); |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Return the gateway's title. |
|
379 | - * |
|
380 | - * @return string |
|
381 | - */ |
|
382 | - public function get_title() { |
|
383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
384 | - } |
|
385 | - |
|
386 | - /** |
|
387 | - * Return the gateway's description. |
|
388 | - * |
|
389 | - * @return string |
|
390 | - */ |
|
391 | - public function get_description() { |
|
392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
393 | - } |
|
394 | - |
|
395 | - /** |
|
396 | - * Process Payment. |
|
397 | - * |
|
398 | - * |
|
399 | - * @param WPInv_Invoice $invoice Invoice. |
|
400 | - * @param array $submission_data Posted checkout fields. |
|
401 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
402 | - * @return void |
|
403 | - */ |
|
404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
405 | - // Process the payment then either redirect to the success page or the gateway. |
|
406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * Process refund. |
|
411 | - * |
|
412 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
413 | - * a passed in amount. |
|
414 | - * |
|
415 | - * @param WPInv_Invoice $invoice Invoice. |
|
416 | - * @param float $amount Refund amount. |
|
417 | - * @param string $reason Refund reason. |
|
418 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
419 | - */ |
|
420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
422 | - } |
|
423 | - |
|
424 | - /** |
|
425 | - * Displays the payment fields, credit cards etc. |
|
426 | - * |
|
427 | - * @param int $invoice_id 0 or invoice id. |
|
428 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
429 | - */ |
|
430 | - public function payment_fields( $invoice_id, $form ) { |
|
431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Filters the gateway settings. |
|
436 | - * |
|
437 | - * @param array $admin_settings |
|
438 | - */ |
|
439 | - public function admin_settings( $admin_settings ) { |
|
440 | - return $admin_settings; |
|
441 | - } |
|
442 | - |
|
443 | - /** |
|
444 | - * Retrieves the value of a gateway setting. |
|
445 | - * |
|
446 | - * @param string $option |
|
447 | - */ |
|
448 | - public function get_option( $option, $default = false ) { |
|
449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
450 | - } |
|
451 | - |
|
452 | - /** |
|
453 | - * Check if a gateway supports a given feature. |
|
454 | - * |
|
455 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
456 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
457 | - * |
|
458 | - * @param string $feature string The name of a feature to test support for. |
|
459 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
460 | - * @since 1.0.19 |
|
461 | - */ |
|
462 | - public function supports( $feature ) { |
|
463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Returns the credit card form html. |
|
468 | - * |
|
469 | - * @param bool $save whether or not to display the save button. |
|
470 | - */ |
|
162 | + // Gateway checkout fiellds. |
|
163 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
164 | + |
|
165 | + // Process payment. |
|
166 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
167 | + |
|
168 | + // Change the checkout button text. |
|
169 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
170 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
171 | + } |
|
172 | + |
|
173 | + // Check if a gateway is valid for a given currency. |
|
174 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
175 | + |
|
176 | + // Generate the transaction url. |
|
177 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
178 | + |
|
179 | + // Generate the subscription url. |
|
180 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
181 | + |
|
182 | + // Confirm payments. |
|
183 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
184 | + |
|
185 | + // Verify IPNs. |
|
186 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
187 | + |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Checks if this gateway is a given gateway. |
|
192 | + * |
|
193 | + * @since 1.0.19 |
|
194 | + * @return bool |
|
195 | + */ |
|
196 | + public function is( $gateway ) { |
|
197 | + return $gateway == $this->id; |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Returns a users saved tokens for this gateway. |
|
202 | + * |
|
203 | + * @since 1.0.19 |
|
204 | + * @return array |
|
205 | + */ |
|
206 | + public function get_tokens( $sandbox = null ) { |
|
207 | + |
|
208 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
209 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
210 | + |
|
211 | + if ( is_array( $tokens ) ) { |
|
212 | + $this->tokens = $tokens; |
|
213 | + } |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + if ( ! is_bool( $sandbox ) ) { |
|
218 | + return $this->tokens; |
|
219 | + } |
|
220 | + |
|
221 | + // Filter tokens. |
|
222 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | + return wp_list_filter( $this->tokens, $args ); |
|
224 | + |
|
225 | + } |
|
226 | + |
|
227 | + /** |
|
228 | + * Saves a token for this gateway. |
|
229 | + * |
|
230 | + * @since 1.0.19 |
|
231 | + */ |
|
232 | + public function save_token( $token ) { |
|
233 | + |
|
234 | + $tokens = $this->get_tokens(); |
|
235 | + $tokens[] = $token; |
|
236 | + |
|
237 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
238 | + |
|
239 | + $this->tokens = $tokens; |
|
240 | + |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Return the title for admin screens. |
|
245 | + * |
|
246 | + * @return string |
|
247 | + */ |
|
248 | + public function get_method_title() { |
|
249 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Return the description for admin screens. |
|
254 | + * |
|
255 | + * @return string |
|
256 | + */ |
|
257 | + public function get_method_description() { |
|
258 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
259 | + } |
|
260 | + |
|
261 | + /** |
|
262 | + * Get the success url. |
|
263 | + * |
|
264 | + * @param WPInv_Invoice $invoice Invoice object. |
|
265 | + * @return string |
|
266 | + */ |
|
267 | + public function get_return_url( $invoice ) { |
|
268 | + |
|
269 | + // Payment success url |
|
270 | + $return_url = add_query_arg( |
|
271 | + array( |
|
272 | + 'payment-confirm' => $this->id, |
|
273 | + 'invoice_key' => $invoice->get_key(), |
|
274 | + 'utm_nooverride' => 1 |
|
275 | + ), |
|
276 | + wpinv_get_success_page_uri() |
|
277 | + ); |
|
278 | + |
|
279 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
280 | + } |
|
281 | + |
|
282 | + /** |
|
283 | + * Confirms payments when rendering the success page. |
|
284 | + * |
|
285 | + * @param string $content Success page content. |
|
286 | + * @return string |
|
287 | + */ |
|
288 | + public function confirm_payment( $content ) { |
|
289 | + |
|
290 | + // Retrieve the invoice. |
|
291 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
292 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
293 | + |
|
294 | + // Ensure that it exists and that it is pending payment. |
|
295 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
296 | + return $content; |
|
297 | + } |
|
298 | + |
|
299 | + // Can the user view this invoice?? |
|
300 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
301 | + return $content; |
|
302 | + } |
|
303 | + |
|
304 | + // Show payment processing indicator. |
|
305 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Processes ipns and marks payments as complete. |
|
310 | + * |
|
311 | + * @return void |
|
312 | + */ |
|
313 | + public function verify_ipn() {} |
|
314 | + |
|
315 | + /** |
|
316 | + * Processes invoice addons. |
|
317 | + * |
|
318 | + * @param WPInv_Invoice $invoice |
|
319 | + * @param GetPaid_Form_Item[] $items |
|
320 | + * @return WPInv_Invoice |
|
321 | + */ |
|
322 | + public function process_addons( $invoice, $items ) { |
|
323 | + |
|
324 | + } |
|
325 | + |
|
326 | + /** |
|
327 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
328 | + * |
|
329 | + * @param string $transaction_url transaction url. |
|
330 | + * @param WPInv_Invoice $invoice Invoice object. |
|
331 | + * @return string transaction URL, or empty string. |
|
332 | + */ |
|
333 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
334 | + |
|
335 | + $transaction_id = $invoice->get_transaction_id(); |
|
336 | + |
|
337 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
341 | + } |
|
342 | + |
|
343 | + return $transaction_url; |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
348 | + * |
|
349 | + * @param string $subscription_url transaction url. |
|
350 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
351 | + * @return string subscription URL, or empty string. |
|
352 | + */ |
|
353 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
354 | + |
|
355 | + $profile_id = $subscription->get_profile_id(); |
|
356 | + |
|
357 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
358 | + |
|
359 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
362 | + |
|
363 | + } |
|
364 | + |
|
365 | + return $subscription_url; |
|
366 | + } |
|
367 | + |
|
368 | + /** |
|
369 | + * Check if the gateway is available for use. |
|
370 | + * |
|
371 | + * @return bool |
|
372 | + */ |
|
373 | + public function is_available() { |
|
374 | + return ! empty( $this->enabled ); |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Return the gateway's title. |
|
379 | + * |
|
380 | + * @return string |
|
381 | + */ |
|
382 | + public function get_title() { |
|
383 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
384 | + } |
|
385 | + |
|
386 | + /** |
|
387 | + * Return the gateway's description. |
|
388 | + * |
|
389 | + * @return string |
|
390 | + */ |
|
391 | + public function get_description() { |
|
392 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
393 | + } |
|
394 | + |
|
395 | + /** |
|
396 | + * Process Payment. |
|
397 | + * |
|
398 | + * |
|
399 | + * @param WPInv_Invoice $invoice Invoice. |
|
400 | + * @param array $submission_data Posted checkout fields. |
|
401 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
402 | + * @return void |
|
403 | + */ |
|
404 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
405 | + // Process the payment then either redirect to the success page or the gateway. |
|
406 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * Process refund. |
|
411 | + * |
|
412 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
413 | + * a passed in amount. |
|
414 | + * |
|
415 | + * @param WPInv_Invoice $invoice Invoice. |
|
416 | + * @param float $amount Refund amount. |
|
417 | + * @param string $reason Refund reason. |
|
418 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
419 | + */ |
|
420 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
422 | + } |
|
423 | + |
|
424 | + /** |
|
425 | + * Displays the payment fields, credit cards etc. |
|
426 | + * |
|
427 | + * @param int $invoice_id 0 or invoice id. |
|
428 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
429 | + */ |
|
430 | + public function payment_fields( $invoice_id, $form ) { |
|
431 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Filters the gateway settings. |
|
436 | + * |
|
437 | + * @param array $admin_settings |
|
438 | + */ |
|
439 | + public function admin_settings( $admin_settings ) { |
|
440 | + return $admin_settings; |
|
441 | + } |
|
442 | + |
|
443 | + /** |
|
444 | + * Retrieves the value of a gateway setting. |
|
445 | + * |
|
446 | + * @param string $option |
|
447 | + */ |
|
448 | + public function get_option( $option, $default = false ) { |
|
449 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
450 | + } |
|
451 | + |
|
452 | + /** |
|
453 | + * Check if a gateway supports a given feature. |
|
454 | + * |
|
455 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
456 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
457 | + * |
|
458 | + * @param string $feature string The name of a feature to test support for. |
|
459 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
460 | + * @since 1.0.19 |
|
461 | + */ |
|
462 | + public function supports( $feature ) { |
|
463 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Returns the credit card form html. |
|
468 | + * |
|
469 | + * @param bool $save whether or not to display the save button. |
|
470 | + */ |
|
471 | 471 | public function get_cc_form( $save = false ) { |
472 | 472 | |
473 | - ob_start(); |
|
473 | + ob_start(); |
|
474 | 474 | |
475 | 475 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
476 | 476 | |
@@ -565,11 +565,11 @@ discard block |
||
565 | 565 | 'name' => $this->id . '[cc_cvv2]', |
566 | 566 | 'id' => "$id_prefix-cc-cvv2", |
567 | 567 | 'label' => __( 'CCV', 'invoicing' ), |
568 | - 'label_type' => 'vertical', |
|
569 | - 'class' => 'form-control-sm', |
|
570 | - 'extra_attributes' => array( |
|
571 | - 'autocomplete' => "cc-csc", |
|
572 | - ), |
|
568 | + 'label_type' => 'vertical', |
|
569 | + 'class' => 'form-control-sm', |
|
570 | + 'extra_attributes' => array( |
|
571 | + 'autocomplete' => "cc-csc", |
|
572 | + ), |
|
573 | 573 | ) |
574 | 574 | ); |
575 | 575 | ?> |
@@ -579,192 +579,192 @@ discard block |
||
579 | 579 | |
580 | 580 | <?php |
581 | 581 | |
582 | - if ( $save ) { |
|
583 | - echo $this->save_payment_method_checkbox(); |
|
584 | - } |
|
582 | + if ( $save ) { |
|
583 | + echo $this->save_payment_method_checkbox(); |
|
584 | + } |
|
585 | 585 | |
586 | - ?> |
|
586 | + ?> |
|
587 | 587 | </div> |
588 | 588 | |
589 | 589 | </div> |
590 | 590 | <?php |
591 | 591 | |
592 | - return ob_get_clean(); |
|
592 | + return ob_get_clean(); |
|
593 | + |
|
594 | + } |
|
593 | 595 | |
596 | + /** |
|
597 | + * Displays a new payment method entry form. |
|
598 | + * |
|
599 | + * @since 1.0.19 |
|
600 | + */ |
|
601 | + public function new_payment_method_entry( $form ) { |
|
602 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
594 | 603 | } |
595 | 604 | |
596 | - /** |
|
597 | - * Displays a new payment method entry form. |
|
598 | - * |
|
599 | - * @since 1.0.19 |
|
600 | - */ |
|
601 | - public function new_payment_method_entry( $form ) { |
|
602 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
|
603 | - } |
|
604 | - |
|
605 | - /** |
|
606 | - * Grab and display our saved payment methods. |
|
607 | - * |
|
608 | - * @since 1.0.19 |
|
609 | - */ |
|
610 | - public function saved_payment_methods() { |
|
611 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
612 | - |
|
613 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
614 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
615 | - } |
|
616 | - |
|
617 | - $html .= $this->get_new_payment_method_option_html(); |
|
618 | - $html .= '</ul>'; |
|
619 | - |
|
620 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
621 | - } |
|
622 | - |
|
623 | - /** |
|
624 | - * Gets saved payment method HTML from a token. |
|
625 | - * |
|
626 | - * @since 1.0.19 |
|
627 | - * @param array $token Payment Token. |
|
628 | - * @return string Generated payment method HTML |
|
629 | - */ |
|
630 | - public function get_saved_payment_method_option_html( $token ) { |
|
631 | - |
|
632 | - return sprintf( |
|
633 | - '<li class="getpaid-payment-method form-group"> |
|
605 | + /** |
|
606 | + * Grab and display our saved payment methods. |
|
607 | + * |
|
608 | + * @since 1.0.19 |
|
609 | + */ |
|
610 | + public function saved_payment_methods() { |
|
611 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
612 | + |
|
613 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
614 | + $html .= $this->get_saved_payment_method_option_html( $token ); |
|
615 | + } |
|
616 | + |
|
617 | + $html .= $this->get_new_payment_method_option_html(); |
|
618 | + $html .= '</ul>'; |
|
619 | + |
|
620 | + echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
621 | + } |
|
622 | + |
|
623 | + /** |
|
624 | + * Gets saved payment method HTML from a token. |
|
625 | + * |
|
626 | + * @since 1.0.19 |
|
627 | + * @param array $token Payment Token. |
|
628 | + * @return string Generated payment method HTML |
|
629 | + */ |
|
630 | + public function get_saved_payment_method_option_html( $token ) { |
|
631 | + |
|
632 | + return sprintf( |
|
633 | + '<li class="getpaid-payment-method form-group"> |
|
634 | 634 | <label> |
635 | 635 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
636 | 636 | <span>%3$s</span> |
637 | 637 | </label> |
638 | 638 | </li>', |
639 | - esc_attr( $this->id ), |
|
640 | - esc_attr( $token['id'] ), |
|
641 | - esc_html( $token['name'] ), |
|
642 | - checked( empty( $token['default'] ), false, false ), |
|
643 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
644 | - ); |
|
645 | - |
|
646 | - } |
|
647 | - |
|
648 | - /** |
|
649 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
650 | - * |
|
651 | - * @since 1.0.19 |
|
652 | - */ |
|
653 | - public function get_new_payment_method_option_html() { |
|
654 | - |
|
655 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
656 | - |
|
657 | - return sprintf( |
|
658 | - '<li class="getpaid-new-payment-method"> |
|
639 | + esc_attr( $this->id ), |
|
640 | + esc_attr( $token['id'] ), |
|
641 | + esc_html( $token['name'] ), |
|
642 | + checked( empty( $token['default'] ), false, false ), |
|
643 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
644 | + ); |
|
645 | + |
|
646 | + } |
|
647 | + |
|
648 | + /** |
|
649 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
650 | + * |
|
651 | + * @since 1.0.19 |
|
652 | + */ |
|
653 | + public function get_new_payment_method_option_html() { |
|
654 | + |
|
655 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
656 | + |
|
657 | + return sprintf( |
|
658 | + '<li class="getpaid-new-payment-method"> |
|
659 | 659 | <label> |
660 | 660 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
661 | 661 | <span>%2$s</span> |
662 | 662 | </label> |
663 | 663 | </li>', |
664 | - esc_attr( $this->id ), |
|
665 | - esc_html( $label ) |
|
666 | - ); |
|
667 | - |
|
668 | - } |
|
669 | - |
|
670 | - /** |
|
671 | - * Outputs a checkbox for saving a new payment method to the database. |
|
672 | - * |
|
673 | - * @since 1.0.19 |
|
674 | - */ |
|
675 | - public function save_payment_method_checkbox() { |
|
676 | - |
|
677 | - return aui()->input( |
|
678 | - array( |
|
679 | - 'type' => 'checkbox', |
|
680 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
681 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
682 | - 'required' => false, |
|
683 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
684 | - 'value' => 'true', |
|
685 | - 'checked' => true, |
|
686 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
687 | - ) |
|
688 | - ); |
|
689 | - |
|
690 | - } |
|
691 | - |
|
692 | - /** |
|
693 | - * Registers the gateway. |
|
694 | - * |
|
695 | - * @return array |
|
696 | - */ |
|
697 | - public function register_gateway( $gateways ) { |
|
698 | - |
|
699 | - $gateways[ $this->id ] = array( |
|
700 | - |
|
701 | - 'admin_label' => $this->method_title, |
|
664 | + esc_attr( $this->id ), |
|
665 | + esc_html( $label ) |
|
666 | + ); |
|
667 | + |
|
668 | + } |
|
669 | + |
|
670 | + /** |
|
671 | + * Outputs a checkbox for saving a new payment method to the database. |
|
672 | + * |
|
673 | + * @since 1.0.19 |
|
674 | + */ |
|
675 | + public function save_payment_method_checkbox() { |
|
676 | + |
|
677 | + return aui()->input( |
|
678 | + array( |
|
679 | + 'type' => 'checkbox', |
|
680 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
681 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
682 | + 'required' => false, |
|
683 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
684 | + 'value' => 'true', |
|
685 | + 'checked' => true, |
|
686 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
687 | + ) |
|
688 | + ); |
|
689 | + |
|
690 | + } |
|
691 | + |
|
692 | + /** |
|
693 | + * Registers the gateway. |
|
694 | + * |
|
695 | + * @return array |
|
696 | + */ |
|
697 | + public function register_gateway( $gateways ) { |
|
698 | + |
|
699 | + $gateways[ $this->id ] = array( |
|
700 | + |
|
701 | + 'admin_label' => $this->method_title, |
|
702 | 702 | 'checkout_label' => $this->title, |
703 | - 'ordering' => $this->order, |
|
703 | + 'ordering' => $this->order, |
|
704 | 704 | |
705 | - ); |
|
705 | + ); |
|
706 | 706 | |
707 | - return $gateways; |
|
707 | + return $gateways; |
|
708 | 708 | |
709 | - } |
|
709 | + } |
|
710 | 710 | |
711 | - /** |
|
712 | - * Checks whether or not this is a sandbox request. |
|
713 | - * |
|
714 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
715 | - * @return bool |
|
716 | - */ |
|
717 | - public function is_sandbox( $invoice = null ) { |
|
711 | + /** |
|
712 | + * Checks whether or not this is a sandbox request. |
|
713 | + * |
|
714 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
715 | + * @return bool |
|
716 | + */ |
|
717 | + public function is_sandbox( $invoice = null ) { |
|
718 | 718 | |
719 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
720 | - return $invoice->get_mode() == 'test'; |
|
721 | - } |
|
719 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
720 | + return $invoice->get_mode() == 'test'; |
|
721 | + } |
|
722 | 722 | |
723 | - return wpinv_is_test_mode( $this->id ); |
|
723 | + return wpinv_is_test_mode( $this->id ); |
|
724 | 724 | |
725 | - } |
|
725 | + } |
|
726 | 726 | |
727 | - /** |
|
728 | - * Renames the checkout button |
|
729 | - * |
|
730 | - * @return string |
|
731 | - */ |
|
732 | - public function rename_checkout_button() { |
|
733 | - return $this->checkout_button_text; |
|
734 | - } |
|
727 | + /** |
|
728 | + * Renames the checkout button |
|
729 | + * |
|
730 | + * @return string |
|
731 | + */ |
|
732 | + public function rename_checkout_button() { |
|
733 | + return $this->checkout_button_text; |
|
734 | + } |
|
735 | 735 | |
736 | - /** |
|
737 | - * Validate gateway currency |
|
738 | - * |
|
739 | - * @return bool |
|
740 | - */ |
|
741 | - public function validate_currency( $validation, $currency ) { |
|
736 | + /** |
|
737 | + * Validate gateway currency |
|
738 | + * |
|
739 | + * @return bool |
|
740 | + */ |
|
741 | + public function validate_currency( $validation, $currency ) { |
|
742 | 742 | |
743 | - // Required currencies. |
|
744 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
745 | - return false; |
|
746 | - } |
|
743 | + // Required currencies. |
|
744 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
745 | + return false; |
|
746 | + } |
|
747 | 747 | |
748 | - // Excluded currencies. |
|
749 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
750 | - return false; |
|
751 | - } |
|
748 | + // Excluded currencies. |
|
749 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
750 | + return false; |
|
751 | + } |
|
752 | 752 | |
753 | - return $validation; |
|
754 | - } |
|
753 | + return $validation; |
|
754 | + } |
|
755 | 755 | |
756 | - /** |
|
757 | - * Displays an error |
|
758 | - * |
|
759 | - */ |
|
760 | - public function show_error( $code, $message, $type ) { |
|
756 | + /** |
|
757 | + * Displays an error |
|
758 | + * |
|
759 | + */ |
|
760 | + public function show_error( $code, $message, $type ) { |
|
761 | 761 | |
762 | - if ( is_admin() ) { |
|
763 | - getpaid_admin()->{"show_$type"}( $message ); |
|
764 | - } |
|
762 | + if ( is_admin() ) { |
|
763 | + getpaid_admin()->{"show_$type"}( $message ); |
|
764 | + } |
|
765 | 765 | |
766 | - wpinv_set_error( $code, $message, $type ); |
|
766 | + wpinv_set_error( $code, $message, $type ); |
|
767 | 767 | |
768 | - } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
@@ -196,11 +196,11 @@ discard block |
||
196 | 196 | $cb = "wpinv_{$option['type']}_callback"; |
197 | 197 | $section = "wpinv_settings_{$tab}_$section"; |
198 | 198 | |
199 | - if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | - $tip = wpinv_clean( $option['desc'] ); |
|
201 | - $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
202 | - unset( $option['desc'] ); |
|
203 | - } |
|
199 | + if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) { |
|
200 | + $tip = wpinv_clean( $option['desc'] ); |
|
201 | + $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
|
202 | + unset( $option['desc'] ); |
|
203 | + } |
|
204 | 204 | |
205 | 205 | // Loop through all tabs. |
206 | 206 | add_settings_field( |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
228 | 228 | 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
229 | 229 | 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
230 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
231 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
232 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
230 | + 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
231 | + 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
232 | + 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
233 | 233 | 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
234 | 234 | 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
235 | 235 | ) |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return array |
244 | 244 | */ |
245 | 245 | function wpinv_get_registered_settings() { |
246 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
246 | + return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | */ |
263 | 263 | function wpinv_settings_sanitize( $input = array() ) { |
264 | 264 | |
265 | - $wpinv_options = wpinv_get_options(); |
|
266 | - $raw_referrer = wp_get_raw_referer(); |
|
265 | + $wpinv_options = wpinv_get_options(); |
|
266 | + $raw_referrer = wp_get_raw_referer(); |
|
267 | 267 | |
268 | 268 | if ( empty( $raw_referrer ) ) { |
269 | 269 | return $input; |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | |
272 | 272 | wp_parse_str( $raw_referrer, $referrer ); |
273 | 273 | |
274 | - if ( empty( $referrer['tab'] ) ) { |
|
274 | + if ( empty( $referrer['tab'] ) ) { |
|
275 | 275 | return $input; |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | 278 | $settings = wpinv_get_registered_settings(); |
279 | 279 | $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | } |
296 | 296 | |
297 | 297 | // General filter |
298 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
298 | + $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
299 | 299 | |
300 | - // Key specific filter. |
|
301 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
300 | + // Key specific filter. |
|
301 | + $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | // Loop through the whitelist and unset any that are empty for the tab being saved |
@@ -354,14 +354,14 @@ discard block |
||
354 | 354 | |
355 | 355 | foreach ( $new_rates as $rate ) { |
356 | 356 | |
357 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
358 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
359 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
360 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
361 | - $rate['global'] = empty( $rate['state'] ); |
|
362 | - $tax_rates[] = $rate; |
|
357 | + $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
358 | + $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
359 | + $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
360 | + $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
361 | + $rate['global'] = empty( $rate['state'] ); |
|
362 | + $tax_rates[] = $rate; |
|
363 | 363 | |
364 | - } |
|
364 | + } |
|
365 | 365 | |
366 | 366 | update_option( 'wpinv_tax_rates', $tax_rates ); |
367 | 367 | |
@@ -379,11 +379,11 @@ discard block |
||
379 | 379 | $tabs['general'] = __( 'General', 'invoicing' ); |
380 | 380 | $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
381 | 381 | $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
382 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
382 | + $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
383 | 383 | |
384 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
385 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
386 | - } |
|
384 | + if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
385 | + $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
386 | + } |
|
387 | 387 | |
388 | 388 | $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
389 | 389 | $tabs['misc'] = __( 'Misc', 'invoicing' ); |
@@ -421,14 +421,14 @@ discard block |
||
421 | 421 | ) ), |
422 | 422 | 'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array( |
423 | 423 | 'main' => __( 'Tax Settings', 'invoicing' ), |
424 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
425 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
424 | + 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
425 | + 'vat' => __( 'EU VAT Settings', 'invoicing' ) |
|
426 | 426 | ) ), |
427 | 427 | 'emails' => apply_filters( 'wpinv_settings_sections_emails', array( |
428 | 428 | 'main' => __( 'Email Settings', 'invoicing' ), |
429 | - ) ), |
|
429 | + ) ), |
|
430 | 430 | |
431 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
431 | + 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
432 | 432 | |
433 | 433 | 'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array( |
434 | 434 | 'main' => __( 'Privacy policy', 'invoicing' ), |
@@ -448,48 +448,48 @@ discard block |
||
448 | 448 | } |
449 | 449 | |
450 | 450 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
451 | - $pages_options = array(); |
|
451 | + $pages_options = array(); |
|
452 | 452 | |
453 | - if( $default_label !== NULL && $default_label !== false ) { |
|
454 | - $pages_options = array( '' => $default_label ); // Blank option |
|
455 | - } |
|
453 | + if( $default_label !== NULL && $default_label !== false ) { |
|
454 | + $pages_options = array( '' => $default_label ); // Blank option |
|
455 | + } |
|
456 | 456 | |
457 | - $pages = get_pages(); |
|
458 | - if ( $pages ) { |
|
459 | - foreach ( $pages as $page ) { |
|
460 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
457 | + $pages = get_pages(); |
|
458 | + if ( $pages ) { |
|
459 | + foreach ( $pages as $page ) { |
|
460 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
461 | 461 | $pages_options[ $page->ID ] = $title; |
462 | - } |
|
463 | - } |
|
462 | + } |
|
463 | + } |
|
464 | 464 | |
465 | - return $pages_options; |
|
465 | + return $pages_options; |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | function wpinv_header_callback( $args ) { |
469 | - if ( !empty( $args['desc'] ) ) { |
|
469 | + if ( !empty( $args['desc'] ) ) { |
|
470 | 470 | echo $args['desc']; |
471 | 471 | } |
472 | 472 | } |
473 | 473 | |
474 | 474 | function wpinv_hidden_callback( $args ) { |
475 | 475 | |
476 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
477 | - $value = wpinv_get_option( $args['id'], $std ); |
|
476 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
477 | + $value = wpinv_get_option( $args['id'], $std ); |
|
478 | 478 | |
479 | - if ( isset( $args['set_value'] ) ) { |
|
480 | - $value = $args['set_value']; |
|
481 | - } |
|
479 | + if ( isset( $args['set_value'] ) ) { |
|
480 | + $value = $args['set_value']; |
|
481 | + } |
|
482 | 482 | |
483 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
484 | - $args['readonly'] = true; |
|
485 | - $name = ''; |
|
486 | - } else { |
|
487 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
488 | - } |
|
483 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
484 | + $args['readonly'] = true; |
|
485 | + $name = ''; |
|
486 | + } else { |
|
487 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
488 | + } |
|
489 | 489 | |
490 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
490 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
491 | 491 | |
492 | - echo $html; |
|
492 | + echo $html; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | /** |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | */ |
498 | 498 | function wpinv_checkbox_callback( $args ) { |
499 | 499 | |
500 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
501 | - $std = wpinv_get_option( $args['id'], $std ); |
|
502 | - $id = esc_attr( $args['id'] ); |
|
500 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
501 | + $std = wpinv_get_option( $args['id'], $std ); |
|
502 | + $id = esc_attr( $args['id'] ); |
|
503 | 503 | |
504 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
505 | - ?> |
|
504 | + getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
505 | + ?> |
|
506 | 506 | <fieldset> |
507 | 507 | <label> |
508 | 508 | <input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox"> |
@@ -514,75 +514,75 @@ discard block |
||
514 | 514 | |
515 | 515 | function wpinv_multicheck_callback( $args ) { |
516 | 516 | |
517 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
518 | - $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
517 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
518 | + $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
519 | 519 | |
520 | - if ( ! empty( $args['options'] ) ) { |
|
520 | + if ( ! empty( $args['options'] ) ) { |
|
521 | 521 | |
522 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
523 | - $value = wpinv_get_option( $args['id'], $std ); |
|
522 | + $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
523 | + $value = wpinv_get_option( $args['id'], $std ); |
|
524 | 524 | |
525 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
525 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">'; |
|
526 | 526 | foreach( $args['options'] as $key => $option ): |
527 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
528 | - if ( in_array( $sanitize_key, $value ) ) { |
|
529 | - $enabled = $sanitize_key; |
|
530 | - } else { |
|
531 | - $enabled = NULL; |
|
532 | - } |
|
533 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
534 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
535 | - endforeach; |
|
536 | - echo '</div>'; |
|
537 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
538 | - } |
|
527 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
528 | + if ( in_array( $sanitize_key, $value ) ) { |
|
529 | + $enabled = $sanitize_key; |
|
530 | + } else { |
|
531 | + $enabled = NULL; |
|
532 | + } |
|
533 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
534 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
535 | + endforeach; |
|
536 | + echo '</div>'; |
|
537 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
538 | + } |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | function wpinv_payment_icons_callback( $args ) { |
542 | 542 | |
543 | 543 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
544 | - $value = wpinv_get_option( $args['id'], false); |
|
544 | + $value = wpinv_get_option( $args['id'], false); |
|
545 | 545 | |
546 | - if ( ! empty( $args['options'] ) ) { |
|
547 | - foreach( $args['options'] as $key => $option ) { |
|
546 | + if ( ! empty( $args['options'] ) ) { |
|
547 | + foreach( $args['options'] as $key => $option ) { |
|
548 | 548 | $sanitize_key = wpinv_sanitize_key( $key ); |
549 | 549 | |
550 | - if( empty( $value ) ) { |
|
551 | - $enabled = $option; |
|
552 | - } else { |
|
553 | - $enabled = NULL; |
|
554 | - } |
|
555 | - |
|
556 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
557 | - |
|
558 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
559 | - |
|
560 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
561 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
562 | - } else { |
|
563 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
564 | - |
|
565 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
566 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
567 | - } else { |
|
568 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
569 | - $content_dir = WP_CONTENT_DIR; |
|
570 | - |
|
571 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
572 | - // Replaces backslashes with forward slashes for Windows systems |
|
573 | - $image = wp_normalize_path( $image ); |
|
574 | - $content_dir = wp_normalize_path( $content_dir ); |
|
575 | - } |
|
576 | - |
|
577 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
578 | - } |
|
579 | - |
|
580 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
581 | - } |
|
582 | - echo $option . '</label>'; |
|
583 | - } |
|
584 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
585 | - } |
|
550 | + if( empty( $value ) ) { |
|
551 | + $enabled = $option; |
|
552 | + } else { |
|
553 | + $enabled = NULL; |
|
554 | + } |
|
555 | + |
|
556 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
557 | + |
|
558 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
559 | + |
|
560 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
561 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
562 | + } else { |
|
563 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
564 | + |
|
565 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
566 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
567 | + } else { |
|
568 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
569 | + $content_dir = WP_CONTENT_DIR; |
|
570 | + |
|
571 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
572 | + // Replaces backslashes with forward slashes for Windows systems |
|
573 | + $image = wp_normalize_path( $image ); |
|
574 | + $content_dir = wp_normalize_path( $content_dir ); |
|
575 | + } |
|
576 | + |
|
577 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
578 | + } |
|
579 | + |
|
580 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
581 | + } |
|
582 | + echo $option . '</label>'; |
|
583 | + } |
|
584 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
585 | + } |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | /** |
@@ -590,9 +590,9 @@ discard block |
||
590 | 590 | */ |
591 | 591 | function wpinv_radio_callback( $args ) { |
592 | 592 | |
593 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
594 | - $std = wpinv_get_option( $args['id'], $std ); |
|
595 | - ?> |
|
593 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
594 | + $std = wpinv_get_option( $args['id'], $std ); |
|
595 | + ?> |
|
596 | 596 | <fieldset> |
597 | 597 | <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
598 | 598 | <?php foreach( $args['options'] as $key => $option ) : ?> |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | </ul> |
607 | 607 | </fieldset> |
608 | 608 | <?php |
609 | - getpaid_settings_description_callback( $args ); |
|
609 | + getpaid_settings_description_callback( $args ); |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | /** |
@@ -614,10 +614,10 @@ discard block |
||
614 | 614 | */ |
615 | 615 | function getpaid_settings_description_callback( $args ) { |
616 | 616 | |
617 | - if ( ! empty( $args['desc'] ) ) { |
|
618 | - $description = wp_kses_post( $args['desc'] ); |
|
619 | - echo "<p class='description'>$description</p>"; |
|
620 | - } |
|
617 | + if ( ! empty( $args['desc'] ) ) { |
|
618 | + $description = wp_kses_post( $args['desc'] ); |
|
619 | + echo "<p class='description'>$description</p>"; |
|
620 | + } |
|
621 | 621 | |
622 | 622 | } |
623 | 623 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | */ |
627 | 627 | function wpinv_gateways_callback() { |
628 | 628 | |
629 | - ?> |
|
629 | + ?> |
|
630 | 630 | </td> |
631 | 631 | </tr> |
632 | 632 | <tr class="bsui"> |
@@ -640,22 +640,22 @@ discard block |
||
640 | 640 | |
641 | 641 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
642 | 642 | $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
643 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
644 | - $value = wpinv_get_option( $args['id'], $std ); |
|
643 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
644 | + $value = wpinv_get_option( $args['id'], $std ); |
|
645 | 645 | |
646 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
646 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >'; |
|
647 | 647 | |
648 | - foreach ( $args['options'] as $key => $option ) : |
|
649 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
648 | + foreach ( $args['options'] as $key => $option ) : |
|
649 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
650 | 650 | $selected = selected( $key, $args['selected'], false ); |
651 | 651 | } else { |
652 | 652 | $selected = selected( $key, $value, false ); |
653 | 653 | } |
654 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
655 | - endforeach; |
|
654 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
655 | + endforeach; |
|
656 | 656 | |
657 | - echo '</select>'; |
|
658 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
657 | + echo '</select>'; |
|
658 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | /** |
@@ -666,29 +666,29 @@ discard block |
||
666 | 666 | */ |
667 | 667 | function wpinv_settings_attrs_helper( $args ) { |
668 | 668 | |
669 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
670 | - $id = esc_attr( $args['id'] ); |
|
671 | - $placeholder = esc_attr( $args['placeholder'] ); |
|
669 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
670 | + $id = esc_attr( $args['id'] ); |
|
671 | + $placeholder = esc_attr( $args['placeholder'] ); |
|
672 | 672 | |
673 | - if ( ! empty( $args['faux'] ) ) { |
|
674 | - $args['readonly'] = true; |
|
675 | - $name = ''; |
|
676 | - } else { |
|
677 | - $value = wpinv_get_option( $args['id'], $value ); |
|
678 | - $name = "wpinv_settings[$id]"; |
|
679 | - } |
|
673 | + if ( ! empty( $args['faux'] ) ) { |
|
674 | + $args['readonly'] = true; |
|
675 | + $name = ''; |
|
676 | + } else { |
|
677 | + $value = wpinv_get_option( $args['id'], $value ); |
|
678 | + $name = "wpinv_settings[$id]"; |
|
679 | + } |
|
680 | 680 | |
681 | - $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
682 | - $class = esc_attr( $args['class'] ); |
|
683 | - $style = esc_attr( $args['style'] ); |
|
684 | - $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
681 | + $value = is_scalar( $value ) ? esc_attr( $value ) : ''; |
|
682 | + $class = esc_attr( $args['class'] ); |
|
683 | + $style = esc_attr( $args['style'] ); |
|
684 | + $readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"'; |
|
685 | 685 | |
686 | - $onchange = ''; |
|
686 | + $onchange = ''; |
|
687 | 687 | if ( ! empty( $args['onchange'] ) ) { |
688 | 688 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
689 | - } |
|
689 | + } |
|
690 | 690 | |
691 | - return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
691 | + return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly"; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -696,11 +696,11 @@ discard block |
||
696 | 696 | */ |
697 | 697 | function wpinv_text_callback( $args ) { |
698 | 698 | |
699 | - $desc = wp_kses_post( $args['desc'] ); |
|
700 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
701 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
699 | + $desc = wp_kses_post( $args['desc'] ); |
|
700 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
701 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
702 | 702 | |
703 | - ?> |
|
703 | + ?> |
|
704 | 704 | <label style="width: 100%;"> |
705 | 705 | <input type="text" <?php echo $attr; ?>> |
706 | 706 | <?php echo $desc; ?> |
@@ -714,14 +714,14 @@ discard block |
||
714 | 714 | */ |
715 | 715 | function wpinv_number_callback( $args ) { |
716 | 716 | |
717 | - $desc = wp_kses_post( $args['desc'] ); |
|
718 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
719 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
720 | - $max = intval( $args['max'] ); |
|
721 | - $min = intval( $args['min'] ); |
|
722 | - $step = floatval( $args['step'] ); |
|
717 | + $desc = wp_kses_post( $args['desc'] ); |
|
718 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
719 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
720 | + $max = intval( $args['max'] ); |
|
721 | + $min = intval( $args['min'] ); |
|
722 | + $step = floatval( $args['step'] ); |
|
723 | 723 | |
724 | - ?> |
|
724 | + ?> |
|
725 | 725 | <label style="width: 100%;"> |
726 | 726 | <input type="number" step="<?php echo $step; ?>" max="<?php echo $max; ?>" min="<?php echo $min; ?>" <?php echo $attr; ?>> |
727 | 727 | <?php echo $desc; ?> |
@@ -733,36 +733,36 @@ discard block |
||
733 | 733 | function wpinv_textarea_callback( $args ) { |
734 | 734 | |
735 | 735 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
736 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
737 | - $value = wpinv_get_option( $args['id'], $std ); |
|
736 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
737 | + $value = wpinv_get_option( $args['id'], $std ); |
|
738 | 738 | |
739 | 739 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
740 | 740 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
741 | 741 | |
742 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
743 | - $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
742 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
743 | + $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
744 | 744 | |
745 | - echo $html; |
|
745 | + echo $html; |
|
746 | 746 | } |
747 | 747 | |
748 | 748 | function wpinv_password_callback( $args ) { |
749 | 749 | |
750 | 750 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
751 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
752 | - $value = wpinv_get_option( $args['id'], $std ); |
|
751 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
752 | + $value = wpinv_get_option( $args['id'], $std ); |
|
753 | 753 | |
754 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
755 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
756 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
754 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
755 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
756 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
757 | 757 | |
758 | - echo $html; |
|
758 | + echo $html; |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | function wpinv_missing_callback($args) { |
762 | - printf( |
|
763 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
764 | - '<strong>' . $args['id'] . '</strong>' |
|
765 | - ); |
|
762 | + printf( |
|
763 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
764 | + '<strong>' . $args['id'] . '</strong>' |
|
765 | + ); |
|
766 | 766 | } |
767 | 767 | |
768 | 768 | /** |
@@ -770,14 +770,14 @@ discard block |
||
770 | 770 | */ |
771 | 771 | function wpinv_select_callback( $args ) { |
772 | 772 | |
773 | - $desc = wp_kses_post( $args['desc'] ); |
|
774 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
775 | - $attr = wpinv_settings_attrs_helper( $args ); |
|
776 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
777 | - $value = wpinv_get_option( $args['id'], $value ); |
|
778 | - $rand = uniqid( 'random_id' ); |
|
773 | + $desc = wp_kses_post( $args['desc'] ); |
|
774 | + $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
775 | + $attr = wpinv_settings_attrs_helper( $args ); |
|
776 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
777 | + $value = wpinv_get_option( $args['id'], $value ); |
|
778 | + $rand = uniqid( 'random_id' ); |
|
779 | 779 | |
780 | - ?> |
|
780 | + ?> |
|
781 | 781 | <label style="width: 100%;"> |
782 | 782 | <select <?php echo $attr; ?>> |
783 | 783 | <?php foreach ( $args['options'] as $option => $name ) : ?> |
@@ -810,104 +810,104 @@ discard block |
||
810 | 810 | function wpinv_color_select_callback( $args ) { |
811 | 811 | |
812 | 812 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
813 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
814 | - $value = wpinv_get_option( $args['id'], $std ); |
|
813 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
814 | + $value = wpinv_get_option( $args['id'], $std ); |
|
815 | 815 | |
816 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
816 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
817 | 817 | |
818 | - foreach ( $args['options'] as $option => $color ) { |
|
819 | - $selected = selected( $option, $value, false ); |
|
820 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
821 | - } |
|
818 | + foreach ( $args['options'] as $option => $color ) { |
|
819 | + $selected = selected( $option, $value, false ); |
|
820 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
821 | + } |
|
822 | 822 | |
823 | - $html .= '</select>'; |
|
824 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
823 | + $html .= '</select>'; |
|
824 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
825 | 825 | |
826 | - echo $html; |
|
826 | + echo $html; |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | function wpinv_rich_editor_callback( $args ) { |
830 | - global $wp_version; |
|
830 | + global $wp_version; |
|
831 | 831 | |
832 | 832 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
833 | 833 | |
834 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
835 | - $value = wpinv_get_option( $args['id'], $std ); |
|
834 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
835 | + $value = wpinv_get_option( $args['id'], $std ); |
|
836 | 836 | |
837 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
838 | - $value = $std; |
|
839 | - } |
|
837 | + if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
838 | + $value = $std; |
|
839 | + } |
|
840 | 840 | |
841 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
841 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
842 | 842 | |
843 | - $html = '<div class="getpaid-settings-editor-input">'; |
|
844 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
845 | - ob_start(); |
|
846 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
847 | - $html .= ob_get_clean(); |
|
848 | - } else { |
|
849 | - $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
850 | - } |
|
843 | + $html = '<div class="getpaid-settings-editor-input">'; |
|
844 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
845 | + ob_start(); |
|
846 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) ); |
|
847 | + $html .= ob_get_clean(); |
|
848 | + } else { |
|
849 | + $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
850 | + } |
|
851 | 851 | |
852 | - $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
852 | + $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
853 | 853 | |
854 | - echo $html; |
|
854 | + echo $html; |
|
855 | 855 | } |
856 | 856 | |
857 | 857 | function wpinv_upload_callback( $args ) { |
858 | 858 | |
859 | 859 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
860 | 860 | |
861 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | - $value = wpinv_get_option( $args['id'], $std ); |
|
861 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
862 | + $value = wpinv_get_option( $args['id'], $std ); |
|
863 | 863 | |
864 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
864 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
865 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
866 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
867 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
868 | 868 | |
869 | - echo $html; |
|
869 | + echo $html; |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | function wpinv_color_callback( $args ) { |
873 | 873 | |
874 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
875 | - $value = wpinv_get_option( $args['id'], $std ); |
|
874 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
875 | + $value = wpinv_get_option( $args['id'], $std ); |
|
876 | 876 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
877 | 877 | |
878 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
879 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
878 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
879 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
880 | 880 | |
881 | - echo $html; |
|
881 | + echo $html; |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | function wpinv_country_states_callback($args) { |
885 | 885 | |
886 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
887 | - $value = wpinv_get_option( $args['id'], $std ); |
|
886 | + $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
887 | + $value = wpinv_get_option( $args['id'], $std ); |
|
888 | 888 | |
889 | 889 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
890 | 890 | |
891 | - if ( isset( $args['placeholder'] ) ) { |
|
892 | - $placeholder = $args['placeholder']; |
|
893 | - } else { |
|
894 | - $placeholder = ''; |
|
895 | - } |
|
891 | + if ( isset( $args['placeholder'] ) ) { |
|
892 | + $placeholder = $args['placeholder']; |
|
893 | + } else { |
|
894 | + $placeholder = ''; |
|
895 | + } |
|
896 | 896 | |
897 | - $states = wpinv_get_country_states(); |
|
897 | + $states = wpinv_get_country_states(); |
|
898 | 898 | |
899 | - $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
900 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
899 | + $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"'; |
|
900 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
901 | 901 | |
902 | - foreach ( $states as $option => $name ) { |
|
903 | - $selected = selected( $option, $value, false ); |
|
904 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
905 | - } |
|
902 | + foreach ( $states as $option => $name ) { |
|
903 | + $selected = selected( $option, $value, false ); |
|
904 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
905 | + } |
|
906 | 906 | |
907 | - $html .= '</select>'; |
|
908 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
907 | + $html .= '</select>'; |
|
908 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
909 | 909 | |
910 | - echo $html; |
|
910 | + echo $html; |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | */ |
916 | 916 | function wpinv_tax_rates_callback() { |
917 | 917 | |
918 | - ?> |
|
918 | + ?> |
|
919 | 919 | </td> |
920 | 920 | </tr> |
921 | 921 | <tr class="bsui"> |
@@ -930,17 +930,17 @@ discard block |
||
930 | 930 | * Displays a tax rate' edit row. |
931 | 931 | */ |
932 | 932 | function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) { |
933 | - ob_start(); |
|
933 | + ob_start(); |
|
934 | 934 | |
935 | - $key = sanitize_key( $key ); |
|
936 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
937 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
935 | + $key = sanitize_key( $key ); |
|
936 | + $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
937 | + include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
938 | 938 | |
939 | - if ( $echo ) { |
|
940 | - echo ob_get_clean(); |
|
941 | - } else { |
|
942 | - return ob_get_clean(); |
|
943 | - } |
|
939 | + if ( $echo ) { |
|
940 | + echo ob_get_clean(); |
|
941 | + } else { |
|
942 | + return ob_get_clean(); |
|
943 | + } |
|
944 | 944 | |
945 | 945 | } |
946 | 946 | |
@@ -968,14 +968,14 @@ discard block |
||
968 | 968 | </td> |
969 | 969 | <td> |
970 | 970 | <a href="<?php |
971 | - echo esc_url( |
|
972 | - wp_nonce_url( |
|
973 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
974 | - 'getpaid-nonce', |
|
975 | - 'getpaid-nonce' |
|
976 | - ) |
|
977 | - ); |
|
978 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
971 | + echo esc_url( |
|
972 | + wp_nonce_url( |
|
973 | + add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
974 | + 'getpaid-nonce', |
|
975 | + 'getpaid-nonce' |
|
976 | + ) |
|
977 | + ); |
|
978 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
979 | 979 | </td> |
980 | 980 | </tr> |
981 | 981 | <tr> |
@@ -985,14 +985,14 @@ discard block |
||
985 | 985 | </td> |
986 | 986 | <td> |
987 | 987 | <a href="<?php |
988 | - echo esc_url( |
|
989 | - wp_nonce_url( |
|
990 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
991 | - 'getpaid-nonce', |
|
992 | - 'getpaid-nonce' |
|
993 | - ) |
|
994 | - ); |
|
995 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
988 | + echo esc_url( |
|
989 | + wp_nonce_url( |
|
990 | + add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
991 | + 'getpaid-nonce', |
|
992 | + 'getpaid-nonce' |
|
993 | + ) |
|
994 | + ); |
|
995 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
996 | 996 | </td> |
997 | 997 | </tr> |
998 | 998 | <tr> |
@@ -1002,14 +1002,14 @@ discard block |
||
1002 | 1002 | </td> |
1003 | 1003 | <td> |
1004 | 1004 | <a href="<?php |
1005 | - echo esc_url( |
|
1006 | - wp_nonce_url( |
|
1007 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1008 | - 'getpaid-nonce', |
|
1009 | - 'getpaid-nonce' |
|
1010 | - ) |
|
1011 | - ); |
|
1012 | - ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
1005 | + echo esc_url( |
|
1006 | + wp_nonce_url( |
|
1007 | + add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1008 | + 'getpaid-nonce', |
|
1009 | + 'getpaid-nonce' |
|
1010 | + ) |
|
1011 | + ); |
|
1012 | + ?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a> |
|
1013 | 1013 | </td> |
1014 | 1014 | </tr> |
1015 | 1015 | |
@@ -1020,14 +1020,14 @@ discard block |
||
1020 | 1020 | </td> |
1021 | 1021 | <td> |
1022 | 1022 | <a href="<?php |
1023 | - echo esc_url( |
|
1024 | - wp_nonce_url( |
|
1025 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1026 | - 'getpaid-nonce', |
|
1027 | - 'getpaid-nonce' |
|
1028 | - ) |
|
1029 | - ); |
|
1030 | - ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1023 | + echo esc_url( |
|
1024 | + wp_nonce_url( |
|
1025 | + add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1026 | + 'getpaid-nonce', |
|
1027 | + 'getpaid-nonce' |
|
1028 | + ) |
|
1029 | + ); |
|
1030 | + ?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a> |
|
1031 | 1031 | </td> |
1032 | 1032 | </tr> |
1033 | 1033 | |
@@ -1041,19 +1041,19 @@ discard block |
||
1041 | 1041 | |
1042 | 1042 | |
1043 | 1043 | function wpinv_descriptive_text_callback( $args ) { |
1044 | - echo wp_kses_post( $args['desc'] ); |
|
1044 | + echo wp_kses_post( $args['desc'] ); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | 1047 | function wpinv_raw_html_callback( $args ) { |
1048 | - echo $args['desc']; |
|
1048 | + echo $args['desc']; |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | function wpinv_hook_callback( $args ) { |
1052 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1052 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | function wpinv_set_settings_cap() { |
1056 | - return wpinv_get_capability(); |
|
1056 | + return wpinv_get_capability(); |
|
1057 | 1057 | } |
1058 | 1058 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
1059 | 1059 | |
@@ -1087,15 +1087,15 @@ discard block |
||
1087 | 1087 | */ |
1088 | 1088 | function wpinv_get_merge_tags_help_text( $subscription = false ) { |
1089 | 1089 | |
1090 | - $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1091 | - $link = sprintf( |
|
1092 | - '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1093 | - $url, |
|
1094 | - esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1095 | - ); |
|
1090 | + $url = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f'; |
|
1091 | + $link = sprintf( |
|
1092 | + '<strong><a href="%s" target="_blank">%s</a></strong>', |
|
1093 | + $url, |
|
1094 | + esc_html__( 'View available merge tags.', 'wpinv-quotes' ) |
|
1095 | + ); |
|
1096 | 1096 | |
1097 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1097 | + $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1098 | 1098 | |
1099 | - return "$description $link"; |
|
1099 | + return "$description $link"; |
|
1100 | 1100 | |
1101 | 1101 | } |
@@ -15,331 +15,331 @@ |
||
15 | 15 | class GetPaid_Post_Types { |
16 | 16 | |
17 | 17 | /** |
18 | - * Hook in methods. |
|
19 | - */ |
|
20 | - public function __construct() { |
|
21 | - add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | - add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | - add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | - add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | - } |
|
18 | + * Hook in methods. |
|
19 | + */ |
|
20 | + public function __construct() { |
|
21 | + add_action( 'init', array( __CLASS__, 'register_post_types' ), 1 ); |
|
22 | + add_action( 'init', array( __CLASS__, 'register_post_status' ), 4 ); |
|
23 | + add_action( 'getpaid_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
24 | + add_action( 'getpaid_after_register_post_types', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Register core post types. |
|
29 | - */ |
|
30 | - public static function register_post_types() { |
|
27 | + /** |
|
28 | + * Register core post types. |
|
29 | + */ |
|
30 | + public static function register_post_types() { |
|
31 | 31 | |
32 | - if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | - return; |
|
34 | - } |
|
32 | + if ( ! is_blog_installed() || post_type_exists( 'wpi_item' ) ) { |
|
33 | + return; |
|
34 | + } |
|
35 | 35 | |
36 | - $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
36 | + $capabilities = wpinv_current_user_can_manage_invoicing(); |
|
37 | 37 | |
38 | - // Fires before registering post types. |
|
39 | - do_action( 'getpaid_register_post_types' ); |
|
38 | + // Fires before registering post types. |
|
39 | + do_action( 'getpaid_register_post_types' ); |
|
40 | 40 | |
41 | - // Register item post type. |
|
42 | - register_post_type( |
|
43 | - 'wpi_item', |
|
44 | - apply_filters( |
|
45 | - 'wpinv_register_post_type_invoice_item', |
|
46 | - array( |
|
47 | - 'labels' => array( |
|
48 | - 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | - 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | - 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | - 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | - 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | - 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | - 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | - 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | - 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | - 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | - 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | - 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | - 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | - 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | - ), |
|
63 | - 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | - 'public' => false, |
|
65 | - 'has_archive' => false, |
|
66 | - '_builtin' => false, |
|
67 | - 'show_ui' => true, |
|
68 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | - 'show_in_nav_menus' => false, |
|
70 | - 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | - 'rewrite' => false, |
|
72 | - 'query_var' => false, |
|
73 | - 'map_meta_cap' => true, |
|
74 | - 'show_in_admin_bar' => true, |
|
75 | - 'can_export' => true, |
|
76 | - ) |
|
77 | - ) |
|
78 | - ); |
|
41 | + // Register item post type. |
|
42 | + register_post_type( |
|
43 | + 'wpi_item', |
|
44 | + apply_filters( |
|
45 | + 'wpinv_register_post_type_invoice_item', |
|
46 | + array( |
|
47 | + 'labels' => array( |
|
48 | + 'name' => _x( 'Items', 'post type general name', 'invoicing' ), |
|
49 | + 'singular_name' => _x( 'Item', 'post type singular name', 'invoicing' ), |
|
50 | + 'menu_name' => _x( 'Items', 'admin menu', 'invoicing' ), |
|
51 | + 'name_admin_bar' => _x( 'Item', 'add new on admin bar', 'invoicing' ), |
|
52 | + 'add_new' => _x( 'Add New', 'Item', 'invoicing' ), |
|
53 | + 'add_new_item' => __( 'Add New Item', 'invoicing' ), |
|
54 | + 'new_item' => __( 'New Item', 'invoicing' ), |
|
55 | + 'edit_item' => __( 'Edit Item', 'invoicing' ), |
|
56 | + 'view_item' => __( 'View Item', 'invoicing' ), |
|
57 | + 'all_items' => __( 'Items', 'invoicing' ), |
|
58 | + 'search_items' => __( 'Search items', 'invoicing' ), |
|
59 | + 'parent_item_colon' => __( 'Parent item:', 'invoicing' ), |
|
60 | + 'not_found' => __( 'No items found.', 'invoicing' ), |
|
61 | + 'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' ) |
|
62 | + ), |
|
63 | + 'description' => __( 'This is where you can add new invoice items.', 'invoicing' ), |
|
64 | + 'public' => false, |
|
65 | + 'has_archive' => false, |
|
66 | + '_builtin' => false, |
|
67 | + 'show_ui' => true, |
|
68 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
69 | + 'show_in_nav_menus' => false, |
|
70 | + 'supports' => array( 'title', 'excerpt', 'thumbnail' ), |
|
71 | + 'rewrite' => false, |
|
72 | + 'query_var' => false, |
|
73 | + 'map_meta_cap' => true, |
|
74 | + 'show_in_admin_bar' => true, |
|
75 | + 'can_export' => true, |
|
76 | + ) |
|
77 | + ) |
|
78 | + ); |
|
79 | 79 | |
80 | - // Register payment form post type. |
|
81 | - register_post_type( |
|
82 | - 'wpi_payment_form', |
|
83 | - apply_filters( |
|
84 | - 'wpinv_register_post_type_payment_form', |
|
85 | - array( |
|
86 | - 'labels' => array( |
|
87 | - 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | - 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | - 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | - 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | - 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | - 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | - 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | - 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | - 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | - 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | - 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | - 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | - 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | - 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | - ), |
|
102 | - 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | - 'public' => false, |
|
104 | - 'show_ui' => true, |
|
105 | - 'show_in_menu' => $capabilities ? 'wpinv' : true, |
|
106 | - 'show_in_nav_menus' => false, |
|
107 | - 'query_var' => false, |
|
108 | - 'rewrite' => true, |
|
109 | - 'map_meta_cap' => true, |
|
110 | - 'has_archive' => false, |
|
111 | - 'hierarchical' => false, |
|
112 | - 'menu_position' => null, |
|
113 | - 'supports' => array( 'title' ), |
|
114 | - 'menu_icon' => 'dashicons-media-form', |
|
115 | - 'capabilities' => array( |
|
116 | - 'edit_post' => $capabilities, |
|
117 | - 'read_post' => $capabilities, |
|
118 | - 'delete_post' => $capabilities, |
|
119 | - 'edit_posts' => 'update_core', |
|
120 | - 'edit_others_posts' => 'update_core', |
|
121 | - 'delete_posts' => 'update_core', |
|
122 | - 'publish_posts' => 'update_core', |
|
123 | - 'read_private_posts' => 'update_core' |
|
124 | - ), |
|
125 | - ) |
|
126 | - ) |
|
127 | - ); |
|
80 | + // Register payment form post type. |
|
81 | + register_post_type( |
|
82 | + 'wpi_payment_form', |
|
83 | + apply_filters( |
|
84 | + 'wpinv_register_post_type_payment_form', |
|
85 | + array( |
|
86 | + 'labels' => array( |
|
87 | + 'name' => _x( 'Payment Forms', 'post type general name', 'invoicing' ), |
|
88 | + 'singular_name' => _x( 'Payment Form', 'post type singular name', 'invoicing' ), |
|
89 | + 'menu_name' => _x( 'Payment Forms', 'admin menu', 'invoicing' ), |
|
90 | + 'name_admin_bar' => _x( 'Payment Form', 'add new on admin bar', 'invoicing' ), |
|
91 | + 'add_new' => _x( 'Add New', 'Payment Form', 'invoicing' ), |
|
92 | + 'add_new_item' => __( 'Add New Payment Form', 'invoicing' ), |
|
93 | + 'new_item' => __( 'New Payment Form', 'invoicing' ), |
|
94 | + 'edit_item' => __( 'Edit Payment Form', 'invoicing' ), |
|
95 | + 'view_item' => __( 'View Payment Form', 'invoicing' ), |
|
96 | + 'all_items' => __( 'Payment Forms', 'invoicing' ), |
|
97 | + 'search_items' => __( 'Search Payment Forms', 'invoicing' ), |
|
98 | + 'parent_item_colon' => __( 'Parent Payment Forms:', 'invoicing' ), |
|
99 | + 'not_found' => __( 'No payment forms found.', 'invoicing' ), |
|
100 | + 'not_found_in_trash' => __( 'No payment forms found in trash.', 'invoicing' ) |
|
101 | + ), |
|
102 | + 'description' => __( 'Add new payment forms.', 'invoicing' ), |
|
103 | + 'public' => false, |
|
104 | + 'show_ui' => true, |
|
105 | + 'show_in_menu' => $capabilities ? 'wpinv' : true, |
|
106 | + 'show_in_nav_menus' => false, |
|
107 | + 'query_var' => false, |
|
108 | + 'rewrite' => true, |
|
109 | + 'map_meta_cap' => true, |
|
110 | + 'has_archive' => false, |
|
111 | + 'hierarchical' => false, |
|
112 | + 'menu_position' => null, |
|
113 | + 'supports' => array( 'title' ), |
|
114 | + 'menu_icon' => 'dashicons-media-form', |
|
115 | + 'capabilities' => array( |
|
116 | + 'edit_post' => $capabilities, |
|
117 | + 'read_post' => $capabilities, |
|
118 | + 'delete_post' => $capabilities, |
|
119 | + 'edit_posts' => 'update_core', |
|
120 | + 'edit_others_posts' => 'update_core', |
|
121 | + 'delete_posts' => 'update_core', |
|
122 | + 'publish_posts' => 'update_core', |
|
123 | + 'read_private_posts' => 'update_core' |
|
124 | + ), |
|
125 | + ) |
|
126 | + ) |
|
127 | + ); |
|
128 | 128 | |
129 | - // Register invoice post type. |
|
130 | - register_post_type( |
|
131 | - 'wpi_invoice', |
|
132 | - apply_filters( |
|
133 | - 'wpinv_register_post_type_invoice', |
|
134 | - array( |
|
135 | - 'labels' => array( |
|
136 | - 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | - 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | - 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | - 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | - 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | - 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | - 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | - 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | - 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | - 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | - 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | - 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | - 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | - 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | - 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | - 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | - 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | - 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | - 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | - 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | - 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | - 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | - ), |
|
161 | - 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | - 'public' => true, |
|
163 | - 'has_archive' => false, |
|
164 | - 'publicly_queryable' => true, |
|
165 | - 'exclude_from_search' => true, |
|
166 | - 'show_ui' => true, |
|
167 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | - 'show_in_nav_menus' => false, |
|
169 | - 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | - 'rewrite' => array( |
|
171 | - 'slug' => 'invoice', |
|
172 | - 'with_front' => false, |
|
173 | - ), |
|
174 | - 'query_var' => false, |
|
175 | - 'map_meta_cap' => true, |
|
176 | - 'show_in_admin_bar' => true, |
|
177 | - 'can_export' => true, |
|
178 | - 'hierarchical' => false, |
|
179 | - 'menu_position' => null, |
|
180 | - 'menu_icon' => 'dashicons-media-spreadsheet', |
|
181 | - ) |
|
182 | - ) |
|
183 | - ); |
|
129 | + // Register invoice post type. |
|
130 | + register_post_type( |
|
131 | + 'wpi_invoice', |
|
132 | + apply_filters( |
|
133 | + 'wpinv_register_post_type_invoice', |
|
134 | + array( |
|
135 | + 'labels' => array( |
|
136 | + 'name' => __( 'Invoices', 'invoicing' ), |
|
137 | + 'singular_name' => __( 'Invoice', 'invoicing' ), |
|
138 | + 'all_items' => __( 'Invoices', 'invoicing' ), |
|
139 | + 'menu_name' => _x( 'Invoices', 'Admin menu name', 'invoicing' ), |
|
140 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
141 | + 'add_new_item' => __( 'Add new invoice', 'invoicing' ), |
|
142 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
143 | + 'edit_item' => __( 'Edit invoice', 'invoicing' ), |
|
144 | + 'new_item' => __( 'New invoice', 'invoicing' ), |
|
145 | + 'view_item' => __( 'View invoice', 'invoicing' ), |
|
146 | + 'view_items' => __( 'View Invoices', 'invoicing' ), |
|
147 | + 'search_items' => __( 'Search invoices', 'invoicing' ), |
|
148 | + 'not_found' => __( 'No invoices found', 'invoicing' ), |
|
149 | + 'not_found_in_trash' => __( 'No invoices found in trash', 'invoicing' ), |
|
150 | + 'parent' => __( 'Parent invoice', 'invoicing' ), |
|
151 | + 'featured_image' => __( 'Invoice image', 'invoicing' ), |
|
152 | + 'set_featured_image' => __( 'Set invoice image', 'invoicing' ), |
|
153 | + 'remove_featured_image' => __( 'Remove invoice image', 'invoicing' ), |
|
154 | + 'use_featured_image' => __( 'Use as invoice image', 'invoicing' ), |
|
155 | + 'insert_into_item' => __( 'Insert into invoice', 'invoicing' ), |
|
156 | + 'uploaded_to_this_item' => __( 'Uploaded to this invoice', 'invoicing' ), |
|
157 | + 'filter_items_list' => __( 'Filter invoices', 'invoicing' ), |
|
158 | + 'items_list_navigation' => __( 'Invoices navigation', 'invoicing' ), |
|
159 | + 'items_list' => __( 'Invoices list', 'invoicing' ), |
|
160 | + ), |
|
161 | + 'description' => __( 'This is where invoices are stored.', 'invoicing' ), |
|
162 | + 'public' => true, |
|
163 | + 'has_archive' => false, |
|
164 | + 'publicly_queryable' => true, |
|
165 | + 'exclude_from_search' => true, |
|
166 | + 'show_ui' => true, |
|
167 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
168 | + 'show_in_nav_menus' => false, |
|
169 | + 'supports' => array( 'title', 'author', 'excerpt' ), |
|
170 | + 'rewrite' => array( |
|
171 | + 'slug' => 'invoice', |
|
172 | + 'with_front' => false, |
|
173 | + ), |
|
174 | + 'query_var' => false, |
|
175 | + 'map_meta_cap' => true, |
|
176 | + 'show_in_admin_bar' => true, |
|
177 | + 'can_export' => true, |
|
178 | + 'hierarchical' => false, |
|
179 | + 'menu_position' => null, |
|
180 | + 'menu_icon' => 'dashicons-media-spreadsheet', |
|
181 | + ) |
|
182 | + ) |
|
183 | + ); |
|
184 | 184 | |
185 | - // Register discount post type. |
|
186 | - register_post_type( |
|
187 | - 'wpi_discount', |
|
188 | - apply_filters( |
|
189 | - 'wpinv_register_post_type_discount', |
|
190 | - array( |
|
191 | - 'labels' => array( |
|
192 | - 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | - 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | - 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | - 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | - 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | - 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | - 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | - 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | - 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | - 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | - 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | - 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | - 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | - 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | - 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | - 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | - 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | - 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | - 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | - 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | - 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | - 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | - 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | - 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
216 | - ), |
|
217 | - 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
218 | - 'public' => false, |
|
219 | - 'can_export' => true, |
|
220 | - '_builtin' => false, |
|
221 | - 'publicly_queryable' => false, |
|
222 | - 'exclude_from_search'=> true, |
|
223 | - 'show_ui' => true, |
|
224 | - 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
225 | - 'query_var' => false, |
|
226 | - 'rewrite' => false, |
|
227 | - 'map_meta_cap' => true, |
|
228 | - 'has_archive' => false, |
|
229 | - 'hierarchical' => false, |
|
230 | - 'supports' => array( 'title', 'excerpt' ), |
|
231 | - 'show_in_nav_menus' => false, |
|
232 | - 'show_in_admin_bar' => true, |
|
233 | - 'menu_position' => null, |
|
234 | - ) |
|
235 | - ) |
|
236 | - ); |
|
185 | + // Register discount post type. |
|
186 | + register_post_type( |
|
187 | + 'wpi_discount', |
|
188 | + apply_filters( |
|
189 | + 'wpinv_register_post_type_discount', |
|
190 | + array( |
|
191 | + 'labels' => array( |
|
192 | + 'name' => __( 'Discounts', 'invoicing' ), |
|
193 | + 'singular_name' => __( 'Discount', 'invoicing' ), |
|
194 | + 'all_items' => __( 'Discounts', 'invoicing' ), |
|
195 | + 'menu_name' => _x( 'Discounts', 'Admin menu name', 'invoicing' ), |
|
196 | + 'add_new' => __( 'Add New', 'invoicing' ), |
|
197 | + 'add_new_item' => __( 'Add new discount', 'invoicing' ), |
|
198 | + 'edit' => __( 'Edit', 'invoicing' ), |
|
199 | + 'edit_item' => __( 'Edit discount', 'invoicing' ), |
|
200 | + 'new_item' => __( 'New discount', 'invoicing' ), |
|
201 | + 'view_item' => __( 'View discount', 'invoicing' ), |
|
202 | + 'view_items' => __( 'View Discounts', 'invoicing' ), |
|
203 | + 'search_items' => __( 'Search discounts', 'invoicing' ), |
|
204 | + 'not_found' => __( 'No discounts found', 'invoicing' ), |
|
205 | + 'not_found_in_trash' => __( 'No discounts found in trash', 'invoicing' ), |
|
206 | + 'parent' => __( 'Parent discount', 'invoicing' ), |
|
207 | + 'featured_image' => __( 'Discount image', 'invoicing' ), |
|
208 | + 'set_featured_image' => __( 'Set discount image', 'invoicing' ), |
|
209 | + 'remove_featured_image' => __( 'Remove discount image', 'invoicing' ), |
|
210 | + 'use_featured_image' => __( 'Use as discount image', 'invoicing' ), |
|
211 | + 'insert_into_item' => __( 'Insert into discount', 'invoicing' ), |
|
212 | + 'uploaded_to_this_item' => __( 'Uploaded to this discount', 'invoicing' ), |
|
213 | + 'filter_items_list' => __( 'Filter discounts', 'invoicing' ), |
|
214 | + 'items_list_navigation' => __( 'Discount navigation', 'invoicing' ), |
|
215 | + 'items_list' => __( 'Discounts list', 'invoicing' ), |
|
216 | + ), |
|
217 | + 'description' => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ), |
|
218 | + 'public' => false, |
|
219 | + 'can_export' => true, |
|
220 | + '_builtin' => false, |
|
221 | + 'publicly_queryable' => false, |
|
222 | + 'exclude_from_search'=> true, |
|
223 | + 'show_ui' => true, |
|
224 | + 'show_in_menu' => wpinv_current_user_can_manage_invoicing() ? 'wpinv' : false, |
|
225 | + 'query_var' => false, |
|
226 | + 'rewrite' => false, |
|
227 | + 'map_meta_cap' => true, |
|
228 | + 'has_archive' => false, |
|
229 | + 'hierarchical' => false, |
|
230 | + 'supports' => array( 'title', 'excerpt' ), |
|
231 | + 'show_in_nav_menus' => false, |
|
232 | + 'show_in_admin_bar' => true, |
|
233 | + 'menu_position' => null, |
|
234 | + ) |
|
235 | + ) |
|
236 | + ); |
|
237 | 237 | |
238 | - do_action( 'getpaid_after_register_post_types' ); |
|
239 | - } |
|
238 | + do_action( 'getpaid_after_register_post_types' ); |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Register our custom post statuses. |
|
243 | - */ |
|
244 | - public static function register_post_status() { |
|
241 | + /** |
|
242 | + * Register our custom post statuses. |
|
243 | + */ |
|
244 | + public static function register_post_status() { |
|
245 | 245 | |
246 | - $invoice_statuses = apply_filters( |
|
247 | - 'getpaid_register_invoice_post_statuses', |
|
248 | - array( |
|
246 | + $invoice_statuses = apply_filters( |
|
247 | + 'getpaid_register_invoice_post_statuses', |
|
248 | + array( |
|
249 | 249 | |
250 | - 'wpi-pending' => array( |
|
251 | - 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | - 'public' => true, |
|
253 | - 'exclude_from_search' => true, |
|
254 | - 'show_in_admin_all_list' => true, |
|
255 | - 'show_in_admin_status_list' => true, |
|
256 | - /* translators: %s: number of invoices */ |
|
257 | - 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | - ), |
|
250 | + 'wpi-pending' => array( |
|
251 | + 'label' => _x( 'Pending Payment', 'Invoice status', 'invoicing' ), |
|
252 | + 'public' => true, |
|
253 | + 'exclude_from_search' => true, |
|
254 | + 'show_in_admin_all_list' => true, |
|
255 | + 'show_in_admin_status_list' => true, |
|
256 | + /* translators: %s: number of invoices */ |
|
257 | + 'label_count' => _n_noop( 'Pending Payment <span class="count">(%s)</span>', 'Pending Payment <span class="count">(%s)</span>', 'invoicing' ) |
|
258 | + ), |
|
259 | 259 | |
260 | - 'wpi-processing' => array( |
|
261 | - 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | - 'public' => true, |
|
263 | - 'exclude_from_search' => true, |
|
264 | - 'show_in_admin_all_list' => true, |
|
265 | - 'show_in_admin_status_list' => true, |
|
266 | - /* translators: %s: number of invoices */ |
|
267 | - 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | - ), |
|
260 | + 'wpi-processing' => array( |
|
261 | + 'label' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
262 | + 'public' => true, |
|
263 | + 'exclude_from_search' => true, |
|
264 | + 'show_in_admin_all_list' => true, |
|
265 | + 'show_in_admin_status_list' => true, |
|
266 | + /* translators: %s: number of invoices */ |
|
267 | + 'label_count' => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' ) |
|
268 | + ), |
|
269 | 269 | |
270 | - 'wpi-onhold' => array( |
|
271 | - 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | - 'public' => true, |
|
273 | - 'exclude_from_search' => true, |
|
274 | - 'show_in_admin_all_list' => true, |
|
275 | - 'show_in_admin_status_list' => true, |
|
276 | - /* translators: %s: number of invoices */ |
|
277 | - 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | - ), |
|
270 | + 'wpi-onhold' => array( |
|
271 | + 'label' => _x( 'On Hold', 'Invoice status', 'invoicing' ), |
|
272 | + 'public' => true, |
|
273 | + 'exclude_from_search' => true, |
|
274 | + 'show_in_admin_all_list' => true, |
|
275 | + 'show_in_admin_status_list' => true, |
|
276 | + /* translators: %s: number of invoices */ |
|
277 | + 'label_count' => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' ) |
|
278 | + ), |
|
279 | 279 | |
280 | - 'wpi-cancelled' => array( |
|
281 | - 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | - 'public' => true, |
|
283 | - 'exclude_from_search' => true, |
|
284 | - 'show_in_admin_all_list' => true, |
|
285 | - 'show_in_admin_status_list' => true, |
|
286 | - /* translators: %s: number of invoices */ |
|
287 | - 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | - ), |
|
280 | + 'wpi-cancelled' => array( |
|
281 | + 'label' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
282 | + 'public' => true, |
|
283 | + 'exclude_from_search' => true, |
|
284 | + 'show_in_admin_all_list' => true, |
|
285 | + 'show_in_admin_status_list' => true, |
|
286 | + /* translators: %s: number of invoices */ |
|
287 | + 'label_count' => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' ) |
|
288 | + ), |
|
289 | 289 | |
290 | - 'wpi-refunded' => array( |
|
291 | - 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | - 'public' => true, |
|
293 | - 'exclude_from_search' => true, |
|
294 | - 'show_in_admin_all_list' => true, |
|
295 | - 'show_in_admin_status_list' => true, |
|
296 | - /* translators: %s: number of invoices */ |
|
297 | - 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | - ), |
|
290 | + 'wpi-refunded' => array( |
|
291 | + 'label' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
292 | + 'public' => true, |
|
293 | + 'exclude_from_search' => true, |
|
294 | + 'show_in_admin_all_list' => true, |
|
295 | + 'show_in_admin_status_list' => true, |
|
296 | + /* translators: %s: number of invoices */ |
|
297 | + 'label_count' => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' ) |
|
298 | + ), |
|
299 | 299 | |
300 | - 'wpi-failed' => array( |
|
301 | - 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | - 'public' => true, |
|
303 | - 'exclude_from_search' => true, |
|
304 | - 'show_in_admin_all_list' => true, |
|
305 | - 'show_in_admin_status_list' => true, |
|
306 | - /* translators: %s: number of invoices */ |
|
307 | - 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | - ), |
|
300 | + 'wpi-failed' => array( |
|
301 | + 'label' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
302 | + 'public' => true, |
|
303 | + 'exclude_from_search' => true, |
|
304 | + 'show_in_admin_all_list' => true, |
|
305 | + 'show_in_admin_status_list' => true, |
|
306 | + /* translators: %s: number of invoices */ |
|
307 | + 'label_count' => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' ) |
|
308 | + ), |
|
309 | 309 | |
310 | - 'wpi-renewal' => array( |
|
311 | - 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | - 'public' => true, |
|
313 | - 'exclude_from_search' => true, |
|
314 | - 'show_in_admin_all_list' => true, |
|
315 | - 'show_in_admin_status_list' => true, |
|
316 | - /* translators: %s: number of invoices */ |
|
317 | - 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | - ) |
|
319 | - ) |
|
320 | - ); |
|
310 | + 'wpi-renewal' => array( |
|
311 | + 'label' => _x( 'Renewal', 'Invoice status', 'invoicing' ), |
|
312 | + 'public' => true, |
|
313 | + 'exclude_from_search' => true, |
|
314 | + 'show_in_admin_all_list' => true, |
|
315 | + 'show_in_admin_status_list' => true, |
|
316 | + /* translators: %s: number of invoices */ |
|
317 | + 'label_count' => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' ) |
|
318 | + ) |
|
319 | + ) |
|
320 | + ); |
|
321 | 321 | |
322 | - foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | - register_post_status( $invoice_statuse, $args ); |
|
324 | - } |
|
325 | - } |
|
322 | + foreach ( $invoice_statuses as $invoice_statuse => $args ) { |
|
323 | + register_post_status( $invoice_statuse, $args ); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - /** |
|
328 | - * Flush rewrite rules. |
|
329 | - */ |
|
330 | - public static function flush_rewrite_rules() { |
|
331 | - flush_rewrite_rules(); |
|
332 | - } |
|
327 | + /** |
|
328 | + * Flush rewrite rules. |
|
329 | + */ |
|
330 | + public static function flush_rewrite_rules() { |
|
331 | + flush_rewrite_rules(); |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Flush rules to prevent 404. |
|
336 | - * |
|
337 | - */ |
|
338 | - public static function maybe_flush_rewrite_rules() { |
|
339 | - if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | - update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | - self::flush_rewrite_rules(); |
|
342 | - } |
|
343 | - } |
|
334 | + /** |
|
335 | + * Flush rules to prevent 404. |
|
336 | + * |
|
337 | + */ |
|
338 | + public static function maybe_flush_rewrite_rules() { |
|
339 | + if ( ! get_option( 'getpaid_flushed_rewrite_rules' ) ) { |
|
340 | + update_option( 'getpaid_flushed_rewrite_rules', '1' ); |
|
341 | + self::flush_rewrite_rules(); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | |
345 | 345 | } |