@@ -12,128 +12,128 @@ |
||
12 | 12 | */ |
13 | 13 | class Recipe { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Recipe() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Recipe() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - add_action( 'lsx_hp_settings_page_recipe_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | - } |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + add_action( 'lsx_hp_settings_page_recipe_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return an instance of this class. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * |
|
36 | - * @return object \lsx_health_plan\classes\admin\Recipe() A single instance of this class. |
|
37 | - */ |
|
38 | - public static function get_instance() { |
|
39 | - // If the single instance hasn't been set, set it now. |
|
40 | - if ( null === self::$instance ) { |
|
41 | - self::$instance = new self(); |
|
42 | - } |
|
43 | - return self::$instance; |
|
44 | - } |
|
31 | + /** |
|
32 | + * Return an instance of this class. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * |
|
36 | + * @return object \lsx_health_plan\classes\admin\Recipe() A single instance of this class. |
|
37 | + */ |
|
38 | + public static function get_instance() { |
|
39 | + // If the single instance hasn't been set, set it now. |
|
40 | + if ( null === self::$instance ) { |
|
41 | + self::$instance = new self(); |
|
42 | + } |
|
43 | + return self::$instance; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Registers the general settings. |
|
48 | - * |
|
49 | - * @param object $cmb new_cmb2_box(). |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function settings( $cmb ) { |
|
53 | - $cmb->add_field( |
|
54 | - array( |
|
55 | - 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
56 | - 'id' => 'recipe_disabled', |
|
57 | - 'type' => 'checkbox', |
|
58 | - 'value' => 1, |
|
59 | - 'default' => 0, |
|
60 | - 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
61 | - ) |
|
62 | - ); |
|
46 | + /** |
|
47 | + * Registers the general settings. |
|
48 | + * |
|
49 | + * @param object $cmb new_cmb2_box(). |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function settings( $cmb ) { |
|
53 | + $cmb->add_field( |
|
54 | + array( |
|
55 | + 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
56 | + 'id' => 'recipe_disabled', |
|
57 | + 'type' => 'checkbox', |
|
58 | + 'value' => 1, |
|
59 | + 'default' => 0, |
|
60 | + 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | 63 | |
64 | - $cmb->add_field( |
|
65 | - array( |
|
66 | - 'id' => 'recipe_archive_description', |
|
67 | - 'type' => 'wysiwyg', |
|
68 | - 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
69 | - 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
70 | - 'options' => array( |
|
71 | - 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
72 | - ), |
|
73 | - ) |
|
74 | - ); |
|
64 | + $cmb->add_field( |
|
65 | + array( |
|
66 | + 'id' => 'recipe_archive_description', |
|
67 | + 'type' => 'wysiwyg', |
|
68 | + 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
69 | + 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
70 | + 'options' => array( |
|
71 | + 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
72 | + ), |
|
73 | + ) |
|
74 | + ); |
|
75 | 75 | |
76 | - $cmb->add_field( |
|
77 | - array( |
|
78 | - 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
79 | - 'id' => 'recipes_intro', |
|
80 | - 'type' => 'textarea_small', |
|
81 | - 'value' => '', |
|
82 | - 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
83 | - ) |
|
84 | - ); |
|
76 | + $cmb->add_field( |
|
77 | + array( |
|
78 | + 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
79 | + 'id' => 'recipes_intro', |
|
80 | + 'type' => 'textarea_small', |
|
81 | + 'value' => '', |
|
82 | + 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
83 | + ) |
|
84 | + ); |
|
85 | 85 | |
86 | - $cmb->add_field( |
|
87 | - array( |
|
88 | - 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
89 | - 'name' => __( 'Recipes Slug', 'lsx-health-plan' ), |
|
90 | - 'id' => 'endpoint_recipe', |
|
91 | - 'type' => 'input', |
|
92 | - 'value' => '', |
|
93 | - 'default' => 'recipe', |
|
94 | - ) |
|
95 | - ); |
|
86 | + $cmb->add_field( |
|
87 | + array( |
|
88 | + 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
89 | + 'name' => __( 'Recipes Slug', 'lsx-health-plan' ), |
|
90 | + 'id' => 'endpoint_recipe', |
|
91 | + 'type' => 'input', |
|
92 | + 'value' => '', |
|
93 | + 'default' => 'recipe', |
|
94 | + ) |
|
95 | + ); |
|
96 | 96 | |
97 | - $cmb->add_field( |
|
98 | - array( |
|
99 | - 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
100 | - 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
101 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
102 | - 'limit' => 1, |
|
103 | - 'id' => 'connected_recipes', |
|
104 | - 'type' => 'post_search_ajax', |
|
105 | - 'query_args' => array( |
|
106 | - 'post_type' => 'recipe', |
|
107 | - 'post_status' => array( 'publish' ), |
|
108 | - 'posts_per_page' => -1, |
|
109 | - ), |
|
110 | - ) |
|
111 | - ); |
|
112 | - if ( function_exists( 'download_monitor' ) ) { |
|
113 | - $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
114 | - $plugin_name = 'Download Monitor'; |
|
115 | - $description = sprintf( |
|
116 | - /* translators: %s: The subscription info */ |
|
117 | - __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your recipe here.', 'lsx-search' ), |
|
118 | - $page_url, |
|
119 | - $plugin_name |
|
120 | - ); |
|
121 | - $cmb->add_field( |
|
122 | - array( |
|
123 | - 'name' => __( 'Default Recipe PDF', 'lsx-health-plan' ), |
|
124 | - 'description' => $description, |
|
125 | - 'id' => 'download_recipe', |
|
126 | - 'type' => 'post_search_ajax', |
|
127 | - 'limit' => 1, |
|
128 | - 'query_args' => array( |
|
129 | - 'post_type' => array( 'dlm_download' ), |
|
130 | - 'post_status' => array( 'publish' ), |
|
131 | - 'posts_per_page' => -1, |
|
132 | - ), |
|
133 | - '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' ), |
|
134 | - ) |
|
135 | - ); |
|
136 | - } |
|
137 | - } |
|
97 | + $cmb->add_field( |
|
98 | + array( |
|
99 | + 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
100 | + 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
101 | + 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
102 | + 'limit' => 1, |
|
103 | + 'id' => 'connected_recipes', |
|
104 | + 'type' => 'post_search_ajax', |
|
105 | + 'query_args' => array( |
|
106 | + 'post_type' => 'recipe', |
|
107 | + 'post_status' => array( 'publish' ), |
|
108 | + 'posts_per_page' => -1, |
|
109 | + ), |
|
110 | + ) |
|
111 | + ); |
|
112 | + if ( function_exists( 'download_monitor' ) ) { |
|
113 | + $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
114 | + $plugin_name = 'Download Monitor'; |
|
115 | + $description = sprintf( |
|
116 | + /* translators: %s: The subscription info */ |
|
117 | + __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your recipe here.', 'lsx-search' ), |
|
118 | + $page_url, |
|
119 | + $plugin_name |
|
120 | + ); |
|
121 | + $cmb->add_field( |
|
122 | + array( |
|
123 | + 'name' => __( 'Default Recipe PDF', 'lsx-health-plan' ), |
|
124 | + 'description' => $description, |
|
125 | + 'id' => 'download_recipe', |
|
126 | + 'type' => 'post_search_ajax', |
|
127 | + 'limit' => 1, |
|
128 | + 'query_args' => array( |
|
129 | + 'post_type' => array( 'dlm_download' ), |
|
130 | + 'post_status' => array( 'publish' ), |
|
131 | + 'posts_per_page' => -1, |
|
132 | + ), |
|
133 | + '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' ), |
|
134 | + ) |
|
135 | + ); |
|
136 | + } |
|
137 | + } |
|
138 | 138 | } |
139 | 139 | Recipe::get_instance(); |
@@ -12,112 +12,112 @@ |
||
12 | 12 | */ |
13 | 13 | class Exercise { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Exercise() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Exercise() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - add_action( 'lsx_hp_settings_page_exercise_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | - } |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + add_action( 'lsx_hp_settings_page_exercise_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return an instance of this class. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * |
|
36 | - * @return object \lsx_health_plan\classes\admin\Exercise() A single instance of this class. |
|
37 | - */ |
|
38 | - public static function get_instance() { |
|
39 | - // If the single instance hasn't been set, set it now. |
|
40 | - if ( null === self::$instance ) { |
|
41 | - self::$instance = new self(); |
|
42 | - } |
|
43 | - return self::$instance; |
|
44 | - } |
|
31 | + /** |
|
32 | + * Return an instance of this class. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * |
|
36 | + * @return object \lsx_health_plan\classes\admin\Exercise() A single instance of this class. |
|
37 | + */ |
|
38 | + public static function get_instance() { |
|
39 | + // If the single instance hasn't been set, set it now. |
|
40 | + if ( null === self::$instance ) { |
|
41 | + self::$instance = new self(); |
|
42 | + } |
|
43 | + return self::$instance; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Registers the general settings. |
|
48 | - * |
|
49 | - * @param object $cmb new_cmb2_box(). |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function settings( $cmb ) { |
|
53 | - $cmb->add_field( |
|
54 | - array( |
|
55 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
56 | - 'id' => 'exercise_enabled', |
|
57 | - 'type' => 'checkbox', |
|
58 | - 'value' => 1, |
|
59 | - 'default' => 0, |
|
60 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
61 | - ) |
|
62 | - ); |
|
63 | - $cmb->add_field( |
|
64 | - array( |
|
65 | - 'id' => 'exercise_archive_description', |
|
66 | - 'type' => 'wysiwyg', |
|
67 | - 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
68 | - 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
69 | - 'options' => array( |
|
70 | - 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
71 | - ), |
|
72 | - ) |
|
73 | - ); |
|
74 | - $cmb->add_field( |
|
75 | - array( |
|
76 | - 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
77 | - 'name' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
78 | - 'id' => 'endpoint_exercise_single', |
|
79 | - 'type' => 'input', |
|
80 | - 'value' => '', |
|
81 | - 'default' => 'exercise', |
|
82 | - ) |
|
83 | - ); |
|
84 | - $cmb->add_field( |
|
85 | - array( |
|
86 | - 'name' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
87 | - 'id' => 'endpoint_exercise_archive', |
|
88 | - 'type' => 'input', |
|
89 | - 'value' => '', |
|
90 | - 'default' => 'exercises', |
|
91 | - ) |
|
92 | - ); |
|
93 | - $cmb->add_field( |
|
94 | - array( |
|
95 | - 'name' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
96 | - 'id' => 'endpoint_exercise_type', |
|
97 | - 'type' => 'input', |
|
98 | - 'value' => '', |
|
99 | - 'default' => 'exercise-type', |
|
100 | - ) |
|
101 | - ); |
|
102 | - $cmb->add_field( |
|
103 | - array( |
|
104 | - 'name' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
105 | - 'id' => 'endpoint_exercise_equipment', |
|
106 | - 'type' => 'input', |
|
107 | - 'value' => '', |
|
108 | - 'default' => 'equipment', |
|
109 | - ) |
|
110 | - ); |
|
111 | - $cmb->add_field( |
|
112 | - array( |
|
113 | - 'name' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
114 | - 'id' => 'endpoint_exercise_musclegroup', |
|
115 | - 'type' => 'input', |
|
116 | - 'value' => '', |
|
117 | - 'default' => 'muscle-group', |
|
118 | - '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' ), |
|
119 | - ) |
|
120 | - ); |
|
121 | - } |
|
46 | + /** |
|
47 | + * Registers the general settings. |
|
48 | + * |
|
49 | + * @param object $cmb new_cmb2_box(). |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function settings( $cmb ) { |
|
53 | + $cmb->add_field( |
|
54 | + array( |
|
55 | + 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
56 | + 'id' => 'exercise_enabled', |
|
57 | + 'type' => 'checkbox', |
|
58 | + 'value' => 1, |
|
59 | + 'default' => 0, |
|
60 | + 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | + $cmb->add_field( |
|
64 | + array( |
|
65 | + 'id' => 'exercise_archive_description', |
|
66 | + 'type' => 'wysiwyg', |
|
67 | + 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
68 | + 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
69 | + 'options' => array( |
|
70 | + 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
71 | + ), |
|
72 | + ) |
|
73 | + ); |
|
74 | + $cmb->add_field( |
|
75 | + array( |
|
76 | + 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
77 | + 'name' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
78 | + 'id' => 'endpoint_exercise_single', |
|
79 | + 'type' => 'input', |
|
80 | + 'value' => '', |
|
81 | + 'default' => 'exercise', |
|
82 | + ) |
|
83 | + ); |
|
84 | + $cmb->add_field( |
|
85 | + array( |
|
86 | + 'name' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
87 | + 'id' => 'endpoint_exercise_archive', |
|
88 | + 'type' => 'input', |
|
89 | + 'value' => '', |
|
90 | + 'default' => 'exercises', |
|
91 | + ) |
|
92 | + ); |
|
93 | + $cmb->add_field( |
|
94 | + array( |
|
95 | + 'name' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
96 | + 'id' => 'endpoint_exercise_type', |
|
97 | + 'type' => 'input', |
|
98 | + 'value' => '', |
|
99 | + 'default' => 'exercise-type', |
|
100 | + ) |
|
101 | + ); |
|
102 | + $cmb->add_field( |
|
103 | + array( |
|
104 | + 'name' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
105 | + 'id' => 'endpoint_exercise_equipment', |
|
106 | + 'type' => 'input', |
|
107 | + 'value' => '', |
|
108 | + 'default' => 'equipment', |
|
109 | + ) |
|
110 | + ); |
|
111 | + $cmb->add_field( |
|
112 | + array( |
|
113 | + 'name' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
114 | + 'id' => 'endpoint_exercise_musclegroup', |
|
115 | + 'type' => 'input', |
|
116 | + 'value' => '', |
|
117 | + 'default' => 'muscle-group', |
|
118 | + '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' ), |
|
119 | + ) |
|
120 | + ); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 | Exercise::get_instance(); |
@@ -17,27 +17,27 @@ discard block |
||
17 | 17 | * @return boolean |
18 | 18 | */ |
19 | 19 | function has_attached_post( $post_id = '', $meta_key = '', $single = true ) { |
20 | - $has_post = false; |
|
21 | - if ( '' === $post_id ) { |
|
22 | - $post_id = get_the_ID(); |
|
23 | - } |
|
24 | - $items = get_post_meta( $post_id, $meta_key, $single ); |
|
25 | - if ( '' !== $items && false !== $items && 0 !== $items ) { |
|
26 | - if ( ! is_array( $items ) ) { |
|
27 | - $items = array( $items ); |
|
28 | - } |
|
29 | - $items = check_posts_exist( $items ); |
|
30 | - if ( ! empty( $items ) ) { |
|
31 | - $has_post = true; |
|
32 | - } |
|
33 | - } else { |
|
34 | - // Check for defaults. |
|
35 | - $options = get_option( 'all' ); |
|
36 | - if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) { |
|
37 | - $has_post = true; |
|
38 | - } |
|
39 | - } |
|
40 | - return $has_post; |
|
20 | + $has_post = false; |
|
21 | + if ( '' === $post_id ) { |
|
22 | + $post_id = get_the_ID(); |
|
23 | + } |
|
24 | + $items = get_post_meta( $post_id, $meta_key, $single ); |
|
25 | + if ( '' !== $items && false !== $items && 0 !== $items ) { |
|
26 | + if ( ! is_array( $items ) ) { |
|
27 | + $items = array( $items ); |
|
28 | + } |
|
29 | + $items = check_posts_exist( $items ); |
|
30 | + if ( ! empty( $items ) ) { |
|
31 | + $has_post = true; |
|
32 | + } |
|
33 | + } else { |
|
34 | + // Check for defaults. |
|
35 | + $options = get_option( 'all' ); |
|
36 | + if ( isset( $options[ $meta_key ] ) && '' !== $options[ $meta_key ] && ! empty( $options[ $meta_key ] ) ) { |
|
37 | + $has_post = true; |
|
38 | + } |
|
39 | + } |
|
40 | + return $has_post; |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
@@ -48,18 +48,18 @@ discard block |
||
48 | 48 | * @return mixed Option value |
49 | 49 | */ |
50 | 50 | function get_option( $key = '', $default = false ) { |
51 | - if ( function_exists( 'cmb2_get_option' ) ) { |
|
52 | - return cmb2_get_option( 'lsx_health_plan_options', $key, $default ); |
|
53 | - } |
|
54 | - // Fallback to get_option if CMB2 is not loaded yet. |
|
55 | - $opts = \get_option( 'lsx_health_plan_options', $default ); |
|
56 | - $val = $default; |
|
57 | - if ( 'all' === $key ) { |
|
58 | - $val = $opts; |
|
59 | - } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { |
|
60 | - $val = $opts[ $key ]; |
|
61 | - } |
|
62 | - return $val; |
|
51 | + if ( function_exists( 'cmb2_get_option' ) ) { |
|
52 | + return cmb2_get_option( 'lsx_health_plan_options', $key, $default ); |
|
53 | + } |
|
54 | + // Fallback to get_option if CMB2 is not loaded yet. |
|
55 | + $opts = \get_option( 'lsx_health_plan_options', $default ); |
|
56 | + $val = $default; |
|
57 | + if ( 'all' === $key ) { |
|
58 | + $val = $opts; |
|
59 | + } elseif ( is_array( $opts ) && array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) { |
|
60 | + $val = $opts[ $key ]; |
|
61 | + } |
|
62 | + return $val; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -70,54 +70,54 @@ discard block |
||
70 | 70 | * @return mixed Option value |
71 | 71 | */ |
72 | 72 | function get_downloads( $type = 'all', $post_id = '' ) { |
73 | - $lsx_health_plan = \lsx_health_plan(); |
|
74 | - $post_types = $lsx_health_plan->get_post_types(); |
|
75 | - if ( '' === $post_id ) { |
|
76 | - $post_id = get_the_ID(); |
|
77 | - } |
|
78 | - $downloads = array(); |
|
79 | - $options = get_option( 'all' ); |
|
80 | - |
|
81 | - foreach ( $post_types as $post_type ) { |
|
82 | - if ( 'all' === $type || in_array( $type, $post_types, true ) ) { |
|
83 | - |
|
84 | - // Get the default downloads for this post type. |
|
85 | - $default_downloads = array(); |
|
86 | - $new_downloads = array(); |
|
87 | - if ( isset( $options[ 'download_' . $post_type ] ) ) { |
|
88 | - if ( is_array( $options[ 'download_' . $post_type ] ) ) { |
|
89 | - $default_downloads = $options[ 'download_' . $post_type ]; |
|
90 | - } else { |
|
91 | - $default_downloads[] = $options[ 'download_' . $post_type ]; |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - if ( 'page' === $post_type ) { |
|
96 | - $key = 'plan_warmup'; |
|
97 | - } else { |
|
98 | - $key = 'connected_' . $post_type . 's'; |
|
99 | - } |
|
100 | - |
|
101 | - $connected_items = get_post_meta( $post_id, $key, true ); |
|
102 | - if ( ! empty( $connected_items ) ) { |
|
103 | - foreach ( $connected_items as $connected_item ) { |
|
104 | - $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true ); |
|
105 | - if ( false !== $current_downloads && ! empty( $current_downloads ) ) { |
|
106 | - $new_downloads = array_merge( $new_downloads, $current_downloads ); |
|
107 | - } |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - if ( ! empty( $new_downloads ) ) { |
|
112 | - $downloads = array_merge( $downloads, $new_downloads ); |
|
113 | - } elseif ( ! empty( $default_downloads ) ) { |
|
114 | - $downloads = array_merge( $downloads, $default_downloads ); |
|
115 | - } |
|
116 | - $downloads = array_unique( $downloads ); |
|
117 | - } |
|
118 | - } |
|
119 | - $downloads = check_posts_exist( $downloads ); |
|
120 | - return $downloads; |
|
73 | + $lsx_health_plan = \lsx_health_plan(); |
|
74 | + $post_types = $lsx_health_plan->get_post_types(); |
|
75 | + if ( '' === $post_id ) { |
|
76 | + $post_id = get_the_ID(); |
|
77 | + } |
|
78 | + $downloads = array(); |
|
79 | + $options = get_option( 'all' ); |
|
80 | + |
|
81 | + foreach ( $post_types as $post_type ) { |
|
82 | + if ( 'all' === $type || in_array( $type, $post_types, true ) ) { |
|
83 | + |
|
84 | + // Get the default downloads for this post type. |
|
85 | + $default_downloads = array(); |
|
86 | + $new_downloads = array(); |
|
87 | + if ( isset( $options[ 'download_' . $post_type ] ) ) { |
|
88 | + if ( is_array( $options[ 'download_' . $post_type ] ) ) { |
|
89 | + $default_downloads = $options[ 'download_' . $post_type ]; |
|
90 | + } else { |
|
91 | + $default_downloads[] = $options[ 'download_' . $post_type ]; |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + if ( 'page' === $post_type ) { |
|
96 | + $key = 'plan_warmup'; |
|
97 | + } else { |
|
98 | + $key = 'connected_' . $post_type . 's'; |
|
99 | + } |
|
100 | + |
|
101 | + $connected_items = get_post_meta( $post_id, $key, true ); |
|
102 | + if ( ! empty( $connected_items ) ) { |
|
103 | + foreach ( $connected_items as $connected_item ) { |
|
104 | + $current_downloads = get_post_meta( $connected_item, 'connected_downloads', true ); |
|
105 | + if ( false !== $current_downloads && ! empty( $current_downloads ) ) { |
|
106 | + $new_downloads = array_merge( $new_downloads, $current_downloads ); |
|
107 | + } |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + if ( ! empty( $new_downloads ) ) { |
|
112 | + $downloads = array_merge( $downloads, $new_downloads ); |
|
113 | + } elseif ( ! empty( $default_downloads ) ) { |
|
114 | + $downloads = array_merge( $downloads, $default_downloads ); |
|
115 | + } |
|
116 | + $downloads = array_unique( $downloads ); |
|
117 | + } |
|
118 | + } |
|
119 | + $downloads = check_posts_exist( $downloads ); |
|
120 | + return $downloads; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,35 +127,35 @@ discard block |
||
127 | 127 | * @return array an array of the downloads or empty. |
128 | 128 | */ |
129 | 129 | function get_weekly_downloads( $week = '' ) { |
130 | - $downloads = array(); |
|
131 | - if ( '' !== $week ) { |
|
132 | - $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week ); |
|
133 | - if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) { |
|
134 | - $downloads = $saved_downloads; |
|
135 | - } else { |
|
136 | - $args = array( |
|
137 | - 'orderby' => 'title', |
|
138 | - 'order' => 'ASC', |
|
139 | - 'post_type' => 'dlm_download', |
|
140 | - 'posts_per_page' => -1, |
|
141 | - 'nopagin' => true, |
|
142 | - 'fields' => 'ids', |
|
143 | - 'tax_query' => array( |
|
144 | - array( |
|
145 | - 'taxonomy' => 'dlm_download_category', |
|
146 | - 'field' => 'slug', |
|
147 | - 'terms' => array( $week ), |
|
148 | - ), |
|
149 | - ), |
|
150 | - ); |
|
151 | - $download_query = new \WP_Query( $args ); |
|
152 | - if ( $download_query->have_posts() ) { |
|
153 | - $downloads = $download_query->posts; |
|
154 | - } |
|
155 | - } |
|
156 | - } |
|
157 | - $downloads = check_posts_exist( $downloads ); |
|
158 | - return $downloads; |
|
130 | + $downloads = array(); |
|
131 | + if ( '' !== $week ) { |
|
132 | + $saved_downloads = get_transient( 'lsx_hp_weekly_downloads_' . $week ); |
|
133 | + if ( false !== $saved_downloads && ! empty( $saved_downloads ) ) { |
|
134 | + $downloads = $saved_downloads; |
|
135 | + } else { |
|
136 | + $args = array( |
|
137 | + 'orderby' => 'title', |
|
138 | + 'order' => 'ASC', |
|
139 | + 'post_type' => 'dlm_download', |
|
140 | + 'posts_per_page' => -1, |
|
141 | + 'nopagin' => true, |
|
142 | + 'fields' => 'ids', |
|
143 | + 'tax_query' => array( |
|
144 | + array( |
|
145 | + 'taxonomy' => 'dlm_download_category', |
|
146 | + 'field' => 'slug', |
|
147 | + 'terms' => array( $week ), |
|
148 | + ), |
|
149 | + ), |
|
150 | + ); |
|
151 | + $download_query = new \WP_Query( $args ); |
|
152 | + if ( $download_query->have_posts() ) { |
|
153 | + $downloads = $download_query->posts; |
|
154 | + } |
|
155 | + } |
|
156 | + } |
|
157 | + $downloads = check_posts_exist( $downloads ); |
|
158 | + return $downloads; |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | /** |
@@ -165,22 +165,22 @@ discard block |
||
165 | 165 | * @return void |
166 | 166 | */ |
167 | 167 | function check_posts_exist( $post_ids = array() ) { |
168 | - $new_ids = array(); |
|
169 | - global $wpdb; |
|
170 | - if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { |
|
171 | - $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
172 | - $query = " |
|
168 | + $new_ids = array(); |
|
169 | + global $wpdb; |
|
170 | + if ( is_array( $post_ids ) && ! empty( $post_ids ) ) { |
|
171 | + $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
172 | + $query = " |
|
173 | 173 | SELECT `ID` |
174 | 174 | FROM `{$wpdb->posts}` |
175 | 175 | WHERE `ID` IN ({$post_ids}) |
176 | 176 | AND `post_status` != 'trash' |
177 | 177 | "; |
178 | - $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL |
|
179 | - if ( ! empty( $results ) ) { |
|
180 | - $new_ids = wp_list_pluck( $results, 'ID' ); |
|
181 | - } |
|
182 | - } |
|
183 | - return $new_ids; |
|
178 | + $results = $wpdb->get_results( $query ); // WPCS: unprepared SQL |
|
179 | + if ( ! empty( $results ) ) { |
|
180 | + $new_ids = wp_list_pluck( $results, 'ID' ); |
|
181 | + } |
|
182 | + } |
|
183 | + return $new_ids; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * @return void |
193 | 193 | */ |
194 | 194 | function register_modal( $id = '', $title = '', $body = '' ) { |
195 | - lsx_health_plan()->frontend->modals->register_modal( |
|
196 | - array( |
|
197 | - 'title' => $title, |
|
198 | - 'body' => $body, |
|
199 | - ), |
|
200 | - $id |
|
201 | - ); |
|
195 | + lsx_health_plan()->frontend->modals->register_modal( |
|
196 | + array( |
|
197 | + 'title' => $title, |
|
198 | + 'body' => $body, |
|
199 | + ), |
|
200 | + $id |
|
201 | + ); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | * @return void |
209 | 209 | */ |
210 | 210 | function output_modal( $args = array() ) { |
211 | - $defaults = array( |
|
212 | - 'id' => '', |
|
213 | - 'title' => '', |
|
214 | - 'body' => '', |
|
215 | - ); |
|
216 | - $args = wp_parse_args( $args, $defaults ); |
|
217 | - ?> |
|
211 | + $defaults = array( |
|
212 | + 'id' => '', |
|
213 | + 'title' => '', |
|
214 | + 'body' => '', |
|
215 | + ); |
|
216 | + $args = wp_parse_args( $args, $defaults ); |
|
217 | + ?> |
|
218 | 218 | <!-- Modal --> |
219 | 219 | <div class="modal fade lsx-health-plan-modal" id="<?php echo esc_html( $args['id'] ); ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo esc_html( $args['id'] ); ?>" aria-hidden="true"> |
220 | 220 | <div class="modal-dialog" role="document"> |
@@ -222,36 +222,36 @@ discard block |
||
222 | 222 | <button type="button" class="close" data-dismiss="modal">×</button> |
223 | 223 | <div class="modal-header"> |
224 | 224 | <?php |
225 | - if ( '' !== $args['title'] ) { |
|
226 | - echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' ); |
|
227 | - } |
|
228 | - ?> |
|
225 | + if ( '' !== $args['title'] ) { |
|
226 | + echo wp_kses_post( '<h2>' . $args['title'] . '</h2>' ); |
|
227 | + } |
|
228 | + ?> |
|
229 | 229 | </div> |
230 | 230 | <div class="modal-body"> |
231 | 231 | <?php |
232 | - if ( '' !== $args['body'] ) { |
|
233 | - $allowed_html = array( |
|
234 | - 'iframe' => array( |
|
235 | - 'data-src' => array(), |
|
236 | - 'src' => array(), |
|
237 | - 'width' => array(), |
|
238 | - 'height' => array(), |
|
239 | - 'frameBorder' => array( '0' ), |
|
240 | - 'class' => array(), |
|
241 | - 'allowFullScreen' => array(), |
|
242 | - 'style' => array(), |
|
243 | - ), |
|
244 | - 'h5' => array( |
|
245 | - 'class' => array(), |
|
246 | - ), |
|
247 | - ); |
|
248 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
249 | - echo wp_kses_post( $args['body'] ); |
|
250 | - } else { |
|
251 | - echo wp_kses( $args['body'], $allowed_html ); |
|
252 | - } |
|
253 | - } |
|
254 | - ?> |
|
232 | + if ( '' !== $args['body'] ) { |
|
233 | + $allowed_html = array( |
|
234 | + 'iframe' => array( |
|
235 | + 'data-src' => array(), |
|
236 | + 'src' => array(), |
|
237 | + 'width' => array(), |
|
238 | + 'height' => array(), |
|
239 | + 'frameBorder' => array( '0' ), |
|
240 | + 'class' => array(), |
|
241 | + 'allowFullScreen' => array(), |
|
242 | + 'style' => array(), |
|
243 | + ), |
|
244 | + 'h5' => array( |
|
245 | + 'class' => array(), |
|
246 | + ), |
|
247 | + ); |
|
248 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
249 | + echo wp_kses_post( $args['body'] ); |
|
250 | + } else { |
|
251 | + echo wp_kses( $args['body'], $allowed_html ); |
|
252 | + } |
|
253 | + } |
|
254 | + ?> |
|
255 | 255 | </div> |
256 | 256 | </div> |
257 | 257 | </div> |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | * @return void |
268 | 268 | */ |
269 | 269 | function get_video_url( $embed ) { |
270 | - $url = ''; |
|
271 | - if ( false !== stripos( $embed, '<iframe' ) ) { |
|
272 | - preg_match( '/src="([^"]+)"/', $embed, $match ); |
|
273 | - if ( is_array( $match ) && isset( $match[1] ) ) { |
|
274 | - $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>'; |
|
275 | - } else { |
|
276 | - $url = $embed; |
|
277 | - } |
|
278 | - } else { |
|
279 | - $url = $embed; |
|
280 | - } |
|
281 | - return $url; |
|
270 | + $url = ''; |
|
271 | + if ( false !== stripos( $embed, '<iframe' ) ) { |
|
272 | + preg_match( '/src="([^"]+)"/', $embed, $match ); |
|
273 | + if ( is_array( $match ) && isset( $match[1] ) ) { |
|
274 | + $url = '<iframe data-src="' . $match[1] . '" style="border: 0;" frameBorder="0" class="giphy-embed" allowFullScreen height="300" width="100%"></iframe>'; |
|
275 | + } else { |
|
276 | + $url = $embed; |
|
277 | + } |
|
278 | + } else { |
|
279 | + $url = $embed; |
|
280 | + } |
|
281 | + return $url; |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -289,18 +289,18 @@ discard block |
||
289 | 289 | * @return boolean |
290 | 290 | */ |
291 | 291 | function is_week_complete( $term_id = false, $section_keys = array(), $group_title = '' ) { |
292 | - $return = false; |
|
293 | - if ( ! empty( $section_keys ) ) { |
|
294 | - $group_count = count( $section_keys ); |
|
295 | - foreach ( $section_keys as &$pid ) { |
|
296 | - $pid = 'day_' . \lsx_health_plan\functions\plan\generate_section_id( $pid ) . '_complete'; |
|
297 | - } |
|
298 | - $days_complete = get_meta_amounts( $section_keys ); |
|
299 | - if ( (int) $group_count === (int) $days_complete ) { |
|
300 | - $return = true; |
|
301 | - } |
|
302 | - } |
|
303 | - return $return; |
|
292 | + $return = false; |
|
293 | + if ( ! empty( $section_keys ) ) { |
|
294 | + $group_count = count( $section_keys ); |
|
295 | + foreach ( $section_keys as &$pid ) { |
|
296 | + $pid = 'day_' . \lsx_health_plan\functions\plan\generate_section_id( $pid ) . '_complete'; |
|
297 | + } |
|
298 | + $days_complete = get_meta_amounts( $section_keys ); |
|
299 | + if ( (int) $group_count === (int) $days_complete ) { |
|
300 | + $return = true; |
|
301 | + } |
|
302 | + } |
|
303 | + return $return; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -311,23 +311,23 @@ discard block |
||
311 | 311 | * @return void |
312 | 312 | */ |
313 | 313 | function get_meta_amounts( $post_ids = array() ) { |
314 | - global $wpdb; |
|
315 | - $amount = 0; |
|
316 | - $current_user = wp_get_current_user(); |
|
317 | - if ( false !== $current_user && ! empty( $post_ids ) ) { |
|
318 | - $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
319 | - $query = " |
|
314 | + global $wpdb; |
|
315 | + $amount = 0; |
|
316 | + $current_user = wp_get_current_user(); |
|
317 | + if ( false !== $current_user && ! empty( $post_ids ) ) { |
|
318 | + $post_ids = "'" . implode( "','", $post_ids ) . "'"; |
|
319 | + $query = " |
|
320 | 320 | SELECT COUNT(`meta_value`) |
321 | 321 | FROM `{$wpdb->usermeta}` |
322 | 322 | WHERE `meta_key` IN ({$post_ids}) |
323 | 323 | AND `user_id` = '{$current_user->ID}' |
324 | 324 | "; |
325 | - $results = $wpdb->get_var( $query ); // WPCS: unprepared SQL |
|
326 | - if ( ! empty( $results ) ) { |
|
327 | - $amount = $results; |
|
328 | - } |
|
329 | - } |
|
330 | - return $amount; |
|
325 | + $results = $wpdb->get_var( $query ); // WPCS: unprepared SQL |
|
326 | + if ( ! empty( $results ) ) { |
|
327 | + $amount = $results; |
|
328 | + } |
|
329 | + } |
|
330 | + return $amount; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -337,46 +337,46 @@ discard block |
||
337 | 337 | * @return void |
338 | 338 | */ |
339 | 339 | function hp_get_plan_type_meta( $post ) { |
340 | - $plan_meta = ''; |
|
340 | + $plan_meta = ''; |
|
341 | 341 | |
342 | - $term_obj_list = get_the_terms( $post->ID, 'plan-type' ); |
|
343 | - if ( false !== $term_obj_list ) { |
|
344 | - $terms_string = ''; |
|
345 | - $terms_ids = wp_list_pluck( $term_obj_list, 'term_id' ); |
|
342 | + $term_obj_list = get_the_terms( $post->ID, 'plan-type' ); |
|
343 | + if ( false !== $term_obj_list ) { |
|
344 | + $terms_string = ''; |
|
345 | + $terms_ids = wp_list_pluck( $term_obj_list, 'term_id' ); |
|
346 | 346 | |
347 | - foreach ( $term_obj_list as $term ) { |
|
348 | - $term_link = get_term_link( $term ); |
|
349 | - $term_name = '<a href="' . $term_link . '">' .$term->name . '<span>, </span></a>'; |
|
347 | + foreach ( $term_obj_list as $term ) { |
|
348 | + $term_link = get_term_link( $term ); |
|
349 | + $term_name = '<a href="' . $term_link . '">' .$term->name . '<span>, </span></a>'; |
|
350 | 350 | |
351 | - $terms_string .= $term_name; |
|
352 | - } |
|
351 | + $terms_string .= $term_name; |
|
352 | + } |
|
353 | 353 | |
354 | - foreach ( $terms_ids as $terms_id ) { |
|
355 | - $term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true ); |
|
356 | - $img = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' ); |
|
357 | - if ( ! empty( $img ) ) { |
|
358 | - $image_url = $img[0]; |
|
359 | - $img = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />'; |
|
360 | - } |
|
354 | + foreach ( $terms_ids as $terms_id ) { |
|
355 | + $term_thumbnail_id = get_term_meta( $terms_id, 'thumbnail', true ); |
|
356 | + $img = wp_get_attachment_image_src( $term_thumbnail_id, 'thumbnail' ); |
|
357 | + if ( ! empty( $img ) ) { |
|
358 | + $image_url = $img[0]; |
|
359 | + $img = '<img loading="lazy" alt="thumbnail" style="width:24px; height: auto;" class="attachment-responsive wp-post-image lsx-responsive" src="' . esc_url( $image_url ) . '" />'; |
|
360 | + } |
|
361 | 361 | |
362 | - $plan_meta .= $img; |
|
363 | - } |
|
362 | + $plan_meta .= $img; |
|
363 | + } |
|
364 | 364 | |
365 | - $plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>'; |
|
366 | - } |
|
365 | + $plan_meta = '<div class="plan-meta">' . $plan_meta . '<span>' . $terms_string . '</span></div>'; |
|
366 | + } |
|
367 | 367 | |
368 | - return $plan_meta; |
|
368 | + return $plan_meta; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
372 | 372 | * Limit media library access |
373 | 373 | */ |
374 | 374 | function set_only_author( $wp_query ) { |
375 | - global $current_user; |
|
376 | - if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) { |
|
377 | - $wp_query->set( 'administrator', $current_user->ID ); |
|
378 | - add_filter( 'views_upload', 'fix_media_counts' ); |
|
379 | - } |
|
375 | + global $current_user; |
|
376 | + if ( is_admin() && ! current_user_can( 'edit_others_posts' ) ) { |
|
377 | + $wp_query->set( 'administrator', $current_user->ID ); |
|
378 | + add_filter( 'views_upload', 'fix_media_counts' ); |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | add_action( 'pre_get_posts', '\lsx_health_plan\functions\set_only_author' ); |
382 | 382 | |
@@ -387,12 +387,12 @@ discard block |
||
387 | 387 | * @return void |
388 | 388 | */ |
389 | 389 | function hp_excerpt( $post_id ) { |
390 | - if ( ! has_excerpt( $post_id ) ) { |
|
391 | - $content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 ); |
|
392 | - } else { |
|
393 | - $content = get_the_excerpt( $post_id ); |
|
394 | - } |
|
395 | - return $content; |
|
390 | + if ( ! has_excerpt( $post_id ) ) { |
|
391 | + $content = wp_trim_words( get_post_field( 'post_content', $post_id ), 10 ); |
|
392 | + } else { |
|
393 | + $content = get_the_excerpt( $post_id ); |
|
394 | + } |
|
395 | + return $content; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -402,9 +402,9 @@ discard block |
||
402 | 402 | * @return void |
403 | 403 | */ |
404 | 404 | function column_class( $columns = '3' ) { |
405 | - $cols = ''; |
|
406 | - $cols .= '5' === $columns ? '15' : 12 / $columns; |
|
407 | - return $cols; |
|
405 | + $cols = ''; |
|
406 | + $cols .= '5' === $columns ? '15' : 12 / $columns; |
|
407 | + return $cols; |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | /** |
@@ -414,22 +414,22 @@ discard block |
||
414 | 414 | * @return void |
415 | 415 | */ |
416 | 416 | function get_exercises_by_workout( $workout = '' ) { |
417 | - $exercises = array(); |
|
418 | - $i = 1; |
|
419 | - $section_counter = 6; |
|
420 | - while ( $i <= $section_counter ) { |
|
421 | - $group_name = 'workout_section_' . $i; |
|
422 | - $groups = get_post_meta( $workout, $group_name, true ); |
|
423 | - if ( ! empty( $groups ) ) { |
|
424 | - foreach ( $groups as $group ) { |
|
425 | - if ( isset( $group['connected_exercises'] ) ) { |
|
426 | - $exercises[] = $group['connected_exercises']; |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - $i++; |
|
431 | - } |
|
432 | - return $exercises; |
|
417 | + $exercises = array(); |
|
418 | + $i = 1; |
|
419 | + $section_counter = 6; |
|
420 | + while ( $i <= $section_counter ) { |
|
421 | + $group_name = 'workout_section_' . $i; |
|
422 | + $groups = get_post_meta( $workout, $group_name, true ); |
|
423 | + if ( ! empty( $groups ) ) { |
|
424 | + foreach ( $groups as $group ) { |
|
425 | + if ( isset( $group['connected_exercises'] ) ) { |
|
426 | + $exercises[] = $group['connected_exercises']; |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + $i++; |
|
431 | + } |
|
432 | + return $exercises; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -440,20 +440,20 @@ discard block |
||
440 | 440 | * @return int |
441 | 441 | */ |
442 | 442 | function get_progress( $plan_id = false ) { |
443 | - $progress = 0; |
|
444 | - $complete = array(); |
|
445 | - $count = 0; |
|
446 | - if ( false !== $plan_id && \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) { |
|
447 | - $sections = \lsx_health_plan\functions\plan\get_sections(); |
|
448 | - $all_count = count( $sections ); |
|
449 | - foreach ( $sections as $section_key => $section_values ) { |
|
450 | - if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) { |
|
451 | - $complete[] = true; |
|
452 | - } |
|
453 | - } |
|
454 | - $progress = (int) count( $complete ) / (int) $all_count * 100; |
|
455 | - } |
|
456 | - return $progress; |
|
443 | + $progress = 0; |
|
444 | + $complete = array(); |
|
445 | + $count = 0; |
|
446 | + if ( false !== $plan_id && \lsx_health_plan\functions\plan\has_sections( $plan_id ) ) { |
|
447 | + $sections = \lsx_health_plan\functions\plan\get_sections(); |
|
448 | + $all_count = count( $sections ); |
|
449 | + foreach ( $sections as $section_key => $section_values ) { |
|
450 | + if ( lsx_health_plan_is_day_complete( $plan_id, $section_values['title'] ) ) { |
|
451 | + $complete[] = true; |
|
452 | + } |
|
453 | + } |
|
454 | + $progress = (int) count( $complete ) / (int) $all_count * 100; |
|
455 | + } |
|
456 | + return $progress; |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | |
@@ -464,18 +464,18 @@ discard block |
||
464 | 464 | * @return void |
465 | 465 | */ |
466 | 466 | function hp_back_archive_link() { |
467 | - global $wp_taxonomies; |
|
467 | + global $wp_taxonomies; |
|
468 | 468 | |
469 | - $post_type = get_queried_object()->taxonomy; |
|
470 | - $post_type = $wp_taxonomies[$post_type]->object_type; |
|
469 | + $post_type = get_queried_object()->taxonomy; |
|
470 | + $post_type = $wp_taxonomies[$post_type]->object_type; |
|
471 | 471 | |
472 | - if ( is_tax() ) { |
|
473 | - ?> |
|
472 | + if ( is_tax() ) { |
|
473 | + ?> |
|
474 | 474 | <div class="archive-category-title hp-archive-category-title"> |
475 | 475 | <a class="back-to-blog" href="<?php echo ( esc_url( get_post_type_archive_link( $post_type[0] ) ) ); ?>"><?php echo esc_html__( 'Back To ', 'lsx' ) . esc_html( $post_type[0] ) . 's'; ?></a> |
476 | 476 | </div> |
477 | 477 | <?php |
478 | - } |
|
478 | + } |
|
479 | 479 | } |
480 | 480 | add_action( 'lsx_content_wrap_before', '\lsx_health_plan\functions\hp_back_archive_link', 20 ); |
481 | 481 | |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | * @return array |
487 | 487 | */ |
488 | 488 | function prep_array( $item ) { |
489 | - if ( ! is_array( $item ) ) { |
|
490 | - $item = explode( ',', $item ); |
|
491 | - if ( ! is_array( $item ) ) { |
|
492 | - $item = array( $item ); |
|
493 | - } |
|
494 | - } |
|
495 | - return $item; |
|
489 | + if ( ! is_array( $item ) ) { |
|
490 | + $item = explode( ',', $item ); |
|
491 | + if ( ! is_array( $item ) ) { |
|
492 | + $item = array( $item ); |
|
493 | + } |
|
494 | + } |
|
495 | + return $item; |
|
496 | 496 | } |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | |
9 | 9 | $warm_up = get_post_meta( get_the_ID(), 'plan_warmup', true ); |
10 | 10 | if ( false === $warm_up || '' === $warm_up ) { |
11 | - $options = \lsx_health_plan\functions\get_option( 'all' ); |
|
12 | - if ( isset( $options['plan_warmup'] ) && '' !== $options['plan_warmup'] && ! empty( $options['plan_warmup'] ) ) { |
|
13 | - $warm_up = $options['plan_warmup']; |
|
14 | - } |
|
11 | + $options = \lsx_health_plan\functions\get_option( 'all' ); |
|
12 | + if ( isset( $options['plan_warmup'] ) && '' !== $options['plan_warmup'] && ! empty( $options['plan_warmup'] ) ) { |
|
13 | + $warm_up = $options['plan_warmup']; |
|
14 | + } |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | ?> |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | <?php |
20 | 20 | |
21 | 21 | if ( false !== $warm_up && '' !== $warm_up ) { |
22 | - if ( ! is_array( $warm_up ) ) { |
|
23 | - $warm_up = array( $warm_up ); |
|
24 | - } |
|
22 | + if ( ! is_array( $warm_up ) ) { |
|
23 | + $warm_up = array( $warm_up ); |
|
24 | + } |
|
25 | 25 | |
26 | - $warmup_type = array( 'page', 'workout', 'exercise' ); |
|
27 | - $warmup_query = new WP_Query( |
|
28 | - array( |
|
29 | - 'post__in' => $warm_up, |
|
30 | - 'post_type' => $warmup_type, |
|
31 | - ) |
|
32 | - ); |
|
26 | + $warmup_type = array( 'page', 'workout', 'exercise' ); |
|
27 | + $warmup_query = new WP_Query( |
|
28 | + array( |
|
29 | + 'post__in' => $warm_up, |
|
30 | + 'post_type' => $warmup_type, |
|
31 | + ) |
|
32 | + ); |
|
33 | 33 | |
34 | - if ( $warmup_query->have_posts() ) { |
|
35 | - while ( $warmup_query->have_posts() ) { |
|
36 | - $warmup_query->the_post(); |
|
37 | - lsx_entry_before(); |
|
38 | - if ( 'workout' === get_post_type() ) { |
|
39 | - $connected_workouts = array( get_the_ID() ); |
|
40 | - ?> |
|
34 | + if ( $warmup_query->have_posts() ) { |
|
35 | + while ( $warmup_query->have_posts() ) { |
|
36 | + $warmup_query->the_post(); |
|
37 | + lsx_entry_before(); |
|
38 | + if ( 'workout' === get_post_type() ) { |
|
39 | + $connected_workouts = array( get_the_ID() ); |
|
40 | + ?> |
|
41 | 41 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
42 | 42 | <?php lsx_entry_top(); ?> |
43 | 43 | <div class="entry-content"> |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | <?php lsx_entry_bottom(); ?> |
52 | 52 | </article><!-- #post-## --> |
53 | 53 | <?php |
54 | - lsx_health_plan_warmup_sets( $connected_workouts ); |
|
55 | - } else { |
|
56 | - ?> |
|
54 | + lsx_health_plan_warmup_sets( $connected_workouts ); |
|
55 | + } else { |
|
56 | + ?> |
|
57 | 57 | <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> |
58 | 58 | <?php lsx_entry_top(); ?> |
59 | 59 | <div class="entry-content"> |
@@ -63,24 +63,24 @@ discard block |
||
63 | 63 | <h2><?php esc_html_e( 'Warm Up', 'lsx-health-plan' ); ?></h2> |
64 | 64 | </div> |
65 | 65 | <?php |
66 | - the_content(); |
|
67 | - wp_link_pages( array( |
|
68 | - 'before' => '<div class="lsx-postnav-wrapper"><div class="lsx-postnav">', |
|
69 | - 'after' => '</div></div>', |
|
70 | - 'link_before' => '<span>', |
|
71 | - 'link_after' => '</span>', |
|
72 | - ) ); |
|
73 | - ?> |
|
66 | + the_content(); |
|
67 | + wp_link_pages( array( |
|
68 | + 'before' => '<div class="lsx-postnav-wrapper"><div class="lsx-postnav">', |
|
69 | + 'after' => '</div></div>', |
|
70 | + 'link_before' => '<span>', |
|
71 | + 'link_after' => '</span>', |
|
72 | + ) ); |
|
73 | + ?> |
|
74 | 74 | </div> |
75 | 75 | </div><!-- .entry-content --> |
76 | 76 | <?php lsx_entry_bottom(); ?> |
77 | 77 | </article><!-- #post-## --> |
78 | 78 | <?php |
79 | - } |
|
79 | + } |
|
80 | 80 | |
81 | - } |
|
82 | - wp_reset_postdata(); |
|
83 | - } |
|
81 | + } |
|
82 | + wp_reset_postdata(); |
|
83 | + } |
|
84 | 84 | } |
85 | 85 | ?> |
86 | 86 | </div> |
@@ -8,245 +8,245 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class Recipe { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Recipe() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\Recipe() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Holds post_type slug used as an index |
|
22 | - * |
|
23 | - * @since 1.0.0 |
|
24 | - * |
|
25 | - * @var string |
|
26 | - */ |
|
27 | - public $slug = 'recipe'; |
|
20 | + /** |
|
21 | + * Holds post_type slug used as an index |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $slug = 'recipe'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Holds post_type labels |
|
31 | - * |
|
32 | - * @since 1.0.0 |
|
33 | - * |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - public $labels = array(); |
|
29 | + /** |
|
30 | + * Holds post_type labels |
|
31 | + * |
|
32 | + * @since 1.0.0 |
|
33 | + * |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + public $labels = array(); |
|
37 | 37 | |
38 | - /** |
|
39 | - * Constructor |
|
40 | - */ |
|
41 | - public function __construct() { |
|
42 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
43 | - add_action( 'init', array( $this, 'taxonomy_setup' ) ); |
|
44 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
38 | + /** |
|
39 | + * Constructor |
|
40 | + */ |
|
41 | + public function __construct() { |
|
42 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
43 | + add_action( 'init', array( $this, 'taxonomy_setup' ) ); |
|
44 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
45 | 45 | |
46 | - // Frontend Actions and Filters. |
|
47 | - add_action( 'wp_head', array( $this, 'remove_archive_original_header' ), 99 ); |
|
48 | - add_action( 'lsx_content_wrap_before', array( $this, 'hp_lsx_archive_header' ) ); |
|
46 | + // Frontend Actions and Filters. |
|
47 | + add_action( 'wp_head', array( $this, 'remove_archive_original_header' ), 99 ); |
|
48 | + add_action( 'lsx_content_wrap_before', array( $this, 'hp_lsx_archive_header' ) ); |
|
49 | 49 | |
50 | - add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
51 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
52 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
53 | - add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
54 | - add_filter( 'lsx_display_global_header_description', array( $this, 'disable_global_header_description' ), 100 ); |
|
55 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 ); |
|
50 | + add_filter( 'lsx_health_plan_archive_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
51 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
52 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
53 | + add_filter( 'get_the_archive_title', array( $this, 'get_the_archive_title' ), 100 ); |
|
54 | + add_filter( 'lsx_display_global_header_description', array( $this, 'disable_global_header_description' ), 100 ); |
|
55 | + add_filter( 'woocommerce_get_breadcrumb', array( $this, 'recipes_breadcrumb_filter' ), 30, 1 ); |
|
56 | 56 | |
57 | - // Backend Actions and Filters. |
|
58 | - add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) ); |
|
59 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
60 | - } |
|
57 | + // Backend Actions and Filters. |
|
58 | + add_action( 'cmb2_admin_init', array( $this, 'featured_metabox' ) ); |
|
59 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Return an instance of this class. |
|
64 | - * |
|
65 | - * @since 1.0.0 |
|
66 | - * |
|
67 | - * @return object \lsx_health_plan\classes\Recipe() A single instance of this class. |
|
68 | - */ |
|
69 | - public static function get_instance() { |
|
62 | + /** |
|
63 | + * Return an instance of this class. |
|
64 | + * |
|
65 | + * @since 1.0.0 |
|
66 | + * |
|
67 | + * @return object \lsx_health_plan\classes\Recipe() A single instance of this class. |
|
68 | + */ |
|
69 | + public static function get_instance() { |
|
70 | 70 | |
71 | - // If the single instance hasn't been set, set it now. |
|
72 | - if ( null === self::$instance ) { |
|
73 | - self::$instance = new self(); |
|
74 | - } |
|
71 | + // If the single instance hasn't been set, set it now. |
|
72 | + if ( null === self::$instance ) { |
|
73 | + self::$instance = new self(); |
|
74 | + } |
|
75 | 75 | |
76 | - return self::$instance; |
|
76 | + return self::$instance; |
|
77 | 77 | |
78 | - } |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Register the post type. |
|
82 | - */ |
|
83 | - public function register_post_type() { |
|
84 | - $this->labels = array( |
|
85 | - 'name' => esc_html__( 'Recipes', 'lsx-health-plan' ), |
|
86 | - 'singular_name' => esc_html__( 'Recipe', 'lsx-health-plan' ), |
|
87 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
88 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
89 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
90 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
91 | - 'all_items' => esc_html__( 'All Recipes', 'lsx-health-plan' ), |
|
92 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
93 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
94 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
95 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
96 | - 'parent_item_colon' => '', |
|
97 | - 'menu_name' => esc_html__( 'Recipes', 'lsx-health-plan' ), |
|
98 | - ); |
|
99 | - $args = array( |
|
100 | - 'labels' => $this->labels, |
|
101 | - 'public' => true, |
|
102 | - 'publicly_queryable' => true, |
|
103 | - 'show_ui' => true, |
|
104 | - 'show_in_menu' => 'edit.php?post_type=meal-pseudo', |
|
105 | - 'show_in_rest' => true, |
|
106 | - 'menu_icon' => 'dashicons-editor-ul', |
|
107 | - 'query_var' => true, |
|
108 | - 'rewrite' => array( |
|
109 | - 'slug' => 'recipe', |
|
110 | - ), |
|
111 | - 'capability_type' => 'post', |
|
112 | - 'has_archive' => 'recipes', |
|
113 | - 'hierarchical' => false, |
|
114 | - 'menu_position' => null, |
|
115 | - 'supports' => array( |
|
116 | - 'title', |
|
117 | - 'editor', |
|
118 | - 'thumbnail', |
|
119 | - 'custom-fields', |
|
120 | - ), |
|
121 | - ); |
|
122 | - register_post_type( 'recipe', $args ); |
|
123 | - } |
|
80 | + /** |
|
81 | + * Register the post type. |
|
82 | + */ |
|
83 | + public function register_post_type() { |
|
84 | + $this->labels = array( |
|
85 | + 'name' => esc_html__( 'Recipes', 'lsx-health-plan' ), |
|
86 | + 'singular_name' => esc_html__( 'Recipe', 'lsx-health-plan' ), |
|
87 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
88 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
89 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
90 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
91 | + 'all_items' => esc_html__( 'All Recipes', 'lsx-health-plan' ), |
|
92 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
93 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
94 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
95 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
96 | + 'parent_item_colon' => '', |
|
97 | + 'menu_name' => esc_html__( 'Recipes', 'lsx-health-plan' ), |
|
98 | + ); |
|
99 | + $args = array( |
|
100 | + 'labels' => $this->labels, |
|
101 | + 'public' => true, |
|
102 | + 'publicly_queryable' => true, |
|
103 | + 'show_ui' => true, |
|
104 | + 'show_in_menu' => 'edit.php?post_type=meal-pseudo', |
|
105 | + 'show_in_rest' => true, |
|
106 | + 'menu_icon' => 'dashicons-editor-ul', |
|
107 | + 'query_var' => true, |
|
108 | + 'rewrite' => array( |
|
109 | + 'slug' => 'recipe', |
|
110 | + ), |
|
111 | + 'capability_type' => 'post', |
|
112 | + 'has_archive' => 'recipes', |
|
113 | + 'hierarchical' => false, |
|
114 | + 'menu_position' => null, |
|
115 | + 'supports' => array( |
|
116 | + 'title', |
|
117 | + 'editor', |
|
118 | + 'thumbnail', |
|
119 | + 'custom-fields', |
|
120 | + ), |
|
121 | + ); |
|
122 | + register_post_type( 'recipe', $args ); |
|
123 | + } |
|
124 | 124 | |
125 | - /** |
|
126 | - * Registers the Recipes under the Meals Post type menu. |
|
127 | - * |
|
128 | - * @return void |
|
129 | - */ |
|
130 | - public function register_menus() { |
|
131 | - add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipes', 'lsx-health-plan' ), esc_html__( 'Recipes', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=recipe' ); |
|
132 | - add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipe Types', 'lsx-health-plan' ), esc_html__( 'Recipe Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe' ); |
|
133 | - add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Cuisines', 'lsx-health-plan' ), esc_html__( 'Cuisines', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe' ); |
|
134 | - } |
|
125 | + /** |
|
126 | + * Registers the Recipes under the Meals Post type menu. |
|
127 | + * |
|
128 | + * @return void |
|
129 | + */ |
|
130 | + public function register_menus() { |
|
131 | + add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipes', 'lsx-health-plan' ), esc_html__( 'Recipes', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=recipe' ); |
|
132 | + add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Recipe Types', 'lsx-health-plan' ), esc_html__( 'Recipe Types', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-type&post_type=recipe' ); |
|
133 | + add_submenu_page( 'edit.php?post_type=meal', esc_html__( 'Cuisines', 'lsx-health-plan' ), esc_html__( 'Cuisines', 'lsx-health-plan' ), 'edit_posts', 'edit-tags.php?taxonomy=recipe-cuisine&post_type=recipe' ); |
|
134 | + } |
|
135 | 135 | |
136 | - /** |
|
137 | - * Register the Cuisine taxonomy. |
|
138 | - */ |
|
139 | - public function taxonomy_setup() { |
|
140 | - $labels = array( |
|
141 | - 'name' => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ), |
|
142 | - 'singular_name' => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ), |
|
143 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
144 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
145 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
146 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
147 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
148 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
149 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
150 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
151 | - 'menu_name' => esc_html__( 'Cuisines', 'lsx-health-plan' ), |
|
152 | - ); |
|
153 | - $args = array( |
|
154 | - 'hierarchical' => true, |
|
155 | - 'labels' => $labels, |
|
156 | - 'show_ui' => true, |
|
157 | - 'show_admin_column' => true, |
|
158 | - 'show_in_menu' => 'edit.php?post_type=meal', |
|
159 | - 'query_var' => true, |
|
160 | - 'rewrite' => array( |
|
161 | - 'slug' => 'recipe-cuisine', |
|
162 | - ), |
|
163 | - ); |
|
164 | - register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args ); |
|
136 | + /** |
|
137 | + * Register the Cuisine taxonomy. |
|
138 | + */ |
|
139 | + public function taxonomy_setup() { |
|
140 | + $labels = array( |
|
141 | + 'name' => esc_html_x( 'Cuisine', 'taxonomy general name', 'lsx-health-plan' ), |
|
142 | + 'singular_name' => esc_html_x( 'Cuisines', 'taxonomy singular name', 'lsx-health-plan' ), |
|
143 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
144 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
145 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
146 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
147 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
148 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
149 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
150 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
151 | + 'menu_name' => esc_html__( 'Cuisines', 'lsx-health-plan' ), |
|
152 | + ); |
|
153 | + $args = array( |
|
154 | + 'hierarchical' => true, |
|
155 | + 'labels' => $labels, |
|
156 | + 'show_ui' => true, |
|
157 | + 'show_admin_column' => true, |
|
158 | + 'show_in_menu' => 'edit.php?post_type=meal', |
|
159 | + 'query_var' => true, |
|
160 | + 'rewrite' => array( |
|
161 | + 'slug' => 'recipe-cuisine', |
|
162 | + ), |
|
163 | + ); |
|
164 | + register_taxonomy( 'recipe-cuisine', array( $this->slug ), $args ); |
|
165 | 165 | |
166 | - $labels = array( |
|
167 | - 'name' => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
168 | - 'singular_name' => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ), |
|
169 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
170 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
171 | - 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
172 | - 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
173 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
174 | - 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
175 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
176 | - 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
177 | - 'menu_name' => esc_html__( 'Types', 'lsx-health-plan' ), |
|
178 | - ); |
|
179 | - $args = array( |
|
180 | - 'hierarchical' => true, |
|
181 | - 'labels' => $labels, |
|
182 | - 'show_ui' => true, |
|
183 | - 'show_in_menu' => 'edit.php?post_type=meal', |
|
184 | - 'show_admin_column' => true, |
|
185 | - 'query_var' => true, |
|
186 | - 'rewrite' => array( |
|
187 | - 'slug' => 'recipe-type', |
|
188 | - ), |
|
189 | - ); |
|
190 | - register_taxonomy( 'recipe-type', array( $this->slug ), $args ); |
|
191 | - } |
|
166 | + $labels = array( |
|
167 | + 'name' => esc_html_x( 'Recipe Type', 'taxonomy general name', 'lsx-health-plan' ), |
|
168 | + 'singular_name' => esc_html_x( 'Recipe Types', 'taxonomy singular name', 'lsx-health-plan' ), |
|
169 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
170 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
171 | + 'parent_item' => esc_html__( 'Parent', 'lsx-health-plan' ), |
|
172 | + 'parent_item_colon' => esc_html__( 'Parent:', 'lsx-health-plan' ), |
|
173 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
174 | + 'update_item' => esc_html__( 'Update', 'lsx-health-plan' ), |
|
175 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
176 | + 'new_item_name' => esc_html__( 'New Name', 'lsx-health-plan' ), |
|
177 | + 'menu_name' => esc_html__( 'Types', 'lsx-health-plan' ), |
|
178 | + ); |
|
179 | + $args = array( |
|
180 | + 'hierarchical' => true, |
|
181 | + 'labels' => $labels, |
|
182 | + 'show_ui' => true, |
|
183 | + 'show_in_menu' => 'edit.php?post_type=meal', |
|
184 | + 'show_admin_column' => true, |
|
185 | + 'query_var' => true, |
|
186 | + 'rewrite' => array( |
|
187 | + 'slug' => 'recipe-type', |
|
188 | + ), |
|
189 | + ); |
|
190 | + register_taxonomy( 'recipe-type', array( $this->slug ), $args ); |
|
191 | + } |
|
192 | 192 | |
193 | - /** |
|
194 | - * Adds the post type to the different arrays. |
|
195 | - * |
|
196 | - * @param array $post_types |
|
197 | - * @return array |
|
198 | - */ |
|
199 | - public function enable_post_type( $post_types = array() ) { |
|
200 | - $post_types[] = $this->slug; |
|
201 | - return $post_types; |
|
202 | - } |
|
193 | + /** |
|
194 | + * Adds the post type to the different arrays. |
|
195 | + * |
|
196 | + * @param array $post_types |
|
197 | + * @return array |
|
198 | + */ |
|
199 | + public function enable_post_type( $post_types = array() ) { |
|
200 | + $post_types[] = $this->slug; |
|
201 | + return $post_types; |
|
202 | + } |
|
203 | 203 | |
204 | - /** |
|
205 | - * Enables the Bi Directional relationships |
|
206 | - * |
|
207 | - * @param array $connections |
|
208 | - * @return void |
|
209 | - */ |
|
210 | - public function enable_connections( $connections = array() ) { |
|
211 | - $connections['recipe']['connected_plans'] = 'connected_recipes'; |
|
212 | - $connections['plan']['connected_recipes'] = 'connected_plans'; |
|
213 | - return $connections; |
|
214 | - } |
|
204 | + /** |
|
205 | + * Enables the Bi Directional relationships |
|
206 | + * |
|
207 | + * @param array $connections |
|
208 | + * @return void |
|
209 | + */ |
|
210 | + public function enable_connections( $connections = array() ) { |
|
211 | + $connections['recipe']['connected_plans'] = 'connected_recipes'; |
|
212 | + $connections['plan']['connected_recipes'] = 'connected_plans'; |
|
213 | + return $connections; |
|
214 | + } |
|
215 | 215 | |
216 | - /** |
|
217 | - * Remove the "Archives:" from the post type recipes. |
|
218 | - * |
|
219 | - * @param string $title the term title. |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - public function get_the_archive_title( $title ) { |
|
223 | - if ( is_post_type_archive( 'recipe' ) ) { |
|
224 | - $title = __( 'Recipes', 'lsx-health-plan' ); |
|
225 | - } |
|
226 | - if ( is_post_type_archive( 'exercise' ) ) { |
|
227 | - $title = __( 'Exercises', 'lsx-health-plan' ); |
|
228 | - } |
|
229 | - if ( is_tax( 'recipe-type' ) ) { |
|
230 | - $queried_object = get_queried_object(); |
|
231 | - if ( isset( $queried_object->name ) ) { |
|
232 | - $title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' ); |
|
233 | - } |
|
234 | - } |
|
235 | - return $title; |
|
236 | - } |
|
216 | + /** |
|
217 | + * Remove the "Archives:" from the post type recipes. |
|
218 | + * |
|
219 | + * @param string $title the term title. |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + public function get_the_archive_title( $title ) { |
|
223 | + if ( is_post_type_archive( 'recipe' ) ) { |
|
224 | + $title = __( 'Recipes', 'lsx-health-plan' ); |
|
225 | + } |
|
226 | + if ( is_post_type_archive( 'exercise' ) ) { |
|
227 | + $title = __( 'Exercises', 'lsx-health-plan' ); |
|
228 | + } |
|
229 | + if ( is_tax( 'recipe-type' ) ) { |
|
230 | + $queried_object = get_queried_object(); |
|
231 | + if ( isset( $queried_object->name ) ) { |
|
232 | + $title = $queried_object->name . ' ' . __( 'Recipes', 'lsx-health-plan' ); |
|
233 | + } |
|
234 | + } |
|
235 | + return $title; |
|
236 | + } |
|
237 | 237 | |
238 | - public function remove_archive_original_header() { |
|
239 | - if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) { |
|
240 | - remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
241 | - } |
|
242 | - if ( ! is_post_type_archive() ) { |
|
243 | - add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 ); |
|
244 | - } |
|
245 | - } |
|
238 | + public function remove_archive_original_header() { |
|
239 | + if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) { |
|
240 | + remove_action( 'lsx_content_wrap_before', 'lsx_global_header' ); |
|
241 | + } |
|
242 | + if ( ! is_post_type_archive() ) { |
|
243 | + add_action( 'lsx_content_wrap_before', 'lsx_health_plan_recipe_archive_description', 11 ); |
|
244 | + } |
|
245 | + } |
|
246 | 246 | |
247 | - public function hp_lsx_archive_header() { |
|
248 | - if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) { |
|
249 | - ?> |
|
247 | + public function hp_lsx_archive_header() { |
|
248 | + if ( is_post_type_archive( 'recipe' ) || is_post_type_archive( 'exercise' ) ) { |
|
249 | + ?> |
|
250 | 250 | <div class="archive-header-wrapper banner-archive"> |
251 | 251 | <?php lsx_global_header_inner_bottom(); ?> |
252 | 252 | <header class="archive-header"> |
@@ -259,205 +259,205 @@ discard block |
||
259 | 259 | </h1> |
260 | 260 | |
261 | 261 | <?php |
262 | - lsx_health_plan_recipe_archive_description(); |
|
263 | - ?> |
|
262 | + lsx_health_plan_recipe_archive_description(); |
|
263 | + ?> |
|
264 | 264 | </header> |
265 | 265 | </div> |
266 | 266 | <?php |
267 | - } |
|
268 | - } |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - /** |
|
271 | - * Disables the global header description |
|
272 | - * |
|
273 | - * @param boolean $disable |
|
274 | - * @return boolean |
|
275 | - */ |
|
276 | - public function disable_global_header_description( $disable ) { |
|
277 | - if ( is_tax( 'recipe-type' ) ) { |
|
278 | - $disable = true; |
|
279 | - } |
|
280 | - return $disable; |
|
281 | - } |
|
270 | + /** |
|
271 | + * Disables the global header description |
|
272 | + * |
|
273 | + * @param boolean $disable |
|
274 | + * @return boolean |
|
275 | + */ |
|
276 | + public function disable_global_header_description( $disable ) { |
|
277 | + if ( is_tax( 'recipe-type' ) ) { |
|
278 | + $disable = true; |
|
279 | + } |
|
280 | + return $disable; |
|
281 | + } |
|
282 | 282 | |
283 | - /** |
|
284 | - * Holds the array for the breadcrumbs. |
|
285 | - * |
|
286 | - * @var array $crumbs |
|
287 | - * @return array |
|
288 | - */ |
|
289 | - public function recipes_breadcrumb_filter( $crumbs ) { |
|
290 | - $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', 'recipe' ); |
|
291 | - $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe_archive', 'recipes' ); |
|
292 | - $url = get_post_type_archive_link( 'recipe' ); |
|
283 | + /** |
|
284 | + * Holds the array for the breadcrumbs. |
|
285 | + * |
|
286 | + * @var array $crumbs |
|
287 | + * @return array |
|
288 | + */ |
|
289 | + public function recipes_breadcrumb_filter( $crumbs ) { |
|
290 | + $recipe = \lsx_health_plan\functions\get_option( 'endpoint_recipe', 'recipe' ); |
|
291 | + $recipes = \lsx_health_plan\functions\get_option( 'endpoint_recipe_archive', 'recipes' ); |
|
292 | + $url = get_post_type_archive_link( 'recipe' ); |
|
293 | 293 | |
294 | - if ( is_singular( 'recipe' ) ) { |
|
295 | - $recipe_name = get_the_title(); |
|
296 | - $term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' ); |
|
297 | - $recipe_type = $term_obj_list[0]->name; |
|
298 | - $recipe_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
294 | + if ( is_singular( 'recipe' ) ) { |
|
295 | + $recipe_name = get_the_title(); |
|
296 | + $term_obj_list = get_the_terms( get_the_ID(), 'recipe-type' ); |
|
297 | + $recipe_type = $term_obj_list[0]->name; |
|
298 | + $recipe_type_url = get_term_link( $term_obj_list[0]->term_id ); |
|
299 | 299 | |
300 | - $crumbs[1] = array( |
|
301 | - 0 => $recipes, |
|
302 | - 1 => $url, |
|
303 | - ); |
|
304 | - $crumbs[2] = array( |
|
305 | - 0 => $recipe_type, |
|
306 | - 1 => $recipe_type_url, |
|
307 | - ); |
|
308 | - $crumbs[3] = array( |
|
309 | - 0 => $recipe_name, |
|
310 | - ); |
|
311 | - } |
|
312 | - if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) { |
|
313 | - $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
300 | + $crumbs[1] = array( |
|
301 | + 0 => $recipes, |
|
302 | + 1 => $url, |
|
303 | + ); |
|
304 | + $crumbs[2] = array( |
|
305 | + 0 => $recipe_type, |
|
306 | + 1 => $recipe_type_url, |
|
307 | + ); |
|
308 | + $crumbs[3] = array( |
|
309 | + 0 => $recipe_name, |
|
310 | + ); |
|
311 | + } |
|
312 | + if ( is_tax( 'recipe-type' ) || is_tax( 'recipe-cuisine' ) ) { |
|
313 | + $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); |
|
314 | 314 | |
315 | - $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
315 | + $single_term_title = str_replace( '-', ' ', $term->taxonomy ) . ': ' . $term->name; |
|
316 | 316 | |
317 | - $crumbs[1] = array( |
|
318 | - 0 => $recipes, |
|
319 | - 1 => $url, |
|
320 | - ); |
|
321 | - $crumbs[2] = array( |
|
322 | - 0 => $single_term_title, |
|
323 | - ); |
|
324 | - } |
|
325 | - return $crumbs; |
|
326 | - } |
|
317 | + $crumbs[1] = array( |
|
318 | + 0 => $recipes, |
|
319 | + 1 => $url, |
|
320 | + ); |
|
321 | + $crumbs[2] = array( |
|
322 | + 0 => $single_term_title, |
|
323 | + ); |
|
324 | + } |
|
325 | + return $crumbs; |
|
326 | + } |
|
327 | 327 | |
328 | - /** |
|
329 | - * Define the metabox and field configurations. |
|
330 | - */ |
|
331 | - public function featured_metabox() { |
|
332 | - $cmb = new_cmb2_box( |
|
333 | - array( |
|
334 | - 'id' => $this->slug . '_featured_metabox', |
|
335 | - 'title' => __( 'Featured', 'lsx-health-plan' ), |
|
336 | - 'object_types' => array( $this->slug ), |
|
337 | - 'context' => 'side', |
|
338 | - 'priority' => 'high', |
|
339 | - 'show_names' => true, |
|
340 | - ) |
|
341 | - ); |
|
342 | - $cmb->add_field( |
|
343 | - array( |
|
344 | - 'name' => __( 'Featured', 'lsx-health-plan' ), |
|
345 | - 'desc' => __( 'Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan' ), |
|
346 | - 'id' => $this->slug . '_featured', |
|
347 | - 'type' => 'checkbox', |
|
348 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
349 | - ) |
|
350 | - ); |
|
351 | - } |
|
328 | + /** |
|
329 | + * Define the metabox and field configurations. |
|
330 | + */ |
|
331 | + public function featured_metabox() { |
|
332 | + $cmb = new_cmb2_box( |
|
333 | + array( |
|
334 | + 'id' => $this->slug . '_featured_metabox', |
|
335 | + 'title' => __( 'Featured', 'lsx-health-plan' ), |
|
336 | + 'object_types' => array( $this->slug ), |
|
337 | + 'context' => 'side', |
|
338 | + 'priority' => 'high', |
|
339 | + 'show_names' => true, |
|
340 | + ) |
|
341 | + ); |
|
342 | + $cmb->add_field( |
|
343 | + array( |
|
344 | + 'name' => __( 'Featured', 'lsx-health-plan' ), |
|
345 | + 'desc' => __( 'Enable the checkbox to feature this recipe, featured recipes display in any page that has the recipe shortcode: [lsx_health_plan_featured_recipes_block]', 'lsx-health-plan' ), |
|
346 | + 'id' => $this->slug . '_featured', |
|
347 | + 'type' => 'checkbox', |
|
348 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
349 | + ) |
|
350 | + ); |
|
351 | + } |
|
352 | 352 | |
353 | - /** |
|
354 | - * Define the metabox and field configurations. |
|
355 | - */ |
|
356 | - public function details_metaboxes() { |
|
357 | - $cmb = new_cmb2_box( |
|
358 | - array( |
|
359 | - 'id' => $this->slug . '_details_metabox', |
|
360 | - 'title' => __( 'Cooking Info', 'lsx-health-plan' ), |
|
361 | - 'object_types' => array( $this->slug ), // Post type |
|
362 | - 'context' => 'normal', |
|
363 | - 'priority' => 'high', |
|
364 | - 'show_names' => true, |
|
365 | - ) |
|
366 | - ); |
|
367 | - $cmb->add_field( |
|
368 | - array( |
|
369 | - 'name' => __( 'Prep Time', 'lsx-health-plan' ), |
|
370 | - 'id' => $this->slug . '_prep_time', |
|
371 | - 'desc' => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ), |
|
372 | - 'type' => 'text', |
|
373 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
374 | - ) |
|
375 | - ); |
|
376 | - $cmb->add_field( |
|
377 | - array( |
|
378 | - 'name' => __( 'Cooking Time', 'lsx-health-plan' ), |
|
379 | - 'id' => $this->slug . '_cooking_time', |
|
380 | - 'desc' => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ), |
|
381 | - 'type' => 'text', |
|
382 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
383 | - ) |
|
384 | - ); |
|
385 | - $cmb->add_field( |
|
386 | - array( |
|
387 | - 'name' => __( 'Serves', 'lsx-health-plan' ), |
|
388 | - 'id' => $this->slug . '_serves', |
|
389 | - 'desc' => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ), |
|
390 | - 'type' => 'text', |
|
391 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
392 | - 'attributes' => array( |
|
393 | - 'type' => 'number', |
|
394 | - 'pattern' => '\d*', |
|
395 | - ), |
|
396 | - ) |
|
397 | - ); |
|
398 | - $cmb->add_field( |
|
399 | - array( |
|
400 | - 'name' => __( 'Portion', 'lsx-health-plan' ), |
|
401 | - 'desc' => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ), |
|
402 | - 'id' => $this->slug . '_portion', |
|
403 | - 'type' => 'text', |
|
404 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
405 | - ) |
|
406 | - ); |
|
407 | - $cmb = new_cmb2_box( |
|
408 | - array( |
|
409 | - 'id' => $this->slug . '_nutritional_metabox', |
|
410 | - 'title' => __( 'Nutritional Info', 'lsx-health-plan' ), |
|
411 | - 'object_types' => array( $this->slug ), // Post type |
|
412 | - 'context' => 'normal', |
|
413 | - 'priority' => 'high', |
|
414 | - 'show_names' => true, |
|
415 | - ) |
|
416 | - ); |
|
417 | - $cmb->add_field( |
|
418 | - array( |
|
419 | - 'name' => __( 'Energy', 'lsx-health-plan' ), |
|
420 | - 'id' => $this->slug . '_energy', |
|
421 | - 'desc' => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ), |
|
422 | - 'type' => 'text', |
|
423 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
424 | - ) |
|
425 | - ); |
|
426 | - $cmb->add_field( |
|
427 | - array( |
|
428 | - 'name' => __( 'Protein', 'lsx-health-plan' ), |
|
429 | - 'id' => $this->slug . '_protein', |
|
430 | - 'desc' => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ), |
|
431 | - 'type' => 'text', |
|
432 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
433 | - ) |
|
434 | - ); |
|
435 | - $cmb->add_field( |
|
436 | - array( |
|
437 | - 'name' => __( 'Carbohydrates', 'lsx-health-plan' ), |
|
438 | - 'id' => $this->slug . '_carbohydrates', |
|
439 | - 'desc' => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ), |
|
440 | - 'type' => 'text', |
|
441 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
442 | - ) |
|
443 | - ); |
|
444 | - $cmb->add_field( |
|
445 | - array( |
|
446 | - 'name' => __( 'Fibre', 'lsx-health-plan' ), |
|
447 | - 'id' => $this->slug . '_fibre', |
|
448 | - 'desc' => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ), |
|
449 | - 'type' => 'text', |
|
450 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
451 | - ) |
|
452 | - ); |
|
453 | - $cmb->add_field( |
|
454 | - array( |
|
455 | - 'name' => __( 'Fat', 'lsx-health-plan' ), |
|
456 | - 'id' => $this->slug . '_fat', |
|
457 | - 'desc' => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ), |
|
458 | - 'type' => 'text', |
|
459 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
460 | - ) |
|
461 | - ); |
|
462 | - } |
|
353 | + /** |
|
354 | + * Define the metabox and field configurations. |
|
355 | + */ |
|
356 | + public function details_metaboxes() { |
|
357 | + $cmb = new_cmb2_box( |
|
358 | + array( |
|
359 | + 'id' => $this->slug . '_details_metabox', |
|
360 | + 'title' => __( 'Cooking Info', 'lsx-health-plan' ), |
|
361 | + 'object_types' => array( $this->slug ), // Post type |
|
362 | + 'context' => 'normal', |
|
363 | + 'priority' => 'high', |
|
364 | + 'show_names' => true, |
|
365 | + ) |
|
366 | + ); |
|
367 | + $cmb->add_field( |
|
368 | + array( |
|
369 | + 'name' => __( 'Prep Time', 'lsx-health-plan' ), |
|
370 | + 'id' => $this->slug . '_prep_time', |
|
371 | + 'desc' => __( 'Add the preparation time for the entire meal i.e: 25 mins', 'lsx-health-plan' ), |
|
372 | + 'type' => 'text', |
|
373 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
374 | + ) |
|
375 | + ); |
|
376 | + $cmb->add_field( |
|
377 | + array( |
|
378 | + 'name' => __( 'Cooking Time', 'lsx-health-plan' ), |
|
379 | + 'id' => $this->slug . '_cooking_time', |
|
380 | + 'desc' => __( 'Add the cooking time i.e: 15 mins', 'lsx-health-plan' ), |
|
381 | + 'type' => 'text', |
|
382 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
383 | + ) |
|
384 | + ); |
|
385 | + $cmb->add_field( |
|
386 | + array( |
|
387 | + 'name' => __( 'Serves', 'lsx-health-plan' ), |
|
388 | + 'id' => $this->slug . '_serves', |
|
389 | + 'desc' => __( 'Add the recommended serving size i.e: 6', 'lsx-health-plan' ), |
|
390 | + 'type' => 'text', |
|
391 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
392 | + 'attributes' => array( |
|
393 | + 'type' => 'number', |
|
394 | + 'pattern' => '\d*', |
|
395 | + ), |
|
396 | + ) |
|
397 | + ); |
|
398 | + $cmb->add_field( |
|
399 | + array( |
|
400 | + 'name' => __( 'Portion', 'lsx-health-plan' ), |
|
401 | + 'desc' => __( 'Add the recommended portion size i.e: 200mg', 'lsx-health-plan' ), |
|
402 | + 'id' => $this->slug . '_portion', |
|
403 | + 'type' => 'text', |
|
404 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
405 | + ) |
|
406 | + ); |
|
407 | + $cmb = new_cmb2_box( |
|
408 | + array( |
|
409 | + 'id' => $this->slug . '_nutritional_metabox', |
|
410 | + 'title' => __( 'Nutritional Info', 'lsx-health-plan' ), |
|
411 | + 'object_types' => array( $this->slug ), // Post type |
|
412 | + 'context' => 'normal', |
|
413 | + 'priority' => 'high', |
|
414 | + 'show_names' => true, |
|
415 | + ) |
|
416 | + ); |
|
417 | + $cmb->add_field( |
|
418 | + array( |
|
419 | + 'name' => __( 'Energy', 'lsx-health-plan' ), |
|
420 | + 'id' => $this->slug . '_energy', |
|
421 | + 'desc' => __( 'Add the energy amount for the entire meal i.e: 700 kj', 'lsx-health-plan' ), |
|
422 | + 'type' => 'text', |
|
423 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
424 | + ) |
|
425 | + ); |
|
426 | + $cmb->add_field( |
|
427 | + array( |
|
428 | + 'name' => __( 'Protein', 'lsx-health-plan' ), |
|
429 | + 'id' => $this->slug . '_protein', |
|
430 | + 'desc' => __( 'Add the protein amount for the entire meal i.e: 50 g', 'lsx-health-plan' ), |
|
431 | + 'type' => 'text', |
|
432 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
433 | + ) |
|
434 | + ); |
|
435 | + $cmb->add_field( |
|
436 | + array( |
|
437 | + 'name' => __( 'Carbohydrates', 'lsx-health-plan' ), |
|
438 | + 'id' => $this->slug . '_carbohydrates', |
|
439 | + 'desc' => __( 'Add the carbohydrates amount for the entire meal i.e: 5 g', 'lsx-health-plan' ), |
|
440 | + 'type' => 'text', |
|
441 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
442 | + ) |
|
443 | + ); |
|
444 | + $cmb->add_field( |
|
445 | + array( |
|
446 | + 'name' => __( 'Fibre', 'lsx-health-plan' ), |
|
447 | + 'id' => $this->slug . '_fibre', |
|
448 | + 'desc' => __( 'Add the fibre amount for the entire meal i.e: 5 g', 'lsx-health-plan' ), |
|
449 | + 'type' => 'text', |
|
450 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
451 | + ) |
|
452 | + ); |
|
453 | + $cmb->add_field( |
|
454 | + array( |
|
455 | + 'name' => __( 'Fat', 'lsx-health-plan' ), |
|
456 | + 'id' => $this->slug . '_fat', |
|
457 | + 'desc' => __( 'Add the fat amount for the entire meal i.e: 20 g', 'lsx-health-plan' ), |
|
458 | + 'type' => 'text', |
|
459 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
460 | + ) |
|
461 | + ); |
|
462 | + } |
|
463 | 463 | } |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | $plan_link = get_permalink(); |
9 | 9 | $current_section = get_query_var( 'section', false ); |
10 | 10 | if ( '' !== $current_section ) { |
11 | - $plan_link = \lsx_health_plan\functions\plan\get_permalink( get_the_ID(), $current_section ); |
|
11 | + $plan_link = \lsx_health_plan\functions\plan\get_permalink( get_the_ID(), $current_section ); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | if ( false !== $current_section && \lsx_health_plan\functions\plan\has_sections() ) { |
15 | - $section_info = \lsx_health_plan\functions\plan\get_section_info( $current_section ); |
|
16 | - if ( empty( $section_info ) || ( isset( $section_info['rest_day_enabled'] ) && ! empty( $section_info['rest_day_enabled'] ) && ! lsx_health_plan_has_meal() ) ) { |
|
17 | - return; |
|
18 | - } |
|
15 | + $section_info = \lsx_health_plan\functions\plan\get_section_info( $current_section ); |
|
16 | + if ( empty( $section_info ) || ( isset( $section_info['rest_day_enabled'] ) && ! empty( $section_info['rest_day_enabled'] ) && ! lsx_health_plan_has_meal() ) ) { |
|
17 | + return; |
|
18 | + } |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | ?> |
@@ -23,33 +23,33 @@ discard block |
||
23 | 23 | <ul class="nav nav-pills"> |
24 | 24 | <li class="<?php lsx_health_plan_nav_class( '' ); ?>"><a class="overview-tab" href="<?php echo esc_attr( $plan_link ); ?>"><?php lsx_get_svg_icon( 'eye.svg' ); ?> <?php esc_html_e( 'Overview', 'lsx-health-plan' ); ?></a></li> |
25 | 25 | <?php |
26 | - if ( lsx_health_plan_has_warmup() ) { |
|
27 | - $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
28 | - if ( false === $warm_up ) { |
|
29 | - $warm_up = 'warm-up'; |
|
30 | - } |
|
31 | - ?> |
|
26 | + if ( lsx_health_plan_has_warmup() ) { |
|
27 | + $warm_up = \lsx_health_plan\functions\get_option( 'endpoint_warm_up', false ); |
|
28 | + if ( false === $warm_up ) { |
|
29 | + $warm_up = 'warm-up'; |
|
30 | + } |
|
31 | + ?> |
|
32 | 32 | <li class="<?php lsx_health_plan_nav_class( 'warm-up' ); ?>"><a class="warm-up-tab" href="<?php echo esc_attr( $plan_link ); ?><?php echo esc_attr( $warm_up ); ?>/"><?php lsx_get_svg_icon( 'warm.svg' ); ?> <?php esc_html_e( 'Warm-up', 'lsx-health-plan' ); ?></a></li> |
33 | 33 | <?php |
34 | - } |
|
35 | - if ( lsx_health_plan_has_workout() ) { |
|
36 | - $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
37 | - if ( false === $workout ) { |
|
38 | - $workout = 'workout'; |
|
39 | - } |
|
40 | - ?> |
|
34 | + } |
|
35 | + if ( lsx_health_plan_has_workout() ) { |
|
36 | + $workout = \lsx_health_plan\functions\get_option( 'endpoint_workout', false ); |
|
37 | + if ( false === $workout ) { |
|
38 | + $workout = 'workout'; |
|
39 | + } |
|
40 | + ?> |
|
41 | 41 | <li class="<?php lsx_health_plan_nav_class( 'workout' ); ?>"><a class="workout-tab" href="<?php echo esc_attr( $plan_link ); ?><?php echo esc_attr( $workout ); ?>/"><?php lsx_get_svg_icon( 'work.svg' ); ?> <?php esc_html_e( 'Workout', 'lsx-health-plan' ); ?></a></li> |
42 | 42 | <?php |
43 | - } |
|
44 | - if ( lsx_health_plan_has_meal() ) { |
|
45 | - $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
46 | - if ( false === $meal ) { |
|
47 | - $meal = 'meal'; |
|
48 | - } |
|
49 | - ?> |
|
43 | + } |
|
44 | + if ( lsx_health_plan_has_meal() ) { |
|
45 | + $meal = \lsx_health_plan\functions\get_option( 'endpoint_meal', false ); |
|
46 | + if ( false === $meal ) { |
|
47 | + $meal = 'meal'; |
|
48 | + } |
|
49 | + ?> |
|
50 | 50 | <li class="<?php lsx_health_plan_nav_class( 'meal' ); ?>"><a class="meal-plan-tab" href="<?php echo esc_attr( $plan_link ); ?><?php echo esc_attr( $meal ); ?>/"><?php lsx_get_svg_icon( 'meal.svg' ); ?> <?php esc_html_e( 'Meal Plan', 'lsx-health-plan' ); ?></a></li> |
51 | 51 | <?php |
52 | - } |
|
53 | - ?> |
|
52 | + } |
|
53 | + ?> |
|
54 | 54 | </ul> |
55 | 55 | </div> |
@@ -12,257 +12,257 @@ |
||
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; |
|
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 | 23 | |
24 | - /** |
|
25 | - * Option key, and option page slug |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $screen_id = 'lsx_health_plan_settings'; |
|
24 | + /** |
|
25 | + * Option key, and option page slug |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $screen_id = 'lsx_health_plan_settings'; |
|
30 | 30 | |
31 | - /** |
|
32 | - * An array of the post types for the Global Downloads field. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $download_types = array(); |
|
31 | + /** |
|
32 | + * An array of the post types for the Global Downloads field. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $download_types = array(); |
|
37 | 37 | |
38 | - /** |
|
39 | - * An array of the post types for the Global Defaults field. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - //public $default_types = array(); |
|
38 | + /** |
|
39 | + * An array of the post types for the Global Defaults field. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + //public $default_types = array(); |
|
44 | 44 | |
45 | - /** |
|
46 | - * An array of the endpoints for the Endpoint Translation field. |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - public $endpoints = array(); |
|
45 | + /** |
|
46 | + * An array of the endpoints for the Endpoint Translation field. |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + public $endpoints = array(); |
|
51 | 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 ); |
|
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 | 59 | |
60 | - add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 ); |
|
61 | - } |
|
60 | + add_action( 'lsx_hp_settings_page_general_top', array( $this, 'general_settings' ), 1, 1 ); |
|
61 | + } |
|
62 | 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 | - } |
|
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 | 77 | |
78 | - /** |
|
79 | - * Loads the variable classes and the static classes. |
|
80 | - */ |
|
81 | - private function load_classes() { |
|
78 | + /** |
|
79 | + * Loads the variable classes and the static classes. |
|
80 | + */ |
|
81 | + private function load_classes() { |
|
82 | 82 | |
83 | - $this->post_types = array( |
|
84 | - 'my-plans', |
|
85 | - 'workout', |
|
86 | - 'exercise', |
|
87 | - 'meal', |
|
88 | - 'recipe', |
|
89 | - //'tip', |
|
90 | - 'recipe', |
|
91 | - ); |
|
83 | + $this->post_types = array( |
|
84 | + 'my-plans', |
|
85 | + 'workout', |
|
86 | + 'exercise', |
|
87 | + 'meal', |
|
88 | + 'recipe', |
|
89 | + //'tip', |
|
90 | + 'recipe', |
|
91 | + ); |
|
92 | 92 | |
93 | - foreach ( $this->post_types as $post_type ) { |
|
94 | - $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
|
95 | - } |
|
93 | + foreach ( $this->post_types as $post_type ) { |
|
94 | + $this->$post_type = require_once LSX_HEALTH_PLAN_PATH . 'classes/admin/settings/class-' . $post_type . '.php'; |
|
95 | + } |
|
96 | 96 | |
97 | - } |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Hook in and register a submenu options page for the Page post-type menu. |
|
101 | - */ |
|
102 | - public function register_settings_page() { |
|
103 | - $cmb = new_cmb2_box( |
|
104 | - array( |
|
105 | - 'id' => $this->screen_id, |
|
106 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
107 | - 'object_types' => array( 'options-page' ), |
|
108 | - 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
|
109 | - 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
|
110 | - 'capability' => 'manage_options', // Cap required to view options-page. |
|
111 | - ) |
|
112 | - ); |
|
113 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
114 | - } |
|
99 | + /** |
|
100 | + * Hook in and register a submenu options page for the Page post-type menu. |
|
101 | + */ |
|
102 | + public function register_settings_page() { |
|
103 | + $cmb = new_cmb2_box( |
|
104 | + array( |
|
105 | + 'id' => $this->screen_id, |
|
106 | + 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
107 | + 'object_types' => array( 'options-page' ), |
|
108 | + 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
|
109 | + 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
|
110 | + 'capability' => 'manage_options', // Cap required to view options-page. |
|
111 | + ) |
|
112 | + ); |
|
113 | + do_action( 'lsx_hp_settings_page', $cmb ); |
|
114 | + } |
|
115 | 115 | |
116 | - /** |
|
117 | - * Registers the general settings. |
|
118 | - * |
|
119 | - * @param object $cmb new_cmb2_box(). |
|
120 | - * @return void |
|
121 | - */ |
|
122 | - public function general_settings( $cmb ) { |
|
123 | - $cmb->add_field( |
|
124 | - array( |
|
125 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
126 | - 'id' => 'exercise_enabled', |
|
127 | - 'type' => 'checkbox', |
|
128 | - 'value' => 1, |
|
129 | - 'default' => 0, |
|
130 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
131 | - ) |
|
132 | - ); |
|
116 | + /** |
|
117 | + * Registers the general settings. |
|
118 | + * |
|
119 | + * @param object $cmb new_cmb2_box(). |
|
120 | + * @return void |
|
121 | + */ |
|
122 | + public function general_settings( $cmb ) { |
|
123 | + $cmb->add_field( |
|
124 | + array( |
|
125 | + 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
126 | + 'id' => 'exercise_enabled', |
|
127 | + 'type' => 'checkbox', |
|
128 | + 'value' => 1, |
|
129 | + 'default' => 0, |
|
130 | + 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
131 | + ) |
|
132 | + ); |
|
133 | 133 | |
134 | - $cmb->add_field( |
|
135 | - array( |
|
136 | - 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
137 | - 'id' => 'workout_disabled', |
|
138 | - 'type' => 'checkbox', |
|
139 | - 'value' => 1, |
|
140 | - 'default' => 0, |
|
141 | - 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
142 | - ) |
|
143 | - ); |
|
134 | + $cmb->add_field( |
|
135 | + array( |
|
136 | + 'name' => __( 'Disable Workouts', 'lsx-health-plan' ), |
|
137 | + 'id' => 'workout_disabled', |
|
138 | + 'type' => 'checkbox', |
|
139 | + 'value' => 1, |
|
140 | + 'default' => 0, |
|
141 | + 'description' => __( 'Disable workout post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
142 | + ) |
|
143 | + ); |
|
144 | 144 | |
145 | - $cmb->add_field( |
|
146 | - array( |
|
147 | - 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
148 | - 'id' => 'recipe_disabled', |
|
149 | - 'type' => 'checkbox', |
|
150 | - 'value' => 1, |
|
151 | - 'default' => 0, |
|
152 | - 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
153 | - ) |
|
154 | - ); |
|
145 | + $cmb->add_field( |
|
146 | + array( |
|
147 | + 'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
|
148 | + 'id' => 'recipe_disabled', |
|
149 | + 'type' => 'checkbox', |
|
150 | + 'value' => 1, |
|
151 | + 'default' => 0, |
|
152 | + 'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
153 | + ) |
|
154 | + ); |
|
155 | 155 | |
156 | - $cmb->add_field( |
|
157 | - array( |
|
158 | - 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
159 | - 'id' => 'meal_disabled', |
|
160 | - 'type' => 'checkbox', |
|
161 | - 'value' => 1, |
|
162 | - 'default' => 0, |
|
163 | - 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
164 | - ) |
|
165 | - ); |
|
156 | + $cmb->add_field( |
|
157 | + array( |
|
158 | + 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
159 | + 'id' => 'meal_disabled', |
|
160 | + 'type' => 'checkbox', |
|
161 | + 'value' => 1, |
|
162 | + 'default' => 0, |
|
163 | + 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
164 | + ) |
|
165 | + ); |
|
166 | 166 | |
167 | 167 | |
168 | - $cmb->add_field( |
|
169 | - array( |
|
170 | - 'name' => __( 'Login Slug', 'lsx-health-plan' ), |
|
171 | - 'id' => 'login_slug', |
|
172 | - 'type' => 'input', |
|
173 | - 'value' => '', |
|
174 | - 'default' => 'login', |
|
175 | - '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' ), |
|
176 | - ) |
|
177 | - ); |
|
168 | + $cmb->add_field( |
|
169 | + array( |
|
170 | + 'name' => __( 'Login Slug', 'lsx-health-plan' ), |
|
171 | + 'id' => 'login_slug', |
|
172 | + 'type' => 'input', |
|
173 | + 'value' => '', |
|
174 | + 'default' => 'login', |
|
175 | + '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' ), |
|
176 | + ) |
|
177 | + ); |
|
178 | 178 | |
179 | - } |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * Enable Business Directory Search settings only if LSX Search plugin is enabled. |
|
183 | - * |
|
184 | - * @param object $cmb The CMB2() class. |
|
185 | - * @param string $section either engine,archive or single. |
|
186 | - * @return void |
|
187 | - */ |
|
188 | - public function generate_tabs( $cmb ) { |
|
189 | - $tabs = $this->get_settings_tabs(); |
|
181 | + /** |
|
182 | + * Enable Business Directory Search settings only if LSX Search plugin is enabled. |
|
183 | + * |
|
184 | + * @param object $cmb The CMB2() class. |
|
185 | + * @param string $section either engine,archive or single. |
|
186 | + * @return void |
|
187 | + */ |
|
188 | + public function generate_tabs( $cmb ) { |
|
189 | + $tabs = $this->get_settings_tabs(); |
|
190 | 190 | |
191 | - foreach ( $tabs as $tab_key => $tab ) { |
|
192 | - $cmb->add_field( |
|
193 | - array( |
|
194 | - 'id' => 'settings_' . $tab_key . '_title', |
|
195 | - 'type' => 'title', |
|
196 | - 'name' => $tab['title'], |
|
197 | - 'default' => $tab['title'], |
|
198 | - 'description' => $tab['desc'], |
|
199 | - ) |
|
200 | - ); |
|
201 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
191 | + foreach ( $tabs as $tab_key => $tab ) { |
|
192 | + $cmb->add_field( |
|
193 | + array( |
|
194 | + 'id' => 'settings_' . $tab_key . '_title', |
|
195 | + 'type' => 'title', |
|
196 | + 'name' => $tab['title'], |
|
197 | + 'default' => $tab['title'], |
|
198 | + 'description' => $tab['desc'], |
|
199 | + ) |
|
200 | + ); |
|
201 | + do_action( 'lsx_hp_settings_page_' . $tab_key . '_top', $cmb ); |
|
202 | 202 | |
203 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
203 | + do_action( 'lsx_hp_settings_page_' . $tab_key . '_middle', $cmb ); |
|
204 | 204 | |
205 | - do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
205 | + do_action( 'lsx_hp_settings_page_' . $tab_key . '_bottom', $cmb ); |
|
206 | 206 | |
207 | - $cmb->add_field( |
|
208 | - array( |
|
209 | - 'id' => 'settings_' . $tab_key . '_closing', |
|
210 | - 'type' => 'tab_closing', |
|
211 | - ) |
|
212 | - ); |
|
213 | - } |
|
214 | - } |
|
207 | + $cmb->add_field( |
|
208 | + array( |
|
209 | + 'id' => 'settings_' . $tab_key . '_closing', |
|
210 | + 'type' => 'tab_closing', |
|
211 | + ) |
|
212 | + ); |
|
213 | + } |
|
214 | + } |
|
215 | 215 | |
216 | 216 | |
217 | - /** |
|
218 | - * Returns the tabs and their descriptions. |
|
219 | - * |
|
220 | - * @return array |
|
221 | - */ |
|
222 | - public function get_settings_tabs() { |
|
223 | - $tabs = array( |
|
224 | - 'general' => array( |
|
225 | - 'title' => __( 'General', 'lsx-health-plan' ), |
|
226 | - 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
227 | - ), |
|
228 | - ); |
|
217 | + /** |
|
218 | + * Returns the tabs and their descriptions. |
|
219 | + * |
|
220 | + * @return array |
|
221 | + */ |
|
222 | + public function get_settings_tabs() { |
|
223 | + $tabs = array( |
|
224 | + 'general' => array( |
|
225 | + 'title' => __( 'General', 'lsx-health-plan' ), |
|
226 | + 'desc' => __( 'Control the sitewide settings for the LSX HP site.', 'lsx-health-plan' ), |
|
227 | + ), |
|
228 | + ); |
|
229 | 229 | |
230 | - foreach ( $this->post_types as $post_type ) { |
|
231 | - switch ( $post_type ) { |
|
232 | - case 'my-plans': |
|
233 | - $page_url = get_post_type_archive_link( 'plan' ); |
|
234 | - $description = sprintf( |
|
235 | - /* translators: %s: The subscription info */ |
|
236 | - __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> pages.', 'lsx-search' ), |
|
237 | - $page_url, |
|
238 | - __( 'plan', 'lsx-health-plan' ) |
|
239 | - ); |
|
240 | - $tabs[ $post_type ] = array( |
|
241 | - 'title' => __( 'My Plans', 'lsx-health-plan' ), |
|
242 | - 'desc' => $description, |
|
243 | - ); |
|
244 | - break; |
|
245 | - default: |
|
246 | - //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
247 | - $temp_post_type = get_post_type_object( $post_type ); |
|
248 | - if ( ! is_wp_error( $temp_post_type ) ) { |
|
249 | - $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
250 | - $description = sprintf( |
|
251 | - /* translators: %s: The subscription info */ |
|
252 | - __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
253 | - $page_url, |
|
254 | - $temp_post_type->label |
|
255 | - ); |
|
230 | + foreach ( $this->post_types as $post_type ) { |
|
231 | + switch ( $post_type ) { |
|
232 | + case 'my-plans': |
|
233 | + $page_url = get_post_type_archive_link( 'plan' ); |
|
234 | + $description = sprintf( |
|
235 | + /* translators: %s: The subscription info */ |
|
236 | + __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> pages.', 'lsx-search' ), |
|
237 | + $page_url, |
|
238 | + __( 'plan', 'lsx-health-plan' ) |
|
239 | + ); |
|
240 | + $tabs[ $post_type ] = array( |
|
241 | + 'title' => __( 'My Plans', 'lsx-health-plan' ), |
|
242 | + 'desc' => $description, |
|
243 | + ); |
|
244 | + break; |
|
245 | + default: |
|
246 | + //if ( ! in_array( $post_type, \lsx\search\includes\get_restricted_post_types() ) ) { |
|
247 | + $temp_post_type = get_post_type_object( $post_type ); |
|
248 | + if ( ! is_wp_error( $temp_post_type ) ) { |
|
249 | + $page_url = get_post_type_archive_link( $temp_post_type->name ); |
|
250 | + $description = sprintf( |
|
251 | + /* translators: %s: The subscription info */ |
|
252 | + __( 'Control the settings for your <a target="_blank" href="%1$s">%2$s</a> archive.', 'lsx-search' ), |
|
253 | + $page_url, |
|
254 | + $temp_post_type->label |
|
255 | + ); |
|
256 | 256 | |
257 | - $tabs[ $post_type ] = array( |
|
258 | - 'title' => $temp_post_type->label, |
|
259 | - 'desc' => $description, |
|
260 | - ); |
|
261 | - } |
|
262 | - //} |
|
263 | - break; |
|
264 | - } |
|
265 | - } |
|
266 | - return $tabs; |
|
267 | - } |
|
257 | + $tabs[ $post_type ] = array( |
|
258 | + 'title' => $temp_post_type->label, |
|
259 | + 'desc' => $description, |
|
260 | + ); |
|
261 | + } |
|
262 | + //} |
|
263 | + break; |
|
264 | + } |
|
265 | + } |
|
266 | + return $tabs; |
|
267 | + } |
|
268 | 268 | } |
@@ -12,146 +12,146 @@ |
||
12 | 12 | */ |
13 | 13 | class Meal { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Meal() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Meal() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - add_action( 'lsx_hp_settings_page_meal_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | - } |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + add_action( 'lsx_hp_settings_page_meal_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return an instance of this class. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * |
|
36 | - * @return object \lsx_health_plan\classes\admin\Meal() A single instance of this class. |
|
37 | - */ |
|
38 | - public static function get_instance() { |
|
39 | - // If the single instance hasn't been set, set it now. |
|
40 | - if ( null === self::$instance ) { |
|
41 | - self::$instance = new self(); |
|
42 | - } |
|
43 | - return self::$instance; |
|
44 | - } |
|
31 | + /** |
|
32 | + * Return an instance of this class. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * |
|
36 | + * @return object \lsx_health_plan\classes\admin\Meal() A single instance of this class. |
|
37 | + */ |
|
38 | + public static function get_instance() { |
|
39 | + // If the single instance hasn't been set, set it now. |
|
40 | + if ( null === self::$instance ) { |
|
41 | + self::$instance = new self(); |
|
42 | + } |
|
43 | + return self::$instance; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Registers the general settings. |
|
48 | - * |
|
49 | - * @param object $cmb new_cmb2_box(). |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function settings( $cmb ) { |
|
53 | - $cmb->add_field( |
|
54 | - array( |
|
55 | - 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
56 | - 'id' => 'meal_disabled', |
|
57 | - 'type' => 'checkbox', |
|
58 | - 'value' => 1, |
|
59 | - 'default' => 0, |
|
60 | - 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
61 | - ) |
|
62 | - ); |
|
46 | + /** |
|
47 | + * Registers the general settings. |
|
48 | + * |
|
49 | + * @param object $cmb new_cmb2_box(). |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function settings( $cmb ) { |
|
53 | + $cmb->add_field( |
|
54 | + array( |
|
55 | + 'name' => __( 'Disable Meals', 'lsx-health-plan' ), |
|
56 | + 'id' => 'meal_disabled', |
|
57 | + 'type' => 'checkbox', |
|
58 | + 'value' => 1, |
|
59 | + 'default' => 0, |
|
60 | + 'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | 63 | |
64 | - $cmb->add_field( |
|
65 | - array( |
|
66 | - 'id' => 'meal_archive_description', |
|
67 | - 'type' => 'wysiwyg', |
|
68 | - 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
69 | - 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
70 | - 'options' => array( |
|
71 | - 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
72 | - ), |
|
73 | - ) |
|
74 | - ); |
|
64 | + $cmb->add_field( |
|
65 | + array( |
|
66 | + 'id' => 'meal_archive_description', |
|
67 | + 'type' => 'wysiwyg', |
|
68 | + 'name' => __( 'Archive Description', 'lsx-health-plan' ), |
|
69 | + 'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
|
70 | + 'options' => array( |
|
71 | + 'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
72 | + ), |
|
73 | + ) |
|
74 | + ); |
|
75 | 75 | |
76 | - $cmb->add_field( |
|
77 | - array( |
|
78 | - 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
79 | - 'id' => 'meal_plan_intro', |
|
80 | - 'type' => 'textarea_small', |
|
81 | - 'value' => '', |
|
82 | - 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
83 | - ) |
|
84 | - ); |
|
76 | + $cmb->add_field( |
|
77 | + array( |
|
78 | + 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
79 | + 'id' => 'meal_plan_intro', |
|
80 | + 'type' => 'textarea_small', |
|
81 | + 'value' => '', |
|
82 | + 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
83 | + ) |
|
84 | + ); |
|
85 | 85 | |
86 | - $cmb->add_field( |
|
87 | - array( |
|
88 | - 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
89 | - 'name' => __( 'Meal Slug', 'lsx-health-plan' ), |
|
90 | - 'id' => 'endpoint_meal', |
|
91 | - 'type' => 'input', |
|
92 | - 'value' => '', |
|
93 | - 'default' => 'meal', |
|
94 | - ) |
|
95 | - ); |
|
96 | - $cmb->add_field( |
|
97 | - array( |
|
98 | - 'name' => __( 'Meals Archive Slug', 'lsx-health-plan' ), |
|
99 | - 'id' => 'endpoint_meal_archive', |
|
100 | - 'type' => 'input', |
|
101 | - 'value' => '', |
|
102 | - 'default' => 'meals', |
|
103 | - ) |
|
104 | - ); |
|
105 | - $cmb->add_field( |
|
106 | - array( |
|
107 | - 'name' => __( 'Single Meal Slug', 'lsx-health-plan' ), |
|
108 | - 'id' => 'meal_single_slug', |
|
109 | - 'type' => 'input', |
|
110 | - 'value' => '', |
|
111 | - 'default' => 'meal', |
|
112 | - ) |
|
113 | - ); |
|
86 | + $cmb->add_field( |
|
87 | + array( |
|
88 | + 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
89 | + 'name' => __( 'Meal Slug', 'lsx-health-plan' ), |
|
90 | + 'id' => 'endpoint_meal', |
|
91 | + 'type' => 'input', |
|
92 | + 'value' => '', |
|
93 | + 'default' => 'meal', |
|
94 | + ) |
|
95 | + ); |
|
96 | + $cmb->add_field( |
|
97 | + array( |
|
98 | + 'name' => __( 'Meals Archive Slug', 'lsx-health-plan' ), |
|
99 | + 'id' => 'endpoint_meal_archive', |
|
100 | + 'type' => 'input', |
|
101 | + 'value' => '', |
|
102 | + 'default' => 'meals', |
|
103 | + ) |
|
104 | + ); |
|
105 | + $cmb->add_field( |
|
106 | + array( |
|
107 | + 'name' => __( 'Single Meal Slug', 'lsx-health-plan' ), |
|
108 | + 'id' => 'meal_single_slug', |
|
109 | + 'type' => 'input', |
|
110 | + 'value' => '', |
|
111 | + 'default' => 'meal', |
|
112 | + ) |
|
113 | + ); |
|
114 | 114 | |
115 | - $cmb->add_field( |
|
116 | - array( |
|
117 | - 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
118 | - 'name' => __( 'Default Meal Plan', 'lsx-health-plan' ), |
|
119 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
120 | - 'limit' => 1, |
|
121 | - 'id' => 'connected_meals', |
|
122 | - 'type' => 'post_search_ajax', |
|
123 | - 'query_args' => array( |
|
124 | - 'post_type' => 'meal', |
|
125 | - 'post_status' => array( 'publish' ), |
|
126 | - 'posts_per_page' => -1, |
|
127 | - ), |
|
128 | - ) |
|
129 | - ); |
|
130 | - if ( function_exists( 'download_monitor' ) ) { |
|
131 | - $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
132 | - $plugin_name = 'Download Monitor'; |
|
133 | - $description = sprintf( |
|
134 | - /* translators: %s: The subscription info */ |
|
135 | - __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ), |
|
136 | - $page_url, |
|
137 | - $plugin_name |
|
138 | - ); |
|
139 | - $cmb->add_field( |
|
140 | - array( |
|
141 | - 'name' => __( 'Default Meal Plan PDF', 'lsx-health-plan' ), |
|
142 | - 'description' => $description, |
|
143 | - 'id' => 'download_meal', |
|
144 | - 'type' => 'post_search_ajax', |
|
145 | - 'limit' => 1, |
|
146 | - 'query_args' => array( |
|
147 | - 'post_type' => array( 'dlm_download' ), |
|
148 | - 'post_status' => array( 'publish' ), |
|
149 | - 'posts_per_page' => -1, |
|
150 | - ), |
|
151 | - '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' ), |
|
152 | - ) |
|
153 | - ); |
|
154 | - } |
|
155 | - } |
|
115 | + $cmb->add_field( |
|
116 | + array( |
|
117 | + 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
118 | + 'name' => __( 'Default Meal Plan', 'lsx-health-plan' ), |
|
119 | + 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
120 | + 'limit' => 1, |
|
121 | + 'id' => 'connected_meals', |
|
122 | + 'type' => 'post_search_ajax', |
|
123 | + 'query_args' => array( |
|
124 | + 'post_type' => 'meal', |
|
125 | + 'post_status' => array( 'publish' ), |
|
126 | + 'posts_per_page' => -1, |
|
127 | + ), |
|
128 | + ) |
|
129 | + ); |
|
130 | + if ( function_exists( 'download_monitor' ) ) { |
|
131 | + $page_url = 'https://wordpress.org/plugins/download-monitor/'; |
|
132 | + $plugin_name = 'Download Monitor'; |
|
133 | + $description = sprintf( |
|
134 | + /* translators: %s: The subscription info */ |
|
135 | + __( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ), |
|
136 | + $page_url, |
|
137 | + $plugin_name |
|
138 | + ); |
|
139 | + $cmb->add_field( |
|
140 | + array( |
|
141 | + 'name' => __( 'Default Meal Plan PDF', 'lsx-health-plan' ), |
|
142 | + 'description' => $description, |
|
143 | + 'id' => 'download_meal', |
|
144 | + 'type' => 'post_search_ajax', |
|
145 | + 'limit' => 1, |
|
146 | + 'query_args' => array( |
|
147 | + 'post_type' => array( 'dlm_download' ), |
|
148 | + 'post_status' => array( 'publish' ), |
|
149 | + 'posts_per_page' => -1, |
|
150 | + ), |
|
151 | + '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' ), |
|
152 | + ) |
|
153 | + ); |
|
154 | + } |
|
155 | + } |
|
156 | 156 | } |
157 | 157 | Meal::get_instance(); |
@@ -12,167 +12,167 @@ |
||
12 | 12 | */ |
13 | 13 | class Plan { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\My_Plans() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\My_Plans() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Constructor |
|
26 | - */ |
|
27 | - public function __construct() { |
|
28 | - add_action( 'lsx_hp_settings_page_my-plans_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | - } |
|
24 | + /** |
|
25 | + * Constructor |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | + add_action( 'lsx_hp_settings_page_my-plans_top', array( $this, 'settings' ), 1, 1 ); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * Return an instance of this class. |
|
33 | - * |
|
34 | - * @since 1.0.0 |
|
35 | - * |
|
36 | - * @return object \lsx_health_plan\classes\admin\My_Plans() A single instance of this class. |
|
37 | - */ |
|
38 | - public static function get_instance() { |
|
39 | - // If the single instance hasn't been set, set it now. |
|
40 | - if ( null === self::$instance ) { |
|
41 | - self::$instance = new self(); |
|
42 | - } |
|
43 | - return self::$instance; |
|
44 | - } |
|
31 | + /** |
|
32 | + * Return an instance of this class. |
|
33 | + * |
|
34 | + * @since 1.0.0 |
|
35 | + * |
|
36 | + * @return object \lsx_health_plan\classes\admin\My_Plans() A single instance of this class. |
|
37 | + */ |
|
38 | + public static function get_instance() { |
|
39 | + // If the single instance hasn't been set, set it now. |
|
40 | + if ( null === self::$instance ) { |
|
41 | + self::$instance = new self(); |
|
42 | + } |
|
43 | + return self::$instance; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Registers the general settings. |
|
48 | - * |
|
49 | - * @param object $cmb new_cmb2_box(). |
|
50 | - * @return void |
|
51 | - */ |
|
52 | - public function settings( $cmb ) { |
|
53 | - $cmb->add_field( |
|
54 | - array( |
|
55 | - 'name' => __( 'Plan Filters', 'lsx-health-plan' ), |
|
56 | - 'id' => 'plan_filters_disabled', |
|
57 | - 'type' => 'checkbox', |
|
58 | - 'value' => 1, |
|
59 | - 'default' => 0, |
|
60 | - 'description' => __( 'Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan' ), |
|
61 | - ) |
|
62 | - ); |
|
46 | + /** |
|
47 | + * Registers the general settings. |
|
48 | + * |
|
49 | + * @param object $cmb new_cmb2_box(). |
|
50 | + * @return void |
|
51 | + */ |
|
52 | + public function settings( $cmb ) { |
|
53 | + $cmb->add_field( |
|
54 | + array( |
|
55 | + 'name' => __( 'Plan Filters', 'lsx-health-plan' ), |
|
56 | + 'id' => 'plan_filters_disabled', |
|
57 | + 'type' => 'checkbox', |
|
58 | + 'value' => 1, |
|
59 | + 'default' => 0, |
|
60 | + 'description' => __( 'Toggle the display of the tab filters on the post type archive.', 'lsx-health-plan' ), |
|
61 | + ) |
|
62 | + ); |
|
63 | 63 | |
64 | - $cmb->add_field( |
|
65 | - array( |
|
66 | - 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
67 | - 'name' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
68 | - 'description' => __( 'This will be the slug url for redirecting users after login, use the login page slug.', 'lsx-health-plan' ), |
|
69 | - 'id' => 'my_plan_slug', |
|
70 | - 'type' => 'select', |
|
71 | - 'default' => 'my-plan', |
|
72 | - 'options' => $this->get_page_options(), |
|
73 | - ) |
|
74 | - ); |
|
64 | + $cmb->add_field( |
|
65 | + array( |
|
66 | + 'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
|
67 | + 'name' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
68 | + 'description' => __( 'This will be the slug url for redirecting users after login, use the login page slug.', 'lsx-health-plan' ), |
|
69 | + 'id' => 'my_plan_slug', |
|
70 | + 'type' => 'select', |
|
71 | + 'default' => 'my-plan', |
|
72 | + 'options' => $this->get_page_options(), |
|
73 | + ) |
|
74 | + ); |
|
75 | 75 | |
76 | - $cmb->add_field( |
|
77 | - array( |
|
78 | - 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
79 | - 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
80 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
81 | - 'limit' => 1, |
|
82 | - 'id' => 'connected_recipes', |
|
83 | - 'type' => 'post_search_ajax', |
|
84 | - ) |
|
85 | - ); |
|
76 | + $cmb->add_field( |
|
77 | + array( |
|
78 | + 'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
|
79 | + 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
80 | + 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
81 | + 'limit' => 1, |
|
82 | + 'id' => 'connected_recipes', |
|
83 | + 'type' => 'post_search_ajax', |
|
84 | + ) |
|
85 | + ); |
|
86 | 86 | |
87 | - $cmb->add_field( |
|
88 | - array( |
|
89 | - 'name' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
90 | - 'id' => 'plan_single_slug', |
|
91 | - 'type' => 'input', |
|
92 | - 'value' => '', |
|
93 | - 'default' => 'plan', |
|
94 | - ) |
|
95 | - ); |
|
96 | - $cmb->add_field( |
|
97 | - array( |
|
98 | - 'name' => __( 'Plans Archive Slug', 'lsx-health-plan' ), |
|
99 | - 'id' => 'endpoint_plan_archive', |
|
100 | - 'type' => 'input', |
|
101 | - 'value' => '', |
|
102 | - 'default' => 'plans', |
|
103 | - ) |
|
104 | - ); |
|
87 | + $cmb->add_field( |
|
88 | + array( |
|
89 | + 'name' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
90 | + 'id' => 'plan_single_slug', |
|
91 | + 'type' => 'input', |
|
92 | + 'value' => '', |
|
93 | + 'default' => 'plan', |
|
94 | + ) |
|
95 | + ); |
|
96 | + $cmb->add_field( |
|
97 | + array( |
|
98 | + 'name' => __( 'Plans Archive Slug', 'lsx-health-plan' ), |
|
99 | + 'id' => 'endpoint_plan_archive', |
|
100 | + 'type' => 'input', |
|
101 | + 'value' => '', |
|
102 | + 'default' => 'plans', |
|
103 | + ) |
|
104 | + ); |
|
105 | 105 | |
106 | - $cmb->add_field( |
|
107 | - array( |
|
108 | - 'before_row' => '<h4><b><u>My Stats Options</u></b></h4>', |
|
109 | - 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
110 | - 'desc' => 'Disable All Stats', |
|
111 | - 'id' => 'disable_all_stats', |
|
112 | - 'type' => 'checkbox', |
|
113 | - 'value' => 1, |
|
114 | - 'default' => 0, |
|
115 | - ) |
|
116 | - ); |
|
117 | - $cmb->add_field( |
|
118 | - array( |
|
119 | - 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
120 | - 'id' => 'disable_weight_checkbox', |
|
121 | - 'type' => 'checkbox', |
|
122 | - 'value' => 1, |
|
123 | - 'default' => 0, |
|
124 | - ) |
|
125 | - ); |
|
126 | - $cmb->add_field( |
|
127 | - array( |
|
128 | - 'name' => __( 'Disable Height', 'lsx-health-plan' ), |
|
129 | - 'id' => 'disable_height_checkbox', |
|
130 | - 'type' => 'checkbox', |
|
131 | - 'value' => 1, |
|
132 | - 'default' => 0, |
|
133 | - ) |
|
134 | - ); |
|
135 | - $cmb->add_field( |
|
136 | - array( |
|
137 | - 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
138 | - 'id' => 'disable_waist_checkbox', |
|
139 | - 'type' => 'checkbox', |
|
140 | - 'value' => 1, |
|
141 | - 'default' => 0, |
|
142 | - ) |
|
143 | - ); |
|
144 | - $cmb->add_field( |
|
145 | - array( |
|
146 | - 'name' => __( 'Disable BMI', 'lsx-health-plan' ), |
|
147 | - 'id' => 'disable_bmi_checkbox', |
|
148 | - 'type' => 'checkbox', |
|
149 | - 'value' => 1, |
|
150 | - 'default' => 0, |
|
151 | - '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' ), |
|
152 | - ) |
|
153 | - ); |
|
154 | - } |
|
106 | + $cmb->add_field( |
|
107 | + array( |
|
108 | + 'before_row' => '<h4><b><u>My Stats Options</u></b></h4>', |
|
109 | + 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
110 | + 'desc' => 'Disable All Stats', |
|
111 | + 'id' => 'disable_all_stats', |
|
112 | + 'type' => 'checkbox', |
|
113 | + 'value' => 1, |
|
114 | + 'default' => 0, |
|
115 | + ) |
|
116 | + ); |
|
117 | + $cmb->add_field( |
|
118 | + array( |
|
119 | + 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
120 | + 'id' => 'disable_weight_checkbox', |
|
121 | + 'type' => 'checkbox', |
|
122 | + 'value' => 1, |
|
123 | + 'default' => 0, |
|
124 | + ) |
|
125 | + ); |
|
126 | + $cmb->add_field( |
|
127 | + array( |
|
128 | + 'name' => __( 'Disable Height', 'lsx-health-plan' ), |
|
129 | + 'id' => 'disable_height_checkbox', |
|
130 | + 'type' => 'checkbox', |
|
131 | + 'value' => 1, |
|
132 | + 'default' => 0, |
|
133 | + ) |
|
134 | + ); |
|
135 | + $cmb->add_field( |
|
136 | + array( |
|
137 | + 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
138 | + 'id' => 'disable_waist_checkbox', |
|
139 | + 'type' => 'checkbox', |
|
140 | + 'value' => 1, |
|
141 | + 'default' => 0, |
|
142 | + ) |
|
143 | + ); |
|
144 | + $cmb->add_field( |
|
145 | + array( |
|
146 | + 'name' => __( 'Disable BMI', 'lsx-health-plan' ), |
|
147 | + 'id' => 'disable_bmi_checkbox', |
|
148 | + 'type' => 'checkbox', |
|
149 | + 'value' => 1, |
|
150 | + 'default' => 0, |
|
151 | + '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' ), |
|
152 | + ) |
|
153 | + ); |
|
154 | + } |
|
155 | 155 | |
156 | - public function get_page_options() { |
|
157 | - $query_args = array( |
|
158 | - 'post_type' => 'page', |
|
159 | - 'post_status' => array( 'publish' ), |
|
160 | - 'posts_per_page' => -1, |
|
161 | - 'orderby' => 'title', |
|
162 | - 'fields' => array( 'ids' ), |
|
163 | - ); |
|
164 | - $options = array( |
|
165 | - '' => __( 'Select a page', 'lsx-health-plan' ), |
|
166 | - ); |
|
167 | - $page_query = new \WP_Query( $query_args ); |
|
168 | - if ( $page_query->have_posts() ) { |
|
169 | - foreach ( $page_query->posts as $pid ) { |
|
170 | - $title = get_the_title( $pid ); |
|
171 | - $key = sanitize_title( $title ); |
|
172 | - $options[ $key ] = $title; |
|
173 | - } |
|
174 | - } |
|
175 | - return $options; |
|
176 | - } |
|
156 | + public function get_page_options() { |
|
157 | + $query_args = array( |
|
158 | + 'post_type' => 'page', |
|
159 | + 'post_status' => array( 'publish' ), |
|
160 | + 'posts_per_page' => -1, |
|
161 | + 'orderby' => 'title', |
|
162 | + 'fields' => array( 'ids' ), |
|
163 | + ); |
|
164 | + $options = array( |
|
165 | + '' => __( 'Select a page', 'lsx-health-plan' ), |
|
166 | + ); |
|
167 | + $page_query = new \WP_Query( $query_args ); |
|
168 | + if ( $page_query->have_posts() ) { |
|
169 | + foreach ( $page_query->posts as $pid ) { |
|
170 | + $title = get_the_title( $pid ); |
|
171 | + $key = sanitize_title( $title ); |
|
172 | + $options[ $key ] = $title; |
|
173 | + } |
|
174 | + } |
|
175 | + return $options; |
|
176 | + } |
|
177 | 177 | } |
178 | 178 | Plan::get_instance(); |