@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function register_hook_listener() { |
| 59 | 59 | |
| 60 | - add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 60 | + add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 61 | 61 | add_action( 'admin_init', array( $this, 'settings_fields' ) ); |
| 62 | - add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 62 | + add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 63 | 63 | |
| 64 | 64 | } // End setup_settings() |
| 65 | 65 | |
@@ -293,14 +293,14 @@ discard block |
||
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | 295 | public function settings_screen () |
| 296 | - { |
|
| 296 | + { |
|
| 297 | 297 | |
| 298 | - ?> |
|
| 298 | + ?> |
|
| 299 | 299 | <div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>"> |
| 300 | 300 | <?php screen_icon('woothemes-sensei'); ?> |
| 301 | 301 | <h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) { |
| 302 | - echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 303 | - } ?></h2> |
|
| 302 | + echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 303 | + } ?></h2> |
|
| 304 | 304 | <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" |
| 305 | 305 | title="WooThemes"><img |
| 306 | 306 | src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes"/></a></p> |
@@ -308,26 +308,26 @@ discard block |
||
| 308 | 308 | <form action="options.php" method="post"> |
| 309 | 309 | |
| 310 | 310 | <?php |
| 311 | - $this->settings_tabs(); |
|
| 312 | - settings_fields($this->token); |
|
| 313 | - $page = 'woothemes-sensei-settings'; |
|
| 314 | - foreach ($this->sections as $section_id => $section) { |
|
| 311 | + $this->settings_tabs(); |
|
| 312 | + settings_fields($this->token); |
|
| 313 | + $page = 'woothemes-sensei-settings'; |
|
| 314 | + foreach ($this->sections as $section_id => $section) { |
|
| 315 | 315 | |
| 316 | - echo '<section id="' . $section_id . '">'; |
|
| 316 | + echo '<section id="' . $section_id . '">'; |
|
| 317 | 317 | |
| 318 | - if ($section['name']) |
|
| 319 | - echo "<h2>{$section['name']}</h2>\n"; |
|
| 318 | + if ($section['name']) |
|
| 319 | + echo "<h2>{$section['name']}</h2>\n"; |
|
| 320 | 320 | |
| 321 | - echo '<table class="form-table">'; |
|
| 322 | - do_settings_fields($page, $section_id ); |
|
| 323 | - echo '</table>'; |
|
| 321 | + echo '<table class="form-table">'; |
|
| 322 | + do_settings_fields($page, $section_id ); |
|
| 323 | + echo '</table>'; |
|
| 324 | 324 | |
| 325 | - echo '</section>'; |
|
| 325 | + echo '</section>'; |
|
| 326 | 326 | |
| 327 | - } |
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - submit_button(); |
|
| 330 | - ?> |
|
| 329 | + submit_button(); |
|
| 330 | + ?> |
|
| 331 | 331 | </form> |
| 332 | 332 | <?php do_action( 'settings_after_form' ); ?> |
| 333 | 333 | </div><!--/#woothemes-sensei--> |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function get_settings () { |
| 344 | 344 | |
| 345 | - $this->settings = get_option( $this->token, array() ); |
|
| 345 | + $this->settings = get_option( $this->token, array() ); |
|
| 346 | 346 | |
| 347 | 347 | foreach ( $this->fields as $k => $v ) { |
| 348 | 348 | if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) { |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * @return void |
| 376 | 376 | */ |
| 377 | 377 | public function settings_errors () { |
| 378 | - settings_errors( $this->token . '-errors' ); |
|
| 378 | + settings_errors( $this->token . '-errors' ); |
|
| 379 | 379 | } // End settings_errors() |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n"; |
| 442 | 442 | if ( $has_description ) { |
| 443 | 443 | echo wp_kses( $args['data']['description'], array( 'a' => array( |
| 444 | - 'href' => array(), |
|
| 445 | - 'title' => array() |
|
| 446 | - ) |
|
| 444 | + 'href' => array(), |
|
| 445 | + 'title' => array() |
|
| 446 | + ) |
|
| 447 | 447 | ) |
| 448 | 448 | ) . '</label>' . "\n"; |
| 449 | 449 | } |
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | */ |
| 833 | 833 | public function enqueue_scripts () { |
| 834 | 834 | |
| 835 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 835 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 836 | 836 | |
| 837 | 837 | wp_enqueue_script( 'farbtastic' ); |
| 838 | 838 | wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version ); |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
| 3 | 3 | |
| 4 | 4 | /** |
| 5 | 5 | * A settings API (wrapping the WordPress Settings API). |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | * @access public |
| 32 | 32 | * @since 1.0.0 |
| 33 | 33 | */ |
| 34 | - public function __construct () { |
|
| 34 | + public function __construct() { |
|
| 35 | 35 | |
| 36 | 36 | $this->token = 'woothemes-sensei-settings'; |
| 37 | 37 | $this->page_slug = 'woothemes-sensei-settings-api'; |
@@ -57,9 +57,9 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function register_hook_listener() { |
| 59 | 59 | |
| 60 | - add_action( 'admin_menu', array( $this, 'register_settings_screen' ), 60 ); |
|
| 61 | - add_action( 'admin_init', array( $this, 'settings_fields' ) ); |
|
| 62 | - add_action( 'init', array( $this, 'general_init' ), 5 ); |
|
| 60 | + add_action('admin_menu', array($this, 'register_settings_screen'), 60); |
|
| 61 | + add_action('admin_init', array($this, 'settings_fields')); |
|
| 62 | + add_action('init', array($this, 'general_init'), 5); |
|
| 63 | 63 | |
| 64 | 64 | } // End setup_settings() |
| 65 | 65 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | $this->init_sections(); |
| 74 | 74 | $this->init_fields(); |
| 75 | 75 | $this->get_settings(); |
| 76 | - if ( $this->has_tabs == true ) { |
|
| 76 | + if ($this->has_tabs == true) { |
|
| 77 | 77 | $this->create_tabs(); |
| 78 | 78 | } // End If Statement |
| 79 | 79 | } // End general_init() |
@@ -84,9 +84,9 @@ discard block |
||
| 84 | 84 | * @since 1.0.0 |
| 85 | 85 | * @return void |
| 86 | 86 | */ |
| 87 | - public function init_sections () { |
|
| 87 | + public function init_sections() { |
|
| 88 | 88 | // Override this function in your class and assign the array of sections to $this->sections. |
| 89 | - _e( 'Override init_sections() in your class.', 'woothemes-sensei' ); |
|
| 89 | + _e('Override init_sections() in your class.', 'woothemes-sensei'); |
|
| 90 | 90 | } // End init_sections() |
| 91 | 91 | |
| 92 | 92 | /** |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @since 1.0.0 |
| 96 | 96 | * @return void |
| 97 | 97 | */ |
| 98 | - public function init_fields () { |
|
| 98 | + public function init_fields() { |
|
| 99 | 99 | // Override this function in your class and assign the array of sections to $this->fields. |
| 100 | - _e( 'Override init_fields() in your class.', 'woothemes-sensei' ); |
|
| 100 | + _e('Override init_fields() in your class.', 'woothemes-sensei'); |
|
| 101 | 101 | } // End init_fields() |
| 102 | 102 | |
| 103 | 103 | /** |
@@ -106,34 +106,34 @@ discard block |
||
| 106 | 106 | * @since 1.1.0 |
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | - public function settings_tabs () { |
|
| 109 | + public function settings_tabs() { |
|
| 110 | 110 | |
| 111 | - if ( ! $this->has_tabs ) { return; } |
|
| 111 | + if ( ! $this->has_tabs) { return; } |
|
| 112 | 112 | |
| 113 | - if ( count( $this->tabs ) > 0 ) { |
|
| 113 | + if (count($this->tabs) > 0) { |
|
| 114 | 114 | $html = ''; |
| 115 | 115 | |
| 116 | - $html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">' . "\n"; |
|
| 116 | + $html .= '<ul id="settings-sections" class="subsubsub hide-if-no-js">'."\n"; |
|
| 117 | 117 | |
| 118 | 118 | $sections = array( |
| 119 | - 'all' => array( 'href' => '#all', 'name' => __( 'All', 'woothemes-sensei' ), 'class' => 'current all tab' ) |
|
| 119 | + 'all' => array('href' => '#all', 'name' => __('All', 'woothemes-sensei'), 'class' => 'current all tab') |
|
| 120 | 120 | ); |
| 121 | 121 | |
| 122 | - foreach ( $this->tabs as $k => $v ) { |
|
| 123 | - $sections[$k] = array( 'href' => '#' . esc_attr( $k ), 'name' => esc_attr( $v['name'] ), 'class' => 'tab' ); |
|
| 122 | + foreach ($this->tabs as $k => $v) { |
|
| 123 | + $sections[$k] = array('href' => '#'.esc_attr($k), 'name' => esc_attr($v['name']), 'class' => 'tab'); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | $count = 1; |
| 127 | - foreach ( $sections as $k => $v ) { |
|
| 127 | + foreach ($sections as $k => $v) { |
|
| 128 | 128 | $count++; |
| 129 | - $html .= '<li><a href="' . $v['href'] . '"'; |
|
| 130 | - if ( isset( $v['class'] ) && ( $v['class'] != '' ) ) { $html .= ' class="' . esc_attr( $v['class'] ) . '"'; } |
|
| 131 | - $html .= '>' . esc_attr( $v['name'] ) . '</a>'; |
|
| 132 | - if ( $count <= count( $sections ) ) { $html .= ' | '; } |
|
| 133 | - $html .= '</li>' . "\n"; |
|
| 129 | + $html .= '<li><a href="'.$v['href'].'"'; |
|
| 130 | + if (isset($v['class']) && ($v['class'] != '')) { $html .= ' class="'.esc_attr($v['class']).'"'; } |
|
| 131 | + $html .= '>'.esc_attr($v['name']).'</a>'; |
|
| 132 | + if ($count <= count($sections)) { $html .= ' | '; } |
|
| 133 | + $html .= '</li>'."\n"; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $html .= '</ul><div class="clear"></div>' . "\n"; |
|
| 136 | + $html .= '</ul><div class="clear"></div>'."\n"; |
|
| 137 | 137 | |
| 138 | 138 | echo $html; |
| 139 | 139 | } |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | * @since 1.1.0 |
| 146 | 146 | * @return void |
| 147 | 147 | */ |
| 148 | - private function create_tabs () { |
|
| 149 | - if ( count( $this->sections ) > 0 ) { |
|
| 148 | + private function create_tabs() { |
|
| 149 | + if (count($this->sections) > 0) { |
|
| 150 | 150 | $tabs = array(); |
| 151 | - foreach ( $this->sections as $k => $v ) { |
|
| 151 | + foreach ($this->sections as $k => $v) { |
|
| 152 | 152 | $tabs[$k] = $v; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -162,10 +162,10 @@ discard block |
||
| 162 | 162 | * @since 1.0.0 |
| 163 | 163 | * @return void |
| 164 | 164 | */ |
| 165 | - public function create_sections () { |
|
| 166 | - if ( count( $this->sections ) > 0 ) { |
|
| 167 | - foreach ( $this->sections as $k => $v ) { |
|
| 168 | - add_settings_section( $k, $v['name'], array( $this, 'section_description' ), $this->token ); |
|
| 165 | + public function create_sections() { |
|
| 166 | + if (count($this->sections) > 0) { |
|
| 167 | + foreach ($this->sections as $k => $v) { |
|
| 168 | + add_settings_section($k, $v['name'], array($this, 'section_description'), $this->token); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | } // End create_sections() |
@@ -176,18 +176,18 @@ discard block |
||
| 176 | 176 | * @since 1.0.0 |
| 177 | 177 | * @return void |
| 178 | 178 | */ |
| 179 | - public function create_fields () { |
|
| 180 | - if ( count( $this->sections ) > 0 ) { |
|
| 179 | + public function create_fields() { |
|
| 180 | + if (count($this->sections) > 0) { |
|
| 181 | 181 | // $this->parse_fields( $this->fields ); |
| 182 | 182 | |
| 183 | - foreach ( $this->fields as $k => $v ) { |
|
| 184 | - $method = $this->determine_method( $v, 'form' ); |
|
| 183 | + foreach ($this->fields as $k => $v) { |
|
| 184 | + $method = $this->determine_method($v, 'form'); |
|
| 185 | 185 | $name = $v['name']; |
| 186 | - if ( $v['type'] == 'info' ) { $name = ''; } |
|
| 187 | - add_settings_field( $k, $name, $method, $this->token, $v['section'], array( 'key' => $k, 'data' => $v ) ); |
|
| 186 | + if ($v['type'] == 'info') { $name = ''; } |
|
| 187 | + add_settings_field($k, $name, $method, $this->token, $v['section'], array('key' => $k, 'data' => $v)); |
|
| 188 | 188 | |
| 189 | 189 | // Let the API know that we have a colourpicker field. |
| 190 | - if ( $v['type'] == 'range' && $this->has_range == false ) { $this->has_range = true; } |
|
| 190 | + if ($v['type'] == 'range' && $this->has_range == false) { $this->has_range = true; } |
|
| 191 | 191 | } |
| 192 | 192 | } |
| 193 | 193 | } // End create_fields() |
@@ -199,43 +199,43 @@ discard block |
||
| 199 | 199 | * @param array $data |
| 200 | 200 | * @return callable, array or string |
| 201 | 201 | */ |
| 202 | - protected function determine_method ( $data, $type = 'form' ) { |
|
| 202 | + protected function determine_method($data, $type = 'form') { |
|
| 203 | 203 | $method = ''; |
| 204 | 204 | |
| 205 | - if ( ! in_array( $type, array( 'form', 'validate', 'check' ) ) ) { return; } |
|
| 205 | + if ( ! in_array($type, array('form', 'validate', 'check'))) { return; } |
|
| 206 | 206 | |
| 207 | 207 | // Check for custom functions. |
| 208 | - if ( isset( $data[$type] ) ) { |
|
| 209 | - if ( function_exists( $data[$type] ) ) { |
|
| 208 | + if (isset($data[$type])) { |
|
| 209 | + if (function_exists($data[$type])) { |
|
| 210 | 210 | $method = $data[$type]; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - if ( $method == '' && method_exists( $this, $data[$type] ) ) { |
|
| 214 | - if ( $type == 'form' ) { |
|
| 215 | - $method = array( $this, $data[$type] ); |
|
| 213 | + if ($method == '' && method_exists($this, $data[$type])) { |
|
| 214 | + if ($type == 'form') { |
|
| 215 | + $method = array($this, $data[$type]); |
|
| 216 | 216 | } else { |
| 217 | 217 | $method = $data[$type]; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - if ( $method == '' && method_exists ( $this, $type . '_field_' . $data['type'] ) ) { |
|
| 223 | - if ( $type == 'form' ) { |
|
| 224 | - $method = array( $this, $type . '_field_' . $data['type'] ); |
|
| 222 | + if ($method == '' && method_exists($this, $type.'_field_'.$data['type'])) { |
|
| 223 | + if ($type == 'form') { |
|
| 224 | + $method = array($this, $type.'_field_'.$data['type']); |
|
| 225 | 225 | } else { |
| 226 | - $method = $type . '_field_' . $data['type']; |
|
| 226 | + $method = $type.'_field_'.$data['type']; |
|
| 227 | 227 | } |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - if ( $method == '' && function_exists ( $this->token . '_' . $type . '_field_' . $data['type'] ) ) { |
|
| 231 | - $method = $this->token . '_' . $type . '_field_' . $data['type']; |
|
| 230 | + if ($method == '' && function_exists($this->token.'_'.$type.'_field_'.$data['type'])) { |
|
| 231 | + $method = $this->token.'_'.$type.'_field_'.$data['type']; |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - if ( $method == '' ) { |
|
| 235 | - if ( $type == 'form' ) { |
|
| 236 | - $method = array( $this, $type . '_field_text' ); |
|
| 234 | + if ($method == '') { |
|
| 235 | + if ($type == 'form') { |
|
| 236 | + $method = array($this, $type.'_field_text'); |
|
| 237 | 237 | } else { |
| 238 | - $method = $type . '_field_text'; |
|
| 238 | + $method = $type.'_field_text'; |
|
| 239 | 239 | } |
| 240 | 240 | } |
| 241 | 241 | |
@@ -249,10 +249,10 @@ discard block |
||
| 249 | 249 | * @param array $fields |
| 250 | 250 | * @return void |
| 251 | 251 | */ |
| 252 | - public function parse_fields ( $fields ) { |
|
| 253 | - foreach ( $fields as $k => $v ) { |
|
| 254 | - if ( isset( $v['section'] ) && ( $v['section'] != '' ) && ( isset( $this->sections[$v['section']] ) ) ) { |
|
| 255 | - if ( ! isset( $this->sections[$v['section']]['fields'] ) ) { |
|
| 252 | + public function parse_fields($fields) { |
|
| 253 | + foreach ($fields as $k => $v) { |
|
| 254 | + if (isset($v['section']) && ($v['section'] != '') && (isset($this->sections[$v['section']]))) { |
|
| 255 | + if ( ! isset($this->sections[$v['section']]['fields'])) { |
|
| 256 | 256 | $this->sections[$v['section']]['fields'] = array(); |
| 257 | 257 | } |
| 258 | 258 | |
@@ -269,19 +269,19 @@ discard block |
||
| 269 | 269 | * @since 1.0.0 |
| 270 | 270 | * @return void |
| 271 | 271 | */ |
| 272 | - public function register_settings_screen () { |
|
| 272 | + public function register_settings_screen() { |
|
| 273 | 273 | |
| 274 | - if ( current_user_can( 'manage_sensei' ) ) { |
|
| 275 | - $hook = add_submenu_page( 'sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array( $this, 'settings_screen' ) ); |
|
| 274 | + if (current_user_can('manage_sensei')) { |
|
| 275 | + $hook = add_submenu_page('sensei', $this->name, $this->menu_label, 'manage_sensei', $this->page_slug, array($this, 'settings_screen')); |
|
| 276 | 276 | |
| 277 | 277 | $this->hook = $hook; |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
| 280 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
| 281 | 281 | |
| 282 | - add_action( 'admin_notices', array( $this, 'settings_errors' ) ); |
|
| 283 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
| 284 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
| 282 | + add_action('admin_notices', array($this, 'settings_errors')); |
|
| 283 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
| 284 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
| 285 | 285 | |
| 286 | 286 | } |
| 287 | 287 | } // End register_settings_screen() |
@@ -292,14 +292,14 @@ discard block |
||
| 292 | 292 | * @since 1.0.0 |
| 293 | 293 | * @return void |
| 294 | 294 | */ |
| 295 | - public function settings_screen () |
|
| 295 | + public function settings_screen() |
|
| 296 | 296 | { |
| 297 | 297 | |
| 298 | 298 | ?> |
| 299 | 299 | <div id="woothemes-sensei" class="wrap <?php echo esc_attr($this->token); ?>"> |
| 300 | 300 | <?php screen_icon('woothemes-sensei'); ?> |
| 301 | 301 | <h2><?php echo esc_html($this->name); ?><?php if ('' != $this->settings_version) { |
| 302 | - echo ' <span class="version">' . $this->settings_version . '</span>'; |
|
| 302 | + echo ' <span class="version">'.$this->settings_version.'</span>'; |
|
| 303 | 303 | } ?></h2> |
| 304 | 304 | <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" |
| 305 | 305 | title="WooThemes"><img |
@@ -313,13 +313,13 @@ discard block |
||
| 313 | 313 | $page = 'woothemes-sensei-settings'; |
| 314 | 314 | foreach ($this->sections as $section_id => $section) { |
| 315 | 315 | |
| 316 | - echo '<section id="' . $section_id . '">'; |
|
| 316 | + echo '<section id="'.$section_id.'">'; |
|
| 317 | 317 | |
| 318 | 318 | if ($section['name']) |
| 319 | 319 | echo "<h2>{$section['name']}</h2>\n"; |
| 320 | 320 | |
| 321 | 321 | echo '<table class="form-table">'; |
| 322 | - do_settings_fields($page, $section_id ); |
|
| 322 | + do_settings_fields($page, $section_id); |
|
| 323 | 323 | echo '</table>'; |
| 324 | 324 | |
| 325 | 325 | echo '</section>'; |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | submit_button(); |
| 330 | 330 | ?> |
| 331 | 331 | </form> |
| 332 | - <?php do_action( 'settings_after_form' ); ?> |
|
| 332 | + <?php do_action('settings_after_form'); ?> |
|
| 333 | 333 | </div><!--/#woothemes-sensei--> |
| 334 | 334 | <?php |
| 335 | 335 | } // End settings_screen() |
@@ -340,15 +340,15 @@ discard block |
||
| 340 | 340 | * @since 1.0.0 |
| 341 | 341 | * @return array |
| 342 | 342 | */ |
| 343 | - public function get_settings () { |
|
| 343 | + public function get_settings() { |
|
| 344 | 344 | |
| 345 | - $this->settings = get_option( $this->token, array() ); |
|
| 345 | + $this->settings = get_option($this->token, array()); |
|
| 346 | 346 | |
| 347 | - foreach ( $this->fields as $k => $v ) { |
|
| 348 | - if ( ! isset( $this->settings[$k] ) && isset( $v['default'] ) ) { |
|
| 347 | + foreach ($this->fields as $k => $v) { |
|
| 348 | + if ( ! isset($this->settings[$k]) && isset($v['default'])) { |
|
| 349 | 349 | $this->settings[$k] = $v['default']; |
| 350 | 350 | } |
| 351 | - if ( $v['type'] == 'checkbox' && $this->settings[$k] != true ) { |
|
| 351 | + if ($v['type'] == 'checkbox' && $this->settings[$k] != true) { |
|
| 352 | 352 | $this->settings[$k] = 0; |
| 353 | 353 | } |
| 354 | 354 | } |
@@ -362,8 +362,8 @@ discard block |
||
| 362 | 362 | * @since 1.0.0 |
| 363 | 363 | * @return void |
| 364 | 364 | */ |
| 365 | - public function settings_fields () { |
|
| 366 | - register_setting( $this->token, $this->token, array( $this, 'validate_fields' ) ); |
|
| 365 | + public function settings_fields() { |
|
| 366 | + register_setting($this->token, $this->token, array($this, 'validate_fields')); |
|
| 367 | 367 | $this->create_sections(); |
| 368 | 368 | $this->create_fields(); |
| 369 | 369 | } // End settings_fields() |
@@ -374,8 +374,8 @@ discard block |
||
| 374 | 374 | * @since 1.0.0 |
| 375 | 375 | * @return void |
| 376 | 376 | */ |
| 377 | - public function settings_errors () { |
|
| 378 | - settings_errors( $this->token . '-errors' ); |
|
| 377 | + public function settings_errors() { |
|
| 378 | + settings_errors($this->token.'-errors'); |
|
| 379 | 379 | } // End settings_errors() |
| 380 | 380 | |
| 381 | 381 | /** |
@@ -384,9 +384,9 @@ discard block |
||
| 384 | 384 | * @since 1.0.0 |
| 385 | 385 | * @return void |
| 386 | 386 | */ |
| 387 | - public function section_description ( $section ) { |
|
| 388 | - if ( isset( $this->sections[$section['id']]['description'] ) ) { |
|
| 389 | - echo wpautop( $this->sections[$section['id']]['description'] ); |
|
| 387 | + public function section_description($section) { |
|
| 388 | + if (isset($this->sections[$section['id']]['description'])) { |
|
| 389 | + echo wpautop($this->sections[$section['id']]['description']); |
|
| 390 | 390 | } |
| 391 | 391 | } // End section_description_main() |
| 392 | 392 | |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | * @param array $args |
| 398 | 398 | * @return void |
| 399 | 399 | */ |
| 400 | - public function form_field_text ( $args ) { |
|
| 400 | + public function form_field_text($args) { |
|
| 401 | 401 | $options = $this->get_settings(); |
| 402 | 402 | |
| 403 | - echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n"; |
|
| 404 | - if ( isset( $args['data']['description'] ) ) { |
|
| 405 | - echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n"; |
|
| 403 | + echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" value="'.esc_attr($options[$args['key']]).'" />'."\n"; |
|
| 404 | + if (isset($args['data']['description'])) { |
|
| 405 | + echo '<span class="description">'.$args['data']['description'].'</span>'."\n"; |
|
| 406 | 406 | } |
| 407 | 407 | } // End form_field_text() |
| 408 | 408 | |
@@ -413,13 +413,13 @@ discard block |
||
| 413 | 413 | * @param array $args |
| 414 | 414 | * @return void |
| 415 | 415 | */ |
| 416 | - public function form_field_color ( $args ) { |
|
| 416 | + public function form_field_color($args) { |
|
| 417 | 417 | $options = $this->get_settings(); |
| 418 | 418 | |
| 419 | - echo '<input id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" size="40" type="text" class="color" value="' . esc_attr( $options[$args['key']] ) . '" />' . "\n"; |
|
| 419 | + echo '<input id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" size="40" type="text" class="color" value="'.esc_attr($options[$args['key']]).'" />'."\n"; |
|
| 420 | 420 | echo '<div style="position:absolute;background:#FFF;z-index:99;border-radius:100%;" class="colorpicker"></div>'; |
| 421 | - if ( isset( $args['data']['description'] ) ) { |
|
| 422 | - echo '<span class="description">' . $args['data']['description'] . '</span>' . "\n"; |
|
| 421 | + if (isset($args['data']['description'])) { |
|
| 422 | + echo '<span class="description">'.$args['data']['description'].'</span>'."\n"; |
|
| 423 | 423 | } |
| 424 | 424 | } // End form_field_text() |
| 425 | 425 | |
@@ -430,22 +430,22 @@ discard block |
||
| 430 | 430 | * @param array $args |
| 431 | 431 | * @return void |
| 432 | 432 | */ |
| 433 | - public function form_field_checkbox ( $args ) { |
|
| 433 | + public function form_field_checkbox($args) { |
|
| 434 | 434 | $options = $this->get_settings(); |
| 435 | 435 | |
| 436 | 436 | $has_description = false; |
| 437 | - if ( isset( $args['data']['description'] ) ) { |
|
| 437 | + if (isset($args['data']['description'])) { |
|
| 438 | 438 | $has_description = true; |
| 439 | - echo '<label for="' . esc_attr( $args['key'] ) . '">' . "\n"; |
|
| 439 | + echo '<label for="'.esc_attr($args['key']).'">'."\n"; |
|
| 440 | 440 | } |
| 441 | - echo '<input id="' . $args['key'] . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" type="checkbox" value="1"' . checked( esc_attr( $options[$args['key']] ), '1', false ) . ' />' . "\n"; |
|
| 442 | - if ( $has_description ) { |
|
| 443 | - echo wp_kses( $args['data']['description'], array( 'a' => array( |
|
| 441 | + echo '<input id="'.$args['key'].'" name="'.$this->token.'['.esc_attr($args['key']).']" type="checkbox" value="1"'.checked(esc_attr($options[$args['key']]), '1', false).' />'."\n"; |
|
| 442 | + if ($has_description) { |
|
| 443 | + echo wp_kses($args['data']['description'], array('a' => array( |
|
| 444 | 444 | 'href' => array(), |
| 445 | 445 | 'title' => array() |
| 446 | 446 | ) |
| 447 | 447 | ) |
| 448 | - ) . '</label>' . "\n"; |
|
| 448 | + ).'</label>'."\n"; |
|
| 449 | 449 | } |
| 450 | 450 | } // End form_field_checkbox() |
| 451 | 451 | |
@@ -456,12 +456,12 @@ discard block |
||
| 456 | 456 | * @param array $args |
| 457 | 457 | * @return void |
| 458 | 458 | */ |
| 459 | - public function form_field_textarea ( $args ) { |
|
| 459 | + public function form_field_textarea($args) { |
|
| 460 | 460 | $options = $this->get_settings(); |
| 461 | 461 | |
| 462 | - echo '<textarea id="' . esc_attr( $args['key'] ) . '" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" cols="42" rows="5">' . esc_html( $options[$args['key']] ) . '</textarea>' . "\n"; |
|
| 463 | - if ( isset( $args['data']['description'] ) ) { |
|
| 464 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 462 | + echo '<textarea id="'.esc_attr($args['key']).'" name="'.$this->token.'['.esc_attr($args['key']).']" cols="42" rows="5">'.esc_html($options[$args['key']]).'</textarea>'."\n"; |
|
| 463 | + if (isset($args['data']['description'])) { |
|
| 464 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 465 | 465 | } |
| 466 | 466 | } // End form_field_textarea() |
| 467 | 467 | |
@@ -472,20 +472,20 @@ discard block |
||
| 472 | 472 | * @param array $args |
| 473 | 473 | * @return void |
| 474 | 474 | */ |
| 475 | - public function form_field_select ( $args ) { |
|
| 475 | + public function form_field_select($args) { |
|
| 476 | 476 | $options = $this->get_settings(); |
| 477 | 477 | |
| 478 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 478 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 479 | 479 | $html = ''; |
| 480 | - $html .= '<select class="" id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']">' . "\n"; |
|
| 481 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 482 | - $html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n"; |
|
| 480 | + $html .= '<select class="" id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']">'."\n"; |
|
| 481 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 482 | + $html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n"; |
|
| 483 | 483 | } |
| 484 | - $html .= '</select>' . "\n"; |
|
| 484 | + $html .= '</select>'."\n"; |
|
| 485 | 485 | echo $html; |
| 486 | 486 | |
| 487 | - if ( isset( $args['data']['description'] ) ) { |
|
| 488 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 487 | + if (isset($args['data']['description'])) { |
|
| 488 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | } // End form_field_select() |
@@ -497,18 +497,18 @@ discard block |
||
| 497 | 497 | * @param array $args |
| 498 | 498 | * @return void |
| 499 | 499 | */ |
| 500 | - public function form_field_radio ( $args ) { |
|
| 500 | + public function form_field_radio($args) { |
|
| 501 | 501 | $options = $this->get_settings(); |
| 502 | 502 | |
| 503 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 503 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 504 | 504 | $html = ''; |
| 505 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 506 | - $html .= '<input type="radio" name="' . $this->token . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n"; |
|
| 505 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 506 | + $html .= '<input type="radio" name="'.$this->token.'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n"; |
|
| 507 | 507 | } |
| 508 | 508 | echo $html; |
| 509 | 509 | |
| 510 | - if ( isset( $args['data']['description'] ) ) { |
|
| 511 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 510 | + if (isset($args['data']['description'])) { |
|
| 511 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 512 | 512 | } |
| 513 | 513 | } |
| 514 | 514 | } // End form_field_radio() |
@@ -520,28 +520,28 @@ discard block |
||
| 520 | 520 | * @param array $args |
| 521 | 521 | * @return void |
| 522 | 522 | */ |
| 523 | - public function form_field_multicheck ( $args ) { |
|
| 523 | + public function form_field_multicheck($args) { |
|
| 524 | 524 | $options = $this->get_settings(); |
| 525 | 525 | |
| 526 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 527 | - $html = '<div class="multicheck-container" style="margin-bottom:10px;">' . "\n"; |
|
| 528 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 526 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 527 | + $html = '<div class="multicheck-container" style="margin-bottom:10px;">'."\n"; |
|
| 528 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 529 | 529 | $checked = ''; |
| 530 | 530 | |
| 531 | - if( isset( $options[ $args['key'] ] ) ) { |
|
| 532 | - if ( in_array( $k, (array)$options[ $args['key'] ] ) ) { $checked = ' checked="checked"'; } |
|
| 531 | + if (isset($options[$args['key']])) { |
|
| 532 | + if (in_array($k, (array) $options[$args['key']])) { $checked = ' checked="checked"'; } |
|
| 533 | 533 | } else { |
| 534 | - if ( in_array( $k, $args['data']['defaults'] ) ) { $checked = ' checked="checked"'; } |
|
| 534 | + if (in_array($k, $args['data']['defaults'])) { $checked = ' checked="checked"'; } |
|
| 535 | 535 | } |
| 536 | - $html .= '<label for="checkbox-' . esc_attr( $k ) . '">' . "\n"; |
|
| 537 | - $html .= '<input type="checkbox" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . '][]" class="multicheck multicheck-' . esc_attr( $args['key'] ) . '" value="' . esc_attr( $k ) . '" id="checkbox-' . esc_attr( $k ) . '" ' . $checked . ' /> ' . $v . "\n"; |
|
| 538 | - $html .= '</label><br />' . "\n"; |
|
| 536 | + $html .= '<label for="checkbox-'.esc_attr($k).'">'."\n"; |
|
| 537 | + $html .= '<input type="checkbox" name="'.esc_attr($this->token).'['.esc_attr($args['key']).'][]" class="multicheck multicheck-'.esc_attr($args['key']).'" value="'.esc_attr($k).'" id="checkbox-'.esc_attr($k).'" '.$checked.' /> '.$v."\n"; |
|
| 538 | + $html .= '</label><br />'."\n"; |
|
| 539 | 539 | } |
| 540 | - $html .= '</div>' . "\n"; |
|
| 540 | + $html .= '</div>'."\n"; |
|
| 541 | 541 | echo $html; |
| 542 | 542 | |
| 543 | - if ( isset( $args['data']['description'] ) ) { |
|
| 544 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 543 | + if (isset($args['data']['description'])) { |
|
| 544 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 545 | 545 | } |
| 546 | 546 | } |
| 547 | 547 | } // End form_field_multicheck() |
@@ -553,20 +553,20 @@ discard block |
||
| 553 | 553 | * @param array $args |
| 554 | 554 | * @return void |
| 555 | 555 | */ |
| 556 | - public function form_field_range ( $args ) { |
|
| 556 | + public function form_field_range($args) { |
|
| 557 | 557 | $options = $this->get_settings(); |
| 558 | 558 | |
| 559 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 559 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 560 | 560 | $html = ''; |
| 561 | - $html .= '<select id="' . esc_attr( $args['key'] ) . '" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" class="range-input">' . "\n"; |
|
| 562 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 563 | - $html .= '<option value="' . esc_attr( $k ) . '"' . selected( esc_attr( $options[$args['key']] ), $k, false ) . '>' . $v . '</option>' . "\n"; |
|
| 561 | + $html .= '<select id="'.esc_attr($args['key']).'" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" class="range-input">'."\n"; |
|
| 562 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 563 | + $html .= '<option value="'.esc_attr($k).'"'.selected(esc_attr($options[$args['key']]), $k, false).'>'.$v.'</option>'."\n"; |
|
| 564 | 564 | } |
| 565 | - $html .= '</select>' . "\n"; |
|
| 565 | + $html .= '</select>'."\n"; |
|
| 566 | 566 | echo $html; |
| 567 | 567 | |
| 568 | - if ( isset( $args['data']['description'] ) ) { |
|
| 569 | - echo '<p><span class="description">' . esc_html( $args['data']['description'] ) . '</span></p>' . "\n"; |
|
| 568 | + if (isset($args['data']['description'])) { |
|
| 569 | + echo '<p><span class="description">'.esc_html($args['data']['description']).'</span></p>'."\n"; |
|
| 570 | 570 | } |
| 571 | 571 | } |
| 572 | 572 | } // End form_field_range() |
@@ -578,18 +578,18 @@ discard block |
||
| 578 | 578 | * @param array $args |
| 579 | 579 | * @return void |
| 580 | 580 | */ |
| 581 | - public function form_field_images ( $args ) { |
|
| 581 | + public function form_field_images($args) { |
|
| 582 | 582 | $options = $this->get_settings(); |
| 583 | 583 | |
| 584 | - if ( isset( $args['data']['options'] ) && ( count( (array)$args['data']['options'] ) > 0 ) ) { |
|
| 584 | + if (isset($args['data']['options']) && (count((array) $args['data']['options']) > 0)) { |
|
| 585 | 585 | $html = ''; |
| 586 | - foreach ( $args['data']['options'] as $k => $v ) { |
|
| 587 | - $html .= '<input type="radio" name="' . esc_attr( $this->token ) . '[' . esc_attr( $args['key'] ) . ']" value="' . esc_attr( $k ) . '"' . checked( esc_attr( $options[$args['key']] ), $k, false ) . ' /> ' . $v . '<br />' . "\n"; |
|
| 586 | + foreach ($args['data']['options'] as $k => $v) { |
|
| 587 | + $html .= '<input type="radio" name="'.esc_attr($this->token).'['.esc_attr($args['key']).']" value="'.esc_attr($k).'"'.checked(esc_attr($options[$args['key']]), $k, false).' /> '.$v.'<br />'."\n"; |
|
| 588 | 588 | } |
| 589 | 589 | echo $html; |
| 590 | 590 | |
| 591 | - if ( isset( $args['data']['description'] ) ) { |
|
| 592 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 591 | + if (isset($args['data']['description'])) { |
|
| 592 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 593 | 593 | } |
| 594 | 594 | } |
| 595 | 595 | } // End form_field_images() |
@@ -601,19 +601,19 @@ discard block |
||
| 601 | 601 | * @param array $args |
| 602 | 602 | * @return void |
| 603 | 603 | */ |
| 604 | - public function form_field_info ( $args ) { |
|
| 604 | + public function form_field_info($args) { |
|
| 605 | 605 | $class = ''; |
| 606 | - if ( isset( $args['data']['class'] ) ) { |
|
| 607 | - $class = ' ' . esc_attr( $args['data']['class'] ); |
|
| 606 | + if (isset($args['data']['class'])) { |
|
| 607 | + $class = ' '.esc_attr($args['data']['class']); |
|
| 608 | 608 | } |
| 609 | - $html = '<div id="' . $args['key'] . '" class="info-box' . $class . '">' . "\n"; |
|
| 610 | - if ( isset( $args['data']['name'] ) && ( $args['data']['name'] != '' ) ) { |
|
| 611 | - $html .= '<h3 class="title">' . esc_html( $args['data']['name'] ) . '</h3>' . "\n"; |
|
| 609 | + $html = '<div id="'.$args['key'].'" class="info-box'.$class.'">'."\n"; |
|
| 610 | + if (isset($args['data']['name']) && ($args['data']['name'] != '')) { |
|
| 611 | + $html .= '<h3 class="title">'.esc_html($args['data']['name']).'</h3>'."\n"; |
|
| 612 | 612 | } |
| 613 | - if ( isset( $args['data']['description'] ) && ( $args['data']['description'] != '' ) ) { |
|
| 614 | - $html .= '<p>' . esc_html( $args['data']['description'] ) . '</p>' . "\n"; |
|
| 613 | + if (isset($args['data']['description']) && ($args['data']['description'] != '')) { |
|
| 614 | + $html .= '<p>'.esc_html($args['data']['description']).'</p>'."\n"; |
|
| 615 | 615 | } |
| 616 | - $html .= '</div>' . "\n"; |
|
| 616 | + $html .= '</div>'."\n"; |
|
| 617 | 617 | |
| 618 | 618 | echo $html; |
| 619 | 619 | } // End form_field_info() |
@@ -625,14 +625,14 @@ discard block |
||
| 625 | 625 | * @since 1.9.0 |
| 626 | 626 | * @param array $args |
| 627 | 627 | */ |
| 628 | - public function form_field_button( $args ) { |
|
| 628 | + public function form_field_button($args) { |
|
| 629 | 629 | $options = $this->get_settings(); |
| 630 | 630 | |
| 631 | - if ( isset( $args['data']['target'] ) && isset( $args['data']['label'] ) ) { |
|
| 632 | - printf( '<a href="%s" class="button button-secondary">%s</a> ', esc_url( $args['data']['target'] ), esc_html( $args['data']['label'] ) ); |
|
| 631 | + if (isset($args['data']['target']) && isset($args['data']['label'])) { |
|
| 632 | + printf('<a href="%s" class="button button-secondary">%s</a> ', esc_url($args['data']['target']), esc_html($args['data']['label'])); |
|
| 633 | 633 | |
| 634 | - if ( isset( $args['data']['description'] ) ) { |
|
| 635 | - echo '<span class="description">' . esc_html( $args['data']['description'] ) . '</span>' . "\n"; |
|
| 634 | + if (isset($args['data']['description'])) { |
|
| 635 | + echo '<span class="description">'.esc_html($args['data']['description']).'</span>'."\n"; |
|
| 636 | 636 | } |
| 637 | 637 | } |
| 638 | 638 | } // End form_field_button() |
@@ -646,23 +646,23 @@ discard block |
||
| 646 | 646 | * @uses $this->parse_errors() |
| 647 | 647 | * @return array $options |
| 648 | 648 | */ |
| 649 | - public function validate_fields ( $input ) { |
|
| 649 | + public function validate_fields($input) { |
|
| 650 | 650 | $options = $this->get_settings(); |
| 651 | 651 | |
| 652 | - foreach ( $this->fields as $k => $v ) { |
|
| 652 | + foreach ($this->fields as $k => $v) { |
|
| 653 | 653 | // Make sure checkboxes are present even when false. |
| 654 | - if ( $v['type'] == 'checkbox' && ! isset( $input[$k] ) ) { $input[$k] = false; } |
|
| 655 | - if ( $v['type'] == 'multicheck' && ! isset( $input[$k] ) ) { $input[$k] = false; } |
|
| 654 | + if ($v['type'] == 'checkbox' && ! isset($input[$k])) { $input[$k] = false; } |
|
| 655 | + if ($v['type'] == 'multicheck' && ! isset($input[$k])) { $input[$k] = false; } |
|
| 656 | 656 | |
| 657 | - if ( isset( $input[$k] ) ) { |
|
| 657 | + if (isset($input[$k])) { |
|
| 658 | 658 | // Perform checks on required fields. |
| 659 | - if ( isset( $v['required'] ) && ( $v['required'] == true ) ) { |
|
| 660 | - if ( in_array( $v['type'], $this->get_array_field_types() ) && ( count( (array) $input[$k] ) <= 0 ) ) { |
|
| 661 | - $this->add_error( $k, $v ); |
|
| 659 | + if (isset($v['required']) && ($v['required'] == true)) { |
|
| 660 | + if (in_array($v['type'], $this->get_array_field_types()) && (count((array) $input[$k]) <= 0)) { |
|
| 661 | + $this->add_error($k, $v); |
|
| 662 | 662 | continue; |
| 663 | 663 | } else { |
| 664 | - if ( $input[$k] == '' ) { |
|
| 665 | - $this->add_error( $k, $v ); |
|
| 664 | + if ($input[$k] == '') { |
|
| 665 | + $this->add_error($k, $v); |
|
| 666 | 666 | continue; |
| 667 | 667 | } |
| 668 | 668 | } |
@@ -671,28 +671,28 @@ discard block |
||
| 671 | 671 | $value = $input[$k]; |
| 672 | 672 | |
| 673 | 673 | // Check if the field is valid. |
| 674 | - $method = $this->determine_method( $v, 'check' ); |
|
| 674 | + $method = $this->determine_method($v, 'check'); |
|
| 675 | 675 | |
| 676 | - if ( function_exists ( $method ) ) { |
|
| 677 | - $is_valid = $method( $value ); |
|
| 676 | + if (function_exists($method)) { |
|
| 677 | + $is_valid = $method($value); |
|
| 678 | 678 | } else { |
| 679 | - if ( method_exists( $this, $method ) ) { |
|
| 680 | - $is_valid = $this->$method( $value ); |
|
| 679 | + if (method_exists($this, $method)) { |
|
| 680 | + $is_valid = $this->$method($value); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if ( ! $is_valid ) { |
|
| 685 | - $this->add_error( $k, $v ); |
|
| 684 | + if ( ! $is_valid) { |
|
| 685 | + $this->add_error($k, $v); |
|
| 686 | 686 | continue; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - $method = $this->determine_method( $v, 'validate' ); |
|
| 689 | + $method = $this->determine_method($v, 'validate'); |
|
| 690 | 690 | |
| 691 | - if ( function_exists ( $method ) ) { |
|
| 692 | - $options[$k] = $method( $value ); |
|
| 691 | + if (function_exists($method)) { |
|
| 692 | + $options[$k] = $method($value); |
|
| 693 | 693 | } else { |
| 694 | - if ( method_exists( $this, $method ) ) { |
|
| 695 | - $options[$k] = $this->$method( $value ); |
|
| 694 | + if (method_exists($this, $method)) { |
|
| 695 | + $options[$k] = $this->$method($value); |
|
| 696 | 696 | } |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -710,8 +710,8 @@ discard block |
||
| 710 | 710 | * @param string $input |
| 711 | 711 | * @return string |
| 712 | 712 | */ |
| 713 | - public function validate_field_text ( $input ) { |
|
| 714 | - return trim( esc_attr( $input ) ); |
|
| 713 | + public function validate_field_text($input) { |
|
| 714 | + return trim(esc_attr($input)); |
|
| 715 | 715 | } // End validate_field_text() |
| 716 | 716 | |
| 717 | 717 | /** |
@@ -721,11 +721,11 @@ discard block |
||
| 721 | 721 | * @param string $input |
| 722 | 722 | * @return string |
| 723 | 723 | */ |
| 724 | - public function validate_field_checkbox ( $input ) { |
|
| 725 | - if ( ! isset( $input ) ) { |
|
| 724 | + public function validate_field_checkbox($input) { |
|
| 725 | + if ( ! isset($input)) { |
|
| 726 | 726 | return 0; |
| 727 | 727 | } else { |
| 728 | - return (bool)$input; |
|
| 728 | + return (bool) $input; |
|
| 729 | 729 | } |
| 730 | 730 | } // End validate_field_checkbox() |
| 731 | 731 | |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | * @param string $input |
| 737 | 737 | * @return string |
| 738 | 738 | */ |
| 739 | - public function validate_field_multicheck ( $input ) { |
|
| 739 | + public function validate_field_multicheck($input) { |
|
| 740 | 740 | $input = (array) $input; |
| 741 | 741 | |
| 742 | - $input = array_map( 'esc_attr', $input ); |
|
| 742 | + $input = array_map('esc_attr', $input); |
|
| 743 | 743 | |
| 744 | 744 | return $input; |
| 745 | 745 | } // End validate_field_multicheck() |
@@ -751,8 +751,8 @@ discard block |
||
| 751 | 751 | * @param string $input |
| 752 | 752 | * @return string |
| 753 | 753 | */ |
| 754 | - public function validate_field_range ( $input ) { |
|
| 755 | - $input = number_format( floatval( $input ), 0 ); |
|
| 754 | + public function validate_field_range($input) { |
|
| 755 | + $input = number_format(floatval($input), 0); |
|
| 756 | 756 | |
| 757 | 757 | return $input; |
| 758 | 758 | } // End validate_field_range() |
@@ -764,8 +764,8 @@ discard block |
||
| 764 | 764 | * @param string $input |
| 765 | 765 | * @return string |
| 766 | 766 | */ |
| 767 | - public function validate_field_url ( $input ) { |
|
| 768 | - return trim( esc_url( $input ) ); |
|
| 767 | + public function validate_field_url($input) { |
|
| 768 | + return trim(esc_url($input)); |
|
| 769 | 769 | } // End validate_field_url() |
| 770 | 770 | |
| 771 | 771 | /** |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @since 1.1.0 |
| 775 | 775 | * @return boolean Is the value valid? |
| 776 | 776 | */ |
| 777 | - public function check_field_text ( $input ) { |
|
| 777 | + public function check_field_text($input) { |
|
| 778 | 778 | $is_valid = true; |
| 779 | 779 | |
| 780 | 780 | return $is_valid; |
@@ -788,11 +788,11 @@ discard block |
||
| 788 | 788 | * @param array $data |
| 789 | 789 | * @return void |
| 790 | 790 | */ |
| 791 | - protected function add_error ( $key, $data ) { |
|
| 792 | - if ( isset( $data['error_message'] ) ) { |
|
| 791 | + protected function add_error($key, $data) { |
|
| 792 | + if (isset($data['error_message'])) { |
|
| 793 | 793 | $message = $data['error_message']; |
| 794 | 794 | } else { |
| 795 | - $message = sprintf( __( '%s is a required field', 'woothemes-sensei' ), $data['name'] ); |
|
| 795 | + $message = sprintf(__('%s is a required field', 'woothemes-sensei'), $data['name']); |
|
| 796 | 796 | } |
| 797 | 797 | $this->errors[$key] = $message; |
| 798 | 798 | } // End add_error() |
@@ -803,14 +803,14 @@ discard block |
||
| 803 | 803 | * @since 1.0.0 |
| 804 | 804 | * @return void |
| 805 | 805 | */ |
| 806 | - protected function parse_errors () { |
|
| 807 | - if ( count ( $this->errors ) > 0 ) { |
|
| 808 | - foreach ( $this->errors as $k => $v ) { |
|
| 809 | - add_settings_error( $this->token . '-errors', $k, $v, 'error' ); |
|
| 806 | + protected function parse_errors() { |
|
| 807 | + if (count($this->errors) > 0) { |
|
| 808 | + foreach ($this->errors as $k => $v) { |
|
| 809 | + add_settings_error($this->token.'-errors', $k, $v, 'error'); |
|
| 810 | 810 | } |
| 811 | 811 | } else { |
| 812 | - $message = sprintf( __( '%s updated', 'woothemes-sensei' ), $this->name ); |
|
| 813 | - add_settings_error( $this->token . '-errors', $this->token, $message, 'updated' ); |
|
| 812 | + $message = sprintf(__('%s updated', 'woothemes-sensei'), $this->name); |
|
| 813 | + add_settings_error($this->token.'-errors', $this->token, $message, 'updated'); |
|
| 814 | 814 | } |
| 815 | 815 | } // End parse_errors() |
| 816 | 816 | |
@@ -820,8 +820,8 @@ discard block |
||
| 820 | 820 | * @since 1.0.0 |
| 821 | 821 | * @return array |
| 822 | 822 | */ |
| 823 | - protected function get_array_field_types () { |
|
| 824 | - return array( 'multicheck' ); |
|
| 823 | + protected function get_array_field_types() { |
|
| 824 | + return array('multicheck'); |
|
| 825 | 825 | } // End get_array_field_types() |
| 826 | 826 | |
| 827 | 827 | /** |
@@ -830,21 +830,21 @@ discard block |
||
| 830 | 830 | * @since 1.0.0 |
| 831 | 831 | * @return void |
| 832 | 832 | */ |
| 833 | - public function enqueue_scripts () { |
|
| 833 | + public function enqueue_scripts() { |
|
| 834 | 834 | |
| 835 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
| 835 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
| 836 | 836 | |
| 837 | - wp_enqueue_script( 'farbtastic' ); |
|
| 838 | - wp_enqueue_script( 'woothemes-sensei-settings', esc_url( Sensei()->plugin_url . 'assets/js/settings' . $suffix . '.js' ), array( 'jquery', 'farbtastic' ), Sensei()->version ); |
|
| 837 | + wp_enqueue_script('farbtastic'); |
|
| 838 | + wp_enqueue_script('woothemes-sensei-settings', esc_url(Sensei()->plugin_url.'assets/js/settings'.$suffix.'.js'), array('jquery', 'farbtastic'), Sensei()->version); |
|
| 839 | 839 | |
| 840 | - if ( $this->has_range ) { |
|
| 841 | - wp_enqueue_script( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/js/ranges' . $suffix . '.js' ), array( 'jquery-ui-slider' ), Sensei()->version ); |
|
| 840 | + if ($this->has_range) { |
|
| 841 | + wp_enqueue_script('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/js/ranges'.$suffix.'.js'), array('jquery-ui-slider'), Sensei()->version); |
|
| 842 | 842 | } |
| 843 | 843 | |
| 844 | - wp_register_script( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/js/image-selectors' . $suffix . '.js' ), array( 'jquery' ), Sensei()->version ); |
|
| 844 | + wp_register_script('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/js/image-selectors'.$suffix.'.js'), array('jquery'), Sensei()->version); |
|
| 845 | 845 | |
| 846 | - if ( $this->has_imageselector ) { |
|
| 847 | - wp_enqueue_script( 'woothemes-sensei-settings-imageselectors' ); |
|
| 846 | + if ($this->has_imageselector) { |
|
| 847 | + wp_enqueue_script('woothemes-sensei-settings-imageselectors'); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | } // End enqueue_scripts() |
@@ -855,12 +855,12 @@ discard block |
||
| 855 | 855 | * @since 1.0.0 |
| 856 | 856 | * @return void |
| 857 | 857 | */ |
| 858 | - public function enqueue_styles () { |
|
| 858 | + public function enqueue_styles() { |
|
| 859 | 859 | |
| 860 | - wp_enqueue_style( $this->token . '-admin' ); |
|
| 860 | + wp_enqueue_style($this->token.'-admin'); |
|
| 861 | 861 | |
| 862 | - wp_enqueue_style( 'farbtastic' ); |
|
| 863 | - wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), array( 'farbtastic' ), Sensei()->version ); |
|
| 862 | + wp_enqueue_style('farbtastic'); |
|
| 863 | + wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), array('farbtastic'), Sensei()->version); |
|
| 864 | 864 | |
| 865 | 865 | $this->enqueue_field_styles(); |
| 866 | 866 | } // End enqueue_styles() |
@@ -871,16 +871,16 @@ discard block |
||
| 871 | 871 | * @since 1.0.0 |
| 872 | 872 | * @return void |
| 873 | 873 | */ |
| 874 | - public function enqueue_field_styles () { |
|
| 874 | + public function enqueue_field_styles() { |
|
| 875 | 875 | |
| 876 | - if ( $this->has_range ) { |
|
| 877 | - wp_enqueue_style( 'woothemes-sensei-settings-ranges', esc_url( Sensei()->plugin_url . 'assets/css/ranges.css' ), '', Sensei()->version ); |
|
| 876 | + if ($this->has_range) { |
|
| 877 | + wp_enqueue_style('woothemes-sensei-settings-ranges', esc_url(Sensei()->plugin_url.'assets/css/ranges.css'), '', Sensei()->version); |
|
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - wp_register_style( 'woothemes-sensei-settings-imageselectors', esc_url( Sensei()->plugin_url . 'assets/css/image-selectors.css' ), '', Sensei()->version ); |
|
| 880 | + wp_register_style('woothemes-sensei-settings-imageselectors', esc_url(Sensei()->plugin_url.'assets/css/image-selectors.css'), '', Sensei()->version); |
|
| 881 | 881 | |
| 882 | - if ( $this->has_imageselector ) { |
|
| 883 | - wp_enqueue_style( 'woothemes-sensei-settings-imageselectors' ); |
|
| 882 | + if ($this->has_imageselector) { |
|
| 883 | + wp_enqueue_style('woothemes-sensei-settings-imageselectors'); |
|
| 884 | 884 | } |
| 885 | 885 | } // End enqueue_field_styles() |
| 886 | 886 | } // End Class |
@@ -890,4 +890,4 @@ discard block |
||
| 890 | 890 | * @ignore only for backward compatibility |
| 891 | 891 | * @since 1.9.0 |
| 892 | 892 | */ |
| 893 | -class WooThemes_Sensei_Settings_API extends Sensei_Settings_API{} |
|
| 893 | +class WooThemes_Sensei_Settings_API extends Sensei_Settings_API {} |
|