@@ -37,14 +37,14 @@ discard block |
||
| 37 | 37 | * Contructor |
| 38 | 38 | */ |
| 39 | 39 | public function __construct() { |
| 40 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
| 41 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
| 42 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
| 43 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
| 44 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
| 45 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
| 46 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
| 47 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
| 40 | + add_filter('cmb2_enqueue_css', array($this, 'disable_cmb2_styles'), 1, 1); |
|
| 41 | + add_action('cmb2_before_form', array($this, 'generate_navigation'), 10, 4); |
|
| 42 | + add_action('cmb2_before_title_field_row', array($this, 'output_tab_open_div'), 10, 1); |
|
| 43 | + add_action('cmb2_after_tab_closing_field_row', array($this, 'output_tab_closing_div'), 10, 1); |
|
| 44 | + add_action('cmb2_render_tab_closing', array($this, 'cmb2_render_callback_for_tab_closing'), 10, 5); |
|
| 45 | + add_filter('cmb2_sanitize_tab_closing', array($this, 'cmb2_sanitize_tab_closing_callback'), 10, 2); |
|
| 46 | + add_action('cmb2_after_form', array($this, 'navigation_js'), 10, 4); |
|
| 47 | + add_filter('cmb2_options_page_redirect_url', array($this, 'add_tab_argument'), 10, 1); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public static function get_instance() { |
| 58 | 58 | // If the single instance hasn't been set, set it now. |
| 59 | - if ( null == self::$instance ) { |
|
| 59 | + if (null == self::$instance) { |
|
| 60 | 60 | self::$instance = new self(); |
| 61 | 61 | } |
| 62 | 62 | return self::$instance; |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | * |
| 68 | 68 | * @return bool $enabled Whether to enable (enqueue) styles. |
| 69 | 69 | */ |
| 70 | - public function disable_cmb2_styles( $enabled ) { |
|
| 71 | - if ( is_admin() ) { |
|
| 70 | + public function disable_cmb2_styles($enabled) { |
|
| 71 | + if (is_admin()) { |
|
| 72 | 72 | $current_screen = get_current_screen(); |
| 73 | - if ( is_object( $current_screen ) && 'plan_page_lsx_health_plan_options' === $current_screen->id ) { |
|
| 73 | + if (is_object($current_screen) && 'plan_page_lsx_health_plan_options' === $current_screen->id) { |
|
| 74 | 74 | $enabled = false; |
| 75 | 75 | } |
| 76 | 76 | } |
@@ -86,14 +86,14 @@ discard block |
||
| 86 | 86 | * @param object $cmb2_obj |
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
| 90 | - if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
| 89 | + public function generate_navigation($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
| 90 | + if ('lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type) { |
|
| 91 | 91 | $this->navigation = array(); |
| 92 | 92 | $this->is_options_page = true; |
| 93 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
| 94 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
| 95 | - if ( 'title' === $field['type'] ) { |
|
| 96 | - $this->navigation[ $field_index ] = $field['name']; |
|
| 93 | + if (isset($cmb2_obj->meta_box['fields']) && ! empty($cmb2_obj->meta_box['fields'])) { |
|
| 94 | + foreach ($cmb2_obj->meta_box['fields'] as $field_index => $field) { |
|
| 95 | + if ('title' === $field['type']) { |
|
| 96 | + $this->navigation[$field_index] = $field['name']; |
|
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | } |
@@ -107,32 +107,32 @@ discard block |
||
| 107 | 107 | * @return void |
| 108 | 108 | */ |
| 109 | 109 | public function output_navigation() { |
| 110 | - if ( ! empty( $this->navigation ) ) { |
|
| 110 | + if ( ! empty($this->navigation)) { |
|
| 111 | 111 | ?> |
| 112 | 112 | <div class="wp-filter hide-if-no-js"> |
| 113 | 113 | <ul class="filter-links"> |
| 114 | 114 | <?php |
| 115 | 115 | $first_tab = true; |
| 116 | - $total = count( $this->navigation ); |
|
| 116 | + $total = count($this->navigation); |
|
| 117 | 117 | $count = 0; |
| 118 | 118 | $separator = ' |'; |
| 119 | 119 | $selected_tab = ''; |
| 120 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
| 121 | - $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
| 120 | + if (isset($_GET['cmb_tab']) && '' !== $_GET['cmb_tab']) { |
|
| 121 | + $selected_tab = sanitize_text_field($_GET['cmb_tab']); |
|
| 122 | 122 | $selected_tab = 'settings_' . $selected_tab; |
| 123 | 123 | } |
| 124 | - foreach ( $this->navigation as $key => $label ) { |
|
| 124 | + foreach ($this->navigation as $key => $label) { |
|
| 125 | 125 | $count++; |
| 126 | 126 | $current_css = ''; |
| 127 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
| 127 | + if ((true === $first_tab && '' === $selected_tab) || $key === $selected_tab) { |
|
| 128 | 128 | $first_tab = false; |
| 129 | 129 | $current_css = 'current'; |
| 130 | 130 | } |
| 131 | - if ( $count === $total ) { |
|
| 131 | + if ($count === $total) { |
|
| 132 | 132 | $separator = ''; |
| 133 | 133 | } |
| 134 | 134 | ?> |
| 135 | - <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
|
| 135 | + <li><a href="#" class="<?php echo esc_attr($current_css); ?>" data-sort="<?php echo esc_attr($key); ?>_tab"><?php echo esc_attr($label); ?></a><?php echo esc_attr($separator); ?></li> |
|
| 136 | 136 | <?php |
| 137 | 137 | } |
| 138 | 138 | ?> |
@@ -148,10 +148,10 @@ discard block |
||
| 148 | 148 | * @param object $field CMB2_Field(); |
| 149 | 149 | * @return void |
| 150 | 150 | */ |
| 151 | - public function output_tab_open_div( $field ) { |
|
| 152 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
| 151 | + public function output_tab_open_div($field) { |
|
| 152 | + if (true === $this->is_options_page && isset($field->args['type']) && 'title' === $field->args['type']) { |
|
| 153 | 153 | ?> |
| 154 | - <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
|
| 154 | + <div id="<?php echo esc_attr($field->args['id']); ?>_tab" class="tab tab-nav hidden"> |
|
| 155 | 155 | <?php |
| 156 | 156 | } |
| 157 | 157 | } |
@@ -162,19 +162,19 @@ discard block |
||
| 162 | 162 | * @param object $field CMB2_Field(); |
| 163 | 163 | * @return void |
| 164 | 164 | */ |
| 165 | - public function output_tab_closing_div( $field ) { |
|
| 166 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
| 165 | + public function output_tab_closing_div($field) { |
|
| 166 | + if (true === $this->is_options_page && isset($field->args['type']) && 'tab_closing' === $field->args['type']) { |
|
| 167 | 167 | ?> |
| 168 | 168 | </div> |
| 169 | 169 | <?php |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
| 173 | + public function cmb2_render_callback_for_tab_closing($field, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
| 174 | 174 | return; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
| 177 | + public function cmb2_sanitize_tab_closing_callback($override_value, $value) { |
|
| 178 | 178 | return ''; |
| 179 | 179 | } |
| 180 | 180 | |
@@ -187,8 +187,8 @@ discard block |
||
| 187 | 187 | * @param object $cmb2_obj |
| 188 | 188 | * @return void |
| 189 | 189 | */ |
| 190 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
| 191 | - if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
| 190 | + public function navigation_js($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
| 191 | + if ('lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type) { |
|
| 192 | 192 | ?> |
| 193 | 193 | <script> |
| 194 | 194 | var LSX_HP_CMB2 = Object.create( null ); |
@@ -270,14 +270,14 @@ discard block |
||
| 270 | 270 | * @param string $url |
| 271 | 271 | * @return void |
| 272 | 272 | */ |
| 273 | - public function add_tab_argument( $url ) { |
|
| 274 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
| 275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
| 276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
| 277 | - if ( 'single' !== $tab_selection ) { |
|
| 278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
| 273 | + public function add_tab_argument($url) { |
|
| 274 | + if (isset($_POST['cmb_tab']) && '' !== $_POST['cmb_tab']) { // @codingStandardsIgnoreLine |
|
| 275 | + $tab_selection = sanitize_text_field($_POST['cmb_tab']); // @codingStandardsIgnoreLine |
|
| 276 | + $tab_selection = str_replace(array('settings_', '_tab'), '', $tab_selection); // @codingStandardsIgnoreLine |
|
| 277 | + if ('single' !== $tab_selection) { |
|
| 278 | + $url = add_query_arg('cmb_tab', $tab_selection, $url); |
|
| 279 | 279 | } else { |
| 280 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
| 280 | + $url = remove_query_arg('cmb_tab', $url); |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | return $url; |
@@ -33,35 +33,35 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | public function __construct() { |
| 35 | 35 | |
| 36 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
| 37 | - add_action( 'init', array( $this, 'plan_type_taxonomy_setup' ) ); |
|
| 38 | - add_action( 'init', array( $this, 'week_taxonomy_setup' ) ); |
|
| 36 | + add_action('init', array($this, 'register_post_type')); |
|
| 37 | + add_action('init', array($this, 'plan_type_taxonomy_setup')); |
|
| 38 | + add_action('init', array($this, 'week_taxonomy_setup')); |
|
| 39 | 39 | |
| 40 | 40 | // Icons for the plan types. |
| 41 | - add_action( 'create_term', array( $this, 'save_meta' ), 10, 2 ); |
|
| 42 | - add_action( 'edit_term', array( $this, 'save_meta' ), 10, 2 ); |
|
| 41 | + add_action('create_term', array($this, 'save_meta'), 10, 2); |
|
| 42 | + add_action('edit_term', array($this, 'save_meta'), 10, 2); |
|
| 43 | 43 | $prefix_taxonomy = 'plan-type'; |
| 44 | - add_action( sprintf( '%s_edit_form_fields', $prefix_taxonomy ), array( $this, 'add_thumbnail_form_field' ), 3, 1 ); |
|
| 44 | + add_action(sprintf('%s_edit_form_fields', $prefix_taxonomy), array($this, 'add_thumbnail_form_field'), 3, 1); |
|
| 45 | 45 | |
| 46 | 46 | // Register the Metaboxes. |
| 47 | - add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ), 5 ); |
|
| 48 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ), 5 ); |
|
| 49 | - add_action( 'cmb2_admin_init', array( $this, 'plan_connections' ), 5 ); |
|
| 50 | - add_action( 'cmb2_admin_init', array( $this, 'sections_metabox_loop' ), 1 ); |
|
| 47 | + add_action('cmb2_admin_init', array($this, 'featured_metabox'), 5); |
|
| 48 | + add_action('cmb2_admin_init', array($this, 'details_metaboxes'), 5); |
|
| 49 | + add_action('cmb2_admin_init', array($this, 'plan_connections'), 5); |
|
| 50 | + add_action('cmb2_admin_init', array($this, 'sections_metabox_loop'), 1); |
|
| 51 | 51 | |
| 52 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
| 52 | + add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100); |
|
| 53 | 53 | //add_filter( 'lsx_global_header_title', array( $this, 'hp_recipe_header_title' ), 200, 1 ); |
| 54 | 54 | |
| 55 | 55 | // Template Redirects. |
| 56 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
| 57 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
| 56 | + add_filter('lsx_health_plan_archive_template', array($this, 'enable_post_type'), 10, 1); |
|
| 57 | + add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1); |
|
| 58 | 58 | |
| 59 | 59 | // Plan Archive Actions. |
| 60 | - add_action( 'pre_get_posts', array( $this, 'set_parent_only' ), 10, 1 ); |
|
| 61 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
| 62 | - add_action( 'lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1 ); |
|
| 63 | - add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1 ); |
|
| 64 | - add_filter( 'lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1 ); |
|
| 60 | + add_action('pre_get_posts', array($this, 'set_parent_only'), 10, 1); |
|
| 61 | + add_filter('get_the_archive_title', array($this, 'get_the_archive_title'), 100); |
|
| 62 | + add_action('lsx_content_top', 'lsx_hp_plan_archive_filters', 10, 1); |
|
| 63 | + add_filter('lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_search_enabled', 10, 1); |
|
| 64 | + add_filter('lsx_hp_disable_plan_archive_filters', '\lsx_health_plan\functions\plan\is_filters_disabled', 10, 1); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | */ |
| 74 | 74 | public static function get_instance() { |
| 75 | 75 | // If the single instance hasn't been set, set it now. |
| 76 | - if ( null === self::$instance ) { |
|
| 76 | + if (null === self::$instance) { |
|
| 77 | 77 | self::$instance = new self(); |
| 78 | 78 | } |
| 79 | 79 | return self::$instance; |
@@ -83,21 +83,21 @@ discard block |
||
| 83 | 83 | */ |
| 84 | 84 | public function register_post_type() { |
| 85 | 85 | $labels = array( |
| 86 | - 'name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
| 87 | - 'singular_name' => esc_html__( 'Plan', 'lsx-health-plan' ), |
|
| 88 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
| 89 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
| 90 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
| 91 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
| 92 | - 'all_items' => esc_html__( 'All Plans', 'lsx-health-plan' ), |
|
| 93 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
| 94 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
| 95 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
| 96 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
| 86 | + 'name' => esc_html__('Plans', 'lsx-health-plan'), |
|
| 87 | + 'singular_name' => esc_html__('Plan', 'lsx-health-plan'), |
|
| 88 | + 'add_new' => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'), |
|
| 89 | + 'add_new_item' => esc_html__('Add New', 'lsx-health-plan'), |
|
| 90 | + 'edit_item' => esc_html__('Edit', 'lsx-health-plan'), |
|
| 91 | + 'new_item' => esc_html__('New', 'lsx-health-plan'), |
|
| 92 | + 'all_items' => esc_html__('All Plans', 'lsx-health-plan'), |
|
| 93 | + 'view_item' => esc_html__('View', 'lsx-health-plan'), |
|
| 94 | + 'search_items' => esc_html__('Search', 'lsx-health-plan'), |
|
| 95 | + 'not_found' => esc_html__('None found', 'lsx-health-plan'), |
|
| 96 | + 'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'), |
|
| 97 | 97 | 'parent_item_colon' => '', |
| 98 | - 'menu_name' => esc_html__( 'Plans', 'lsx-health-plan' ), |
|
| 98 | + 'menu_name' => esc_html__('Plans', 'lsx-health-plan'), |
|
| 99 | 99 | ); |
| 100 | - $args = array( |
|
| 100 | + $args = array( |
|
| 101 | 101 | 'labels' => $labels, |
| 102 | 102 | 'public' => true, |
| 103 | 103 | 'publicly_queryable' => true, |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | 'menu_icon' => 'dashicons-welcome-write-blog', |
| 108 | 108 | 'query_var' => true, |
| 109 | 109 | 'rewrite' => array( |
| 110 | - 'slug' => \lsx_health_plan\functions\get_option( 'plan_single_slug', 'plan' ), |
|
| 110 | + 'slug' => \lsx_health_plan\functions\get_option('plan_single_slug', 'plan'), |
|
| 111 | 111 | ), |
| 112 | 112 | 'capability_type' => 'page', |
| 113 | - 'has_archive' => \lsx_health_plan\functions\get_option( 'endpoint_plan_archive', 'plans' ), |
|
| 113 | + 'has_archive' => \lsx_health_plan\functions\get_option('endpoint_plan_archive', 'plans'), |
|
| 114 | 114 | 'hierarchical' => false, |
| 115 | 115 | 'menu_position' => null, |
| 116 | 116 | 'supports' => array( |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | 'custom-fields', |
| 122 | 122 | ), |
| 123 | 123 | ); |
| 124 | - register_post_type( 'plan', $args ); |
|
| 124 | + register_post_type('plan', $args); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | public function plan_type_taxonomy_setup() { |
| 131 | 131 | $labels = array( |
| 132 | - 'name' => esc_html_x( 'Plan Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
| 133 | - 'singular_name' => esc_html_x( 'Plan Type', 'taxonomy singular name', 'lsx-health-plan' ), |
|
| 134 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
| 135 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
| 136 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
| 137 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
| 138 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
| 139 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
| 140 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
| 141 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
| 142 | - 'menu_name' => esc_html__( 'Plan Types', 'lsx-health-plan' ), |
|
| 132 | + 'name' => esc_html_x('Plan Type', 'taxonomy general name', 'lsx-health-plan'), |
|
| 133 | + 'singular_name' => esc_html_x('Plan Type', 'taxonomy singular name', 'lsx-health-plan'), |
|
| 134 | + 'search_items' => esc_html__('Search', 'lsx-health-plan'), |
|
| 135 | + 'all_items' => esc_html__('All', 'lsx-health-plan'), |
|
| 136 | + 'parent_item' => esc_html__('Parent', 'lsx-health-plan'), |
|
| 137 | + 'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'), |
|
| 138 | + 'edit_item' => esc_html__('Edit', 'lsx-health-plan'), |
|
| 139 | + 'update_item' => esc_html__('Update', 'lsx-health-plan'), |
|
| 140 | + 'add_new_item' => esc_html__('Add New', 'lsx-health-plan'), |
|
| 141 | + 'new_item_name' => esc_html__('New Name', 'lsx-health-plan'), |
|
| 142 | + 'menu_name' => esc_html__('Plan Types', 'lsx-health-plan'), |
|
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | 145 | $args = array( |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | ), |
| 154 | 154 | ); |
| 155 | 155 | |
| 156 | - register_taxonomy( 'plan-type', array( 'plan' ), $args ); |
|
| 156 | + register_taxonomy('plan-type', array('plan'), $args); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | /** |
@@ -161,17 +161,17 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function week_taxonomy_setup() { |
| 163 | 163 | $labels = array( |
| 164 | - 'name' => esc_html_x( 'Week', 'taxonomy general name', 'lsx-health-plan' ), |
|
| 165 | - 'singular_name' => esc_html_x( 'Week', 'taxonomy singular name', 'lsx-health-plan' ), |
|
| 166 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
| 167 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
| 168 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
| 169 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
| 170 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
| 171 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
| 172 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
| 173 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
| 174 | - 'menu_name' => esc_html__( 'Weeks', 'lsx-health-plan' ), |
|
| 164 | + 'name' => esc_html_x('Week', 'taxonomy general name', 'lsx-health-plan'), |
|
| 165 | + 'singular_name' => esc_html_x('Week', 'taxonomy singular name', 'lsx-health-plan'), |
|
| 166 | + 'search_items' => esc_html__('Search', 'lsx-health-plan'), |
|
| 167 | + 'all_items' => esc_html__('All', 'lsx-health-plan'), |
|
| 168 | + 'parent_item' => esc_html__('Parent', 'lsx-health-plan'), |
|
| 169 | + 'parent_item_colon' => esc_html__('Parent:', 'lsx-health-plan'), |
|
| 170 | + 'edit_item' => esc_html__('Edit', 'lsx-health-plan'), |
|
| 171 | + 'update_item' => esc_html__('Update', 'lsx-health-plan'), |
|
| 172 | + 'add_new_item' => esc_html__('Add New', 'lsx-health-plan'), |
|
| 173 | + 'new_item_name' => esc_html__('New Name', 'lsx-health-plan'), |
|
| 174 | + 'menu_name' => esc_html__('Weeks', 'lsx-health-plan'), |
|
| 175 | 175 | ); |
| 176 | 176 | |
| 177 | 177 | $args = array( |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | ), |
| 187 | 187 | ); |
| 188 | 188 | |
| 189 | - register_taxonomy( 'week', array( 'plan' ), $args ); |
|
| 189 | + register_taxonomy('week', array('plan'), $args); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
@@ -194,13 +194,13 @@ discard block |
||
| 194 | 194 | * |
| 195 | 195 | * @since 0.1.0 |
| 196 | 196 | */ |
| 197 | - public function add_thumbnail_form_field( $term = false ) { |
|
| 198 | - if ( is_object( $term ) ) { |
|
| 199 | - $value = get_term_meta( $term->term_id, 'thumbnail', true ); |
|
| 200 | - $image_preview = wp_get_attachment_image_src( $value, 'thumbnail' ); |
|
| 197 | + public function add_thumbnail_form_field($term = false) { |
|
| 198 | + if (is_object($term)) { |
|
| 199 | + $value = get_term_meta($term->term_id, 'thumbnail', true); |
|
| 200 | + $image_preview = wp_get_attachment_image_src($value, 'thumbnail'); |
|
| 201 | 201 | |
| 202 | - if ( is_array( $image_preview ) ) { |
|
| 203 | - $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url( $image_preview[0] ) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />'; |
|
| 202 | + if (is_array($image_preview)) { |
|
| 203 | + $image_preview = '<img style="height: 50px; width: 50px;" src="' . esc_url($image_preview[0]) . '" width="' . $image_preview[1] . '" height="' . $image_preview[2] . '" class="alignnone size-thumbnail d wp-image-' . $value . '" />'; |
|
| 204 | 204 | } |
| 205 | 205 | } else { |
| 206 | 206 | $image_preview = false; |
@@ -208,15 +208,15 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | ?> |
| 210 | 210 | <tr class="form-field form-required term-thumbnail-wrap"> |
| 211 | - <th scope="row"><label for="thumbnail"><?php esc_html_e( 'Icon Image', 'lsx-health-plan' ); ?></label></th> |
|
| 211 | + <th scope="row"><label for="thumbnail"><?php esc_html_e('Icon Image', 'lsx-health-plan'); ?></label></th> |
|
| 212 | 212 | <td> |
| 213 | - <input class="input_image_id" type="hidden" name="thumbnail" value="<?php echo wp_kses_post( $value ); ?>"> |
|
| 213 | + <input class="input_image_id" type="hidden" name="thumbnail" value="<?php echo wp_kses_post($value); ?>"> |
|
| 214 | 214 | <div class="thumbnail-preview"> |
| 215 | - <?php echo wp_kses_post( $image_preview ); ?> |
|
| 215 | + <?php echo wp_kses_post($image_preview); ?> |
|
| 216 | 216 | </div> |
| 217 | - <a style="<?php if ( '' !== $value && false !== $value ) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-add"><?php esc_html_e( 'Choose Image', 'lsx-health-plan' ); ?></a> |
|
| 218 | - <a style="<?php if ( '' === $value || false === $value ) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-remove"><?php esc_html_e( 'Remove Image', 'lsx-health-plan' ); ?></a> |
|
| 219 | - <?php wp_nonce_field( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ); ?> |
|
| 217 | + <a style="<?php if ('' !== $value && false !== $value) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-add"><?php esc_html_e('Choose Image', 'lsx-health-plan'); ?></a> |
|
| 218 | + <a style="<?php if ('' === $value || false === $value) { ?>display:none;<?php } ?>" class="button-secondary lsx-thumbnail-image-remove"><?php esc_html_e('Remove Image', 'lsx-health-plan'); ?></a> |
|
| 219 | + <?php wp_nonce_field('lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce'); ?> |
|
| 220 | 220 | </td> |
| 221 | 221 | </tr> |
| 222 | 222 | <?php |
@@ -230,27 +230,27 @@ discard block |
||
| 230 | 230 | * @param int $term_id |
| 231 | 231 | * @param string $taxonomy |
| 232 | 232 | */ |
| 233 | - public function save_meta( $term_id = 0, $taxonomy = '' ) { |
|
| 234 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
|
| 233 | + public function save_meta($term_id = 0, $taxonomy = '') { |
|
| 234 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 235 | 235 | return; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if ( ! isset( $_POST['thumbnail'] ) ) { |
|
| 238 | + if ( ! isset($_POST['thumbnail'])) { |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - if ( check_admin_referer( 'lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce' ) ) { |
|
| 243 | - if ( ! isset( $_POST['thumbnail'] ) ) { |
|
| 242 | + if (check_admin_referer('lsx_hp_term_thumbnail_nonce', 'lsx_hp_term_thumbnail_nonce')) { |
|
| 243 | + if ( ! isset($_POST['thumbnail'])) { |
|
| 244 | 244 | return; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $thumbnail_meta = sanitize_text_field( $_POST['thumbnail'] ); |
|
| 248 | - $thumbnail_meta = ! empty( $thumbnail_meta ) ? $thumbnail_meta : ''; |
|
| 247 | + $thumbnail_meta = sanitize_text_field($_POST['thumbnail']); |
|
| 248 | + $thumbnail_meta = ! empty($thumbnail_meta) ? $thumbnail_meta : ''; |
|
| 249 | 249 | |
| 250 | - if ( empty( $thumbnail_meta ) ) { |
|
| 251 | - delete_term_meta( $term_id, 'thumbnail' ); |
|
| 250 | + if (empty($thumbnail_meta)) { |
|
| 251 | + delete_term_meta($term_id, 'thumbnail'); |
|
| 252 | 252 | } else { |
| 253 | - update_term_meta( $term_id, 'thumbnail', $thumbnail_meta ); |
|
| 253 | + update_term_meta($term_id, 'thumbnail', $thumbnail_meta); |
|
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
@@ -259,33 +259,33 @@ discard block |
||
| 259 | 259 | * Define the metabox and field configurations. |
| 260 | 260 | */ |
| 261 | 261 | public function details_metaboxes() { |
| 262 | - $cmb = new_cmb2_box( array( |
|
| 262 | + $cmb = new_cmb2_box(array( |
|
| 263 | 263 | 'id' => $this->slug . '_details_metabox', |
| 264 | - 'title' => __( 'Details', 'lsx-health-plan' ), |
|
| 265 | - 'object_types' => array( $this->slug ), // Post type |
|
| 264 | + 'title' => __('Details', 'lsx-health-plan'), |
|
| 265 | + 'object_types' => array($this->slug), // Post type |
|
| 266 | 266 | 'context' => 'normal', |
| 267 | 267 | 'priority' => 'high', |
| 268 | 268 | 'show_names' => true, |
| 269 | - ) ); |
|
| 269 | + )); |
|
| 270 | 270 | |
| 271 | 271 | $warmup_type = 'page'; |
| 272 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 273 | - $warmup_type = array( 'page', 'workout' ); |
|
| 272 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
| 273 | + $warmup_type = array('page', 'workout'); |
|
| 274 | 274 | } |
| 275 | - $cmb->add_field( array( |
|
| 276 | - 'name' => __( 'Warmup', 'lsx-health-plan' ), |
|
| 277 | - 'desc' => __( 'Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan' ), |
|
| 275 | + $cmb->add_field(array( |
|
| 276 | + 'name' => __('Warmup', 'lsx-health-plan'), |
|
| 277 | + 'desc' => __('Connect the warm up page that applies to this day plan using the field provided.', 'lsx-health-plan'), |
|
| 278 | 278 | 'id' => $this->slug . '_warmup', |
| 279 | 279 | 'type' => 'post_search_ajax', |
| 280 | 280 | // Optional : |
| 281 | - 'limit' => 3, // Limit selection to X items only (default 1) |
|
| 281 | + 'limit' => 3, // Limit selection to X items only (default 1) |
|
| 282 | 282 | 'sortable' => true, // Allow selected items to be sortable (default false) |
| 283 | 283 | 'query_args' => array( |
| 284 | 284 | 'post_type' => $warmup_type, |
| 285 | - 'post_status' => array( 'publish' ), |
|
| 285 | + 'post_status' => array('publish'), |
|
| 286 | 286 | 'posts_per_page' => -1, |
| 287 | 287 | ), |
| 288 | - ) ); |
|
| 288 | + )); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | /** |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @param array $post_types |
| 295 | 295 | * @return array |
| 296 | 296 | */ |
| 297 | - public function enable_post_type( $post_types = array() ) { |
|
| 297 | + public function enable_post_type($post_types = array()) { |
|
| 298 | 298 | $post_types[] = $this->slug; |
| 299 | 299 | return $post_types; |
| 300 | 300 | } |
@@ -308,8 +308,8 @@ discard block |
||
| 308 | 308 | $cmb = new_cmb2_box( |
| 309 | 309 | array( |
| 310 | 310 | 'id' => $this->slug . '_connections_metabox', |
| 311 | - 'title' => __( 'Plans', 'lsx-health-plan' ), |
|
| 312 | - 'object_types' => array( 'workout', 'meal', 'tip', 'recipe' ), |
|
| 311 | + 'title' => __('Plans', 'lsx-health-plan'), |
|
| 312 | + 'object_types' => array('workout', 'meal', 'tip', 'recipe'), |
|
| 313 | 313 | 'context' => 'normal', |
| 314 | 314 | 'priority' => 'high', |
| 315 | 315 | 'show_names' => true, |
@@ -317,15 +317,15 @@ discard block |
||
| 317 | 317 | ); |
| 318 | 318 | $cmb->add_field( |
| 319 | 319 | array( |
| 320 | - 'name' => __( 'Plan', 'lsx-health-plan' ), |
|
| 320 | + 'name' => __('Plan', 'lsx-health-plan'), |
|
| 321 | 321 | 'id' => 'connected_plans', |
| 322 | - 'desc' => __( 'Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan' ), |
|
| 322 | + 'desc' => __('Connect this to the day plan it applies to, using the field provided.', 'lsx-health-plan'), |
|
| 323 | 323 | 'type' => 'post_search_ajax', |
| 324 | 324 | 'limit' => 15, |
| 325 | 325 | 'sortable' => true, |
| 326 | 326 | 'query_args' => array( |
| 327 | - 'post_type' => array( 'plan' ), |
|
| 328 | - 'post_status' => array( 'publish' ), |
|
| 327 | + 'post_type' => array('plan'), |
|
| 328 | + 'post_status' => array('publish'), |
|
| 329 | 329 | 'posts_per_page' => -1, |
| 330 | 330 | ), |
| 331 | 331 | ) |
@@ -338,9 +338,9 @@ discard block |
||
| 338 | 338 | * @param string $title the term title. |
| 339 | 339 | * @return string |
| 340 | 340 | */ |
| 341 | - public function get_the_archive_title( $title ) { |
|
| 342 | - if ( is_post_type_archive( 'plan' ) ) { |
|
| 343 | - $title = __( 'Our health plans', 'lsx-health-plan' ); |
|
| 341 | + public function get_the_archive_title($title) { |
|
| 342 | + if (is_post_type_archive('plan')) { |
|
| 343 | + $title = __('Our health plans', 'lsx-health-plan'); |
|
| 344 | 344 | } |
| 345 | 345 | return $title; |
| 346 | 346 | } |
@@ -351,9 +351,9 @@ discard block |
||
| 351 | 351 | * @param object $wp_query |
| 352 | 352 | * @return array |
| 353 | 353 | */ |
| 354 | - public function set_parent_only( $wp_query ) { |
|
| 355 | - if ( ! is_admin() && $wp_query->is_main_query() && ( $wp_query->is_post_type_archive( 'plan' ) || $wp_query->is_tax( 'plan-type' ) ) ) { |
|
| 356 | - $wp_query->set( 'post_parent', '0' ); |
|
| 354 | + public function set_parent_only($wp_query) { |
|
| 355 | + if ( ! is_admin() && $wp_query->is_main_query() && ($wp_query->is_post_type_archive('plan') || $wp_query->is_tax('plan-type'))) { |
|
| 356 | + $wp_query->set('post_parent', '0'); |
|
| 357 | 357 | } |
| 358 | 358 | } |
| 359 | 359 | |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | $cmb = new_cmb2_box( |
| 365 | 365 | array( |
| 366 | 366 | 'id' => $this->slug . '_featured_metabox_plan', |
| 367 | - 'title' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
| 368 | - 'object_types' => array( $this->slug ), // Post type |
|
| 367 | + 'title' => __('Featured Plan', 'lsx-health-plan'), |
|
| 368 | + 'object_types' => array($this->slug), // Post type |
|
| 369 | 369 | 'context' => 'side', |
| 370 | 370 | 'priority' => 'high', |
| 371 | 371 | 'show_names' => true, |
@@ -373,8 +373,8 @@ discard block |
||
| 373 | 373 | ); |
| 374 | 374 | $cmb->add_field( |
| 375 | 375 | array( |
| 376 | - 'name' => __( 'Featured Plan', 'lsx-health-plan' ), |
|
| 377 | - 'desc' => __( 'Enable a featured plan' ), |
|
| 376 | + 'name' => __('Featured Plan', 'lsx-health-plan'), |
|
| 377 | + 'desc' => __('Enable a featured plan'), |
|
| 378 | 378 | 'id' => $this->slug . '_featured_plan', |
| 379 | 379 | 'type' => 'checkbox', |
| 380 | 380 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
@@ -389,8 +389,8 @@ discard block |
||
| 389 | 389 | $cmb = new_cmb2_box( |
| 390 | 390 | array( |
| 391 | 391 | 'id' => $this->slug . '_sections_metabox', |
| 392 | - 'title' => __( 'Sections', 'lsx-health-plan' ), |
|
| 393 | - 'object_types' => array( $this->slug ), // Post type. |
|
| 392 | + 'title' => __('Sections', 'lsx-health-plan'), |
|
| 393 | + 'object_types' => array($this->slug), // Post type. |
|
| 394 | 394 | 'context' => 'normal', |
| 395 | 395 | 'priority' => 'low', |
| 396 | 396 | 'show_names' => true, |
@@ -406,9 +406,9 @@ discard block |
||
| 406 | 406 | 'id' => $this->slug . '_sections', |
| 407 | 407 | 'type' => 'group', |
| 408 | 408 | 'options' => array( |
| 409 | - 'group_title' => __( 'Section', 'lsx-health-plan' ) . ' {#}', // {#} gets replaced by row number |
|
| 410 | - 'add_button' => __( 'Add section', 'lsx-health-plan' ), |
|
| 411 | - 'remove_button' => __( 'Remove section', 'lsx-health-plan' ), |
|
| 409 | + 'group_title' => __('Section', 'lsx-health-plan') . ' {#}', // {#} gets replaced by row number |
|
| 410 | + 'add_button' => __('Add section', 'lsx-health-plan'), |
|
| 411 | + 'remove_button' => __('Remove section', 'lsx-health-plan'), |
|
| 412 | 412 | 'sortable' => true, |
| 413 | 413 | 'closed' => true, // true to have the groups closed by default |
| 414 | 414 | ), |
@@ -420,10 +420,10 @@ discard block |
||
| 420 | 420 | $cmb->add_group_field( |
| 421 | 421 | $group, |
| 422 | 422 | array( |
| 423 | - 'name' => __( 'Title', 'lsx-health-plan' ), |
|
| 423 | + 'name' => __('Title', 'lsx-health-plan'), |
|
| 424 | 424 | 'id' => 'title', |
| 425 | 425 | 'type' => 'text', |
| 426 | - 'desc' => __( 'e.g Day 1 / Week 1', 'lsx-health-plan' ), |
|
| 426 | + 'desc' => __('e.g Day 1 / Week 1', 'lsx-health-plan'), |
|
| 427 | 427 | 'classes' => 'lsx-field-col lsx-field-col-50', |
| 428 | 428 | ) |
| 429 | 429 | ); |
@@ -431,10 +431,10 @@ discard block |
||
| 431 | 431 | $cmb->add_group_field( |
| 432 | 432 | $group, |
| 433 | 433 | array( |
| 434 | - 'name' => __( 'Group', 'lsx-health-plan' ), |
|
| 434 | + 'name' => __('Group', 'lsx-health-plan'), |
|
| 435 | 435 | 'id' => 'group', |
| 436 | 436 | 'type' => 'text', |
| 437 | - 'desc' => __( 'e.g Week 1 / January', 'lsx-health-plan' ), |
|
| 437 | + 'desc' => __('e.g Week 1 / January', 'lsx-health-plan'), |
|
| 438 | 438 | 'classes' => 'lsx-field-col lsx-field-col-50', |
| 439 | 439 | ) |
| 440 | 440 | ); |
@@ -442,25 +442,25 @@ discard block |
||
| 442 | 442 | $cmb->add_group_field( |
| 443 | 443 | $group, |
| 444 | 444 | array( |
| 445 | - 'name' => __( 'Overview', 'lsx-health-plan' ), |
|
| 445 | + 'name' => __('Overview', 'lsx-health-plan'), |
|
| 446 | 446 | 'id' => 'description', |
| 447 | 447 | 'type' => 'wysiwyg', |
| 448 | 448 | ) |
| 449 | 449 | ); |
| 450 | 450 | |
| 451 | - if ( post_type_exists( 'workout' ) ) { |
|
| 451 | + if (post_type_exists('workout')) { |
|
| 452 | 452 | $cmb->add_group_field( |
| 453 | 453 | $group, |
| 454 | 454 | array( |
| 455 | - 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
| 455 | + 'name' => __('Workouts', 'lsx-health-plan'), |
|
| 456 | 456 | 'id' => 'connected_workouts', |
| 457 | - 'desc' => __( 'Connect the workout(s) that apply to this section.', 'lsx-health-plan' ), |
|
| 457 | + 'desc' => __('Connect the workout(s) that apply to this section.', 'lsx-health-plan'), |
|
| 458 | 458 | 'type' => 'post_search_ajax', |
| 459 | 459 | 'limit' => 15, |
| 460 | 460 | 'sortable' => true, |
| 461 | 461 | 'query_args' => array( |
| 462 | - 'post_type' => array( 'workout' ), |
|
| 463 | - 'post_status' => array( 'publish' ), |
|
| 462 | + 'post_type' => array('workout'), |
|
| 463 | + 'post_status' => array('publish'), |
|
| 464 | 464 | 'posts_per_page' => -1, |
| 465 | 465 | ), |
| 466 | 466 | 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
@@ -468,40 +468,40 @@ discard block |
||
| 468 | 468 | ); |
| 469 | 469 | } |
| 470 | 470 | |
| 471 | - if ( post_type_exists( 'meal' ) ) { |
|
| 471 | + if (post_type_exists('meal')) { |
|
| 472 | 472 | $cmb->add_group_field( |
| 473 | 473 | $group, |
| 474 | 474 | array( |
| 475 | - 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
| 476 | - 'desc' => __( 'Connect the meal(s) that apply to this section.', 'lsx-health-plan' ), |
|
| 475 | + 'name' => __('Meals', 'lsx-health-plan'), |
|
| 476 | + 'desc' => __('Connect the meal(s) that apply to this section.', 'lsx-health-plan'), |
|
| 477 | 477 | 'id' => 'connected_meals', |
| 478 | 478 | 'type' => 'post_search_ajax', |
| 479 | 479 | // Optional : |
| 480 | 480 | 'limit' => 15, // Limit selection to X items only (default 1) |
| 481 | 481 | 'sortable' => true, // Allow selected items to be sortable (default false) |
| 482 | 482 | 'query_args' => array( |
| 483 | - 'post_type' => array( 'meal' ), |
|
| 484 | - 'post_status' => array( 'publish' ), |
|
| 483 | + 'post_type' => array('meal'), |
|
| 484 | + 'post_status' => array('publish'), |
|
| 485 | 485 | 'posts_per_page' => -1, |
| 486 | 486 | ), |
| 487 | 487 | 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
| 488 | 488 | ) |
| 489 | 489 | ); |
| 490 | 490 | } |
| 491 | - if ( post_type_exists( 'tip' ) ) { |
|
| 491 | + if (post_type_exists('tip')) { |
|
| 492 | 492 | $cmb->add_group_field( |
| 493 | 493 | $group, |
| 494 | 494 | array( |
| 495 | - 'name' => __( 'Tips', 'lsx-health-plan' ), |
|
| 495 | + 'name' => __('Tips', 'lsx-health-plan'), |
|
| 496 | 496 | 'id' => 'connected_tips', |
| 497 | - 'desc' => __( 'Connect the tip(s) that apply to this section.', 'lsx-health-plan' ), |
|
| 497 | + 'desc' => __('Connect the tip(s) that apply to this section.', 'lsx-health-plan'), |
|
| 498 | 498 | 'type' => 'post_search_ajax', |
| 499 | 499 | // Optional : |
| 500 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
| 501 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
| 500 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
| 501 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
| 502 | 502 | 'query_args' => array( |
| 503 | - 'post_type' => array( 'tip' ), |
|
| 504 | - 'post_status' => array( 'publish' ), |
|
| 503 | + 'post_type' => array('tip'), |
|
| 504 | + 'post_status' => array('publish'), |
|
| 505 | 505 | 'posts_per_page' => -1, |
| 506 | 506 | ), |
| 507 | 507 | 'classes' => 'lsx-field-col lsx-field-add-field lsx-field-col-33', |
@@ -54,16 +54,16 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function __construct() { |
| 56 | 56 | $this->load_classes(); |
| 57 | - add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) ); |
|
| 58 | - add_action( 'lsx_hp_settings_page', array( $this, 'generate_tabs' ), 1, 1 ); |
|
| 59 | - |
|
| 60 | - add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 ); |
|
| 61 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 ); |
|
| 62 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 ); |
|
| 63 | - add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 ); |
|
| 64 | - add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 ); |
|
| 65 | - add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 ); |
|
| 66 | - add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 ); |
|
| 57 | + add_action('cmb2_admin_init', array($this, 'register_settings_page')); |
|
| 58 | + add_action('lsx_hp_settings_page', array($this, 'generate_tabs'), 1, 1); |
|
| 59 | + |
|
| 60 | + add_action('lsx_hp_settings_page_general_top', array($this, 'general_settings'), 1, 1); |
|
| 61 | + add_action('lsx_hp_settings_page', array($this, 'global_defaults'), 3, 1); |
|
| 62 | + add_action('lsx_hp_settings_page', array($this, 'global_downloads'), 5, 1); |
|
| 63 | + add_action('lsx_hp_settings_page', array($this, 'stat_disable'), 6, 1); |
|
| 64 | + add_action('lsx_hp_settings_page', array($this, 'endpoint_translations'), 7, 1); |
|
| 65 | + add_action('lsx_hp_settings_page', array($this, 'exercise_translations'), 7, 1); |
|
| 66 | + add_action('lsx_hp_settings_page', array($this, 'post_type_toggles'), 9, 1); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public static function get_instance() { |
| 77 | 77 | // If the single instance hasn't been set, set it now. |
| 78 | - if ( null === self::$instance ) { |
|
| 78 | + if (null === self::$instance) { |
|
| 79 | 79 | self::$instance = new self(); |
| 80 | 80 | } |
| 81 | 81 | return self::$instance; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | //'tip', |
| 96 | 96 | ); |
| 97 | 97 | |
| 98 | - foreach ( $this->post_types as $post_type ) { |
|
| 98 | + foreach ($this->post_types as $post_type) { |
|
| 99 | 99 | $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -107,124 +107,124 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function set_vars() { |
| 109 | 109 | |
| 110 | - $this->default_types = array( |
|
| 110 | + $this->default_types = array( |
|
| 111 | 111 | 'page' => array( |
| 112 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
| 113 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
| 112 | + 'title' => __('Warm Up', 'lsx-health-plan'), |
|
| 113 | + 'description' => __('Set a default warm up routine.', 'lsx-health-plan'), |
|
| 114 | 114 | 'limit' => 1, |
| 115 | 115 | 'id' => 'plan_warmup', |
| 116 | 116 | ), |
| 117 | 117 | ); |
| 118 | 118 | $this->download_types = array( |
| 119 | 119 | 'page' => array( |
| 120 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
| 121 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
| 120 | + 'title' => __('Warm Up', 'lsx-health-plan'), |
|
| 121 | + 'description' => __('Set a default warm up routine.', 'lsx-health-plan'), |
|
| 122 | 122 | 'limit' => 1, |
| 123 | 123 | ), |
| 124 | 124 | ); |
| 125 | - $this->endpoints = array( |
|
| 125 | + $this->endpoints = array( |
|
| 126 | 126 | 'endpoint_warm_up' => array( |
| 127 | - 'title' => __( 'Warm Up Endpoint', 'lsx-health-plan' ), |
|
| 127 | + 'title' => __('Warm Up Endpoint', 'lsx-health-plan'), |
|
| 128 | 128 | 'default' => 'warm-up', |
| 129 | 129 | ), |
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | - if ( post_type_exists( 'meal' ) ) { |
|
| 133 | - $this->download_types['meal'] = array( |
|
| 134 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
| 135 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
| 132 | + if (post_type_exists('meal')) { |
|
| 133 | + $this->download_types['meal'] = array( |
|
| 134 | + 'title' => __('Meal Plan', 'lsx-health-plan'), |
|
| 135 | + 'description' => __('Set a default meal plan.', 'lsx-health-plan'), |
|
| 136 | 136 | ); |
| 137 | - $this->default_types['meal'] = array( |
|
| 138 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
| 139 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
| 137 | + $this->default_types['meal'] = array( |
|
| 138 | + 'title' => __('Meal Plan', 'lsx-health-plan'), |
|
| 139 | + 'description' => __('Set a default meal plan.', 'lsx-health-plan'), |
|
| 140 | 140 | 'id' => 'connected_meals', |
| 141 | 141 | ); |
| 142 | 142 | $this->endpoints['endpoint_meal'] = array( |
| 143 | - 'title' => __( 'Meal Endpoint', 'lsx-health-plan' ), |
|
| 143 | + 'title' => __('Meal Endpoint', 'lsx-health-plan'), |
|
| 144 | 144 | 'default' => 'meal', |
| 145 | - 'description' => __( 'Define the tab slug which shows on the single plan page.', 'lsx-health-plan' ), |
|
| 145 | + 'description' => __('Define the tab slug which shows on the single plan page.', 'lsx-health-plan'), |
|
| 146 | 146 | ); |
| 147 | 147 | $this->endpoints['endpoint_meal_archive'] = array( |
| 148 | - 'title' => __( 'Meals Archive Endpoint', 'lsx-health-plan' ), |
|
| 148 | + 'title' => __('Meals Archive Endpoint', 'lsx-health-plan'), |
|
| 149 | 149 | 'default' => 'meals', |
| 150 | 150 | ); |
| 151 | 151 | $this->endpoints['meal_single_slug'] = array( |
| 152 | - 'title' => __( 'Single Meal Slug', 'lsx-health-plan' ), |
|
| 152 | + 'title' => __('Single Meal Slug', 'lsx-health-plan'), |
|
| 153 | 153 | 'default' => 'meal', |
| 154 | 154 | ); |
| 155 | 155 | } |
| 156 | - if ( post_type_exists( 'recipe' ) ) { |
|
| 156 | + if (post_type_exists('recipe')) { |
|
| 157 | 157 | $this->download_types['recipe'] = array( |
| 158 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
| 159 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
| 158 | + 'title' => __('Recipe', 'lsx-health-plan'), |
|
| 159 | + 'description' => __('Set a default recipe.', 'lsx-health-plan'), |
|
| 160 | 160 | ); |
| 161 | 161 | $this->default_types['recipe'] = array( |
| 162 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
| 163 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
| 162 | + 'title' => __('Recipe', 'lsx-health-plan'), |
|
| 163 | + 'description' => __('Set a default recipe.', 'lsx-health-plan'), |
|
| 164 | 164 | 'id' => 'connected_recipes', |
| 165 | 165 | ); |
| 166 | 166 | $this->endpoints['endpoint_recipe'] = array( |
| 167 | - 'title' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
|
| 167 | + 'title' => __('Recipes Endpoint', 'lsx-health-plan'), |
|
| 168 | 168 | 'default' => 'recipe', |
| 169 | 169 | ); |
| 170 | 170 | } |
| 171 | - if ( post_type_exists( 'workout' ) ) { |
|
| 171 | + if (post_type_exists('workout')) { |
|
| 172 | 172 | $this->download_types['workout'] = array( |
| 173 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
| 174 | - 'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ), |
|
| 173 | + 'title' => __('Workout', 'lsx-health-plan'), |
|
| 174 | + 'description' => __('Set a default workout routine PDF.', 'lsx-health-plan'), |
|
| 175 | 175 | ); |
| 176 | 176 | $this->default_types['workout'] = array( |
| 177 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
| 178 | - 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
| 177 | + 'title' => __('Workout', 'lsx-health-plan'), |
|
| 178 | + 'description' => __('Set a default workout routine.', 'lsx-health-plan'), |
|
| 179 | 179 | 'id' => 'connected_workouts', |
| 180 | 180 | ); |
| 181 | 181 | $this->endpoints['endpoint_workout_archive'] = array( |
| 182 | - 'title' => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ), |
|
| 182 | + 'title' => __('Workouts Archive Endpoint', 'lsx-health-plan'), |
|
| 183 | 183 | 'default' => '', |
| 184 | 184 | ); |
| 185 | 185 | $this->endpoints['endpoint_workout'] = array( |
| 186 | - 'title' => __( 'Single Workout Endpoint', 'lsx-health-plan' ), |
|
| 186 | + 'title' => __('Single Workout Endpoint', 'lsx-health-plan'), |
|
| 187 | 187 | 'default' => 'workout', |
| 188 | 188 | ); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | $this->endpoints['login_slug'] = array( |
| 192 | - 'title' => __( 'Login Slug', 'lsx-health-plan' ), |
|
| 192 | + 'title' => __('Login Slug', 'lsx-health-plan'), |
|
| 193 | 193 | 'default' => 'login', |
| 194 | 194 | ); |
| 195 | 195 | $this->endpoints['my_plan_slug'] = array( |
| 196 | - 'title' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
| 196 | + 'title' => __('My Plan Slug', 'lsx-health-plan'), |
|
| 197 | 197 | 'default' => 'my-plan', |
| 198 | 198 | ); |
| 199 | 199 | $this->endpoints['plan_single_slug'] = array( |
| 200 | - 'title' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
| 200 | + 'title' => __('Single Plan Slug', 'lsx-health-plan'), |
|
| 201 | 201 | 'default' => 'plan', |
| 202 | 202 | ); |
| 203 | 203 | $this->endpoints['endpoint_plan_archive'] = array( |
| 204 | - 'title' => __( 'Plans Archive Endpoint', 'lsx-health-plan' ), |
|
| 204 | + 'title' => __('Plans Archive Endpoint', 'lsx-health-plan'), |
|
| 205 | 205 | 'default' => 'plans', |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 208 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
| 209 | 209 | $this->endpoints['exercise'] = array( |
| 210 | 210 | 'exercise_single' => array( |
| 211 | - 'title' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
| 211 | + 'title' => __('Single Exercise Slug', 'lsx-health-plan'), |
|
| 212 | 212 | 'default' => 'exercise', |
| 213 | 213 | ), |
| 214 | 214 | 'exercise_archive' => array( |
| 215 | - 'title' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
| 215 | + 'title' => __('Archive Exercise Slug', 'lsx-health-plan'), |
|
| 216 | 216 | 'default' => 'exercises', |
| 217 | 217 | ), |
| 218 | 218 | 'exercise_type' => array( |
| 219 | - 'title' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
| 219 | + 'title' => __('Exercise Type Slug', 'lsx-health-plan'), |
|
| 220 | 220 | 'default' => 'exercise-type', |
| 221 | 221 | ), |
| 222 | 222 | 'exercise_equipment' => array( |
| 223 | - 'title' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
| 223 | + 'title' => __('Equipment Slug', 'lsx-health-plan'), |
|
| 224 | 224 | 'default' => 'equipment', |
| 225 | 225 | ), |
| 226 | 226 | 'exercise_musclegroup' => array( |
| 227 | - 'title' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
| 227 | + 'title' => __('Muscle Group Slug', 'lsx-health-plan'), |
|
| 228 | 228 | 'default' => 'muscle-group', |
| 229 | 229 | ), |
| 230 | 230 | ); |
@@ -239,14 +239,14 @@ discard block |
||
| 239 | 239 | $cmb = new_cmb2_box( |
| 240 | 240 | array( |
| 241 | 241 | 'id' => $this->screen_id, |
| 242 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
| 243 | - 'object_types' => array( 'options-page' ), |
|
| 242 | + 'title' => esc_html__('Settings', 'lsx-health-plan'), |
|
| 243 | + 'object_types' => array('options-page'), |
|
| 244 | 244 | 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
| 245 | 245 | 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
| 246 | 246 | 'capability' => 'manage_options', // Cap required to view options-page. |
| 247 | 247 | ) |
| 248 | 248 | ); |
| 249 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
| 249 | + do_action('lsx_hp_settings_page', $cmb); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -255,17 +255,17 @@ discard block |
||
| 255 | 255 | * @param object $cmb new_cmb2_box(). |
| 256 | 256 | * @return void |
| 257 | 257 | */ |
| 258 | - public function general_settings( $cmb ) { |
|
| 258 | + public function general_settings($cmb) { |
|
| 259 | 259 | $cmb->add_field( |
| 260 | 260 | array( |
| 261 | - 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
| 261 | + 'name' => __('Membership Product', 'lsx-health-plan'), |
|
| 262 | 262 | 'id' => 'membership_product', |
| 263 | 263 | 'type' => 'post_search_ajax', |
| 264 | 264 | 'limit' => 1, |
| 265 | 265 | 'sortable' => false, |
| 266 | 266 | 'query_args' => array( |
| 267 | - 'post_type' => array( 'product' ), |
|
| 268 | - 'post_status' => array( 'publish' ), |
|
| 267 | + 'post_type' => array('product'), |
|
| 268 | + 'post_status' => array('publish'), |
|
| 269 | 269 | 'posts_per_page' => -1, |
| 270 | 270 | ), |
| 271 | 271 | ) |
@@ -273,43 +273,43 @@ discard block |
||
| 273 | 273 | |
| 274 | 274 | $cmb->add_field( |
| 275 | 275 | array( |
| 276 | - 'name' => __( 'Your Warm-up Intro', 'lsx-health-plan' ), |
|
| 276 | + 'name' => __('Your Warm-up Intro', 'lsx-health-plan'), |
|
| 277 | 277 | 'id' => 'warmup_intro', |
| 278 | 278 | 'type' => 'textarea_small', |
| 279 | 279 | 'value' => '', |
| 280 | - 'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ), |
|
| 280 | + 'default' => __("Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan'), |
|
| 281 | 281 | ) |
| 282 | 282 | ); |
| 283 | - if ( post_type_exists( 'workout' ) ) { |
|
| 283 | + if (post_type_exists('workout')) { |
|
| 284 | 284 | $cmb->add_field( |
| 285 | 285 | array( |
| 286 | - 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
| 286 | + 'name' => __('Your Workout Intro', 'lsx-health-plan'), |
|
| 287 | 287 | 'id' => 'workout_intro', |
| 288 | 288 | 'type' => 'textarea_small', |
| 289 | 289 | 'value' => '', |
| 290 | - 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
| 290 | + 'default' => __("Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan'), |
|
| 291 | 291 | ) |
| 292 | 292 | ); |
| 293 | 293 | } |
| 294 | - if ( post_type_exists( 'meal' ) ) { |
|
| 294 | + if (post_type_exists('meal')) { |
|
| 295 | 295 | $cmb->add_field( |
| 296 | 296 | array( |
| 297 | - 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
| 297 | + 'name' => __('Your Meal Plan Intro', 'lsx-health-plan'), |
|
| 298 | 298 | 'id' => 'meal_plan_intro', |
| 299 | 299 | 'type' => 'textarea_small', |
| 300 | 300 | 'value' => '', |
| 301 | - 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
| 301 | + 'default' => __('Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan'), |
|
| 302 | 302 | ) |
| 303 | 303 | ); |
| 304 | 304 | } |
| 305 | - if ( post_type_exists( 'recipe' ) ) { |
|
| 305 | + if (post_type_exists('recipe')) { |
|
| 306 | 306 | $cmb->add_field( |
| 307 | 307 | array( |
| 308 | - 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
| 308 | + 'name' => __('Recipes Intro', 'lsx-health-plan'), |
|
| 309 | 309 | 'id' => 'recipes_intro', |
| 310 | 310 | 'type' => 'textarea_small', |
| 311 | 311 | 'value' => '', |
| 312 | - 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
| 312 | + 'default' => __("Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan'), |
|
| 313 | 313 | ) |
| 314 | 314 | ); |
| 315 | 315 | } |
@@ -321,27 +321,27 @@ discard block |
||
| 321 | 321 | * @param object $cmb new_cmb2_box(). |
| 322 | 322 | * @return void |
| 323 | 323 | */ |
| 324 | - public function global_defaults( $cmb ) { |
|
| 324 | + public function global_defaults($cmb) { |
|
| 325 | 325 | $cmb->add_field( |
| 326 | 326 | array( |
| 327 | 327 | 'id' => 'global_defaults_title', |
| 328 | 328 | 'type' => 'title', |
| 329 | - 'name' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
| 330 | - 'default' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
| 331 | - 'description' => __( 'If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan' ), |
|
| 329 | + 'name' => __('Global Defaults', 'lsx-health-plan'), |
|
| 330 | + 'default' => __('Global Defaults', 'lsx-health-plan'), |
|
| 331 | + 'description' => __('If you have not connected a specific post to your day plan, set a default option below.', 'lsx-health-plan'), |
|
| 332 | 332 | ) |
| 333 | 333 | ); |
| 334 | 334 | |
| 335 | - foreach ( $this->default_types as $type => $default_type ) { |
|
| 335 | + foreach ($this->default_types as $type => $default_type) { |
|
| 336 | 336 | $limit = 5; |
| 337 | 337 | $sortable = false; |
| 338 | - if ( isset( $default_type['limit'] ) ) { |
|
| 338 | + if (isset($default_type['limit'])) { |
|
| 339 | 339 | $limit = $default_type['limit']; |
| 340 | 340 | $sortable = true; |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 344 | - $type = array( 'page', 'workout' ); |
|
| 343 | + if ('page' === $type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
| 344 | + $type = array('page', 'workout'); |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $cmb->add_field( |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | 'sortable' => $sortable, |
| 355 | 355 | 'query_args' => array( |
| 356 | 356 | 'post_type' => $type, |
| 357 | - 'post_status' => array( 'publish' ), |
|
| 357 | + 'post_status' => array('publish'), |
|
| 358 | 358 | 'posts_per_page' => -1, |
| 359 | 359 | ), |
| 360 | 360 | ) |
@@ -375,20 +375,20 @@ discard block |
||
| 375 | 375 | * @param object $cmb new_cmb2_box(). |
| 376 | 376 | * @return void |
| 377 | 377 | */ |
| 378 | - public function global_downloads( $cmb ) { |
|
| 378 | + public function global_downloads($cmb) { |
|
| 379 | 379 | $cmb->add_field( |
| 380 | 380 | array( |
| 381 | 381 | 'id' => 'global_downloads_title', |
| 382 | 382 | 'type' => 'title', |
| 383 | - 'name' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
| 384 | - 'default' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
| 383 | + 'name' => __('Global Downloads', 'lsx-health-plan'), |
|
| 384 | + 'default' => __('Global Downloads', 'lsx-health-plan'), |
|
| 385 | 385 | ) |
| 386 | 386 | ); |
| 387 | 387 | |
| 388 | - foreach ( $this->download_types as $type => $download_type ) { |
|
| 388 | + foreach ($this->download_types as $type => $download_type) { |
|
| 389 | 389 | $limit = 5; |
| 390 | 390 | $sortable = false; |
| 391 | - if ( isset( $download_type['limit'] ) ) { |
|
| 391 | + if (isset($download_type['limit'])) { |
|
| 392 | 392 | $limit = $download_type['limit']; |
| 393 | 393 | $sortable = true; |
| 394 | 394 | } |
@@ -401,8 +401,8 @@ discard block |
||
| 401 | 401 | 'limit' => $limit, |
| 402 | 402 | 'sortable' => $sortable, |
| 403 | 403 | 'query_args' => array( |
| 404 | - 'post_type' => array( 'dlm_download' ), |
|
| 405 | - 'post_status' => array( 'publish' ), |
|
| 404 | + 'post_type' => array('dlm_download'), |
|
| 405 | + 'post_status' => array('publish'), |
|
| 406 | 406 | 'posts_per_page' => -1, |
| 407 | 407 | ), |
| 408 | 408 | ) |
@@ -422,18 +422,18 @@ discard block |
||
| 422 | 422 | * @param object $cmb new_cmb2_box(). |
| 423 | 423 | * @return void |
| 424 | 424 | */ |
| 425 | - public function endpoint_translations( $cmb ) { |
|
| 425 | + public function endpoint_translations($cmb) { |
|
| 426 | 426 | $cmb->add_field( |
| 427 | 427 | array( |
| 428 | 428 | 'id' => 'endpoints_title', |
| 429 | 429 | 'type' => 'title', |
| 430 | - 'name' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
| 431 | - 'default' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
| 432 | - 'description' => __( 'Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
| 430 | + 'name' => __('Set Endpoint Translations', 'lsx-health-plan'), |
|
| 431 | + 'default' => __('Set Endpoint Translations', 'lsx-health-plan'), |
|
| 432 | + 'description' => __('Endpoint is a web address (URL) at which the user can gain access to it. You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'), |
|
| 433 | 433 | ) |
| 434 | 434 | ); |
| 435 | - foreach ( $this->endpoints as $slug => $endpoint_vars ) { |
|
| 436 | - if ( 'exercise' === $slug ) { |
|
| 435 | + foreach ($this->endpoints as $slug => $endpoint_vars) { |
|
| 436 | + if ('exercise' === $slug) { |
|
| 437 | 437 | continue; |
| 438 | 438 | } |
| 439 | 439 | |
@@ -461,19 +461,19 @@ discard block |
||
| 461 | 461 | * @param object $cmb new_cmb2_box(). |
| 462 | 462 | * @return void |
| 463 | 463 | */ |
| 464 | - public function exercise_translations( $cmb ) { |
|
| 465 | - if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) { |
|
| 464 | + public function exercise_translations($cmb) { |
|
| 465 | + if (isset($this->endpoints['exercise']) && '' !== $this->endpoints['exercise'] && ! empty($this->endpoints['exercise'])) { |
|
| 466 | 466 | $cmb->add_field( |
| 467 | 467 | array( |
| 468 | 468 | 'id' => 'exercise_endpoints_title', |
| 469 | 469 | 'type' => 'title', |
| 470 | - 'name' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
| 471 | - 'default' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
| 472 | - 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
| 470 | + 'name' => __('Set Exercise Translations', 'lsx-health-plan'), |
|
| 471 | + 'default' => __('Set Exercise Translations', 'lsx-health-plan'), |
|
| 472 | + 'description' => __('You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'), |
|
| 473 | 473 | ) |
| 474 | 474 | ); |
| 475 | 475 | |
| 476 | - foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) { |
|
| 476 | + foreach ($this->endpoints['exercise'] as $slug => $endpoint_vars) { |
|
| 477 | 477 | $cmb->add_field( |
| 478 | 478 | array( |
| 479 | 479 | 'name' => $endpoint_vars['title'], |
@@ -499,27 +499,27 @@ discard block |
||
| 499 | 499 | * @param object $cmb new_cmb2_box(). |
| 500 | 500 | * @return void |
| 501 | 501 | */ |
| 502 | - public function post_type_toggles( $cmb ) { |
|
| 503 | - $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
| 502 | + public function post_type_toggles($cmb) { |
|
| 503 | + $post_types = apply_filters('lsx_health_plan_post_types', isset($this->post_types)); |
|
| 504 | 504 | |
| 505 | 505 | $cmb->add_field( |
| 506 | 506 | array( |
| 507 | 507 | 'id' => 'post_type_toggles_title', |
| 508 | 508 | 'type' => 'title', |
| 509 | - 'name' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
| 510 | - 'default' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
| 511 | - 'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 509 | + 'name' => __('Disable Post Types', 'lsx-health-plan'), |
|
| 510 | + 'default' => __('Disable Post Types', 'lsx-health-plan'), |
|
| 511 | + 'description' => __('Disable post types if you are wanting a minimal site.', 'lsx-health-plan'), |
|
| 512 | 512 | ) |
| 513 | 513 | ); |
| 514 | 514 | |
| 515 | - foreach ( $post_types as $post_type ) { |
|
| 516 | - if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) { |
|
| 515 | + foreach ($post_types as $post_type) { |
|
| 516 | + if ('plan' === $post_type || 'exercise' === $post_type || ('video' === $post_type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false))) { |
|
| 517 | 517 | continue; |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | $cmb->add_field( |
| 521 | 521 | array( |
| 522 | - 'name' => ucwords( $post_type ), |
|
| 522 | + 'name' => ucwords($post_type), |
|
| 523 | 523 | 'id' => $post_type . '_disabled', |
| 524 | 524 | 'type' => 'checkbox', |
| 525 | 525 | 'value' => 1, |
@@ -539,19 +539,19 @@ discard block |
||
| 539 | 539 | array( |
| 540 | 540 | 'id' => 'post_type_toggles_enable_title', |
| 541 | 541 | 'type' => 'title', |
| 542 | - 'name' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
| 543 | - 'default' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
| 544 | - 'description' => __( 'Enable new functionailty like the "exercise" post type.', 'lsx-health-plan' ), |
|
| 542 | + 'name' => __('Enable Post Types', 'lsx-health-plan'), |
|
| 543 | + 'default' => __('Enable Post Types', 'lsx-health-plan'), |
|
| 544 | + 'description' => __('Enable new functionailty like the "exercise" post type.', 'lsx-health-plan'), |
|
| 545 | 545 | ) |
| 546 | 546 | ); |
| 547 | 547 | $cmb->add_field( |
| 548 | 548 | array( |
| 549 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
| 549 | + 'name' => __('Exercises', 'lsx-health-plan'), |
|
| 550 | 550 | 'id' => 'exercise_enabled', |
| 551 | 551 | 'type' => 'checkbox', |
| 552 | 552 | 'value' => 1, |
| 553 | 553 | 'default' => 0, |
| 554 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
| 554 | + 'description' => __('Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan'), |
|
| 555 | 555 | ) |
| 556 | 556 | ); |
| 557 | 557 | $cmb->add_field( |
@@ -568,18 +568,18 @@ discard block |
||
| 568 | 568 | * @return void |
| 569 | 569 | */ |
| 570 | 570 | |
| 571 | - public function stat_disable( $cmb ) { |
|
| 571 | + public function stat_disable($cmb) { |
|
| 572 | 572 | $cmb->add_field( |
| 573 | 573 | array( |
| 574 | 574 | 'id' => 'stat_disable_title', |
| 575 | 575 | 'type' => 'title', |
| 576 | - 'name' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
| 577 | - 'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
| 576 | + 'name' => __('Disable Profile Stats', 'lsx-health-plan'), |
|
| 577 | + 'default' => __('Disable Profile Stats', 'lsx-health-plan'), |
|
| 578 | 578 | ) |
| 579 | 579 | ); |
| 580 | 580 | $cmb->add_field( |
| 581 | 581 | array( |
| 582 | - 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
| 582 | + 'name' => __('Disable All Stats', 'lsx-health-plan'), |
|
| 583 | 583 | 'desc' => 'Disable All Stats', |
| 584 | 584 | 'id' => 'disable_all_stats', |
| 585 | 585 | 'type' => 'checkbox', |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | ); |
| 590 | 590 | $cmb->add_field( |
| 591 | 591 | array( |
| 592 | - 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
| 592 | + 'name' => __('Disable Weight', 'lsx-health-plan'), |
|
| 593 | 593 | 'id' => 'disable_weight_checkbox', |
| 594 | 594 | 'type' => 'checkbox', |
| 595 | 595 | 'value' => 1, |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | ); |
| 599 | 599 | $cmb->add_field( |
| 600 | 600 | array( |
| 601 | - 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
| 601 | + 'name' => __('Disable Waist', 'lsx-health-plan'), |
|
| 602 | 602 | 'id' => 'disable_waist_checkbox', |
| 603 | 603 | 'type' => 'checkbox', |
| 604 | 604 | 'value' => 1, |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | ); |
| 608 | 608 | $cmb->add_field( |
| 609 | 609 | array( |
| 610 | - 'name' => __( 'Disable Fitness', 'lsx-health-plan' ), |
|
| 610 | + 'name' => __('Disable Fitness', 'lsx-health-plan'), |
|
| 611 | 611 | 'id' => 'disable_fitness_checkbox', |
| 612 | 612 | 'type' => 'checkbox', |
| 613 | 613 | 'value' => 1, |
@@ -629,10 +629,10 @@ discard block |
||
| 629 | 629 | * @param string $section either engine,archive or single. |
| 630 | 630 | * @return void |
| 631 | 631 | */ |
| 632 | - public function generate_tabs( $cmb ) { |
|
| 632 | + public function generate_tabs($cmb) { |
|
| 633 | 633 | $tabs = $this->get_settings_tabs(); |
| 634 | 634 | |
| 635 | - foreach ( $tabs as $tab_key => $tab ) { |
|
| 635 | + foreach ($tabs as $tab_key => $tab) { |
|
| 636 | 636 | $cmb->add_field( |
| 637 | 637 | array( |
| 638 | 638 | 'id' => 'settings_' . $tab_key . '_title', |
@@ -642,11 +642,11 @@ discard block |
||
| 642 | 642 | 'description' => $tab['desc'], |
| 643 | 643 | ) |
| 644 | 644 | ); |
| 645 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
| 645 | + do_action('lsx_hp_settings_page_' . $tab_key . '_top', $cmb); |
|
| 646 | 646 | |
| 647 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
| 647 | + do_action('lsx_hp_settings_page_' . $tab_key . '_middle', $cmb); |
|
| 648 | 648 | |
| 649 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
| 649 | + do_action('lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb); |
|
| 650 | 650 | |
| 651 | 651 | $cmb->add_field( |
| 652 | 652 | array( |
@@ -666,26 +666,26 @@ discard block |
||
| 666 | 666 | public function get_settings_tabs() { |
| 667 | 667 | $tabs = array( |
| 668 | 668 | 'general' => array( |
| 669 | - 'title' => __( 'General', 'lsx-health-plan' ), |
|
| 670 | - 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
| 669 | + 'title' => __('General', 'lsx-health-plan'), |
|
| 670 | + 'desc' => __('Control the sitewide settings for the LSX HP site.', 'lsx-health-plan'), |
|
| 671 | 671 | ), |
| 672 | 672 | ); |
| 673 | 673 | |
| 674 | - foreach ( $this->post_types as $post_type ) { |
|
| 675 | - switch ( $post_type ) { |
|
| 674 | + foreach ($this->post_types as $post_type) { |
|
| 675 | + switch ($post_type) { |
|
| 676 | 676 | default: |
| 677 | - if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
| 678 | - $temp_post_type = get_post_type_object( $post_type ); |
|
| 679 | - if ( ! is_wp_error( $temp_post_type ) ) { |
|
| 680 | - $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
| 677 | + if ( ! in_array($post_type, \lsx\search\includes\get_restricted_post_types())) { |
|
| 678 | + $temp_post_type = get_post_type_object($post_type); |
|
| 679 | + if ( ! is_wp_error($temp_post_type)) { |
|
| 680 | + $page_url = get_post_type_archive_link($temp_post_type->name); |
|
| 681 | 681 | $description = sprintf( |
| 682 | 682 | /* translators: %s: The subscription info */ |
| 683 | - __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
| 683 | + __('Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search'), |
|
| 684 | 684 | $page_url, |
| 685 | 685 | $temp_post_type->label |
| 686 | 686 | ); |
| 687 | 687 | |
| 688 | - $tabs[ $post_type ] = array( |
|
| 688 | + $tabs[$post_type] = array( |
|
| 689 | 689 | 'title' => $temp_post_type->label, |
| 690 | 690 | 'desc' => $description, |
| 691 | 691 | ); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * Contructor |
| 26 | 26 | */ |
| 27 | 27 | public function __construct() { |
| 28 | - add_action( 'lsx_hp_settings_page_plan_top', array( $this, 'settings' ), 1, 1 ); |
|
| 28 | + add_action('lsx_hp_settings_page_plan_top', array($this, 'settings'), 1, 1); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public static function get_instance() { |
| 39 | 39 | // If the single instance hasn't been set, set it now. |
| 40 | - if ( null === self::$instance ) { |
|
| 40 | + if (null === self::$instance) { |
|
| 41 | 41 | self::$instance = new self(); |
| 42 | 42 | } |
| 43 | 43 | return self::$instance; |
@@ -49,15 +49,15 @@ discard block |
||
| 49 | 49 | * @param object $cmb new_cmb2_box(). |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - public function settings( $cmb ) { |
|
| 52 | + public function settings($cmb) { |
|
| 53 | 53 | $cmb->add_field( |
| 54 | 54 | array( |
| 55 | - 'name' => __( 'Plan Filters', 'lsx-health-plan' ), |
|
| 55 | + 'name' => __('Plan Filters', 'lsx-health-plan'), |
|
| 56 | 56 | 'id' => 'plan_filters_disabled', |
| 57 | 57 | 'type' => 'checkbox', |
| 58 | 58 | 'value' => 1, |
| 59 | 59 | 'default' => 0, |
| 60 | - 'description' => __( 'Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan' ), |
|
| 60 | + 'description' => __('Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan'), |
|
| 61 | 61 | ) |
| 62 | 62 | ); |
| 63 | 63 | } |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | public function __construct() { |
| 34 | 34 | |
| 35 | - add_action( 'wp_enqueue_scripts', array( $this, 'assets' ), 5 ); |
|
| 35 | + add_action('wp_enqueue_scripts', array($this, 'assets'), 5); |
|
| 36 | 36 | |
| 37 | 37 | require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-endpoints.php'; |
| 38 | 38 | $this->endpoints = Endpoints::get_instance(); |
@@ -43,22 +43,22 @@ discard block |
||
| 43 | 43 | require_once LSX_HEALTH_PLAN_PATH . 'classes/frontend/class-gallery.php'; |
| 44 | 44 | $this->gallery = frontend\Gallery::get_instance(); |
| 45 | 45 | |
| 46 | - if ( is_admin() ) { |
|
| 47 | - add_filter( 'lsx_customizer_colour_selectors_body', array( $this, 'customizer_body_colours_handler' ), 15, 2 ); |
|
| 46 | + if (is_admin()) { |
|
| 47 | + add_filter('lsx_customizer_colour_selectors_body', array($this, 'customizer_body_colours_handler'), 15, 2); |
|
| 48 | 48 | } else { |
| 49 | - add_action( 'body_class', array( $this, 'hp_add_body_classes' ) ); |
|
| 49 | + add_action('body_class', array($this, 'hp_add_body_classes')); |
|
| 50 | 50 | // Handle the template redirects. |
| 51 | - add_filter( 'template_include', array( $this, 'archive_template_include' ), 99 ); |
|
| 52 | - add_filter( 'template_include', array( $this, 'single_template_include' ), 99 ); |
|
| 53 | - add_filter( 'template_include', array( $this, 'taxonomy_template_include' ), 99 ); |
|
| 54 | - add_action( 'template_redirect', array( $this, 'redirect' ) ); |
|
| 55 | - |
|
| 56 | - add_action( 'init', array( $this, 'handle_day_action' ), 100 ); |
|
| 57 | - add_filter( 'wp_kses_allowed_html', array( $this, 'wpkses_post_tags' ), 100, 2 ); |
|
| 58 | - add_filter( 'lsx_global_header_title', array( $this, 'single_title' ), 200, 1 ); |
|
| 51 | + add_filter('template_include', array($this, 'archive_template_include'), 99); |
|
| 52 | + add_filter('template_include', array($this, 'single_template_include'), 99); |
|
| 53 | + add_filter('template_include', array($this, 'taxonomy_template_include'), 99); |
|
| 54 | + add_action('template_redirect', array($this, 'redirect')); |
|
| 55 | + |
|
| 56 | + add_action('init', array($this, 'handle_day_action'), 100); |
|
| 57 | + add_filter('wp_kses_allowed_html', array($this, 'wpkses_post_tags'), 100, 2); |
|
| 58 | + add_filter('lsx_global_header_title', array($this, 'single_title'), 200, 1); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - add_action( 'wp_head', array( $this, 'remove_hp_single_posts_footer' ), 99 ); |
|
| 61 | + add_action('wp_head', array($this, 'remove_hp_single_posts_footer'), 99); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,8 +67,8 @@ discard block |
||
| 67 | 67 | * @return void |
| 68 | 68 | */ |
| 69 | 69 | public function remove_hp_single_posts_footer() { |
| 70 | - if ( is_single() && ( is_singular( 'exercise' ) || is_singular( 'recipe' ) || is_singular( 'workout' ) || is_singular( 'meal' ) ) ) { |
|
| 71 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
| 70 | + if (is_single() && (is_singular('exercise') || is_singular('recipe') || is_singular('workout') || is_singular('meal'))) { |
|
| 71 | + remove_action('lsx_footer_before', 'lsx_add_footer_sidebar_area'); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | public static function get_instance() { |
| 83 | 83 | // If the single instance hasn't been set, set it now. |
| 84 | - if ( null === self::$instance ) { |
|
| 84 | + if (null === self::$instance) { |
|
| 85 | 85 | self::$instance = new self(); |
| 86 | 86 | } |
| 87 | 87 | return self::$instance; |
@@ -94,20 +94,20 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function assets() { |
| 96 | 96 | |
| 97 | - if ( is_post_type_archive( 'plan' ) && false === \lsx_health_plan\functions\plan\is_filters_disabled() ) { |
|
| 98 | - wp_enqueue_script( 'isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array( 'jquery' ), null, LSX_HEALTH_PLAN_URL, true ); |
|
| 97 | + if (is_post_type_archive('plan') && false === \lsx_health_plan\functions\plan\is_filters_disabled()) { |
|
| 98 | + wp_enqueue_script('isotope', LSX_HEALTH_PLAN_URL . 'assets/js/vendor/isotope.pkgd.min.js', array('jquery'), null, LSX_HEALTH_PLAN_URL, true); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - wp_enqueue_style( 'lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER ); |
|
| 102 | - wp_style_add_data( 'lsx-health-plan', 'rtl', 'replace' ); |
|
| 103 | - wp_enqueue_script( 'lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array( 'jquery' ) ); |
|
| 101 | + wp_enqueue_style('lsx-health-plan', LSX_HEALTH_PLAN_URL . 'assets/css/lsx-health-plan.css', array(), LSX_HEALTH_PLAN_VER); |
|
| 102 | + wp_style_add_data('lsx-health-plan', 'rtl', 'replace'); |
|
| 103 | + wp_enqueue_script('lsx-health-plan-scripts', LSX_HEALTH_PLAN_URL . 'assets/js/src/lsx-health-plan-admin.js', array('jquery')); |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
| 108 | 108 | * Handle body colours that might be change by LSX Customizer. |
| 109 | 109 | */ |
| 110 | - public function customizer_body_colours_handler( $css, $colors ) { |
|
| 110 | + public function customizer_body_colours_handler($css, $colors) { |
|
| 111 | 111 | $css .= ' |
| 112 | 112 | @import "' . LSX_HEALTH_PLAN_PATH . '/assets/css/scss/partials/customizer-health-plan-body-colours"; |
| 113 | 113 | |
@@ -130,11 +130,11 @@ discard block |
||
| 130 | 130 | /** |
| 131 | 131 | * Archive template. |
| 132 | 132 | */ |
| 133 | - public function archive_template_include( $template ) { |
|
| 134 | - $applicable_post_types = apply_filters( 'lsx_health_plan_archive_template', array() ); |
|
| 135 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_post_type_archive( $applicable_post_types ) ) { |
|
| 133 | + public function archive_template_include($template) { |
|
| 134 | + $applicable_post_types = apply_filters('lsx_health_plan_archive_template', array()); |
|
| 135 | + if ( ! empty($applicable_post_types) && is_main_query() && is_post_type_archive($applicable_post_types)) { |
|
| 136 | 136 | $post_type = get_post_type(); |
| 137 | - if ( empty( locate_template( array( 'archive-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php' ) ) { |
|
| 137 | + if (empty(locate_template(array('archive-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php')) { |
|
| 138 | 138 | $template = LSX_HEALTH_PLAN_PATH . 'templates/archive-' . $post_type . '.php'; |
| 139 | 139 | } |
| 140 | 140 | } |
@@ -147,31 +147,31 @@ discard block |
||
| 147 | 147 | * @param array $classes |
| 148 | 148 | * @return void |
| 149 | 149 | */ |
| 150 | - public function hp_add_body_classes( $classes = array() ) { |
|
| 150 | + public function hp_add_body_classes($classes = array()) { |
|
| 151 | 151 | global $post; |
| 152 | 152 | |
| 153 | - if ( isset( $post->post_content ) && has_shortcode( $post->post_content, 'lsx_health_plan_my_profile_block' ) ) { |
|
| 153 | + if (isset($post->post_content) && has_shortcode($post->post_content, 'lsx_health_plan_my_profile_block')) { |
|
| 154 | 154 | $classes[] = 'my-plan-shortcode'; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ( is_single() && is_singular( 'plan' ) ) { |
|
| 157 | + if (is_single() && is_singular('plan')) { |
|
| 158 | 158 | $args = array( |
| 159 | 159 | 'post_parent' => get_the_ID(), |
| 160 | 160 | 'post_type' => 'plan', |
| 161 | 161 | ); |
| 162 | 162 | |
| 163 | 163 | $post_id = get_the_ID(); |
| 164 | - $has_children = get_children( $args ); |
|
| 165 | - $has_parent = wp_get_post_parent_id( $post_id ); |
|
| 164 | + $has_children = get_children($args); |
|
| 165 | + $has_parent = wp_get_post_parent_id($post_id); |
|
| 166 | 166 | |
| 167 | - if ( ! empty( $has_children ) ) { |
|
| 167 | + if ( ! empty($has_children)) { |
|
| 168 | 168 | $plan_type_class = 'parent-plan-page'; |
| 169 | - if ( 0 !== $has_parent ) { |
|
| 169 | + if (0 !== $has_parent) { |
|
| 170 | 170 | $plan_type_class = 'parent-sub-plan-page'; |
| 171 | 171 | } |
| 172 | 172 | } else { |
| 173 | 173 | $plan_type_class = 'unique-plan-page'; |
| 174 | - if ( 0 !== $has_parent ) { |
|
| 174 | + if (0 !== $has_parent) { |
|
| 175 | 175 | $plan_type_class = 'child-plan-page'; |
| 176 | 176 | } |
| 177 | 177 | } |
@@ -183,11 +183,11 @@ discard block |
||
| 183 | 183 | /** |
| 184 | 184 | * Single template. |
| 185 | 185 | */ |
| 186 | - public function single_template_include( $template ) { |
|
| 187 | - $applicable_post_types = apply_filters( 'lsx_health_plan_single_template', array() ); |
|
| 188 | - if ( ! empty( $applicable_post_types ) && is_main_query() && is_singular( $applicable_post_types ) ) { |
|
| 186 | + public function single_template_include($template) { |
|
| 187 | + $applicable_post_types = apply_filters('lsx_health_plan_single_template', array()); |
|
| 188 | + if ( ! empty($applicable_post_types) && is_main_query() && is_singular($applicable_post_types)) { |
|
| 189 | 189 | $post_type = get_post_type(); |
| 190 | - if ( empty( locate_template( array( 'single-' . $post_type . '.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php' ) ) { |
|
| 190 | + if (empty(locate_template(array('single-' . $post_type . '.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php')) { |
|
| 191 | 191 | $template = LSX_HEALTH_PLAN_PATH . 'templates/single-' . $post_type . '.php'; |
| 192 | 192 | } |
| 193 | 193 | } |
@@ -200,11 +200,11 @@ discard block |
||
| 200 | 200 | * @param $template string |
| 201 | 201 | * @return string |
| 202 | 202 | */ |
| 203 | - public function taxonomy_template_include( $template ) { |
|
| 204 | - $applicable_taxonomies = apply_filters( 'lsx_health_plan_taxonomies_template', array() ); |
|
| 205 | - if ( is_main_query() && is_tax( $applicable_taxonomies ) ) { |
|
| 206 | - $current_taxonomy = get_query_var( 'taxonomy' ); |
|
| 207 | - if ( '' === locate_template( array( 'taxonomy-' . $current_taxonomy . '.php' ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php' ) ) { |
|
| 203 | + public function taxonomy_template_include($template) { |
|
| 204 | + $applicable_taxonomies = apply_filters('lsx_health_plan_taxonomies_template', array()); |
|
| 205 | + if (is_main_query() && is_tax($applicable_taxonomies)) { |
|
| 206 | + $current_taxonomy = get_query_var('taxonomy'); |
|
| 207 | + if ('' === locate_template(array('taxonomy-' . $current_taxonomy . '.php')) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php')) { |
|
| 208 | 208 | $template = LSX_HEALTH_PLAN_PATH . 'templates/taxonomy-' . $current_taxonomy . '.php'; |
| 209 | 209 | } |
| 210 | 210 | } |
@@ -217,17 +217,17 @@ discard block |
||
| 217 | 217 | * @return void |
| 218 | 218 | */ |
| 219 | 219 | public function redirect() { |
| 220 | - if ( ! is_user_logged_in() || ! function_exists( 'wc_get_page_id' ) || is_home() ) { |
|
| 220 | + if ( ! is_user_logged_in() || ! function_exists('wc_get_page_id') || is_home()) { |
|
| 221 | 221 | return; |
| 222 | 222 | } |
| 223 | - if ( lsx_health_plan_user_has_purchase() && ( is_page( wc_get_page_id( 'cart' ) ) || is_page( wc_get_page_id( 'checkout' ) ) ) ) { |
|
| 224 | - wp_redirect( get_permalink( wc_get_page_id( 'myaccount' ) ) ); |
|
| 223 | + if (lsx_health_plan_user_has_purchase() && (is_page(wc_get_page_id('cart')) || is_page(wc_get_page_id('checkout')))) { |
|
| 224 | + wp_redirect(get_permalink(wc_get_page_id('myaccount'))); |
|
| 225 | 225 | die; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - $product_id = \lsx_health_plan\functions\get_option( 'membership_product', false ); |
|
| 229 | - if ( false !== $product_id && is_single( $product_id ) ) { |
|
| 230 | - wp_redirect( home_url() ); |
|
| 228 | + $product_id = \lsx_health_plan\functions\get_option('membership_product', false); |
|
| 229 | + if (false !== $product_id && is_single($product_id)) { |
|
| 230 | + wp_redirect(home_url()); |
|
| 231 | 231 | die; |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -236,26 +236,26 @@ discard block |
||
| 236 | 236 | * Registers the rewrites. |
| 237 | 237 | */ |
| 238 | 238 | public function handle_day_action() { |
| 239 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'complete' ) ) { |
|
| 240 | - update_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete', true ); |
|
| 241 | - $plan_id = sanitize_key( $_POST['lsx-health-plan-id'] ); |
|
| 242 | - $plan_parent = wp_get_post_parent_id( $plan_id ); |
|
| 243 | - if ( 0 !== $plan_parent ) { |
|
| 239 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'complete')) { |
|
| 240 | + update_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete', true); |
|
| 241 | + $plan_id = sanitize_key($_POST['lsx-health-plan-id']); |
|
| 242 | + $plan_parent = wp_get_post_parent_id($plan_id); |
|
| 243 | + if (0 !== $plan_parent) { |
|
| 244 | 244 | $plan_id = $plan_parent; |
| 245 | 245 | } |
| 246 | - wp_safe_redirect( get_permalink( $plan_id ) ); |
|
| 246 | + wp_safe_redirect(get_permalink($plan_id)); |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - if ( isset( $_POST['lsx-health-plan-actions'] ) && wp_verify_nonce( $_POST['lsx-health-plan-actions'], 'unlock' ) ) { |
|
| 250 | - delete_user_meta( get_current_user_id(), 'day_' . sanitize_key( $_POST['lsx-health-plan-id'] ) . '_complete' ); |
|
| 249 | + if (isset($_POST['lsx-health-plan-actions']) && wp_verify_nonce($_POST['lsx-health-plan-actions'], 'unlock')) { |
|
| 250 | + delete_user_meta(get_current_user_id(), 'day_' . sanitize_key($_POST['lsx-health-plan-id']) . '_complete'); |
|
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
| 255 | 255 | * Registers the rewrites. |
| 256 | 256 | */ |
| 257 | - public function wpkses_post_tags( $tags, $context ) { |
|
| 258 | - if ( 'post' === $context ) { |
|
| 257 | + public function wpkses_post_tags($tags, $context) { |
|
| 258 | + if ('post' === $context) { |
|
| 259 | 259 | $tags['iframe'] = array( |
| 260 | 260 | 'src' => true, |
| 261 | 261 | 'height' => true, |
@@ -275,16 +275,16 @@ discard block |
||
| 275 | 275 | /** |
| 276 | 276 | * Remove the single recipe and exercise title |
| 277 | 277 | */ |
| 278 | - public function single_title( $title ) { |
|
| 278 | + public function single_title($title) { |
|
| 279 | 279 | |
| 280 | - if ( is_single() && is_singular( 'recipe' ) ) { |
|
| 280 | + if (is_single() && is_singular('recipe')) { |
|
| 281 | 281 | |
| 282 | - $title = __( 'Recipe', 'lsx-health-plan' ); |
|
| 282 | + $title = __('Recipe', 'lsx-health-plan'); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - if ( is_single() && is_singular( 'exercise' ) ) { |
|
| 285 | + if (is_single() && is_singular('exercise')) { |
|
| 286 | 286 | |
| 287 | - $title = __( 'Exercise', 'lsx-health-plan' ); |
|
| 287 | + $title = __('Exercise', 'lsx-health-plan'); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | return $title; |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | function is_search_enabled() { |
| 17 | 17 | $enabled = false; |
| 18 | - if ( function_exists( 'lsx_search' ) ) { |
|
| 18 | + if (function_exists('lsx_search')) { |
|
| 19 | 19 | $search_instance = \LSX_Search::get_instance(); |
| 20 | - if ( null !== $search_instance ) { |
|
| 20 | + if (null !== $search_instance) { |
|
| 21 | 21 | $enabled = $search_instance->frontend->is_search_enabled(); |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -30,15 +30,15 @@ discard block |
||
| 30 | 30 | * @param integer $plan_id |
| 31 | 31 | * @return boolean |
| 32 | 32 | */ |
| 33 | -function has_sections( $plan_id = 0 ) { |
|
| 33 | +function has_sections($plan_id = 0) { |
|
| 34 | 34 | $sections = false; |
| 35 | - if ( 0 === $plan_id ) { |
|
| 35 | + if (0 === $plan_id) { |
|
| 36 | 36 | $plan_id = get_the_ID(); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $section_array = get_post_meta( $plan_id, 'plan_sections', true ); |
|
| 39 | + $section_array = get_post_meta($plan_id, 'plan_sections', true); |
|
| 40 | 40 | |
| 41 | - if ( ! empty( $section_array ) ) { |
|
| 41 | + if ( ! empty($section_array)) { |
|
| 42 | 42 | $sections = true; |
| 43 | 43 | } |
| 44 | 44 | return $sections; |
@@ -51,16 +51,16 @@ discard block |
||
| 51 | 51 | * @param boolean $group_sections |
| 52 | 52 | * @return array |
| 53 | 53 | */ |
| 54 | -function get_sections( $plan_id = 0, $group_sections = false ) { |
|
| 54 | +function get_sections($plan_id = 0, $group_sections = false) { |
|
| 55 | 55 | $sections = array(); |
| 56 | - if ( 0 === $plan_id ) { |
|
| 56 | + if (0 === $plan_id) { |
|
| 57 | 57 | $plan_id = get_the_ID(); |
| 58 | 58 | } |
| 59 | - $section_array = get_post_meta( $plan_id, 'plan_sections', true ); |
|
| 60 | - if ( ! empty( $section_array ) ) { |
|
| 59 | + $section_array = get_post_meta($plan_id, 'plan_sections', true); |
|
| 60 | + if ( ! empty($section_array)) { |
|
| 61 | 61 | $sections = $section_array; |
| 62 | - if ( false !== $group_sections ) { |
|
| 63 | - $sections = group_sections( $sections ); |
|
| 62 | + if (false !== $group_sections) { |
|
| 63 | + $sections = group_sections($sections); |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | return $sections; |
@@ -72,14 +72,14 @@ discard block |
||
| 72 | 72 | * @param string $section_key |
| 73 | 73 | * @return array |
| 74 | 74 | */ |
| 75 | -function get_section_info( $section_key = '' ) { |
|
| 75 | +function get_section_info($section_key = '') { |
|
| 76 | 76 | $section_info = array(); |
| 77 | 77 | |
| 78 | 78 | $sections = get_sections(); |
| 79 | - if ( ! empty( $sections ) ) { |
|
| 80 | - foreach ( $sections as $key => $values ) { |
|
| 81 | - $current_key = sanitize_title( $values['title'] ); |
|
| 82 | - if ( $current_key === $section_key ) { |
|
| 79 | + if ( ! empty($sections)) { |
|
| 80 | + foreach ($sections as $key => $values) { |
|
| 81 | + $current_key = sanitize_title($values['title']); |
|
| 82 | + if ($current_key === $section_key) { |
|
| 83 | 83 | return $values; |
| 84 | 84 | } |
| 85 | 85 | } |
@@ -93,16 +93,16 @@ discard block |
||
| 93 | 93 | * @param array $sections |
| 94 | 94 | * @return array |
| 95 | 95 | */ |
| 96 | -function group_sections( $sections = array() ) { |
|
| 96 | +function group_sections($sections = array()) { |
|
| 97 | 97 | $groups = array(); |
| 98 | - if ( ! empty( $sections ) ) { |
|
| 99 | - foreach ( $sections as $section_key => $section_values ) { |
|
| 100 | - $group_key = apply_filters( 'lsx_hp_default_plan_group', __( 'Daily Plan', 'lsx-health-plan' ) ); |
|
| 101 | - if ( isset( $section_values['group'] ) && '' !== $section_values['group'] ) { |
|
| 98 | + if ( ! empty($sections)) { |
|
| 99 | + foreach ($sections as $section_key => $section_values) { |
|
| 100 | + $group_key = apply_filters('lsx_hp_default_plan_group', __('Daily Plan', 'lsx-health-plan')); |
|
| 101 | + if (isset($section_values['group']) && '' !== $section_values['group']) { |
|
| 102 | 102 | $group_key = $section_values['group']; |
| 103 | 103 | } |
| 104 | - $group_key = sanitize_title( $group_key ); |
|
| 105 | - $groups[ $group_key ][ $section_key ] = $section_values; |
|
| 104 | + $group_key = sanitize_title($group_key); |
|
| 105 | + $groups[$group_key][$section_key] = $section_values; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | return $groups; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | * @param array $sections |
| 115 | 115 | * @return array |
| 116 | 116 | */ |
| 117 | -function get_group_title( $sections = array() ) { |
|
| 118 | - $group_title = apply_filters( 'lsx_hp_default_plan_group', __( 'Daily Plan', 'lsx-health-plan' ) ); |
|
| 119 | - if ( ! empty( $sections ) ) { |
|
| 120 | - $first_section = reset( $sections ); |
|
| 121 | - if ( isset( $first_section['group'] ) && '' !== $first_section['group'] ) { |
|
| 117 | +function get_group_title($sections = array()) { |
|
| 118 | + $group_title = apply_filters('lsx_hp_default_plan_group', __('Daily Plan', 'lsx-health-plan')); |
|
| 119 | + if ( ! empty($sections)) { |
|
| 120 | + $first_section = reset($sections); |
|
| 121 | + if (isset($first_section['group']) && '' !== $first_section['group']) { |
|
| 122 | 122 | $group_title = $first_section['group']; |
| 123 | 123 | } |
| 124 | 124 | } |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | * @param string $title |
| 133 | 133 | * @return array |
| 134 | 134 | */ |
| 135 | -function get_permalink( $plan_id = 0, $title = '' ) { |
|
| 136 | - if ( 0 === $plan_id ) { |
|
| 135 | +function get_permalink($plan_id = 0, $title = '') { |
|
| 136 | + if (0 === $plan_id) { |
|
| 137 | 137 | $plan_id = get_the_ID(); |
| 138 | 138 | } |
| 139 | - $url = \get_permalink( $plan_id ); |
|
| 140 | - if ( '' !== $title ) { |
|
| 141 | - $url .= sanitize_title( $title ) . '/'; |
|
| 139 | + $url = \get_permalink($plan_id); |
|
| 140 | + if ('' !== $title) { |
|
| 141 | + $url .= sanitize_title($title) . '/'; |
|
| 142 | 142 | } |
| 143 | 143 | return $url; |
| 144 | 144 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @return boolean |
| 150 | 150 | */ |
| 151 | -function is_filters_disabled( $disabled = false ) { |
|
| 152 | - $is_disabled = \lsx_health_plan\functions\get_option( 'plan_filters_disabled', false ); |
|
| 153 | - if ( false !== $is_disabled ) { |
|
| 151 | +function is_filters_disabled($disabled = false) { |
|
| 152 | + $is_disabled = \lsx_health_plan\functions\get_option('plan_filters_disabled', false); |
|
| 153 | + if (false !== $is_disabled) { |
|
| 154 | 154 | $disabled = true; |
| 155 | 155 | } |
| 156 | 156 | return $disabled; |