@@ -12,269 +12,269 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Settings { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Holds class instance |
|
| 17 | - * |
|
| 18 | - * @since 1.0.0 |
|
| 19 | - * |
|
| 20 | - * @var object \lsx_health_plan\classes\admin\Settings() |
|
| 21 | - */ |
|
| 22 | - protected static $instance = null; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * Option key, and option page slug |
|
| 26 | - * |
|
| 27 | - * @var string |
|
| 28 | - */ |
|
| 29 | - protected $screen_id = 'lsx_health_plan_settings'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * An array of the post types for the Global Downloads field. |
|
| 33 | - * |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - public $download_types = array(); |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * An array of the post types for the Global Defaults field. |
|
| 40 | - * |
|
| 41 | - * @var array |
|
| 42 | - */ |
|
| 43 | - //public $default_types = array(); |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * An array of the endpoints for the Endpoint Translation field. |
|
| 47 | - * |
|
| 48 | - * @var array |
|
| 49 | - */ |
|
| 50 | - public $endpoints = array(); |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Constructor |
|
| 54 | - */ |
|
| 55 | - public function __construct() { |
|
| 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 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Return an instance of this class. |
|
| 65 | - * |
|
| 66 | - * @since 1.0.0 |
|
| 67 | - * |
|
| 68 | - * @return object \lsx_health_plan\classes\admin\Settings() A single instance of this class. |
|
| 69 | - */ |
|
| 70 | - public static function get_instance() { |
|
| 71 | - // If the single instance hasn't been set, set it now. |
|
| 72 | - if ( null === self::$instance ) { |
|
| 73 | - self::$instance = new self(); |
|
| 74 | - } |
|
| 75 | - return self::$instance; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Loads the variable classes and the static classes. |
|
| 80 | - */ |
|
| 81 | - private function load_classes() { |
|
| 82 | - |
|
| 83 | - $this->post_types = array( |
|
| 84 | - 'plan', |
|
| 85 | - 'workout', |
|
| 86 | - 'exercise', |
|
| 87 | - 'meal', |
|
| 88 | - 'recipe', |
|
| 89 | - //'tip', |
|
| 90 | - ); |
|
| 91 | - |
|
| 92 | - foreach ( $this->post_types as $post_type ) { |
|
| 93 | - $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Hook in and register a submenu options page for the Page post-type menu. |
|
| 100 | - */ |
|
| 101 | - public function register_settings_page() { |
|
| 102 | - $cmb = new_cmb2_box( |
|
| 103 | - array( |
|
| 104 | - 'id' => $this->screen_id, |
|
| 105 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
| 106 | - 'object_types' => array( 'options-page' ), |
|
| 107 | - 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
|
| 108 | - 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
|
| 109 | - 'capability' => 'manage_options', // Cap required to view options-page. |
|
| 110 | - ) |
|
| 111 | - ); |
|
| 112 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Registers the general settings. |
|
| 117 | - * |
|
| 118 | - * @param object $cmb new_cmb2_box(). |
|
| 119 | - * @return void |
|
| 120 | - */ |
|
| 121 | - public function general_settings( $cmb ) { |
|
| 122 | - if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 123 | - $cmb->add_field( |
|
| 124 | - array( |
|
| 125 | - 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
| 126 | - 'id' => 'membership_product', |
|
| 127 | - 'type' => 'post_search_ajax', |
|
| 128 | - 'limit' => 1, |
|
| 129 | - 'sortable' => false, |
|
| 130 | - 'query_args' => array( |
|
| 131 | - 'post_type' => array( 'product' ), |
|
| 132 | - 'post_status' => array( 'publish' ), |
|
| 133 | - 'posts_per_page' => -1, |
|
| 134 | - ), |
|
| 135 | - ) |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - if ( false === \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 140 | - $cmb->add_field( |
|
| 141 | - array( |
|
| 142 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
| 143 | - 'id' => 'exercise_enabled', |
|
| 144 | - 'type' => 'checkbox', |
|
| 145 | - 'value' => 1, |
|
| 146 | - 'default' => 0, |
|
| 147 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
| 148 | - ) |
|
| 149 | - ); |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - if ( \lsx_health_plan\functions\get_option( 'workout_disabled' ) ) { |
|
| 154 | - $cmb->add_field( |
|
| 155 | - array( |
|
| 156 | - 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
| 157 | - 'id' => 'workout_disabled', |
|
| 158 | - 'type' => 'checkbox', |
|
| 159 | - 'value' => 1, |
|
| 160 | - 'default' => 0, |
|
| 161 | - 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 162 | - ) |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if ( \lsx_health_plan\functions\get_option( 'recipe_disabled' ) ) { |
|
| 167 | - $cmb->add_field( |
|
| 168 | - array( |
|
| 169 | - 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
| 170 | - 'id' => 'recipe_disabled', |
|
| 171 | - 'type' => 'checkbox', |
|
| 172 | - 'value' => 1, |
|
| 173 | - 'default' => 0, |
|
| 174 | - 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 175 | - ) |
|
| 176 | - ); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if ( \lsx_health_plan\functions\get_option( 'meal_disabled' ) ) { |
|
| 180 | - $cmb->add_field( |
|
| 181 | - array( |
|
| 182 | - 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
| 183 | - 'id' => 'meal_disabled', |
|
| 184 | - 'type' => 'checkbox', |
|
| 185 | - 'value' => 1, |
|
| 186 | - 'default' => 0, |
|
| 187 | - 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 188 | - ) |
|
| 189 | - ); |
|
| 190 | - } |
|
| 15 | + /** |
|
| 16 | + * Holds class instance |
|
| 17 | + * |
|
| 18 | + * @since 1.0.0 |
|
| 19 | + * |
|
| 20 | + * @var object \lsx_health_plan\classes\admin\Settings() |
|
| 21 | + */ |
|
| 22 | + protected static $instance = null; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * Option key, and option page slug |
|
| 26 | + * |
|
| 27 | + * @var string |
|
| 28 | + */ |
|
| 29 | + protected $screen_id = 'lsx_health_plan_settings'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * An array of the post types for the Global Downloads field. |
|
| 33 | + * |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + public $download_types = array(); |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * An array of the post types for the Global Defaults field. |
|
| 40 | + * |
|
| 41 | + * @var array |
|
| 42 | + */ |
|
| 43 | + //public $default_types = array(); |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * An array of the endpoints for the Endpoint Translation field. |
|
| 47 | + * |
|
| 48 | + * @var array |
|
| 49 | + */ |
|
| 50 | + public $endpoints = array(); |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Constructor |
|
| 54 | + */ |
|
| 55 | + public function __construct() { |
|
| 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 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Return an instance of this class. |
|
| 65 | + * |
|
| 66 | + * @since 1.0.0 |
|
| 67 | + * |
|
| 68 | + * @return object \lsx_health_plan\classes\admin\Settings() A single instance of this class. |
|
| 69 | + */ |
|
| 70 | + public static function get_instance() { |
|
| 71 | + // If the single instance hasn't been set, set it now. |
|
| 72 | + if ( null === self::$instance ) { |
|
| 73 | + self::$instance = new self(); |
|
| 74 | + } |
|
| 75 | + return self::$instance; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Loads the variable classes and the static classes. |
|
| 80 | + */ |
|
| 81 | + private function load_classes() { |
|
| 82 | + |
|
| 83 | + $this->post_types = array( |
|
| 84 | + 'plan', |
|
| 85 | + 'workout', |
|
| 86 | + 'exercise', |
|
| 87 | + 'meal', |
|
| 88 | + 'recipe', |
|
| 89 | + //'tip', |
|
| 90 | + ); |
|
| 91 | + |
|
| 92 | + foreach ( $this->post_types as $post_type ) { |
|
| 93 | + $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Hook in and register a submenu options page for the Page post-type menu. |
|
| 100 | + */ |
|
| 101 | + public function register_settings_page() { |
|
| 102 | + $cmb = new_cmb2_box( |
|
| 103 | + array( |
|
| 104 | + 'id' => $this->screen_id, |
|
| 105 | + 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
| 106 | + 'object_types' => array( 'options-page' ), |
|
| 107 | + 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
|
| 108 | + 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
|
| 109 | + 'capability' => 'manage_options', // Cap required to view options-page. |
|
| 110 | + ) |
|
| 111 | + ); |
|
| 112 | + do_action( 'lsx_hp_settings_page', $cmb ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Registers the general settings. |
|
| 117 | + * |
|
| 118 | + * @param object $cmb new_cmb2_box(). |
|
| 119 | + * @return void |
|
| 120 | + */ |
|
| 121 | + public function general_settings( $cmb ) { |
|
| 122 | + if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 123 | + $cmb->add_field( |
|
| 124 | + array( |
|
| 125 | + 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
| 126 | + 'id' => 'membership_product', |
|
| 127 | + 'type' => 'post_search_ajax', |
|
| 128 | + 'limit' => 1, |
|
| 129 | + 'sortable' => false, |
|
| 130 | + 'query_args' => array( |
|
| 131 | + 'post_type' => array( 'product' ), |
|
| 132 | + 'post_status' => array( 'publish' ), |
|
| 133 | + 'posts_per_page' => -1, |
|
| 134 | + ), |
|
| 135 | + ) |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + if ( false === \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 140 | + $cmb->add_field( |
|
| 141 | + array( |
|
| 142 | + 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
| 143 | + 'id' => 'exercise_enabled', |
|
| 144 | + 'type' => 'checkbox', |
|
| 145 | + 'value' => 1, |
|
| 146 | + 'default' => 0, |
|
| 147 | + 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
| 148 | + ) |
|
| 149 | + ); |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + if ( \lsx_health_plan\functions\get_option( 'workout_disabled' ) ) { |
|
| 154 | + $cmb->add_field( |
|
| 155 | + array( |
|
| 156 | + 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
| 157 | + 'id' => 'workout_disabled', |
|
| 158 | + 'type' => 'checkbox', |
|
| 159 | + 'value' => 1, |
|
| 160 | + 'default' => 0, |
|
| 161 | + 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 162 | + ) |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if ( \lsx_health_plan\functions\get_option( 'recipe_disabled' ) ) { |
|
| 167 | + $cmb->add_field( |
|
| 168 | + array( |
|
| 169 | + 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
| 170 | + 'id' => 'recipe_disabled', |
|
| 171 | + 'type' => 'checkbox', |
|
| 172 | + 'value' => 1, |
|
| 173 | + 'default' => 0, |
|
| 174 | + 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 175 | + ) |
|
| 176 | + ); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if ( \lsx_health_plan\functions\get_option( 'meal_disabled' ) ) { |
|
| 180 | + $cmb->add_field( |
|
| 181 | + array( |
|
| 182 | + 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
| 183 | + 'id' => 'meal_disabled', |
|
| 184 | + 'type' => 'checkbox', |
|
| 185 | + 'value' => 1, |
|
| 186 | + 'default' => 0, |
|
| 187 | + 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 188 | + ) |
|
| 189 | + ); |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | 192 | |
| 193 | - $cmb->add_field( |
|
| 194 | - array( |
|
| 195 | - 'name' => __( 'Login Slug', 'lsx-health-plan' ), |
|
| 196 | - 'id' => 'login_slug', |
|
| 197 | - 'type' => 'input', |
|
| 198 | - 'value' => '', |
|
| 199 | - 'default' => 'login', |
|
| 200 | - 'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
|
| 201 | - ) |
|
| 202 | - ); |
|
| 203 | - |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * Enable Business Directory Search settings only if LSX Search plugin is enabled. |
|
| 208 | - * |
|
| 209 | - * @param object $cmb The CMB2() class. |
|
| 210 | - * @param string $section either engine,archive or single. |
|
| 211 | - * @return void |
|
| 212 | - */ |
|
| 213 | - public function generate_tabs( $cmb ) { |
|
| 214 | - $tabs = $this->get_settings_tabs(); |
|
| 215 | - |
|
| 216 | - foreach ( $tabs as $tab_key => $tab ) { |
|
| 217 | - $cmb->add_field( |
|
| 218 | - array( |
|
| 219 | - 'id' => 'settings_' . $tab_key . '_title', |
|
| 220 | - 'type' => 'title', |
|
| 221 | - 'name' => $tab['title'], |
|
| 222 | - 'default' => $tab['title'], |
|
| 223 | - 'description' => $tab['desc'], |
|
| 224 | - ) |
|
| 225 | - ); |
|
| 226 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
| 227 | - |
|
| 228 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
| 229 | - |
|
| 230 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
| 231 | - |
|
| 232 | - $cmb->add_field( |
|
| 233 | - array( |
|
| 234 | - 'id' => 'settings_' . $tab_key . '_closing', |
|
| 235 | - 'type' => 'tab_closing', |
|
| 236 | - ) |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * Returns the tabs and their descriptions. |
|
| 244 | - * |
|
| 245 | - * @return array |
|
| 246 | - */ |
|
| 247 | - public function get_settings_tabs() { |
|
| 248 | - $tabs = array( |
|
| 249 | - 'general' => array( |
|
| 250 | - 'title' => __( 'General', 'lsx-health-plan' ), |
|
| 251 | - 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
| 252 | - ), |
|
| 253 | - ); |
|
| 254 | - |
|
| 255 | - foreach ( $this->post_types as $post_type ) { |
|
| 256 | - switch ( $post_type ) { |
|
| 257 | - default: |
|
| 258 | - //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
| 259 | - $temp_post_type = get_post_type_object( $post_type ); |
|
| 260 | - if ( ! is_wp_error( $temp_post_type ) ) { |
|
| 261 | - $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
| 262 | - $description = sprintf( |
|
| 263 | - /* translators: %s: The subscription info */ |
|
| 264 | - __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
| 265 | - $page_url, |
|
| 266 | - $temp_post_type->label |
|
| 267 | - ); |
|
| 268 | - |
|
| 269 | - $tabs[ $post_type ] = array( |
|
| 270 | - 'title' => $temp_post_type->label, |
|
| 271 | - 'desc' => $description, |
|
| 272 | - ); |
|
| 273 | - } |
|
| 274 | - //} |
|
| 275 | - break; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - return $tabs; |
|
| 279 | - } |
|
| 193 | + $cmb->add_field( |
|
| 194 | + array( |
|
| 195 | + 'name' => __( 'Login Slug', 'lsx-health-plan' ), |
|
| 196 | + 'id' => 'login_slug', |
|
| 197 | + 'type' => 'input', |
|
| 198 | + 'value' => '', |
|
| 199 | + 'default' => 'login', |
|
| 200 | + 'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
|
| 201 | + ) |
|
| 202 | + ); |
|
| 203 | + |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * Enable Business Directory Search settings only if LSX Search plugin is enabled. |
|
| 208 | + * |
|
| 209 | + * @param object $cmb The CMB2() class. |
|
| 210 | + * @param string $section either engine,archive or single. |
|
| 211 | + * @return void |
|
| 212 | + */ |
|
| 213 | + public function generate_tabs( $cmb ) { |
|
| 214 | + $tabs = $this->get_settings_tabs(); |
|
| 215 | + |
|
| 216 | + foreach ( $tabs as $tab_key => $tab ) { |
|
| 217 | + $cmb->add_field( |
|
| 218 | + array( |
|
| 219 | + 'id' => 'settings_' . $tab_key . '_title', |
|
| 220 | + 'type' => 'title', |
|
| 221 | + 'name' => $tab['title'], |
|
| 222 | + 'default' => $tab['title'], |
|
| 223 | + 'description' => $tab['desc'], |
|
| 224 | + ) |
|
| 225 | + ); |
|
| 226 | + do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
| 227 | + |
|
| 228 | + do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
| 229 | + |
|
| 230 | + do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
| 231 | + |
|
| 232 | + $cmb->add_field( |
|
| 233 | + array( |
|
| 234 | + 'id' => 'settings_' . $tab_key . '_closing', |
|
| 235 | + 'type' => 'tab_closing', |
|
| 236 | + ) |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * Returns the tabs and their descriptions. |
|
| 244 | + * |
|
| 245 | + * @return array |
|
| 246 | + */ |
|
| 247 | + public function get_settings_tabs() { |
|
| 248 | + $tabs = array( |
|
| 249 | + 'general' => array( |
|
| 250 | + 'title' => __( 'General', 'lsx-health-plan' ), |
|
| 251 | + 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
| 252 | + ), |
|
| 253 | + ); |
|
| 254 | + |
|
| 255 | + foreach ( $this->post_types as $post_type ) { |
|
| 256 | + switch ( $post_type ) { |
|
| 257 | + default: |
|
| 258 | + //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
| 259 | + $temp_post_type = get_post_type_object( $post_type ); |
|
| 260 | + if ( ! is_wp_error( $temp_post_type ) ) { |
|
| 261 | + $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
| 262 | + $description = sprintf( |
|
| 263 | + /* translators: %s: The subscription info */ |
|
| 264 | + __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
| 265 | + $page_url, |
|
| 266 | + $temp_post_type->label |
|
| 267 | + ); |
|
| 268 | + |
|
| 269 | + $tabs[ $post_type ] = array( |
|
| 270 | + 'title' => $temp_post_type->label, |
|
| 271 | + 'desc' => $description, |
|
| 272 | + ); |
|
| 273 | + } |
|
| 274 | + //} |
|
| 275 | + break; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + return $tabs; |
|
| 279 | + } |
|
| 280 | 280 | } |
@@ -54,10 +54,10 @@ 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 ); |
|
| 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 | 59 | |
| 60 | - add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 ); |
|
| 60 | + add_action('lsx_hp_settings_page_general_top', array($this, 'general_settings'), 1, 1); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public static function get_instance() { |
| 71 | 71 | // If the single instance hasn't been set, set it now. |
| 72 | - if ( null === self::$instance ) { |
|
| 72 | + if (null === self::$instance) { |
|
| 73 | 73 | self::$instance = new self(); |
| 74 | 74 | } |
| 75 | 75 | return self::$instance; |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | //'tip', |
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | - foreach ( $this->post_types as $post_type ) { |
|
| 92 | + foreach ($this->post_types as $post_type) { |
|
| 93 | 93 | $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
| 94 | 94 | } |
| 95 | 95 | |
@@ -102,14 +102,14 @@ discard block |
||
| 102 | 102 | $cmb = new_cmb2_box( |
| 103 | 103 | array( |
| 104 | 104 | 'id' => $this->screen_id, |
| 105 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
| 106 | - 'object_types' => array( 'options-page' ), |
|
| 105 | + 'title' => esc_html__('Settings', 'lsx-health-plan'), |
|
| 106 | + 'object_types' => array('options-page'), |
|
| 107 | 107 | 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
| 108 | 108 | 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
| 109 | 109 | 'capability' => 'manage_options', // Cap required to view options-page. |
| 110 | 110 | ) |
| 111 | 111 | ); |
| 112 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
| 112 | + do_action('lsx_hp_settings_page', $cmb); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -118,73 +118,73 @@ discard block |
||
| 118 | 118 | * @param object $cmb new_cmb2_box(). |
| 119 | 119 | * @return void |
| 120 | 120 | */ |
| 121 | - public function general_settings( $cmb ) { |
|
| 122 | - if ( function_exists( 'wc_memberships_is_post_content_restricted' ) ) { |
|
| 121 | + public function general_settings($cmb) { |
|
| 122 | + if (function_exists('wc_memberships_is_post_content_restricted')) { |
|
| 123 | 123 | $cmb->add_field( |
| 124 | 124 | array( |
| 125 | - 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
| 125 | + 'name' => __('Membership Product', 'lsx-health-plan'), |
|
| 126 | 126 | 'id' => 'membership_product', |
| 127 | 127 | 'type' => 'post_search_ajax', |
| 128 | 128 | 'limit' => 1, |
| 129 | 129 | 'sortable' => false, |
| 130 | 130 | 'query_args' => array( |
| 131 | - 'post_type' => array( 'product' ), |
|
| 132 | - 'post_status' => array( 'publish' ), |
|
| 131 | + 'post_type' => array('product'), |
|
| 132 | + 'post_status' => array('publish'), |
|
| 133 | 133 | 'posts_per_page' => -1, |
| 134 | 134 | ), |
| 135 | 135 | ) |
| 136 | 136 | ); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ( false === \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
| 139 | + if (false === \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
| 140 | 140 | $cmb->add_field( |
| 141 | 141 | array( |
| 142 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
| 142 | + 'name' => __('Exercises', 'lsx-health-plan'), |
|
| 143 | 143 | 'id' => 'exercise_enabled', |
| 144 | 144 | 'type' => 'checkbox', |
| 145 | 145 | 'value' => 1, |
| 146 | 146 | 'default' => 0, |
| 147 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
| 147 | + 'description' => __('Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan'), |
|
| 148 | 148 | ) |
| 149 | 149 | ); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | |
| 153 | - if ( \lsx_health_plan\functions\get_option( 'workout_disabled' ) ) { |
|
| 153 | + if (\lsx_health_plan\functions\get_option('workout_disabled')) { |
|
| 154 | 154 | $cmb->add_field( |
| 155 | 155 | array( |
| 156 | - 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
| 156 | + 'name' => __('Disable Workouts', 'lsx-health-plan'), |
|
| 157 | 157 | 'id' => 'workout_disabled', |
| 158 | 158 | 'type' => 'checkbox', |
| 159 | 159 | 'value' => 1, |
| 160 | 160 | 'default' => 0, |
| 161 | - 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 161 | + 'description' => __('Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan'), |
|
| 162 | 162 | ) |
| 163 | 163 | ); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ( \lsx_health_plan\functions\get_option( 'recipe_disabled' ) ) { |
|
| 166 | + if (\lsx_health_plan\functions\get_option('recipe_disabled')) { |
|
| 167 | 167 | $cmb->add_field( |
| 168 | 168 | array( |
| 169 | - 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
| 169 | + 'name' => __('Disable Recipes', 'lsx-health-plan'), |
|
| 170 | 170 | 'id' => 'recipe_disabled', |
| 171 | 171 | 'type' => 'checkbox', |
| 172 | 172 | 'value' => 1, |
| 173 | 173 | 'default' => 0, |
| 174 | - 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 174 | + 'description' => __('Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan'), |
|
| 175 | 175 | ) |
| 176 | 176 | ); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( \lsx_health_plan\functions\get_option( 'meal_disabled' ) ) { |
|
| 179 | + if (\lsx_health_plan\functions\get_option('meal_disabled')) { |
|
| 180 | 180 | $cmb->add_field( |
| 181 | 181 | array( |
| 182 | - 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
| 182 | + 'name' => __('Disable Meals', 'lsx-health-plan'), |
|
| 183 | 183 | 'id' => 'meal_disabled', |
| 184 | 184 | 'type' => 'checkbox', |
| 185 | 185 | 'value' => 1, |
| 186 | 186 | 'default' => 0, |
| 187 | - 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
| 187 | + 'description' => __('Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan'), |
|
| 188 | 188 | ) |
| 189 | 189 | ); |
| 190 | 190 | } |
@@ -192,12 +192,12 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | $cmb->add_field( |
| 194 | 194 | array( |
| 195 | - 'name' => __( 'Login Slug', 'lsx-health-plan' ), |
|
| 195 | + 'name' => __('Login Slug', 'lsx-health-plan'), |
|
| 196 | 196 | 'id' => 'login_slug', |
| 197 | 197 | 'type' => 'input', |
| 198 | 198 | 'value' => '', |
| 199 | 199 | 'default' => 'login', |
| 200 | - 'after_row' => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ), |
|
| 200 | + 'after_row' => __('<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan'), |
|
| 201 | 201 | ) |
| 202 | 202 | ); |
| 203 | 203 | |
@@ -210,10 +210,10 @@ discard block |
||
| 210 | 210 | * @param string $section either engine,archive or single. |
| 211 | 211 | * @return void |
| 212 | 212 | */ |
| 213 | - public function generate_tabs( $cmb ) { |
|
| 213 | + public function generate_tabs($cmb) { |
|
| 214 | 214 | $tabs = $this->get_settings_tabs(); |
| 215 | 215 | |
| 216 | - foreach ( $tabs as $tab_key => $tab ) { |
|
| 216 | + foreach ($tabs as $tab_key => $tab) { |
|
| 217 | 217 | $cmb->add_field( |
| 218 | 218 | array( |
| 219 | 219 | 'id' => 'settings_' . $tab_key . '_title', |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | 'description' => $tab['desc'], |
| 224 | 224 | ) |
| 225 | 225 | ); |
| 226 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
| 226 | + do_action('lsx_hp_settings_page_' . $tab_key . '_top', $cmb); |
|
| 227 | 227 | |
| 228 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
| 228 | + do_action('lsx_hp_settings_page_' . $tab_key . '_middle', $cmb); |
|
| 229 | 229 | |
| 230 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
| 230 | + do_action('lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb); |
|
| 231 | 231 | |
| 232 | 232 | $cmb->add_field( |
| 233 | 233 | array( |
@@ -247,26 +247,26 @@ discard block |
||
| 247 | 247 | public function get_settings_tabs() { |
| 248 | 248 | $tabs = array( |
| 249 | 249 | 'general' => array( |
| 250 | - 'title' => __( 'General', 'lsx-health-plan' ), |
|
| 251 | - 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
| 250 | + 'title' => __('General', 'lsx-health-plan'), |
|
| 251 | + 'desc' => __('Control the sitewide settings for the LSX HP site.', 'lsx-health-plan'), |
|
| 252 | 252 | ), |
| 253 | 253 | ); |
| 254 | 254 | |
| 255 | - foreach ( $this->post_types as $post_type ) { |
|
| 256 | - switch ( $post_type ) { |
|
| 255 | + foreach ($this->post_types as $post_type) { |
|
| 256 | + switch ($post_type) { |
|
| 257 | 257 | default: |
| 258 | 258 | //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
| 259 | - $temp_post_type = get_post_type_object( $post_type ); |
|
| 260 | - if ( ! is_wp_error( $temp_post_type ) ) { |
|
| 261 | - $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
| 259 | + $temp_post_type = get_post_type_object($post_type); |
|
| 260 | + if ( ! is_wp_error($temp_post_type)) { |
|
| 261 | + $page_url = get_post_type_archive_link($temp_post_type->name); |
|
| 262 | 262 | $description = sprintf( |
| 263 | 263 | /* translators: %s: The subscription info */ |
| 264 | - __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
| 264 | + __('Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search'), |
|
| 265 | 265 | $page_url, |
| 266 | 266 | $temp_post_type->label |
| 267 | 267 | ); |
| 268 | 268 | |
| 269 | - $tabs[ $post_type ] = array( |
|
| 269 | + $tabs[$post_type] = array( |
|
| 270 | 270 | 'title' => $temp_post_type->label, |
| 271 | 271 | 'desc' => $description, |
| 272 | 272 | ); |