@@ -11,75 +11,75 @@ discard block |
||
| 11 | 11 | class LSX_Projects_Frontend { |
| 12 | 12 | |
| 13 | 13 | public function __construct() { |
| 14 | - if ( function_exists( 'tour_operator' ) ) { |
|
| 15 | - $this->options = get_option( '_lsx-to_settings', false ); |
|
| 14 | + if (function_exists('tour_operator')) { |
|
| 15 | + $this->options = get_option('_lsx-to_settings', false); |
|
| 16 | 16 | } else { |
| 17 | - $this->options = get_option( '_lsx_settings', false ); |
|
| 17 | + $this->options = get_option('_lsx_settings', false); |
|
| 18 | 18 | |
| 19 | - if ( false === $this->options ) { |
|
| 20 | - $this->options = get_option( '_lsx_lsx-settings', false ); |
|
| 19 | + if (false === $this->options) { |
|
| 20 | + $this->options = get_option('_lsx_lsx-settings', false); |
|
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5 ); |
|
| 25 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wp_kses_allowed_html' ), 10, 2 ); |
|
| 26 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
| 27 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
| 24 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5); |
|
| 25 | + add_filter('wp_kses_allowed_html', array($this, 'wp_kses_allowed_html'), 10, 2); |
|
| 26 | + add_filter('template_include', array($this, 'single_template_include'), 99); |
|
| 27 | + add_filter('template_include', array($this, 'archive_template_include'), 99); |
|
| 28 | 28 | |
| 29 | - if ( ! empty( $this->options['display'] ) && ! empty( $this->options['display']['projects_disable_single'] ) ) { |
|
| 30 | - add_action( 'template_redirect', array( $this, 'disable_single' ) ); |
|
| 29 | + if ( ! empty($this->options['display']) && ! empty($this->options['display']['projects_disable_single'])) { |
|
| 30 | + add_action('template_redirect', array($this, 'disable_single')); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - if ( is_admin() ) { |
|
| 34 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
| 33 | + if (is_admin()) { |
|
| 34 | + add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - add_filter( 'lsx_banner_title', array( $this, 'lsx_banner_archive_title' ), 15 ); |
|
| 37 | + add_filter('lsx_banner_title', array($this, 'lsx_banner_archive_title'), 15); |
|
| 38 | 38 | |
| 39 | - add_filter( 'excerpt_more_p', array( $this, 'change_excerpt_more' ) ); |
|
| 40 | - add_filter( 'excerpt_length', array( $this, 'change_excerpt_length' ) ); |
|
| 41 | - add_filter( 'excerpt_strip_tags', array( $this, 'change_excerpt_strip_tags' ) ); |
|
| 39 | + add_filter('excerpt_more_p', array($this, 'change_excerpt_more')); |
|
| 40 | + add_filter('excerpt_length', array($this, 'change_excerpt_length')); |
|
| 41 | + add_filter('excerpt_strip_tags', array($this, 'change_excerpt_strip_tags')); |
|
| 42 | 42 | |
| 43 | - add_filter( 'pre_get_posts', array( $this, 'posts_per_page' ) ); |
|
| 44 | - add_action( 'wp_footer', array( $this, 'add_form_modal' ) ); |
|
| 43 | + add_filter('pre_get_posts', array($this, 'posts_per_page')); |
|
| 44 | + add_action('wp_footer', array($this, 'add_form_modal')); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function enqueue_scripts() { |
| 48 | - $has_slick = wp_script_is( 'slick', 'queue' ); |
|
| 48 | + $has_slick = wp_script_is('slick', 'queue'); |
|
| 49 | 49 | |
| 50 | - if ( ! $has_slick ) { |
|
| 51 | - wp_enqueue_style( 'slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null ); |
|
| 52 | - wp_enqueue_script( 'slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true ); |
|
| 50 | + if ( ! $has_slick) { |
|
| 51 | + wp_enqueue_style('slick', LSX_PROJECTS_URL . 'assets/css/vendor/slick.css', array(), LSX_PROJECTS_VER, null); |
|
| 52 | + wp_enqueue_script('slick', LSX_PROJECTS_URL . 'assets/js/vendor/slick.min.js', array('jquery'), null, LSX_PROJECTS_VER, true); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $has_scrolltofixed = wp_script_is( 'scrolltofixed', 'queue' ); |
|
| 55 | + $has_scrolltofixed = wp_script_is('scrolltofixed', 'queue'); |
|
| 56 | 56 | |
| 57 | - if ( ! $has_scrolltofixed ) { |
|
| 58 | - wp_enqueue_script( 'scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true ); |
|
| 57 | + if ( ! $has_scrolltofixed) { |
|
| 58 | + wp_enqueue_script('scrolltofixed', LSX_PROJECTS_URL . 'assets/js/vendor/jquery-scrolltofixed-min.js', array('jquery'), null, LSX_PROJECTS_VER, true); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - $has_isotope = wp_script_is( 'isotope', 'queue' ); |
|
| 61 | + $has_isotope = wp_script_is('isotope', 'queue'); |
|
| 62 | 62 | |
| 63 | - if ( ! $has_isotope ) { |
|
| 64 | - wp_enqueue_script( 'isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_PROJECTS_VER, true ); |
|
| 63 | + if ( ! $has_isotope) { |
|
| 64 | + wp_enqueue_script('isotope', LSX_PROJECTS_URL . 'assets/js/vendor/isotope.pkgd.min.js', array('jquery'), null, LSX_PROJECTS_VER, true); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - wp_enqueue_script( 'lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array( 'jquery', 'slick', 'scrolltofixed', 'isotope' ), LSX_PROJECTS_VER, true ); |
|
| 67 | + wp_enqueue_script('lsx-projects', LSX_PROJECTS_URL . 'assets/js/lsx-projects.min.js', array('jquery', 'slick', 'scrolltofixed', 'isotope'), LSX_PROJECTS_VER, true); |
|
| 68 | 68 | |
| 69 | - $params = apply_filters( 'lsx_projects_js_params', array( |
|
| 70 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
| 69 | + $params = apply_filters('lsx_projects_js_params', array( |
|
| 70 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
| 71 | 71 | )); |
| 72 | 72 | |
| 73 | - wp_localize_script( 'lsx-projects', 'lsx_customizer_params', $params ); |
|
| 73 | + wp_localize_script('lsx-projects', 'lsx_customizer_params', $params); |
|
| 74 | 74 | |
| 75 | - wp_enqueue_style( 'lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER ); |
|
| 76 | - wp_style_add_data( 'lsx-projects', 'rtl', 'replace' ); |
|
| 75 | + wp_enqueue_style('lsx-projects', LSX_PROJECTS_URL . 'assets/css/lsx-projects.css', array(), LSX_PROJECTS_VER); |
|
| 76 | + wp_style_add_data('lsx-projects', 'rtl', 'replace'); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Allow data params for Slick slider addon. |
| 81 | 81 | */ |
| 82 | - public function wp_kses_allowed_html( $allowedtags, $context ) { |
|
| 82 | + public function wp_kses_allowed_html($allowedtags, $context) { |
|
| 83 | 83 | $allowedtags['div']['data-slick'] = true; |
| 84 | 84 | return $allowedtags; |
| 85 | 85 | } |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | /** |
| 88 | 88 | * Single template. |
| 89 | 89 | */ |
| 90 | - public function single_template_include( $template ) { |
|
| 91 | - if ( is_main_query() && is_singular( 'project' ) ) { |
|
| 92 | - if ( empty( locate_template( array( 'single-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/single-projects.php' ) ) { |
|
| 90 | + public function single_template_include($template) { |
|
| 91 | + if (is_main_query() && is_singular('project')) { |
|
| 92 | + if (empty(locate_template(array('single-projects.php'))) && file_exists(LSX_PROJECTS_PATH . 'templates/single-projects.php')) { |
|
| 93 | 93 | $template = LSX_PROJECTS_PATH . 'templates/single-projects.php'; |
| 94 | 94 | } |
| 95 | 95 | } |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | /** |
| 101 | 101 | * Archive template. |
| 102 | 102 | */ |
| 103 | - public function archive_template_include( $template ) { |
|
| 104 | - if ( is_main_query() && ( is_post_type_archive( 'project' ) || is_tax( 'project-group' ) ) ) { |
|
| 105 | - if ( empty( locate_template( array( 'archive-projects.php' ) ) ) && file_exists( LSX_PROJECTS_PATH . 'templates/archive-projects.php' ) ) { |
|
| 103 | + public function archive_template_include($template) { |
|
| 104 | + if (is_main_query() && (is_post_type_archive('project') || is_tax('project-group'))) { |
|
| 105 | + if (empty(locate_template(array('archive-projects.php'))) && file_exists(LSX_PROJECTS_PATH . 'templates/archive-projects.php')) { |
|
| 106 | 106 | $template = LSX_PROJECTS_PATH . 'templates/archive-projects.php'; |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | * Removes access to single project member posts. |
| 115 | 115 | */ |
| 116 | 116 | public function disable_single() { |
| 117 | - $queried_post_type = get_query_var( 'post_type' ); |
|
| 117 | + $queried_post_type = get_query_var('post_type'); |
|
| 118 | 118 | |
| 119 | - if ( is_single() && 'project' === $queried_post_type ) { |
|
| 120 | - wp_redirect( home_url(), 301 ); |
|
| 119 | + if (is_single() && 'project' === $queried_post_type) { |
|
| 120 | + wp_redirect(home_url(), 301); |
|
| 121 | 121 | exit; |
| 122 | 122 | } |
| 123 | 123 | } |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | /** |
| 126 | 126 | * Handle body colours that might be change by LSX Customiser |
| 127 | 127 | */ |
| 128 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
| 128 | + public function customizer_body_colours_handler($css, $colors) { |
|
| 129 | 129 | $css .= ' |
| 130 | 130 | @import "' . LSX_PROJECTS_PATH . '/assets/css/scss/customizer-projects-body-colours"; |
| 131 | 131 | |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | /** |
| 149 | 149 | * Change the LSX Banners title for project archive. |
| 150 | 150 | */ |
| 151 | - public function lsx_banner_archive_title( $title ) { |
|
| 152 | - if ( is_main_query() && is_post_type_archive( 'project' ) ) { |
|
| 153 | - $title = '<h1 class="page-title">' . esc_html__( 'Portfolio', 'lsx-projects' ) . '</h1>'; |
|
| 151 | + public function lsx_banner_archive_title($title) { |
|
| 152 | + if (is_main_query() && is_post_type_archive('project')) { |
|
| 153 | + $title = '<h1 class="page-title">' . esc_html__('Portfolio', 'lsx-projects') . '</h1>'; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - if ( is_main_query() && is_tax( 'project-group' ) ) { |
|
| 156 | + if (is_main_query() && is_tax('project-group')) { |
|
| 157 | 157 | $tax = get_queried_object(); |
| 158 | - $title = '<h1 class="page-title">' . esc_html__( 'Project Type', 'lsx-projects' ) . ': ' . apply_filters( 'the_title', $tax->name ) . '</h1>'; |
|
| 158 | + $title = '<h1 class="page-title">' . esc_html__('Project Type', 'lsx-projects') . ': ' . apply_filters('the_title', $tax->name) . '</h1>'; |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | return $title; |
@@ -164,11 +164,11 @@ discard block |
||
| 164 | 164 | /** |
| 165 | 165 | * Remove the "continue reading" when the single is disabled. |
| 166 | 166 | */ |
| 167 | - public function change_excerpt_more( $excerpt_more ) { |
|
| 167 | + public function change_excerpt_more($excerpt_more) { |
|
| 168 | 168 | global $post; |
| 169 | 169 | |
| 170 | - if ( 'project' === $post->post_type ) { |
|
| 171 | - if ( ! empty( $this->options['display'] ) && ! empty( $this->options['display']['projects_disable_single'] ) ) { |
|
| 170 | + if ('project' === $post->post_type) { |
|
| 171 | + if ( ! empty($this->options['display']) && ! empty($this->options['display']['projects_disable_single'])) { |
|
| 172 | 172 | $excerpt_more = ''; |
| 173 | 173 | } |
| 174 | 174 | } |
@@ -179,14 +179,14 @@ discard block |
||
| 179 | 179 | /** |
| 180 | 180 | * Change the word count when crop the content to excerpt (homepage widget). |
| 181 | 181 | */ |
| 182 | - public function change_excerpt_length( $excerpt_word_count ) { |
|
| 182 | + public function change_excerpt_length($excerpt_word_count) { |
|
| 183 | 183 | global $post; |
| 184 | 184 | |
| 185 | - if ( is_front_page() && 'project' === $post->post_type ) { |
|
| 185 | + if (is_front_page() && 'project' === $post->post_type) { |
|
| 186 | 186 | $excerpt_word_count = 20; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) { |
|
| 189 | + if (is_singular('project') && ('team' === $post->post_type || 'testimonial' === $post->post_type)) { |
|
| 190 | 190 | $excerpt_word_count = 20; |
| 191 | 191 | } |
| 192 | 192 | |
@@ -196,14 +196,14 @@ discard block |
||
| 196 | 196 | /** |
| 197 | 197 | * Change the allowed tags crop the content to excerpt (homepage widget). |
| 198 | 198 | */ |
| 199 | - public function change_excerpt_strip_tags( $allowed_tags ) { |
|
| 199 | + public function change_excerpt_strip_tags($allowed_tags) { |
|
| 200 | 200 | global $post; |
| 201 | 201 | |
| 202 | - if ( is_front_page() && 'project' === $post->post_type ) { |
|
| 202 | + if (is_front_page() && 'project' === $post->post_type) { |
|
| 203 | 203 | $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>'; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - if ( is_singular( 'project' ) && ( 'team' === $post->post_type || 'testimonial' === $post->post_type ) ) { |
|
| 206 | + if (is_singular('project') && ('team' === $post->post_type || 'testimonial' === $post->post_type)) { |
|
| 207 | 207 | $allowed_tags = '<p>,<br>,<b>,<strong>,<i>,<u>,<ul>,<ol>,<li>,<span>'; |
| 208 | 208 | } |
| 209 | 209 | |
@@ -213,10 +213,10 @@ discard block |
||
| 213 | 213 | /** |
| 214 | 214 | * Change posts per page counter for archive. |
| 215 | 215 | */ |
| 216 | - public function posts_per_page( $query ) { |
|
| 217 | - if ( ! is_admin() && $query->is_main_query() ) { |
|
| 218 | - if ( $query->is_post_type_archive( 'project' ) || $query->is_tax( 'project-group' ) ) { |
|
| 219 | - $query->set( 'posts_per_page', -1 ); |
|
| 216 | + public function posts_per_page($query) { |
|
| 217 | + if ( ! is_admin() && $query->is_main_query()) { |
|
| 218 | + if ($query->is_post_type_archive('project') || $query->is_tax('project-group')) { |
|
| 219 | + $query->set('posts_per_page', -1); |
|
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | |
@@ -229,15 +229,15 @@ discard block |
||
| 229 | 229 | public function add_form_modal() { |
| 230 | 230 | global $lsx_projects; |
| 231 | 231 | |
| 232 | - if ( empty( $lsx_projects->options['display'] ) || empty( $lsx_projects->options['display']['projects_modal_enable'] ) ) { |
|
| 232 | + if (empty($lsx_projects->options['display']) || empty($lsx_projects->options['display']['projects_modal_enable'])) { |
|
| 233 | 233 | return ''; |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - if ( empty( $lsx_projects->options['display']['projects_modal_cta_label'] ) || empty( $lsx_projects->options['display']['projects_modal_form_id'] ) ) { |
|
| 236 | + if (empty($lsx_projects->options['display']['projects_modal_cta_label']) || empty($lsx_projects->options['display']['projects_modal_form_id'])) { |
|
| 237 | 237 | return ''; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - if ( ! is_single( 'project' ) ) { |
|
| 240 | + if ( ! is_single('project')) { |
|
| 241 | 241 | return ''; |
| 242 | 242 | } |
| 243 | 243 | ?> |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | <button type="button" class="close" data-dismiss="modal">×</button> |
| 248 | 248 | |
| 249 | 249 | <div class="modal-header"> |
| 250 | - <h4 class="modal-title"><?php echo esc_html( $lsx_projects->options['display']['projects_modal_cta_label'] ); ?></h4> |
|
| 250 | + <h4 class="modal-title"><?php echo esc_html($lsx_projects->options['display']['projects_modal_cta_label']); ?></h4> |
|
| 251 | 251 | </div> |
| 252 | 252 | |
| 253 | 253 | <div class="modal-body"> |
| 254 | - <?php echo do_shortcode( '[caldera_form id="' . $lsx_projects->options['display']['projects_modal_form_id'] . '"]' ); ?> |
|
| 254 | + <?php echo do_shortcode('[caldera_form id="' . $lsx_projects->options['display']['projects_modal_form_id'] . '"]'); ?> |
|
| 255 | 255 | </div> |
| 256 | 256 | </div> |
| 257 | 257 | </div> |
@@ -13,14 +13,14 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | |
| 15 | 15 | // If this file is called directly, abort. |
| 16 | -if ( ! defined( 'WPINC' ) ) { |
|
| 16 | +if ( ! defined('WPINC')) { |
|
| 17 | 17 | die; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | -define( 'LSX_PROJECTS_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 21 | -define( 'LSX_PROJECTS_CORE', __FILE__ ); |
|
| 22 | -define( 'LSX_PROJECTS_URL', plugin_dir_url( __FILE__ ) ); |
|
| 23 | -define( 'LSX_PROJECTS_VER', '1.1.3' ); |
|
| 20 | +define('LSX_PROJECTS_PATH', plugin_dir_path(__FILE__)); |
|
| 21 | +define('LSX_PROJECTS_CORE', __FILE__); |
|
| 22 | +define('LSX_PROJECTS_URL', plugin_dir_url(__FILE__)); |
|
| 23 | +define('LSX_PROJECTS_VER', '1.1.3'); |
|
| 24 | 24 | |
| 25 | 25 | /* ======================= Below is the Plugin Class init ========================= */ |
| 26 | 26 | |
@@ -1,18 +1,18 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'CMB_DEV') ) |
|
| 3 | - define( 'CMB_DEV', false ); |
|
| 2 | +if ( ! defined('CMB_DEV')) |
|
| 3 | + define('CMB_DEV', false); |
|
| 4 | 4 | |
| 5 | -if ( ! defined( 'CMB_PATH') ) |
|
| 6 | - define( 'CMB_PATH', plugin_dir_path( __FILE__ ) ); |
|
| 5 | +if ( ! defined('CMB_PATH')) |
|
| 6 | + define('CMB_PATH', plugin_dir_path(__FILE__)); |
|
| 7 | 7 | |
| 8 | -if ( ! defined( 'CMB_URL' ) ) |
|
| 9 | - define( 'CMB_URL', plugins_url( '', __FILE__ ) ); |
|
| 8 | +if ( ! defined('CMB_URL')) |
|
| 9 | + define('CMB_URL', plugins_url('', __FILE__)); |
|
| 10 | 10 | |
| 11 | -include_once( CMB_PATH . '/classes.fields.php' ); |
|
| 12 | -include_once( CMB_PATH . '/class.cmb-meta-box.php' ); |
|
| 11 | +include_once(CMB_PATH . '/classes.fields.php'); |
|
| 12 | +include_once(CMB_PATH . '/class.cmb-meta-box.php'); |
|
| 13 | 13 | |
| 14 | 14 | // Make it possible to add fields in locations other than post edit screen. |
| 15 | -include_once( CMB_PATH . '/fields-anywhere.php' ); |
|
| 15 | +include_once(CMB_PATH . '/fields-anywhere.php'); |
|
| 16 | 16 | |
| 17 | 17 | // include_once( CMB_PATH . '/example-functions.php' ); |
| 18 | 18 | |
@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | */ |
| 24 | 24 | function cmb_init() { |
| 25 | 25 | |
| 26 | - if ( ! is_admin() ) |
|
| 26 | + if ( ! is_admin()) |
|
| 27 | 27 | return; |
| 28 | 28 | |
| 29 | 29 | // Load translations |
| 30 | 30 | $textdomain = 'cmb'; |
| 31 | - $locale = apply_filters( 'plugin_locale', get_locale(), $textdomain ); |
|
| 31 | + $locale = apply_filters('plugin_locale', get_locale(), $textdomain); |
|
| 32 | 32 | |
| 33 | 33 | // By default, try to load language files from /wp-content/languages/custom-meta-boxes/ |
| 34 | - load_textdomain( $textdomain, WP_LANG_DIR . '/custom-meta-boxes/' . $textdomain . '-' . $locale . '.mo' ); |
|
| 35 | - load_textdomain( $textdomain, CMB_PATH . '/languages/' . $textdomain . '-' . $locale . '.mo' ); |
|
| 34 | + load_textdomain($textdomain, WP_LANG_DIR . '/custom-meta-boxes/' . $textdomain . '-' . $locale . '.mo'); |
|
| 35 | + load_textdomain($textdomain, CMB_PATH . '/languages/' . $textdomain . '-' . $locale . '.mo'); |
|
| 36 | 36 | |
| 37 | - $meta_boxes = apply_filters( 'cmb_meta_boxes', array() ); |
|
| 37 | + $meta_boxes = apply_filters('cmb_meta_boxes', array()); |
|
| 38 | 38 | |
| 39 | - if ( ! empty( $meta_boxes ) ) |
|
| 40 | - foreach ( $meta_boxes as $meta_box ) |
|
| 41 | - new CMB_Meta_Box( $meta_box ); |
|
| 39 | + if ( ! empty($meta_boxes)) |
|
| 40 | + foreach ($meta_boxes as $meta_box) |
|
| 41 | + new CMB_Meta_Box($meta_box); |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | -add_action( 'init', 'cmb_init', 50 ); |
|
| 44 | +add_action('init', 'cmb_init', 50); |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Return an array of built in available fields |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | function _cmb_available_fields() { |
| 55 | 55 | |
| 56 | - return apply_filters( 'cmb_field_types', array( |
|
| 56 | + return apply_filters('cmb_field_types', array( |
|
| 57 | 57 | 'text' => 'CMB_Text_Field', |
| 58 | 58 | 'text_small' => 'CMB_Text_Small_Field', |
| 59 | 59 | 'text_url' => 'CMB_URL_Field', |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | 'group' => 'CMB_Group_Field', |
| 79 | 79 | 'gmap' => 'CMB_Gmap_Field', |
| 80 | 80 | 'number' => 'CMB_Number_Field' |
| 81 | - ) ); |
|
| 81 | + )); |
|
| 82 | 82 | |
| 83 | 83 | } |
| 84 | 84 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | * @param string $type |
| 89 | 89 | * @return string $class, or false if not found. |
| 90 | 90 | */ |
| 91 | -function _cmb_field_class_for_type( $type ) { |
|
| 91 | +function _cmb_field_class_for_type($type) { |
|
| 92 | 92 | |
| 93 | 93 | $map = _cmb_available_fields(); |
| 94 | 94 | |
| 95 | - if ( isset( $map[$type] ) ) |
|
| 95 | + if (isset($map[$type])) |
|
| 96 | 96 | return $map[$type]; |
| 97 | 97 | |
| 98 | 98 | return false; |
@@ -114,18 +114,18 @@ discard block |
||
| 114 | 114 | $pattern = '/^SELECT (post_id|user_id), meta_key, meta_value FROM \w* WHERE post_id IN \([\d|,]*\)$/'; |
| 115 | 115 | |
| 116 | 116 | if ( |
| 117 | - 0 === strpos( $query, "SELECT post_id, meta_key, meta_value" ) && |
|
| 118 | - preg_match( $pattern, $query, $matches ) |
|
| 117 | + 0 === strpos($query, "SELECT post_id, meta_key, meta_value") && |
|
| 118 | + preg_match($pattern, $query, $matches) |
|
| 119 | 119 | ) { |
| 120 | 120 | |
| 121 | - if ( isset( $matches[1] ) && 'user_id' == $matches[1] ) |
|
| 121 | + if (isset($matches[1]) && 'user_id' == $matches[1]) |
|
| 122 | 122 | $meta_id_column = 'umeta_id'; |
| 123 | 123 | else |
| 124 | 124 | $meta_id_column = 'meta_id'; |
| 125 | 125 | |
| 126 | 126 | $meta_query_orderby = ' ORDER BY ' . $meta_id_column; |
| 127 | 127 | |
| 128 | - if ( false === strpos( $query, $meta_query_orderby ) ) |
|
| 128 | + if (false === strpos($query, $meta_query_orderby)) |
|
| 129 | 129 | $query .= $meta_query_orderby; |
| 130 | 130 | |
| 131 | 131 | } |
@@ -134,5 +134,5 @@ discard block |
||
| 134 | 134 | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | -if ( version_compare( get_bloginfo( 'version' ), '3.8', '<' ) ) |
|
| 138 | - add_filter( 'query', 'cmb_fix_meta_query_order', 1 ); |
|
| 139 | 137 | \ No newline at end of file |
| 138 | +if (version_compare(get_bloginfo('version'), '3.8', '<')) |
|
| 139 | + add_filter('query', 'cmb_fix_meta_query_order', 1); |
|
| 140 | 140 | \ No newline at end of file |
@@ -11,34 +11,34 @@ discard block |
||
| 11 | 11 | public $value; |
| 12 | 12 | public $field_index = 0; |
| 13 | 13 | |
| 14 | - public function __construct( $name, $title, array $values, $args = array() ) { |
|
| 14 | + public function __construct($name, $title, array $values, $args = array()) { |
|
| 15 | 15 | |
| 16 | - $this->id = $name; |
|
| 16 | + $this->id = $name; |
|
| 17 | 17 | $this->name = $name . '[]'; |
| 18 | - $this->title = $title; |
|
| 19 | - $this->args = wp_parse_args( $args, $this->get_default_args() ); |
|
| 18 | + $this->title = $title; |
|
| 19 | + $this->args = wp_parse_args($args, $this->get_default_args()); |
|
| 20 | 20 | |
| 21 | 21 | // Deprecated argument: 'std' |
| 22 | - if ( ! empty( $this->args['std'] ) && empty( $this->args['default'] ) ) { |
|
| 22 | + if ( ! empty($this->args['std']) && empty($this->args['default'])) { |
|
| 23 | 23 | $this->args['default'] = $this->args['std']; |
| 24 | - _deprecated_argument( 'CMB_Field', '0.9', "field argument 'std' is deprecated, use 'default' instead" ); |
|
| 24 | + _deprecated_argument('CMB_Field', '0.9', "field argument 'std' is deprecated, use 'default' instead"); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - if ( ! empty( $this->args['options'] ) && is_array( reset( $this->args['options'] ) ) ) { |
|
| 27 | + if ( ! empty($this->args['options']) && is_array(reset($this->args['options']))) { |
|
| 28 | 28 | $re_format = array(); |
| 29 | - foreach ( $this->args['options'] as $option ) { |
|
| 29 | + foreach ($this->args['options'] as $option) { |
|
| 30 | 30 | $re_format[$option['value']] = $option['name']; |
| 31 | 31 | } |
| 32 | 32 | $this->args['options'] = $re_format; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // If the field has a custom value populator callback |
| 36 | - if ( ! empty( $args['values_callback'] ) ) |
|
| 37 | - $this->values = call_user_func( $args['values_callback'], get_the_id() ); |
|
| 36 | + if ( ! empty($args['values_callback'])) |
|
| 37 | + $this->values = call_user_func($args['values_callback'], get_the_id()); |
|
| 38 | 38 | else |
| 39 | 39 | $this->values = $values; |
| 40 | 40 | |
| 41 | - $this->value = reset( $this->values ); |
|
| 41 | + $this->value = reset($this->values); |
|
| 42 | 42 | |
| 43 | 43 | } |
| 44 | 44 | |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | 'class' => '', |
| 66 | 66 | 'data_delegate' => null, |
| 67 | 67 | 'save_callback' => null, |
| 68 | - 'string-repeat-field' => __( 'Add New', 'cmb' ), |
|
| 69 | - 'string-delete-field' => __( 'Remove Field', 'cmb' ), |
|
| 68 | + 'string-repeat-field' => __('Add New', 'cmb'), |
|
| 69 | + 'string-delete-field' => __('Remove Field', 'cmb'), |
|
| 70 | 70 | ), |
| 71 | - get_class( $this ) |
|
| 71 | + get_class($this) |
|
| 72 | 72 | ); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | public function enqueue_scripts() { |
| 81 | 81 | |
| 82 | - if ( isset( $this->args['sortable'] ) && $this->args['sortable'] ) |
|
| 83 | - wp_enqueue_script( 'jquery-ui-sortable' ); |
|
| 82 | + if (isset($this->args['sortable']) && $this->args['sortable']) |
|
| 83 | + wp_enqueue_script('jquery-ui-sortable'); |
|
| 84 | 84 | |
| 85 | 85 | } |
| 86 | 86 | |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | * @param string $append |
| 101 | 101 | * @return null |
| 102 | 102 | */ |
| 103 | - public function id_attr( $append = null ) { |
|
| 103 | + public function id_attr($append = null) { |
|
| 104 | 104 | |
| 105 | - printf( 'id="%s"', esc_attr( $this->get_the_id_attr( $append ) ) ); |
|
| 105 | + printf('id="%s"', esc_attr($this->get_the_id_attr($append))); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
@@ -117,21 +117,21 @@ discard block |
||
| 117 | 117 | * @param string $append |
| 118 | 118 | * @return null |
| 119 | 119 | */ |
| 120 | - public function get_the_id_attr( $append = null ) { |
|
| 120 | + public function get_the_id_attr($append = null) { |
|
| 121 | 121 | |
| 122 | 122 | $id = $this->id; |
| 123 | 123 | |
| 124 | - if ( isset( $this->parent ) ) { |
|
| 125 | - $parent_id = preg_replace( '/cmb\-field\-(\d+|x)/', 'cmb-group-$1', $this->parent->get_the_id_attr() ); |
|
| 124 | + if (isset($this->parent)) { |
|
| 125 | + $parent_id = preg_replace('/cmb\-field\-(\d+|x)/', 'cmb-group-$1', $this->parent->get_the_id_attr()); |
|
| 126 | 126 | $id = $parent_id . '[' . $id . ']'; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | $id .= '-cmb-field-' . $this->field_index; |
| 130 | 130 | |
| 131 | - if ( ! is_null( $append ) ) |
|
| 131 | + if ( ! is_null($append)) |
|
| 132 | 132 | $id .= '-' . $append; |
| 133 | 133 | |
| 134 | - $id = str_replace( array( '[', ']', '--' ), '-', $id ); |
|
| 134 | + $id = str_replace(array('[', ']', '--'), '-', $id); |
|
| 135 | 135 | |
| 136 | 136 | return $id; |
| 137 | 137 | |
@@ -146,41 +146,41 @@ discard block |
||
| 146 | 146 | * @param string $append |
| 147 | 147 | * @return string id attribute value. |
| 148 | 148 | */ |
| 149 | - public function for_attr( $append = null ) { |
|
| 149 | + public function for_attr($append = null) { |
|
| 150 | 150 | |
| 151 | - printf( 'for="%s"', esc_attr( $this->get_the_id_attr( $append ) ) ); |
|
| 151 | + printf('for="%s"', esc_attr($this->get_the_id_attr($append))); |
|
| 152 | 152 | |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - public function name_attr( $append = null ) { |
|
| 155 | + public function name_attr($append = null) { |
|
| 156 | 156 | |
| 157 | - printf( 'name="%s"', esc_attr( $this->get_the_name_attr( $append ) ) ); |
|
| 157 | + printf('name="%s"', esc_attr($this->get_the_name_attr($append))); |
|
| 158 | 158 | |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function get_the_name_attr( $append = null ) { |
|
| 161 | + public function get_the_name_attr($append = null) { |
|
| 162 | 162 | |
| 163 | - $name = str_replace( '[]', '', $this->name ); |
|
| 163 | + $name = str_replace('[]', '', $this->name); |
|
| 164 | 164 | |
| 165 | - if ( isset( $this->parent ) ) { |
|
| 166 | - $parent_name = preg_replace( '/cmb\-field\-(\d+|x)/', 'cmb-group-$1', $this->parent->get_the_name_attr() ); |
|
| 165 | + if (isset($this->parent)) { |
|
| 166 | + $parent_name = preg_replace('/cmb\-field\-(\d+|x)/', 'cmb-group-$1', $this->parent->get_the_name_attr()); |
|
| 167 | 167 | $name = $parent_name . '[' . $name . ']'; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $name .= "[cmb-field-$this->field_index]"; |
| 171 | 171 | |
| 172 | - if ( ! is_null( $append ) ) |
|
| 172 | + if ( ! is_null($append)) |
|
| 173 | 173 | $name .= $append; |
| 174 | 174 | |
| 175 | 175 | return $name; |
| 176 | 176 | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public function class_attr( $classes = '' ) { |
|
| 179 | + public function class_attr($classes = '') { |
|
| 180 | 180 | |
| 181 | - if ( $classes = implode( ' ', array_map( 'sanitize_html_class', array_filter( array_unique( explode( ' ', $classes . ' ' . $this->args['class'] ) ) ) ) ) ) { ?> |
|
| 181 | + if ($classes = implode(' ', array_map('sanitize_html_class', array_filter(array_unique(explode(' ', $classes . ' ' . $this->args['class'])))))) { ?> |
|
| 182 | 182 | |
| 183 | - class="<?php echo esc_attr( $classes ); ?>" |
|
| 183 | + class="<?php echo esc_attr($classes); ?>" |
|
| 184 | 184 | |
| 185 | 185 | <?php } |
| 186 | 186 | |
@@ -193,22 +193,22 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public function get_js_id() { |
| 195 | 195 | |
| 196 | - return str_replace( array( '-', '[', ']', '--' ),'_', $this->get_the_id_attr() ); // JS friendly ID |
|
| 196 | + return str_replace(array('-', '[', ']', '--'), '_', $this->get_the_id_attr()); // JS friendly ID |
|
| 197 | 197 | |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - public function boolean_attr( $attrs = array() ) { |
|
| 200 | + public function boolean_attr($attrs = array()) { |
|
| 201 | 201 | |
| 202 | - if ( $this->args['readonly'] ) |
|
| 202 | + if ($this->args['readonly']) |
|
| 203 | 203 | $attrs[] = 'readonly'; |
| 204 | 204 | |
| 205 | - if ( $this->args['disabled'] ) |
|
| 205 | + if ($this->args['disabled']) |
|
| 206 | 206 | $attrs[] = 'disabled'; |
| 207 | 207 | |
| 208 | - $attrs = array_filter( array_unique( $attrs ) ); |
|
| 208 | + $attrs = array_filter(array_unique($attrs)); |
|
| 209 | 209 | |
| 210 | - foreach ( $attrs as $attr ) |
|
| 211 | - echo esc_html( $attr ) . '="' . esc_attr( $attr ) . '"'; |
|
| 210 | + foreach ($attrs as $attr) |
|
| 211 | + echo esc_html($attr) . '="' . esc_attr($attr) . '"'; |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
@@ -228,26 +228,26 @@ discard block |
||
| 228 | 228 | */ |
| 229 | 229 | protected function get_delegate_data() { |
| 230 | 230 | |
| 231 | - if ( $this->args['data_delegate'] ) |
|
| 232 | - return call_user_func_array( $this->args['data_delegate'], array( $this ) ); |
|
| 231 | + if ($this->args['data_delegate']) |
|
| 232 | + return call_user_func_array($this->args['data_delegate'], array($this)); |
|
| 233 | 233 | |
| 234 | 234 | return array(); |
| 235 | 235 | |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | public function get_value() { |
| 239 | - return ( $this->value || $this->value === '0' ) ? $this->value : $this->args['default']; |
|
| 239 | + return ($this->value || $this->value === '0') ? $this->value : $this->args['default']; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | public function &get_values() { |
| 243 | 243 | return $this->values; |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - public function set_values( array $values ) { |
|
| 246 | + public function set_values(array $values) { |
|
| 247 | 247 | |
| 248 | 248 | $this->values = $values; |
| 249 | 249 | |
| 250 | - unset( $this->value ); |
|
| 250 | + unset($this->value); |
|
| 251 | 251 | |
| 252 | 252 | } |
| 253 | 253 | |
@@ -259,48 +259,48 @@ discard block |
||
| 259 | 259 | * @todo this surely only works for posts |
| 260 | 260 | * @todo why do values need to be passed in, they can already be passed in on construct |
| 261 | 261 | */ |
| 262 | - public function save( $post_id, $values ) { |
|
| 262 | + public function save($post_id, $values) { |
|
| 263 | 263 | |
| 264 | 264 | // Don't save readonly values. |
| 265 | - if ( $this->args['readonly'] ) |
|
| 265 | + if ($this->args['readonly']) |
|
| 266 | 266 | return; |
| 267 | 267 | |
| 268 | 268 | $this->values = $values; |
| 269 | 269 | $this->parse_save_values(); |
| 270 | 270 | |
| 271 | 271 | // Allow override from args |
| 272 | - if ( ! empty( $this->args['save_callback'] ) ) { |
|
| 272 | + if ( ! empty($this->args['save_callback'])) { |
|
| 273 | 273 | |
| 274 | - call_user_func( $this->args['save_callback'], $this->values, $post_id ); |
|
| 274 | + call_user_func($this->args['save_callback'], $this->values, $post_id); |
|
| 275 | 275 | |
| 276 | 276 | return; |
| 277 | 277 | |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // If we are not on a post edit screen |
| 281 | - if ( ! $post_id ) |
|
| 281 | + if ( ! $post_id) |
|
| 282 | 282 | return; |
| 283 | 283 | |
| 284 | - delete_post_meta( $post_id, $this->id ); |
|
| 284 | + delete_post_meta($post_id, $this->id); |
|
| 285 | 285 | |
| 286 | - foreach( $this->values as $v ) { |
|
| 286 | + foreach ($this->values as $v) { |
|
| 287 | 287 | |
| 288 | 288 | $this->value = $v; |
| 289 | 289 | $this->parse_save_value(); |
| 290 | 290 | |
| 291 | - if ( $this->value || $this->value === '0' ) |
|
| 292 | - add_post_meta( $post_id, $this->id, $this->value ); |
|
| 291 | + if ($this->value || $this->value === '0') |
|
| 292 | + add_post_meta($post_id, $this->id, $this->value); |
|
| 293 | 293 | |
| 294 | 294 | } |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | public function title() { |
| 298 | 298 | |
| 299 | - if ( $this->title ) { ?> |
|
| 299 | + if ($this->title) { ?> |
|
| 300 | 300 | |
| 301 | 301 | <div class="field-title"> |
| 302 | 302 | <label <?php $this->for_attr(); ?>> |
| 303 | - <?php echo esc_html( $this->title ); ?> |
|
| 303 | + <?php echo esc_html($this->title); ?> |
|
| 304 | 304 | </label> |
| 305 | 305 | </div> |
| 306 | 306 | |
@@ -310,10 +310,10 @@ discard block |
||
| 310 | 310 | |
| 311 | 311 | public function description() { |
| 312 | 312 | |
| 313 | - if ( ! empty( $this->args['desc'] ) ) { ?> |
|
| 313 | + if ( ! empty($this->args['desc'])) { ?> |
|
| 314 | 314 | |
| 315 | 315 | <div class="cmb_metabox_description"> |
| 316 | - <?php echo wp_kses_post( $this->args['desc'] ); ?> |
|
| 316 | + <?php echo wp_kses_post($this->args['desc']); ?> |
|
| 317 | 317 | </div> |
| 318 | 318 | |
| 319 | 319 | <?php } |
@@ -323,8 +323,8 @@ discard block |
||
| 323 | 323 | public function display() { |
| 324 | 324 | |
| 325 | 325 | // If there are no values and it's not repeateble, we want to do one with empty string |
| 326 | - if ( ! $this->get_values() && ! $this->args['repeatable'] ) |
|
| 327 | - $values = array( '' ); |
|
| 326 | + if ( ! $this->get_values() && ! $this->args['repeatable']) |
|
| 327 | + $values = array(''); |
|
| 328 | 328 | else |
| 329 | 329 | $values = $this->get_values(); |
| 330 | 330 | |
@@ -333,18 +333,18 @@ discard block |
||
| 333 | 333 | $this->description(); |
| 334 | 334 | |
| 335 | 335 | $i = 0; |
| 336 | - if( isset( $this->args['type'] ) && $this->args['type'] == 'gmap' ) { |
|
| 337 | - $values = array( $values ); |
|
| 336 | + if (isset($this->args['type']) && $this->args['type'] == 'gmap') { |
|
| 337 | + $values = array($values); |
|
| 338 | 338 | } |
| 339 | - foreach ( $values as $key => $value ) { |
|
| 339 | + foreach ($values as $key => $value) { |
|
| 340 | 340 | |
| 341 | 341 | $this->field_index = $i; |
| 342 | 342 | $this->value = $value; ?> |
| 343 | 343 | |
| 344 | - <div class="field-item" data-class="<?php echo esc_attr( get_class( $this ) ); ?>" style="position: relative; <?php echo esc_attr( $this->args['style'] ); ?>"> |
|
| 344 | + <div class="field-item" data-class="<?php echo esc_attr(get_class($this)); ?>" style="position: relative; <?php echo esc_attr($this->args['style']); ?>"> |
|
| 345 | 345 | |
| 346 | - <?php if ( $this->args['repeatable'] ) : ?> |
|
| 347 | - <button class="cmb-delete-field" title="<?php echo esc_attr( $this->args['string-delete-field'] ); ?>"> |
|
| 346 | + <?php if ($this->args['repeatable']) : ?> |
|
| 347 | + <button class="cmb-delete-field" title="<?php echo esc_attr($this->args['string-delete-field']); ?>"> |
|
| 348 | 348 | <span class="cmb-delete-field-icon">×</span> |
| 349 | 349 | </button> |
| 350 | 350 | <?php endif; ?> |
@@ -360,17 +360,17 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | // Insert a hidden one if it's repeatable |
| 363 | - if ( $this->args['repeatable'] ) { |
|
| 363 | + if ($this->args['repeatable']) { |
|
| 364 | 364 | |
| 365 | 365 | $this->field_index = 'x'; // x used to distinguish hidden fields. |
| 366 | 366 | $this->value = ''; ?> |
| 367 | 367 | |
| 368 | - <div class="field-item hidden" data-class="<?php echo esc_attr( get_class( $this ) ); ?>" style="position: relative; <?php echo esc_attr( $this->args['style'] ); ?>"> |
|
| 368 | + <div class="field-item hidden" data-class="<?php echo esc_attr(get_class($this)); ?>" style="position: relative; <?php echo esc_attr($this->args['style']); ?>"> |
|
| 369 | 369 | |
| 370 | - <?php if ( $this->args['repeatable'] ) : ?> |
|
| 371 | - <button class="cmb-delete-field" title="<?php echo esc_attr( $this->args['string-delete-field'] ); ?>"> |
|
| 370 | + <?php if ($this->args['repeatable']) : ?> |
|
| 371 | + <button class="cmb-delete-field" title="<?php echo esc_attr($this->args['string-delete-field']); ?>"> |
|
| 372 | 372 | <span class="cmb-delete-field-icon">×</span> |
| 373 | - <?php echo esc_html( $this->args['string-delete-field'] ); ?> |
|
| 373 | + <?php echo esc_html($this->args['string-delete-field']); ?> |
|
| 374 | 374 | </button> |
| 375 | 375 | <?php endif; ?> |
| 376 | 376 | |
@@ -378,7 +378,7 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | </div> |
| 380 | 380 | |
| 381 | - <button class="button repeat-field"><?php echo esc_html( $this->args['string-repeat-field'] ); ?></button> |
|
| 381 | + <button class="button repeat-field"><?php echo esc_html($this->args['string-repeat-field']); ?></button> |
|
| 382 | 382 | |
| 383 | 383 | <?php } |
| 384 | 384 | |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | |
| 396 | 396 | public function html() { ?> |
| 397 | 397 | |
| 398 | - <input type="text" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr( $this->get_value() ); ?>" /> |
|
| 398 | + <input type="text" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr($this->get_value()); ?>" /> |
|
| 399 | 399 | |
| 400 | 400 | <?php } |
| 401 | 401 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | return array_merge( |
| 428 | 428 | parent::get_default_args(), |
| 429 | 429 | array( |
| 430 | - 'library-type' => array( 'video', 'audio', 'text', 'application' ) |
|
| 430 | + 'library-type' => array('video', 'audio', 'text', 'application') |
|
| 431 | 431 | ) |
| 432 | 432 | ); |
| 433 | 433 | } |
@@ -439,39 +439,39 @@ discard block |
||
| 439 | 439 | |
| 440 | 440 | parent::enqueue_scripts(); |
| 441 | 441 | |
| 442 | - wp_enqueue_media( array( 'post' => $post_ID )); |
|
| 443 | - wp_enqueue_script( 'cmb-file-upload', trailingslashit( CMB_URL ) . 'js/file-upload.js', array( 'jquery', 'cmb-scripts' ) ); |
|
| 442 | + wp_enqueue_media(array('post' => $post_ID)); |
|
| 443 | + wp_enqueue_script('cmb-file-upload', trailingslashit(CMB_URL) . 'js/file-upload.js', array('jquery', 'cmb-scripts')); |
|
| 444 | 444 | |
| 445 | 445 | } |
| 446 | 446 | |
| 447 | 447 | public function html() { |
| 448 | 448 | |
| 449 | - if ( $this->get_value() ) { |
|
| 450 | - $src = wp_mime_type_icon( $this->get_value() ); |
|
| 451 | - $size = getimagesize( str_replace( site_url(), ABSPATH, $src ) ); |
|
| 449 | + if ($this->get_value()) { |
|
| 450 | + $src = wp_mime_type_icon($this->get_value()); |
|
| 451 | + $size = getimagesize(str_replace(site_url(), ABSPATH, $src)); |
|
| 452 | 452 | $icon_img = '<img src="' . $src . '" ' . $size[3] . ' />'; |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $data_type = ( ! empty( $this->args['library-type'] ) ? implode( ',', $this->args['library-type'] ) : null ); |
|
| 455 | + $data_type = ( ! empty($this->args['library-type']) ? implode(',', $this->args['library-type']) : null); |
|
| 456 | 456 | |
| 457 | 457 | ?> |
| 458 | 458 | |
| 459 | - <div class="cmb-file-wrap" <?php echo 'data-type="' . esc_attr( $data_type ) . '"'; ?>> |
|
| 459 | + <div class="cmb-file-wrap" <?php echo 'data-type="' . esc_attr($data_type) . '"'; ?>> |
|
| 460 | 460 | |
| 461 | 461 | <div class="cmb-file-wrap-placeholder"></div> |
| 462 | 462 | |
| 463 | - <button class="button cmb-file-upload <?php echo esc_attr( $this->get_value() ) ? 'hidden' : '' ?>"> |
|
| 464 | - <?php esc_html_e( 'Add File', 'cmb' ); ?> |
|
| 463 | + <button class="button cmb-file-upload <?php echo esc_attr($this->get_value()) ? 'hidden' : '' ?>"> |
|
| 464 | + <?php esc_html_e('Add File', 'cmb'); ?> |
|
| 465 | 465 | </button> |
| 466 | 466 | |
| 467 | 467 | <div class="cmb-file-holder type-file <?php echo $this->get_value() ? '' : 'hidden'; ?>"> |
| 468 | 468 | |
| 469 | - <?php if ( $this->get_value() ) : ?> |
|
| 469 | + <?php if ($this->get_value()) : ?> |
|
| 470 | 470 | |
| 471 | - <?php if ( isset( $icon_img ) ) echo $icon_img; ?> |
|
| 471 | + <?php if (isset($icon_img)) echo $icon_img; ?> |
|
| 472 | 472 | |
| 473 | 473 | <div class="cmb-file-name"> |
| 474 | - <strong><?php echo esc_html( basename( get_attached_file( $this->get_value() ) ) ); ?></strong> |
|
| 474 | + <strong><?php echo esc_html(basename(get_attached_file($this->get_value()))); ?></strong> |
|
| 475 | 475 | </div> |
| 476 | 476 | |
| 477 | 477 | <?php endif; ?> |
@@ -479,13 +479,13 @@ discard block |
||
| 479 | 479 | </div> |
| 480 | 480 | |
| 481 | 481 | <button class="cmb-remove-file button <?php echo $this->get_value() ? '' : 'hidden'; ?>"> |
| 482 | - <?php esc_html_e( 'Remove', 'cmb' ); ?> |
|
| 482 | + <?php esc_html_e('Remove', 'cmb'); ?> |
|
| 483 | 483 | </button> |
| 484 | 484 | |
| 485 | 485 | <input type="hidden" |
| 486 | - <?php $this->class_attr( 'cmb-file-upload-input' ); ?> |
|
| 486 | + <?php $this->class_attr('cmb-file-upload-input'); ?> |
|
| 487 | 487 | <?php $this->name_attr(); ?> |
| 488 | - value="<?php echo esc_attr( $this->value ); ?>" |
|
| 488 | + value="<?php echo esc_attr($this->value); ?>" |
|
| 489 | 489 | /> |
| 490 | 490 | |
| 491 | 491 | </div> |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | parent::get_default_args(), |
| 507 | 507 | array( |
| 508 | 508 | 'size' => 'thumbnail', |
| 509 | - 'library-type' => array( 'image' ), |
|
| 509 | + 'library-type' => array('image'), |
|
| 510 | 510 | 'show_size' => false |
| 511 | 511 | ) |
| 512 | 512 | ); |
@@ -514,52 +514,52 @@ discard block |
||
| 514 | 514 | |
| 515 | 515 | public function html() { |
| 516 | 516 | |
| 517 | - if ( $this->get_value() ) |
|
| 518 | - $image = wp_get_attachment_image_src( $this->get_value(), $this->args['size'], true ); |
|
| 517 | + if ($this->get_value()) |
|
| 518 | + $image = wp_get_attachment_image_src($this->get_value(), $this->args['size'], true); |
|
| 519 | 519 | |
| 520 | 520 | // Convert size arg to array of width, height, crop |
| 521 | - $size = $this->parse_image_size( $this->args['size'] ); |
|
| 521 | + $size = $this->parse_image_size($this->args['size']); |
|
| 522 | 522 | |
| 523 | 523 | // Inline styles |
| 524 | - $styles = sprintf( 'width: %1$dpx; height: %2$dpx; line-height: %2$dpx', intval( $size['width'] ), intval( $size['height'] ) ); |
|
| 525 | - $placeholder_styles = sprintf( 'width: %dpx; height: %dpx;', intval( $size['width'] ) - 8, intval( $size['height'] ) - 8 ); |
|
| 524 | + $styles = sprintf('width: %1$dpx; height: %2$dpx; line-height: %2$dpx', intval($size['width']), intval($size['height'])); |
|
| 525 | + $placeholder_styles = sprintf('width: %dpx; height: %dpx;', intval($size['width']) - 8, intval($size['height']) - 8); |
|
| 526 | 526 | |
| 527 | - $data_type = ( ! empty( $this->args['library-type'] ) ? implode( ',', $this->args['library-type'] ) : null ); |
|
| 527 | + $data_type = ( ! empty($this->args['library-type']) ? implode(',', $this->args['library-type']) : null); |
|
| 528 | 528 | |
| 529 | 529 | ?> |
| 530 | 530 | |
| 531 | - <div class="cmb-file-wrap" style="<?php echo esc_attr( $styles ); ?>" data-type="<?php echo esc_attr( $data_type ); ?>"> |
|
| 531 | + <div class="cmb-file-wrap" style="<?php echo esc_attr($styles); ?>" data-type="<?php echo esc_attr($data_type); ?>"> |
|
| 532 | 532 | |
| 533 | - <div class="cmb-file-wrap-placeholder" style="<?php echo esc_attr( $placeholder_styles ); ?>"> |
|
| 533 | + <div class="cmb-file-wrap-placeholder" style="<?php echo esc_attr($placeholder_styles); ?>"> |
|
| 534 | 534 | |
| 535 | - <?php if ( $this->args['show_size'] ) : ?> |
|
| 535 | + <?php if ($this->args['show_size']) : ?> |
|
| 536 | 536 | <span class="dimensions"> |
| 537 | - <?php printf( '%dpx × %dpx', intval( $size['width'] ), intval( $size['height'] ) ); ?> |
|
| 537 | + <?php printf('%dpx × %dpx', intval($size['width']), intval($size['height'])); ?> |
|
| 538 | 538 | </span> |
| 539 | 539 | <?php endif; ?> |
| 540 | 540 | |
| 541 | 541 | </div> |
| 542 | 542 | |
| 543 | - <button class="button cmb-file-upload <?php echo esc_attr( $this->get_value() ) ? 'hidden' : '' ?>" data-nonce="<?php echo wp_create_nonce( 'cmb-file-upload-nonce' ); ?>"> |
|
| 544 | - <?php esc_html_e( 'Select', 'cmb' ); ?> |
|
| 543 | + <button class="button cmb-file-upload <?php echo esc_attr($this->get_value()) ? 'hidden' : '' ?>" data-nonce="<?php echo wp_create_nonce('cmb-file-upload-nonce'); ?>"> |
|
| 544 | + <?php esc_html_e('Select', 'cmb'); ?> |
|
| 545 | 545 | </button> |
| 546 | 546 | |
| 547 | 547 | <div class="cmb-file-holder type-img <?php echo $this->get_value() ? '' : 'hidden'; ?>" data-crop="<?php echo (bool) $size['crop']; ?>"> |
| 548 | 548 | |
| 549 | - <?php if ( ! empty( $image ) ) : ?> |
|
| 550 | - <img src="<?php echo esc_url( $image[0] ); ?>" width="<?php echo intval( $image[1] ); ?>" height="<?php echo intval( $image[2] ); ?>" /> |
|
| 549 | + <?php if ( ! empty($image)) : ?> |
|
| 550 | + <img src="<?php echo esc_url($image[0]); ?>" width="<?php echo intval($image[1]); ?>" height="<?php echo intval($image[2]); ?>" /> |
|
| 551 | 551 | <?php endif; ?> |
| 552 | 552 | |
| 553 | 553 | </div> |
| 554 | 554 | |
| 555 | 555 | <button class="cmb-remove-file button <?php echo $this->get_value() ? '' : 'hidden'; ?>"> |
| 556 | - <?php esc_html_e( 'Remove', 'cmb' ); ?> |
|
| 556 | + <?php esc_html_e('Remove', 'cmb'); ?> |
|
| 557 | 557 | </button> |
| 558 | 558 | |
| 559 | 559 | <input type="hidden" |
| 560 | - <?php $this->class_attr( 'cmb-file-upload-input' ); ?> |
|
| 560 | + <?php $this->class_attr('cmb-file-upload-input'); ?> |
|
| 561 | 561 | <?php $this->name_attr(); ?> |
| 562 | - value="<?php echo esc_attr( $this->value ); ?>" |
|
| 562 | + value="<?php echo esc_attr($this->value); ?>" |
|
| 563 | 563 | /> |
| 564 | 564 | |
| 565 | 565 | </div> |
@@ -572,20 +572,20 @@ discard block |
||
| 572 | 572 | * @param string $size |
| 573 | 573 | * @return array width, height, crop |
| 574 | 574 | */ |
| 575 | - private function parse_image_size( $size ) { |
|
| 575 | + private function parse_image_size($size) { |
|
| 576 | 576 | |
| 577 | 577 | // Handle string for built-in image sizes |
| 578 | - if ( is_string( $size ) && in_array( $size, array( 'thumbnail', 'medium', 'large' ) ) ) { |
|
| 578 | + if (is_string($size) && in_array($size, array('thumbnail', 'medium', 'large'))) { |
|
| 579 | 579 | return array( |
| 580 | - 'width' => get_option( $size . '_size_w' ), |
|
| 581 | - 'height' => get_option( $size . '_size_h' ), |
|
| 582 | - 'crop' => get_option( $size . '_crop' ) |
|
| 580 | + 'width' => get_option($size . '_size_w'), |
|
| 581 | + 'height' => get_option($size . '_size_h'), |
|
| 582 | + 'crop' => get_option($size . '_crop') |
|
| 583 | 583 | ); |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | // Handle string for additional image sizes |
| 587 | 587 | global $_wp_additional_image_sizes; |
| 588 | - if ( is_string( $size ) && isset( $_wp_additional_image_sizes[$size] ) ) { |
|
| 588 | + if (is_string($size) && isset($_wp_additional_image_sizes[$size])) { |
|
| 589 | 589 | return array( |
| 590 | 590 | 'width' => $_wp_additional_image_sizes[$size]['width'], |
| 591 | 591 | 'height' => $_wp_additional_image_sizes[$size]['height'], |
@@ -594,14 +594,14 @@ discard block |
||
| 594 | 594 | } |
| 595 | 595 | |
| 596 | 596 | // Handle default WP size format. |
| 597 | - if ( is_array( $size ) && isset( $size[0] ) && isset( $size[1] ) ) |
|
| 598 | - $size = array( 'width' => $size[0], 'height' => $size[1] ); |
|
| 597 | + if (is_array($size) && isset($size[0]) && isset($size[1])) |
|
| 598 | + $size = array('width' => $size[0], 'height' => $size[1]); |
|
| 599 | 599 | |
| 600 | - return wp_parse_args( $size, array( |
|
| 601 | - 'width' => get_option( 'thumbnail_size_w' ), |
|
| 602 | - 'height' => get_option( 'thumbnail_size_h' ), |
|
| 603 | - 'crop' => get_option( 'thumbnail_crop' ) |
|
| 604 | - ) ); |
|
| 600 | + return wp_parse_args($size, array( |
|
| 601 | + 'width' => get_option('thumbnail_size_w'), |
|
| 602 | + 'height' => get_option('thumbnail_size_h'), |
|
| 603 | + 'crop' => get_option('thumbnail_crop') |
|
| 604 | + )); |
|
| 605 | 605 | |
| 606 | 606 | } |
| 607 | 607 | |
@@ -612,25 +612,25 @@ discard block |
||
| 612 | 612 | */ |
| 613 | 613 | static function request_image_ajax_callback() { |
| 614 | 614 | |
| 615 | - if ( ! ( isset( $_POST['nonce'] ) && wp_verify_nonce( $_POST['nonce'], 'cmb-file-upload-nonce' ) ) ) |
|
| 615 | + if ( ! (isset($_POST['nonce']) && wp_verify_nonce($_POST['nonce'], 'cmb-file-upload-nonce'))) |
|
| 616 | 616 | return; |
| 617 | 617 | |
| 618 | - $id = intval( $_POST['id'] ); |
|
| 618 | + $id = intval($_POST['id']); |
|
| 619 | 619 | |
| 620 | 620 | $size = array( |
| 621 | - intval( $_POST['width'] ), |
|
| 622 | - intval( $_POST['height'] ), |
|
| 621 | + intval($_POST['width']), |
|
| 622 | + intval($_POST['height']), |
|
| 623 | 623 | 'crop' => (bool) $_POST['crop'] |
| 624 | 624 | ); |
| 625 | 625 | |
| 626 | - $image = wp_get_attachment_image_src( $id, $size ); |
|
| 627 | - echo reset( $image ); |
|
| 626 | + $image = wp_get_attachment_image_src($id, $size); |
|
| 627 | + echo reset($image); |
|
| 628 | 628 | |
| 629 | 629 | die(); // this is required to return a proper result |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | } |
| 633 | -add_action( 'wp_ajax_cmb_request_image', array( 'CMB_Image_Field', 'request_image_ajax_callback' ) ); |
|
| 633 | +add_action('wp_ajax_cmb_request_image', array('CMB_Image_Field', 'request_image_ajax_callback')); |
|
| 634 | 634 | |
| 635 | 635 | /** |
| 636 | 636 | * Standard text meta box for a URL. |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | |
| 650 | 650 | public function html() { ?> |
| 651 | 651 | |
| 652 | - <input step="<?php echo esc_attr( $this->args['step'] ); ?>" type="number" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_number code' ); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr( $this->value ); ?>" /> |
|
| 652 | + <input step="<?php echo esc_attr($this->args['step']); ?>" type="number" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_number code'); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr($this->value); ?>" /> |
|
| 653 | 653 | |
| 654 | 654 | <?php } |
| 655 | 655 | } |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | public function html() { ?> |
| 664 | 664 | |
| 665 | - <input type="text" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_url code' ); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr( esc_url( $this->value ) ); ?>" /> |
|
| 665 | + <input type="text" <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_url code'); ?> <?php $this->name_attr(); ?> value="<?php echo esc_attr(esc_url($this->value)); ?>" /> |
|
| 666 | 666 | |
| 667 | 667 | <?php } |
| 668 | 668 | } |
@@ -677,14 +677,14 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | parent::enqueue_scripts(); |
| 679 | 679 | |
| 680 | - wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3' ); |
|
| 680 | + wp_enqueue_style('cmb-jquery-ui', trailingslashit(CMB_URL) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3'); |
|
| 681 | 681 | |
| 682 | - wp_enqueue_script( 'cmb-datetime', trailingslashit( CMB_URL ) . 'js/field.datetime.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts' ) ); |
|
| 682 | + wp_enqueue_script('cmb-datetime', trailingslashit(CMB_URL) . 'js/field.datetime.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts')); |
|
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | public function html() { ?> |
| 686 | 686 | |
| 687 | - <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_small cmb_datepicker' ); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo esc_attr( $this->value ); ?>" /> |
|
| 687 | + <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_small cmb_datepicker'); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo esc_attr($this->value); ?>" /> |
|
| 688 | 688 | |
| 689 | 689 | <?php } |
| 690 | 690 | } |
@@ -695,15 +695,15 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | parent::enqueue_scripts(); |
| 697 | 697 | |
| 698 | - wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3' ); |
|
| 698 | + wp_enqueue_style('cmb-jquery-ui', trailingslashit(CMB_URL) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3'); |
|
| 699 | 699 | |
| 700 | - wp_enqueue_script( 'cmb-timepicker', trailingslashit( CMB_URL ) . 'js/jquery.timePicker.min.js', array( 'jquery', 'cmb-scripts' ) ); |
|
| 701 | - wp_enqueue_script( 'cmb-datetime', trailingslashit( CMB_URL ) . 'js/field.datetime.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts' ) ); |
|
| 700 | + wp_enqueue_script('cmb-timepicker', trailingslashit(CMB_URL) . 'js/jquery.timePicker.min.js', array('jquery', 'cmb-scripts')); |
|
| 701 | + wp_enqueue_script('cmb-datetime', trailingslashit(CMB_URL) . 'js/field.datetime.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts')); |
|
| 702 | 702 | } |
| 703 | 703 | |
| 704 | 704 | public function html() { ?> |
| 705 | 705 | |
| 706 | - <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_small cmb_timepicker' ); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo esc_attr( $this->value ); ?>"/> |
|
| 706 | + <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_small cmb_timepicker'); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo esc_attr($this->value); ?>"/> |
|
| 707 | 707 | |
| 708 | 708 | <?php } |
| 709 | 709 | |
@@ -719,25 +719,25 @@ discard block |
||
| 719 | 719 | |
| 720 | 720 | parent::enqueue_scripts(); |
| 721 | 721 | |
| 722 | - wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3' ); |
|
| 722 | + wp_enqueue_style('cmb-jquery-ui', trailingslashit(CMB_URL) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3'); |
|
| 723 | 723 | |
| 724 | - wp_enqueue_script( 'cmb-timepicker', trailingslashit( CMB_URL ) . 'js/jquery.timePicker.min.js', array( 'jquery', 'cmb-scripts' ) ); |
|
| 725 | - wp_enqueue_script( 'cmb-datetime', trailingslashit( CMB_URL ) . 'js/field.datetime.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts' ) ); |
|
| 724 | + wp_enqueue_script('cmb-timepicker', trailingslashit(CMB_URL) . 'js/jquery.timePicker.min.js', array('jquery', 'cmb-scripts')); |
|
| 725 | + wp_enqueue_script('cmb-datetime', trailingslashit(CMB_URL) . 'js/field.datetime.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts')); |
|
| 726 | 726 | |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | public function html() { ?> |
| 730 | 730 | |
| 731 | - <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_small cmb_datepicker' ); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo $this->value ? esc_attr( date( 'm\/d\/Y', $this->value ) ) : '' ?>" /> |
|
| 731 | + <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_small cmb_datepicker'); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo $this->value ? esc_attr(date('m\/d\/Y', $this->value)) : '' ?>" /> |
|
| 732 | 732 | |
| 733 | 733 | <?php } |
| 734 | 734 | |
| 735 | 735 | public function parse_save_values() { |
| 736 | 736 | |
| 737 | - foreach( $this->values as &$value ) |
|
| 738 | - $value = strtotime( $value ); |
|
| 737 | + foreach ($this->values as &$value) |
|
| 738 | + $value = strtotime($value); |
|
| 739 | 739 | |
| 740 | - sort( $this->values ); |
|
| 740 | + sort($this->values); |
|
| 741 | 741 | |
| 742 | 742 | } |
| 743 | 743 | |
@@ -753,16 +753,16 @@ discard block |
||
| 753 | 753 | |
| 754 | 754 | parent::enqueue_scripts(); |
| 755 | 755 | |
| 756 | - wp_enqueue_style( 'cmb-jquery-ui', trailingslashit( CMB_URL ) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3' ); |
|
| 756 | + wp_enqueue_style('cmb-jquery-ui', trailingslashit(CMB_URL) . 'css/vendor/jquery-ui/jquery-ui.css', '1.10.3'); |
|
| 757 | 757 | |
| 758 | - wp_enqueue_script( 'cmb-timepicker', trailingslashit( CMB_URL ) . 'js/jquery.timePicker.min.js', array( 'jquery', 'cmb-scripts' ) ); |
|
| 759 | - wp_enqueue_script( 'cmb-datetime', trailingslashit( CMB_URL ) . 'js/field.datetime.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts' ) ); |
|
| 758 | + wp_enqueue_script('cmb-timepicker', trailingslashit(CMB_URL) . 'js/jquery.timePicker.min.js', array('jquery', 'cmb-scripts')); |
|
| 759 | + wp_enqueue_script('cmb-datetime', trailingslashit(CMB_URL) . 'js/field.datetime.js', array('jquery', 'jquery-ui-core', 'jquery-ui-datepicker', 'cmb-scripts')); |
|
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | public function html() { ?> |
| 763 | 763 | |
| 764 | - <input <?php $this->id_attr('date'); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_small cmb_datepicker' ); ?> type="text" <?php $this->name_attr( '[date]' ); ?> value="<?php echo $this->value ? esc_attr( date( 'm\/d\/Y', $this->value ) ) : '' ?>" /> |
|
| 765 | - <input <?php $this->id_attr('time'); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_text_small cmb_timepicker' ); ?> type="text" <?php $this->name_attr( '[time]' ); ?> value="<?php echo $this->value ? esc_attr( date( 'h:i A', $this->value ) ) : '' ?>" /> |
|
| 764 | + <input <?php $this->id_attr('date'); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_small cmb_datepicker'); ?> type="text" <?php $this->name_attr('[date]'); ?> value="<?php echo $this->value ? esc_attr(date('m\/d\/Y', $this->value)) : '' ?>" /> |
|
| 765 | + <input <?php $this->id_attr('time'); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_text_small cmb_timepicker'); ?> type="text" <?php $this->name_attr('[time]'); ?> value="<?php echo $this->value ? esc_attr(date('h:i A', $this->value)) : '' ?>" /> |
|
| 766 | 766 | |
| 767 | 767 | <?php } |
| 768 | 768 | |
@@ -770,15 +770,15 @@ discard block |
||
| 770 | 770 | |
| 771 | 771 | // Convert all [date] and [time] values to a unix timestamp. |
| 772 | 772 | // If date is empty, assume delete. If time is empty, assume 00:00. |
| 773 | - foreach( $this->values as $key => &$value ) { |
|
| 774 | - if ( empty( $value['date'] ) ) |
|
| 775 | - unset( $this->values[$key] ); |
|
| 773 | + foreach ($this->values as $key => &$value) { |
|
| 774 | + if (empty($value['date'])) |
|
| 775 | + unset($this->values[$key]); |
|
| 776 | 776 | else |
| 777 | - $value = strtotime( $value['date'] . ' ' . $value['time'] ); |
|
| 777 | + $value = strtotime($value['date'] . ' ' . $value['time']); |
|
| 778 | 778 | } |
| 779 | 779 | |
| 780 | - $this->values = array_filter( $this->values ); |
|
| 781 | - sort( $this->values ); |
|
| 780 | + $this->values = array_filter($this->values); |
|
| 781 | + sort($this->values); |
|
| 782 | 782 | |
| 783 | 783 | parent::parse_save_values(); |
| 784 | 784 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | |
| 797 | 797 | public function html() { ?> |
| 798 | 798 | |
| 799 | - <textarea <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> rows="<?php echo ! empty( $this->args['rows'] ) ? esc_attr( $this->args['rows'] ) : 4; ?>" <?php $this->name_attr(); ?>><?php echo esc_html( $this->value ); ?></textarea> |
|
| 799 | + <textarea <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> rows="<?php echo ! empty($this->args['rows']) ? esc_attr($this->args['rows']) : 4; ?>" <?php $this->name_attr(); ?>><?php echo esc_html($this->value); ?></textarea> |
|
| 800 | 800 | |
| 801 | 801 | <?php } |
| 802 | 802 | |
@@ -830,13 +830,13 @@ discard block |
||
| 830 | 830 | |
| 831 | 831 | parent::enqueue_scripts(); |
| 832 | 832 | |
| 833 | - wp_enqueue_script( 'cmb-colorpicker', trailingslashit( CMB_URL ) . 'js/field.colorpicker.js', array( 'jquery', 'wp-color-picker', 'cmb-scripts' ) ); |
|
| 834 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 833 | + wp_enqueue_script('cmb-colorpicker', trailingslashit(CMB_URL) . 'js/field.colorpicker.js', array('jquery', 'wp-color-picker', 'cmb-scripts')); |
|
| 834 | + wp_enqueue_style('wp-color-picker'); |
|
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | public function html() { ?> |
| 838 | 838 | |
| 839 | - <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr( 'cmb_colorpicker cmb_text_small' ); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo esc_attr( $this->get_value() ); ?>" /> |
|
| 839 | + <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr('cmb_colorpicker cmb_text_small'); ?> type="text" <?php $this->name_attr(); ?> value="<?php echo esc_attr($this->get_value()); ?>" /> |
|
| 840 | 840 | |
| 841 | 841 | <?php } |
| 842 | 842 | |
@@ -866,14 +866,14 @@ discard block |
||
| 866 | 866 | |
| 867 | 867 | public function html() { |
| 868 | 868 | |
| 869 | - if ( $this->has_data_delegate() ) |
|
| 869 | + if ($this->has_data_delegate()) |
|
| 870 | 870 | $this->args['options'] = $this->get_delegate_data(); ?> |
| 871 | 871 | |
| 872 | - <?php foreach ( $this->args['options'] as $key => $value ): ?> |
|
| 872 | + <?php foreach ($this->args['options'] as $key => $value): ?> |
|
| 873 | 873 | |
| 874 | - <input <?php $this->id_attr( 'item-' . $key ); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> type="radio" <?php $this->name_attr(); ?> value="<?php echo esc_attr( $key ); ?>" <?php checked( $key, $this->get_value() ); ?> /> |
|
| 875 | - <label <?php $this->for_attr( 'item-' . $key ); ?> style="margin-right: 20px;"> |
|
| 876 | - <?php echo esc_html( $value ); ?> |
|
| 874 | + <input <?php $this->id_attr('item-' . $key); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> type="radio" <?php $this->name_attr(); ?> value="<?php echo esc_attr($key); ?>" <?php checked($key, $this->get_value()); ?> /> |
|
| 875 | + <label <?php $this->for_attr('item-' . $key); ?> style="margin-right: 20px;"> |
|
| 876 | + <?php echo esc_html($value); ?> |
|
| 877 | 877 | </label> |
| 878 | 878 | |
| 879 | 879 | <?php endforeach; ?> |
@@ -906,22 +906,22 @@ discard block |
||
| 906 | 906 | |
| 907 | 907 | public function html() { |
| 908 | 908 | |
| 909 | - if ( $this->has_data_delegate() ) |
|
| 909 | + if ($this->has_data_delegate()) |
|
| 910 | 910 | $this->args['options'] = $this->get_delegate_data(); ?> |
| 911 | 911 | |
| 912 | - <?php foreach ( $this->args['options'] as $key => $value ): ?> |
|
| 912 | + <?php foreach ($this->args['options'] as $key => $value): ?> |
|
| 913 | 913 | <div class="cmb-cell-2"> |
| 914 | - <input <?php $this->id_attr( 'item-' . $key ); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> type="checkbox" <?php $this->name_attr(); ?>[] value="<?php echo esc_attr( $key ); ?>" <?php checked( $key, $this->get_value() ); ?> /> |
|
| 915 | - <label <?php $this->for_attr( 'item-' . $key ); ?> style="margin-right: 20px;"> |
|
| 916 | - <?php echo esc_html( $value ); ?> |
|
| 914 | + <input <?php $this->id_attr('item-' . $key); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> type="checkbox" <?php $this->name_attr(); ?>[] value="<?php echo esc_attr($key); ?>" <?php checked($key, $this->get_value()); ?> /> |
|
| 915 | + <label <?php $this->for_attr('item-' . $key); ?> style="margin-right: 20px;"> |
|
| 916 | + <?php echo esc_html($value); ?> |
|
| 917 | 917 | </label> |
| 918 | 918 | </div> |
| 919 | 919 | <?php endforeach; ?> |
| 920 | 920 | |
| 921 | 921 | <?php } |
| 922 | 922 | |
| 923 | - public function parse_save_values(){ |
|
| 924 | - $this->values = array( $this->values ); |
|
| 923 | + public function parse_save_values() { |
|
| 924 | + $this->values = array($this->values); |
|
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | } |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | |
| 935 | 935 | public function html() { ?> |
| 936 | 936 | |
| 937 | - <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> type="checkbox" <?php $this->name_attr(); ?> value="1" <?php checked( $this->get_value() ); ?> /> |
|
| 937 | + <input <?php $this->id_attr(); ?> <?php $this->boolean_attr(); ?> <?php $this->class_attr(); ?> type="checkbox" <?php $this->name_attr(); ?> value="1" <?php checked($this->get_value()); ?> /> |
|
| 938 | 938 | |
| 939 | 939 | <?php } |
| 940 | 940 | |
@@ -952,7 +952,7 @@ discard block |
||
| 952 | 952 | |
| 953 | 953 | <div class="field-title"> |
| 954 | 954 | <h3 <?php $this->class_attr(); ?>> |
| 955 | - <?php echo esc_html( $this->title ); ?> |
|
| 955 | + <?php echo esc_html($this->title); ?> |
|
| 956 | 956 | </h3> |
| 957 | 957 | </div> |
| 958 | 958 | |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | |
| 989 | 989 | parent::enqueue_scripts(); |
| 990 | 990 | |
| 991 | - wp_enqueue_script( 'cmb-wysiwyg', trailingslashit( CMB_URL ) . 'js/field-wysiwyg.js', array( 'jquery', 'cmb-scripts' ) ); |
|
| 991 | + wp_enqueue_script('cmb-wysiwyg', trailingslashit(CMB_URL) . 'js/field-wysiwyg.js', array('jquery', 'cmb-scripts')); |
|
| 992 | 992 | } |
| 993 | 993 | |
| 994 | 994 | public function html() { |
@@ -998,17 +998,17 @@ discard block |
||
| 998 | 998 | |
| 999 | 999 | $field_id = $this->get_js_id(); |
| 1000 | 1000 | |
| 1001 | - printf( '<div class="cmb-wysiwyg" data-id="%s" data-name="%s" data-field-id="%s">', $id, $name, $field_id ); |
|
| 1001 | + printf('<div class="cmb-wysiwyg" data-id="%s" data-name="%s" data-field-id="%s">', $id, $name, $field_id); |
|
| 1002 | 1002 | |
| 1003 | - if ( $this->is_placeholder() ) { |
|
| 1003 | + if ($this->is_placeholder()) { |
|
| 1004 | 1004 | |
| 1005 | 1005 | // For placeholder, output the markup for the editor in a JS var. |
| 1006 | 1006 | ob_start(); |
| 1007 | 1007 | $this->args['options']['textarea_name'] = 'cmb-placeholder-name-' . $field_id; |
| 1008 | - wp_editor( '', 'cmb-placeholder-id-' . $field_id, $this->args['options'] ); |
|
| 1008 | + wp_editor('', 'cmb-placeholder-id-' . $field_id, $this->args['options']); |
|
| 1009 | 1009 | $editor = ob_get_clean(); |
| 1010 | - $editor = str_replace( array( "\n", "\r" ), "", $editor ); |
|
| 1011 | - $editor = str_replace( array( "'" ), '"', $editor ); |
|
| 1010 | + $editor = str_replace(array("\n", "\r"), "", $editor); |
|
| 1011 | + $editor = str_replace(array("'"), '"', $editor); |
|
| 1012 | 1012 | |
| 1013 | 1013 | ?> |
| 1014 | 1014 | |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | } else { |
| 1024 | 1024 | |
| 1025 | 1025 | $this->args['options']['textarea_name'] = $name; |
| 1026 | - echo wp_editor( $this->get_value(), $id, $this->args['options'] ); |
|
| 1026 | + echo wp_editor($this->get_value(), $id, $this->args['options']); |
|
| 1027 | 1027 | |
| 1028 | 1028 | } |
| 1029 | 1029 | |
@@ -1039,10 +1039,10 @@ discard block |
||
| 1039 | 1039 | */ |
| 1040 | 1040 | public function is_placeholder() { |
| 1041 | 1041 | |
| 1042 | - if ( isset( $this->parent ) && ! is_int( $this->parent->field_index ) ) |
|
| 1042 | + if (isset($this->parent) && ! is_int($this->parent->field_index)) |
|
| 1043 | 1043 | return true; |
| 1044 | 1044 | |
| 1045 | - else return ! is_int( $this->field_index ); |
|
| 1045 | + else return ! is_int($this->field_index); |
|
| 1046 | 1046 | |
| 1047 | 1047 | } |
| 1048 | 1048 | |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | |
| 1064 | 1064 | $args = func_get_args(); |
| 1065 | 1065 | |
| 1066 | - call_user_func_array( array( 'parent', '__construct' ), $args ); |
|
| 1066 | + call_user_func_array(array('parent', '__construct'), $args); |
|
| 1067 | 1067 | |
| 1068 | 1068 | } |
| 1069 | 1069 | |
@@ -1084,16 +1084,16 @@ discard block |
||
| 1084 | 1084 | ); |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | - public function parse_save_values(){ |
|
| 1087 | + public function parse_save_values() { |
|
| 1088 | 1088 | |
| 1089 | - if ( isset( $this->parent ) && isset( $this->args['multiple'] ) && $this->args['multiple'] ) |
|
| 1090 | - $this->values = array( $this->values ); |
|
| 1089 | + if (isset($this->parent) && isset($this->args['multiple']) && $this->args['multiple']) |
|
| 1090 | + $this->values = array($this->values); |
|
| 1091 | 1091 | |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | 1094 | public function get_options() { |
| 1095 | 1095 | |
| 1096 | - if ( $this->has_data_delegate() ) |
|
| 1096 | + if ($this->has_data_delegate()) |
|
| 1097 | 1097 | $this->args['options'] = $this->get_delegate_data(); |
| 1098 | 1098 | |
| 1099 | 1099 | return $this->args['options']; |
@@ -1117,23 +1117,23 @@ discard block |
||
| 1117 | 1117 | 'wc_product_retailer' |
| 1118 | 1118 | ); |
| 1119 | 1119 | |
| 1120 | - if ( ! in_array( $typenow, $no_enqueue ) ) { |
|
| 1121 | - wp_enqueue_script( 'select2', trailingslashit( CMB_URL ) . 'js/vendor/select2/select2.js', array( 'jquery' ) ); |
|
| 1120 | + if ( ! in_array($typenow, $no_enqueue)) { |
|
| 1121 | + wp_enqueue_script('select2', trailingslashit(CMB_URL) . 'js/vendor/select2/select2.js', array('jquery')); |
|
| 1122 | 1122 | } |
| 1123 | 1123 | |
| 1124 | - wp_enqueue_script( 'field-select', trailingslashit( CMB_URL ) . 'js/field.select.js', array( 'jquery', 'select2', 'cmb-scripts' ) ); |
|
| 1124 | + wp_enqueue_script('field-select', trailingslashit(CMB_URL) . 'js/field.select.js', array('jquery', 'select2', 'cmb-scripts')); |
|
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | 1127 | public function enqueue_styles() { |
| 1128 | 1128 | |
| 1129 | 1129 | parent::enqueue_styles(); |
| 1130 | 1130 | |
| 1131 | - wp_enqueue_style( 'select2', trailingslashit( CMB_URL ) . 'js/vendor/select2/select2.css' ); |
|
| 1131 | + wp_enqueue_style('select2', trailingslashit(CMB_URL) . 'js/vendor/select2/select2.css'); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | 1134 | public function html() { |
| 1135 | 1135 | |
| 1136 | - if ( $this->has_data_delegate() ) |
|
| 1136 | + if ($this->has_data_delegate()) |
|
| 1137 | 1137 | $this->args['options'] = $this->get_delegate_data(); |
| 1138 | 1138 | |
| 1139 | 1139 | $this->output_field(); |
@@ -1147,28 +1147,28 @@ discard block |
||
| 1147 | 1147 | $val = (array) $this->get_value(); |
| 1148 | 1148 | |
| 1149 | 1149 | $name = $this->get_the_name_attr(); |
| 1150 | - $name .= ! empty( $this->args['multiple'] ) ? '[]' : null; |
|
| 1150 | + $name .= ! empty($this->args['multiple']) ? '[]' : null; |
|
| 1151 | 1151 | |
| 1152 | - $none = is_string( $this->args['allow_none'] ) ? $this->args['allow_none'] : __( 'None', 'cmb' ); |
|
| 1152 | + $none = is_string($this->args['allow_none']) ? $this->args['allow_none'] : __('None', 'cmb'); |
|
| 1153 | 1153 | |
| 1154 | 1154 | ?> |
| 1155 | 1155 | |
| 1156 | 1156 | <select |
| 1157 | 1157 | <?php $this->id_attr(); ?> |
| 1158 | 1158 | <?php $this->boolean_attr(); ?> |
| 1159 | - <?php printf( 'name="%s"', esc_attr( $name ) ); ?> |
|
| 1160 | - <?php printf( 'data-field-id="%s" ', esc_attr( $this->get_js_id() ) ); ?> |
|
| 1161 | - <?php echo ! empty( $this->args['multiple'] ) ? 'multiple' : '' ?> |
|
| 1162 | - <?php $this->class_attr( 'cmb_select' ); ?> |
|
| 1159 | + <?php printf('name="%s"', esc_attr($name)); ?> |
|
| 1160 | + <?php printf('data-field-id="%s" ', esc_attr($this->get_js_id())); ?> |
|
| 1161 | + <?php echo ! empty($this->args['multiple']) ? 'multiple' : '' ?> |
|
| 1162 | + <?php $this->class_attr('cmb_select'); ?> |
|
| 1163 | 1163 | style="width: 100%" |
| 1164 | 1164 | > |
| 1165 | 1165 | |
| 1166 | - <?php if ( $this->args['allow_none'] ) : ?> |
|
| 1166 | + <?php if ($this->args['allow_none']) : ?> |
|
| 1167 | 1167 | <option value=""><?php echo $none; ?></option> |
| 1168 | 1168 | <?php endif; ?> |
| 1169 | 1169 | |
| 1170 | - <?php foreach ( $this->args['options'] as $value => $name ): ?> |
|
| 1171 | - <option <?php selected( in_array( $value, $val ) ) ?> value="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $name ); ?></option> |
|
| 1170 | + <?php foreach ($this->args['options'] as $value => $name): ?> |
|
| 1171 | + <option <?php selected(in_array($value, $val)) ?> value="<?php echo esc_attr($value); ?>"><?php echo esc_html($name); ?></option> |
|
| 1172 | 1172 | <?php endforeach; ?> |
| 1173 | 1173 | |
| 1174 | 1174 | </select> |
@@ -1178,10 +1178,10 @@ discard block |
||
| 1178 | 1178 | |
| 1179 | 1179 | public function output_script() { |
| 1180 | 1180 | |
| 1181 | - $options = wp_parse_args( $this->args['select2_options'], array( |
|
| 1182 | - 'placeholder' => __( 'Type to search', 'cmb' ), |
|
| 1181 | + $options = wp_parse_args($this->args['select2_options'], array( |
|
| 1182 | + 'placeholder' => __('Type to search', 'cmb'), |
|
| 1183 | 1183 | 'allowClear' => true, |
| 1184 | - ) ); |
|
| 1184 | + )); |
|
| 1185 | 1185 | |
| 1186 | 1186 | ?> |
| 1187 | 1187 | |
@@ -1189,12 +1189,12 @@ discard block |
||
| 1189 | 1189 | |
| 1190 | 1190 | (function($) { |
| 1191 | 1191 | |
| 1192 | - var options = <?php echo json_encode( $options ); ?> |
|
| 1192 | + var options = <?php echo json_encode($options); ?> |
|
| 1193 | 1193 | |
| 1194 | 1194 | if ( 'undefined' === typeof( window.cmb_select_fields ) ) |
| 1195 | 1195 | window.cmb_select_fields = {}; |
| 1196 | 1196 | |
| 1197 | - var id = <?php echo json_encode( $this->get_js_id() ); ?>; |
|
| 1197 | + var id = <?php echo json_encode($this->get_js_id()); ?>; |
|
| 1198 | 1198 | window.cmb_select_fields[id] = options; |
| 1199 | 1199 | |
| 1200 | 1200 | })( jQuery ); |
@@ -1228,9 +1228,9 @@ discard block |
||
| 1228 | 1228 | |
| 1229 | 1229 | $args = func_get_args(); |
| 1230 | 1230 | |
| 1231 | - call_user_func_array( array( 'parent', '__construct' ), $args ); |
|
| 1231 | + call_user_func_array(array('parent', '__construct'), $args); |
|
| 1232 | 1232 | |
| 1233 | - $this->args['data_delegate'] = array( $this, 'get_delegate_data' ); |
|
| 1233 | + $this->args['data_delegate'] = array($this, 'get_delegate_data'); |
|
| 1234 | 1234 | |
| 1235 | 1235 | } |
| 1236 | 1236 | |
@@ -1238,13 +1238,13 @@ discard block |
||
| 1238 | 1238 | |
| 1239 | 1239 | $terms = $this->get_terms(); |
| 1240 | 1240 | |
| 1241 | - if ( is_wp_error( $terms ) ) { |
|
| 1241 | + if (is_wp_error($terms)) { |
|
| 1242 | 1242 | return array(); |
| 1243 | 1243 | } |
| 1244 | 1244 | |
| 1245 | 1245 | $term_options = array(); |
| 1246 | 1246 | |
| 1247 | - foreach ( $terms as $term ) |
|
| 1247 | + foreach ($terms as $term) |
|
| 1248 | 1248 | $term_options[$term->term_id] = $term->name; |
| 1249 | 1249 | |
| 1250 | 1250 | return $term_options; |
@@ -1253,7 +1253,7 @@ discard block |
||
| 1253 | 1253 | |
| 1254 | 1254 | private function get_terms() { |
| 1255 | 1255 | |
| 1256 | - return get_terms( $this->args['taxonomy'], array( 'hide_empty' => $this->args['hide_empty'] ) ); |
|
| 1256 | + return get_terms($this->args['taxonomy'], array('hide_empty' => $this->args['hide_empty'])); |
|
| 1257 | 1257 | |
| 1258 | 1258 | } |
| 1259 | 1259 | |
@@ -1274,11 +1274,11 @@ discard block |
||
| 1274 | 1274 | |
| 1275 | 1275 | $args = func_get_args(); |
| 1276 | 1276 | |
| 1277 | - call_user_func_array( array( 'parent', '__construct' ), $args ); |
|
| 1277 | + call_user_func_array(array('parent', '__construct'), $args); |
|
| 1278 | 1278 | |
| 1279 | - if ( ! $this->args['use_ajax'] ) { |
|
| 1279 | + if ( ! $this->args['use_ajax']) { |
|
| 1280 | 1280 | |
| 1281 | - $this->args['data_delegate'] = array( $this, 'get_delegate_data' ); |
|
| 1281 | + $this->args['data_delegate'] = array($this, 'get_delegate_data'); |
|
| 1282 | 1282 | |
| 1283 | 1283 | } |
| 1284 | 1284 | |
@@ -1304,8 +1304,8 @@ discard block |
||
| 1304 | 1304 | |
| 1305 | 1305 | $data = array(); |
| 1306 | 1306 | |
| 1307 | - foreach ( $this->get_posts() as $post_id ) |
|
| 1308 | - $data[$post_id] = get_the_title( $post_id ); |
|
| 1307 | + foreach ($this->get_posts() as $post_id) |
|
| 1308 | + $data[$post_id] = get_the_title($post_id); |
|
| 1309 | 1309 | |
| 1310 | 1310 | return $data; |
| 1311 | 1311 | |
@@ -1314,9 +1314,9 @@ discard block |
||
| 1314 | 1314 | private function get_posts() { |
| 1315 | 1315 | |
| 1316 | 1316 | $this->args['query']['fields'] = 'ids'; |
| 1317 | - $query = new WP_Query( $this->args['query'] ); |
|
| 1317 | + $query = new WP_Query($this->args['query']); |
|
| 1318 | 1318 | |
| 1319 | - return isset( $query->posts ) ? $query->posts : array(); |
|
| 1319 | + return isset($query->posts) ? $query->posts : array(); |
|
| 1320 | 1320 | |
| 1321 | 1321 | } |
| 1322 | 1322 | |
@@ -1324,8 +1324,8 @@ discard block |
||
| 1324 | 1324 | |
| 1325 | 1325 | // AJAX multi select2 data is submitted as a string of comma separated post IDs. |
| 1326 | 1326 | // If empty, set to false instead of empty array to ensure the meta entry is deleted. |
| 1327 | - if ( $this->args['use_ajax'] && $this->args['multiple'] ) { |
|
| 1328 | - $this->value = ( ! empty( $this->value ) ) ? explode( ',', $this->value ) : false; |
|
| 1327 | + if ($this->args['use_ajax'] && $this->args['multiple']) { |
|
| 1328 | + $this->value = ( ! empty($this->value)) ? explode(',', $this->value) : false; |
|
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | 1331 | } |
@@ -1333,15 +1333,15 @@ discard block |
||
| 1333 | 1333 | public function output_field() { |
| 1334 | 1334 | |
| 1335 | 1335 | // If AJAX, must use input type not standard select. |
| 1336 | - if ( $this->args['use_ajax'] ) : |
|
| 1336 | + if ($this->args['use_ajax']) : |
|
| 1337 | 1337 | |
| 1338 | 1338 | ?> |
| 1339 | 1339 | |
| 1340 | 1340 | <input |
| 1341 | 1341 | <?php $this->id_attr(); ?> |
| 1342 | - <?php printf( 'value="%s" ', esc_attr( implode( ',' , (array) $this->value ) ) ); ?> |
|
| 1343 | - <?php printf( 'name="%s"', esc_attr( $this->get_the_name_attr() ) ); ?> |
|
| 1344 | - <?php printf( 'data-field-id="%s" ', esc_attr( $this->get_js_id() ) ); ?> |
|
| 1342 | + <?php printf('value="%s" ', esc_attr(implode(',', (array) $this->value))); ?> |
|
| 1343 | + <?php printf('name="%s"', esc_attr($this->get_the_name_attr())); ?> |
|
| 1344 | + <?php printf('data-field-id="%s" ', esc_attr($this->get_js_id())); ?> |
|
| 1345 | 1345 | <?php $this->boolean_attr(); ?> |
| 1346 | 1346 | class="cmb_select" |
| 1347 | 1347 | style="width: 100%" |
@@ -1371,29 +1371,29 @@ discard block |
||
| 1371 | 1371 | return false; |
| 1372 | 1372 | |
| 1373 | 1373 | // Get options for this field so we can modify it. |
| 1374 | - var id = <?php echo json_encode( $this->get_js_id() ); ?>; |
|
| 1374 | + var id = <?php echo json_encode($this->get_js_id()); ?>; |
|
| 1375 | 1375 | var options = window.cmb_select_fields[id]; |
| 1376 | 1376 | |
| 1377 | - <?php if ( $this->args['use_ajax'] && $this->args['multiple'] ) : ?> |
|
| 1377 | + <?php if ($this->args['use_ajax'] && $this->args['multiple']) : ?> |
|
| 1378 | 1378 | // The multiple setting is required when using ajax (because an input field is used instead of select) |
| 1379 | 1379 | options.multiple = true; |
| 1380 | 1380 | <?php endif; ?> |
| 1381 | 1381 | |
| 1382 | - <?php if ( $this->args['use_ajax'] && ! empty( $this->value ) ) : ?> |
|
| 1382 | + <?php if ($this->args['use_ajax'] && ! empty($this->value)) : ?> |
|
| 1383 | 1383 | |
| 1384 | 1384 | options.initSelection = function( element, callback ) { |
| 1385 | 1385 | |
| 1386 | 1386 | var data = []; |
| 1387 | 1387 | |
| 1388 | - <?php if ( $this->args['multiple'] ) : ?> |
|
| 1388 | + <?php if ($this->args['multiple']) : ?> |
|
| 1389 | 1389 | |
| 1390 | - <?php foreach ( (array) $this->value as $post_id ) : ?> |
|
| 1391 | - data.push( <?php echo json_encode( array( 'id' => $post_id, 'text' => html_entity_decode( get_the_title( $post_id ) ) ) ); ?> ); |
|
| 1390 | + <?php foreach ((array) $this->value as $post_id) : ?> |
|
| 1391 | + data.push( <?php echo json_encode(array('id' => $post_id, 'text' => html_entity_decode(get_the_title($post_id)))); ?> ); |
|
| 1392 | 1392 | <?php endforeach; ?> |
| 1393 | 1393 | |
| 1394 | 1394 | <?php else : ?> |
| 1395 | 1395 | |
| 1396 | - data = <?php echo json_encode( array( 'id' => $this->value, 'text' => html_entity_decode( get_the_title( $this->get_value() ) ) ) ); ?>; |
|
| 1396 | + data = <?php echo json_encode(array('id' => $this->value, 'text' => html_entity_decode(get_the_title($this->get_value())))); ?>; |
|
| 1397 | 1397 | |
| 1398 | 1398 | <?php endif; ?> |
| 1399 | 1399 | |
@@ -1403,19 +1403,19 @@ discard block |
||
| 1403 | 1403 | |
| 1404 | 1404 | <?php endif; ?> |
| 1405 | 1405 | |
| 1406 | - <?php if ( $this->args['use_ajax'] ) : ?> |
|
| 1406 | + <?php if ($this->args['use_ajax']) : ?> |
|
| 1407 | 1407 | |
| 1408 | 1408 | <?php $this->args['query']['fields'] = 'ids'; ?> |
| 1409 | 1409 | |
| 1410 | 1410 | var ajaxData = { |
| 1411 | 1411 | action : 'cmb_post_select', |
| 1412 | - post_id : '<?php echo intval( get_the_id() ); ?>', // Used for user capabilty check. |
|
| 1413 | - nonce : <?php echo json_encode( wp_create_nonce( 'cmb_select_field' ) ); ?>, |
|
| 1414 | - query : <?php echo json_encode( $this->args['query'] ); ?> |
|
| 1412 | + post_id : '<?php echo intval(get_the_id()); ?>', // Used for user capabilty check. |
|
| 1413 | + nonce : <?php echo json_encode(wp_create_nonce('cmb_select_field')); ?>, |
|
| 1414 | + query : <?php echo json_encode($this->args['query']); ?> |
|
| 1415 | 1415 | }; |
| 1416 | 1416 | |
| 1417 | 1417 | options.ajax = { |
| 1418 | - url: <?php echo json_encode( esc_url( admin_url( 'admin-ajax.php' ) ) ); ?>, |
|
| 1418 | + url: <?php echo json_encode(esc_url(admin_url('admin-ajax.php'))); ?>, |
|
| 1419 | 1419 | type: 'POST', |
| 1420 | 1420 | dataType: 'json', |
| 1421 | 1421 | data: function( term, page ) { |
@@ -1444,31 +1444,31 @@ discard block |
||
| 1444 | 1444 | // TODO this should be in inside the class |
| 1445 | 1445 | function cmb_ajax_post_select() { |
| 1446 | 1446 | |
| 1447 | - $post_id = ! empty( $_POST['post_id'] ) ? intval( $_POST['post_id'] ) : false; |
|
| 1448 | - $nonce = ! empty( $_POST['nonce'] ) ? $_POST['nonce'] : false; |
|
| 1449 | - $args = ! empty( $_POST['query'] ) ? $_POST['query'] : array(); |
|
| 1447 | + $post_id = ! empty($_POST['post_id']) ? intval($_POST['post_id']) : false; |
|
| 1448 | + $nonce = ! empty($_POST['nonce']) ? $_POST['nonce'] : false; |
|
| 1449 | + $args = ! empty($_POST['query']) ? $_POST['query'] : array(); |
|
| 1450 | 1450 | |
| 1451 | - if ( ! $nonce || ! wp_verify_nonce( $nonce, 'cmb_select_field' ) || ! current_user_can( 'edit_post', $post_id ) ) { |
|
| 1452 | - echo json_encode( array( 'total' => 0, 'posts' => array() ) ); |
|
| 1451 | + if ( ! $nonce || ! wp_verify_nonce($nonce, 'cmb_select_field') || ! current_user_can('edit_post', $post_id)) { |
|
| 1452 | + echo json_encode(array('total' => 0, 'posts' => array())); |
|
| 1453 | 1453 | exit; |
| 1454 | 1454 | } |
| 1455 | 1455 | |
| 1456 | 1456 | $args['fields'] = 'ids'; // Only need to retrieve post IDs. |
| 1457 | 1457 | |
| 1458 | - $query = new WP_Query( $args ); |
|
| 1458 | + $query = new WP_Query($args); |
|
| 1459 | 1459 | |
| 1460 | - $json = array( 'total' => $query->found_posts, 'posts' => array() ); |
|
| 1460 | + $json = array('total' => $query->found_posts, 'posts' => array()); |
|
| 1461 | 1461 | |
| 1462 | - foreach ( $query->posts as $post_id ) { |
|
| 1463 | - array_push( $json['posts'], array( 'id' => $post_id, 'text' => html_entity_decode( get_the_title( $post_id ) ) ) ); |
|
| 1462 | + foreach ($query->posts as $post_id) { |
|
| 1463 | + array_push($json['posts'], array('id' => $post_id, 'text' => html_entity_decode(get_the_title($post_id)))); |
|
| 1464 | 1464 | } |
| 1465 | 1465 | |
| 1466 | - echo json_encode( $json ); |
|
| 1466 | + echo json_encode($json); |
|
| 1467 | 1467 | |
| 1468 | 1468 | exit; |
| 1469 | 1469 | |
| 1470 | 1470 | } |
| 1471 | -add_action( 'wp_ajax_cmb_post_select', 'cmb_ajax_post_select' ); |
|
| 1471 | +add_action('wp_ajax_cmb_post_select', 'cmb_ajax_post_select'); |
|
| 1472 | 1472 | |
| 1473 | 1473 | /** |
| 1474 | 1474 | * Field to group child fieids |
@@ -1485,13 +1485,13 @@ discard block |
||
| 1485 | 1485 | function __construct() { |
| 1486 | 1486 | |
| 1487 | 1487 | $args = func_get_args(); // you can't just put func_get_args() into a function as a parameter |
| 1488 | - call_user_func_array( array( 'parent', '__construct' ), $args ); |
|
| 1488 | + call_user_func_array(array('parent', '__construct'), $args); |
|
| 1489 | 1489 | |
| 1490 | - if ( ! empty( $this->args['fields'] ) ) { |
|
| 1491 | - foreach ( $this->args['fields'] as $f ) { |
|
| 1490 | + if ( ! empty($this->args['fields'])) { |
|
| 1491 | + foreach ($this->args['fields'] as $f) { |
|
| 1492 | 1492 | |
| 1493 | - $class = _cmb_field_class_for_type( $f['type'] ); |
|
| 1494 | - $this->add_field( new $class( $f['id'], $f['name'], array(), $f ) ); |
|
| 1493 | + $class = _cmb_field_class_for_type($f['type']); |
|
| 1494 | + $this->add_field(new $class($f['id'], $f['name'], array(), $f)); |
|
| 1495 | 1495 | |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
@@ -1508,8 +1508,8 @@ discard block |
||
| 1508 | 1508 | parent::get_default_args(), |
| 1509 | 1509 | array( |
| 1510 | 1510 | 'fields' => array(), |
| 1511 | - 'string-repeat-field' => __( 'Add New Group', 'cmb' ), |
|
| 1512 | - 'string-delete-field' => __( 'Remove Group', 'cmb' ), |
|
| 1511 | + 'string-repeat-field' => __('Add New Group', 'cmb'), |
|
| 1512 | + 'string-delete-field' => __('Remove Group', 'cmb'), |
|
| 1513 | 1513 | ) |
| 1514 | 1514 | ); |
| 1515 | 1515 | } |
@@ -1518,9 +1518,9 @@ discard block |
||
| 1518 | 1518 | |
| 1519 | 1519 | parent::enqueue_scripts(); |
| 1520 | 1520 | |
| 1521 | - foreach ( $this->args['fields'] as $f ) { |
|
| 1522 | - $class = _cmb_field_class_for_type( $f['type'] ); |
|
| 1523 | - $field = new $class( '', '', array(), $f ); |
|
| 1521 | + foreach ($this->args['fields'] as $f) { |
|
| 1522 | + $class = _cmb_field_class_for_type($f['type']); |
|
| 1523 | + $field = new $class('', '', array(), $f); |
|
| 1524 | 1524 | $field->enqueue_scripts(); |
| 1525 | 1525 | } |
| 1526 | 1526 | |
@@ -1530,9 +1530,9 @@ discard block |
||
| 1530 | 1530 | |
| 1531 | 1531 | parent::enqueue_styles(); |
| 1532 | 1532 | |
| 1533 | - foreach ( $this->args['fields'] as $f ) { |
|
| 1534 | - $class = _cmb_field_class_for_type( $f['type'] ); |
|
| 1535 | - $field = new $class( '', '', array(), $f ); |
|
| 1533 | + foreach ($this->args['fields'] as $f) { |
|
| 1534 | + $class = _cmb_field_class_for_type($f['type']); |
|
| 1535 | + $field = new $class('', '', array(), $f); |
|
| 1536 | 1536 | $field->enqueue_styles(); |
| 1537 | 1537 | } |
| 1538 | 1538 | |
@@ -1548,21 +1548,21 @@ discard block |
||
| 1548 | 1548 | $this->title(); |
| 1549 | 1549 | $this->description(); |
| 1550 | 1550 | |
| 1551 | - if ( ! $this->args['repeatable'] && empty( $values ) ) { |
|
| 1552 | - $values = array( null ); |
|
| 1551 | + if ( ! $this->args['repeatable'] && empty($values)) { |
|
| 1552 | + $values = array(null); |
|
| 1553 | 1553 | } |
| 1554 | 1554 | |
| 1555 | - if ( $values ) { |
|
| 1555 | + if ($values) { |
|
| 1556 | 1556 | |
| 1557 | 1557 | $i = 0; |
| 1558 | - foreach ( $values as $value ) { |
|
| 1558 | + foreach ($values as $value) { |
|
| 1559 | 1559 | |
| 1560 | 1560 | $this->field_index = $i; |
| 1561 | 1561 | $this->value = $value; |
| 1562 | 1562 | |
| 1563 | 1563 | ?> |
| 1564 | 1564 | |
| 1565 | - <div class="field-item" data-class="<?php echo esc_attr( get_class($this) ) ?>" style="<?php echo esc_attr( $this->args['style'] ); ?>"> |
|
| 1565 | + <div class="field-item" data-class="<?php echo esc_attr(get_class($this)) ?>" style="<?php echo esc_attr($this->args['style']); ?>"> |
|
| 1566 | 1566 | <?php $this->html(); ?> |
| 1567 | 1567 | </div> |
| 1568 | 1568 | |
@@ -1574,20 +1574,20 @@ discard block |
||
| 1574 | 1574 | |
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | - if ( $this->args['repeatable'] ) { |
|
| 1577 | + if ($this->args['repeatable']) { |
|
| 1578 | 1578 | |
| 1579 | 1579 | $this->field_index = 'x'; // x used to distinguish hidden fields. |
| 1580 | 1580 | $this->value = ''; |
| 1581 | 1581 | |
| 1582 | 1582 | ?> |
| 1583 | 1583 | |
| 1584 | - <div class="field-item hidden" data-class="<?php echo esc_attr( get_class( $this ) ); ?>" style="<?php echo esc_attr( $this->args['style'] ); ?>"> |
|
| 1584 | + <div class="field-item hidden" data-class="<?php echo esc_attr(get_class($this)); ?>" style="<?php echo esc_attr($this->args['style']); ?>"> |
|
| 1585 | 1585 | <?php $this->html(); ?> |
| 1586 | 1586 | </div> |
| 1587 | 1587 | |
| 1588 | 1588 | <?php |
| 1589 | 1589 | $button_name = 'Group'; |
| 1590 | - if(isset($this->args['single_name'])){ |
|
| 1590 | + if (isset($this->args['single_name'])) { |
|
| 1591 | 1591 | $button_name = $this->args['single_name']; |
| 1592 | 1592 | }?> |
| 1593 | 1593 | <button class="button repeat-field"> |
@@ -1604,28 +1604,28 @@ discard block |
||
| 1604 | 1604 | $value = $this->get_value(); |
| 1605 | 1605 | |
| 1606 | 1606 | // Reset all field values. |
| 1607 | - foreach ( $fields as $field ) { |
|
| 1608 | - $field->set_values( array() ); |
|
| 1607 | + foreach ($fields as $field) { |
|
| 1608 | + $field->set_values(array()); |
|
| 1609 | 1609 | } |
| 1610 | 1610 | |
| 1611 | 1611 | // Set values for this field. |
| 1612 | - if ( ! empty( $value ) ) { |
|
| 1613 | - foreach ( $value as $field_id => $field_value ) { |
|
| 1614 | - $field_value = ( ! empty( $field_value ) ) ? $field_value : array(); |
|
| 1615 | - if ( ! empty( $fields[$field_id] ) ) { |
|
| 1616 | - $fields[$field_id]->set_values( (array) $field_value ); |
|
| 1612 | + if ( ! empty($value)) { |
|
| 1613 | + foreach ($value as $field_id => $field_value) { |
|
| 1614 | + $field_value = ( ! empty($field_value)) ? $field_value : array(); |
|
| 1615 | + if ( ! empty($fields[$field_id])) { |
|
| 1616 | + $fields[$field_id]->set_values((array) $field_value); |
|
| 1617 | 1617 | } |
| 1618 | 1618 | } |
| 1619 | 1619 | } |
| 1620 | 1620 | |
| 1621 | 1621 | ?> |
| 1622 | 1622 | |
| 1623 | - <?php if ( $this->args['repeatable'] ) : ?> |
|
| 1623 | + <?php if ($this->args['repeatable']) : ?> |
|
| 1624 | 1624 | |
| 1625 | 1625 | |
| 1626 | 1626 | <?php |
| 1627 | 1627 | $button_name = 'Group'; |
| 1628 | - if(isset($this->args['single_name'])){ |
|
| 1628 | + if (isset($this->args['single_name'])) { |
|
| 1629 | 1629 | $button_name = $this->args['single_name']; |
| 1630 | 1630 | }?> |
| 1631 | 1631 | |
@@ -1638,7 +1638,7 @@ discard block |
||
| 1638 | 1638 | </button> |
| 1639 | 1639 | <?php endif; ?> |
| 1640 | 1640 | |
| 1641 | - <?php CMB_Meta_Box::layout_fields( $fields ); ?> |
|
| 1641 | + <?php CMB_Meta_Box::layout_fields($fields); ?> |
|
| 1642 | 1642 | |
| 1643 | 1643 | <?php } |
| 1644 | 1644 | |
@@ -1647,30 +1647,30 @@ discard block |
||
| 1647 | 1647 | $fields = &$this->get_fields(); |
| 1648 | 1648 | $values = &$this->get_values(); |
| 1649 | 1649 | |
| 1650 | - foreach ( $values as &$group_value ) { |
|
| 1651 | - foreach ( $group_value as $field_id => &$field_value ) { |
|
| 1650 | + foreach ($values as &$group_value) { |
|
| 1651 | + foreach ($group_value as $field_id => &$field_value) { |
|
| 1652 | 1652 | |
| 1653 | - if ( ! isset( $fields[$field_id] ) ) { |
|
| 1653 | + if ( ! isset($fields[$field_id])) { |
|
| 1654 | 1654 | $field_value = array(); |
| 1655 | 1655 | continue; |
| 1656 | 1656 | } |
| 1657 | 1657 | |
| 1658 | 1658 | $field = $fields[$field_id]; |
| 1659 | - $field->set_values( $field_value ); |
|
| 1659 | + $field->set_values($field_value); |
|
| 1660 | 1660 | $field->parse_save_values(); |
| 1661 | 1661 | |
| 1662 | 1662 | $field_value = $field->get_values(); |
| 1663 | 1663 | |
| 1664 | 1664 | // if the field is a repeatable field, store the whole array of them, if it's not repeatble, |
| 1665 | 1665 | // just store the first (and only) one directly |
| 1666 | - if ( ! $field->args['repeatable'] ) |
|
| 1667 | - $field_value = reset( $field_value ); |
|
| 1666 | + if ( ! $field->args['repeatable']) |
|
| 1667 | + $field_value = reset($field_value); |
|
| 1668 | 1668 | } |
| 1669 | 1669 | } |
| 1670 | 1670 | |
| 1671 | 1671 | } |
| 1672 | 1672 | |
| 1673 | - public function add_field( CMB_Field $field ) { |
|
| 1673 | + public function add_field(CMB_Field $field) { |
|
| 1674 | 1674 | $field->parent = $this; |
| 1675 | 1675 | $this->fields[$field->id] = $field; |
| 1676 | 1676 | } |
@@ -1679,19 +1679,19 @@ discard block |
||
| 1679 | 1679 | return $this->fields; |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | - public function set_values( array $values ) { |
|
| 1682 | + public function set_values(array $values) { |
|
| 1683 | 1683 | |
| 1684 | 1684 | $fields = &$this->get_fields(); |
| 1685 | 1685 | $this->values = $values; |
| 1686 | 1686 | |
| 1687 | 1687 | // Reset all field values. |
| 1688 | - foreach ( $fields as $field ) { |
|
| 1689 | - $field->set_values( array() ); |
|
| 1688 | + foreach ($fields as $field) { |
|
| 1689 | + $field->set_values(array()); |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | - foreach ( $values as $value ) { |
|
| 1693 | - foreach ( $value as $field_id => $field_value ) { |
|
| 1694 | - $fields[$field_id]->set_values( (array) $field_value ); |
|
| 1692 | + foreach ($values as $value) { |
|
| 1693 | + foreach ($value as $field_id => $field_value) { |
|
| 1694 | + $fields[$field_id]->set_values((array) $field_value); |
|
| 1695 | 1695 | } |
| 1696 | 1696 | } |
| 1697 | 1697 | |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | 'default_lat' => '-33.9296903', |
| 1725 | 1725 | 'default_long' => '18.4527097', |
| 1726 | 1726 | 'default_zoom' => '9', |
| 1727 | - 'string-marker-title' => __( 'Drag to set the exact location', 'cmb' ), |
|
| 1727 | + 'string-marker-title' => __('Drag to set the exact location', 'cmb'), |
|
| 1728 | 1728 | ) |
| 1729 | 1729 | ); |
| 1730 | 1730 | } |
@@ -1733,14 +1733,14 @@ discard block |
||
| 1733 | 1733 | |
| 1734 | 1734 | parent::enqueue_scripts(); |
| 1735 | 1735 | |
| 1736 | - $options = get_option('_lsx_lsx-settings',false); |
|
| 1736 | + $options = get_option('_lsx_lsx-settings', false); |
|
| 1737 | 1737 | |
| 1738 | - if(false !== $options && isset($options['general']['googlemaps_key'])) { |
|
| 1738 | + if (false !== $options && isset($options['general']['googlemaps_key'])) { |
|
| 1739 | 1739 | |
| 1740 | - wp_enqueue_script( 'cmb-google-maps', 'https://maps.googleapis.com/maps/api/js?key='.$options['general']['googlemaps_key'].'&libraries=places' ); |
|
| 1741 | - wp_enqueue_script( 'cmb-google-maps-script', trailingslashit( CMB_URL ) . 'js/field-gmap.js', array( 'jquery', 'cmb-google-maps' ) ); |
|
| 1740 | + wp_enqueue_script('cmb-google-maps', 'https://maps.googleapis.com/maps/api/js?key=' . $options['general']['googlemaps_key'] . '&libraries=places'); |
|
| 1741 | + wp_enqueue_script('cmb-google-maps-script', trailingslashit(CMB_URL) . 'js/field-gmap.js', array('jquery', 'cmb-google-maps')); |
|
| 1742 | 1742 | |
| 1743 | - wp_localize_script( 'cmb-google-maps-script', 'CMBGmaps', array( |
|
| 1743 | + wp_localize_script('cmb-google-maps-script', 'CMBGmaps', array( |
|
| 1744 | 1744 | 'defaults' => array( |
| 1745 | 1745 | 'latitude' => $this->args['default_lat'], |
| 1746 | 1746 | 'longitude' => $this->args['default_long'], |
@@ -1749,7 +1749,7 @@ discard block |
||
| 1749 | 1749 | 'strings' => array( |
| 1750 | 1750 | 'markerTitle' => $this->args['string-marker-title'] |
| 1751 | 1751 | ) |
| 1752 | - ) ); |
|
| 1752 | + )); |
|
| 1753 | 1753 | } |
| 1754 | 1754 | |
| 1755 | 1755 | } |
@@ -1759,34 +1759,34 @@ discard block |
||
| 1759 | 1759 | // Ensure all args used are set |
| 1760 | 1760 | $value = wp_parse_args( |
| 1761 | 1761 | $this->get_value(), |
| 1762 | - array( 'address' => null,'lat' => null, 'long' => null,'zoom' => null, 'elevation' => null ) |
|
| 1762 | + array('address' => null, 'lat' => null, 'long' => null, 'zoom' => null, 'elevation' => null) |
|
| 1763 | 1763 | ); |
| 1764 | 1764 | |
| 1765 | 1765 | $style = array( |
| 1766 | - sprintf( 'width: %s;', $this->args['field_width'] ), |
|
| 1767 | - sprintf( 'height: %s;', $this->args['field_height'] ), |
|
| 1766 | + sprintf('width: %s;', $this->args['field_width']), |
|
| 1767 | + sprintf('height: %s;', $this->args['field_height']), |
|
| 1768 | 1768 | 'border: 1px solid #eee;', |
| 1769 | 1769 | 'margin-top: 8px;' |
| 1770 | 1770 | ); |
| 1771 | 1771 | |
| 1772 | 1772 | ?> |
| 1773 | 1773 | |
| 1774 | - <input type="text" <?php $this->class_attr( 'map-search' ); ?> <?php $this->id_attr(); ?> placeholder="Enter an address" value="<?php echo esc_attr( $value['address'] ); ?>" /> |
|
| 1775 | - <select <?php $this->class_attr( 'map-zoom' ); ?>> |
|
| 1774 | + <input type="text" <?php $this->class_attr('map-search'); ?> <?php $this->id_attr(); ?> placeholder="Enter an address" value="<?php echo esc_attr($value['address']); ?>" /> |
|
| 1775 | + <select <?php $this->class_attr('map-zoom'); ?>> |
|
| 1776 | 1776 | <option value="">Zoom</option> |
| 1777 | - <?php foreach(array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21') as $zoom_level) { |
|
| 1778 | - if($zoom_level === $value['zoom']) { $selected='selected="selected"'; }else{$selected='';} |
|
| 1779 | - echo '<option '.$selected.' value="'.$zoom_level.'">'.$zoom_level.'</option>'; |
|
| 1777 | + <?php foreach (array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21') as $zoom_level) { |
|
| 1778 | + if ($zoom_level === $value['zoom']) { $selected = 'selected="selected"'; } else {$selected = ''; } |
|
| 1779 | + echo '<option ' . $selected . ' value="' . $zoom_level . '">' . $zoom_level . '</option>'; |
|
| 1780 | 1780 | }?> |
| 1781 | 1781 | </select> |
| 1782 | 1782 | |
| 1783 | - <div class="map" style="<?php echo esc_attr( implode( ' ', $style ) ); ?>"></div> |
|
| 1783 | + <div class="map" style="<?php echo esc_attr(implode(' ', $style)); ?>"></div> |
|
| 1784 | 1784 | |
| 1785 | - <input type="hidden" class="address" <?php $this->name_attr( '[address]' ); ?> value="<?php echo esc_attr( $value['address'] ); ?>" /> |
|
| 1786 | - <input type="hidden" class="latitude" <?php $this->name_attr( '[lat]' ); ?> value="<?php echo esc_attr( $value['lat'] ); ?>" /> |
|
| 1787 | - <input type="hidden" class="longitude" <?php $this->name_attr( '[long]' ); ?> value="<?php echo esc_attr( $value['long'] ); ?>" /> |
|
| 1788 | - <input type="hidden" class="zoom" <?php $this->name_attr( '[zoom]' ); ?> value="<?php echo esc_attr( $value['zoom'] ); ?>" /> |
|
| 1789 | - <input type="hidden" class="elevation" <?php $this->name_attr( '[elevation]' ); ?> value="<?php echo esc_attr( $value['elevation'] ); ?>" /> |
|
| 1785 | + <input type="hidden" class="address" <?php $this->name_attr('[address]'); ?> value="<?php echo esc_attr($value['address']); ?>" /> |
|
| 1786 | + <input type="hidden" class="latitude" <?php $this->name_attr('[lat]'); ?> value="<?php echo esc_attr($value['lat']); ?>" /> |
|
| 1787 | + <input type="hidden" class="longitude" <?php $this->name_attr('[long]'); ?> value="<?php echo esc_attr($value['long']); ?>" /> |
|
| 1788 | + <input type="hidden" class="zoom" <?php $this->name_attr('[zoom]'); ?> value="<?php echo esc_attr($value['zoom']); ?>" /> |
|
| 1789 | + <input type="hidden" class="elevation" <?php $this->name_attr('[elevation]'); ?> value="<?php echo esc_attr($value['elevation']); ?>" /> |
|
| 1790 | 1790 | |
| 1791 | 1791 | <?php |
| 1792 | 1792 | } |
@@ -8,46 +8,46 @@ discard block |
||
| 8 | 8 | protected $_meta_box; |
| 9 | 9 | private $fields = array(); |
| 10 | 10 | |
| 11 | - function __construct( $meta_box ) { |
|
| 11 | + function __construct($meta_box) { |
|
| 12 | 12 | |
| 13 | 13 | $this->_meta_box = $meta_box; |
| 14 | 14 | |
| 15 | - if ( empty( $this->_meta_box['id'] ) ) |
|
| 16 | - $this->_meta_box['id'] = sanitize_title( $this->_meta_box['title'] ); |
|
| 15 | + if (empty($this->_meta_box['id'])) |
|
| 16 | + $this->_meta_box['id'] = sanitize_title($this->_meta_box['title']); |
|
| 17 | 17 | |
| 18 | - add_action( 'add_meta_boxes', array( &$this, 'init_fields_for_post' ) ); |
|
| 19 | - add_action( 'cmb_init_fields', array( &$this, 'init_fields' ) ); |
|
| 18 | + add_action('add_meta_boxes', array(&$this, 'init_fields_for_post')); |
|
| 19 | + add_action('cmb_init_fields', array(&$this, 'init_fields')); |
|
| 20 | 20 | |
| 21 | - add_action( 'admin_menu', array( &$this, 'add' ) ); |
|
| 22 | - add_action( 'save_post', array( &$this, 'save_for_post' ) ); |
|
| 23 | - add_action( 'edit_attachment', array( &$this, 'save_for_post' ) ); |
|
| 24 | - add_action( 'cmb_save_fields', array( &$this, 'save' ) ); |
|
| 21 | + add_action('admin_menu', array(&$this, 'add')); |
|
| 22 | + add_action('save_post', array(&$this, 'save_for_post')); |
|
| 23 | + add_action('edit_attachment', array(&$this, 'save_for_post')); |
|
| 24 | + add_action('cmb_save_fields', array(&$this, 'save')); |
|
| 25 | 25 | |
| 26 | - add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_scripts' ), 9 ); |
|
| 27 | - add_action( 'admin_enqueue_scripts', array( &$this, 'enqueue_styles' ), 9 ); |
|
| 26 | + add_action('admin_enqueue_scripts', array(&$this, 'enqueue_scripts'), 9); |
|
| 27 | + add_action('admin_enqueue_scripts', array(&$this, 'enqueue_styles'), 9); |
|
| 28 | 28 | |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function init_fields( $post_id = 0 ) { |
|
| 31 | + public function init_fields($post_id = 0) { |
|
| 32 | 32 | |
| 33 | - foreach ( $this->_meta_box['fields'] as $key => $field ) { |
|
| 33 | + foreach ($this->_meta_box['fields'] as $key => $field) { |
|
| 34 | 34 | |
| 35 | 35 | $values = array(); |
| 36 | 36 | |
| 37 | 37 | $args = $field; |
| 38 | - unset( $args['id'] ); |
|
| 39 | - unset( $args['type'] ); |
|
| 40 | - unset( $args['name'] ); |
|
| 38 | + unset($args['id']); |
|
| 39 | + unset($args['type']); |
|
| 40 | + unset($args['name']); |
|
| 41 | 41 | |
| 42 | - $class = _cmb_field_class_for_type( $field['type'] ); |
|
| 42 | + $class = _cmb_field_class_for_type($field['type']); |
|
| 43 | 43 | |
| 44 | 44 | // If we are on a post edit screen - get metadata value of the field for this post |
| 45 | - if ( $post_id ) { |
|
| 46 | - $values = (array) get_post_meta( $post_id, $field['id'], false ); |
|
| 45 | + if ($post_id) { |
|
| 46 | + $values = (array) get_post_meta($post_id, $field['id'], false); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - if ( class_exists( $class ) ) { |
|
| 50 | - $this->fields[] = new $class( $field['id'], $field['name'], (array) $values, $args ); |
|
| 49 | + if (class_exists($class)) { |
|
| 50 | + $this->fields[] = new $class($field['id'], $field['name'], (array) $values, $args); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | } |
@@ -59,33 +59,33 @@ discard block |
||
| 59 | 59 | global $post, $temp_ID; |
| 60 | 60 | |
| 61 | 61 | // Get the current ID |
| 62 | - if( isset( $_GET['post'] ) ) |
|
| 62 | + if (isset($_GET['post'])) |
|
| 63 | 63 | $post_id = $_GET['post']; |
| 64 | 64 | |
| 65 | - elseif( isset( $_POST['post_ID'] ) ) |
|
| 65 | + elseif (isset($_POST['post_ID'])) |
|
| 66 | 66 | $post_id = $_POST['post_ID']; |
| 67 | 67 | |
| 68 | - elseif ( ! empty( $post->ID ) ) |
|
| 68 | + elseif ( ! empty($post->ID)) |
|
| 69 | 69 | $post_id = $post->ID; |
| 70 | 70 | |
| 71 | - if ( is_page() || ! isset( $post_id ) ) |
|
| 71 | + if (is_page() || ! isset($post_id)) |
|
| 72 | 72 | return false; |
| 73 | 73 | |
| 74 | - $this->init_fields( (int) $post_id ); |
|
| 74 | + $this->init_fields((int) $post_id); |
|
| 75 | 75 | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | function enqueue_scripts() { |
| 79 | 79 | |
| 80 | - wp_enqueue_script( 'cmb-scripts', trailingslashit( CMB_URL ) . 'js/cmb.js', array( 'jquery' ) ); |
|
| 80 | + wp_enqueue_script('cmb-scripts', trailingslashit(CMB_URL) . 'js/cmb.js', array('jquery')); |
|
| 81 | 81 | |
| 82 | - wp_localize_script( 'cmb-scripts', 'CMBData', array( |
|
| 82 | + wp_localize_script('cmb-scripts', 'CMBData', array( |
|
| 83 | 83 | 'strings' => array( |
| 84 | - 'confirmDeleteField' => __( 'Are you sure you want to delete this field?', 'cmb' ) |
|
| 84 | + 'confirmDeleteField' => __('Are you sure you want to delete this field?', 'cmb') |
|
| 85 | 85 | ) |
| 86 | - ) ); |
|
| 86 | + )); |
|
| 87 | 87 | |
| 88 | - foreach ( $this->fields as $field ) |
|
| 88 | + foreach ($this->fields as $field) |
|
| 89 | 89 | $field->enqueue_scripts(); |
| 90 | 90 | |
| 91 | 91 | } |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $suffix = CMB_DEV ? '' : '.min'; |
| 96 | 96 | |
| 97 | - if ( version_compare( get_bloginfo( 'version' ), '3.8', '>=' ) ) |
|
| 98 | - wp_enqueue_style( 'cmb-styles', trailingslashit( CMB_URL ) . "css/dist/cmb$suffix.css" ); |
|
| 97 | + if (version_compare(get_bloginfo('version'), '3.8', '>=')) |
|
| 98 | + wp_enqueue_style('cmb-styles', trailingslashit(CMB_URL) . "css/dist/cmb$suffix.css"); |
|
| 99 | 99 | else |
| 100 | - wp_enqueue_style( 'cmb-styles', trailingslashit( CMB_URL ) . 'css/legacy.css' ); |
|
| 100 | + wp_enqueue_style('cmb-styles', trailingslashit(CMB_URL) . 'css/legacy.css'); |
|
| 101 | 101 | |
| 102 | - foreach ( $this->fields as $field ) |
|
| 102 | + foreach ($this->fields as $field) |
|
| 103 | 103 | $field->enqueue_styles(); |
| 104 | 104 | |
| 105 | 105 | } |
@@ -111,15 +111,15 @@ discard block |
||
| 111 | 111 | $this->_meta_box['priority'] = empty($this->_meta_box['priority']) ? 'low' : $this->_meta_box['priority']; |
| 112 | 112 | |
| 113 | 113 | // Backwards compatablilty. |
| 114 | - if ( isset( $this->_meta_box['show_on']['key'] ) ) { |
|
| 115 | - $this->_meta_box['show_on'][ $this->_meta_box['show_on']['key'] ] = $this->_meta_box['show_on']['value']; |
|
| 116 | - unset( $this->_meta_box['show_on']['key'] ); |
|
| 117 | - unset( $this->_meta_box['show_on']['value'] ); |
|
| 114 | + if (isset($this->_meta_box['show_on']['key'])) { |
|
| 115 | + $this->_meta_box['show_on'][$this->_meta_box['show_on']['key']] = $this->_meta_box['show_on']['value']; |
|
| 116 | + unset($this->_meta_box['show_on']['key']); |
|
| 117 | + unset($this->_meta_box['show_on']['value']); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - foreach ( (array) $this->_meta_box['pages'] as $page ) { |
|
| 121 | - if ( $this->is_metabox_displayed() ) { |
|
| 122 | - add_meta_box( $this->_meta_box['id'], $this->_meta_box['title'], array(&$this, 'show'), $page, $this->_meta_box['context'], $this->_meta_box['priority'] ) ; |
|
| 120 | + foreach ((array) $this->_meta_box['pages'] as $page) { |
|
| 121 | + if ($this->is_metabox_displayed()) { |
|
| 122 | + add_meta_box($this->_meta_box['id'], $this->_meta_box['title'], array(&$this, 'show'), $page, $this->_meta_box['context'], $this->_meta_box['priority']); |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
@@ -130,107 +130,107 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | function is_metabox_displayed() { |
| 132 | 132 | $display = true; |
| 133 | - $display = $this->add_for_id( $display ); |
|
| 134 | - $display = $this->hide_for_id( $display ); |
|
| 135 | - $display = $this->add_for_page_template( $display ); |
|
| 136 | - $display = $this->hide_for_page_template( $display ); |
|
| 133 | + $display = $this->add_for_id($display); |
|
| 134 | + $display = $this->hide_for_id($display); |
|
| 135 | + $display = $this->add_for_page_template($display); |
|
| 136 | + $display = $this->hide_for_page_template($display); |
|
| 137 | 137 | return $display; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | 140 | // Add CMB for ID |
| 141 | - function add_for_id( $display ) { |
|
| 141 | + function add_for_id($display) { |
|
| 142 | 142 | |
| 143 | - if ( ! isset( $this->_meta_box['show_on']['id'] ) ) { |
|
| 143 | + if ( ! isset($this->_meta_box['show_on']['id'])) { |
|
| 144 | 144 | return $display; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // Don't show CMB if we can't identify ID of a post |
| 148 | 148 | $post_id = $this->get_post_id(); |
| 149 | 149 | |
| 150 | - if ( ! isset( $post_id ) ) { |
|
| 150 | + if ( ! isset($post_id)) { |
|
| 151 | 151 | return false; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // If value isn't an array, turn it into one |
| 155 | - $this->_meta_box['show_on']['id'] = ! is_array( $this->_meta_box['show_on']['id'] ) ? array( $this->_meta_box['show_on']['id'] ) : $this->_meta_box['show_on']['id']; |
|
| 155 | + $this->_meta_box['show_on']['id'] = ! is_array($this->_meta_box['show_on']['id']) ? array($this->_meta_box['show_on']['id']) : $this->_meta_box['show_on']['id']; |
|
| 156 | 156 | |
| 157 | - return in_array( $post_id, $this->_meta_box['show_on']['id'] ); |
|
| 157 | + return in_array($post_id, $this->_meta_box['show_on']['id']); |
|
| 158 | 158 | |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // Hide CMB for ID |
| 162 | - function hide_for_id( $display ) { |
|
| 162 | + function hide_for_id($display) { |
|
| 163 | 163 | |
| 164 | - if ( ! isset( $this->_meta_box['hide_on']['id'] ) ) { |
|
| 164 | + if ( ! isset($this->_meta_box['hide_on']['id'])) { |
|
| 165 | 165 | return $display; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | // Return if we can't identify ID of a post |
| 169 | 169 | $post_id = $this->get_post_id(); |
| 170 | - if ( ! isset( $post_id ) ) { |
|
| 170 | + if ( ! isset($post_id)) { |
|
| 171 | 171 | return $display; |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | // If value isn't an array, turn it into one |
| 175 | - $this->_meta_box['hide_on']['id'] = ! is_array( $this->_meta_box['hide_on']['id'] ) ? array( $this->_meta_box['hide_on']['id'] ) : $this->_meta_box['hide_on']['id']; |
|
| 175 | + $this->_meta_box['hide_on']['id'] = ! is_array($this->_meta_box['hide_on']['id']) ? array($this->_meta_box['hide_on']['id']) : $this->_meta_box['hide_on']['id']; |
|
| 176 | 176 | |
| 177 | - return ! in_array( $post_id, $this->_meta_box['hide_on']['id'] ); |
|
| 177 | + return ! in_array($post_id, $this->_meta_box['hide_on']['id']); |
|
| 178 | 178 | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | // Add CMB for Page Template |
| 182 | - function add_for_page_template( $display ) { |
|
| 182 | + function add_for_page_template($display) { |
|
| 183 | 183 | |
| 184 | - if ( ! isset( $this->_meta_box['show_on']['page-template'] ) ) { |
|
| 184 | + if ( ! isset($this->_meta_box['show_on']['page-template'])) { |
|
| 185 | 185 | return $display; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // Return false if we can't identify ID of a post |
| 189 | 189 | $post_id = $this->get_post_id(); |
| 190 | - if ( ! isset( $post_id ) ) { |
|
| 190 | + if ( ! isset($post_id)) { |
|
| 191 | 191 | return false; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | // Get current template |
| 195 | - $current_template = get_post_meta( $post_id, '_wp_page_template', true ); |
|
| 195 | + $current_template = get_post_meta($post_id, '_wp_page_template', true); |
|
| 196 | 196 | |
| 197 | 197 | // If value isn't an array, turn it into one |
| 198 | - $this->_meta_box['show_on']['page-template'] = ! is_array( $this->_meta_box['show_on']['page-template'] ) ? array( $this->_meta_box['show_on']['page-template'] ) : $this->_meta_box['show_on']['page-template']; |
|
| 198 | + $this->_meta_box['show_on']['page-template'] = ! is_array($this->_meta_box['show_on']['page-template']) ? array($this->_meta_box['show_on']['page-template']) : $this->_meta_box['show_on']['page-template']; |
|
| 199 | 199 | |
| 200 | - return in_array( $current_template, $this->_meta_box['show_on']['page-template'] ); |
|
| 200 | + return in_array($current_template, $this->_meta_box['show_on']['page-template']); |
|
| 201 | 201 | |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Hide CMB for Page Template |
| 205 | - function hide_for_page_template( $display ) { |
|
| 205 | + function hide_for_page_template($display) { |
|
| 206 | 206 | |
| 207 | - if ( ! isset( $this->_meta_box['hide_on']['page-template'] ) ) { |
|
| 207 | + if ( ! isset($this->_meta_box['hide_on']['page-template'])) { |
|
| 208 | 208 | return $display; |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // Return $display if we can't identify ID of a post and hence its current template |
| 212 | 212 | $post_id = $this->get_post_id(); |
| 213 | 213 | |
| 214 | - if ( ! isset( $post_id ) ) { |
|
| 214 | + if ( ! isset($post_id)) { |
|
| 215 | 215 | return $display; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | // Get current template |
| 219 | - $current_template = get_post_meta( $post_id, '_wp_page_template', true ); |
|
| 219 | + $current_template = get_post_meta($post_id, '_wp_page_template', true); |
|
| 220 | 220 | |
| 221 | 221 | // If value isn't an array, turn it into one |
| 222 | - $this->_meta_box['hide_on']['page-template'] = ! is_array( $this->_meta_box['hide_on']['page-template'] ) ? array( $this->_meta_box['hide_on']['page-template'] ) : $this->_meta_box['hide_on']['page-template']; |
|
| 222 | + $this->_meta_box['hide_on']['page-template'] = ! is_array($this->_meta_box['hide_on']['page-template']) ? array($this->_meta_box['hide_on']['page-template']) : $this->_meta_box['hide_on']['page-template']; |
|
| 223 | 223 | |
| 224 | - return ! in_array( $current_template, $this->_meta_box['hide_on']['page-template'] ); |
|
| 224 | + return ! in_array($current_template, $this->_meta_box['hide_on']['page-template']); |
|
| 225 | 225 | |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | // display fields |
| 229 | 229 | function show() { ?> |
| 230 | 230 | |
| 231 | - <input type="hidden" name="wp_meta_box_nonce" value="<?php esc_attr_e( wp_create_nonce( basename(__FILE__) ) ); ?>" /> |
|
| 231 | + <input type="hidden" name="wp_meta_box_nonce" value="<?php esc_attr_e(wp_create_nonce(basename(__FILE__))); ?>" /> |
|
| 232 | 232 | |
| 233 | - <?php self::layout_fields( $this->fields ); |
|
| 233 | + <?php self::layout_fields($this->fields); |
|
| 234 | 234 | |
| 235 | 235 | } |
| 236 | 236 | |
@@ -241,15 +241,15 @@ discard block |
||
| 241 | 241 | * |
| 242 | 242 | * @param CMB_Field[] $fields |
| 243 | 243 | */ |
| 244 | - static function layout_fields( array $fields ) { ?> |
|
| 244 | + static function layout_fields(array $fields) { ?> |
|
| 245 | 245 | |
| 246 | 246 | <div class="cmb_metabox"> |
| 247 | 247 | |
| 248 | 248 | <?php $current_colspan = 0; |
| 249 | 249 | |
| 250 | - foreach ( $fields as $field ) : |
|
| 250 | + foreach ($fields as $field) : |
|
| 251 | 251 | |
| 252 | - if ( $current_colspan == 0 ) : ?> |
|
| 252 | + if ($current_colspan == 0) : ?> |
|
| 253 | 253 | |
| 254 | 254 | <div class="cmb-row"> |
| 255 | 255 | |
@@ -257,36 +257,36 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $current_colspan += $field->args['cols']; |
| 259 | 259 | |
| 260 | - $classes = array( 'field', get_class($field) ); |
|
| 260 | + $classes = array('field', get_class($field)); |
|
| 261 | 261 | |
| 262 | - if ( ! empty( $field->args['repeatable'] ) ) |
|
| 262 | + if ( ! empty($field->args['repeatable'])) |
|
| 263 | 263 | $classes[] = 'repeatable'; |
| 264 | 264 | |
| 265 | - if ( ! empty( $field->args['sortable'] ) ) |
|
| 265 | + if ( ! empty($field->args['sortable'])) |
|
| 266 | 266 | $classes[] = 'cmb-sortable'; |
| 267 | 267 | |
| 268 | 268 | $attrs = array( |
| 269 | - sprintf( 'id="%s"', sanitize_html_class( $field->id ) ), |
|
| 270 | - sprintf( 'class="%s"', esc_attr( implode(' ', array_map( 'sanitize_html_class', $classes ) ) ) ) |
|
| 269 | + sprintf('id="%s"', sanitize_html_class($field->id)), |
|
| 270 | + sprintf('class="%s"', esc_attr(implode(' ', array_map('sanitize_html_class', $classes)))) |
|
| 271 | 271 | ); |
| 272 | 272 | |
| 273 | 273 | // Field Repeatable Max. |
| 274 | - if ( isset( $field->args['repeatable_max'] ) ) |
|
| 275 | - $attrs[] = sprintf( 'data-rep-max="%s"', intval( $field->args['repeatable_max'] ) ); |
|
| 274 | + if (isset($field->args['repeatable_max'])) |
|
| 275 | + $attrs[] = sprintf('data-rep-max="%s"', intval($field->args['repeatable_max'])); |
|
| 276 | 276 | |
| 277 | 277 | ?> |
| 278 | 278 | |
| 279 | - <div class="cmb-cell-<?php echo intval( $field->args['cols'] ); ?>"> |
|
| 279 | + <div class="cmb-cell-<?php echo intval($field->args['cols']); ?>"> |
|
| 280 | 280 | |
| 281 | - <div <?php echo implode( ' ', $attrs ); ?>> |
|
| 281 | + <div <?php echo implode(' ', $attrs); ?>> |
|
| 282 | 282 | <?php $field->display(); ?> |
| 283 | 283 | </div> |
| 284 | 284 | |
| 285 | - <input type="hidden" name="_cmb_present_<?php esc_attr_e( $field->id ); ?>" value="1" /> |
|
| 285 | + <input type="hidden" name="_cmb_present_<?php esc_attr_e($field->id); ?>" value="1" /> |
|
| 286 | 286 | |
| 287 | 287 | </div> |
| 288 | 288 | |
| 289 | - <?php if ( $current_colspan == 12 || $field === end( $fields ) ) : |
|
| 289 | + <?php if ($current_colspan == 12 || $field === end($fields)) : |
|
| 290 | 290 | |
| 291 | 291 | $current_colspan = 0; ?> |
| 292 | 292 | |
@@ -300,15 +300,15 @@ discard block |
||
| 300 | 300 | |
| 301 | 301 | <?php } |
| 302 | 302 | |
| 303 | - function strip_repeatable( $values ) { |
|
| 303 | + function strip_repeatable($values) { |
|
| 304 | 304 | |
| 305 | - foreach ( $values as $key => $value ) { |
|
| 305 | + foreach ($values as $key => $value) { |
|
| 306 | 306 | |
| 307 | - if ( false !== strpos( $key, 'cmb-group-x' ) || false !== strpos( $key, 'cmb-field-x' ) ) |
|
| 308 | - unset( $values[$key] ); |
|
| 307 | + if (false !== strpos($key, 'cmb-group-x') || false !== strpos($key, 'cmb-field-x')) |
|
| 308 | + unset($values[$key]); |
|
| 309 | 309 | |
| 310 | - elseif ( is_array( $value ) ) |
|
| 311 | - $values[$key] = $this->strip_repeatable( $value ); |
|
| 310 | + elseif (is_array($value)) |
|
| 311 | + $values[$key] = $this->strip_repeatable($value); |
|
| 312 | 312 | |
| 313 | 313 | } |
| 314 | 314 | |
@@ -316,60 +316,60 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Save data from metabox |
| 319 | - function save( $post_id = 0 ) { |
|
| 319 | + function save($post_id = 0) { |
|
| 320 | 320 | |
| 321 | 321 | // Verify nonce |
| 322 | - if ( ! isset( $_POST['wp_meta_box_nonce'] ) || ! wp_verify_nonce( $_POST['wp_meta_box_nonce'], basename( __FILE__ ) ) ) |
|
| 322 | + if ( ! isset($_POST['wp_meta_box_nonce']) || ! wp_verify_nonce($_POST['wp_meta_box_nonce'], basename(__FILE__))) |
|
| 323 | 323 | return $post_id; |
| 324 | 324 | |
| 325 | - foreach ( $this->_meta_box['fields'] as $field ) { |
|
| 325 | + foreach ($this->_meta_box['fields'] as $field) { |
|
| 326 | 326 | |
| 327 | 327 | // Verify this meta box was shown on the page |
| 328 | - if ( ! isset( $_POST['_cmb_present_' . $field['id'] ] ) ) |
|
| 328 | + if ( ! isset($_POST['_cmb_present_' . $field['id']])) |
|
| 329 | 329 | continue; |
| 330 | 330 | |
| 331 | - if ( isset( $_POST[ $field['id'] ] ) ) |
|
| 332 | - $value = (array) $_POST[ $field['id'] ]; |
|
| 331 | + if (isset($_POST[$field['id']])) |
|
| 332 | + $value = (array) $_POST[$field['id']]; |
|
| 333 | 333 | else |
| 334 | 334 | $value = array(); |
| 335 | 335 | |
| 336 | - $value = $this->strip_repeatable( $value ); |
|
| 336 | + $value = $this->strip_repeatable($value); |
|
| 337 | 337 | |
| 338 | - if ( ! $class = _cmb_field_class_for_type( $field['type'] ) ) { |
|
| 339 | - do_action( 'cmb_save_' . $field['type'], $field, $value ); |
|
| 338 | + if ( ! $class = _cmb_field_class_for_type($field['type'])) { |
|
| 339 | + do_action('cmb_save_' . $field['type'], $field, $value); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $field_obj = new $class( $field['id'], $field['name'], $value, $field ); |
|
| 343 | - if ( 'post_select' === $field['type'] || 'group' === $field['type'] ) { |
|
| 342 | + $field_obj = new $class($field['id'], $field['name'], $value, $field); |
|
| 343 | + if ('post_select' === $field['type'] || 'group' === $field['type']) { |
|
| 344 | 344 | do_action('cmb_save_custom', $post_id, $field, $value); |
| 345 | 345 | } |
| 346 | - $field_obj->save( $post_id, $value ); |
|
| 346 | + $field_obj->save($post_id, $value); |
|
| 347 | 347 | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | // If we are not on a post, need to refresh the field objects to reflect new values, as we do not get a redirect |
| 351 | - if ( ! $post_id ) { |
|
| 351 | + if ( ! $post_id) { |
|
| 352 | 352 | $this->fields = array(); |
| 353 | 353 | $this->init_fields(); |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | // Save the on save_post hook |
| 358 | - function save_for_post( $post_id ) { |
|
| 358 | + function save_for_post($post_id) { |
|
| 359 | 359 | |
| 360 | 360 | // check autosave |
| 361 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) |
|
| 361 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
| 362 | 362 | return $post_id; |
| 363 | 363 | |
| 364 | - $this->save( $post_id ); |
|
| 364 | + $this->save($post_id); |
|
| 365 | 365 | |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | function get_post_id() { |
| 369 | 369 | |
| 370 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 370 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 371 | 371 | |
| 372 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 372 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 373 | 373 | $post_id = $_POST['post_id']; |
| 374 | 374 | } |
| 375 | 375 | |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @return null |
| 13 | 13 | */ |
| 14 | -function cmb_draw_meta_boxes( $pages, $context = 'normal', $object = null ) { |
|
| 14 | +function cmb_draw_meta_boxes($pages, $context = 'normal', $object = null) { |
|
| 15 | 15 | |
| 16 | - cmb_do_meta_boxes( $pages, $context, $object ); |
|
| 16 | + cmb_do_meta_boxes($pages, $context, $object); |
|
| 17 | 17 | |
| 18 | 18 | wp_enqueue_script('post'); |
| 19 | 19 | |
@@ -29,54 +29,54 @@ discard block |
||
| 29 | 29 | * @param mixed $object gets passed to the box callback function as first parameter |
| 30 | 30 | * @return int number of meta_boxes |
| 31 | 31 | */ |
| 32 | -function cmb_do_meta_boxes( $screen, $context, $object ) { |
|
| 32 | +function cmb_do_meta_boxes($screen, $context, $object) { |
|
| 33 | 33 | |
| 34 | 34 | global $wp_meta_boxes; |
| 35 | 35 | |
| 36 | 36 | static $already_sorted = false; |
| 37 | 37 | |
| 38 | - if ( empty( $screen ) ) |
|
| 38 | + if (empty($screen)) |
|
| 39 | 39 | $screen = get_current_screen(); |
| 40 | 40 | |
| 41 | - elseif ( is_string( $screen ) ) |
|
| 42 | - $screen = convert_to_screen( $screen ); |
|
| 41 | + elseif (is_string($screen)) |
|
| 42 | + $screen = convert_to_screen($screen); |
|
| 43 | 43 | |
| 44 | 44 | $page = $screen->id; |
| 45 | 45 | |
| 46 | - $hidden = get_hidden_meta_boxes( $screen ); |
|
| 46 | + $hidden = get_hidden_meta_boxes($screen); |
|
| 47 | 47 | |
| 48 | 48 | $i = 0; |
| 49 | 49 | |
| 50 | 50 | do { |
| 51 | 51 | // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose |
| 52 | 52 | |
| 53 | - if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) |
|
| 54 | - foreach ( $sorted as $box_context => $ids ) |
|
| 55 | - foreach ( explode(',', $ids ) as $id ) |
|
| 56 | - if ( $id && 'dashboard_browser_nag' !== $id ) |
|
| 57 | - add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); |
|
| 53 | + if ( ! $already_sorted && $sorted = get_user_option("meta-box-order_$page")) |
|
| 54 | + foreach ($sorted as $box_context => $ids) |
|
| 55 | + foreach (explode(',', $ids) as $id) |
|
| 56 | + if ($id && 'dashboard_browser_nag' !== $id) |
|
| 57 | + add_meta_box($id, null, null, $screen, $box_context, 'sorted'); |
|
| 58 | 58 | |
| 59 | 59 | $already_sorted = true; |
| 60 | 60 | |
| 61 | - if ( ! isset( $wp_meta_boxes ) || ! isset( $wp_meta_boxes[$page] ) || ! isset( $wp_meta_boxes[$page][$context] ) ) |
|
| 61 | + if ( ! isset($wp_meta_boxes) || ! isset($wp_meta_boxes[$page]) || ! isset($wp_meta_boxes[$page][$context])) |
|
| 62 | 62 | break; |
| 63 | 63 | |
| 64 | - foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { |
|
| 64 | + foreach (array('high', 'sorted', 'core', 'default', 'low') as $priority) { |
|
| 65 | 65 | |
| 66 | - if ( isset( $wp_meta_boxes[$page][$context][$priority] ) ) { |
|
| 66 | + if (isset($wp_meta_boxes[$page][$context][$priority])) { |
|
| 67 | 67 | |
| 68 | - foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { |
|
| 68 | + foreach ((array) $wp_meta_boxes[$page][$context][$priority] as $box) { |
|
| 69 | 69 | |
| 70 | - if ( false == $box || ! $box['title'] ) |
|
| 70 | + if (false == $box || ! $box['title']) |
|
| 71 | 71 | continue; |
| 72 | 72 | |
| 73 | 73 | $i++; |
| 74 | 74 | |
| 75 | 75 | $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; ?> |
| 76 | 76 | |
| 77 | - <div id="<?php esc_attr_e( $box['id'] ); ?>" class="<?php esc_attr_e( postbox_classes( $box['id'], $page ) . $hidden_class ); ?>"> |
|
| 77 | + <div id="<?php esc_attr_e($box['id']); ?>" class="<?php esc_attr_e(postbox_classes($box['id'], $page) . $hidden_class); ?>"> |
|
| 78 | 78 | |
| 79 | - <?php call_user_func( $box['callback'], $object, $box ); ?> |
|
| 79 | + <?php call_user_func($box['callback'], $object, $box); ?> |
|
| 80 | 80 | |
| 81 | 81 | </div> |
| 82 | 82 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | } |
| 88 | - } while( 0 ); |
|
| 88 | + } while (0); |
|
| 89 | 89 | |
| 90 | 90 | return $i; |
| 91 | 91 | |
@@ -73,23 +73,23 @@ discard block |
||
| 73 | 73 | * @since 1.0.0 |
| 74 | 74 | * @access private |
| 75 | 75 | */ |
| 76 | - private function __construct( $slug ) { |
|
| 76 | + private function __construct($slug) { |
|
| 77 | 77 | |
| 78 | 78 | |
| 79 | 79 | // set slug |
| 80 | 80 | $this->plugin_slug = $slug; |
| 81 | 81 | |
| 82 | 82 | // add admin page |
| 83 | - add_action( 'admin_menu', array( $this, 'add_settings_pages' ), 25 ); |
|
| 83 | + add_action('admin_menu', array($this, 'add_settings_pages'), 25); |
|
| 84 | 84 | |
| 85 | 85 | // add metaboxes |
| 86 | - add_action( 'add_meta_boxes', array( $this, 'add_metaboxes'), 25 ); |
|
| 86 | + add_action('add_meta_boxes', array($this, 'add_metaboxes'), 25); |
|
| 87 | 87 | |
| 88 | 88 | // save config |
| 89 | - add_action( 'wp_ajax_' . $this->plugin_slug . '_save_config', array( $this, 'save_config') ); |
|
| 89 | + add_action('wp_ajax_' . $this->plugin_slug . '_save_config', array($this, 'save_config')); |
|
| 90 | 90 | |
| 91 | 91 | // save metabox |
| 92 | - add_action( 'save_post', array( $this, 'save_meta' ), 10, 2 ); |
|
| 92 | + add_action('save_post', array($this, 'save_meta'), 10, 2); |
|
| 93 | 93 | |
| 94 | 94 | } |
| 95 | 95 | |
@@ -100,27 +100,27 @@ discard block |
||
| 100 | 100 | * |
| 101 | 101 | * @uses "add_meta_boxes" hook |
| 102 | 102 | */ |
| 103 | - public function add_metaboxes(){ |
|
| 103 | + public function add_metaboxes() { |
|
| 104 | 104 | |
| 105 | 105 | $screen = get_current_screen(); |
| 106 | 106 | |
| 107 | - if( !is_object( $screen ) || $screen->base != 'post' ){ |
|
| 107 | + if ( ! is_object($screen) || $screen->base != 'post') { |
|
| 108 | 108 | return; |
| 109 | 109 | } |
| 110 | 110 | // post type metaboxes |
| 111 | 111 | $configs = array(); |
| 112 | 112 | |
| 113 | - foreach( (array) $this->metaboxes as $metabox_slug => $metabox ){ |
|
| 113 | + foreach ((array) $this->metaboxes as $metabox_slug => $metabox) { |
|
| 114 | 114 | |
| 115 | 115 | // only process this post type |
| 116 | - if( empty($metabox['post_type']) || !in_array( $screen->post_type, (array) $metabox['post_type'] ) || empty( $metabox[ 'name' ] ) ){ |
|
| 116 | + if (empty($metabox['post_type']) || ! in_array($screen->post_type, (array) $metabox['post_type']) || empty($metabox['name'])) { |
|
| 117 | 117 | continue; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | add_meta_box( |
| 121 | 121 | $metabox_slug, |
| 122 | 122 | $metabox['name'], |
| 123 | - array( $this, 'render_metabox' ), |
|
| 123 | + array($this, 'render_metabox'), |
|
| 124 | 124 | $screen->post_type, |
| 125 | 125 | $metabox['context'], |
| 126 | 126 | $metabox['priority'], |
@@ -128,50 +128,50 @@ discard block |
||
| 128 | 128 | ); |
| 129 | 129 | |
| 130 | 130 | // do scripts |
| 131 | - $uix = $this->get_metabox( $metabox_slug ); |
|
| 132 | - if( false !== $uix ){ |
|
| 133 | - $configs[ $metabox_slug ] = $uix; |
|
| 131 | + $uix = $this->get_metabox($metabox_slug); |
|
| 132 | + if (false !== $uix) { |
|
| 133 | + $configs[$metabox_slug] = $uix; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | } |
| 137 | 137 | // scripts |
| 138 | - if( !empty( $configs ) ){ |
|
| 139 | - $this->enqueue_metabox_stylescripts( $configs, $screen->post_type ); |
|
| 138 | + if ( ! empty($configs)) { |
|
| 139 | + $this->enqueue_metabox_stylescripts($configs, $screen->post_type); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | |
| 145 | - public function render_metabox( $post, $metabox ){ |
|
| 145 | + public function render_metabox($post, $metabox) { |
|
| 146 | 146 | |
| 147 | 147 | $uix = $metabox['args']; |
| 148 | 148 | |
| 149 | - if( !empty( $uix['base_color'] ) ){ |
|
| 149 | + if ( ! empty($uix['base_color'])) { |
|
| 150 | 150 | ?><style type="text/css">.uix-modal-title > h3,.wrap a.page-title-action:hover{background: <?php echo $uix['base_color']; ?>;}</style> |
| 151 | 151 | <?php |
| 152 | 152 | } |
| 153 | 153 | ?> |
| 154 | - <input id="uix_<?php echo esc_attr( $metabox['id'] ); ?>" name="uix[<?php echo esc_attr( $metabox['id'] ); ?>]" value="" type="hidden"> |
|
| 155 | - <div class="uix-tab-canvas" data-app="<?php echo esc_attr( $metabox['id'] ); ?>"></div> |
|
| 156 | - <script type="text/html" data-template="<?php echo esc_attr( $metabox['id'] ); ?>"> |
|
| 154 | + <input id="uix_<?php echo esc_attr($metabox['id']); ?>" name="uix[<?php echo esc_attr($metabox['id']); ?>]" value="" type="hidden"> |
|
| 155 | + <div class="uix-tab-canvas" data-app="<?php echo esc_attr($metabox['id']); ?>"></div> |
|
| 156 | + <script type="text/html" data-template="<?php echo esc_attr($metabox['id']); ?>"> |
|
| 157 | 157 | <?php |
| 158 | - if( !empty( $uix['template'] ) && file_exists( $uix['template'] ) ){ |
|
| 158 | + if ( ! empty($uix['template']) && file_exists($uix['template'])) { |
|
| 159 | 159 | include $uix['template']; |
| 160 | - }else{ |
|
| 161 | - echo esc_html__( 'Template not found: ', $this->plugin_slug ) . $uix['template']; |
|
| 160 | + } else { |
|
| 161 | + echo esc_html__('Template not found: ', $this->plugin_slug) . $uix['template']; |
|
| 162 | 162 | } |
| 163 | 163 | ?> |
| 164 | 164 | </script> |
| 165 | - <?php if( !empty( $uix['partials'] ) ){ |
|
| 166 | - foreach( $uix['partials'] as $partial_id => $partial ){ |
|
| 165 | + <?php if ( ! empty($uix['partials'])) { |
|
| 166 | + foreach ($uix['partials'] as $partial_id => $partial) { |
|
| 167 | 167 | ?> |
| 168 | - <script type="text/html" id="__partial_<?php echo esc_attr( $partial_id ); ?>" data-handlebars-partial="<?php echo esc_attr( $partial_id ); ?>"> |
|
| 168 | + <script type="text/html" id="__partial_<?php echo esc_attr($partial_id); ?>" data-handlebars-partial="<?php echo esc_attr($partial_id); ?>"> |
|
| 169 | 169 | <?php |
| 170 | 170 | // include this tabs template |
| 171 | - if( !empty( $partial ) && file_exists( $partial ) ){ |
|
| 171 | + if ( ! empty($partial) && file_exists($partial)) { |
|
| 172 | 172 | include $partial; |
| 173 | - }else{ |
|
| 174 | - echo esc_html__( 'Partial Template not found: ', $this->plugin_slug ) . $partial_id; |
|
| 173 | + } else { |
|
| 174 | + echo esc_html__('Partial Template not found: ', $this->plugin_slug) . $partial_id; |
|
| 175 | 175 | } |
| 176 | 176 | ?> |
| 177 | 177 | </script> |
@@ -180,16 +180,16 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | |
| 183 | - if( !empty( $uix['modals'] ) ){ |
|
| 184 | - foreach( $uix['modals'] as $modal_id => $modal ){ |
|
| 183 | + if ( ! empty($uix['modals'])) { |
|
| 184 | + foreach ($uix['modals'] as $modal_id => $modal) { |
|
| 185 | 185 | ?> |
| 186 | - <script type="text/html" id="__modal_<?php echo esc_attr( $modal_id ); ?>" data-handlebars-partial="<?php echo esc_attr( $modal_id ); ?>"> |
|
| 186 | + <script type="text/html" id="__modal_<?php echo esc_attr($modal_id); ?>" data-handlebars-partial="<?php echo esc_attr($modal_id); ?>"> |
|
| 187 | 187 | <?php |
| 188 | 188 | // include this tabs template |
| 189 | - if( !empty( $modal ) && file_exists( $modal ) ){ |
|
| 189 | + if ( ! empty($modal) && file_exists($modal)) { |
|
| 190 | 190 | include $modal; |
| 191 | - }else{ |
|
| 192 | - echo esc_html__( 'Modal Template not found: ', $this->plugin_slug ) . $modal_id; |
|
| 191 | + } else { |
|
| 192 | + echo esc_html__('Modal Template not found: ', $this->plugin_slug) . $modal_id; |
|
| 193 | 193 | } |
| 194 | 194 | ?> |
| 195 | 195 | </script> |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | Remove |
| 224 | 224 | </button> |
| 225 | 225 | </script> |
| 226 | - <?php if( !empty( $uix['chromeless'] ) ){ ?> |
|
| 226 | + <?php if ( ! empty($uix['chromeless'])) { ?> |
|
| 227 | 227 | <script type="text/javascript"> |
| 228 | 228 | jQuery('#<?php echo $metabox['id']; ?>').addClass('uix-metabox'); |
| 229 | 229 | </script> |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | * |
| 248 | 248 | * @return object|\uix\uix A single instance of this class. |
| 249 | 249 | */ |
| 250 | - public static function get_instance( $slug ) { |
|
| 250 | + public static function get_instance($slug) { |
|
| 251 | 251 | |
| 252 | 252 | // If the single instance hasn't been set, set it now. |
| 253 | - if ( null == self::$instance ) { |
|
| 254 | - self::$instance = new self( $slug ); |
|
| 253 | + if (null == self::$instance) { |
|
| 254 | + self::$instance = new self($slug); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | return self::$instance; |
@@ -264,33 +264,33 @@ discard block |
||
| 264 | 264 | * @since 1.0.0 |
| 265 | 265 | * @return string/array the requested setting |
| 266 | 266 | */ |
| 267 | - public static function get_setting( $path, $manual = false ) { |
|
| 267 | + public static function get_setting($path, $manual = false) { |
|
| 268 | 268 | |
| 269 | - $path = explode( '.', $path ); |
|
| 269 | + $path = explode('.', $path); |
|
| 270 | 270 | $temp = null; |
| 271 | - $page_slug = array_shift( $path ); |
|
| 271 | + $page_slug = array_shift($path); |
|
| 272 | 272 | |
| 273 | - if ( null == self::$instance || true === $manual ) { |
|
| 274 | - if ( false === $manual ) { |
|
| 275 | - trigger_error( 'Cannot request a value without a UIX instance. Set second argument to TRUE for manual lookup.' ); |
|
| 273 | + if (null == self::$instance || true === $manual) { |
|
| 274 | + if (false === $manual) { |
|
| 275 | + trigger_error('Cannot request a value without a UIX instance. Set second argument to TRUE for manual lookup.'); |
|
| 276 | 276 | |
| 277 | 277 | return; |
| 278 | 278 | } |
| 279 | 279 | // attempt a manual lookup - requires the full option name |
| 280 | 280 | $option_tag = $page_slug; |
| 281 | 281 | } else { |
| 282 | - if ( ! empty( self::$instance->pages[ $page_slug ]['option_name'] ) ) { |
|
| 283 | - $option_tag = self::$instance->pages[ $page_slug ]['option_name']; |
|
| 282 | + if ( ! empty(self::$instance->pages[$page_slug]['option_name'])) { |
|
| 283 | + $option_tag = self::$instance->pages[$page_slug]['option_name']; |
|
| 284 | 284 | } else { |
| 285 | 285 | $option_tag = '_' . self::$instance->plugin_slug . '_' . $page_slug; |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | - $temp = get_option( $option_tag ); |
|
| 289 | - foreach ( $path as $index => $value ) { |
|
| 290 | - if ( ! isset( $temp[ $value ] ) ) { |
|
| 288 | + $temp = get_option($option_tag); |
|
| 289 | + foreach ($path as $index => $value) { |
|
| 290 | + if ( ! isset($temp[$value])) { |
|
| 291 | 291 | return null; |
| 292 | 292 | } |
| 293 | - $temp = $temp[ $value ]; |
|
| 293 | + $temp = $temp[$value]; |
|
| 294 | 294 | } |
| 295 | 295 | |
| 296 | 296 | return $temp; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @since 1.0.0 |
| 304 | 304 | */ |
| 305 | - public function register_pages( $pages ) { |
|
| 305 | + public function register_pages($pages) { |
|
| 306 | 306 | |
| 307 | 307 | /** |
| 308 | 308 | * Filter settings pages to be created |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | * @param array $pages Page structures to be created |
| 311 | 311 | */ |
| 312 | 312 | |
| 313 | - $this->pages = apply_filters( $this->plugin_slug . '_set_admin_pages', $pages ); |
|
| 313 | + $this->pages = apply_filters($this->plugin_slug . '_set_admin_pages', $pages); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | * |
| 319 | 319 | * @since 1.0.0 |
| 320 | 320 | */ |
| 321 | - public function register_metaboxes( $metaboxes ) { |
|
| 321 | + public function register_metaboxes($metaboxes) { |
|
| 322 | 322 | // register pages |
| 323 | 323 | $this->metaboxes = $metaboxes; |
| 324 | 324 | } |
@@ -334,13 +334,13 @@ discard block |
||
| 334 | 334 | |
| 335 | 335 | $page = $this->get_page(); |
| 336 | 336 | |
| 337 | - if ( ! empty( $page['help'] ) ) { |
|
| 337 | + if ( ! empty($page['help'])) { |
|
| 338 | 338 | |
| 339 | 339 | $screen = get_current_screen(); |
| 340 | 340 | |
| 341 | - foreach ( (array) $page['help'] as $help_slug => $help ) { |
|
| 341 | + foreach ((array) $page['help'] as $help_slug => $help) { |
|
| 342 | 342 | |
| 343 | - if ( is_file( $help['content'] ) && file_exists( $help['content'] ) ) { |
|
| 343 | + if (is_file($help['content']) && file_exists($help['content'])) { |
|
| 344 | 344 | ob_start(); |
| 345 | 345 | include $help['content']; |
| 346 | 346 | $content = ob_get_clean(); |
@@ -348,16 +348,16 @@ discard block |
||
| 348 | 348 | $content = $help['content']; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - $screen->add_help_tab( array( |
|
| 351 | + $screen->add_help_tab(array( |
|
| 352 | 352 | 'id' => $help_slug, |
| 353 | 353 | 'title' => $help['title'], |
| 354 | 354 | 'content' => $content, |
| 355 | - ) ); |
|
| 355 | + )); |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | // Help sidebars are optional |
| 359 | - if ( ! empty( $page['help_sidebar'] ) ) { |
|
| 360 | - $screen->set_help_sidebar( $page['help_sidebar'] ); |
|
| 359 | + if ( ! empty($page['help_sidebar'])) { |
|
| 360 | + $screen->set_help_sidebar($page['help_sidebar']); |
|
| 361 | 361 | } |
| 362 | 362 | } |
| 363 | 363 | |
@@ -370,24 +370,24 @@ discard block |
||
| 370 | 370 | * |
| 371 | 371 | * @since 0.0.1 |
| 372 | 372 | */ |
| 373 | - public function save_meta( $post_id ){ |
|
| 373 | + public function save_meta($post_id) { |
|
| 374 | 374 | |
| 375 | - if( !empty( $_POST['uix'] ) ){ |
|
| 375 | + if ( ! empty($_POST['uix'])) { |
|
| 376 | 376 | |
| 377 | - foreach( ( array) $_POST['uix'] as $slug => $data ){ |
|
| 378 | - if( empty( $this->metaboxes[ $slug ] ) ){ |
|
| 377 | + foreach ((array) $_POST['uix'] as $slug => $data) { |
|
| 378 | + if (empty($this->metaboxes[$slug])) { |
|
| 379 | 379 | continue; |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - $uix = $this->metaboxes[ $slug ]; |
|
| 383 | - $config = json_decode( stripslashes_deep( $data ), true ); |
|
| 382 | + $uix = $this->metaboxes[$slug]; |
|
| 383 | + $config = json_decode(stripslashes_deep($data), true); |
|
| 384 | 384 | |
| 385 | - if( empty( $uix['meta_name'] ) ){ |
|
| 386 | - $uix['meta_name'] = '_' . $this->plugin_slug . '_' . sanitize_text_field( $slug ); |
|
| 385 | + if (empty($uix['meta_name'])) { |
|
| 386 | + $uix['meta_name'] = '_' . $this->plugin_slug . '_' . sanitize_text_field($slug); |
|
| 387 | 387 | } |
| 388 | 388 | // get config object |
| 389 | 389 | |
| 390 | - $config_object = update_post_meta( $post_id, $uix['meta_name'], $config ); |
|
| 390 | + $config_object = update_post_meta($post_id, $uix['meta_name'], $config); |
|
| 391 | 391 | |
| 392 | 392 | } |
| 393 | 393 | |
@@ -405,17 +405,17 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public function save_config() { |
| 407 | 407 | |
| 408 | - if ( ! empty( $_POST['config'] ) ) { |
|
| 408 | + if ( ! empty($_POST['config'])) { |
|
| 409 | 409 | |
| 410 | - $config = json_decode( stripslashes_deep( $_POST['config'] ), true ); |
|
| 410 | + $config = json_decode(stripslashes_deep($_POST['config']), true); |
|
| 411 | 411 | |
| 412 | - if ( wp_verify_nonce( $_POST['uix_setup'], $this->plugin_slug ) ) { |
|
| 412 | + if (wp_verify_nonce($_POST['uix_setup'], $this->plugin_slug)) { |
|
| 413 | 413 | |
| 414 | - $page_slug = sanitize_text_field( $_POST['page_slug'] ); |
|
| 414 | + $page_slug = sanitize_text_field($_POST['page_slug']); |
|
| 415 | 415 | |
| 416 | - if ( ! empty( $this->pages[ $page_slug ] ) ) { |
|
| 416 | + if ( ! empty($this->pages[$page_slug])) { |
|
| 417 | 417 | $params = null; |
| 418 | - if ( ! empty( $_POST['params'] ) ) { |
|
| 418 | + if ( ! empty($_POST['params'])) { |
|
| 419 | 419 | $params = $_POST['params']; |
| 420 | 420 | } |
| 421 | 421 | /** |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | * @param array $page_config the page config array |
| 425 | 425 | * @param array $params any defined save_params. |
| 426 | 426 | */ |
| 427 | - $page = apply_filters( $this->plugin_slug . '_get_page_save', $this->pages[ $page_slug ], $params ); |
|
| 427 | + $page = apply_filters($this->plugin_slug . '_get_page_save', $this->pages[$page_slug], $params); |
|
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | 430 | * Filter config object |
@@ -432,37 +432,37 @@ discard block |
||
| 432 | 432 | * @param array $config the config array to save |
| 433 | 433 | * @param array $page the page config to be saved for |
| 434 | 434 | */ |
| 435 | - $config = apply_filters( $this->plugin_slug . '_pre_save_config', $config, $page ); |
|
| 435 | + $config = apply_filters($this->plugin_slug . '_pre_save_config', $config, $page); |
|
| 436 | 436 | |
| 437 | 437 | |
| 438 | - $success = __( 'Settings saved.', $this->plugin_slug ); |
|
| 439 | - if ( ! empty( $page['saved_message'] ) ) { |
|
| 438 | + $success = __('Settings saved.', $this->plugin_slug); |
|
| 439 | + if ( ! empty($page['saved_message'])) { |
|
| 440 | 440 | $success = $page['saved_message']; |
| 441 | 441 | } |
| 442 | 442 | $option_tag = '_' . $this->plugin_slug . '_' . $page_slug; |
| 443 | - if ( ! empty( $page['option_name'] ) ) { |
|
| 443 | + if ( ! empty($page['option_name'])) { |
|
| 444 | 444 | $option_tag = $page['option_name']; |
| 445 | 445 | } |
| 446 | 446 | // push backup if not autosave |
| 447 | - if ( empty( $_POST['autosave'] ) ) { |
|
| 448 | - $previous = get_option( $option_tag ); |
|
| 449 | - if ( ! empty( $previous ) ) { |
|
| 450 | - update_option( $option_tag . '-' . current_time( 'timestamp' ), $previous ); |
|
| 447 | + if (empty($_POST['autosave'])) { |
|
| 448 | + $previous = get_option($option_tag); |
|
| 449 | + if ( ! empty($previous)) { |
|
| 450 | + update_option($option_tag . '-' . current_time('timestamp'), $previous); |
|
| 451 | 451 | } |
| 452 | 452 | } |
| 453 | 453 | // save object |
| 454 | - update_option( $option_tag, $config ); |
|
| 455 | - wp_send_json_success( $success ); |
|
| 454 | + update_option($option_tag, $config); |
|
| 455 | + wp_send_json_success($success); |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | } else { |
| 459 | - wp_send_json_error( esc_html__( 'Could not verify nonce', $this->plugin_slug ) ); |
|
| 459 | + wp_send_json_error(esc_html__('Could not verify nonce', $this->plugin_slug)); |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // nope |
| 465 | - wp_send_json_error( esc_html__( 'Could not save, sorry.', $this->plugin_slug ) ); |
|
| 465 | + wp_send_json_error(esc_html__('Could not save, sorry.', $this->plugin_slug)); |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | public function enqueue_admin_stylescripts() { |
| 477 | 477 | |
| 478 | 478 | $uix = $this->get_page(); |
| 479 | - if ( false === $uix ) { |
|
| 479 | + if (false === $uix) { |
|
| 480 | 480 | return; |
| 481 | 481 | } |
| 482 | 482 | |
@@ -484,39 +484,39 @@ discard block |
||
| 484 | 484 | |
| 485 | 485 | // allow for minimized scripts |
| 486 | 486 | $prefix = '.min'; |
| 487 | - $uix_url = plugin_dir_url( __FILE__ ); |
|
| 488 | - if ( defined( 'DEBUG_SCRIPTS' ) ) { |
|
| 487 | + $uix_url = plugin_dir_url(__FILE__); |
|
| 488 | + if (defined('DEBUG_SCRIPTS')) { |
|
| 489 | 489 | //$prefix = null; |
| 490 | 490 | } |
| 491 | 491 | // base styles |
| 492 | - wp_enqueue_style( $this->plugin_slug . '-base-icons', $uix_url . 'assets/css/icons' . $prefix . '.css' ); |
|
| 493 | - wp_enqueue_style( $this->plugin_slug . '-base-styles', $uix_url . 'assets/css/admin' . $prefix . '.css' ); |
|
| 492 | + wp_enqueue_style($this->plugin_slug . '-base-icons', $uix_url . 'assets/css/icons' . $prefix . '.css'); |
|
| 493 | + wp_enqueue_style($this->plugin_slug . '-base-styles', $uix_url . 'assets/css/admin' . $prefix . '.css'); |
|
| 494 | 494 | // enqueue scripts |
| 495 | - wp_enqueue_script( 'handlebars', $uix_url . 'assets/js/handlebars.min-latest.js', array(), null, true ); |
|
| 495 | + wp_enqueue_script('handlebars', $uix_url . 'assets/js/handlebars.min-latest.js', array(), null, true); |
|
| 496 | 496 | // if has modals |
| 497 | - if ( ! empty( $uix['modals'] ) ) { |
|
| 498 | - wp_enqueue_script( $this->plugin_slug . '-core-modals', $uix_url . 'assets/js/uix-modals' . $prefix . '.js', array( |
|
| 497 | + if ( ! empty($uix['modals'])) { |
|
| 498 | + wp_enqueue_script($this->plugin_slug . '-core-modals', $uix_url . 'assets/js/uix-modals' . $prefix . '.js', array( |
|
| 499 | 499 | 'jquery', |
| 500 | 500 | 'handlebars', |
| 501 | - ), null, true ); |
|
| 501 | + ), null, true); |
|
| 502 | 502 | } |
| 503 | - wp_enqueue_script( $this->plugin_slug . '-helpers', $uix_url . 'assets/js/uix-helpers' . $prefix . '.js', array( 'handlebars' ), null, true ); |
|
| 504 | - wp_enqueue_script( $this->plugin_slug . '-core-admin', $uix_url . 'assets/js/uix-core' . $prefix . '.js', array( |
|
| 503 | + wp_enqueue_script($this->plugin_slug . '-helpers', $uix_url . 'assets/js/uix-helpers' . $prefix . '.js', array('handlebars'), null, true); |
|
| 504 | + wp_enqueue_script($this->plugin_slug . '-core-admin', $uix_url . 'assets/js/uix-core' . $prefix . '.js', array( |
|
| 505 | 505 | 'jquery', |
| 506 | 506 | 'handlebars', |
| 507 | - ), null, true ); |
|
| 507 | + ), null, true); |
|
| 508 | 508 | |
| 509 | 509 | // enqueue admin runtime styles |
| 510 | - $this->enqueue_set( $uix, $this->plugin_slug . '-' . $uix['page_slug'] ); |
|
| 510 | + $this->enqueue_set($uix, $this->plugin_slug . '-' . $uix['page_slug']); |
|
| 511 | 511 | |
| 512 | 512 | // enqueue tab specific runtime styles |
| 513 | - if ( ! empty( $uix['tabs'] ) ) { |
|
| 514 | - foreach ( $uix['tabs'] as $tab_slug => $tab ) { |
|
| 513 | + if ( ! empty($uix['tabs'])) { |
|
| 514 | + foreach ($uix['tabs'] as $tab_slug => $tab) { |
|
| 515 | 515 | //$this->enqueue_set( $tab, $this->plugin_slug . '-' . $uix['page_slug'] . '-' . $tab_slug ); |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
| 519 | - wp_localize_script( $this->plugin_slug . '-core-admin', 'uix', $uix ); |
|
| 519 | + wp_localize_script($this->plugin_slug . '-core-admin', 'uix', $uix); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | /** |
@@ -526,7 +526,7 @@ discard block |
||
| 526 | 526 | * |
| 527 | 527 | * @return null |
| 528 | 528 | */ |
| 529 | - public function enqueue_metabox_stylescripts( $metaboxes, $post_type ) { |
|
| 529 | + public function enqueue_metabox_stylescripts($metaboxes, $post_type) { |
|
| 530 | 530 | |
| 531 | 531 | |
| 532 | 532 | $uix = array( |
@@ -538,35 +538,35 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | // allow for minimized scripts |
| 540 | 540 | $prefix = '.min'; |
| 541 | - $uix_url = plugin_dir_url( __FILE__ ); |
|
| 542 | - if( defined( 'DEBUG_SCRIPTS' ) ){ |
|
| 541 | + $uix_url = plugin_dir_url(__FILE__); |
|
| 542 | + if (defined('DEBUG_SCRIPTS')) { |
|
| 543 | 543 | $prefix = null; |
| 544 | 544 | } |
| 545 | 545 | // base styles |
| 546 | - wp_enqueue_style( $this->plugin_slug . '-base-icons', $uix_url . 'assets/css/icons' . $prefix . '.css' ); |
|
| 547 | - wp_enqueue_style( $this->plugin_slug . '-base-styles', $uix_url . 'assets/css/metabox' . $prefix . '.css' ); |
|
| 546 | + wp_enqueue_style($this->plugin_slug . '-base-icons', $uix_url . 'assets/css/icons' . $prefix . '.css'); |
|
| 547 | + wp_enqueue_style($this->plugin_slug . '-base-styles', $uix_url . 'assets/css/metabox' . $prefix . '.css'); |
|
| 548 | 548 | // enqueue scripts |
| 549 | - wp_enqueue_script( 'handlebars', $uix_url . 'assets/js/handlebars.min-latest.js', array(), null, true ); |
|
| 549 | + wp_enqueue_script('handlebars', $uix_url . 'assets/js/handlebars.min-latest.js', array(), null, true); |
|
| 550 | 550 | // if has modals |
| 551 | 551 | |
| 552 | - wp_enqueue_script( $this->plugin_slug . '-helpers', $uix_url . 'assets/js/uix-helpers' . $prefix . '.js', array( 'handlebars' ), null, true ); |
|
| 553 | - wp_enqueue_script( $this->plugin_slug . '-core-admin', $uix_url . 'assets/js/uix-core' . $prefix . '.js', array( 'jquery', 'handlebars' ), null, true ); |
|
| 552 | + wp_enqueue_script($this->plugin_slug . '-helpers', $uix_url . 'assets/js/uix-helpers' . $prefix . '.js', array('handlebars'), null, true); |
|
| 553 | + wp_enqueue_script($this->plugin_slug . '-core-admin', $uix_url . 'assets/js/uix-core' . $prefix . '.js', array('jquery', 'handlebars'), null, true); |
|
| 554 | 554 | |
| 555 | - foreach( $metaboxes as $slug=>$metabox ){ |
|
| 556 | - if( !empty( $metabox['modals'] ) ){ |
|
| 555 | + foreach ($metaboxes as $slug=>$metabox) { |
|
| 556 | + if ( ! empty($metabox['modals'])) { |
|
| 557 | 557 | $uix['modals'] = true; |
| 558 | 558 | } |
| 559 | - $uix['config'][ $slug ] = $metabox['config']; |
|
| 559 | + $uix['config'][$slug] = $metabox['config']; |
|
| 560 | 560 | // enqueue admin runtime styles |
| 561 | - $this->enqueue_set( $metabox, $this->plugin_slug . '-' . $slug ); |
|
| 561 | + $this->enqueue_set($metabox, $this->plugin_slug . '-' . $slug); |
|
| 562 | 562 | |
| 563 | 563 | } |
| 564 | - if( !empty( $uix['modals'] ) ){ |
|
| 565 | - wp_enqueue_script( $this->plugin_slug . '-core-modals', $uix_url . 'assets/js/uix-modals' . $prefix . '.js', array( 'jquery', 'handlebars' ), null, true ); |
|
| 564 | + if ( ! empty($uix['modals'])) { |
|
| 565 | + wp_enqueue_script($this->plugin_slug . '-core-modals', $uix_url . 'assets/js/uix-modals' . $prefix . '.js', array('jquery', 'handlebars'), null, true); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | |
| 569 | - wp_localize_script( $this->plugin_slug . '-core-admin', 'uix', $uix ); |
|
| 569 | + wp_localize_script($this->plugin_slug . '-core-admin', 'uix', $uix); |
|
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | * @since 0.0.1 |
| 577 | 577 | * |
| 578 | 578 | */ |
| 579 | - private function enqueue_set( $set, $prefix ) { |
|
| 579 | + private function enqueue_set($set, $prefix) { |
|
| 580 | 580 | // go over the set to see if it has styles or scripts |
| 581 | 581 | |
| 582 | 582 | // setup default args for array type includes |
@@ -589,31 +589,31 @@ discard block |
||
| 589 | 589 | ); |
| 590 | 590 | |
| 591 | 591 | // enqueue set specific runtime styles |
| 592 | - if ( ! empty( $set['styles'] ) ) { |
|
| 593 | - foreach ( $set['styles'] as $style_key => $style ) { |
|
| 594 | - if ( is_int( $style_key ) ) { |
|
| 595 | - wp_enqueue_style( $style ); |
|
| 592 | + if ( ! empty($set['styles'])) { |
|
| 593 | + foreach ($set['styles'] as $style_key => $style) { |
|
| 594 | + if (is_int($style_key)) { |
|
| 595 | + wp_enqueue_style($style); |
|
| 596 | 596 | } else { |
| 597 | - if ( is_array( $style ) ) { |
|
| 598 | - $args = array_merge( $arguments_array, $style ); |
|
| 599 | - wp_enqueue_style( $prefix . '-' . $script_key, $args['src'], $args['deps'], $args['ver'], $args['in_footer'] ); |
|
| 597 | + if (is_array($style)) { |
|
| 598 | + $args = array_merge($arguments_array, $style); |
|
| 599 | + wp_enqueue_style($prefix . '-' . $script_key, $args['src'], $args['deps'], $args['ver'], $args['in_footer']); |
|
| 600 | 600 | } else { |
| 601 | - wp_enqueue_style( $prefix . '-' . $style_key, $style ); |
|
| 601 | + wp_enqueue_style($prefix . '-' . $style_key, $style); |
|
| 602 | 602 | } |
| 603 | 603 | } |
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | 606 | // enqueue set specific runtime scripts |
| 607 | - if ( ! empty( $set['scripts'] ) ) { |
|
| 608 | - foreach ( $set['scripts'] as $script_key => $script ) { |
|
| 609 | - if ( is_int( $script_key ) ) { |
|
| 610 | - wp_enqueue_script( $script ); |
|
| 607 | + if ( ! empty($set['scripts'])) { |
|
| 608 | + foreach ($set['scripts'] as $script_key => $script) { |
|
| 609 | + if (is_int($script_key)) { |
|
| 610 | + wp_enqueue_script($script); |
|
| 611 | 611 | } else { |
| 612 | - if ( is_array( $script ) ) { |
|
| 613 | - $args = array_merge( $arguments_array, $script ); |
|
| 614 | - wp_enqueue_script( $prefix . '-' . $script_key, $args['src'], $args['deps'], $args['ver'], $args['in_footer'] ); |
|
| 612 | + if (is_array($script)) { |
|
| 613 | + $args = array_merge($arguments_array, $script); |
|
| 614 | + wp_enqueue_script($prefix . '-' . $script_key, $args['src'], $args['deps'], $args['ver'], $args['in_footer']); |
|
| 615 | 615 | } else { |
| 616 | - wp_enqueue_script( $prefix . '-' . $script_key, $script ); |
|
| 616 | + wp_enqueue_script($prefix . '-' . $script_key, $script); |
|
| 617 | 617 | } |
| 618 | 618 | } |
| 619 | 619 | } |
@@ -632,13 +632,13 @@ discard block |
||
| 632 | 632 | // check that the scrren object is valid to be safe. |
| 633 | 633 | $screen = get_current_screen(); |
| 634 | 634 | |
| 635 | - if ( empty( $screen ) || ! is_object( $screen ) ) { |
|
| 635 | + if (empty($screen) || ! is_object($screen)) { |
|
| 636 | 636 | return false; |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | // get the page slug from base ID |
| 640 | - $page_slug = array_search( $screen->base, $this->plugin_screen_hook_suffix ); |
|
| 641 | - if ( empty( $page_slug ) || empty( $this->pages[ $page_slug ] ) ) { |
|
| 640 | + $page_slug = array_search($screen->base, $this->plugin_screen_hook_suffix); |
|
| 641 | + if (empty($page_slug) || empty($this->pages[$page_slug])) { |
|
| 642 | 642 | return false; // in case its not found or the array item is no longer valid, just leave. |
| 643 | 643 | } |
| 644 | 644 | /** |
@@ -646,13 +646,13 @@ discard block |
||
| 646 | 646 | * |
| 647 | 647 | * @param array $page The page object array. |
| 648 | 648 | */ |
| 649 | - $uix = apply_filters( $this->plugin_slug . '_get_page', $this->pages[ $page_slug ] ); |
|
| 649 | + $uix = apply_filters($this->plugin_slug . '_get_page', $this->pages[$page_slug]); |
|
| 650 | 650 | |
| 651 | - if ( empty( $uix['option_name'] ) ) { |
|
| 652 | - $uix['option_name'] = '_' . $this->plugin_slug . '_' . sanitize_text_field( $page_slug ); |
|
| 651 | + if (empty($uix['option_name'])) { |
|
| 652 | + $uix['option_name'] = '_' . $this->plugin_slug . '_' . sanitize_text_field($page_slug); |
|
| 653 | 653 | } |
| 654 | 654 | // get config object |
| 655 | - $config_object = get_option( $uix['option_name'], array() ); |
|
| 655 | + $config_object = get_option($uix['option_name'], array()); |
|
| 656 | 656 | |
| 657 | 657 | $uix['page_slug'] = $page_slug; |
| 658 | 658 | /** |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @param array $config_object The object as retrieved from DB |
| 662 | 662 | * @param array $page_slug The page slug this object belongs to. |
| 663 | 663 | */ |
| 664 | - $uix['config'] = apply_filters( $this->plugin_slug . '_get_config', $config_object, $uix ); |
|
| 664 | + $uix['config'] = apply_filters($this->plugin_slug . '_get_config', $config_object, $uix); |
|
| 665 | 665 | |
| 666 | 666 | |
| 667 | 667 | return $uix; |
@@ -674,18 +674,18 @@ discard block |
||
| 674 | 674 | * |
| 675 | 675 | * @return array $metabox array structure of current uix metabox |
| 676 | 676 | */ |
| 677 | - private function get_metabox( $slug ){ |
|
| 677 | + private function get_metabox($slug) { |
|
| 678 | 678 | global $post; |
| 679 | 679 | |
| 680 | 680 | // check that the scrren object is valid to be safe. |
| 681 | 681 | $screen = get_current_screen(); |
| 682 | 682 | |
| 683 | - if( empty( $screen ) || !is_object( $screen ) || empty( $screen->post_type ) ){ |
|
| 683 | + if (empty($screen) || ! is_object($screen) || empty($screen->post_type)) { |
|
| 684 | 684 | return false; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | // get the page slug from base ID |
| 688 | - if( empty( $this->metaboxes[ $slug ] ) ){ |
|
| 688 | + if (empty($this->metaboxes[$slug])) { |
|
| 689 | 689 | return false; // in case its not found or the array item is no longer valid, just leave. |
| 690 | 690 | } |
| 691 | 691 | /** |
@@ -693,14 +693,14 @@ discard block |
||
| 693 | 693 | * |
| 694 | 694 | * @param array $page The page object array. |
| 695 | 695 | */ |
| 696 | - $uix = apply_filters( $this->plugin_slug . '_get_metabox', $this->metaboxes[ $slug ] ); |
|
| 696 | + $uix = apply_filters($this->plugin_slug . '_get_metabox', $this->metaboxes[$slug]); |
|
| 697 | 697 | |
| 698 | - if( empty( $uix['meta_name'] ) ){ |
|
| 699 | - $uix['meta_name'] = '_' . $this->plugin_slug . '_' . sanitize_text_field( $slug ); |
|
| 698 | + if (empty($uix['meta_name'])) { |
|
| 699 | + $uix['meta_name'] = '_' . $this->plugin_slug . '_' . sanitize_text_field($slug); |
|
| 700 | 700 | } |
| 701 | 701 | // get config object |
| 702 | 702 | |
| 703 | - $config_object = get_post_meta( $post->ID, $uix['meta_name'], true ); |
|
| 703 | + $config_object = get_post_meta($post->ID, $uix['meta_name'], true); |
|
| 704 | 704 | |
| 705 | 705 | $uix['slug'] = $slug; |
| 706 | 706 | /** |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | * @param array $config_object The object as retrieved from DB |
| 710 | 710 | * @param array $slug The page slug this object belongs to. |
| 711 | 711 | */ |
| 712 | - $uix['config'] = apply_filters( $this->plugin_slug . '_get_meta_config', $config_object, $uix ); |
|
| 712 | + $uix['config'] = apply_filters($this->plugin_slug . '_get_meta_config', $config_object, $uix); |
|
| 713 | 713 | |
| 714 | 714 | return $uix; |
| 715 | 715 | |
@@ -723,9 +723,9 @@ discard block |
||
| 723 | 723 | */ |
| 724 | 724 | public function add_settings_pages() { |
| 725 | 725 | |
| 726 | - foreach ( (array) $this->pages as $page_slug => $page ) { |
|
| 726 | + foreach ((array) $this->pages as $page_slug => $page) { |
|
| 727 | 727 | |
| 728 | - if ( empty( $page['page_title'] ) || empty( $page['menu_title'] ) ) { |
|
| 728 | + if (empty($page['page_title']) || empty($page['menu_title'])) { |
|
| 729 | 729 | continue; |
| 730 | 730 | } |
| 731 | 731 | |
@@ -734,39 +734,39 @@ discard block |
||
| 734 | 734 | 'icon' => null, |
| 735 | 735 | 'position' => null, |
| 736 | 736 | ); |
| 737 | - $args = array_merge( $args, $page ); |
|
| 737 | + $args = array_merge($args, $page); |
|
| 738 | 738 | |
| 739 | - if ( ! empty( $page['parent'] ) ) { |
|
| 739 | + if ( ! empty($page['parent'])) { |
|
| 740 | 740 | |
| 741 | - $this->plugin_screen_hook_suffix[ $page_slug ] = add_submenu_page( |
|
| 741 | + $this->plugin_screen_hook_suffix[$page_slug] = add_submenu_page( |
|
| 742 | 742 | $args['parent'], |
| 743 | 743 | $args['page_title'], |
| 744 | 744 | $args['menu_title'], |
| 745 | 745 | $args['capability'], |
| 746 | 746 | $this->plugin_slug . '-' . $page_slug, |
| 747 | - array( $this, 'create_admin_page' ) |
|
| 747 | + array($this, 'create_admin_page') |
|
| 748 | 748 | ); |
| 749 | 749 | |
| 750 | 750 | } else { |
| 751 | 751 | |
| 752 | - $this->plugin_screen_hook_suffix[ $page_slug ] = add_menu_page( |
|
| 752 | + $this->plugin_screen_hook_suffix[$page_slug] = add_menu_page( |
|
| 753 | 753 | $args['page_title'], |
| 754 | 754 | $args['menu_title'], |
| 755 | 755 | $args['capability'], |
| 756 | 756 | $this->plugin_slug . '-' . $page_slug, |
| 757 | - array( $this, 'create_admin_page' ), |
|
| 757 | + array($this, 'create_admin_page'), |
|
| 758 | 758 | $args['icon'], |
| 759 | 759 | $args['position'] |
| 760 | 760 | ); |
| 761 | 761 | } |
| 762 | - add_action( 'admin_print_styles-' . $this->plugin_screen_hook_suffix[ $page_slug ], array( |
|
| 762 | + add_action('admin_print_styles-' . $this->plugin_screen_hook_suffix[$page_slug], array( |
|
| 763 | 763 | $this, |
| 764 | 764 | 'enqueue_admin_stylescripts', |
| 765 | - ) ); |
|
| 766 | - add_action( 'load-' . $this->plugin_screen_hook_suffix[ $page_slug ], array( |
|
| 765 | + )); |
|
| 766 | + add_action('load-' . $this->plugin_screen_hook_suffix[$page_slug], array( |
|
| 767 | 767 | $this, |
| 768 | 768 | 'add_help', |
| 769 | - ) ); |
|
| 769 | + )); |
|
| 770 | 770 | } |
| 771 | 771 | } |
| 772 | 772 | |
@@ -778,70 +778,70 @@ discard block |
||
| 778 | 778 | public function create_admin_page() { |
| 779 | 779 | |
| 780 | 780 | $uix = $this->get_page(); |
| 781 | - $template_path = plugin_dir_path( dirname( __FILE__ ) ); |
|
| 781 | + $template_path = plugin_dir_path(dirname(__FILE__)); |
|
| 782 | 782 | ?> |
| 783 | 783 | <div class="wrap"> |
| 784 | 784 | |
| 785 | - <h1><?php esc_html_e( $uix['page_title'], $this->plugin_slug ); ?> |
|
| 786 | - <?php if ( ! empty( $uix['version'] ) ) { ?> |
|
| 787 | - <small><?php esc_html_e( $uix['version'], $this->plugin_slug ); ?></small><?php } ?> |
|
| 785 | + <h1><?php esc_html_e($uix['page_title'], $this->plugin_slug); ?> |
|
| 786 | + <?php if ( ! empty($uix['version'])) { ?> |
|
| 787 | + <small><?php esc_html_e($uix['version'], $this->plugin_slug); ?></small><?php } ?> |
|
| 788 | 788 | </h1> |
| 789 | - <?php if ( ! empty( $uix['tabs'] ) ) { ?> |
|
| 789 | + <?php if ( ! empty($uix['tabs'])) { ?> |
|
| 790 | 790 | <div class="wp-filter hide-if-no-js"> |
| 791 | 791 | <ul class="filter-links"> |
| 792 | - <?php foreach ( (array) $uix['tabs'] as $tab_slug => $tab ) { |
|
| 792 | + <?php foreach ((array) $uix['tabs'] as $tab_slug => $tab) { |
|
| 793 | 793 | $display = ""; |
| 794 | - if ( isset( $tab['disabled'] ) && true === $tab['disabled'] ) { |
|
| 794 | + if (isset($tab['disabled']) && true === $tab['disabled']) { |
|
| 795 | 795 | $display = 'style="display:none;"'; |
| 796 | 796 | } |
| 797 | 797 | ?> |
| 798 | 798 | <li><a <?php echo $display; ?> |
| 799 | - data-tab="<?php echo esc_attr( $tab_slug ); ?>" |
|
| 800 | - href="#<?php echo esc_attr( $tab_slug ) ?>"><?php echo esc_html( $tab['menu_title'] ); ?></a> |
|
| 799 | + data-tab="<?php echo esc_attr($tab_slug); ?>" |
|
| 800 | + href="#<?php echo esc_attr($tab_slug) ?>"><?php echo esc_html($tab['menu_title']); ?></a> |
|
| 801 | 801 | </li> |
| 802 | 802 | <?php } ?> |
| 803 | 803 | </ul> |
| 804 | 804 | </div> |
| 805 | 805 | <?php } ?> |
| 806 | - <?php wp_nonce_field( $this->plugin_slug, 'uix_setup' ); ?> |
|
| 806 | + <?php wp_nonce_field($this->plugin_slug, 'uix_setup'); ?> |
|
| 807 | 807 | <?php |
| 808 | - if ( ! empty( $uix['tabs'] ) ) { |
|
| 808 | + if ( ! empty($uix['tabs'])) { |
|
| 809 | 809 | $this->current_tab = false; |
| 810 | - foreach ( (array) $uix['tabs'] as $tab_slug => $tab ) { |
|
| 810 | + foreach ((array) $uix['tabs'] as $tab_slug => $tab) { |
|
| 811 | 811 | $this->current_tab = $tab_slug; ?> |
| 812 | 812 | <div class="uix-tab-canvas" |
| 813 | - data-app="<?php echo esc_attr( $tab_slug ); ?>"></div> |
|
| 813 | + data-app="<?php echo esc_attr($tab_slug); ?>"></div> |
|
| 814 | 814 | <script type="text/html" |
| 815 | - data-template="<?php echo esc_attr( $tab_slug ); ?>"> |
|
| 815 | + data-template="<?php echo esc_attr($tab_slug); ?>"> |
|
| 816 | 816 | <?php |
| 817 | - if ( ! empty( $tab['page_title'] ) ) { |
|
| 817 | + if ( ! empty($tab['page_title'])) { |
|
| 818 | 818 | echo '<h2>' . $tab['page_title']; |
| 819 | 819 | } |
| 820 | - if ( ! empty( $tab['page_description'] ) ) { ?> |
|
| 820 | + if ( ! empty($tab['page_description'])) { ?> |
|
| 821 | 821 | <small><?php echo $tab['page_description']; ?></small> <?php } |
| 822 | - if ( ! empty( $tab['page_title'] ) ) { |
|
| 822 | + if ( ! empty($tab['page_title'])) { |
|
| 823 | 823 | echo '</h2>'; |
| 824 | 824 | } |
| 825 | 825 | // include this tabs template |
| 826 | - if ( ! empty( $tab['template'] ) && file_exists( $tab['template'] ) ) { |
|
| 826 | + if ( ! empty($tab['template']) && file_exists($tab['template'])) { |
|
| 827 | 827 | include $tab['template']; |
| 828 | 828 | } else { |
| 829 | - echo esc_html__( 'Template not found: ', $this->plugin_slug ) . $tab['page_title']; |
|
| 829 | + echo esc_html__('Template not found: ', $this->plugin_slug) . $tab['page_title']; |
|
| 830 | 830 | } |
| 831 | 831 | ?> |
| 832 | 832 | </script> |
| 833 | - <?php if ( ! empty( $tab['partials'] ) ){ |
|
| 834 | - foreach ( $tab['partials'] as $partial_id => $partial ){ |
|
| 833 | + <?php if ( ! empty($tab['partials'])) { |
|
| 834 | + foreach ($tab['partials'] as $partial_id => $partial) { |
|
| 835 | 835 | ?> |
| 836 | 836 | <script type="text/html" |
| 837 | - id="__partial_<?php echo esc_attr( $partial_id ); ?>" |
|
| 838 | - data-handlebars-partial="<?php echo esc_attr( $partial_id ); ?>"> |
|
| 837 | + id="__partial_<?php echo esc_attr($partial_id); ?>" |
|
| 838 | + data-handlebars-partial="<?php echo esc_attr($partial_id); ?>"> |
|
| 839 | 839 | <?php |
| 840 | 840 | // include this tabs template |
| 841 | - if ( ! empty( $partial ) && file_exists( $template_path . $partial ) ) { |
|
| 841 | + if ( ! empty($partial) && file_exists($template_path . $partial)) { |
|
| 842 | 842 | include $template_path . $partial; |
| 843 | 843 | } else { |
| 844 | - echo esc_html__( 'Partial Template not found: ', $this->plugin_slug ) . $partial_id; |
|
| 844 | + echo esc_html__('Partial Template not found: ', $this->plugin_slug) . $partial_id; |
|
| 845 | 845 | } |
| 846 | 846 | ?> |
| 847 | 847 | </script> |
@@ -851,22 +851,22 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | $this->current_tab = false; |
| 853 | 853 | } else { |
| 854 | - if ( ! empty( $uix['template'] ) && file_exists( $uix['template'] ) ) { |
|
| 854 | + if ( ! empty($uix['template']) && file_exists($uix['template'])) { |
|
| 855 | 855 | include $uix['template']; |
| 856 | 856 | } |
| 857 | 857 | } |
| 858 | - if ( ! empty( $uix['modals'] ) ) { |
|
| 859 | - foreach ( $uix['modals'] as $modal_id => $modal ) { |
|
| 858 | + if ( ! empty($uix['modals'])) { |
|
| 859 | + foreach ($uix['modals'] as $modal_id => $modal) { |
|
| 860 | 860 | ?> |
| 861 | 861 | <script type="text/html" |
| 862 | - id="__modal_<?php echo esc_attr( $modal_id ); ?>" |
|
| 863 | - data-handlebars-partial="<?php echo esc_attr( $modal_id ); ?>"> |
|
| 862 | + id="__modal_<?php echo esc_attr($modal_id); ?>" |
|
| 863 | + data-handlebars-partial="<?php echo esc_attr($modal_id); ?>"> |
|
| 864 | 864 | <?php |
| 865 | 865 | // include this tabs template |
| 866 | - if ( ! empty( $modal ) && file_exists( $template_path . $modal ) ) { |
|
| 866 | + if ( ! empty($modal) && file_exists($template_path . $modal)) { |
|
| 867 | 867 | include $template_path . $modal; |
| 868 | 868 | } else { |
| 869 | - echo esc_html__( 'Modal Template not found: ', $this->plugin_slug ) . $modal_id; |
|
| 869 | + echo esc_html__('Modal Template not found: ', $this->plugin_slug) . $modal_id; |
|
| 870 | 870 | } |
| 871 | 871 | ?> |
| 872 | 872 | </script> |
@@ -875,9 +875,9 @@ discard block |
||
| 875 | 875 | } |
| 876 | 876 | ?> |
| 877 | 877 | <hr> |
| 878 | - <?php if ( ! empty( $uix['save_button'] ) ) { ?> |
|
| 878 | + <?php if ( ! empty($uix['save_button'])) { ?> |
|
| 879 | 879 | <p class="uix-footer-bar"><button type="button" class="button button-primary" data-save-object="true"> |
| 880 | - <?php esc_html_e( $uix['save_button'], $this->plugin_slug ); ?> |
|
| 880 | + <?php esc_html_e($uix['save_button'], $this->plugin_slug); ?> |
|
| 881 | 881 | </button> |
| 882 | 882 | <span class="spinner uix-save-spinner"></span> |
| 883 | 883 | <span class="save-confirm" style="display: none;"><span class="dashicons dashicons-yes"></span></span> |