@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * Contructor |
31 | 31 | */ |
32 | 32 | public function __construct() { |
33 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
34 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
35 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
36 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
37 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
33 | + add_action('init', array($this, 'register_post_type')); |
|
34 | + add_action('admin_menu', array($this, 'register_menus')); |
|
35 | + add_filter('lsx_health_plan_single_template', array($this, 'enable_post_type'), 10, 1); |
|
36 | + add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1); |
|
37 | + add_action('cmb2_admin_init', array($this, 'details_metaboxes')); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | */ |
47 | 47 | public static function get_instance() { |
48 | 48 | // If the single instance hasn't been set, set it now. |
49 | - if ( null === self::$instance ) { |
|
49 | + if (null === self::$instance) { |
|
50 | 50 | self::$instance = new self(); |
51 | 51 | } |
52 | 52 | return self::$instance; |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public function register_post_type() { |
58 | 58 | $labels = array( |
59 | - 'name' => esc_html__( 'Video', 'lsx-health-plan' ), |
|
60 | - 'singular_name' => esc_html__( 'Videos', 'lsx-health-plan' ), |
|
61 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
62 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
63 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
64 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
65 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
66 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
67 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
68 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
69 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
59 | + 'name' => esc_html__('Video', 'lsx-health-plan'), |
|
60 | + 'singular_name' => esc_html__('Videos', 'lsx-health-plan'), |
|
61 | + 'add_new' => esc_html_x('Add New', 'post type general name', 'lsx-health-plan'), |
|
62 | + 'add_new_item' => esc_html__('Add New', 'lsx-health-plan'), |
|
63 | + 'edit_item' => esc_html__('Edit', 'lsx-health-plan'), |
|
64 | + 'new_item' => esc_html__('New', 'lsx-health-plan'), |
|
65 | + 'all_items' => esc_html__('All', 'lsx-health-plan'), |
|
66 | + 'view_item' => esc_html__('View', 'lsx-health-plan'), |
|
67 | + 'search_items' => esc_html__('Search', 'lsx-health-plan'), |
|
68 | + 'not_found' => esc_html__('None found', 'lsx-health-plan'), |
|
69 | + 'not_found_in_trash' => esc_html__('None found in Trash', 'lsx-health-plan'), |
|
70 | 70 | 'parent_item_colon' => '', |
71 | - 'menu_name' => esc_html__( 'Videos', 'lsx-health-plan' ), |
|
71 | + 'menu_name' => esc_html__('Videos', 'lsx-health-plan'), |
|
72 | 72 | ); |
73 | - $args = array( |
|
73 | + $args = array( |
|
74 | 74 | 'labels' => $labels, |
75 | 75 | 'public' => true, |
76 | 76 | 'publicly_queryable' => true, |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | 'editor', |
90 | 90 | ), |
91 | 91 | ); |
92 | - register_post_type( 'video', $args ); |
|
92 | + register_post_type('video', $args); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @return void |
99 | 99 | */ |
100 | 100 | public function register_menus() { |
101 | - add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Videos', 'lsx-health-plan' ), esc_html__( 'Videos', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=video' ); |
|
101 | + add_submenu_page('edit.php?post_type=workout', esc_html__('Videos', 'lsx-health-plan'), esc_html__('Videos', 'lsx-health-plan'), 'edit_posts', 'edit.php?post_type=video'); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * @param array $post_types |
108 | 108 | * @return array |
109 | 109 | */ |
110 | - public function enable_post_type( $post_types = array() ) { |
|
110 | + public function enable_post_type($post_types = array()) { |
|
111 | 111 | $post_types[] = $this->slug; |
112 | 112 | return $post_types; |
113 | 113 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param array $connections |
119 | 119 | * @return void |
120 | 120 | */ |
121 | - public function enable_connections( $connections = array() ) { |
|
121 | + public function enable_connections($connections = array()) { |
|
122 | 122 | $connections['video']['connected_plans'] = 'connected_videos'; |
123 | 123 | $connections['plan']['connected_videos'] = 'connected_plans'; |
124 | 124 | $connections['video']['connected_workouts'] = 'connected_videos'; |
@@ -130,35 +130,35 @@ discard block |
||
130 | 130 | * Define the metabox and field configurations. |
131 | 131 | */ |
132 | 132 | public function details_metaboxes() { |
133 | - $cmb = new_cmb2_box( array( |
|
133 | + $cmb = new_cmb2_box(array( |
|
134 | 134 | 'id' => $this->slug . '_details_metabox', |
135 | - 'title' => __( 'Video Details', 'lsx-health-plan' ), |
|
136 | - 'object_types' => array( $this->slug ), // Post type |
|
135 | + 'title' => __('Video Details', 'lsx-health-plan'), |
|
136 | + 'object_types' => array($this->slug), // Post type |
|
137 | 137 | 'context' => 'normal', |
138 | 138 | 'priority' => 'high', |
139 | 139 | 'show_names' => true, |
140 | - ) ); |
|
141 | - $cmb->add_field( array( |
|
142 | - 'name' => __( 'Featured Video', 'lsx-health-plan' ), |
|
143 | - 'desc' => __( 'Enable the checkbox to feature this video, featured videos display in any page that has the video shortcode: [lsx_health_plan_featured_videos_block]', 'lsx-health-plan' ), |
|
140 | + )); |
|
141 | + $cmb->add_field(array( |
|
142 | + 'name' => __('Featured Video', 'lsx-health-plan'), |
|
143 | + 'desc' => __('Enable the checkbox to feature this video, featured videos display in any page that has the video shortcode: [lsx_health_plan_featured_videos_block]', 'lsx-health-plan'), |
|
144 | 144 | 'id' => $this->slug . '_featured_video', |
145 | 145 | 'type' => 'checkbox', |
146 | 146 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
147 | - ) ); |
|
148 | - $cmb->add_field( array( |
|
149 | - 'name' => __( 'Youtube Source', 'lsx-health-plan' ), |
|
150 | - 'desc' => __( 'Drop in the url for your video from YouTube in this field, i.e: "https://www.youtube.com/watch?v=9xwazD5SyVg"', 'lsx-health-plan' ), |
|
147 | + )); |
|
148 | + $cmb->add_field(array( |
|
149 | + 'name' => __('Youtube Source', 'lsx-health-plan'), |
|
150 | + 'desc' => __('Drop in the url for your video from YouTube in this field, i.e: "https://www.youtube.com/watch?v=9xwazD5SyVg"', 'lsx-health-plan'), |
|
151 | 151 | 'id' => $this->slug . '_youtube_source', |
152 | 152 | 'type' => 'oembed', |
153 | 153 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
154 | - ) ); |
|
155 | - $cmb->add_field( array( |
|
156 | - 'name' => __( 'Giphy Source', 'lsx-health-plan' ), |
|
157 | - 'desc' => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan' ), |
|
154 | + )); |
|
155 | + $cmb->add_field(array( |
|
156 | + 'name' => __('Giphy Source', 'lsx-health-plan'), |
|
157 | + 'desc' => __('Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan'), |
|
158 | 158 | 'id' => $this->slug . '_giphy_source', |
159 | 159 | 'type' => 'textarea_code', |
160 | 160 | 'show_on_cb' => 'cmb2_hide_if_no_cats', |
161 | - ) ); |
|
161 | + )); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // /** |
@@ -8,187 +8,187 @@ |
||
8 | 8 | */ |
9 | 9 | class Video { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Video() |
|
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\Video() |
|
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 = 'video'; |
|
20 | + /** |
|
21 | + * Holds post_type slug used as an index |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $slug = 'video'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Contructor |
|
31 | - */ |
|
32 | - public function __construct() { |
|
33 | - add_action( 'init', array( $this, 'register_post_type' ) ); |
|
34 | - add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
35 | - add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
36 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
37 | - add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
38 | - } |
|
29 | + /** |
|
30 | + * Contructor |
|
31 | + */ |
|
32 | + public function __construct() { |
|
33 | + add_action( 'init', array( $this, 'register_post_type' ) ); |
|
34 | + add_action( 'admin_menu', array( $this, 'register_menus' ) ); |
|
35 | + add_filter( 'lsx_health_plan_single_template', array( $this, 'enable_post_type' ), 10, 1 ); |
|
36 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
37 | + add_action( 'cmb2_admin_init', array( $this, 'details_metaboxes' ) ); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Return an instance of this class. |
|
42 | - * |
|
43 | - * @since 1.0.0 |
|
44 | - * |
|
45 | - * @return object \lsx_health_plan\classes\Video() A single instance of this class. |
|
46 | - */ |
|
47 | - public static function get_instance() { |
|
48 | - // If the single instance hasn't been set, set it now. |
|
49 | - if ( null === self::$instance ) { |
|
50 | - self::$instance = new self(); |
|
51 | - } |
|
52 | - return self::$instance; |
|
53 | - } |
|
54 | - /** |
|
55 | - * Register the post type. |
|
56 | - */ |
|
57 | - public function register_post_type() { |
|
58 | - $labels = array( |
|
59 | - 'name' => esc_html__( 'Video', 'lsx-health-plan' ), |
|
60 | - 'singular_name' => esc_html__( 'Videos', 'lsx-health-plan' ), |
|
61 | - 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
62 | - 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
63 | - 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
64 | - 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
65 | - 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
66 | - 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
67 | - 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
68 | - 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
69 | - 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
70 | - 'parent_item_colon' => '', |
|
71 | - 'menu_name' => esc_html__( 'Videos', 'lsx-health-plan' ), |
|
72 | - ); |
|
73 | - $args = array( |
|
74 | - 'labels' => $labels, |
|
75 | - 'public' => true, |
|
76 | - 'publicly_queryable' => true, |
|
77 | - 'show_ui' => true, |
|
78 | - 'show_in_menu' => false, |
|
79 | - 'show_in_rest' => true, |
|
80 | - 'menu_icon' => 'dashicons-format-video', |
|
81 | - 'query_var' => true, |
|
82 | - 'rewrite' => false, |
|
83 | - 'capability_type' => 'post', |
|
84 | - 'has_archive' => false, |
|
85 | - 'hierarchical' => false, |
|
86 | - 'menu_position' => null, |
|
87 | - 'supports' => array( |
|
88 | - 'title', |
|
89 | - 'editor', |
|
90 | - ), |
|
91 | - ); |
|
92 | - register_post_type( 'video', $args ); |
|
93 | - } |
|
40 | + /** |
|
41 | + * Return an instance of this class. |
|
42 | + * |
|
43 | + * @since 1.0.0 |
|
44 | + * |
|
45 | + * @return object \lsx_health_plan\classes\Video() A single instance of this class. |
|
46 | + */ |
|
47 | + public static function get_instance() { |
|
48 | + // If the single instance hasn't been set, set it now. |
|
49 | + if ( null === self::$instance ) { |
|
50 | + self::$instance = new self(); |
|
51 | + } |
|
52 | + return self::$instance; |
|
53 | + } |
|
54 | + /** |
|
55 | + * Register the post type. |
|
56 | + */ |
|
57 | + public function register_post_type() { |
|
58 | + $labels = array( |
|
59 | + 'name' => esc_html__( 'Video', 'lsx-health-plan' ), |
|
60 | + 'singular_name' => esc_html__( 'Videos', 'lsx-health-plan' ), |
|
61 | + 'add_new' => esc_html_x( 'Add New', 'post type general name', 'lsx-health-plan' ), |
|
62 | + 'add_new_item' => esc_html__( 'Add New', 'lsx-health-plan' ), |
|
63 | + 'edit_item' => esc_html__( 'Edit', 'lsx-health-plan' ), |
|
64 | + 'new_item' => esc_html__( 'New', 'lsx-health-plan' ), |
|
65 | + 'all_items' => esc_html__( 'All', 'lsx-health-plan' ), |
|
66 | + 'view_item' => esc_html__( 'View', 'lsx-health-plan' ), |
|
67 | + 'search_items' => esc_html__( 'Search', 'lsx-health-plan' ), |
|
68 | + 'not_found' => esc_html__( 'None found', 'lsx-health-plan' ), |
|
69 | + 'not_found_in_trash' => esc_html__( 'None found in Trash', 'lsx-health-plan' ), |
|
70 | + 'parent_item_colon' => '', |
|
71 | + 'menu_name' => esc_html__( 'Videos', 'lsx-health-plan' ), |
|
72 | + ); |
|
73 | + $args = array( |
|
74 | + 'labels' => $labels, |
|
75 | + 'public' => true, |
|
76 | + 'publicly_queryable' => true, |
|
77 | + 'show_ui' => true, |
|
78 | + 'show_in_menu' => false, |
|
79 | + 'show_in_rest' => true, |
|
80 | + 'menu_icon' => 'dashicons-format-video', |
|
81 | + 'query_var' => true, |
|
82 | + 'rewrite' => false, |
|
83 | + 'capability_type' => 'post', |
|
84 | + 'has_archive' => false, |
|
85 | + 'hierarchical' => false, |
|
86 | + 'menu_position' => null, |
|
87 | + 'supports' => array( |
|
88 | + 'title', |
|
89 | + 'editor', |
|
90 | + ), |
|
91 | + ); |
|
92 | + register_post_type( 'video', $args ); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Registers the Recipes under the Meals Post type menu. |
|
97 | - * |
|
98 | - * @return void |
|
99 | - */ |
|
100 | - public function register_menus() { |
|
101 | - add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Videos', 'lsx-health-plan' ), esc_html__( 'Videos', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=video' ); |
|
102 | - } |
|
95 | + /** |
|
96 | + * Registers the Recipes under the Meals Post type menu. |
|
97 | + * |
|
98 | + * @return void |
|
99 | + */ |
|
100 | + public function register_menus() { |
|
101 | + add_submenu_page( 'edit.php?post_type=workout', esc_html__( 'Videos', 'lsx-health-plan' ), esc_html__( 'Videos', 'lsx-health-plan' ), 'edit_posts', 'edit.php?post_type=video' ); |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Adds the post type to the different arrays. |
|
106 | - * |
|
107 | - * @param array $post_types |
|
108 | - * @return array |
|
109 | - */ |
|
110 | - public function enable_post_type( $post_types = array() ) { |
|
111 | - $post_types[] = $this->slug; |
|
112 | - return $post_types; |
|
113 | - } |
|
104 | + /** |
|
105 | + * Adds the post type to the different arrays. |
|
106 | + * |
|
107 | + * @param array $post_types |
|
108 | + * @return array |
|
109 | + */ |
|
110 | + public function enable_post_type( $post_types = array() ) { |
|
111 | + $post_types[] = $this->slug; |
|
112 | + return $post_types; |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Enables the Bi Directional relationships |
|
117 | - * |
|
118 | - * @param array $connections |
|
119 | - * @return void |
|
120 | - */ |
|
121 | - public function enable_connections( $connections = array() ) { |
|
122 | - $connections['video']['connected_plans'] = 'connected_videos'; |
|
123 | - $connections['plan']['connected_videos'] = 'connected_plans'; |
|
124 | - $connections['video']['connected_workouts'] = 'connected_videos'; |
|
125 | - $connections['plan']['connected_videos'] = 'connected_workouts'; |
|
126 | - return $connections; |
|
127 | - } |
|
115 | + /** |
|
116 | + * Enables the Bi Directional relationships |
|
117 | + * |
|
118 | + * @param array $connections |
|
119 | + * @return void |
|
120 | + */ |
|
121 | + public function enable_connections( $connections = array() ) { |
|
122 | + $connections['video']['connected_plans'] = 'connected_videos'; |
|
123 | + $connections['plan']['connected_videos'] = 'connected_plans'; |
|
124 | + $connections['video']['connected_workouts'] = 'connected_videos'; |
|
125 | + $connections['plan']['connected_videos'] = 'connected_workouts'; |
|
126 | + return $connections; |
|
127 | + } |
|
128 | 128 | |
129 | - /** |
|
130 | - * Define the metabox and field configurations. |
|
131 | - */ |
|
132 | - public function details_metaboxes() { |
|
133 | - $cmb = new_cmb2_box( array( |
|
134 | - 'id' => $this->slug . '_details_metabox', |
|
135 | - 'title' => __( 'Video Details', 'lsx-health-plan' ), |
|
136 | - 'object_types' => array( $this->slug ), // Post type |
|
137 | - 'context' => 'normal', |
|
138 | - 'priority' => 'high', |
|
139 | - 'show_names' => true, |
|
140 | - ) ); |
|
141 | - $cmb->add_field( array( |
|
142 | - 'name' => __( 'Featured Video', 'lsx-health-plan' ), |
|
143 | - 'desc' => __( 'Enable the checkbox to feature this video, featured videos display in any page that has the video shortcode: [lsx_health_plan_featured_videos_block]', 'lsx-health-plan' ), |
|
144 | - 'id' => $this->slug . '_featured_video', |
|
145 | - 'type' => 'checkbox', |
|
146 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
147 | - ) ); |
|
148 | - $cmb->add_field( array( |
|
149 | - 'name' => __( 'Youtube Source', 'lsx-health-plan' ), |
|
150 | - 'desc' => __( 'Drop in the url for your video from YouTube in this field, i.e: "https://www.youtube.com/watch?v=9xwazD5SyVg"', 'lsx-health-plan' ), |
|
151 | - 'id' => $this->slug . '_youtube_source', |
|
152 | - 'type' => 'oembed', |
|
153 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
154 | - ) ); |
|
155 | - $cmb->add_field( array( |
|
156 | - 'name' => __( 'Giphy Source', 'lsx-health-plan' ), |
|
157 | - 'desc' => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan' ), |
|
158 | - 'id' => $this->slug . '_giphy_source', |
|
159 | - 'type' => 'textarea_code', |
|
160 | - 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
161 | - ) ); |
|
162 | - } |
|
129 | + /** |
|
130 | + * Define the metabox and field configurations. |
|
131 | + */ |
|
132 | + public function details_metaboxes() { |
|
133 | + $cmb = new_cmb2_box( array( |
|
134 | + 'id' => $this->slug . '_details_metabox', |
|
135 | + 'title' => __( 'Video Details', 'lsx-health-plan' ), |
|
136 | + 'object_types' => array( $this->slug ), // Post type |
|
137 | + 'context' => 'normal', |
|
138 | + 'priority' => 'high', |
|
139 | + 'show_names' => true, |
|
140 | + ) ); |
|
141 | + $cmb->add_field( array( |
|
142 | + 'name' => __( 'Featured Video', 'lsx-health-plan' ), |
|
143 | + 'desc' => __( 'Enable the checkbox to feature this video, featured videos display in any page that has the video shortcode: [lsx_health_plan_featured_videos_block]', 'lsx-health-plan' ), |
|
144 | + 'id' => $this->slug . '_featured_video', |
|
145 | + 'type' => 'checkbox', |
|
146 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
147 | + ) ); |
|
148 | + $cmb->add_field( array( |
|
149 | + 'name' => __( 'Youtube Source', 'lsx-health-plan' ), |
|
150 | + 'desc' => __( 'Drop in the url for your video from YouTube in this field, i.e: "https://www.youtube.com/watch?v=9xwazD5SyVg"', 'lsx-health-plan' ), |
|
151 | + 'id' => $this->slug . '_youtube_source', |
|
152 | + 'type' => 'oembed', |
|
153 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
154 | + ) ); |
|
155 | + $cmb->add_field( array( |
|
156 | + 'name' => __( 'Giphy Source', 'lsx-health-plan' ), |
|
157 | + 'desc' => __( 'Drop in the iFrame embed code from Giphy in this field, i.e: <iframe src="https://giphy.com/embed/3o7527Rn1HxXWqgxuo" width="480" height="270" frameborder="0" class="giphy-embed" allowfullscreen></iframe>', 'lsx-health-plan' ), |
|
158 | + 'id' => $this->slug . '_giphy_source', |
|
159 | + 'type' => 'textarea_code', |
|
160 | + 'show_on_cb' => 'cmb2_hide_if_no_cats', |
|
161 | + ) ); |
|
162 | + } |
|
163 | 163 | |
164 | - // /** |
|
165 | - // * Registers the workout connections on the workout post type. |
|
166 | - // * |
|
167 | - // * @return void |
|
168 | - // */ |
|
169 | - // public function videos_connections() { |
|
170 | - // $cmb = new_cmb2_box( array( |
|
171 | - // 'id' => $this->slug . '_videos_connections_metabox', |
|
172 | - // 'title' => __( 'Videos', 'lsx-health-plan' ), |
|
173 | - // 'desc' => __( 'Start typing to search for your workouts', 'lsx-health-plan' ), |
|
174 | - // 'object_types' => array( 'workout' ), // Post type |
|
175 | - // 'context' => 'normal', |
|
176 | - // 'priority' => 'high', |
|
177 | - // 'show_names' => false, |
|
178 | - // ) ); |
|
179 | - // $cmb->add_field( array( |
|
180 | - // 'name' => __( 'Videos', 'lsx-health-plan' ), |
|
181 | - // 'id' => 'connected_videos', |
|
182 | - // 'type' => 'post_search_ajax', |
|
183 | - // // Optional : |
|
184 | - // 'limit' => 15, // Limit selection to X items only (default 1) |
|
185 | - // 'sortable' => true, // Allow selected items to be sortable (default false) |
|
186 | - // 'query_args' => array( |
|
187 | - // 'post_type' => array( 'video' ), |
|
188 | - // 'post_status' => array( 'publish' ), |
|
189 | - // 'posts_per_page' => -1, |
|
190 | - // ), |
|
191 | - // ) ); |
|
192 | - // } |
|
164 | + // /** |
|
165 | + // * Registers the workout connections on the workout post type. |
|
166 | + // * |
|
167 | + // * @return void |
|
168 | + // */ |
|
169 | + // public function videos_connections() { |
|
170 | + // $cmb = new_cmb2_box( array( |
|
171 | + // 'id' => $this->slug . '_videos_connections_metabox', |
|
172 | + // 'title' => __( 'Videos', 'lsx-health-plan' ), |
|
173 | + // 'desc' => __( 'Start typing to search for your workouts', 'lsx-health-plan' ), |
|
174 | + // 'object_types' => array( 'workout' ), // Post type |
|
175 | + // 'context' => 'normal', |
|
176 | + // 'priority' => 'high', |
|
177 | + // 'show_names' => false, |
|
178 | + // ) ); |
|
179 | + // $cmb->add_field( array( |
|
180 | + // 'name' => __( 'Videos', 'lsx-health-plan' ), |
|
181 | + // 'id' => 'connected_videos', |
|
182 | + // 'type' => 'post_search_ajax', |
|
183 | + // // Optional : |
|
184 | + // 'limit' => 15, // Limit selection to X items only (default 1) |
|
185 | + // 'sortable' => true, // Allow selected items to be sortable (default false) |
|
186 | + // 'query_args' => array( |
|
187 | + // 'post_type' => array( 'video' ), |
|
188 | + // 'post_status' => array( 'publish' ), |
|
189 | + // 'posts_per_page' => -1, |
|
190 | + // ), |
|
191 | + // ) ); |
|
192 | + // } |
|
193 | 193 | |
194 | 194 | } |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | * Contructor |
31 | 31 | */ |
32 | 32 | public function __construct() { |
33 | - add_action( 'cmb2_admin_init', array( $this, 'downloads_post_type_metaboxes' ), 5 ); |
|
34 | - add_action( 'cmb2_admin_init', array( $this, 'download_connections' ), 5 ); |
|
35 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
33 | + add_action('cmb2_admin_init', array($this, 'downloads_post_type_metaboxes'), 5); |
|
34 | + add_action('cmb2_admin_init', array($this, 'download_connections'), 5); |
|
35 | + add_filter('lsx_health_plan_connections', array($this, 'enable_connections'), 10, 1); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public static function get_instance() { |
46 | 46 | // If the single instance hasn't been set, set it now. |
47 | - if ( null === self::$instance ) { |
|
47 | + if (null === self::$instance) { |
|
48 | 48 | self::$instance = new self(); |
49 | 49 | } |
50 | 50 | return self::$instance; |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @param array $connections |
57 | 57 | * @return void |
58 | 58 | */ |
59 | - public function enable_connections( $connections = array() ) { |
|
59 | + public function enable_connections($connections = array()) { |
|
60 | 60 | $connections['dlm_download']['connected_pages'] = 'connected_downloads'; |
61 | 61 | $connections['dlm_download']['connected_workouts'] = 'connected_downloads'; |
62 | 62 | $connections['dlm_download']['connected_meals'] = 'connected_downloads'; |
@@ -74,66 +74,66 @@ discard block |
||
74 | 74 | * Define the metabox and field configurations. |
75 | 75 | */ |
76 | 76 | public function downloads_post_type_metaboxes() { |
77 | - $cmb = new_cmb2_box( array( |
|
77 | + $cmb = new_cmb2_box(array( |
|
78 | 78 | 'id' => $this->slug . '_connections_metabox', |
79 | - 'title' => __( 'Connections', 'lsx-health-plan' ), |
|
80 | - 'object_types' => array( 'dlm_download' ), // Post type |
|
79 | + 'title' => __('Connections', 'lsx-health-plan'), |
|
80 | + 'object_types' => array('dlm_download'), // Post type |
|
81 | 81 | 'context' => 'normal', |
82 | 82 | 'priority' => 'high', |
83 | 83 | 'show_names' => true, |
84 | - ) ); |
|
85 | - $cmb->add_field( array( |
|
86 | - 'name' => __( 'Pages', 'lsx-health-plan' ), |
|
84 | + )); |
|
85 | + $cmb->add_field(array( |
|
86 | + 'name' => __('Pages', 'lsx-health-plan'), |
|
87 | 87 | 'id' => 'connected_pages', |
88 | 88 | 'type' => 'post_search_ajax', |
89 | 89 | // Optional : |
90 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
90 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
91 | 91 | 'sortable' => true, // Allow selected items to be sortable (default false) |
92 | 92 | 'query_args' => array( |
93 | - 'post_type' => array( 'page' ), |
|
94 | - 'post_status' => array( 'publish' ), |
|
93 | + 'post_type' => array('page'), |
|
94 | + 'post_status' => array('publish'), |
|
95 | 95 | 'posts_per_page' => -1, |
96 | 96 | ), |
97 | - ) ); |
|
98 | - $cmb->add_field( array( |
|
99 | - 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
97 | + )); |
|
98 | + $cmb->add_field(array( |
|
99 | + 'name' => __('Workouts', 'lsx-health-plan'), |
|
100 | 100 | 'id' => 'connected_workouts', |
101 | 101 | 'type' => 'post_search_ajax', |
102 | 102 | // Optional : |
103 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
103 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
104 | 104 | 'sortable' => true, // Allow selected items to be sortable (default false) |
105 | 105 | 'query_args' => array( |
106 | - 'post_type' => array( 'workout' ), |
|
107 | - 'post_status' => array( 'publish' ), |
|
106 | + 'post_type' => array('workout'), |
|
107 | + 'post_status' => array('publish'), |
|
108 | 108 | 'posts_per_page' => -1, |
109 | 109 | ), |
110 | - ) ); |
|
111 | - $cmb->add_field( array( |
|
112 | - 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
110 | + )); |
|
111 | + $cmb->add_field(array( |
|
112 | + 'name' => __('Meals', 'lsx-health-plan'), |
|
113 | 113 | 'id' => 'connected_meals', |
114 | 114 | 'type' => 'post_search_ajax', |
115 | 115 | // Optional : |
116 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
117 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
116 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
117 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
118 | 118 | 'query_args' => array( |
119 | - 'post_type' => array( 'meal' ), |
|
120 | - 'post_status' => array( 'publish' ), |
|
119 | + 'post_type' => array('meal'), |
|
120 | + 'post_status' => array('publish'), |
|
121 | 121 | 'posts_per_page' => -1, |
122 | 122 | ), |
123 | - ) ); |
|
124 | - $cmb->add_field( array( |
|
125 | - 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
123 | + )); |
|
124 | + $cmb->add_field(array( |
|
125 | + 'name' => __('Recipe', 'lsx-health-plan'), |
|
126 | 126 | 'id' => 'connected_recipes', |
127 | 127 | 'type' => 'post_search_ajax', |
128 | 128 | // Optional : |
129 | 129 | 'limit' => 10, // Limit selection to X items only (default 1) |
130 | 130 | 'sortable' => true, // Allow selected items to be sortable (default false) |
131 | 131 | 'query_args' => array( |
132 | - 'post_type' => array( 'recipe' ), |
|
133 | - 'post_status' => array( 'publish' ), |
|
132 | + 'post_type' => array('recipe'), |
|
133 | + 'post_status' => array('publish'), |
|
134 | 134 | 'posts_per_page' => -1, |
135 | 135 | ), |
136 | - ) ); |
|
136 | + )); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -142,27 +142,27 @@ discard block |
||
142 | 142 | * @return void |
143 | 143 | */ |
144 | 144 | public function download_connections() { |
145 | - $cmb = new_cmb2_box( array( |
|
145 | + $cmb = new_cmb2_box(array( |
|
146 | 146 | 'id' => $this->slug . '_metabox', |
147 | - 'title' => __( 'Downloads', 'lsx-health-plan' ), |
|
148 | - 'object_types' => array( 'workout', 'meal', 'recipe' ), // Post type |
|
147 | + 'title' => __('Downloads', 'lsx-health-plan'), |
|
148 | + 'object_types' => array('workout', 'meal', 'recipe'), // Post type |
|
149 | 149 | 'context' => 'normal', |
150 | 150 | 'priority' => 'high', |
151 | 151 | 'show_names' => true, |
152 | - ) ); |
|
153 | - $cmb->add_field( array( |
|
154 | - 'name' => __( 'Downloads', 'lsx-health-plan' ), |
|
155 | - 'desc' => __( "Add the pdf's connected to this day plan, using the field provided.", 'lsx-health-plan' ), |
|
152 | + )); |
|
153 | + $cmb->add_field(array( |
|
154 | + 'name' => __('Downloads', 'lsx-health-plan'), |
|
155 | + 'desc' => __("Add the pdf's connected to this day plan, using the field provided.", 'lsx-health-plan'), |
|
156 | 156 | 'id' => 'connected_downloads', |
157 | 157 | 'type' => 'post_search_ajax', |
158 | 158 | // Optional |
159 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
159 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
160 | 160 | 'sortable' => true, // Allow selected items to be sortable (default false) |
161 | 161 | 'query_args' => array( |
162 | - 'post_type' => array( 'dlm_download' ), |
|
163 | - 'post_status' => array( 'publish' ), |
|
162 | + 'post_type' => array('dlm_download'), |
|
163 | + 'post_status' => array('publish'), |
|
164 | 164 | 'posts_per_page' => -1, |
165 | 165 | ), |
166 | - ) ); |
|
166 | + )); |
|
167 | 167 | } |
168 | 168 | } |
@@ -8,161 +8,161 @@ |
||
8 | 8 | */ |
9 | 9 | class Download_Monitor { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Download_Monitor() |
|
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\Download_Monitor() |
|
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 = 'download'; |
|
20 | + /** |
|
21 | + * Holds post_type slug used as an index |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * |
|
25 | + * @var string |
|
26 | + */ |
|
27 | + public $slug = 'download'; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Contructor |
|
31 | - */ |
|
32 | - public function __construct() { |
|
33 | - add_action( 'cmb2_admin_init', array( $this, 'downloads_post_type_metaboxes' ), 5 ); |
|
34 | - add_action( 'cmb2_admin_init', array( $this, 'download_connections' ), 5 ); |
|
35 | - add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
36 | - } |
|
29 | + /** |
|
30 | + * Contructor |
|
31 | + */ |
|
32 | + public function __construct() { |
|
33 | + add_action( 'cmb2_admin_init', array( $this, 'downloads_post_type_metaboxes' ), 5 ); |
|
34 | + add_action( 'cmb2_admin_init', array( $this, 'download_connections' ), 5 ); |
|
35 | + add_filter( 'lsx_health_plan_connections', array( $this, 'enable_connections' ), 10, 1 ); |
|
36 | + } |
|
37 | 37 | |
38 | - /** |
|
39 | - * Return an instance of this class. |
|
40 | - * |
|
41 | - * @since 1.0.0 |
|
42 | - * |
|
43 | - * @return object \lsx_health_plan\classes\Download_Monitor() A single instance of this class. |
|
44 | - */ |
|
45 | - public static function get_instance() { |
|
46 | - // If the single instance hasn't been set, set it now. |
|
47 | - if ( null === self::$instance ) { |
|
48 | - self::$instance = new self(); |
|
49 | - } |
|
50 | - return self::$instance; |
|
51 | - } |
|
38 | + /** |
|
39 | + * Return an instance of this class. |
|
40 | + * |
|
41 | + * @since 1.0.0 |
|
42 | + * |
|
43 | + * @return object \lsx_health_plan\classes\Download_Monitor() A single instance of this class. |
|
44 | + */ |
|
45 | + public static function get_instance() { |
|
46 | + // If the single instance hasn't been set, set it now. |
|
47 | + if ( null === self::$instance ) { |
|
48 | + self::$instance = new self(); |
|
49 | + } |
|
50 | + return self::$instance; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Enables the Bi Directional relationships |
|
55 | - * |
|
56 | - * @param array $connections |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function enable_connections( $connections = array() ) { |
|
60 | - $connections['dlm_download']['connected_pages'] = 'connected_downloads'; |
|
61 | - $connections['dlm_download']['connected_workouts'] = 'connected_downloads'; |
|
62 | - $connections['dlm_download']['connected_meals'] = 'connected_downloads'; |
|
63 | - $connections['dlm_download']['connected_recipes'] = 'connected_downloads'; |
|
53 | + /** |
|
54 | + * Enables the Bi Directional relationships |
|
55 | + * |
|
56 | + * @param array $connections |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function enable_connections( $connections = array() ) { |
|
60 | + $connections['dlm_download']['connected_pages'] = 'connected_downloads'; |
|
61 | + $connections['dlm_download']['connected_workouts'] = 'connected_downloads'; |
|
62 | + $connections['dlm_download']['connected_meals'] = 'connected_downloads'; |
|
63 | + $connections['dlm_download']['connected_recipes'] = 'connected_downloads'; |
|
64 | 64 | |
65 | - //Post Type Connections |
|
66 | - $connections['workout']['connected_downloads'] = 'connected_workouts'; |
|
67 | - $connections['meal']['connected_downloads'] = 'connected_meals'; |
|
68 | - $connections['recipe']['connected_downloads'] = 'connected_recipes'; |
|
69 | - $connections['page']['connected_downloads'] = 'connected_pages'; |
|
70 | - return $connections; |
|
71 | - } |
|
65 | + //Post Type Connections |
|
66 | + $connections['workout']['connected_downloads'] = 'connected_workouts'; |
|
67 | + $connections['meal']['connected_downloads'] = 'connected_meals'; |
|
68 | + $connections['recipe']['connected_downloads'] = 'connected_recipes'; |
|
69 | + $connections['page']['connected_downloads'] = 'connected_pages'; |
|
70 | + return $connections; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * Define the metabox and field configurations. |
|
75 | - */ |
|
76 | - public function downloads_post_type_metaboxes() { |
|
77 | - $cmb = new_cmb2_box( array( |
|
78 | - 'id' => $this->slug . '_connections_metabox', |
|
79 | - 'title' => __( 'Connections', 'lsx-health-plan' ), |
|
80 | - 'object_types' => array( 'dlm_download' ), // Post type |
|
81 | - 'context' => 'normal', |
|
82 | - 'priority' => 'high', |
|
83 | - 'show_names' => true, |
|
84 | - ) ); |
|
85 | - $cmb->add_field( array( |
|
86 | - 'name' => __( 'Pages', 'lsx-health-plan' ), |
|
87 | - 'id' => 'connected_pages', |
|
88 | - 'type' => 'post_search_ajax', |
|
89 | - // Optional : |
|
90 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
91 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
92 | - 'query_args' => array( |
|
93 | - 'post_type' => array( 'page' ), |
|
94 | - 'post_status' => array( 'publish' ), |
|
95 | - 'posts_per_page' => -1, |
|
96 | - ), |
|
97 | - ) ); |
|
98 | - $cmb->add_field( array( |
|
99 | - 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
100 | - 'id' => 'connected_workouts', |
|
101 | - 'type' => 'post_search_ajax', |
|
102 | - // Optional : |
|
103 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
104 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
105 | - 'query_args' => array( |
|
106 | - 'post_type' => array( 'workout' ), |
|
107 | - 'post_status' => array( 'publish' ), |
|
108 | - 'posts_per_page' => -1, |
|
109 | - ), |
|
110 | - ) ); |
|
111 | - $cmb->add_field( array( |
|
112 | - 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
113 | - 'id' => 'connected_meals', |
|
114 | - 'type' => 'post_search_ajax', |
|
115 | - // Optional : |
|
116 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
117 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
118 | - 'query_args' => array( |
|
119 | - 'post_type' => array( 'meal' ), |
|
120 | - 'post_status' => array( 'publish' ), |
|
121 | - 'posts_per_page' => -1, |
|
122 | - ), |
|
123 | - ) ); |
|
124 | - $cmb->add_field( array( |
|
125 | - 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
126 | - 'id' => 'connected_recipes', |
|
127 | - 'type' => 'post_search_ajax', |
|
128 | - // Optional : |
|
129 | - 'limit' => 10, // Limit selection to X items only (default 1) |
|
130 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
131 | - 'query_args' => array( |
|
132 | - 'post_type' => array( 'recipe' ), |
|
133 | - 'post_status' => array( 'publish' ), |
|
134 | - 'posts_per_page' => -1, |
|
135 | - ), |
|
136 | - ) ); |
|
137 | - } |
|
73 | + /** |
|
74 | + * Define the metabox and field configurations. |
|
75 | + */ |
|
76 | + public function downloads_post_type_metaboxes() { |
|
77 | + $cmb = new_cmb2_box( array( |
|
78 | + 'id' => $this->slug . '_connections_metabox', |
|
79 | + 'title' => __( 'Connections', 'lsx-health-plan' ), |
|
80 | + 'object_types' => array( 'dlm_download' ), // Post type |
|
81 | + 'context' => 'normal', |
|
82 | + 'priority' => 'high', |
|
83 | + 'show_names' => true, |
|
84 | + ) ); |
|
85 | + $cmb->add_field( array( |
|
86 | + 'name' => __( 'Pages', 'lsx-health-plan' ), |
|
87 | + 'id' => 'connected_pages', |
|
88 | + 'type' => 'post_search_ajax', |
|
89 | + // Optional : |
|
90 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
91 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
92 | + 'query_args' => array( |
|
93 | + 'post_type' => array( 'page' ), |
|
94 | + 'post_status' => array( 'publish' ), |
|
95 | + 'posts_per_page' => -1, |
|
96 | + ), |
|
97 | + ) ); |
|
98 | + $cmb->add_field( array( |
|
99 | + 'name' => __( 'Workouts', 'lsx-health-plan' ), |
|
100 | + 'id' => 'connected_workouts', |
|
101 | + 'type' => 'post_search_ajax', |
|
102 | + // Optional : |
|
103 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
104 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
105 | + 'query_args' => array( |
|
106 | + 'post_type' => array( 'workout' ), |
|
107 | + 'post_status' => array( 'publish' ), |
|
108 | + 'posts_per_page' => -1, |
|
109 | + ), |
|
110 | + ) ); |
|
111 | + $cmb->add_field( array( |
|
112 | + 'name' => __( 'Meals', 'lsx-health-plan' ), |
|
113 | + 'id' => 'connected_meals', |
|
114 | + 'type' => 'post_search_ajax', |
|
115 | + // Optional : |
|
116 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
117 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
118 | + 'query_args' => array( |
|
119 | + 'post_type' => array( 'meal' ), |
|
120 | + 'post_status' => array( 'publish' ), |
|
121 | + 'posts_per_page' => -1, |
|
122 | + ), |
|
123 | + ) ); |
|
124 | + $cmb->add_field( array( |
|
125 | + 'name' => __( 'Recipe', 'lsx-health-plan' ), |
|
126 | + 'id' => 'connected_recipes', |
|
127 | + 'type' => 'post_search_ajax', |
|
128 | + // Optional : |
|
129 | + 'limit' => 10, // Limit selection to X items only (default 1) |
|
130 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
131 | + 'query_args' => array( |
|
132 | + 'post_type' => array( 'recipe' ), |
|
133 | + 'post_status' => array( 'publish' ), |
|
134 | + 'posts_per_page' => -1, |
|
135 | + ), |
|
136 | + ) ); |
|
137 | + } |
|
138 | 138 | |
139 | - /** |
|
140 | - * Registers the workout connections on the plan post type. |
|
141 | - * |
|
142 | - * @return void |
|
143 | - */ |
|
144 | - public function download_connections() { |
|
145 | - $cmb = new_cmb2_box( array( |
|
146 | - 'id' => $this->slug . '_metabox', |
|
147 | - 'title' => __( 'Downloads', 'lsx-health-plan' ), |
|
148 | - 'object_types' => array( 'workout', 'meal', 'recipe' ), // Post type |
|
149 | - 'context' => 'normal', |
|
150 | - 'priority' => 'high', |
|
151 | - 'show_names' => true, |
|
152 | - ) ); |
|
153 | - $cmb->add_field( array( |
|
154 | - 'name' => __( 'Downloads', 'lsx-health-plan' ), |
|
155 | - 'desc' => __( "Add the pdf's connected to this day plan, using the field provided.", 'lsx-health-plan' ), |
|
156 | - 'id' => 'connected_downloads', |
|
157 | - 'type' => 'post_search_ajax', |
|
158 | - // Optional |
|
159 | - 'limit' => 15, // Limit selection to X items only (default 1) |
|
160 | - 'sortable' => true, // Allow selected items to be sortable (default false) |
|
161 | - 'query_args' => array( |
|
162 | - 'post_type' => array( 'dlm_download' ), |
|
163 | - 'post_status' => array( 'publish' ), |
|
164 | - 'posts_per_page' => -1, |
|
165 | - ), |
|
166 | - ) ); |
|
167 | - } |
|
139 | + /** |
|
140 | + * Registers the workout connections on the plan post type. |
|
141 | + * |
|
142 | + * @return void |
|
143 | + */ |
|
144 | + public function download_connections() { |
|
145 | + $cmb = new_cmb2_box( array( |
|
146 | + 'id' => $this->slug . '_metabox', |
|
147 | + 'title' => __( 'Downloads', 'lsx-health-plan' ), |
|
148 | + 'object_types' => array( 'workout', 'meal', 'recipe' ), // Post type |
|
149 | + 'context' => 'normal', |
|
150 | + 'priority' => 'high', |
|
151 | + 'show_names' => true, |
|
152 | + ) ); |
|
153 | + $cmb->add_field( array( |
|
154 | + 'name' => __( 'Downloads', 'lsx-health-plan' ), |
|
155 | + 'desc' => __( "Add the pdf's connected to this day plan, using the field provided.", 'lsx-health-plan' ), |
|
156 | + 'id' => 'connected_downloads', |
|
157 | + 'type' => 'post_search_ajax', |
|
158 | + // Optional |
|
159 | + 'limit' => 15, // Limit selection to X items only (default 1) |
|
160 | + 'sortable' => true, // Allow selected items to be sortable (default false) |
|
161 | + 'query_args' => array( |
|
162 | + 'post_type' => array( 'dlm_download' ), |
|
163 | + 'post_status' => array( 'publish' ), |
|
164 | + 'posts_per_page' => -1, |
|
165 | + ), |
|
166 | + ) ); |
|
167 | + } |
|
168 | 168 | } |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * Contructor |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | - add_filter( 'wpua_profile_title', array( $this, 'profile_title' ), 10, 1 ); |
|
24 | + add_filter('wpua_profile_title', array($this, 'profile_title'), 10, 1); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public static function get_instance() { |
35 | 35 | // If the single instance hasn't been set, set it now. |
36 | - if ( null === self::$instance ) { |
|
36 | + if (null === self::$instance) { |
|
37 | 37 | self::$instance = new self(); |
38 | 38 | } |
39 | 39 | return self::$instance; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | * @param string $title |
46 | 46 | * @return string |
47 | 47 | */ |
48 | - public function profile_title( $title ) { |
|
49 | - $title = '<h3>' . __( 'My Profile', 'lsx-health-plan' ) . '</h3>'; |
|
50 | - $title .= '<p class="tagline">' . __( 'Please upload an image of yourself in .jpeg format. Images should be square, to best fit the cropping area, and files sizes kept below 500kb.', 'lsx-health-plan' ) . '</p>'; |
|
48 | + public function profile_title($title) { |
|
49 | + $title = '<h3>' . __('My Profile', 'lsx-health-plan') . '</h3>'; |
|
50 | + $title .= '<p class="tagline">' . __('Please upload an image of yourself in .jpeg format. Images should be square, to best fit the cropping area, and files sizes kept below 500kb.', 'lsx-health-plan') . '</p>'; |
|
51 | 51 | return $title; |
52 | 52 | } |
53 | 53 | } |
@@ -8,46 +8,46 @@ |
||
8 | 8 | */ |
9 | 9 | class WP_User_Avatar { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Woocommerce() |
|
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\Woocommerce() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Contructor |
|
22 | - */ |
|
23 | - public function __construct() { |
|
24 | - add_filter( 'wpua_profile_title', array( $this, 'profile_title' ), 10, 1 ); |
|
25 | - } |
|
20 | + /** |
|
21 | + * Contructor |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | + add_filter( 'wpua_profile_title', array( $this, 'profile_title' ), 10, 1 ); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Return an instance of this class. |
|
29 | - * |
|
30 | - * @since 1.0.0 |
|
31 | - * |
|
32 | - * @return object \lsx_health_plan\classes\Woocommerce() A single instance of this class. |
|
33 | - */ |
|
34 | - public static function get_instance() { |
|
35 | - // If the single instance hasn't been set, set it now. |
|
36 | - if ( null === self::$instance ) { |
|
37 | - self::$instance = new self(); |
|
38 | - } |
|
39 | - return self::$instance; |
|
40 | - } |
|
27 | + /** |
|
28 | + * Return an instance of this class. |
|
29 | + * |
|
30 | + * @since 1.0.0 |
|
31 | + * |
|
32 | + * @return object \lsx_health_plan\classes\Woocommerce() A single instance of this class. |
|
33 | + */ |
|
34 | + public static function get_instance() { |
|
35 | + // If the single instance hasn't been set, set it now. |
|
36 | + if ( null === self::$instance ) { |
|
37 | + self::$instance = new self(); |
|
38 | + } |
|
39 | + return self::$instance; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Changes the profile title |
|
44 | - * |
|
45 | - * @param string $title |
|
46 | - * @return string |
|
47 | - */ |
|
48 | - public function profile_title( $title ) { |
|
49 | - $title = '<h3>' . __( 'My Profile', 'lsx-health-plan' ) . '</h3>'; |
|
50 | - $title .= '<p class="tagline">' . __( 'Please upload an image of yourself in .jpeg format. Images should be square, to best fit the cropping area, and files sizes kept below 500kb.', 'lsx-health-plan' ) . '</p>'; |
|
51 | - return $title; |
|
52 | - } |
|
42 | + /** |
|
43 | + * Changes the profile title |
|
44 | + * |
|
45 | + * @param string $title |
|
46 | + * @return string |
|
47 | + */ |
|
48 | + public function profile_title( $title ) { |
|
49 | + $title = '<h3>' . __( 'My Profile', 'lsx-health-plan' ) . '</h3>'; |
|
50 | + $title .= '<p class="tagline">' . __( 'Please upload an image of yourself in .jpeg format. Images should be square, to best fit the cropping area, and files sizes kept below 500kb.', 'lsx-health-plan' ) . '</p>'; |
|
51 | + return $title; |
|
52 | + } |
|
53 | 53 | } |
@@ -21,41 +21,41 @@ discard block |
||
21 | 21 | * Contructor |
22 | 22 | */ |
23 | 23 | public function __construct() { |
24 | - add_action( 'init', array( $this, 'init' ), 20, 1 ); |
|
25 | - add_filter( 'woocommerce_add_to_cart_validation', array( $this, 'only_one_in_cart' ), 99, 2 ); |
|
26 | - add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
27 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'breadcrumbs' ), 30, 1 ); |
|
24 | + add_action('init', array($this, 'init'), 20, 1); |
|
25 | + add_filter('woocommerce_add_to_cart_validation', array($this, 'only_one_in_cart'), 99, 2); |
|
26 | + add_filter('woocommerce_order_button_text', array($this, 'checkout_button_text'), 10, 1); |
|
27 | + add_filter('woocommerce_get_breadcrumb', array($this, 'breadcrumbs'), 30, 1); |
|
28 | 28 | |
29 | 29 | // Checkout. |
30 | - add_action( 'woocommerce_after_checkout_form', array( $this, 'payment_gateway_logos' ) ); |
|
31 | - add_action( 'body_class', array( $this, 'hp_add_body_classes' ) ); |
|
32 | - add_action( 'lsx_nav_before', array( $this, 'hp_link_lsx_navbar_header' ), 99 ); |
|
33 | - add_action( 'wp_head', array( $this, 'hp_simple_checkout' ), 99 ); |
|
30 | + add_action('woocommerce_after_checkout_form', array($this, 'payment_gateway_logos')); |
|
31 | + add_action('body_class', array($this, 'hp_add_body_classes')); |
|
32 | + add_action('lsx_nav_before', array($this, 'hp_link_lsx_navbar_header'), 99); |
|
33 | + add_action('wp_head', array($this, 'hp_simple_checkout'), 99); |
|
34 | 34 | |
35 | 35 | // Redirect to the Edit Account Template. |
36 | - add_filter( 'template_include', array( $this, 'account_endpoint_redirect' ), 99 ); |
|
36 | + add_filter('template_include', array($this, 'account_endpoint_redirect'), 99); |
|
37 | 37 | |
38 | - add_action( 'woocommerce_edit_account_form', array( $this, 'iconic_print_user_frontend_fields' ), 10 ); |
|
38 | + add_action('woocommerce_edit_account_form', array($this, 'iconic_print_user_frontend_fields'), 10); |
|
39 | 39 | |
40 | - add_filter( 'iconic_account_fields', array( $this, 'iconic_add_post_data_to_account_fields' ), 10, 1 ); |
|
41 | - add_action( 'show_user_profile', array( $this, 'iconic_print_user_admin_fields' ), 30 ); |
|
40 | + add_filter('iconic_account_fields', array($this, 'iconic_add_post_data_to_account_fields'), 10, 1); |
|
41 | + add_action('show_user_profile', array($this, 'iconic_print_user_admin_fields'), 30); |
|
42 | 42 | |
43 | - add_action( 'personal_options_update', array( $this, 'iconic_save_account_fields' ) ); |
|
44 | - add_action( 'edit_user_profile_update', array( $this, 'iconic_save_account_fields' ) ); |
|
43 | + add_action('personal_options_update', array($this, 'iconic_save_account_fields')); |
|
44 | + add_action('edit_user_profile_update', array($this, 'iconic_save_account_fields')); |
|
45 | 45 | |
46 | - add_action( 'woocommerce_save_account_details', array( $this, 'iconic_save_account_fields' ) ); |
|
47 | - add_filter( 'woocommerce_save_account_details_errors', array( $this, 'iconic_validate_user_frontend_fields' ), 10 ); |
|
46 | + add_action('woocommerce_save_account_details', array($this, 'iconic_save_account_fields')); |
|
47 | + add_filter('woocommerce_save_account_details_errors', array($this, 'iconic_validate_user_frontend_fields'), 10); |
|
48 | 48 | |
49 | 49 | // Profile Fields. |
50 | - add_filter( 'woocommerce_form_field_text', array( $this, 'lsx_profile_photo_field_filter' ), 10, 4 ); |
|
51 | - add_action( 'woocommerce_after_edit_account_form', array( $this, 'action_woocommerce_after_edit_account_form' ), 10, 0 ); |
|
50 | + add_filter('woocommerce_form_field_text', array($this, 'lsx_profile_photo_field_filter'), 10, 4); |
|
51 | + add_action('woocommerce_after_edit_account_form', array($this, 'action_woocommerce_after_edit_account_form'), 10, 0); |
|
52 | 52 | |
53 | 53 | // Lost Password fields |
54 | - add_action( 'woocommerce_before_lost_password_form', array( $this, 'lost_password_page_title' ), 10 ); |
|
54 | + add_action('woocommerce_before_lost_password_form', array($this, 'lost_password_page_title'), 10); |
|
55 | 55 | |
56 | - add_action( 'wp', array( $this, 'allow_reset_password_page' ), 9 ); |
|
56 | + add_action('wp', array($this, 'allow_reset_password_page'), 9); |
|
57 | 57 | |
58 | - add_filter( 'wc_add_to_cart_message_html', '__return_false' ); |
|
58 | + add_filter('wc_add_to_cart_message_html', '__return_false'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public static function get_instance() { |
69 | 69 | // If the single instance hasn't been set, set it now. |
70 | - if ( null === self::$instance ) { |
|
70 | + if (null === self::$instance) { |
|
71 | 71 | self::$instance = new self(); |
72 | 72 | } |
73 | 73 | return self::$instance; |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @return void |
80 | 80 | */ |
81 | 81 | public function init() { |
82 | - remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' ); |
|
82 | + remove_action('woocommerce_account_navigation', 'woocommerce_account_navigation'); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | * @param [type] $added_product_id |
90 | 90 | * @return void |
91 | 91 | */ |
92 | - public function only_one_in_cart( $passed, $added_product_id ) { |
|
92 | + public function only_one_in_cart($passed, $added_product_id) { |
|
93 | 93 | wc_empty_cart(); |
94 | 94 | return $passed; |
95 | 95 | } |
@@ -100,8 +100,8 @@ discard block |
||
100 | 100 | * @param string $label |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - public function checkout_button_text( $label = '' ) { |
|
104 | - $label = __( 'Place order', 'lsx-health-plan' ); |
|
103 | + public function checkout_button_text($label = '') { |
|
104 | + $label = __('Place order', 'lsx-health-plan'); |
|
105 | 105 | return $label; |
106 | 106 | } |
107 | 107 | |
@@ -110,27 +110,27 @@ discard block |
||
110 | 110 | * @param $crumbs |
111 | 111 | * @return array |
112 | 112 | */ |
113 | - public function breadcrumbs( $crumbs ) { |
|
113 | + public function breadcrumbs($crumbs) { |
|
114 | 114 | |
115 | - if ( is_singular( 'plan' ) ) { |
|
115 | + if (is_singular('plan')) { |
|
116 | 116 | |
117 | 117 | $new_crumbs = array(); |
118 | 118 | $new_crumbs[0] = $crumbs[0]; |
119 | 119 | |
120 | 120 | $new_crumbs[1] = array( |
121 | - 0 => get_the_title( wc_get_page_id( 'myaccount' ) ), |
|
122 | - 1 => get_permalink( wc_get_page_id( 'myaccount' ) ), |
|
121 | + 0 => get_the_title(wc_get_page_id('myaccount')), |
|
122 | + 1 => get_permalink(wc_get_page_id('myaccount')), |
|
123 | 123 | ); |
124 | 124 | |
125 | - $endpoint = get_query_var( 'endpoint' ); |
|
126 | - if ( '' === $endpoint || false === $endpoint ) { |
|
125 | + $endpoint = get_query_var('endpoint'); |
|
126 | + if ('' === $endpoint || false === $endpoint) { |
|
127 | 127 | $new_crumbs[2] = array( |
128 | 128 | 0 => get_the_title(), |
129 | 129 | 1 => false, |
130 | 130 | ); |
131 | 131 | } else { |
132 | - $endpoint_translation = \lsx_health_plan\functions\get_option( 'endpoint_' . $endpoint, false ); |
|
133 | - if ( false !== $endpoint_translation && '' !== $endpoint_translation ) { |
|
132 | + $endpoint_translation = \lsx_health_plan\functions\get_option('endpoint_' . $endpoint, false); |
|
133 | + if (false !== $endpoint_translation && '' !== $endpoint_translation) { |
|
134 | 134 | $endpoint = $endpoint_translation; |
135 | 135 | } |
136 | 136 | $new_crumbs[2] = array( |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 1 => get_permalink(), |
139 | 139 | ); |
140 | 140 | $new_crumbs[3] = array( |
141 | - 0 => ucwords( $endpoint ), |
|
141 | + 0 => ucwords($endpoint), |
|
142 | 142 | 1 => false, |
143 | 143 | ); |
144 | 144 | } |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | * @param string $template |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - public function account_endpoint_redirect( $template ) { |
|
158 | - if ( function_exists( 'is_account_page' ) && is_account_page() ) { |
|
159 | - if ( empty( locate_template( array( 'page-template-my-plan.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php' ) ) { |
|
157 | + public function account_endpoint_redirect($template) { |
|
158 | + if (function_exists('is_account_page') && is_account_page()) { |
|
159 | + if (empty(locate_template(array('page-template-my-plan.php'))) && file_exists(LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php')) { |
|
160 | 160 | $template = LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php'; |
161 | 161 | } |
162 | 162 | } |
@@ -170,19 +170,19 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return array |
172 | 172 | */ |
173 | - public function iconic_add_post_data_to_account_fields( $fields ) { |
|
174 | - if ( empty( $_POST ) && wp_verify_nonce( sanitize_key( $_POST ) ) ) { |
|
173 | + public function iconic_add_post_data_to_account_fields($fields) { |
|
174 | + if (empty($_POST) && wp_verify_nonce(sanitize_key($_POST))) { |
|
175 | 175 | return $fields; |
176 | 176 | } |
177 | 177 | |
178 | - foreach ( $fields as $key => $field_args ) { |
|
179 | - if ( isset( $_POST[ $key ] ) && empty( $_POST[ $key ] ) && wp_verify_nonce( sanitize_key( $_POST[ $key ] ) ) ) { |
|
180 | - $fields[ $key ]['value'] = ''; |
|
178 | + foreach ($fields as $key => $field_args) { |
|
179 | + if (isset($_POST[$key]) && empty($_POST[$key]) && wp_verify_nonce(sanitize_key($_POST[$key]))) { |
|
180 | + $fields[$key]['value'] = ''; |
|
181 | 181 | continue; |
182 | 182 | } |
183 | 183 | |
184 | - if ( isset( $_POST[ $key ] ) ) { |
|
185 | - $fields[ $key ]['value'] = sanitize_key( $_POST[ $key ] ); |
|
184 | + if (isset($_POST[$key])) { |
|
185 | + $fields[$key]['value'] = sanitize_key($_POST[$key]); |
|
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
@@ -196,27 +196,27 @@ discard block |
||
196 | 196 | $fields = $this->get_account_fields(); |
197 | 197 | $is_user_logged_in = is_user_logged_in(); |
198 | 198 | |
199 | - $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
200 | - if ( 'on' !== $all_disabled ) { |
|
201 | - echo wp_kses_post( '<h2 class="title-lined my-stats-title">' . __( 'My Stats', 'lsx-health-plan' ) . '</h2>' ); |
|
202 | - echo wp_kses_post( '<div class="my-stats">' ); |
|
199 | + $all_disabled = \lsx_health_plan\functions\get_option('disable_all_stats', false); |
|
200 | + if ('on' !== $all_disabled) { |
|
201 | + echo wp_kses_post('<h2 class="title-lined my-stats-title">' . __('My Stats', 'lsx-health-plan') . '</h2>'); |
|
202 | + echo wp_kses_post('<div class="my-stats">'); |
|
203 | 203 | |
204 | - echo wp_kses_post( '<p class="form-row form-label">' . __( 'Start', 'lsx-health-plan' ) . '</p>' ); |
|
205 | - echo wp_kses_post( '<p class="form-row form-label">' . __( 'Goal', 'lsx-health-plan' ) . '</p>' ); |
|
206 | - echo wp_kses_post( '<p class="form-row form-label">' . __( 'End', 'lsx-health-plan' ) . '</p>' ); |
|
207 | - foreach ( $fields as $key => $field_args ) { |
|
204 | + echo wp_kses_post('<p class="form-row form-label">' . __('Start', 'lsx-health-plan') . '</p>'); |
|
205 | + echo wp_kses_post('<p class="form-row form-label">' . __('Goal', 'lsx-health-plan') . '</p>'); |
|
206 | + echo wp_kses_post('<p class="form-row form-label">' . __('End', 'lsx-health-plan') . '</p>'); |
|
207 | + foreach ($fields as $key => $field_args) { |
|
208 | 208 | $value = null; |
209 | - if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
209 | + if ( ! $this->iconic_is_field_visible($field_args)) { |
|
210 | 210 | continue; |
211 | 211 | } |
212 | - if ( $is_user_logged_in ) { |
|
212 | + if ($is_user_logged_in) { |
|
213 | 213 | $user_id = $this->iconic_get_edit_user_id(); |
214 | - $value = $this->iconic_get_userdata( $user_id, $key ); |
|
214 | + $value = $this->iconic_get_userdata($user_id, $key); |
|
215 | 215 | } |
216 | - $value = ( isset( $field_args['value'] ) && '' !== $field_args['value'] ) ? $field_args['value'] : $value; |
|
217 | - woocommerce_form_field( $key, $field_args, $value ); |
|
216 | + $value = (isset($field_args['value']) && '' !== $field_args['value']) ? $field_args['value'] : $value; |
|
217 | + woocommerce_form_field($key, $field_args, $value); |
|
218 | 218 | } |
219 | - echo wp_kses_post( '</div>' ); |
|
219 | + echo wp_kses_post('</div>'); |
|
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
@@ -228,14 +228,14 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return mixed|string |
230 | 230 | */ |
231 | - public function iconic_get_userdata( $user_id, $key ) { |
|
232 | - if ( ! $this->iconic_is_userdata( $key ) ) { |
|
233 | - return get_user_meta( $user_id, $key, true ); |
|
231 | + public function iconic_get_userdata($user_id, $key) { |
|
232 | + if ( ! $this->iconic_is_userdata($key)) { |
|
233 | + return get_user_meta($user_id, $key, true); |
|
234 | 234 | } |
235 | 235 | |
236 | - $userdata = get_userdata( $user_id ); |
|
236 | + $userdata = get_userdata($user_id); |
|
237 | 237 | |
238 | - if ( ! $userdata || ! isset( $userdata->{$key} ) ) { |
|
238 | + if ( ! $userdata || ! isset($userdata->{$key} )) { |
|
239 | 239 | return ''; |
240 | 240 | } |
241 | 241 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | * @return int |
249 | 249 | */ |
250 | 250 | public function iconic_get_edit_user_id() { |
251 | - return ( isset( $_GET['user_id'] ) && wp_verify_nonce( sanitize_key( $_GET['user_id'] ) ) ) ? (int) $_GET['user_id'] : get_current_user_id(); |
|
251 | + return (isset($_GET['user_id']) && wp_verify_nonce(sanitize_key($_GET['user_id']))) ? (int) $_GET['user_id'] : get_current_user_id(); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | |
@@ -257,47 +257,47 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @param int $customer_id |
259 | 259 | */ |
260 | - public function iconic_save_account_fields( $customer_id ) { |
|
261 | - $nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. |
|
262 | - if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) { |
|
260 | + public function iconic_save_account_fields($customer_id) { |
|
261 | + $nonce_value = wc_get_var($_REQUEST['save-account-details-nonce'], wc_get_var($_REQUEST['_wpnonce'], '')); // @codingStandardsIgnoreLine. |
|
262 | + if ( ! wp_verify_nonce($nonce_value, 'save_account_details')) { |
|
263 | 263 | return; |
264 | 264 | } |
265 | 265 | |
266 | 266 | $fields = $this->get_account_fields(); |
267 | 267 | $sanitized_data = array(); |
268 | - foreach ( $fields as $key => $field_args ) { |
|
269 | - if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
268 | + foreach ($fields as $key => $field_args) { |
|
269 | + if ( ! $this->iconic_is_field_visible($field_args)) { |
|
270 | 270 | continue; |
271 | 271 | } |
272 | 272 | |
273 | - $sanitize = isset( $field_args['sanitize'] ) ? $field_args['sanitize'] : 'wc_clean'; |
|
274 | - $value = ( isset( $_POST[ $key ] ) ) ? call_user_func( $sanitize, $_POST[ $key ] ) : ''; |
|
275 | - if ( $this->iconic_is_userdata( $key ) ) { |
|
273 | + $sanitize = isset($field_args['sanitize']) ? $field_args['sanitize'] : 'wc_clean'; |
|
274 | + $value = (isset($_POST[$key])) ? call_user_func($sanitize, $_POST[$key]) : ''; |
|
275 | + if ($this->iconic_is_userdata($key)) { |
|
276 | 276 | |
277 | - $sanitized_data[ $key ] = $value; |
|
277 | + $sanitized_data[$key] = $value; |
|
278 | 278 | continue; |
279 | 279 | } |
280 | 280 | |
281 | - if ( 'profile_photo' === $key ) { |
|
281 | + if ('profile_photo' === $key) { |
|
282 | 282 | // This handles the image uploads. |
283 | 283 | require_once ABSPATH . 'wp-admin/includes/image.php'; |
284 | 284 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
285 | 285 | require_once ABSPATH . 'wp-admin/includes/media.php'; |
286 | 286 | |
287 | - $id = media_handle_upload( $key, 0, '' ); |
|
288 | - if ( ! is_wp_error( $id ) ) { |
|
289 | - update_term_meta( $customer_id, $key . '_id', $id ); |
|
290 | - update_term_meta( $customer_id, $key, $id ); |
|
287 | + $id = media_handle_upload($key, 0, ''); |
|
288 | + if ( ! is_wp_error($id)) { |
|
289 | + update_term_meta($customer_id, $key . '_id', $id); |
|
290 | + update_term_meta($customer_id, $key, $id); |
|
291 | 291 | } |
292 | 292 | } else { |
293 | - delete_user_meta( $customer_id, $key ); |
|
294 | - update_user_meta( $customer_id, $key, $value ); |
|
293 | + delete_user_meta($customer_id, $key); |
|
294 | + update_user_meta($customer_id, $key, $value); |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | - if ( ! empty( $sanitized_data ) ) { |
|
298 | + if ( ! empty($sanitized_data)) { |
|
299 | 299 | $sanitized_data['ID'] = $customer_id; |
300 | - wp_update_user( $sanitized_data ); |
|
300 | + wp_update_user($sanitized_data); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @return bool |
311 | 311 | */ |
312 | - public function iconic_is_userdata( $key ) { |
|
312 | + public function iconic_is_userdata($key) { |
|
313 | 313 | $userdata = array( |
314 | 314 | 'user_pass', |
315 | 315 | 'user_login', |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | 'show_admin_bar_front', |
331 | 331 | ); |
332 | 332 | |
333 | - return in_array( $key, $userdata, true ); |
|
333 | + return in_array($key, $userdata, true); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -340,31 +340,31 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return bool |
342 | 342 | */ |
343 | - public function iconic_is_field_visible( $field_args ) { |
|
343 | + public function iconic_is_field_visible($field_args) { |
|
344 | 344 | $visible = true; |
345 | - $action = filter_input( INPUT_POST, 'action' ); |
|
345 | + $action = filter_input(INPUT_POST, 'action'); |
|
346 | 346 | |
347 | - if ( is_admin() && ! empty( $field_args['hide_in_admin'] ) ) { |
|
347 | + if (is_admin() && ! empty($field_args['hide_in_admin'])) { |
|
348 | 348 | $visible = false; |
349 | - } elseif ( ( is_account_page() || 'save_account_details' === $action ) && is_user_logged_in() && ! empty( $field_args['hide_in_account'] ) ) { |
|
349 | + } elseif ((is_account_page() || 'save_account_details' === $action) && is_user_logged_in() && ! empty($field_args['hide_in_account'])) { |
|
350 | 350 | $visible = false; |
351 | - } elseif ( ( is_account_page() || 'save_account_details' === $action ) && ! is_user_logged_in() && ! empty( $field_args['hide_in_registration'] ) ) { |
|
351 | + } elseif ((is_account_page() || 'save_account_details' === $action) && ! is_user_logged_in() && ! empty($field_args['hide_in_registration'])) { |
|
352 | 352 | $visible = false; |
353 | - } elseif ( is_checkout() && ! empty( $field_args['hide_in_checkout'] ) ) { |
|
353 | + } elseif (is_checkout() && ! empty($field_args['hide_in_checkout'])) { |
|
354 | 354 | $visible = false; |
355 | 355 | } |
356 | 356 | |
357 | 357 | // Disable the fitness fields if needed. |
358 | - $weight_key = __( 'Weight:' ); |
|
359 | - $waist_key = __( 'Waist:' ); |
|
360 | - $fitness_key = __( 'Fitness Test Score:' ); |
|
361 | - if ( $weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label'] ) { |
|
358 | + $weight_key = __('Weight:'); |
|
359 | + $waist_key = __('Waist:'); |
|
360 | + $fitness_key = __('Fitness Test Score:'); |
|
361 | + if ($weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label']) { |
|
362 | 362 | |
363 | 363 | // Check if all stats are disabled. |
364 | - $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
364 | + $all_disabled = \lsx_health_plan\functions\get_option('disable_all_stats', false); |
|
365 | 365 | |
366 | 366 | $option_key = ''; |
367 | - switch ( $field_args['label'] ) { |
|
367 | + switch ($field_args['label']) { |
|
368 | 368 | case $weight_key: |
369 | 369 | $option_key = 'disable_weight_checkbox'; |
370 | 370 | break; |
@@ -377,8 +377,8 @@ discard block |
||
377 | 377 | $option_key = 'disable_fitness_checkbox'; |
378 | 378 | break; |
379 | 379 | } |
380 | - $is_disabled = \lsx_health_plan\functions\get_option( $option_key, false ); |
|
381 | - if ( 'on' === $all_disabled || 'on' === $is_disabled ) { |
|
380 | + $is_disabled = \lsx_health_plan\functions\get_option($option_key, false); |
|
381 | + if ('on' === $all_disabled || 'on' === $is_disabled) { |
|
382 | 382 | $visible = false; |
383 | 383 | } |
384 | 384 | } |
@@ -391,25 +391,25 @@ discard block |
||
391 | 391 | public function iconic_print_user_admin_fields() { |
392 | 392 | $fields = $this->get_account_fields(); |
393 | 393 | ?> |
394 | - <h2><?php esc_html_e( 'Additional Information', 'lsx-health-plan' ); ?></h2> |
|
394 | + <h2><?php esc_html_e('Additional Information', 'lsx-health-plan'); ?></h2> |
|
395 | 395 | <table class="form-table" id="iconic-additional-information"> |
396 | 396 | <tbody> |
397 | - <?php foreach ( $fields as $key => $field_args ) { ?> |
|
397 | + <?php foreach ($fields as $key => $field_args) { ?> |
|
398 | 398 | <?php |
399 | - if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
399 | + if ( ! $this->iconic_is_field_visible($field_args)) { |
|
400 | 400 | continue; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $user_id = $this->iconic_get_edit_user_id(); |
404 | - $value = get_user_meta( $user_id, $key, true ); |
|
404 | + $value = get_user_meta($user_id, $key, true); |
|
405 | 405 | ?> |
406 | 406 | <tr> |
407 | 407 | <th> |
408 | - <label for="<?php echo esc_html( $key ); ?>"><?php echo esc_html( $field_args['label'] ); ?></label> |
|
408 | + <label for="<?php echo esc_html($key); ?>"><?php echo esc_html($field_args['label']); ?></label> |
|
409 | 409 | </th> |
410 | 410 | <td> |
411 | 411 | <?php $field_args['label'] = false; ?> |
412 | - <?php woocommerce_form_field( $key, $field_args, $value ); ?> |
|
412 | + <?php woocommerce_form_field($key, $field_args, $value); ?> |
|
413 | 413 | </td> |
414 | 414 | </tr> |
415 | 415 | <?php } ?> |
@@ -425,11 +425,11 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @return WP_Error |
427 | 427 | */ |
428 | - public function iconic_validate_user_frontend_fields( $errors ) { |
|
428 | + public function iconic_validate_user_frontend_fields($errors) { |
|
429 | 429 | $fields = $this->get_account_fields(); |
430 | 430 | |
431 | - foreach ( $fields as $key => $field_args ) { |
|
432 | - if ( empty( $field_args['required'] ) ) { |
|
431 | + foreach ($fields as $key => $field_args) { |
|
432 | + if (empty($field_args['required'])) { |
|
433 | 433 | continue; |
434 | 434 | } |
435 | 435 | |
@@ -437,14 +437,14 @@ discard block |
||
437 | 437 | continue; |
438 | 438 | }*/ |
439 | 439 | |
440 | - if ( isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_registration'] ) ) { |
|
440 | + if (isset($_POST['register']) && wp_verify_nonce(sanitize_key($_POST['register'])) && ! empty($field_args['hide_in_registration'])) { |
|
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | - if ( empty( $_POST[ $key ] ) ) { |
|
444 | + if (empty($_POST[$key])) { |
|
445 | 445 | /* translators: %s: field */ |
446 | - $message = sprintf( __( '%s is a required field.', 'lsx-health-plan' ), '<strong>' . $field_args['label'] . '</strong>' ); |
|
447 | - $errors->add( $key, $message ); |
|
446 | + $message = sprintf(__('%s is a required field.', 'lsx-health-plan'), '<strong>' . $field_args['label'] . '</strong>'); |
|
447 | + $errors->add($key, $message); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -460,48 +460,48 @@ discard block |
||
460 | 460 | * |
461 | 461 | * @return mixed |
462 | 462 | */ |
463 | - public function lsx_profile_photo_field_filter( $field, $key, $args, $value ) { |
|
464 | - if ( 'profile_photo' === $args['id'] ) { |
|
463 | + public function lsx_profile_photo_field_filter($field, $key, $args, $value) { |
|
464 | + if ('profile_photo' === $args['id']) { |
|
465 | 465 | |
466 | - if ( $args['required'] ) { |
|
466 | + if ($args['required']) { |
|
467 | 467 | $args['class'][] = 'validate-required'; |
468 | - $required = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>'; |
|
468 | + $required = ' <abbr class="required" title="' . esc_attr__('required', 'lsx-health-plan') . '">*</abbr>'; |
|
469 | 469 | } else { |
470 | 470 | $required = ''; |
471 | 471 | } |
472 | 472 | |
473 | - if ( is_string( $args['label_class'] ) ) { |
|
474 | - $args['label_class'] = array( $args['label_class'] ); |
|
473 | + if (is_string($args['label_class'])) { |
|
474 | + $args['label_class'] = array($args['label_class']); |
|
475 | 475 | } |
476 | 476 | |
477 | - if ( is_null( $value ) ) { |
|
477 | + if (is_null($value)) { |
|
478 | 478 | $value = $args['default']; |
479 | 479 | } |
480 | 480 | |
481 | 481 | // Custom attribute handling. |
482 | 482 | $custom_attributes = array(); |
483 | - $args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' ); |
|
483 | + $args['custom_attributes'] = array_filter((array) $args['custom_attributes'], 'strlen'); |
|
484 | 484 | |
485 | - if ( $args['maxlength'] ) { |
|
486 | - $args['custom_attributes']['maxlength'] = absint( $args['maxlength'] ); |
|
485 | + if ($args['maxlength']) { |
|
486 | + $args['custom_attributes']['maxlength'] = absint($args['maxlength']); |
|
487 | 487 | } |
488 | 488 | |
489 | - if ( ! empty( $args['autocomplete'] ) ) { |
|
489 | + if ( ! empty($args['autocomplete'])) { |
|
490 | 490 | $args['custom_attributes']['autocomplete'] = $args['autocomplete']; |
491 | 491 | } |
492 | 492 | |
493 | - if ( true === $args['autofocus'] ) { |
|
493 | + if (true === $args['autofocus']) { |
|
494 | 494 | $args['custom_attributes']['autofocus'] = 'autofocus'; |
495 | 495 | } |
496 | 496 | |
497 | - if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) { |
|
498 | - foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) { |
|
499 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
497 | + if ( ! empty($args['custom_attributes']) && is_array($args['custom_attributes'])) { |
|
498 | + foreach ($args['custom_attributes'] as $attribute => $attribute_value) { |
|
499 | + $custom_attributes[] = esc_attr($attribute) . '="' . esc_attr($attribute_value) . '"'; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - if ( ! empty( $args['validate'] ) ) { |
|
504 | - foreach ( $args['validate'] as $validate ) { |
|
503 | + if ( ! empty($args['validate'])) { |
|
504 | + foreach ($args['validate'] as $validate) { |
|
505 | 505 | $args['class'][] = 'validate-' . $validate; |
506 | 506 | } |
507 | 507 | } |
@@ -510,38 +510,38 @@ discard block |
||
510 | 510 | $field = ''; |
511 | 511 | $label_id = $args['id']; |
512 | 512 | $sort = $args['priority'] ? $args['priority'] : ''; |
513 | - $field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>'; |
|
513 | + $field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr($sort) . '">%3$s</p>'; |
|
514 | 514 | $args['class'][] = 'validate-required'; |
515 | - $required = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>'; |
|
515 | + $required = ' <abbr class="required" title="' . esc_attr__('required', 'lsx-health-plan') . '">*</abbr>'; |
|
516 | 516 | |
517 | - $field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' />'; |
|
517 | + $field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr(implode(' ', $args['input_class'])) . '" name="' . esc_attr($key) . '" id="' . esc_attr($args['id']) . '" placeholder="' . esc_attr($args['placeholder']) . '" value="" ' . implode(' ', $custom_attributes) . ' />'; |
|
518 | 518 | |
519 | - if ( '' !== $value && $value !== $args['default'] ) { |
|
520 | - $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '_id" id="' . esc_attr( $args['id'] ) . '_id" placeholder="' . esc_attr( $args['placeholder'] ) . '_id" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />'; |
|
519 | + if ('' !== $value && $value !== $args['default']) { |
|
520 | + $field .= '<input type="text" class="input-text ' . esc_attr(implode(' ', $args['input_class'])) . '" name="' . esc_attr($key) . '_id" id="' . esc_attr($args['id']) . '_id" placeholder="' . esc_attr($args['placeholder']) . '_id" value="' . esc_attr($value) . '" ' . implode(' ', $custom_attributes) . ' />'; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | $field .= '<input type="hidden" name="MAX_FILE_SIZE" value="500000" />'; |
524 | 524 | |
525 | - if ( $args['label'] && 'checkbox' !== $args['type'] ) { |
|
526 | - $field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>'; |
|
525 | + if ($args['label'] && 'checkbox' !== $args['type']) { |
|
526 | + $field_html .= '<label for="' . esc_attr($label_id) . '" class="' . esc_attr(implode(' ', $args['label_class'])) . '">' . $args['label'] . $required . '</label>'; |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | $field_html .= $field; |
530 | 530 | |
531 | - if ( $args['description'] ) { |
|
532 | - $field_html .= '<span class="description">' . esc_html( $args['description'] ) . '</span>'; |
|
531 | + if ($args['description']) { |
|
532 | + $field_html .= '<span class="description">' . esc_html($args['description']) . '</span>'; |
|
533 | 533 | } |
534 | 534 | |
535 | - $container_class = esc_attr( implode( ' ', $args['class'] ) ); |
|
536 | - $container_id = esc_attr( $args['id'] ) . '_field'; |
|
537 | - $field = sprintf( $field_container, $container_class, $container_id, $field_html ); |
|
535 | + $container_class = esc_attr(implode(' ', $args['class'])); |
|
536 | + $container_id = esc_attr($args['id']) . '_field'; |
|
537 | + $field = sprintf($field_container, $container_class, $container_id, $field_html); |
|
538 | 538 | } |
539 | 539 | return $field; |
540 | 540 | } |
541 | 541 | |
542 | 542 | |
543 | 543 | public function action_woocommerce_after_edit_account_form() { |
544 | - echo do_shortcode( '[avatar_upload /]' ); |
|
544 | + echo do_shortcode('[avatar_upload /]'); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -550,11 +550,11 @@ discard block |
||
550 | 550 | * @return array |
551 | 551 | */ |
552 | 552 | public function get_account_fields() { |
553 | - $account_fields = apply_filters( 'iconic_account_fields', array( |
|
553 | + $account_fields = apply_filters('iconic_account_fields', array( |
|
554 | 554 | 'weight_start' => array( |
555 | 555 | 'type' => 'text', |
556 | - 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
557 | - 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
556 | + 'label' => __('Weight:', 'lsx-health-plan'), |
|
557 | + 'placeholder' => __('kg', 'lsx-health-plan'), |
|
558 | 558 | 'hide_in_account' => false, |
559 | 559 | 'hide_in_admin' => false, |
560 | 560 | 'hide_in_checkout' => false, |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | ), |
564 | 564 | 'weight_goal' => array( |
565 | 565 | 'type' => 'text', |
566 | - 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
567 | - 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
566 | + 'label' => __('Weight:', 'lsx-health-plan'), |
|
567 | + 'placeholder' => __('kg', 'lsx-health-plan'), |
|
568 | 568 | 'hide_in_account' => false, |
569 | 569 | 'hide_in_admin' => false, |
570 | 570 | 'hide_in_checkout' => false, |
@@ -573,8 +573,8 @@ discard block |
||
573 | 573 | ), |
574 | 574 | 'weight_end' => array( |
575 | 575 | 'type' => 'text', |
576 | - 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
577 | - 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
576 | + 'label' => __('Weight:', 'lsx-health-plan'), |
|
577 | + 'placeholder' => __('kg', 'lsx-health-plan'), |
|
578 | 578 | 'hide_in_account' => false, |
579 | 579 | 'hide_in_admin' => false, |
580 | 580 | 'hide_in_checkout' => false, |
@@ -583,8 +583,8 @@ discard block |
||
583 | 583 | ), |
584 | 584 | 'waist_start' => array( |
585 | 585 | 'type' => 'text', |
586 | - 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
587 | - 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
586 | + 'label' => __('Waist:', 'lsx-health-plan'), |
|
587 | + 'placeholder' => __('cm', 'lsx-health-plan'), |
|
588 | 588 | 'hide_in_account' => false, |
589 | 589 | 'hide_in_admin' => false, |
590 | 590 | 'hide_in_checkout' => false, |
@@ -593,8 +593,8 @@ discard block |
||
593 | 593 | ), |
594 | 594 | 'waist_goal' => array( |
595 | 595 | 'type' => 'text', |
596 | - 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
597 | - 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
596 | + 'label' => __('Waist:', 'lsx-health-plan'), |
|
597 | + 'placeholder' => __('cm', 'lsx-health-plan'), |
|
598 | 598 | 'hide_in_account' => false, |
599 | 599 | 'hide_in_admin' => false, |
600 | 600 | 'hide_in_checkout' => false, |
@@ -603,8 +603,8 @@ discard block |
||
603 | 603 | ), |
604 | 604 | 'waist_end' => array( |
605 | 605 | 'type' => 'text', |
606 | - 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
607 | - 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
606 | + 'label' => __('Waist:', 'lsx-health-plan'), |
|
607 | + 'placeholder' => __('cm', 'lsx-health-plan'), |
|
608 | 608 | 'hide_in_account' => false, |
609 | 609 | 'hide_in_admin' => false, |
610 | 610 | 'hide_in_checkout' => false, |
@@ -613,7 +613,7 @@ discard block |
||
613 | 613 | ), |
614 | 614 | 'fitness_start' => array( |
615 | 615 | 'type' => 'text', |
616 | - 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
616 | + 'label' => __('Fitness Test Score:', 'lsx-health-plan'), |
|
617 | 617 | 'placeholder' => '#', |
618 | 618 | 'hide_in_account' => false, |
619 | 619 | 'hide_in_admin' => false, |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | ), |
624 | 624 | 'fitness_goal' => array( |
625 | 625 | 'type' => 'text', |
626 | - 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
626 | + 'label' => __('Fitness Test Score:', 'lsx-health-plan'), |
|
627 | 627 | 'placeholder' => '#', |
628 | 628 | 'hide_in_account' => false, |
629 | 629 | 'hide_in_admin' => false, |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | ), |
634 | 634 | 'fitness_end' => array( |
635 | 635 | 'type' => 'text', |
636 | - 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
636 | + 'label' => __('Fitness Test Score:', 'lsx-health-plan'), |
|
637 | 637 | 'placeholder' => '#', |
638 | 638 | 'hide_in_account' => false, |
639 | 639 | 'hide_in_admin' => false, |
@@ -641,16 +641,16 @@ discard block |
||
641 | 641 | 'hide_in_registration' => false, |
642 | 642 | 'required' => false, |
643 | 643 | ), |
644 | - ) ); |
|
644 | + )); |
|
645 | 645 | |
646 | - $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false ); |
|
647 | - if ( 'on' === $is_weight_disabled ) { |
|
646 | + $is_weight_disabled = \lsx_health_plan\functions\get_option('disable_weight_checkbox', false); |
|
647 | + if ('on' === $is_weight_disabled) { |
|
648 | 648 | $account_fields['weight_start']['required'] = false; |
649 | 649 | $account_fields['weight_goal']['required'] = false; |
650 | 650 | $account_fields['weight_end']['required'] = false; |
651 | 651 | } |
652 | - $is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false ); |
|
653 | - if ( 'on' === $is_waist_disabled ) { |
|
652 | + $is_waist_disabled = \lsx_health_plan\functions\get_option('disable_waist_checkbox', false); |
|
653 | + if ('on' === $is_waist_disabled) { |
|
654 | 654 | $account_fields['waist_start']['required'] = false; |
655 | 655 | $account_fields['waist_goal']['required'] = false; |
656 | 656 | $account_fields['waist_end']['required'] = false; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | * @return void |
665 | 665 | */ |
666 | 666 | public function allow_reset_password_page() { |
667 | - if ( ! is_user_logged_in() && function_exists( 'wc_memberships' ) && is_wc_endpoint_url( 'lost-password' ) ) { |
|
667 | + if ( ! is_user_logged_in() && function_exists('wc_memberships') && is_wc_endpoint_url('lost-password')) { |
|
668 | 668 | |
669 | 669 | $members_instance = wc_memberships(); |
670 | 670 | $restriction_instance = $members_instance->get_restrictions_instance(); |
671 | 671 | $post_restrictions_instance = $restriction_instance->get_posts_restrictions_instance(); |
672 | - remove_action( 'wp', array( $post_restrictions_instance, 'handle_restriction_modes' ), 10, 1 ); |
|
673 | - add_action( 'body_class', array( $this, 'remove_body_classes' ) ); |
|
672 | + remove_action('wp', array($post_restrictions_instance, 'handle_restriction_modes'), 10, 1); |
|
673 | + add_action('body_class', array($this, 'remove_body_classes')); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
@@ -680,11 +680,11 @@ discard block |
||
680 | 680 | * @param array $classes |
681 | 681 | * @return void |
682 | 682 | */ |
683 | - public function remove_body_classes( $classes = array() ) { |
|
684 | - if ( ! empty( $classes ) ) { |
|
685 | - foreach ( $classes as $class_key => $class_value ) { |
|
686 | - if ( 'gutenberg-compatible-template' === $class_value || 'using-gutenberg' === $class_value ) { |
|
687 | - unset( $classes[ $class_key ] ); |
|
683 | + public function remove_body_classes($classes = array()) { |
|
684 | + if ( ! empty($classes)) { |
|
685 | + foreach ($classes as $class_key => $class_value) { |
|
686 | + if ('gutenberg-compatible-template' === $class_value || 'using-gutenberg' === $class_value) { |
|
687 | + unset($classes[$class_key]); |
|
688 | 688 | } |
689 | 689 | } |
690 | 690 | } |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | * @param array $classes |
698 | 698 | * @return void |
699 | 699 | */ |
700 | - public function hp_add_body_classes( $classes = array() ) { |
|
701 | - if ( is_checkout() ) { |
|
700 | + public function hp_add_body_classes($classes = array()) { |
|
701 | + if (is_checkout()) { |
|
702 | 702 | $classes[] = 'lsx-hp-simple-checkout'; |
703 | 703 | } |
704 | 704 | return $classes; |
@@ -711,14 +711,14 @@ discard block |
||
711 | 711 | * @return void |
712 | 712 | */ |
713 | 713 | public function hp_simple_checkout() { |
714 | - if ( is_checkout() ) { |
|
715 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
714 | + if (is_checkout()) { |
|
715 | + remove_action('lsx_footer_before', 'lsx_add_footer_sidebar_area'); |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | |
719 | 719 | public function lost_password_page_title() { |
720 | 720 | ?> |
721 | - <h1 class="lost-your-password-title"><?php esc_html_e( 'Lost your password?', 'lsx-health-plan' ); ?></h1> |
|
721 | + <h1 class="lost-your-password-title"><?php esc_html_e('Lost your password?', 'lsx-health-plan'); ?></h1> |
|
722 | 722 | <?php |
723 | 723 | } |
724 | 724 | |
@@ -728,9 +728,9 @@ discard block |
||
728 | 728 | * @return void |
729 | 729 | */ |
730 | 730 | public function hp_link_lsx_navbar_header() { |
731 | - if ( is_checkout() ) { |
|
732 | - $home_ulr = '<nav class="checkout-navbar"><ul class="nav navbar-nav"><li><a href="' . home_url() . '">' . __( 'Home', 'lsx-health-plan' ) . '</a></li></ul></nav>'; |
|
733 | - echo wp_kses_post( $home_ulr ); |
|
731 | + if (is_checkout()) { |
|
732 | + $home_ulr = '<nav class="checkout-navbar"><ul class="nav navbar-nav"><li><a href="' . home_url() . '">' . __('Home', 'lsx-health-plan') . '</a></li></ul></nav>'; |
|
733 | + echo wp_kses_post($home_ulr); |
|
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
@@ -746,16 +746,16 @@ discard block |
||
746 | 746 | ?> |
747 | 747 | <div class="row text-center vertical-align lsx-full-width-base-small checkout-cta-bottom"> |
748 | 748 | <div class="col-md-12 img-payfast"> |
749 | - <img src="<?php echo esc_url( $payfast_image ); ?>" alt="payfast"/> |
|
749 | + <img src="<?php echo esc_url($payfast_image); ?>" alt="payfast"/> |
|
750 | 750 | </div> |
751 | 751 | <div class="col-md-12 img-payments hidden-xs"> |
752 | - <img src="<?php echo esc_url( $payment_logos ); ?>" alt="payments"/> |
|
752 | + <img src="<?php echo esc_url($payment_logos); ?>" alt="payments"/> |
|
753 | 753 | </div> |
754 | 754 | <div class="col-md-12 img-payments hidden-sm hidden-md hidden-lg"> |
755 | - <img src="<?php echo esc_url( $payment_logos_mobile ); ?>" alt="payments"/> |
|
755 | + <img src="<?php echo esc_url($payment_logos_mobile); ?>" alt="payments"/> |
|
756 | 756 | </div> |
757 | 757 | <div class="col-md-12 img-encrypt"> |
758 | - <img src="<?php echo esc_url( $encript_image ); ?>" alt="lets_encrypt"/> |
|
758 | + <img src="<?php echo esc_url($encript_image); ?>" alt="lets_encrypt"/> |
|
759 | 759 | </div> |
760 | 760 | </div> |
761 | 761 |
@@ -8,401 +8,401 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class Woocommerce { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Woocommerce() |
|
17 | - */ |
|
18 | - protected static $instance = null; |
|
19 | - |
|
20 | - /** |
|
21 | - * Contructor |
|
22 | - */ |
|
23 | - public function __construct() { |
|
24 | - add_action( 'init', array( $this, 'init' ), 20, 1 ); |
|
25 | - add_filter( 'woocommerce_add_to_cart_validation', array( $this, 'only_one_in_cart' ), 99, 2 ); |
|
26 | - add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
27 | - add_filter( 'woocommerce_get_breadcrumb', array( $this, 'breadcrumbs' ), 30, 1 ); |
|
28 | - |
|
29 | - // Checkout. |
|
30 | - add_action( 'woocommerce_after_checkout_form', array( $this, 'payment_gateway_logos' ) ); |
|
31 | - add_action( 'body_class', array( $this, 'hp_add_body_classes' ) ); |
|
32 | - add_action( 'lsx_nav_before', array( $this, 'hp_link_lsx_navbar_header' ), 99 ); |
|
33 | - add_action( 'wp_head', array( $this, 'hp_simple_checkout' ), 99 ); |
|
34 | - |
|
35 | - // Redirect to the Edit Account Template. |
|
36 | - add_filter( 'template_include', array( $this, 'account_endpoint_redirect' ), 99 ); |
|
37 | - |
|
38 | - add_action( 'woocommerce_edit_account_form', array( $this, 'iconic_print_user_frontend_fields' ), 10 ); |
|
39 | - |
|
40 | - add_filter( 'iconic_account_fields', array( $this, 'iconic_add_post_data_to_account_fields' ), 10, 1 ); |
|
41 | - add_action( 'show_user_profile', array( $this, 'iconic_print_user_admin_fields' ), 30 ); |
|
42 | - |
|
43 | - add_action( 'personal_options_update', array( $this, 'iconic_save_account_fields' ) ); |
|
44 | - add_action( 'edit_user_profile_update', array( $this, 'iconic_save_account_fields' ) ); |
|
45 | - |
|
46 | - add_action( 'woocommerce_save_account_details', array( $this, 'iconic_save_account_fields' ) ); |
|
47 | - add_filter( 'woocommerce_save_account_details_errors', array( $this, 'iconic_validate_user_frontend_fields' ), 10 ); |
|
48 | - |
|
49 | - // Profile Fields. |
|
50 | - add_filter( 'woocommerce_form_field_text', array( $this, 'lsx_profile_photo_field_filter' ), 10, 4 ); |
|
51 | - add_action( 'woocommerce_after_edit_account_form', array( $this, 'action_woocommerce_after_edit_account_form' ), 10, 0 ); |
|
52 | - |
|
53 | - // Lost Password fields |
|
54 | - add_action( 'woocommerce_before_lost_password_form', array( $this, 'lost_password_page_title' ), 10 ); |
|
55 | - |
|
56 | - add_action( 'wp', array( $this, 'allow_reset_password_page' ), 9 ); |
|
57 | - |
|
58 | - add_filter( 'wc_add_to_cart_message_html', '__return_false' ); |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Return an instance of this class. |
|
63 | - * |
|
64 | - * @since 1.0.0 |
|
65 | - * |
|
66 | - * @return object \lsx_health_plan\classes\Woocommerce() A single instance of this class. |
|
67 | - */ |
|
68 | - public static function get_instance() { |
|
69 | - // If the single instance hasn't been set, set it now. |
|
70 | - if ( null === self::$instance ) { |
|
71 | - self::$instance = new self(); |
|
72 | - } |
|
73 | - return self::$instance; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Runs on init |
|
78 | - * |
|
79 | - * @return void |
|
80 | - */ |
|
81 | - public function init() { |
|
82 | - remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' ); |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Empties the cart before a product is added |
|
87 | - * |
|
88 | - * @param [type] $passed |
|
89 | - * @param [type] $added_product_id |
|
90 | - * @return void |
|
91 | - */ |
|
92 | - public function only_one_in_cart( $passed, $added_product_id ) { |
|
93 | - wc_empty_cart(); |
|
94 | - return $passed; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Return the Place Order Text |
|
99 | - * |
|
100 | - * @param string $label |
|
101 | - * @return void |
|
102 | - */ |
|
103 | - public function checkout_button_text( $label = '' ) { |
|
104 | - $label = __( 'Place order', 'lsx-health-plan' ); |
|
105 | - return $label; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Add the "Blog" link to the breadcrumbs |
|
110 | - * @param $crumbs |
|
111 | - * @return array |
|
112 | - */ |
|
113 | - public function breadcrumbs( $crumbs ) { |
|
114 | - |
|
115 | - if ( is_singular( 'plan' ) ) { |
|
116 | - |
|
117 | - $new_crumbs = array(); |
|
118 | - $new_crumbs[0] = $crumbs[0]; |
|
119 | - |
|
120 | - $new_crumbs[1] = array( |
|
121 | - 0 => get_the_title( wc_get_page_id( 'myaccount' ) ), |
|
122 | - 1 => get_permalink( wc_get_page_id( 'myaccount' ) ), |
|
123 | - ); |
|
124 | - |
|
125 | - $endpoint = get_query_var( 'endpoint' ); |
|
126 | - if ( '' === $endpoint || false === $endpoint ) { |
|
127 | - $new_crumbs[2] = array( |
|
128 | - 0 => get_the_title(), |
|
129 | - 1 => false, |
|
130 | - ); |
|
131 | - } else { |
|
132 | - $endpoint_translation = \lsx_health_plan\functions\get_option( 'endpoint_' . $endpoint, false ); |
|
133 | - if ( false !== $endpoint_translation && '' !== $endpoint_translation ) { |
|
134 | - $endpoint = $endpoint_translation; |
|
135 | - } |
|
136 | - $new_crumbs[2] = array( |
|
137 | - 0 => get_the_title(), |
|
138 | - 1 => get_permalink(), |
|
139 | - ); |
|
140 | - $new_crumbs[3] = array( |
|
141 | - 0 => ucwords( $endpoint ), |
|
142 | - 1 => false, |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - $crumbs = $new_crumbs; |
|
147 | - } |
|
148 | - return $crumbs; |
|
149 | - } |
|
150 | - |
|
151 | - /** |
|
152 | - * Redirects to the my account template. |
|
153 | - * |
|
154 | - * @param string $template |
|
155 | - * @return string |
|
156 | - */ |
|
157 | - public function account_endpoint_redirect( $template ) { |
|
158 | - if ( function_exists( 'is_account_page' ) && is_account_page() ) { |
|
159 | - if ( empty( locate_template( array( 'page-template-my-plan.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php' ) ) { |
|
160 | - $template = LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php'; |
|
161 | - } |
|
162 | - } |
|
163 | - return $template; |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Add post values to account fields if set. |
|
168 | - * |
|
169 | - * @param array $fields |
|
170 | - * |
|
171 | - * @return array |
|
172 | - */ |
|
173 | - public function iconic_add_post_data_to_account_fields( $fields ) { |
|
174 | - if ( empty( $_POST ) && wp_verify_nonce( sanitize_key( $_POST ) ) ) { |
|
175 | - return $fields; |
|
176 | - } |
|
177 | - |
|
178 | - foreach ( $fields as $key => $field_args ) { |
|
179 | - if ( isset( $_POST[ $key ] ) && empty( $_POST[ $key ] ) && wp_verify_nonce( sanitize_key( $_POST[ $key ] ) ) ) { |
|
180 | - $fields[ $key ]['value'] = ''; |
|
181 | - continue; |
|
182 | - } |
|
183 | - |
|
184 | - if ( isset( $_POST[ $key ] ) ) { |
|
185 | - $fields[ $key ]['value'] = sanitize_key( $_POST[ $key ] ); |
|
186 | - } |
|
187 | - } |
|
188 | - |
|
189 | - return $fields; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Add fields to registration form and account area. |
|
194 | - */ |
|
195 | - public function iconic_print_user_frontend_fields() { |
|
196 | - $fields = $this->get_account_fields(); |
|
197 | - $is_user_logged_in = is_user_logged_in(); |
|
198 | - |
|
199 | - $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
200 | - if ( 'on' !== $all_disabled ) { |
|
201 | - echo wp_kses_post( '<h2 class="title-lined my-stats-title">' . __( 'My Stats', 'lsx-health-plan' ) . '</h2>' ); |
|
202 | - echo wp_kses_post( '<div class="my-stats">' ); |
|
203 | - |
|
204 | - echo wp_kses_post( '<p class="form-row form-label">' . __( 'Start', 'lsx-health-plan' ) . '</p>' ); |
|
205 | - echo wp_kses_post( '<p class="form-row form-label">' . __( 'Goal', 'lsx-health-plan' ) . '</p>' ); |
|
206 | - echo wp_kses_post( '<p class="form-row form-label">' . __( 'End', 'lsx-health-plan' ) . '</p>' ); |
|
207 | - foreach ( $fields as $key => $field_args ) { |
|
208 | - $value = null; |
|
209 | - if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
210 | - continue; |
|
211 | - } |
|
212 | - if ( $is_user_logged_in ) { |
|
213 | - $user_id = $this->iconic_get_edit_user_id(); |
|
214 | - $value = $this->iconic_get_userdata( $user_id, $key ); |
|
215 | - } |
|
216 | - $value = ( isset( $field_args['value'] ) && '' !== $field_args['value'] ) ? $field_args['value'] : $value; |
|
217 | - woocommerce_form_field( $key, $field_args, $value ); |
|
218 | - } |
|
219 | - echo wp_kses_post( '</div>' ); |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * Get user data. |
|
225 | - * |
|
226 | - * @param $user_id |
|
227 | - * @param $key |
|
228 | - * |
|
229 | - * @return mixed|string |
|
230 | - */ |
|
231 | - public function iconic_get_userdata( $user_id, $key ) { |
|
232 | - if ( ! $this->iconic_is_userdata( $key ) ) { |
|
233 | - return get_user_meta( $user_id, $key, true ); |
|
234 | - } |
|
235 | - |
|
236 | - $userdata = get_userdata( $user_id ); |
|
237 | - |
|
238 | - if ( ! $userdata || ! isset( $userdata->{$key} ) ) { |
|
239 | - return ''; |
|
240 | - } |
|
241 | - |
|
242 | - return $userdata->{$key}; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Get currently editing user ID (frontend account/edit profile/edit other user). |
|
247 | - * |
|
248 | - * @return int |
|
249 | - */ |
|
250 | - public function iconic_get_edit_user_id() { |
|
251 | - return ( isset( $_GET['user_id'] ) && wp_verify_nonce( sanitize_key( $_GET['user_id'] ) ) ) ? (int) $_GET['user_id'] : get_current_user_id(); |
|
252 | - } |
|
253 | - |
|
254 | - |
|
255 | - /** |
|
256 | - * Save registration fields. |
|
257 | - * |
|
258 | - * @param int $customer_id |
|
259 | - */ |
|
260 | - public function iconic_save_account_fields( $customer_id ) { |
|
261 | - $nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. |
|
262 | - if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) { |
|
263 | - return; |
|
264 | - } |
|
265 | - |
|
266 | - $fields = $this->get_account_fields(); |
|
267 | - $sanitized_data = array(); |
|
268 | - foreach ( $fields as $key => $field_args ) { |
|
269 | - if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
270 | - continue; |
|
271 | - } |
|
272 | - |
|
273 | - $sanitize = isset( $field_args['sanitize'] ) ? $field_args['sanitize'] : 'wc_clean'; |
|
274 | - $value = ( isset( $_POST[ $key ] ) ) ? call_user_func( $sanitize, $_POST[ $key ] ) : ''; |
|
275 | - if ( $this->iconic_is_userdata( $key ) ) { |
|
276 | - |
|
277 | - $sanitized_data[ $key ] = $value; |
|
278 | - continue; |
|
279 | - } |
|
280 | - |
|
281 | - if ( 'profile_photo' === $key ) { |
|
282 | - // This handles the image uploads. |
|
283 | - require_once ABSPATH . 'wp-admin/includes/image.php'; |
|
284 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
285 | - require_once ABSPATH . 'wp-admin/includes/media.php'; |
|
286 | - |
|
287 | - $id = media_handle_upload( $key, 0, '' ); |
|
288 | - if ( ! is_wp_error( $id ) ) { |
|
289 | - update_term_meta( $customer_id, $key . '_id', $id ); |
|
290 | - update_term_meta( $customer_id, $key, $id ); |
|
291 | - } |
|
292 | - } else { |
|
293 | - delete_user_meta( $customer_id, $key ); |
|
294 | - update_user_meta( $customer_id, $key, $value ); |
|
295 | - } |
|
296 | - } |
|
297 | - |
|
298 | - if ( ! empty( $sanitized_data ) ) { |
|
299 | - $sanitized_data['ID'] = $customer_id; |
|
300 | - wp_update_user( $sanitized_data ); |
|
301 | - } |
|
302 | - } |
|
303 | - |
|
304 | - |
|
305 | - /** |
|
306 | - * Is this field core user data. |
|
307 | - * |
|
308 | - * @param $key |
|
309 | - * |
|
310 | - * @return bool |
|
311 | - */ |
|
312 | - public function iconic_is_userdata( $key ) { |
|
313 | - $userdata = array( |
|
314 | - 'user_pass', |
|
315 | - 'user_login', |
|
316 | - 'user_nicename', |
|
317 | - 'user_url', |
|
318 | - 'user_email', |
|
319 | - 'display_name', |
|
320 | - 'nickname', |
|
321 | - 'first_name', |
|
322 | - 'last_name', |
|
323 | - 'description', |
|
324 | - 'rich_editing', |
|
325 | - 'user_registered', |
|
326 | - 'role', |
|
327 | - 'jabber', |
|
328 | - 'aim', |
|
329 | - 'yim', |
|
330 | - 'show_admin_bar_front', |
|
331 | - ); |
|
332 | - |
|
333 | - return in_array( $key, $userdata, true ); |
|
334 | - } |
|
335 | - |
|
336 | - /** |
|
337 | - * Is field visible. |
|
338 | - * |
|
339 | - * @param $field_args |
|
340 | - * |
|
341 | - * @return bool |
|
342 | - */ |
|
343 | - public function iconic_is_field_visible( $field_args ) { |
|
344 | - $visible = true; |
|
345 | - $action = filter_input( INPUT_POST, 'action' ); |
|
346 | - |
|
347 | - if ( is_admin() && ! empty( $field_args['hide_in_admin'] ) ) { |
|
348 | - $visible = false; |
|
349 | - } elseif ( ( is_account_page() || 'save_account_details' === $action ) && is_user_logged_in() && ! empty( $field_args['hide_in_account'] ) ) { |
|
350 | - $visible = false; |
|
351 | - } elseif ( ( is_account_page() || 'save_account_details' === $action ) && ! is_user_logged_in() && ! empty( $field_args['hide_in_registration'] ) ) { |
|
352 | - $visible = false; |
|
353 | - } elseif ( is_checkout() && ! empty( $field_args['hide_in_checkout'] ) ) { |
|
354 | - $visible = false; |
|
355 | - } |
|
356 | - |
|
357 | - // Disable the fitness fields if needed. |
|
358 | - $weight_key = __( 'Weight:' ); |
|
359 | - $waist_key = __( 'Waist:' ); |
|
360 | - $fitness_key = __( 'Fitness Test Score:' ); |
|
361 | - if ( $weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label'] ) { |
|
362 | - |
|
363 | - // Check if all stats are disabled. |
|
364 | - $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
365 | - |
|
366 | - $option_key = ''; |
|
367 | - switch ( $field_args['label'] ) { |
|
368 | - case $weight_key: |
|
369 | - $option_key = 'disable_weight_checkbox'; |
|
370 | - break; |
|
371 | - |
|
372 | - case $waist_key: |
|
373 | - $option_key = 'disable_waist_checkbox'; |
|
374 | - break; |
|
375 | - |
|
376 | - case $fitness_key: |
|
377 | - $option_key = 'disable_fitness_checkbox'; |
|
378 | - break; |
|
379 | - } |
|
380 | - $is_disabled = \lsx_health_plan\functions\get_option( $option_key, false ); |
|
381 | - if ( 'on' === $all_disabled || 'on' === $is_disabled ) { |
|
382 | - $visible = false; |
|
383 | - } |
|
384 | - } |
|
385 | - return $visible; |
|
386 | - } |
|
387 | - |
|
388 | - /** |
|
389 | - * Add fields to admin area. |
|
390 | - */ |
|
391 | - public function iconic_print_user_admin_fields() { |
|
392 | - $fields = $this->get_account_fields(); |
|
393 | - ?> |
|
11 | + /** |
|
12 | + * Holds class instance |
|
13 | + * |
|
14 | + * @since 1.0.0 |
|
15 | + * |
|
16 | + * @var object \lsx_health_plan\classes\Woocommerce() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | + |
|
20 | + /** |
|
21 | + * Contructor |
|
22 | + */ |
|
23 | + public function __construct() { |
|
24 | + add_action( 'init', array( $this, 'init' ), 20, 1 ); |
|
25 | + add_filter( 'woocommerce_add_to_cart_validation', array( $this, 'only_one_in_cart' ), 99, 2 ); |
|
26 | + add_filter( 'woocommerce_order_button_text', array( $this, 'checkout_button_text' ), 10, 1 ); |
|
27 | + add_filter( 'woocommerce_get_breadcrumb', array( $this, 'breadcrumbs' ), 30, 1 ); |
|
28 | + |
|
29 | + // Checkout. |
|
30 | + add_action( 'woocommerce_after_checkout_form', array( $this, 'payment_gateway_logos' ) ); |
|
31 | + add_action( 'body_class', array( $this, 'hp_add_body_classes' ) ); |
|
32 | + add_action( 'lsx_nav_before', array( $this, 'hp_link_lsx_navbar_header' ), 99 ); |
|
33 | + add_action( 'wp_head', array( $this, 'hp_simple_checkout' ), 99 ); |
|
34 | + |
|
35 | + // Redirect to the Edit Account Template. |
|
36 | + add_filter( 'template_include', array( $this, 'account_endpoint_redirect' ), 99 ); |
|
37 | + |
|
38 | + add_action( 'woocommerce_edit_account_form', array( $this, 'iconic_print_user_frontend_fields' ), 10 ); |
|
39 | + |
|
40 | + add_filter( 'iconic_account_fields', array( $this, 'iconic_add_post_data_to_account_fields' ), 10, 1 ); |
|
41 | + add_action( 'show_user_profile', array( $this, 'iconic_print_user_admin_fields' ), 30 ); |
|
42 | + |
|
43 | + add_action( 'personal_options_update', array( $this, 'iconic_save_account_fields' ) ); |
|
44 | + add_action( 'edit_user_profile_update', array( $this, 'iconic_save_account_fields' ) ); |
|
45 | + |
|
46 | + add_action( 'woocommerce_save_account_details', array( $this, 'iconic_save_account_fields' ) ); |
|
47 | + add_filter( 'woocommerce_save_account_details_errors', array( $this, 'iconic_validate_user_frontend_fields' ), 10 ); |
|
48 | + |
|
49 | + // Profile Fields. |
|
50 | + add_filter( 'woocommerce_form_field_text', array( $this, 'lsx_profile_photo_field_filter' ), 10, 4 ); |
|
51 | + add_action( 'woocommerce_after_edit_account_form', array( $this, 'action_woocommerce_after_edit_account_form' ), 10, 0 ); |
|
52 | + |
|
53 | + // Lost Password fields |
|
54 | + add_action( 'woocommerce_before_lost_password_form', array( $this, 'lost_password_page_title' ), 10 ); |
|
55 | + |
|
56 | + add_action( 'wp', array( $this, 'allow_reset_password_page' ), 9 ); |
|
57 | + |
|
58 | + add_filter( 'wc_add_to_cart_message_html', '__return_false' ); |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Return an instance of this class. |
|
63 | + * |
|
64 | + * @since 1.0.0 |
|
65 | + * |
|
66 | + * @return object \lsx_health_plan\classes\Woocommerce() A single instance of this class. |
|
67 | + */ |
|
68 | + public static function get_instance() { |
|
69 | + // If the single instance hasn't been set, set it now. |
|
70 | + if ( null === self::$instance ) { |
|
71 | + self::$instance = new self(); |
|
72 | + } |
|
73 | + return self::$instance; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Runs on init |
|
78 | + * |
|
79 | + * @return void |
|
80 | + */ |
|
81 | + public function init() { |
|
82 | + remove_action( 'woocommerce_account_navigation', 'woocommerce_account_navigation' ); |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Empties the cart before a product is added |
|
87 | + * |
|
88 | + * @param [type] $passed |
|
89 | + * @param [type] $added_product_id |
|
90 | + * @return void |
|
91 | + */ |
|
92 | + public function only_one_in_cart( $passed, $added_product_id ) { |
|
93 | + wc_empty_cart(); |
|
94 | + return $passed; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Return the Place Order Text |
|
99 | + * |
|
100 | + * @param string $label |
|
101 | + * @return void |
|
102 | + */ |
|
103 | + public function checkout_button_text( $label = '' ) { |
|
104 | + $label = __( 'Place order', 'lsx-health-plan' ); |
|
105 | + return $label; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Add the "Blog" link to the breadcrumbs |
|
110 | + * @param $crumbs |
|
111 | + * @return array |
|
112 | + */ |
|
113 | + public function breadcrumbs( $crumbs ) { |
|
114 | + |
|
115 | + if ( is_singular( 'plan' ) ) { |
|
116 | + |
|
117 | + $new_crumbs = array(); |
|
118 | + $new_crumbs[0] = $crumbs[0]; |
|
119 | + |
|
120 | + $new_crumbs[1] = array( |
|
121 | + 0 => get_the_title( wc_get_page_id( 'myaccount' ) ), |
|
122 | + 1 => get_permalink( wc_get_page_id( 'myaccount' ) ), |
|
123 | + ); |
|
124 | + |
|
125 | + $endpoint = get_query_var( 'endpoint' ); |
|
126 | + if ( '' === $endpoint || false === $endpoint ) { |
|
127 | + $new_crumbs[2] = array( |
|
128 | + 0 => get_the_title(), |
|
129 | + 1 => false, |
|
130 | + ); |
|
131 | + } else { |
|
132 | + $endpoint_translation = \lsx_health_plan\functions\get_option( 'endpoint_' . $endpoint, false ); |
|
133 | + if ( false !== $endpoint_translation && '' !== $endpoint_translation ) { |
|
134 | + $endpoint = $endpoint_translation; |
|
135 | + } |
|
136 | + $new_crumbs[2] = array( |
|
137 | + 0 => get_the_title(), |
|
138 | + 1 => get_permalink(), |
|
139 | + ); |
|
140 | + $new_crumbs[3] = array( |
|
141 | + 0 => ucwords( $endpoint ), |
|
142 | + 1 => false, |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + $crumbs = $new_crumbs; |
|
147 | + } |
|
148 | + return $crumbs; |
|
149 | + } |
|
150 | + |
|
151 | + /** |
|
152 | + * Redirects to the my account template. |
|
153 | + * |
|
154 | + * @param string $template |
|
155 | + * @return string |
|
156 | + */ |
|
157 | + public function account_endpoint_redirect( $template ) { |
|
158 | + if ( function_exists( 'is_account_page' ) && is_account_page() ) { |
|
159 | + if ( empty( locate_template( array( 'page-template-my-plan.php' ) ) ) && file_exists( LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php' ) ) { |
|
160 | + $template = LSX_HEALTH_PLAN_PATH . 'templates/page-template-my-plan.php'; |
|
161 | + } |
|
162 | + } |
|
163 | + return $template; |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Add post values to account fields if set. |
|
168 | + * |
|
169 | + * @param array $fields |
|
170 | + * |
|
171 | + * @return array |
|
172 | + */ |
|
173 | + public function iconic_add_post_data_to_account_fields( $fields ) { |
|
174 | + if ( empty( $_POST ) && wp_verify_nonce( sanitize_key( $_POST ) ) ) { |
|
175 | + return $fields; |
|
176 | + } |
|
177 | + |
|
178 | + foreach ( $fields as $key => $field_args ) { |
|
179 | + if ( isset( $_POST[ $key ] ) && empty( $_POST[ $key ] ) && wp_verify_nonce( sanitize_key( $_POST[ $key ] ) ) ) { |
|
180 | + $fields[ $key ]['value'] = ''; |
|
181 | + continue; |
|
182 | + } |
|
183 | + |
|
184 | + if ( isset( $_POST[ $key ] ) ) { |
|
185 | + $fields[ $key ]['value'] = sanitize_key( $_POST[ $key ] ); |
|
186 | + } |
|
187 | + } |
|
188 | + |
|
189 | + return $fields; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Add fields to registration form and account area. |
|
194 | + */ |
|
195 | + public function iconic_print_user_frontend_fields() { |
|
196 | + $fields = $this->get_account_fields(); |
|
197 | + $is_user_logged_in = is_user_logged_in(); |
|
198 | + |
|
199 | + $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
200 | + if ( 'on' !== $all_disabled ) { |
|
201 | + echo wp_kses_post( '<h2 class="title-lined my-stats-title">' . __( 'My Stats', 'lsx-health-plan' ) . '</h2>' ); |
|
202 | + echo wp_kses_post( '<div class="my-stats">' ); |
|
203 | + |
|
204 | + echo wp_kses_post( '<p class="form-row form-label">' . __( 'Start', 'lsx-health-plan' ) . '</p>' ); |
|
205 | + echo wp_kses_post( '<p class="form-row form-label">' . __( 'Goal', 'lsx-health-plan' ) . '</p>' ); |
|
206 | + echo wp_kses_post( '<p class="form-row form-label">' . __( 'End', 'lsx-health-plan' ) . '</p>' ); |
|
207 | + foreach ( $fields as $key => $field_args ) { |
|
208 | + $value = null; |
|
209 | + if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
210 | + continue; |
|
211 | + } |
|
212 | + if ( $is_user_logged_in ) { |
|
213 | + $user_id = $this->iconic_get_edit_user_id(); |
|
214 | + $value = $this->iconic_get_userdata( $user_id, $key ); |
|
215 | + } |
|
216 | + $value = ( isset( $field_args['value'] ) && '' !== $field_args['value'] ) ? $field_args['value'] : $value; |
|
217 | + woocommerce_form_field( $key, $field_args, $value ); |
|
218 | + } |
|
219 | + echo wp_kses_post( '</div>' ); |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * Get user data. |
|
225 | + * |
|
226 | + * @param $user_id |
|
227 | + * @param $key |
|
228 | + * |
|
229 | + * @return mixed|string |
|
230 | + */ |
|
231 | + public function iconic_get_userdata( $user_id, $key ) { |
|
232 | + if ( ! $this->iconic_is_userdata( $key ) ) { |
|
233 | + return get_user_meta( $user_id, $key, true ); |
|
234 | + } |
|
235 | + |
|
236 | + $userdata = get_userdata( $user_id ); |
|
237 | + |
|
238 | + if ( ! $userdata || ! isset( $userdata->{$key} ) ) { |
|
239 | + return ''; |
|
240 | + } |
|
241 | + |
|
242 | + return $userdata->{$key}; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Get currently editing user ID (frontend account/edit profile/edit other user). |
|
247 | + * |
|
248 | + * @return int |
|
249 | + */ |
|
250 | + public function iconic_get_edit_user_id() { |
|
251 | + return ( isset( $_GET['user_id'] ) && wp_verify_nonce( sanitize_key( $_GET['user_id'] ) ) ) ? (int) $_GET['user_id'] : get_current_user_id(); |
|
252 | + } |
|
253 | + |
|
254 | + |
|
255 | + /** |
|
256 | + * Save registration fields. |
|
257 | + * |
|
258 | + * @param int $customer_id |
|
259 | + */ |
|
260 | + public function iconic_save_account_fields( $customer_id ) { |
|
261 | + $nonce_value = wc_get_var( $_REQUEST['save-account-details-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine. |
|
262 | + if ( ! wp_verify_nonce( $nonce_value, 'save_account_details' ) ) { |
|
263 | + return; |
|
264 | + } |
|
265 | + |
|
266 | + $fields = $this->get_account_fields(); |
|
267 | + $sanitized_data = array(); |
|
268 | + foreach ( $fields as $key => $field_args ) { |
|
269 | + if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
270 | + continue; |
|
271 | + } |
|
272 | + |
|
273 | + $sanitize = isset( $field_args['sanitize'] ) ? $field_args['sanitize'] : 'wc_clean'; |
|
274 | + $value = ( isset( $_POST[ $key ] ) ) ? call_user_func( $sanitize, $_POST[ $key ] ) : ''; |
|
275 | + if ( $this->iconic_is_userdata( $key ) ) { |
|
276 | + |
|
277 | + $sanitized_data[ $key ] = $value; |
|
278 | + continue; |
|
279 | + } |
|
280 | + |
|
281 | + if ( 'profile_photo' === $key ) { |
|
282 | + // This handles the image uploads. |
|
283 | + require_once ABSPATH . 'wp-admin/includes/image.php'; |
|
284 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
285 | + require_once ABSPATH . 'wp-admin/includes/media.php'; |
|
286 | + |
|
287 | + $id = media_handle_upload( $key, 0, '' ); |
|
288 | + if ( ! is_wp_error( $id ) ) { |
|
289 | + update_term_meta( $customer_id, $key . '_id', $id ); |
|
290 | + update_term_meta( $customer_id, $key, $id ); |
|
291 | + } |
|
292 | + } else { |
|
293 | + delete_user_meta( $customer_id, $key ); |
|
294 | + update_user_meta( $customer_id, $key, $value ); |
|
295 | + } |
|
296 | + } |
|
297 | + |
|
298 | + if ( ! empty( $sanitized_data ) ) { |
|
299 | + $sanitized_data['ID'] = $customer_id; |
|
300 | + wp_update_user( $sanitized_data ); |
|
301 | + } |
|
302 | + } |
|
303 | + |
|
304 | + |
|
305 | + /** |
|
306 | + * Is this field core user data. |
|
307 | + * |
|
308 | + * @param $key |
|
309 | + * |
|
310 | + * @return bool |
|
311 | + */ |
|
312 | + public function iconic_is_userdata( $key ) { |
|
313 | + $userdata = array( |
|
314 | + 'user_pass', |
|
315 | + 'user_login', |
|
316 | + 'user_nicename', |
|
317 | + 'user_url', |
|
318 | + 'user_email', |
|
319 | + 'display_name', |
|
320 | + 'nickname', |
|
321 | + 'first_name', |
|
322 | + 'last_name', |
|
323 | + 'description', |
|
324 | + 'rich_editing', |
|
325 | + 'user_registered', |
|
326 | + 'role', |
|
327 | + 'jabber', |
|
328 | + 'aim', |
|
329 | + 'yim', |
|
330 | + 'show_admin_bar_front', |
|
331 | + ); |
|
332 | + |
|
333 | + return in_array( $key, $userdata, true ); |
|
334 | + } |
|
335 | + |
|
336 | + /** |
|
337 | + * Is field visible. |
|
338 | + * |
|
339 | + * @param $field_args |
|
340 | + * |
|
341 | + * @return bool |
|
342 | + */ |
|
343 | + public function iconic_is_field_visible( $field_args ) { |
|
344 | + $visible = true; |
|
345 | + $action = filter_input( INPUT_POST, 'action' ); |
|
346 | + |
|
347 | + if ( is_admin() && ! empty( $field_args['hide_in_admin'] ) ) { |
|
348 | + $visible = false; |
|
349 | + } elseif ( ( is_account_page() || 'save_account_details' === $action ) && is_user_logged_in() && ! empty( $field_args['hide_in_account'] ) ) { |
|
350 | + $visible = false; |
|
351 | + } elseif ( ( is_account_page() || 'save_account_details' === $action ) && ! is_user_logged_in() && ! empty( $field_args['hide_in_registration'] ) ) { |
|
352 | + $visible = false; |
|
353 | + } elseif ( is_checkout() && ! empty( $field_args['hide_in_checkout'] ) ) { |
|
354 | + $visible = false; |
|
355 | + } |
|
356 | + |
|
357 | + // Disable the fitness fields if needed. |
|
358 | + $weight_key = __( 'Weight:' ); |
|
359 | + $waist_key = __( 'Waist:' ); |
|
360 | + $fitness_key = __( 'Fitness Test Score:' ); |
|
361 | + if ( $weight_key === $field_args['label'] || $waist_key === $field_args['label'] || $fitness_key === $field_args['label'] ) { |
|
362 | + |
|
363 | + // Check if all stats are disabled. |
|
364 | + $all_disabled = \lsx_health_plan\functions\get_option( 'disable_all_stats', false ); |
|
365 | + |
|
366 | + $option_key = ''; |
|
367 | + switch ( $field_args['label'] ) { |
|
368 | + case $weight_key: |
|
369 | + $option_key = 'disable_weight_checkbox'; |
|
370 | + break; |
|
371 | + |
|
372 | + case $waist_key: |
|
373 | + $option_key = 'disable_waist_checkbox'; |
|
374 | + break; |
|
375 | + |
|
376 | + case $fitness_key: |
|
377 | + $option_key = 'disable_fitness_checkbox'; |
|
378 | + break; |
|
379 | + } |
|
380 | + $is_disabled = \lsx_health_plan\functions\get_option( $option_key, false ); |
|
381 | + if ( 'on' === $all_disabled || 'on' === $is_disabled ) { |
|
382 | + $visible = false; |
|
383 | + } |
|
384 | + } |
|
385 | + return $visible; |
|
386 | + } |
|
387 | + |
|
388 | + /** |
|
389 | + * Add fields to admin area. |
|
390 | + */ |
|
391 | + public function iconic_print_user_admin_fields() { |
|
392 | + $fields = $this->get_account_fields(); |
|
393 | + ?> |
|
394 | 394 | <h2><?php esc_html_e( 'Additional Information', 'lsx-health-plan' ); ?></h2> |
395 | 395 | <table class="form-table" id="iconic-additional-information"> |
396 | 396 | <tbody> |
397 | 397 | <?php foreach ( $fields as $key => $field_args ) { ?> |
398 | 398 | <?php |
399 | - if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
400 | - continue; |
|
401 | - } |
|
399 | + if ( ! $this->iconic_is_field_visible( $field_args ) ) { |
|
400 | + continue; |
|
401 | + } |
|
402 | 402 | |
403 | - $user_id = $this->iconic_get_edit_user_id(); |
|
404 | - $value = get_user_meta( $user_id, $key, true ); |
|
405 | - ?> |
|
403 | + $user_id = $this->iconic_get_edit_user_id(); |
|
404 | + $value = get_user_meta( $user_id, $key, true ); |
|
405 | + ?> |
|
406 | 406 | <tr> |
407 | 407 | <th> |
408 | 408 | <label for="<?php echo esc_html( $key ); ?>"><?php echo esc_html( $field_args['label'] ); ?></label> |
@@ -416,334 +416,334 @@ discard block |
||
416 | 416 | </tbody> |
417 | 417 | </table> |
418 | 418 | <?php |
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * Validate fields on frontend. |
|
423 | - * |
|
424 | - * @param WP_Error $errors |
|
425 | - * |
|
426 | - * @return WP_Error |
|
427 | - */ |
|
428 | - public function iconic_validate_user_frontend_fields( $errors ) { |
|
429 | - $fields = $this->get_account_fields(); |
|
430 | - |
|
431 | - foreach ( $fields as $key => $field_args ) { |
|
432 | - if ( empty( $field_args['required'] ) ) { |
|
433 | - continue; |
|
434 | - } |
|
435 | - |
|
436 | - /*if ( ! isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_account'] ) ) { |
|
419 | + } |
|
420 | + |
|
421 | + /** |
|
422 | + * Validate fields on frontend. |
|
423 | + * |
|
424 | + * @param WP_Error $errors |
|
425 | + * |
|
426 | + * @return WP_Error |
|
427 | + */ |
|
428 | + public function iconic_validate_user_frontend_fields( $errors ) { |
|
429 | + $fields = $this->get_account_fields(); |
|
430 | + |
|
431 | + foreach ( $fields as $key => $field_args ) { |
|
432 | + if ( empty( $field_args['required'] ) ) { |
|
433 | + continue; |
|
434 | + } |
|
435 | + |
|
436 | + /*if ( ! isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_account'] ) ) { |
|
437 | 437 | continue; |
438 | 438 | }*/ |
439 | 439 | |
440 | - if ( isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_registration'] ) ) { |
|
441 | - continue; |
|
442 | - } |
|
443 | - |
|
444 | - if ( empty( $_POST[ $key ] ) ) { |
|
445 | - /* translators: %s: field */ |
|
446 | - $message = sprintf( __( '%s is a required field.', 'lsx-health-plan' ), '<strong>' . $field_args['label'] . '</strong>' ); |
|
447 | - $errors->add( $key, $message ); |
|
448 | - } |
|
449 | - } |
|
450 | - |
|
451 | - return $errors; |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * Changes the text into a file upload. |
|
456 | - * @param $field |
|
457 | - * @param $key |
|
458 | - * @param $args |
|
459 | - * @param $value |
|
460 | - * |
|
461 | - * @return mixed |
|
462 | - */ |
|
463 | - public function lsx_profile_photo_field_filter( $field, $key, $args, $value ) { |
|
464 | - if ( 'profile_photo' === $args['id'] ) { |
|
465 | - |
|
466 | - if ( $args['required'] ) { |
|
467 | - $args['class'][] = 'validate-required'; |
|
468 | - $required = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>'; |
|
469 | - } else { |
|
470 | - $required = ''; |
|
471 | - } |
|
472 | - |
|
473 | - if ( is_string( $args['label_class'] ) ) { |
|
474 | - $args['label_class'] = array( $args['label_class'] ); |
|
475 | - } |
|
476 | - |
|
477 | - if ( is_null( $value ) ) { |
|
478 | - $value = $args['default']; |
|
479 | - } |
|
480 | - |
|
481 | - // Custom attribute handling. |
|
482 | - $custom_attributes = array(); |
|
483 | - $args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' ); |
|
484 | - |
|
485 | - if ( $args['maxlength'] ) { |
|
486 | - $args['custom_attributes']['maxlength'] = absint( $args['maxlength'] ); |
|
487 | - } |
|
488 | - |
|
489 | - if ( ! empty( $args['autocomplete'] ) ) { |
|
490 | - $args['custom_attributes']['autocomplete'] = $args['autocomplete']; |
|
491 | - } |
|
492 | - |
|
493 | - if ( true === $args['autofocus'] ) { |
|
494 | - $args['custom_attributes']['autofocus'] = 'autofocus'; |
|
495 | - } |
|
496 | - |
|
497 | - if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) { |
|
498 | - foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) { |
|
499 | - $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
500 | - } |
|
501 | - } |
|
502 | - |
|
503 | - if ( ! empty( $args['validate'] ) ) { |
|
504 | - foreach ( $args['validate'] as $validate ) { |
|
505 | - $args['class'][] = 'validate-' . $validate; |
|
506 | - } |
|
507 | - } |
|
508 | - |
|
509 | - $field_html = ''; |
|
510 | - $field = ''; |
|
511 | - $label_id = $args['id']; |
|
512 | - $sort = $args['priority'] ? $args['priority'] : ''; |
|
513 | - $field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>'; |
|
514 | - $args['class'][] = 'validate-required'; |
|
515 | - $required = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>'; |
|
516 | - |
|
517 | - $field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' />'; |
|
518 | - |
|
519 | - if ( '' !== $value && $value !== $args['default'] ) { |
|
520 | - $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '_id" id="' . esc_attr( $args['id'] ) . '_id" placeholder="' . esc_attr( $args['placeholder'] ) . '_id" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />'; |
|
521 | - } |
|
522 | - |
|
523 | - $field .= '<input type="hidden" name="MAX_FILE_SIZE" value="500000" />'; |
|
524 | - |
|
525 | - if ( $args['label'] && 'checkbox' !== $args['type'] ) { |
|
526 | - $field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>'; |
|
527 | - } |
|
528 | - |
|
529 | - $field_html .= $field; |
|
530 | - |
|
531 | - if ( $args['description'] ) { |
|
532 | - $field_html .= '<span class="description">' . esc_html( $args['description'] ) . '</span>'; |
|
533 | - } |
|
534 | - |
|
535 | - $container_class = esc_attr( implode( ' ', $args['class'] ) ); |
|
536 | - $container_id = esc_attr( $args['id'] ) . '_field'; |
|
537 | - $field = sprintf( $field_container, $container_class, $container_id, $field_html ); |
|
538 | - } |
|
539 | - return $field; |
|
540 | - } |
|
541 | - |
|
542 | - |
|
543 | - public function action_woocommerce_after_edit_account_form() { |
|
544 | - echo do_shortcode( '[avatar_upload /]' ); |
|
545 | - } |
|
546 | - |
|
547 | - /** |
|
548 | - * Get additional account fields. |
|
549 | - * |
|
550 | - * @return array |
|
551 | - */ |
|
552 | - public function get_account_fields() { |
|
553 | - $account_fields = apply_filters( 'iconic_account_fields', array( |
|
554 | - 'weight_start' => array( |
|
555 | - 'type' => 'text', |
|
556 | - 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
557 | - 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
558 | - 'hide_in_account' => false, |
|
559 | - 'hide_in_admin' => false, |
|
560 | - 'hide_in_checkout' => false, |
|
561 | - 'hide_in_registration' => false, |
|
562 | - 'required' => false, |
|
563 | - ), |
|
564 | - 'weight_goal' => array( |
|
565 | - 'type' => 'text', |
|
566 | - 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
567 | - 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
568 | - 'hide_in_account' => false, |
|
569 | - 'hide_in_admin' => false, |
|
570 | - 'hide_in_checkout' => false, |
|
571 | - 'hide_in_registration' => false, |
|
572 | - 'required' => false, |
|
573 | - ), |
|
574 | - 'weight_end' => array( |
|
575 | - 'type' => 'text', |
|
576 | - 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
577 | - 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
578 | - 'hide_in_account' => false, |
|
579 | - 'hide_in_admin' => false, |
|
580 | - 'hide_in_checkout' => false, |
|
581 | - 'hide_in_registration' => false, |
|
582 | - 'required' => false, |
|
583 | - ), |
|
584 | - 'waist_start' => array( |
|
585 | - 'type' => 'text', |
|
586 | - 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
587 | - 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
588 | - 'hide_in_account' => false, |
|
589 | - 'hide_in_admin' => false, |
|
590 | - 'hide_in_checkout' => false, |
|
591 | - 'hide_in_registration' => false, |
|
592 | - 'required' => false, |
|
593 | - ), |
|
594 | - 'waist_goal' => array( |
|
595 | - 'type' => 'text', |
|
596 | - 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
597 | - 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
598 | - 'hide_in_account' => false, |
|
599 | - 'hide_in_admin' => false, |
|
600 | - 'hide_in_checkout' => false, |
|
601 | - 'hide_in_registration' => false, |
|
602 | - 'required' => false, |
|
603 | - ), |
|
604 | - 'waist_end' => array( |
|
605 | - 'type' => 'text', |
|
606 | - 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
607 | - 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
608 | - 'hide_in_account' => false, |
|
609 | - 'hide_in_admin' => false, |
|
610 | - 'hide_in_checkout' => false, |
|
611 | - 'hide_in_registration' => false, |
|
612 | - 'required' => false, |
|
613 | - ), |
|
614 | - 'fitness_start' => array( |
|
615 | - 'type' => 'text', |
|
616 | - 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
617 | - 'placeholder' => '#', |
|
618 | - 'hide_in_account' => false, |
|
619 | - 'hide_in_admin' => false, |
|
620 | - 'hide_in_checkout' => false, |
|
621 | - 'hide_in_registration' => false, |
|
622 | - 'required' => false, |
|
623 | - ), |
|
624 | - 'fitness_goal' => array( |
|
625 | - 'type' => 'text', |
|
626 | - 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
627 | - 'placeholder' => '#', |
|
628 | - 'hide_in_account' => false, |
|
629 | - 'hide_in_admin' => false, |
|
630 | - 'hide_in_checkout' => false, |
|
631 | - 'hide_in_registration' => false, |
|
632 | - 'required' => false, |
|
633 | - ), |
|
634 | - 'fitness_end' => array( |
|
635 | - 'type' => 'text', |
|
636 | - 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
637 | - 'placeholder' => '#', |
|
638 | - 'hide_in_account' => false, |
|
639 | - 'hide_in_admin' => false, |
|
640 | - 'hide_in_checkout' => false, |
|
641 | - 'hide_in_registration' => false, |
|
642 | - 'required' => false, |
|
643 | - ), |
|
644 | - ) ); |
|
645 | - |
|
646 | - $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false ); |
|
647 | - if ( 'on' === $is_weight_disabled ) { |
|
648 | - $account_fields['weight_start']['required'] = false; |
|
649 | - $account_fields['weight_goal']['required'] = false; |
|
650 | - $account_fields['weight_end']['required'] = false; |
|
651 | - } |
|
652 | - $is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false ); |
|
653 | - if ( 'on' === $is_waist_disabled ) { |
|
654 | - $account_fields['waist_start']['required'] = false; |
|
655 | - $account_fields['waist_goal']['required'] = false; |
|
656 | - $account_fields['waist_end']['required'] = false; |
|
657 | - } |
|
658 | - return $account_fields; |
|
659 | - } |
|
660 | - |
|
661 | - /** |
|
662 | - * Removes the content restriction class to allow the password page to show. |
|
663 | - * |
|
664 | - * @return void |
|
665 | - */ |
|
666 | - public function allow_reset_password_page() { |
|
667 | - if ( ! is_user_logged_in() && function_exists( 'wc_memberships' ) && is_wc_endpoint_url( 'lost-password' ) ) { |
|
668 | - |
|
669 | - $members_instance = wc_memberships(); |
|
670 | - $restriction_instance = $members_instance->get_restrictions_instance(); |
|
671 | - $post_restrictions_instance = $restriction_instance->get_posts_restrictions_instance(); |
|
672 | - remove_action( 'wp', array( $post_restrictions_instance, 'handle_restriction_modes' ), 10, 1 ); |
|
673 | - add_action( 'body_class', array( $this, 'remove_body_classes' ) ); |
|
674 | - } |
|
675 | - } |
|
676 | - |
|
677 | - /** |
|
678 | - * Remove the gutenberg classes from the lost password page. |
|
679 | - * |
|
680 | - * @param array $classes |
|
681 | - * @return void |
|
682 | - */ |
|
683 | - public function remove_body_classes( $classes = array() ) { |
|
684 | - if ( ! empty( $classes ) ) { |
|
685 | - foreach ( $classes as $class_key => $class_value ) { |
|
686 | - if ( 'gutenberg-compatible-template' === $class_value || 'using-gutenberg' === $class_value ) { |
|
687 | - unset( $classes[ $class_key ] ); |
|
688 | - } |
|
689 | - } |
|
690 | - } |
|
691 | - return $classes; |
|
692 | - } |
|
693 | - |
|
694 | - /** |
|
695 | - * Add 'lsx-simple-checkout' class to body if it is woocommerce checkout page. |
|
696 | - * |
|
697 | - * @param array $classes |
|
698 | - * @return void |
|
699 | - */ |
|
700 | - public function hp_add_body_classes( $classes = array() ) { |
|
701 | - if ( is_checkout() ) { |
|
702 | - $classes[] = 'lsx-hp-simple-checkout'; |
|
703 | - } |
|
704 | - return $classes; |
|
705 | - } |
|
706 | - |
|
707 | - /** |
|
708 | - * Remove unnecessary items for simple woocommerce checkout page. |
|
709 | - * |
|
710 | - * @param array $classes |
|
711 | - * @return void |
|
712 | - */ |
|
713 | - public function hp_simple_checkout() { |
|
714 | - if ( is_checkout() ) { |
|
715 | - remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
716 | - } |
|
717 | - } |
|
718 | - |
|
719 | - public function lost_password_page_title() { |
|
720 | - ?> |
|
440 | + if ( isset( $_POST['register'] ) && wp_verify_nonce( sanitize_key( $_POST['register'] ) ) && ! empty( $field_args['hide_in_registration'] ) ) { |
|
441 | + continue; |
|
442 | + } |
|
443 | + |
|
444 | + if ( empty( $_POST[ $key ] ) ) { |
|
445 | + /* translators: %s: field */ |
|
446 | + $message = sprintf( __( '%s is a required field.', 'lsx-health-plan' ), '<strong>' . $field_args['label'] . '</strong>' ); |
|
447 | + $errors->add( $key, $message ); |
|
448 | + } |
|
449 | + } |
|
450 | + |
|
451 | + return $errors; |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * Changes the text into a file upload. |
|
456 | + * @param $field |
|
457 | + * @param $key |
|
458 | + * @param $args |
|
459 | + * @param $value |
|
460 | + * |
|
461 | + * @return mixed |
|
462 | + */ |
|
463 | + public function lsx_profile_photo_field_filter( $field, $key, $args, $value ) { |
|
464 | + if ( 'profile_photo' === $args['id'] ) { |
|
465 | + |
|
466 | + if ( $args['required'] ) { |
|
467 | + $args['class'][] = 'validate-required'; |
|
468 | + $required = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>'; |
|
469 | + } else { |
|
470 | + $required = ''; |
|
471 | + } |
|
472 | + |
|
473 | + if ( is_string( $args['label_class'] ) ) { |
|
474 | + $args['label_class'] = array( $args['label_class'] ); |
|
475 | + } |
|
476 | + |
|
477 | + if ( is_null( $value ) ) { |
|
478 | + $value = $args['default']; |
|
479 | + } |
|
480 | + |
|
481 | + // Custom attribute handling. |
|
482 | + $custom_attributes = array(); |
|
483 | + $args['custom_attributes'] = array_filter( (array) $args['custom_attributes'], 'strlen' ); |
|
484 | + |
|
485 | + if ( $args['maxlength'] ) { |
|
486 | + $args['custom_attributes']['maxlength'] = absint( $args['maxlength'] ); |
|
487 | + } |
|
488 | + |
|
489 | + if ( ! empty( $args['autocomplete'] ) ) { |
|
490 | + $args['custom_attributes']['autocomplete'] = $args['autocomplete']; |
|
491 | + } |
|
492 | + |
|
493 | + if ( true === $args['autofocus'] ) { |
|
494 | + $args['custom_attributes']['autofocus'] = 'autofocus'; |
|
495 | + } |
|
496 | + |
|
497 | + if ( ! empty( $args['custom_attributes'] ) && is_array( $args['custom_attributes'] ) ) { |
|
498 | + foreach ( $args['custom_attributes'] as $attribute => $attribute_value ) { |
|
499 | + $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"'; |
|
500 | + } |
|
501 | + } |
|
502 | + |
|
503 | + if ( ! empty( $args['validate'] ) ) { |
|
504 | + foreach ( $args['validate'] as $validate ) { |
|
505 | + $args['class'][] = 'validate-' . $validate; |
|
506 | + } |
|
507 | + } |
|
508 | + |
|
509 | + $field_html = ''; |
|
510 | + $field = ''; |
|
511 | + $label_id = $args['id']; |
|
512 | + $sort = $args['priority'] ? $args['priority'] : ''; |
|
513 | + $field_container = '<p class="form-row %1$s" id="%2$s" data-priority="' . esc_attr( $sort ) . '">%3$s</p>'; |
|
514 | + $args['class'][] = 'validate-required'; |
|
515 | + $required = ' <abbr class="required" title="' . esc_attr__( 'required', 'lsx-health-plan' ) . '">*</abbr>'; |
|
516 | + |
|
517 | + $field .= '<input accept="image/*" type="file" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '" id="' . esc_attr( $args['id'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" value="" ' . implode( ' ', $custom_attributes ) . ' />'; |
|
518 | + |
|
519 | + if ( '' !== $value && $value !== $args['default'] ) { |
|
520 | + $field .= '<input type="text" class="input-text ' . esc_attr( implode( ' ', $args['input_class'] ) ) . '" name="' . esc_attr( $key ) . '_id" id="' . esc_attr( $args['id'] ) . '_id" placeholder="' . esc_attr( $args['placeholder'] ) . '_id" value="' . esc_attr( $value ) . '" ' . implode( ' ', $custom_attributes ) . ' />'; |
|
521 | + } |
|
522 | + |
|
523 | + $field .= '<input type="hidden" name="MAX_FILE_SIZE" value="500000" />'; |
|
524 | + |
|
525 | + if ( $args['label'] && 'checkbox' !== $args['type'] ) { |
|
526 | + $field_html .= '<label for="' . esc_attr( $label_id ) . '" class="' . esc_attr( implode( ' ', $args['label_class'] ) ) . '">' . $args['label'] . $required . '</label>'; |
|
527 | + } |
|
528 | + |
|
529 | + $field_html .= $field; |
|
530 | + |
|
531 | + if ( $args['description'] ) { |
|
532 | + $field_html .= '<span class="description">' . esc_html( $args['description'] ) . '</span>'; |
|
533 | + } |
|
534 | + |
|
535 | + $container_class = esc_attr( implode( ' ', $args['class'] ) ); |
|
536 | + $container_id = esc_attr( $args['id'] ) . '_field'; |
|
537 | + $field = sprintf( $field_container, $container_class, $container_id, $field_html ); |
|
538 | + } |
|
539 | + return $field; |
|
540 | + } |
|
541 | + |
|
542 | + |
|
543 | + public function action_woocommerce_after_edit_account_form() { |
|
544 | + echo do_shortcode( '[avatar_upload /]' ); |
|
545 | + } |
|
546 | + |
|
547 | + /** |
|
548 | + * Get additional account fields. |
|
549 | + * |
|
550 | + * @return array |
|
551 | + */ |
|
552 | + public function get_account_fields() { |
|
553 | + $account_fields = apply_filters( 'iconic_account_fields', array( |
|
554 | + 'weight_start' => array( |
|
555 | + 'type' => 'text', |
|
556 | + 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
557 | + 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
558 | + 'hide_in_account' => false, |
|
559 | + 'hide_in_admin' => false, |
|
560 | + 'hide_in_checkout' => false, |
|
561 | + 'hide_in_registration' => false, |
|
562 | + 'required' => false, |
|
563 | + ), |
|
564 | + 'weight_goal' => array( |
|
565 | + 'type' => 'text', |
|
566 | + 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
567 | + 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
568 | + 'hide_in_account' => false, |
|
569 | + 'hide_in_admin' => false, |
|
570 | + 'hide_in_checkout' => false, |
|
571 | + 'hide_in_registration' => false, |
|
572 | + 'required' => false, |
|
573 | + ), |
|
574 | + 'weight_end' => array( |
|
575 | + 'type' => 'text', |
|
576 | + 'label' => __( 'Weight:', 'lsx-health-plan' ), |
|
577 | + 'placeholder' => __( 'kg', 'lsx-health-plan' ), |
|
578 | + 'hide_in_account' => false, |
|
579 | + 'hide_in_admin' => false, |
|
580 | + 'hide_in_checkout' => false, |
|
581 | + 'hide_in_registration' => false, |
|
582 | + 'required' => false, |
|
583 | + ), |
|
584 | + 'waist_start' => array( |
|
585 | + 'type' => 'text', |
|
586 | + 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
587 | + 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
588 | + 'hide_in_account' => false, |
|
589 | + 'hide_in_admin' => false, |
|
590 | + 'hide_in_checkout' => false, |
|
591 | + 'hide_in_registration' => false, |
|
592 | + 'required' => false, |
|
593 | + ), |
|
594 | + 'waist_goal' => array( |
|
595 | + 'type' => 'text', |
|
596 | + 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
597 | + 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
598 | + 'hide_in_account' => false, |
|
599 | + 'hide_in_admin' => false, |
|
600 | + 'hide_in_checkout' => false, |
|
601 | + 'hide_in_registration' => false, |
|
602 | + 'required' => false, |
|
603 | + ), |
|
604 | + 'waist_end' => array( |
|
605 | + 'type' => 'text', |
|
606 | + 'label' => __( 'Waist:', 'lsx-health-plan' ), |
|
607 | + 'placeholder' => __( 'cm', 'lsx-health-plan' ), |
|
608 | + 'hide_in_account' => false, |
|
609 | + 'hide_in_admin' => false, |
|
610 | + 'hide_in_checkout' => false, |
|
611 | + 'hide_in_registration' => false, |
|
612 | + 'required' => false, |
|
613 | + ), |
|
614 | + 'fitness_start' => array( |
|
615 | + 'type' => 'text', |
|
616 | + 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
617 | + 'placeholder' => '#', |
|
618 | + 'hide_in_account' => false, |
|
619 | + 'hide_in_admin' => false, |
|
620 | + 'hide_in_checkout' => false, |
|
621 | + 'hide_in_registration' => false, |
|
622 | + 'required' => false, |
|
623 | + ), |
|
624 | + 'fitness_goal' => array( |
|
625 | + 'type' => 'text', |
|
626 | + 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
627 | + 'placeholder' => '#', |
|
628 | + 'hide_in_account' => false, |
|
629 | + 'hide_in_admin' => false, |
|
630 | + 'hide_in_checkout' => false, |
|
631 | + 'hide_in_registration' => false, |
|
632 | + 'required' => false, |
|
633 | + ), |
|
634 | + 'fitness_end' => array( |
|
635 | + 'type' => 'text', |
|
636 | + 'label' => __( 'Fitness Test Score:', 'lsx-health-plan' ), |
|
637 | + 'placeholder' => '#', |
|
638 | + 'hide_in_account' => false, |
|
639 | + 'hide_in_admin' => false, |
|
640 | + 'hide_in_checkout' => false, |
|
641 | + 'hide_in_registration' => false, |
|
642 | + 'required' => false, |
|
643 | + ), |
|
644 | + ) ); |
|
645 | + |
|
646 | + $is_weight_disabled = \lsx_health_plan\functions\get_option( 'disable_weight_checkbox', false ); |
|
647 | + if ( 'on' === $is_weight_disabled ) { |
|
648 | + $account_fields['weight_start']['required'] = false; |
|
649 | + $account_fields['weight_goal']['required'] = false; |
|
650 | + $account_fields['weight_end']['required'] = false; |
|
651 | + } |
|
652 | + $is_waist_disabled = \lsx_health_plan\functions\get_option( 'disable_waist_checkbox', false ); |
|
653 | + if ( 'on' === $is_waist_disabled ) { |
|
654 | + $account_fields['waist_start']['required'] = false; |
|
655 | + $account_fields['waist_goal']['required'] = false; |
|
656 | + $account_fields['waist_end']['required'] = false; |
|
657 | + } |
|
658 | + return $account_fields; |
|
659 | + } |
|
660 | + |
|
661 | + /** |
|
662 | + * Removes the content restriction class to allow the password page to show. |
|
663 | + * |
|
664 | + * @return void |
|
665 | + */ |
|
666 | + public function allow_reset_password_page() { |
|
667 | + if ( ! is_user_logged_in() && function_exists( 'wc_memberships' ) && is_wc_endpoint_url( 'lost-password' ) ) { |
|
668 | + |
|
669 | + $members_instance = wc_memberships(); |
|
670 | + $restriction_instance = $members_instance->get_restrictions_instance(); |
|
671 | + $post_restrictions_instance = $restriction_instance->get_posts_restrictions_instance(); |
|
672 | + remove_action( 'wp', array( $post_restrictions_instance, 'handle_restriction_modes' ), 10, 1 ); |
|
673 | + add_action( 'body_class', array( $this, 'remove_body_classes' ) ); |
|
674 | + } |
|
675 | + } |
|
676 | + |
|
677 | + /** |
|
678 | + * Remove the gutenberg classes from the lost password page. |
|
679 | + * |
|
680 | + * @param array $classes |
|
681 | + * @return void |
|
682 | + */ |
|
683 | + public function remove_body_classes( $classes = array() ) { |
|
684 | + if ( ! empty( $classes ) ) { |
|
685 | + foreach ( $classes as $class_key => $class_value ) { |
|
686 | + if ( 'gutenberg-compatible-template' === $class_value || 'using-gutenberg' === $class_value ) { |
|
687 | + unset( $classes[ $class_key ] ); |
|
688 | + } |
|
689 | + } |
|
690 | + } |
|
691 | + return $classes; |
|
692 | + } |
|
693 | + |
|
694 | + /** |
|
695 | + * Add 'lsx-simple-checkout' class to body if it is woocommerce checkout page. |
|
696 | + * |
|
697 | + * @param array $classes |
|
698 | + * @return void |
|
699 | + */ |
|
700 | + public function hp_add_body_classes( $classes = array() ) { |
|
701 | + if ( is_checkout() ) { |
|
702 | + $classes[] = 'lsx-hp-simple-checkout'; |
|
703 | + } |
|
704 | + return $classes; |
|
705 | + } |
|
706 | + |
|
707 | + /** |
|
708 | + * Remove unnecessary items for simple woocommerce checkout page. |
|
709 | + * |
|
710 | + * @param array $classes |
|
711 | + * @return void |
|
712 | + */ |
|
713 | + public function hp_simple_checkout() { |
|
714 | + if ( is_checkout() ) { |
|
715 | + remove_action( 'lsx_footer_before', 'lsx_add_footer_sidebar_area' ); |
|
716 | + } |
|
717 | + } |
|
718 | + |
|
719 | + public function lost_password_page_title() { |
|
720 | + ?> |
|
721 | 721 | <h1 class="lost-your-password-title"><?php esc_html_e( 'Lost your password?', 'lsx-health-plan' ); ?></h1> |
722 | 722 | <?php |
723 | - } |
|
724 | - |
|
725 | - /** |
|
726 | - * Adding the 'Home' link to the checkout. |
|
727 | - * |
|
728 | - * @return void |
|
729 | - */ |
|
730 | - public function hp_link_lsx_navbar_header() { |
|
731 | - if ( is_checkout() ) { |
|
732 | - $home_ulr = '<nav class="checkout-navbar"><ul class="nav navbar-nav"><li><a href="' . home_url() . '">' . __( 'Home', 'lsx-health-plan' ) . '</a></li></ul></nav>'; |
|
733 | - echo wp_kses_post( $home_ulr ); |
|
734 | - } |
|
735 | - } |
|
736 | - |
|
737 | - |
|
738 | - /** |
|
739 | - * Add Lets Enrypt and PayFast logos to cart. |
|
740 | - **/ |
|
741 | - public function payment_gateway_logos() { |
|
742 | - $encript_image = LSX_HEALTH_PLAN_URL . 'assets/images/lets-encript.svg'; |
|
743 | - $payfast_image = LSX_HEALTH_PLAN_URL . 'assets/images/payfast-footer-logo.svg'; |
|
744 | - $payment_logos = LSX_HEALTH_PLAN_URL . 'assets/images/payment-logos.svg'; |
|
745 | - $payment_logos_mobile = LSX_HEALTH_PLAN_URL . 'assets/images/payment-logos-mobile.svg'; |
|
746 | - ?> |
|
723 | + } |
|
724 | + |
|
725 | + /** |
|
726 | + * Adding the 'Home' link to the checkout. |
|
727 | + * |
|
728 | + * @return void |
|
729 | + */ |
|
730 | + public function hp_link_lsx_navbar_header() { |
|
731 | + if ( is_checkout() ) { |
|
732 | + $home_ulr = '<nav class="checkout-navbar"><ul class="nav navbar-nav"><li><a href="' . home_url() . '">' . __( 'Home', 'lsx-health-plan' ) . '</a></li></ul></nav>'; |
|
733 | + echo wp_kses_post( $home_ulr ); |
|
734 | + } |
|
735 | + } |
|
736 | + |
|
737 | + |
|
738 | + /** |
|
739 | + * Add Lets Enrypt and PayFast logos to cart. |
|
740 | + **/ |
|
741 | + public function payment_gateway_logos() { |
|
742 | + $encript_image = LSX_HEALTH_PLAN_URL . 'assets/images/lets-encript.svg'; |
|
743 | + $payfast_image = LSX_HEALTH_PLAN_URL . 'assets/images/payfast-footer-logo.svg'; |
|
744 | + $payment_logos = LSX_HEALTH_PLAN_URL . 'assets/images/payment-logos.svg'; |
|
745 | + $payment_logos_mobile = LSX_HEALTH_PLAN_URL . 'assets/images/payment-logos-mobile.svg'; |
|
746 | + ?> |
|
747 | 747 | <div class="row text-center vertical-align lsx-full-width-base-small checkout-cta-bottom"> |
748 | 748 | <div class="col-md-12 img-payfast"> |
749 | 749 | <img src="<?php echo esc_url( $payfast_image ); ?>" alt="payfast"/> |
@@ -760,5 +760,5 @@ discard block |
||
760 | 760 | </div> |
761 | 761 | |
762 | 762 | <?php |
763 | - } |
|
763 | + } |
|
764 | 764 | } |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * Contructor |
38 | 38 | */ |
39 | 39 | public function __construct() { |
40 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
41 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
42 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
43 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
44 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
45 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
46 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
47 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
40 | + add_filter('cmb2_enqueue_css', array($this, 'disable_cmb2_styles'), 1, 1); |
|
41 | + add_action('cmb2_before_form', array($this, 'generate_navigation'), 10, 4); |
|
42 | + add_action('cmb2_before_title_field_row', array($this, 'output_tab_open_div'), 10, 1); |
|
43 | + add_action('cmb2_after_tab_closing_field_row', array($this, 'output_tab_closing_div'), 10, 1); |
|
44 | + add_action('cmb2_render_tab_closing', array($this, 'cmb2_render_callback_for_tab_closing'), 10, 5); |
|
45 | + add_filter('cmb2_sanitize_tab_closing', array($this, 'cmb2_sanitize_tab_closing_callback'), 10, 2); |
|
46 | + add_action('cmb2_after_form', array($this, 'navigation_js'), 10, 4); |
|
47 | + add_filter('cmb2_options_page_redirect_url', array($this, 'add_tab_argument'), 10, 1); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | public static function get_instance() { |
58 | 58 | // If the single instance hasn't been set, set it now. |
59 | - if ( null == self::$instance ) { |
|
59 | + if (null == self::$instance) { |
|
60 | 60 | self::$instance = new self(); |
61 | 61 | } |
62 | 62 | return self::$instance; |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return bool $enabled Whether to enable (enqueue) styles. |
69 | 69 | */ |
70 | - public function disable_cmb2_styles( $enabled ) { |
|
71 | - if ( is_admin() ) { |
|
70 | + public function disable_cmb2_styles($enabled) { |
|
71 | + if (is_admin()) { |
|
72 | 72 | $current_screen = get_current_screen(); |
73 | - if ( is_object( $current_screen ) && 'plan_page_lsx_health_plan_options' === $current_screen->id ) { |
|
73 | + if (is_object($current_screen) && 'plan_page_lsx_health_plan_options' === $current_screen->id) { |
|
74 | 74 | $enabled = false; |
75 | 75 | } |
76 | 76 | } |
@@ -86,14 +86,14 @@ discard block |
||
86 | 86 | * @param object $cmb2_obj |
87 | 87 | * @return void |
88 | 88 | */ |
89 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
90 | - if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
89 | + public function generate_navigation($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
90 | + if ('lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type) { |
|
91 | 91 | $this->navigation = array(); |
92 | 92 | $this->is_options_page = true; |
93 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
94 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
95 | - if ( 'title' === $field['type'] ) { |
|
96 | - $this->navigation[ $field_index ] = $field['name']; |
|
93 | + if (isset($cmb2_obj->meta_box['fields']) && ! empty($cmb2_obj->meta_box['fields'])) { |
|
94 | + foreach ($cmb2_obj->meta_box['fields'] as $field_index => $field) { |
|
95 | + if ('title' === $field['type']) { |
|
96 | + $this->navigation[$field_index] = $field['name']; |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -107,32 +107,32 @@ discard block |
||
107 | 107 | * @return void |
108 | 108 | */ |
109 | 109 | public function output_navigation() { |
110 | - if ( ! empty( $this->navigation ) ) { |
|
110 | + if ( ! empty($this->navigation)) { |
|
111 | 111 | ?> |
112 | 112 | <div class="wp-filter hide-if-no-js"> |
113 | 113 | <ul class="filter-links"> |
114 | 114 | <?php |
115 | 115 | $first_tab = true; |
116 | - $total = count( $this->navigation ); |
|
116 | + $total = count($this->navigation); |
|
117 | 117 | $count = 0; |
118 | 118 | $separator = ' |'; |
119 | 119 | $selected_tab = ''; |
120 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
121 | - $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
120 | + if (isset($_GET['cmb_tab']) && '' !== $_GET['cmb_tab']) { |
|
121 | + $selected_tab = sanitize_text_field($_GET['cmb_tab']); |
|
122 | 122 | $selected_tab = 'settings_' . $selected_tab; |
123 | 123 | } |
124 | - foreach ( $this->navigation as $key => $label ) { |
|
124 | + foreach ($this->navigation as $key => $label) { |
|
125 | 125 | $count++; |
126 | 126 | $current_css = ''; |
127 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
127 | + if ((true === $first_tab && '' === $selected_tab) || $key === $selected_tab) { |
|
128 | 128 | $first_tab = false; |
129 | 129 | $current_css = 'current'; |
130 | 130 | } |
131 | - if ( $count === $total ) { |
|
131 | + if ($count === $total) { |
|
132 | 132 | $separator = ''; |
133 | 133 | } |
134 | 134 | ?> |
135 | - <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
|
135 | + <li><a href="#" class="<?php echo esc_attr($current_css); ?>" data-sort="<?php echo esc_attr($key); ?>_tab"><?php echo esc_attr($label); ?></a><?php echo esc_attr($separator); ?></li> |
|
136 | 136 | <?php |
137 | 137 | } |
138 | 138 | ?> |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | * @param object $field CMB2_Field(); |
149 | 149 | * @return void |
150 | 150 | */ |
151 | - public function output_tab_open_div( $field ) { |
|
152 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
151 | + public function output_tab_open_div($field) { |
|
152 | + if (true === $this->is_options_page && isset($field->args['type']) && 'title' === $field->args['type']) { |
|
153 | 153 | ?> |
154 | - <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
|
154 | + <div id="<?php echo esc_attr($field->args['id']); ?>_tab" class="tab tab-nav hidden"> |
|
155 | 155 | <?php |
156 | 156 | } |
157 | 157 | } |
@@ -162,19 +162,19 @@ discard block |
||
162 | 162 | * @param object $field CMB2_Field(); |
163 | 163 | * @return void |
164 | 164 | */ |
165 | - public function output_tab_closing_div( $field ) { |
|
166 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
165 | + public function output_tab_closing_div($field) { |
|
166 | + if (true === $this->is_options_page && isset($field->args['type']) && 'tab_closing' === $field->args['type']) { |
|
167 | 167 | ?> |
168 | 168 | </div> |
169 | 169 | <?php |
170 | 170 | } |
171 | 171 | } |
172 | 172 | |
173 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
173 | + public function cmb2_render_callback_for_tab_closing($field, $escaped_value, $object_id, $object_type, $field_type_object) { |
|
174 | 174 | return; |
175 | 175 | } |
176 | 176 | |
177 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
177 | + public function cmb2_sanitize_tab_closing_callback($override_value, $value) { |
|
178 | 178 | return ''; |
179 | 179 | } |
180 | 180 | |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * @param object $cmb2_obj |
188 | 188 | * @return void |
189 | 189 | */ |
190 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
191 | - if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
190 | + public function navigation_js($cmb_id, $object_id, $object_type, $cmb2_obj) { |
|
191 | + if ('lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type) { |
|
192 | 192 | ?> |
193 | 193 | <script> |
194 | 194 | var LSX_HP_CMB2 = Object.create( null ); |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | * @param string $url |
271 | 271 | * @return void |
272 | 272 | */ |
273 | - public function add_tab_argument( $url ) { |
|
274 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
277 | - if ( 'single' !== $tab_selection ) { |
|
278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
273 | + public function add_tab_argument($url) { |
|
274 | + if (isset($_POST['cmb_tab']) && '' !== $_POST['cmb_tab']) { // @codingStandardsIgnoreLine |
|
275 | + $tab_selection = sanitize_text_field($_POST['cmb_tab']); // @codingStandardsIgnoreLine |
|
276 | + $tab_selection = str_replace(array('settings_', '_tab'), '', $tab_selection); // @codingStandardsIgnoreLine |
|
277 | + if ('single' !== $tab_selection) { |
|
278 | + $url = add_query_arg('cmb_tab', $tab_selection, $url); |
|
279 | 279 | } else { |
280 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
280 | + $url = remove_query_arg('cmb_tab', $url); |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | return $url; |
@@ -10,186 +10,186 @@ discard block |
||
10 | 10 | */ |
11 | 11 | class Settings_Theme { |
12 | 12 | |
13 | - /** |
|
14 | - * Holds class instance |
|
15 | - * |
|
16 | - * @since 1.0.0 |
|
17 | - * |
|
18 | - * @var object \lsx_health_plan\classes\admin\Settings_Theme() |
|
19 | - */ |
|
20 | - protected static $instance = null; |
|
13 | + /** |
|
14 | + * Holds class instance |
|
15 | + * |
|
16 | + * @since 1.0.0 |
|
17 | + * |
|
18 | + * @var object \lsx_health_plan\classes\admin\Settings_Theme() |
|
19 | + */ |
|
20 | + protected static $instance = null; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Will return true if this is the LSX Search settings page. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
27 | - public $is_options_page = false; |
|
22 | + /** |
|
23 | + * Will return true if this is the LSX Search settings page. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | + public $is_options_page = false; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Holds the id and labels for the navigation. |
|
31 | - * |
|
32 | - * @var array |
|
33 | - */ |
|
34 | - public $navigation = array(); |
|
29 | + /** |
|
30 | + * Holds the id and labels for the navigation. |
|
31 | + * |
|
32 | + * @var array |
|
33 | + */ |
|
34 | + public $navigation = array(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Contructor |
|
38 | - */ |
|
39 | - public function __construct() { |
|
40 | - add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
41 | - add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
42 | - add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
43 | - add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
44 | - add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
45 | - add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
46 | - add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
47 | - add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
48 | - } |
|
36 | + /** |
|
37 | + * Contructor |
|
38 | + */ |
|
39 | + public function __construct() { |
|
40 | + add_filter( 'cmb2_enqueue_css', array( $this, 'disable_cmb2_styles' ), 1, 1 ); |
|
41 | + add_action( 'cmb2_before_form', array( $this, 'generate_navigation' ), 10, 4 ); |
|
42 | + add_action( 'cmb2_before_title_field_row', array( $this, 'output_tab_open_div' ), 10, 1 ); |
|
43 | + add_action( 'cmb2_after_tab_closing_field_row', array( $this, 'output_tab_closing_div' ), 10, 1 ); |
|
44 | + add_action( 'cmb2_render_tab_closing', array( $this, 'cmb2_render_callback_for_tab_closing' ), 10, 5 ); |
|
45 | + add_filter( 'cmb2_sanitize_tab_closing', array( $this, 'cmb2_sanitize_tab_closing_callback' ), 10, 2 ); |
|
46 | + add_action( 'cmb2_after_form', array( $this, 'navigation_js' ), 10, 4 ); |
|
47 | + add_filter( 'cmb2_options_page_redirect_url', array( $this, 'add_tab_argument' ), 10, 1 ); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Return an instance of this class. |
|
52 | - * |
|
53 | - * @since 1.0.0 |
|
54 | - * |
|
55 | - * @return object \lsx_health_plan\classes\admin\Settings_Theme() A single instance of this class. |
|
56 | - */ |
|
57 | - public static function get_instance() { |
|
58 | - // If the single instance hasn't been set, set it now. |
|
59 | - if ( null == self::$instance ) { |
|
60 | - self::$instance = new self(); |
|
61 | - } |
|
62 | - return self::$instance; |
|
63 | - } |
|
50 | + /** |
|
51 | + * Return an instance of this class. |
|
52 | + * |
|
53 | + * @since 1.0.0 |
|
54 | + * |
|
55 | + * @return object \lsx_health_plan\classes\admin\Settings_Theme() A single instance of this class. |
|
56 | + */ |
|
57 | + public static function get_instance() { |
|
58 | + // If the single instance hasn't been set, set it now. |
|
59 | + if ( null == self::$instance ) { |
|
60 | + self::$instance = new self(); |
|
61 | + } |
|
62 | + return self::$instance; |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Disable CMB2 styles on front end forms. |
|
67 | - * |
|
68 | - * @return bool $enabled Whether to enable (enqueue) styles. |
|
69 | - */ |
|
70 | - public function disable_cmb2_styles( $enabled ) { |
|
71 | - if ( is_admin() ) { |
|
72 | - $current_screen = get_current_screen(); |
|
73 | - if ( is_object( $current_screen ) && 'plan_page_lsx_health_plan_options' === $current_screen->id ) { |
|
74 | - $enabled = false; |
|
75 | - } |
|
76 | - } |
|
77 | - return $enabled; |
|
78 | - } |
|
65 | + /** |
|
66 | + * Disable CMB2 styles on front end forms. |
|
67 | + * |
|
68 | + * @return bool $enabled Whether to enable (enqueue) styles. |
|
69 | + */ |
|
70 | + public function disable_cmb2_styles( $enabled ) { |
|
71 | + if ( is_admin() ) { |
|
72 | + $current_screen = get_current_screen(); |
|
73 | + if ( is_object( $current_screen ) && 'plan_page_lsx_health_plan_options' === $current_screen->id ) { |
|
74 | + $enabled = false; |
|
75 | + } |
|
76 | + } |
|
77 | + return $enabled; |
|
78 | + } |
|
79 | 79 | |
80 | - /** |
|
81 | - * Generates the tabbed navigation for the settings page. |
|
82 | - * |
|
83 | - * @param string $cmb_id |
|
84 | - * @param string $object_id |
|
85 | - * @param string $object_type |
|
86 | - * @param object $cmb2_obj |
|
87 | - * @return void |
|
88 | - */ |
|
89 | - public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
90 | - if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
91 | - $this->navigation = array(); |
|
92 | - $this->is_options_page = true; |
|
93 | - if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
94 | - foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
95 | - if ( 'title' === $field['type'] ) { |
|
96 | - $this->navigation[ $field_index ] = $field['name']; |
|
97 | - } |
|
98 | - } |
|
99 | - } |
|
100 | - $this->output_navigation(); |
|
101 | - } |
|
102 | - } |
|
80 | + /** |
|
81 | + * Generates the tabbed navigation for the settings page. |
|
82 | + * |
|
83 | + * @param string $cmb_id |
|
84 | + * @param string $object_id |
|
85 | + * @param string $object_type |
|
86 | + * @param object $cmb2_obj |
|
87 | + * @return void |
|
88 | + */ |
|
89 | + public function generate_navigation( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
90 | + if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
91 | + $this->navigation = array(); |
|
92 | + $this->is_options_page = true; |
|
93 | + if ( isset( $cmb2_obj->meta_box['fields'] ) && ! empty( $cmb2_obj->meta_box['fields'] ) ) { |
|
94 | + foreach ( $cmb2_obj->meta_box['fields'] as $field_index => $field ) { |
|
95 | + if ( 'title' === $field['type'] ) { |
|
96 | + $this->navigation[ $field_index ] = $field['name']; |
|
97 | + } |
|
98 | + } |
|
99 | + } |
|
100 | + $this->output_navigation(); |
|
101 | + } |
|
102 | + } |
|
103 | 103 | |
104 | - /** |
|
105 | - * Outputs the WP style navigation for the Settings page. |
|
106 | - * |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function output_navigation() { |
|
110 | - if ( ! empty( $this->navigation ) ) { |
|
111 | - ?> |
|
104 | + /** |
|
105 | + * Outputs the WP style navigation for the Settings page. |
|
106 | + * |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function output_navigation() { |
|
110 | + if ( ! empty( $this->navigation ) ) { |
|
111 | + ?> |
|
112 | 112 | <div class="wp-filter hide-if-no-js"> |
113 | 113 | <ul class="filter-links"> |
114 | 114 | <?php |
115 | - $first_tab = true; |
|
116 | - $total = count( $this->navigation ); |
|
117 | - $count = 0; |
|
118 | - $separator = ' |'; |
|
119 | - $selected_tab = ''; |
|
120 | - if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
121 | - $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
122 | - $selected_tab = 'settings_' . $selected_tab; |
|
123 | - } |
|
124 | - foreach ( $this->navigation as $key => $label ) { |
|
125 | - $count++; |
|
126 | - $current_css = ''; |
|
127 | - if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
128 | - $first_tab = false; |
|
129 | - $current_css = 'current'; |
|
130 | - } |
|
131 | - if ( $count === $total ) { |
|
132 | - $separator = ''; |
|
133 | - } |
|
134 | - ?> |
|
115 | + $first_tab = true; |
|
116 | + $total = count( $this->navigation ); |
|
117 | + $count = 0; |
|
118 | + $separator = ' |'; |
|
119 | + $selected_tab = ''; |
|
120 | + if ( isset( $_GET['cmb_tab'] ) && '' !== $_GET['cmb_tab'] ) { |
|
121 | + $selected_tab = sanitize_text_field( $_GET['cmb_tab'] ); |
|
122 | + $selected_tab = 'settings_' . $selected_tab; |
|
123 | + } |
|
124 | + foreach ( $this->navigation as $key => $label ) { |
|
125 | + $count++; |
|
126 | + $current_css = ''; |
|
127 | + if ( ( true === $first_tab && '' === $selected_tab ) || $key === $selected_tab ) { |
|
128 | + $first_tab = false; |
|
129 | + $current_css = 'current'; |
|
130 | + } |
|
131 | + if ( $count === $total ) { |
|
132 | + $separator = ''; |
|
133 | + } |
|
134 | + ?> |
|
135 | 135 | <li><a href="#" class="<?php echo esc_attr( $current_css ); ?>" data-sort="<?php echo esc_attr( $key ); ?>_tab"><?php echo esc_attr( $label ); ?></a><?php echo esc_attr( $separator ); ?></li> |
136 | 136 | <?php |
137 | - } |
|
138 | - ?> |
|
137 | + } |
|
138 | + ?> |
|
139 | 139 | </ul> |
140 | 140 | </div> |
141 | 141 | <?php |
142 | - } |
|
143 | - } |
|
142 | + } |
|
143 | + } |
|
144 | 144 | |
145 | - /** |
|
146 | - * Outputs the opening tab div. |
|
147 | - * |
|
148 | - * @param object $field CMB2_Field(); |
|
149 | - * @return void |
|
150 | - */ |
|
151 | - public function output_tab_open_div( $field ) { |
|
152 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
153 | - ?> |
|
145 | + /** |
|
146 | + * Outputs the opening tab div. |
|
147 | + * |
|
148 | + * @param object $field CMB2_Field(); |
|
149 | + * @return void |
|
150 | + */ |
|
151 | + public function output_tab_open_div( $field ) { |
|
152 | + if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'title' === $field->args['type'] ) { |
|
153 | + ?> |
|
154 | 154 | <div id="<?php echo esc_attr( $field->args['id'] ); ?>_tab" class="tab tab-nav hidden"> |
155 | 155 | <?php |
156 | - } |
|
157 | - } |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Outputs the opening closing div. |
|
161 | - * |
|
162 | - * @param object $field CMB2_Field(); |
|
163 | - * @return void |
|
164 | - */ |
|
165 | - public function output_tab_closing_div( $field ) { |
|
166 | - if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
167 | - ?> |
|
159 | + /** |
|
160 | + * Outputs the opening closing div. |
|
161 | + * |
|
162 | + * @param object $field CMB2_Field(); |
|
163 | + * @return void |
|
164 | + */ |
|
165 | + public function output_tab_closing_div( $field ) { |
|
166 | + if ( true === $this->is_options_page && isset( $field->args['type'] ) && 'tab_closing' === $field->args['type'] ) { |
|
167 | + ?> |
|
168 | 168 | </div> |
169 | 169 | <?php |
170 | - } |
|
171 | - } |
|
170 | + } |
|
171 | + } |
|
172 | 172 | |
173 | - public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
174 | - return; |
|
175 | - } |
|
173 | + public function cmb2_render_callback_for_tab_closing( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
|
174 | + return; |
|
175 | + } |
|
176 | 176 | |
177 | - public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
178 | - return ''; |
|
179 | - } |
|
177 | + public function cmb2_sanitize_tab_closing_callback( $override_value, $value ) { |
|
178 | + return ''; |
|
179 | + } |
|
180 | 180 | |
181 | - /** |
|
182 | - * Outputs the Script for the tabbed navigation. |
|
183 | - * |
|
184 | - * @param string $cmb_id |
|
185 | - * @param string $object_id |
|
186 | - * @param string $object_type |
|
187 | - * @param object $cmb2_obj |
|
188 | - * @return void |
|
189 | - */ |
|
190 | - public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
191 | - if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
192 | - ?> |
|
181 | + /** |
|
182 | + * Outputs the Script for the tabbed navigation. |
|
183 | + * |
|
184 | + * @param string $cmb_id |
|
185 | + * @param string $object_id |
|
186 | + * @param string $object_type |
|
187 | + * @param object $cmb2_obj |
|
188 | + * @return void |
|
189 | + */ |
|
190 | + public function navigation_js( $cmb_id, $object_id, $object_type, $cmb2_obj ) { |
|
191 | + if ( 'lsx_health_plan_settings' === $cmb_id && 'lsx_health_plan_options' === $object_id && 'options-page' === $object_type ) { |
|
192 | + ?> |
|
193 | 193 | <script> |
194 | 194 | var LSX_HP_CMB2 = Object.create( null ); |
195 | 195 | |
@@ -261,25 +261,25 @@ discard block |
||
261 | 261 | } )( jQuery, window, document ); |
262 | 262 | </script> |
263 | 263 | <?php |
264 | - } |
|
265 | - } |
|
264 | + } |
|
265 | + } |
|
266 | 266 | |
267 | - /** |
|
268 | - * This will add the tab selection to the url. |
|
269 | - * |
|
270 | - * @param string $url |
|
271 | - * @return void |
|
272 | - */ |
|
273 | - public function add_tab_argument( $url ) { |
|
274 | - if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
275 | - $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
276 | - $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
277 | - if ( 'single' !== $tab_selection ) { |
|
278 | - $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
279 | - } else { |
|
280 | - $url = remove_query_arg( 'cmb_tab', $url ); |
|
281 | - } |
|
282 | - } |
|
283 | - return $url; |
|
284 | - } |
|
267 | + /** |
|
268 | + * This will add the tab selection to the url. |
|
269 | + * |
|
270 | + * @param string $url |
|
271 | + * @return void |
|
272 | + */ |
|
273 | + public function add_tab_argument( $url ) { |
|
274 | + if ( isset( $_POST['cmb_tab'] ) && '' !== $_POST['cmb_tab'] ) { // @codingStandardsIgnoreLine |
|
275 | + $tab_selection = sanitize_text_field( $_POST['cmb_tab'] ); // @codingStandardsIgnoreLine |
|
276 | + $tab_selection = str_replace( array( 'settings_', '_tab' ), '', $tab_selection ); // @codingStandardsIgnoreLine |
|
277 | + if ( 'single' !== $tab_selection ) { |
|
278 | + $url = add_query_arg( 'cmb_tab', $tab_selection, $url ); |
|
279 | + } else { |
|
280 | + $url = remove_query_arg( 'cmb_tab', $url ); |
|
281 | + } |
|
282 | + } |
|
283 | + return $url; |
|
284 | + } |
|
285 | 285 | } |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * Contructor |
54 | 54 | */ |
55 | 55 | public function __construct() { |
56 | - add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) ); |
|
57 | - add_action( 'lsx_hp_settings_page', array( $this, 'general_settings' ), 1, 1 ); |
|
58 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 ); |
|
59 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 ); |
|
60 | - add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 ); |
|
61 | - add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 ); |
|
62 | - add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 ); |
|
63 | - add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 ); |
|
56 | + add_action('cmb2_admin_init', array($this, 'register_settings_page')); |
|
57 | + add_action('lsx_hp_settings_page', array($this, 'general_settings'), 1, 1); |
|
58 | + add_action('lsx_hp_settings_page', array($this, 'global_defaults'), 3, 1); |
|
59 | + add_action('lsx_hp_settings_page', array($this, 'global_downloads'), 5, 1); |
|
60 | + add_action('lsx_hp_settings_page', array($this, 'stat_disable'), 6, 1); |
|
61 | + add_action('lsx_hp_settings_page', array($this, 'endpoint_translations'), 7, 1); |
|
62 | + add_action('lsx_hp_settings_page', array($this, 'exercise_translations'), 7, 1); |
|
63 | + add_action('lsx_hp_settings_page', array($this, 'post_type_toggles'), 9, 1); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function get_instance() { |
74 | 74 | // If the single instance hasn't been set, set it now. |
75 | - if ( null === self::$instance ) { |
|
75 | + if (null === self::$instance) { |
|
76 | 76 | self::$instance = new self(); |
77 | 77 | } |
78 | 78 | return self::$instance; |
@@ -85,115 +85,115 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function set_vars() { |
87 | 87 | |
88 | - $this->default_types = array( |
|
88 | + $this->default_types = array( |
|
89 | 89 | 'page' => array( |
90 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
91 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
90 | + 'title' => __('Warm Up', 'lsx-health-plan'), |
|
91 | + 'description' => __('Set a default warm up routine.', 'lsx-health-plan'), |
|
92 | 92 | 'limit' => 1, |
93 | 93 | 'id' => 'plan_warmup', |
94 | 94 | ), |
95 | 95 | ); |
96 | 96 | $this->download_types = array( |
97 | 97 | 'page' => array( |
98 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
99 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
98 | + 'title' => __('Warm Up', 'lsx-health-plan'), |
|
99 | + 'description' => __('Set a default warm up routine.', 'lsx-health-plan'), |
|
100 | 100 | 'limit' => 1, |
101 | 101 | ), |
102 | 102 | ); |
103 | - $this->endpoints = array( |
|
103 | + $this->endpoints = array( |
|
104 | 104 | 'endpoint_warm_up' => array( |
105 | - 'title' => __( 'Warm Up Endpoint', 'lsx-health-plan' ), |
|
105 | + 'title' => __('Warm Up Endpoint', 'lsx-health-plan'), |
|
106 | 106 | 'default' => 'warm-up', |
107 | 107 | ), |
108 | 108 | ); |
109 | 109 | |
110 | - if ( post_type_exists( 'meal' ) ) { |
|
111 | - $this->download_types['meal'] = array( |
|
112 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
113 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
110 | + if (post_type_exists('meal')) { |
|
111 | + $this->download_types['meal'] = array( |
|
112 | + 'title' => __('Meal Plan', 'lsx-health-plan'), |
|
113 | + 'description' => __('Set a default meal plan.', 'lsx-health-plan'), |
|
114 | 114 | ); |
115 | - $this->default_types['meal'] = array( |
|
116 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
117 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
115 | + $this->default_types['meal'] = array( |
|
116 | + 'title' => __('Meal Plan', 'lsx-health-plan'), |
|
117 | + 'description' => __('Set a default meal plan.', 'lsx-health-plan'), |
|
118 | 118 | 'id' => 'connected_meals', |
119 | 119 | ); |
120 | 120 | $this->endpoints['endpoint_meal'] = array( |
121 | - 'title' => __( 'Meal Endpoint', 'lsx-health-plan' ), |
|
121 | + 'title' => __('Meal Endpoint', 'lsx-health-plan'), |
|
122 | 122 | 'default' => 'meal', |
123 | 123 | ); |
124 | 124 | } |
125 | - if ( post_type_exists( 'recipe' ) ) { |
|
125 | + if (post_type_exists('recipe')) { |
|
126 | 126 | $this->download_types['recipe'] = array( |
127 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
128 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
127 | + 'title' => __('Recipe', 'lsx-health-plan'), |
|
128 | + 'description' => __('Set a default recipe.', 'lsx-health-plan'), |
|
129 | 129 | ); |
130 | 130 | $this->default_types['recipe'] = array( |
131 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
132 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
131 | + 'title' => __('Recipe', 'lsx-health-plan'), |
|
132 | + 'description' => __('Set a default recipe.', 'lsx-health-plan'), |
|
133 | 133 | 'id' => 'connected_recipes', |
134 | 134 | ); |
135 | 135 | $this->endpoints['endpoint_recipe'] = array( |
136 | - 'title' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
|
136 | + 'title' => __('Recipes Endpoint', 'lsx-health-plan'), |
|
137 | 137 | 'default' => 'recipe', |
138 | 138 | ); |
139 | 139 | } |
140 | - if ( post_type_exists( 'workout' ) ) { |
|
140 | + if (post_type_exists('workout')) { |
|
141 | 141 | $this->download_types['workout'] = array( |
142 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
143 | - 'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ), |
|
142 | + 'title' => __('Workout', 'lsx-health-plan'), |
|
143 | + 'description' => __('Set a default workout routine PDF.', 'lsx-health-plan'), |
|
144 | 144 | ); |
145 | 145 | $this->default_types['workout'] = array( |
146 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
147 | - 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
146 | + 'title' => __('Workout', 'lsx-health-plan'), |
|
147 | + 'description' => __('Set a default workout routine.', 'lsx-health-plan'), |
|
148 | 148 | 'id' => 'connected_workouts', |
149 | 149 | ); |
150 | 150 | $this->endpoints['endpoint_workout_archive'] = array( |
151 | - 'title' => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ), |
|
151 | + 'title' => __('Workouts Archive Endpoint', 'lsx-health-plan'), |
|
152 | 152 | 'default' => '', |
153 | 153 | ); |
154 | 154 | $this->endpoints['endpoint_workout'] = array( |
155 | - 'title' => __( 'Single Workout Endpoint', 'lsx-health-plan' ), |
|
155 | + 'title' => __('Single Workout Endpoint', 'lsx-health-plan'), |
|
156 | 156 | 'default' => 'workout', |
157 | 157 | ); |
158 | 158 | } |
159 | 159 | |
160 | 160 | $this->endpoints['login_slug'] = array( |
161 | - 'title' => __( 'Login Slug', 'lsx-health-plan' ), |
|
161 | + 'title' => __('Login Slug', 'lsx-health-plan'), |
|
162 | 162 | 'default' => 'login', |
163 | 163 | ); |
164 | 164 | $this->endpoints['my_plan_slug'] = array( |
165 | - 'title' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
165 | + 'title' => __('My Plan Slug', 'lsx-health-plan'), |
|
166 | 166 | 'default' => 'my-plan', |
167 | 167 | ); |
168 | 168 | $this->endpoints['plan_single_slug'] = array( |
169 | - 'title' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
169 | + 'title' => __('Single Plan Slug', 'lsx-health-plan'), |
|
170 | 170 | 'default' => 'plan', |
171 | 171 | ); |
172 | 172 | $this->endpoints['endpoint_plan_archive'] = array( |
173 | - 'title' => __( 'Plans Archive Endpoint', 'lsx-health-plan' ), |
|
173 | + 'title' => __('Plans Archive Endpoint', 'lsx-health-plan'), |
|
174 | 174 | 'default' => 'plans', |
175 | 175 | ); |
176 | 176 | |
177 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
177 | + if (false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
178 | 178 | $this->endpoints['exercise'] = array( |
179 | 179 | 'exercise_single' => array( |
180 | - 'title' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
180 | + 'title' => __('Single Exercise Slug', 'lsx-health-plan'), |
|
181 | 181 | 'default' => 'exercise', |
182 | 182 | ), |
183 | 183 | 'exercise_archive' => array( |
184 | - 'title' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
184 | + 'title' => __('Archive Exercise Slug', 'lsx-health-plan'), |
|
185 | 185 | 'default' => 'exercises', |
186 | 186 | ), |
187 | 187 | 'exercise_type' => array( |
188 | - 'title' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
188 | + 'title' => __('Exercise Type Slug', 'lsx-health-plan'), |
|
189 | 189 | 'default' => 'exercise-type', |
190 | 190 | ), |
191 | 191 | 'exercise_equipment' => array( |
192 | - 'title' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
192 | + 'title' => __('Equipment Slug', 'lsx-health-plan'), |
|
193 | 193 | 'default' => 'equipment', |
194 | 194 | ), |
195 | 195 | 'exercise_musclegroup' => array( |
196 | - 'title' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
196 | + 'title' => __('Muscle Group Slug', 'lsx-health-plan'), |
|
197 | 197 | 'default' => 'muscle-group', |
198 | 198 | ), |
199 | 199 | ); |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | $cmb = new_cmb2_box( |
209 | 209 | array( |
210 | 210 | 'id' => $this->screen_id, |
211 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
212 | - 'object_types' => array( 'options-page' ), |
|
211 | + 'title' => esc_html__('Settings', 'lsx-health-plan'), |
|
212 | + 'object_types' => array('options-page'), |
|
213 | 213 | 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
214 | 214 | 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
215 | 215 | 'capability' => 'manage_options', // Cap required to view options-page. |
216 | 216 | ) |
217 | 217 | ); |
218 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
218 | + do_action('lsx_hp_settings_page', $cmb); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -224,25 +224,25 @@ discard block |
||
224 | 224 | * @param object $cmb new_cmb2_box(). |
225 | 225 | * @return void |
226 | 226 | */ |
227 | - public function general_settings( $cmb ) { |
|
227 | + public function general_settings($cmb) { |
|
228 | 228 | $cmb->add_field( |
229 | 229 | array( |
230 | 230 | 'id' => 'settings_general_title', |
231 | 231 | 'type' => 'title', |
232 | - 'name' => __( 'General', 'lsx-health-plan' ), |
|
233 | - 'default' => __( 'General', 'lsx-health-plan' ), |
|
232 | + 'name' => __('General', 'lsx-health-plan'), |
|
233 | + 'default' => __('General', 'lsx-health-plan'), |
|
234 | 234 | ) |
235 | 235 | ); |
236 | 236 | $cmb->add_field( |
237 | 237 | array( |
238 | - 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
238 | + 'name' => __('Membership Product', 'lsx-health-plan'), |
|
239 | 239 | 'id' => 'membership_product', |
240 | 240 | 'type' => 'post_search_ajax', |
241 | 241 | 'limit' => 1, |
242 | 242 | 'sortable' => false, |
243 | 243 | 'query_args' => array( |
244 | - 'post_type' => array( 'product' ), |
|
245 | - 'post_status' => array( 'publish' ), |
|
244 | + 'post_type' => array('product'), |
|
245 | + 'post_status' => array('publish'), |
|
246 | 246 | 'posts_per_page' => -1, |
247 | 247 | ), |
248 | 248 | ) |
@@ -250,43 +250,43 @@ discard block |
||
250 | 250 | |
251 | 251 | $cmb->add_field( |
252 | 252 | array( |
253 | - 'name' => __( 'Your Warm-up Intro', 'lsx-health-plan' ), |
|
253 | + 'name' => __('Your Warm-up Intro', 'lsx-health-plan'), |
|
254 | 254 | 'id' => 'warmup_intro', |
255 | 255 | 'type' => 'textarea', |
256 | 256 | 'value' => '', |
257 | - 'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ), |
|
257 | + 'default' => __("Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan'), |
|
258 | 258 | ) |
259 | 259 | ); |
260 | - if ( post_type_exists( 'workout' ) ) { |
|
260 | + if (post_type_exists('workout')) { |
|
261 | 261 | $cmb->add_field( |
262 | 262 | array( |
263 | - 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
263 | + 'name' => __('Your Workout Intro', 'lsx-health-plan'), |
|
264 | 264 | 'id' => 'workout_intro', |
265 | 265 | 'type' => 'textarea', |
266 | 266 | 'value' => '', |
267 | - 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
267 | + 'default' => __("Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan'), |
|
268 | 268 | ) |
269 | 269 | ); |
270 | 270 | } |
271 | - if ( post_type_exists( 'meal' ) ) { |
|
271 | + if (post_type_exists('meal')) { |
|
272 | 272 | $cmb->add_field( |
273 | 273 | array( |
274 | - 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
274 | + 'name' => __('Your Meal Plan Intro', 'lsx-health-plan'), |
|
275 | 275 | 'id' => 'meal_plan_intro', |
276 | 276 | 'type' => 'textarea', |
277 | 277 | 'value' => '', |
278 | - 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
278 | + 'default' => __('Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan'), |
|
279 | 279 | ) |
280 | 280 | ); |
281 | 281 | } |
282 | - if ( post_type_exists( 'recipe' ) ) { |
|
282 | + if (post_type_exists('recipe')) { |
|
283 | 283 | $cmb->add_field( |
284 | 284 | array( |
285 | - 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
285 | + 'name' => __('Recipes Intro', 'lsx-health-plan'), |
|
286 | 286 | 'id' => 'recipes_intro', |
287 | 287 | 'type' => 'textarea', |
288 | 288 | 'value' => '', |
289 | - 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
289 | + 'default' => __("Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan'), |
|
290 | 290 | ) |
291 | 291 | ); |
292 | 292 | } |
@@ -304,26 +304,26 @@ discard block |
||
304 | 304 | * @param object $cmb new_cmb2_box(). |
305 | 305 | * @return void |
306 | 306 | */ |
307 | - public function global_defaults( $cmb ) { |
|
307 | + public function global_defaults($cmb) { |
|
308 | 308 | $cmb->add_field( |
309 | 309 | array( |
310 | 310 | 'id' => 'global_defaults_title', |
311 | 311 | 'type' => 'title', |
312 | - 'name' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
313 | - 'default' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
312 | + 'name' => __('Global Defaults', 'lsx-health-plan'), |
|
313 | + 'default' => __('Global Defaults', 'lsx-health-plan'), |
|
314 | 314 | ) |
315 | 315 | ); |
316 | 316 | |
317 | - foreach ( $this->default_types as $type => $default_type ) { |
|
317 | + foreach ($this->default_types as $type => $default_type) { |
|
318 | 318 | $limit = 5; |
319 | 319 | $sortable = false; |
320 | - if ( isset( $default_type['limit'] ) ) { |
|
320 | + if (isset($default_type['limit'])) { |
|
321 | 321 | $limit = $default_type['limit']; |
322 | 322 | $sortable = true; |
323 | 323 | } |
324 | 324 | |
325 | - if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
326 | - $type = array( 'page', 'workout' ); |
|
325 | + if ('page' === $type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false)) { |
|
326 | + $type = array('page', 'workout'); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | $cmb->add_field( |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | 'sortable' => $sortable, |
337 | 337 | 'query_args' => array( |
338 | 338 | 'post_type' => $type, |
339 | - 'post_status' => array( 'publish' ), |
|
339 | + 'post_status' => array('publish'), |
|
340 | 340 | 'posts_per_page' => -1, |
341 | 341 | ), |
342 | 342 | ) |
@@ -357,20 +357,20 @@ discard block |
||
357 | 357 | * @param object $cmb new_cmb2_box(). |
358 | 358 | * @return void |
359 | 359 | */ |
360 | - public function global_downloads( $cmb ) { |
|
360 | + public function global_downloads($cmb) { |
|
361 | 361 | $cmb->add_field( |
362 | 362 | array( |
363 | 363 | 'id' => 'global_downloads_title', |
364 | 364 | 'type' => 'title', |
365 | - 'name' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
366 | - 'default' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
365 | + 'name' => __('Global Downloads', 'lsx-health-plan'), |
|
366 | + 'default' => __('Global Downloads', 'lsx-health-plan'), |
|
367 | 367 | ) |
368 | 368 | ); |
369 | 369 | |
370 | - foreach ( $this->download_types as $type => $download_type ) { |
|
370 | + foreach ($this->download_types as $type => $download_type) { |
|
371 | 371 | $limit = 5; |
372 | 372 | $sortable = false; |
373 | - if ( isset( $download_type['limit'] ) ) { |
|
373 | + if (isset($download_type['limit'])) { |
|
374 | 374 | $limit = $download_type['limit']; |
375 | 375 | $sortable = true; |
376 | 376 | } |
@@ -383,8 +383,8 @@ discard block |
||
383 | 383 | 'limit' => $limit, |
384 | 384 | 'sortable' => $sortable, |
385 | 385 | 'query_args' => array( |
386 | - 'post_type' => array( 'dlm_download' ), |
|
387 | - 'post_status' => array( 'publish' ), |
|
386 | + 'post_type' => array('dlm_download'), |
|
387 | + 'post_status' => array('publish'), |
|
388 | 388 | 'posts_per_page' => -1, |
389 | 389 | ), |
390 | 390 | ) |
@@ -404,18 +404,18 @@ discard block |
||
404 | 404 | * @param object $cmb new_cmb2_box(). |
405 | 405 | * @return void |
406 | 406 | */ |
407 | - public function endpoint_translations( $cmb ) { |
|
407 | + public function endpoint_translations($cmb) { |
|
408 | 408 | $cmb->add_field( |
409 | 409 | array( |
410 | 410 | 'id' => 'endpoints_title', |
411 | 411 | 'type' => 'title', |
412 | - 'name' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
413 | - 'default' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
414 | - 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
412 | + 'name' => __('Set Endpoint Translations', 'lsx-health-plan'), |
|
413 | + 'default' => __('Set Endpoint Translations', 'lsx-health-plan'), |
|
414 | + 'description' => __('You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'), |
|
415 | 415 | ) |
416 | 416 | ); |
417 | - foreach ( $this->endpoints as $slug => $endpoint_vars ) { |
|
418 | - if ( 'exercise' === $slug ) { |
|
417 | + foreach ($this->endpoints as $slug => $endpoint_vars) { |
|
418 | + if ('exercise' === $slug) { |
|
419 | 419 | continue; |
420 | 420 | } |
421 | 421 | |
@@ -443,19 +443,19 @@ discard block |
||
443 | 443 | * @param object $cmb new_cmb2_box(). |
444 | 444 | * @return void |
445 | 445 | */ |
446 | - public function exercise_translations( $cmb ) { |
|
447 | - if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) { |
|
446 | + public function exercise_translations($cmb) { |
|
447 | + if (isset($this->endpoints['exercise']) && '' !== $this->endpoints['exercise'] && ! empty($this->endpoints['exercise'])) { |
|
448 | 448 | $cmb->add_field( |
449 | 449 | array( |
450 | 450 | 'id' => 'exercise_endpoints_title', |
451 | 451 | 'type' => 'title', |
452 | - 'name' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
453 | - 'default' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
454 | - 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
452 | + 'name' => __('Set Exercise Translations', 'lsx-health-plan'), |
|
453 | + 'default' => __('Set Exercise Translations', 'lsx-health-plan'), |
|
454 | + 'description' => __('You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan'), |
|
455 | 455 | ) |
456 | 456 | ); |
457 | 457 | |
458 | - foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) { |
|
458 | + foreach ($this->endpoints['exercise'] as $slug => $endpoint_vars) { |
|
459 | 459 | $cmb->add_field( |
460 | 460 | array( |
461 | 461 | 'name' => $endpoint_vars['title'], |
@@ -481,27 +481,27 @@ discard block |
||
481 | 481 | * @param object $cmb new_cmb2_box(). |
482 | 482 | * @return void |
483 | 483 | */ |
484 | - public function post_type_toggles( $cmb ) { |
|
485 | - $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
484 | + public function post_type_toggles($cmb) { |
|
485 | + $post_types = apply_filters('lsx_health_plan_post_types', isset($this->post_types)); |
|
486 | 486 | |
487 | 487 | $cmb->add_field( |
488 | 488 | array( |
489 | 489 | 'id' => 'post_type_toggles_title', |
490 | 490 | 'type' => 'title', |
491 | - 'name' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
492 | - 'default' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
493 | - 'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
491 | + 'name' => __('Disable Post Types', 'lsx-health-plan'), |
|
492 | + 'default' => __('Disable Post Types', 'lsx-health-plan'), |
|
493 | + 'description' => __('Disable post types if you are wanting a minimal site.', 'lsx-health-plan'), |
|
494 | 494 | ) |
495 | 495 | ); |
496 | 496 | |
497 | - foreach ( $post_types as $post_type ) { |
|
498 | - if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) { |
|
497 | + foreach ($post_types as $post_type) { |
|
498 | + if ('plan' === $post_type || 'exercise' === $post_type || ('video' === $post_type && false !== \lsx_health_plan\functions\get_option('exercise_enabled', false))) { |
|
499 | 499 | continue; |
500 | 500 | } |
501 | 501 | |
502 | 502 | $cmb->add_field( |
503 | 503 | array( |
504 | - 'name' => ucwords( $post_type ), |
|
504 | + 'name' => ucwords($post_type), |
|
505 | 505 | 'id' => $post_type . '_disabled', |
506 | 506 | 'type' => 'checkbox', |
507 | 507 | 'value' => 1, |
@@ -521,19 +521,19 @@ discard block |
||
521 | 521 | array( |
522 | 522 | 'id' => 'post_type_toggles_enable_title', |
523 | 523 | 'type' => 'title', |
524 | - 'name' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
525 | - 'default' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
526 | - 'description' => __( 'Enable new functionailty like the "exercise" post type.', 'lsx-health-plan' ), |
|
524 | + 'name' => __('Enable Post Types', 'lsx-health-plan'), |
|
525 | + 'default' => __('Enable Post Types', 'lsx-health-plan'), |
|
526 | + 'description' => __('Enable new functionailty like the "exercise" post type.', 'lsx-health-plan'), |
|
527 | 527 | ) |
528 | 528 | ); |
529 | 529 | $cmb->add_field( |
530 | 530 | array( |
531 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
531 | + 'name' => __('Exercises', 'lsx-health-plan'), |
|
532 | 532 | 'id' => 'exercise_enabled', |
533 | 533 | 'type' => 'checkbox', |
534 | 534 | 'value' => 1, |
535 | 535 | 'default' => 0, |
536 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
536 | + 'description' => __('Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan'), |
|
537 | 537 | ) |
538 | 538 | ); |
539 | 539 | $cmb->add_field( |
@@ -550,18 +550,18 @@ discard block |
||
550 | 550 | * @return void |
551 | 551 | */ |
552 | 552 | |
553 | - public function stat_disable( $cmb ) { |
|
553 | + public function stat_disable($cmb) { |
|
554 | 554 | $cmb->add_field( |
555 | 555 | array( |
556 | 556 | 'id' => 'stat_disable_title', |
557 | 557 | 'type' => 'title', |
558 | - 'name' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
559 | - 'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
558 | + 'name' => __('Disable Profile Stats', 'lsx-health-plan'), |
|
559 | + 'default' => __('Disable Profile Stats', 'lsx-health-plan'), |
|
560 | 560 | ) |
561 | 561 | ); |
562 | 562 | $cmb->add_field( |
563 | 563 | array( |
564 | - 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
564 | + 'name' => __('Disable All Stats', 'lsx-health-plan'), |
|
565 | 565 | 'desc' => 'Disable All Stats', |
566 | 566 | 'id' => 'disable_all_stats', |
567 | 567 | 'type' => 'checkbox', |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | ); |
572 | 572 | $cmb->add_field( |
573 | 573 | array( |
574 | - 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
574 | + 'name' => __('Disable Weight', 'lsx-health-plan'), |
|
575 | 575 | 'id' => 'disable_weight_checkbox', |
576 | 576 | 'type' => 'checkbox', |
577 | 577 | 'value' => 1, |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | ); |
581 | 581 | $cmb->add_field( |
582 | 582 | array( |
583 | - 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
583 | + 'name' => __('Disable Waist', 'lsx-health-plan'), |
|
584 | 584 | 'id' => 'disable_waist_checkbox', |
585 | 585 | 'type' => 'checkbox', |
586 | 586 | 'value' => 1, |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | ); |
590 | 590 | $cmb->add_field( |
591 | 591 | array( |
592 | - 'name' => __( 'Disable Fitness', 'lsx-health-plan' ), |
|
592 | + 'name' => __('Disable Fitness', 'lsx-health-plan'), |
|
593 | 593 | 'id' => 'disable_fitness_checkbox', |
594 | 594 | 'type' => 'checkbox', |
595 | 595 | 'value' => 1, |
@@ -12,595 +12,595 @@ |
||
12 | 12 | */ |
13 | 13 | class Settings { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Settings() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * Option key, and option page slug |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $screen_id = 'lsx_health_plan_settings'; |
|
30 | - |
|
31 | - /** |
|
32 | - * An array of the post types for the Global Downloads field. |
|
33 | - * |
|
34 | - * @var array |
|
35 | - */ |
|
36 | - public $download_types = array(); |
|
37 | - |
|
38 | - /** |
|
39 | - * An array of the post types for the Global Defaults field. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - public $default_types = array(); |
|
44 | - |
|
45 | - /** |
|
46 | - * An array of the endpoints for the Endpoint Translation field. |
|
47 | - * |
|
48 | - * @var array |
|
49 | - */ |
|
50 | - public $endpoints = array(); |
|
51 | - |
|
52 | - /** |
|
53 | - * Contructor |
|
54 | - */ |
|
55 | - public function __construct() { |
|
56 | - add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) ); |
|
57 | - add_action( 'lsx_hp_settings_page', array( $this, 'general_settings' ), 1, 1 ); |
|
58 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 ); |
|
59 | - add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 ); |
|
60 | - add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 ); |
|
61 | - add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 ); |
|
62 | - add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 ); |
|
63 | - add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 ); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Return an instance of this class. |
|
68 | - * |
|
69 | - * @since 1.0.0 |
|
70 | - * |
|
71 | - * @return object \lsx_health_plan\classes\admin\Settings() A single instance of this class. |
|
72 | - */ |
|
73 | - public static function get_instance() { |
|
74 | - // If the single instance hasn't been set, set it now. |
|
75 | - if ( null === self::$instance ) { |
|
76 | - self::$instance = new self(); |
|
77 | - } |
|
78 | - return self::$instance; |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Sets the variables needed for the fields. |
|
83 | - * |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function set_vars() { |
|
87 | - |
|
88 | - $this->default_types = array( |
|
89 | - 'page' => array( |
|
90 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
91 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
92 | - 'limit' => 1, |
|
93 | - 'id' => 'plan_warmup', |
|
94 | - ), |
|
95 | - ); |
|
96 | - $this->download_types = array( |
|
97 | - 'page' => array( |
|
98 | - 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
99 | - 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
100 | - 'limit' => 1, |
|
101 | - ), |
|
102 | - ); |
|
103 | - $this->endpoints = array( |
|
104 | - 'endpoint_warm_up' => array( |
|
105 | - 'title' => __( 'Warm Up Endpoint', 'lsx-health-plan' ), |
|
106 | - 'default' => 'warm-up', |
|
107 | - ), |
|
108 | - ); |
|
109 | - |
|
110 | - if ( post_type_exists( 'meal' ) ) { |
|
111 | - $this->download_types['meal'] = array( |
|
112 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
113 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
114 | - ); |
|
115 | - $this->default_types['meal'] = array( |
|
116 | - 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
117 | - 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
118 | - 'id' => 'connected_meals', |
|
119 | - ); |
|
120 | - $this->endpoints['endpoint_meal'] = array( |
|
121 | - 'title' => __( 'Meal Endpoint', 'lsx-health-plan' ), |
|
122 | - 'default' => 'meal', |
|
123 | - ); |
|
124 | - } |
|
125 | - if ( post_type_exists( 'recipe' ) ) { |
|
126 | - $this->download_types['recipe'] = array( |
|
127 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
128 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
129 | - ); |
|
130 | - $this->default_types['recipe'] = array( |
|
131 | - 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
132 | - 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
133 | - 'id' => 'connected_recipes', |
|
134 | - ); |
|
135 | - $this->endpoints['endpoint_recipe'] = array( |
|
136 | - 'title' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
|
137 | - 'default' => 'recipe', |
|
138 | - ); |
|
139 | - } |
|
140 | - if ( post_type_exists( 'workout' ) ) { |
|
141 | - $this->download_types['workout'] = array( |
|
142 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
143 | - 'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ), |
|
144 | - ); |
|
145 | - $this->default_types['workout'] = array( |
|
146 | - 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
147 | - 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
148 | - 'id' => 'connected_workouts', |
|
149 | - ); |
|
150 | - $this->endpoints['endpoint_workout_archive'] = array( |
|
151 | - 'title' => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ), |
|
152 | - 'default' => '', |
|
153 | - ); |
|
154 | - $this->endpoints['endpoint_workout'] = array( |
|
155 | - 'title' => __( 'Single Workout Endpoint', 'lsx-health-plan' ), |
|
156 | - 'default' => 'workout', |
|
157 | - ); |
|
158 | - } |
|
159 | - |
|
160 | - $this->endpoints['login_slug'] = array( |
|
161 | - 'title' => __( 'Login Slug', 'lsx-health-plan' ), |
|
162 | - 'default' => 'login', |
|
163 | - ); |
|
164 | - $this->endpoints['my_plan_slug'] = array( |
|
165 | - 'title' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
166 | - 'default' => 'my-plan', |
|
167 | - ); |
|
168 | - $this->endpoints['plan_single_slug'] = array( |
|
169 | - 'title' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
170 | - 'default' => 'plan', |
|
171 | - ); |
|
172 | - $this->endpoints['endpoint_plan_archive'] = array( |
|
173 | - 'title' => __( 'Plans Archive Endpoint', 'lsx-health-plan' ), |
|
174 | - 'default' => 'plans', |
|
175 | - ); |
|
176 | - |
|
177 | - if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
178 | - $this->endpoints['exercise'] = array( |
|
179 | - 'exercise_single' => array( |
|
180 | - 'title' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
181 | - 'default' => 'exercise', |
|
182 | - ), |
|
183 | - 'exercise_archive' => array( |
|
184 | - 'title' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
185 | - 'default' => 'exercises', |
|
186 | - ), |
|
187 | - 'exercise_type' => array( |
|
188 | - 'title' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
189 | - 'default' => 'exercise-type', |
|
190 | - ), |
|
191 | - 'exercise_equipment' => array( |
|
192 | - 'title' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
193 | - 'default' => 'equipment', |
|
194 | - ), |
|
195 | - 'exercise_musclegroup' => array( |
|
196 | - 'title' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
197 | - 'default' => 'muscle-group', |
|
198 | - ), |
|
199 | - ); |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * Hook in and register a submenu options page for the Page post-type menu. |
|
205 | - */ |
|
206 | - public function register_settings_page() { |
|
207 | - $this->set_vars(); |
|
208 | - $cmb = new_cmb2_box( |
|
209 | - array( |
|
210 | - 'id' => $this->screen_id, |
|
211 | - 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
212 | - 'object_types' => array( 'options-page' ), |
|
213 | - 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
|
214 | - 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
|
215 | - 'capability' => 'manage_options', // Cap required to view options-page. |
|
216 | - ) |
|
217 | - ); |
|
218 | - do_action( 'lsx_hp_settings_page', $cmb ); |
|
219 | - } |
|
220 | - |
|
221 | - /** |
|
222 | - * Registers the general settings. |
|
223 | - * |
|
224 | - * @param object $cmb new_cmb2_box(). |
|
225 | - * @return void |
|
226 | - */ |
|
227 | - public function general_settings( $cmb ) { |
|
228 | - $cmb->add_field( |
|
229 | - array( |
|
230 | - 'id' => 'settings_general_title', |
|
231 | - 'type' => 'title', |
|
232 | - 'name' => __( 'General', 'lsx-health-plan' ), |
|
233 | - 'default' => __( 'General', 'lsx-health-plan' ), |
|
234 | - ) |
|
235 | - ); |
|
236 | - $cmb->add_field( |
|
237 | - array( |
|
238 | - 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
239 | - 'id' => 'membership_product', |
|
240 | - 'type' => 'post_search_ajax', |
|
241 | - 'limit' => 1, |
|
242 | - 'sortable' => false, |
|
243 | - 'query_args' => array( |
|
244 | - 'post_type' => array( 'product' ), |
|
245 | - 'post_status' => array( 'publish' ), |
|
246 | - 'posts_per_page' => -1, |
|
247 | - ), |
|
248 | - ) |
|
249 | - ); |
|
250 | - |
|
251 | - $cmb->add_field( |
|
252 | - array( |
|
253 | - 'name' => __( 'Your Warm-up Intro', 'lsx-health-plan' ), |
|
254 | - 'id' => 'warmup_intro', |
|
255 | - 'type' => 'textarea', |
|
256 | - 'value' => '', |
|
257 | - 'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ), |
|
258 | - ) |
|
259 | - ); |
|
260 | - if ( post_type_exists( 'workout' ) ) { |
|
261 | - $cmb->add_field( |
|
262 | - array( |
|
263 | - 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
264 | - 'id' => 'workout_intro', |
|
265 | - 'type' => 'textarea', |
|
266 | - 'value' => '', |
|
267 | - 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
268 | - ) |
|
269 | - ); |
|
270 | - } |
|
271 | - if ( post_type_exists( 'meal' ) ) { |
|
272 | - $cmb->add_field( |
|
273 | - array( |
|
274 | - 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
275 | - 'id' => 'meal_plan_intro', |
|
276 | - 'type' => 'textarea', |
|
277 | - 'value' => '', |
|
278 | - 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
279 | - ) |
|
280 | - ); |
|
281 | - } |
|
282 | - if ( post_type_exists( 'recipe' ) ) { |
|
283 | - $cmb->add_field( |
|
284 | - array( |
|
285 | - 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
286 | - 'id' => 'recipes_intro', |
|
287 | - 'type' => 'textarea', |
|
288 | - 'value' => '', |
|
289 | - 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
290 | - ) |
|
291 | - ); |
|
292 | - } |
|
293 | - $cmb->add_field( |
|
294 | - array( |
|
295 | - 'id' => 'settings_general_closing', |
|
296 | - 'type' => 'tab_closing', |
|
297 | - ) |
|
298 | - ); |
|
299 | - } |
|
300 | - |
|
301 | - /** |
|
302 | - * Registers the global default settings. |
|
303 | - * |
|
304 | - * @param object $cmb new_cmb2_box(). |
|
305 | - * @return void |
|
306 | - */ |
|
307 | - public function global_defaults( $cmb ) { |
|
308 | - $cmb->add_field( |
|
309 | - array( |
|
310 | - 'id' => 'global_defaults_title', |
|
311 | - 'type' => 'title', |
|
312 | - 'name' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
313 | - 'default' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
314 | - ) |
|
315 | - ); |
|
316 | - |
|
317 | - foreach ( $this->default_types as $type => $default_type ) { |
|
318 | - $limit = 5; |
|
319 | - $sortable = false; |
|
320 | - if ( isset( $default_type['limit'] ) ) { |
|
321 | - $limit = $default_type['limit']; |
|
322 | - $sortable = true; |
|
323 | - } |
|
324 | - |
|
325 | - if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
326 | - $type = array( 'page', 'workout' ); |
|
327 | - } |
|
328 | - |
|
329 | - $cmb->add_field( |
|
330 | - array( |
|
331 | - 'name' => $default_type['title'], |
|
332 | - 'desc' => $default_type['description'], |
|
333 | - 'id' => $default_type['id'], |
|
334 | - 'type' => 'post_search_ajax', |
|
335 | - 'limit' => $limit, |
|
336 | - 'sortable' => $sortable, |
|
337 | - 'query_args' => array( |
|
338 | - 'post_type' => $type, |
|
339 | - 'post_status' => array( 'publish' ), |
|
340 | - 'posts_per_page' => -1, |
|
341 | - ), |
|
342 | - ) |
|
343 | - ); |
|
344 | - } |
|
345 | - |
|
346 | - $cmb->add_field( |
|
347 | - array( |
|
348 | - 'id' => 'settings_global_defaults_closing', |
|
349 | - 'type' => 'tab_closing', |
|
350 | - ) |
|
351 | - ); |
|
352 | - } |
|
353 | - |
|
354 | - /** |
|
355 | - * Registers the global dowloads settings |
|
356 | - * |
|
357 | - * @param object $cmb new_cmb2_box(). |
|
358 | - * @return void |
|
359 | - */ |
|
360 | - public function global_downloads( $cmb ) { |
|
361 | - $cmb->add_field( |
|
362 | - array( |
|
363 | - 'id' => 'global_downloads_title', |
|
364 | - 'type' => 'title', |
|
365 | - 'name' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
366 | - 'default' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
367 | - ) |
|
368 | - ); |
|
369 | - |
|
370 | - foreach ( $this->download_types as $type => $download_type ) { |
|
371 | - $limit = 5; |
|
372 | - $sortable = false; |
|
373 | - if ( isset( $download_type['limit'] ) ) { |
|
374 | - $limit = $download_type['limit']; |
|
375 | - $sortable = true; |
|
376 | - } |
|
377 | - |
|
378 | - $cmb->add_field( |
|
379 | - array( |
|
380 | - 'name' => $download_type['title'], |
|
381 | - 'id' => 'download_' . $type, |
|
382 | - 'type' => 'post_search_ajax', |
|
383 | - 'limit' => $limit, |
|
384 | - 'sortable' => $sortable, |
|
385 | - 'query_args' => array( |
|
386 | - 'post_type' => array( 'dlm_download' ), |
|
387 | - 'post_status' => array( 'publish' ), |
|
388 | - 'posts_per_page' => -1, |
|
389 | - ), |
|
390 | - ) |
|
391 | - ); |
|
392 | - } |
|
393 | - $cmb->add_field( |
|
394 | - array( |
|
395 | - 'id' => 'settings_global_downloads_closing', |
|
396 | - 'type' => 'tab_closing', |
|
397 | - ) |
|
398 | - ); |
|
399 | - } |
|
400 | - |
|
401 | - /** |
|
402 | - * Registers the endpoint translation settings. |
|
403 | - * |
|
404 | - * @param object $cmb new_cmb2_box(). |
|
405 | - * @return void |
|
406 | - */ |
|
407 | - public function endpoint_translations( $cmb ) { |
|
408 | - $cmb->add_field( |
|
409 | - array( |
|
410 | - 'id' => 'endpoints_title', |
|
411 | - 'type' => 'title', |
|
412 | - 'name' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
413 | - 'default' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
414 | - 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
415 | - ) |
|
416 | - ); |
|
417 | - foreach ( $this->endpoints as $slug => $endpoint_vars ) { |
|
418 | - if ( 'exercise' === $slug ) { |
|
419 | - continue; |
|
420 | - } |
|
421 | - |
|
422 | - $cmb->add_field( |
|
423 | - array( |
|
424 | - 'name' => $endpoint_vars['title'], |
|
425 | - 'id' => $slug, |
|
426 | - 'type' => 'input', |
|
427 | - 'value' => '', |
|
428 | - 'default' => $endpoint_vars['default'], |
|
429 | - ) |
|
430 | - ); |
|
431 | - } |
|
432 | - $cmb->add_field( |
|
433 | - array( |
|
434 | - 'id' => 'settings_endpoints_closing', |
|
435 | - 'type' => 'tab_closing', |
|
436 | - ) |
|
437 | - ); |
|
438 | - } |
|
439 | - |
|
440 | - /** |
|
441 | - * Registers the endpoint translation settings. |
|
442 | - * |
|
443 | - * @param object $cmb new_cmb2_box(). |
|
444 | - * @return void |
|
445 | - */ |
|
446 | - public function exercise_translations( $cmb ) { |
|
447 | - if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) { |
|
448 | - $cmb->add_field( |
|
449 | - array( |
|
450 | - 'id' => 'exercise_endpoints_title', |
|
451 | - 'type' => 'title', |
|
452 | - 'name' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
453 | - 'default' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
454 | - 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
455 | - ) |
|
456 | - ); |
|
457 | - |
|
458 | - foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) { |
|
459 | - $cmb->add_field( |
|
460 | - array( |
|
461 | - 'name' => $endpoint_vars['title'], |
|
462 | - 'id' => 'endpoint_' . $slug, |
|
463 | - 'type' => 'input', |
|
464 | - 'value' => '', |
|
465 | - 'default' => $endpoint_vars['default'], |
|
466 | - ) |
|
467 | - ); |
|
468 | - } |
|
469 | - $cmb->add_field( |
|
470 | - array( |
|
471 | - 'id' => 'settings_exercise_closing', |
|
472 | - 'type' => 'tab_closing', |
|
473 | - ) |
|
474 | - ); |
|
475 | - } |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Registers the post type toggle settings |
|
480 | - * |
|
481 | - * @param object $cmb new_cmb2_box(). |
|
482 | - * @return void |
|
483 | - */ |
|
484 | - public function post_type_toggles( $cmb ) { |
|
485 | - $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
486 | - |
|
487 | - $cmb->add_field( |
|
488 | - array( |
|
489 | - 'id' => 'post_type_toggles_title', |
|
490 | - 'type' => 'title', |
|
491 | - 'name' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
492 | - 'default' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
493 | - 'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
494 | - ) |
|
495 | - ); |
|
496 | - |
|
497 | - foreach ( $post_types as $post_type ) { |
|
498 | - if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) { |
|
499 | - continue; |
|
500 | - } |
|
501 | - |
|
502 | - $cmb->add_field( |
|
503 | - array( |
|
504 | - 'name' => ucwords( $post_type ), |
|
505 | - 'id' => $post_type . '_disabled', |
|
506 | - 'type' => 'checkbox', |
|
507 | - 'value' => 1, |
|
508 | - 'default' => 0, |
|
509 | - ) |
|
510 | - ); |
|
511 | - } |
|
512 | - |
|
513 | - $cmb->add_field( |
|
514 | - array( |
|
515 | - 'id' => 'settings_post_type_toggles_closing', |
|
516 | - 'type' => 'tab_closing', |
|
517 | - ) |
|
518 | - ); |
|
519 | - |
|
520 | - $cmb->add_field( |
|
521 | - array( |
|
522 | - 'id' => 'post_type_toggles_enable_title', |
|
523 | - 'type' => 'title', |
|
524 | - 'name' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
525 | - 'default' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
526 | - 'description' => __( 'Enable new functionailty like the "exercise" post type.', 'lsx-health-plan' ), |
|
527 | - ) |
|
528 | - ); |
|
529 | - $cmb->add_field( |
|
530 | - array( |
|
531 | - 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
532 | - 'id' => 'exercise_enabled', |
|
533 | - 'type' => 'checkbox', |
|
534 | - 'value' => 1, |
|
535 | - 'default' => 0, |
|
536 | - 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
537 | - ) |
|
538 | - ); |
|
539 | - $cmb->add_field( |
|
540 | - array( |
|
541 | - 'id' => 'settings_post_type_toggles_enable_closing', |
|
542 | - 'type' => 'tab_closing', |
|
543 | - ) |
|
544 | - ); |
|
545 | - } |
|
546 | - /** |
|
547 | - * Registers the Profile Stat Toggle settings |
|
548 | - * |
|
549 | - * @param object $cmb new_cmb2_box(). |
|
550 | - * @return void |
|
551 | - */ |
|
552 | - |
|
553 | - public function stat_disable( $cmb ) { |
|
554 | - $cmb->add_field( |
|
555 | - array( |
|
556 | - 'id' => 'stat_disable_title', |
|
557 | - 'type' => 'title', |
|
558 | - 'name' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
559 | - 'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
560 | - ) |
|
561 | - ); |
|
562 | - $cmb->add_field( |
|
563 | - array( |
|
564 | - 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
565 | - 'desc' => 'Disable All Stats', |
|
566 | - 'id' => 'disable_all_stats', |
|
567 | - 'type' => 'checkbox', |
|
568 | - 'value' => 1, |
|
569 | - 'default' => 0, |
|
570 | - ) |
|
571 | - ); |
|
572 | - $cmb->add_field( |
|
573 | - array( |
|
574 | - 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
575 | - 'id' => 'disable_weight_checkbox', |
|
576 | - 'type' => 'checkbox', |
|
577 | - 'value' => 1, |
|
578 | - 'default' => 0, |
|
579 | - ) |
|
580 | - ); |
|
581 | - $cmb->add_field( |
|
582 | - array( |
|
583 | - 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
584 | - 'id' => 'disable_waist_checkbox', |
|
585 | - 'type' => 'checkbox', |
|
586 | - 'value' => 1, |
|
587 | - 'default' => 0, |
|
588 | - ) |
|
589 | - ); |
|
590 | - $cmb->add_field( |
|
591 | - array( |
|
592 | - 'name' => __( 'Disable Fitness', 'lsx-health-plan' ), |
|
593 | - 'id' => 'disable_fitness_checkbox', |
|
594 | - 'type' => 'checkbox', |
|
595 | - 'value' => 1, |
|
596 | - 'default' => 0, |
|
597 | - ) |
|
598 | - ); |
|
599 | - $cmb->add_field( |
|
600 | - array( |
|
601 | - 'id' => 'settings_stat_disable_closing', |
|
602 | - 'type' => 'tab_closing', |
|
603 | - ) |
|
604 | - ); |
|
605 | - } |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Settings() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * Option key, and option page slug |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $screen_id = 'lsx_health_plan_settings'; |
|
30 | + |
|
31 | + /** |
|
32 | + * An array of the post types for the Global Downloads field. |
|
33 | + * |
|
34 | + * @var array |
|
35 | + */ |
|
36 | + public $download_types = array(); |
|
37 | + |
|
38 | + /** |
|
39 | + * An array of the post types for the Global Defaults field. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + public $default_types = array(); |
|
44 | + |
|
45 | + /** |
|
46 | + * An array of the endpoints for the Endpoint Translation field. |
|
47 | + * |
|
48 | + * @var array |
|
49 | + */ |
|
50 | + public $endpoints = array(); |
|
51 | + |
|
52 | + /** |
|
53 | + * Contructor |
|
54 | + */ |
|
55 | + public function __construct() { |
|
56 | + add_action( 'cmb2_admin_init', array( $this, 'register_settings_page' ) ); |
|
57 | + add_action( 'lsx_hp_settings_page', array( $this, 'general_settings' ), 1, 1 ); |
|
58 | + add_action( 'lsx_hp_settings_page', array( $this, 'global_defaults' ), 3, 1 ); |
|
59 | + add_action( 'lsx_hp_settings_page', array( $this, 'global_downloads' ), 5, 1 ); |
|
60 | + add_action( 'lsx_hp_settings_page', array( $this, 'stat_disable' ), 6, 1 ); |
|
61 | + add_action( 'lsx_hp_settings_page', array( $this, 'endpoint_translations' ), 7, 1 ); |
|
62 | + add_action( 'lsx_hp_settings_page', array( $this, 'exercise_translations' ), 7, 1 ); |
|
63 | + add_action( 'lsx_hp_settings_page', array( $this, 'post_type_toggles' ), 9, 1 ); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Return an instance of this class. |
|
68 | + * |
|
69 | + * @since 1.0.0 |
|
70 | + * |
|
71 | + * @return object \lsx_health_plan\classes\admin\Settings() A single instance of this class. |
|
72 | + */ |
|
73 | + public static function get_instance() { |
|
74 | + // If the single instance hasn't been set, set it now. |
|
75 | + if ( null === self::$instance ) { |
|
76 | + self::$instance = new self(); |
|
77 | + } |
|
78 | + return self::$instance; |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Sets the variables needed for the fields. |
|
83 | + * |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function set_vars() { |
|
87 | + |
|
88 | + $this->default_types = array( |
|
89 | + 'page' => array( |
|
90 | + 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
91 | + 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
92 | + 'limit' => 1, |
|
93 | + 'id' => 'plan_warmup', |
|
94 | + ), |
|
95 | + ); |
|
96 | + $this->download_types = array( |
|
97 | + 'page' => array( |
|
98 | + 'title' => __( 'Warm Up', 'lsx-health-plan' ), |
|
99 | + 'description' => __( 'Set a default warm up routine.', 'lsx-health-plan' ), |
|
100 | + 'limit' => 1, |
|
101 | + ), |
|
102 | + ); |
|
103 | + $this->endpoints = array( |
|
104 | + 'endpoint_warm_up' => array( |
|
105 | + 'title' => __( 'Warm Up Endpoint', 'lsx-health-plan' ), |
|
106 | + 'default' => 'warm-up', |
|
107 | + ), |
|
108 | + ); |
|
109 | + |
|
110 | + if ( post_type_exists( 'meal' ) ) { |
|
111 | + $this->download_types['meal'] = array( |
|
112 | + 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
113 | + 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
114 | + ); |
|
115 | + $this->default_types['meal'] = array( |
|
116 | + 'title' => __( 'Meal Plan', 'lsx-health-plan' ), |
|
117 | + 'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ), |
|
118 | + 'id' => 'connected_meals', |
|
119 | + ); |
|
120 | + $this->endpoints['endpoint_meal'] = array( |
|
121 | + 'title' => __( 'Meal Endpoint', 'lsx-health-plan' ), |
|
122 | + 'default' => 'meal', |
|
123 | + ); |
|
124 | + } |
|
125 | + if ( post_type_exists( 'recipe' ) ) { |
|
126 | + $this->download_types['recipe'] = array( |
|
127 | + 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
128 | + 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
129 | + ); |
|
130 | + $this->default_types['recipe'] = array( |
|
131 | + 'title' => __( 'Recipe', 'lsx-health-plan' ), |
|
132 | + 'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
|
133 | + 'id' => 'connected_recipes', |
|
134 | + ); |
|
135 | + $this->endpoints['endpoint_recipe'] = array( |
|
136 | + 'title' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
|
137 | + 'default' => 'recipe', |
|
138 | + ); |
|
139 | + } |
|
140 | + if ( post_type_exists( 'workout' ) ) { |
|
141 | + $this->download_types['workout'] = array( |
|
142 | + 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
143 | + 'description' => __( 'Set a default workout routine PDF.', 'lsx-health-plan' ), |
|
144 | + ); |
|
145 | + $this->default_types['workout'] = array( |
|
146 | + 'title' => __( 'Workout', 'lsx-health-plan' ), |
|
147 | + 'description' => __( 'Set a default workout routine.', 'lsx-health-plan' ), |
|
148 | + 'id' => 'connected_workouts', |
|
149 | + ); |
|
150 | + $this->endpoints['endpoint_workout_archive'] = array( |
|
151 | + 'title' => __( 'Workouts Archive Endpoint', 'lsx-health-plan' ), |
|
152 | + 'default' => '', |
|
153 | + ); |
|
154 | + $this->endpoints['endpoint_workout'] = array( |
|
155 | + 'title' => __( 'Single Workout Endpoint', 'lsx-health-plan' ), |
|
156 | + 'default' => 'workout', |
|
157 | + ); |
|
158 | + } |
|
159 | + |
|
160 | + $this->endpoints['login_slug'] = array( |
|
161 | + 'title' => __( 'Login Slug', 'lsx-health-plan' ), |
|
162 | + 'default' => 'login', |
|
163 | + ); |
|
164 | + $this->endpoints['my_plan_slug'] = array( |
|
165 | + 'title' => __( 'My Plan Slug', 'lsx-health-plan' ), |
|
166 | + 'default' => 'my-plan', |
|
167 | + ); |
|
168 | + $this->endpoints['plan_single_slug'] = array( |
|
169 | + 'title' => __( 'Single Plan Slug', 'lsx-health-plan' ), |
|
170 | + 'default' => 'plan', |
|
171 | + ); |
|
172 | + $this->endpoints['endpoint_plan_archive'] = array( |
|
173 | + 'title' => __( 'Plans Archive Endpoint', 'lsx-health-plan' ), |
|
174 | + 'default' => 'plans', |
|
175 | + ); |
|
176 | + |
|
177 | + if ( false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
178 | + $this->endpoints['exercise'] = array( |
|
179 | + 'exercise_single' => array( |
|
180 | + 'title' => __( 'Single Exercise Slug', 'lsx-health-plan' ), |
|
181 | + 'default' => 'exercise', |
|
182 | + ), |
|
183 | + 'exercise_archive' => array( |
|
184 | + 'title' => __( 'Archive Exercise Slug', 'lsx-health-plan' ), |
|
185 | + 'default' => 'exercises', |
|
186 | + ), |
|
187 | + 'exercise_type' => array( |
|
188 | + 'title' => __( 'Exercise Type Slug', 'lsx-health-plan' ), |
|
189 | + 'default' => 'exercise-type', |
|
190 | + ), |
|
191 | + 'exercise_equipment' => array( |
|
192 | + 'title' => __( 'Equipment Slug', 'lsx-health-plan' ), |
|
193 | + 'default' => 'equipment', |
|
194 | + ), |
|
195 | + 'exercise_musclegroup' => array( |
|
196 | + 'title' => __( 'Muscle Group Slug', 'lsx-health-plan' ), |
|
197 | + 'default' => 'muscle-group', |
|
198 | + ), |
|
199 | + ); |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * Hook in and register a submenu options page for the Page post-type menu. |
|
205 | + */ |
|
206 | + public function register_settings_page() { |
|
207 | + $this->set_vars(); |
|
208 | + $cmb = new_cmb2_box( |
|
209 | + array( |
|
210 | + 'id' => $this->screen_id, |
|
211 | + 'title' => esc_html__( 'Settings', 'lsx-health-plan' ), |
|
212 | + 'object_types' => array( 'options-page' ), |
|
213 | + 'option_key' => 'lsx_health_plan_options', // The option key and admin menu page slug. |
|
214 | + 'parent_slug' => 'edit.php?post_type=plan', // Make options page a submenu item of the themes menu. |
|
215 | + 'capability' => 'manage_options', // Cap required to view options-page. |
|
216 | + ) |
|
217 | + ); |
|
218 | + do_action( 'lsx_hp_settings_page', $cmb ); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Registers the general settings. |
|
223 | + * |
|
224 | + * @param object $cmb new_cmb2_box(). |
|
225 | + * @return void |
|
226 | + */ |
|
227 | + public function general_settings( $cmb ) { |
|
228 | + $cmb->add_field( |
|
229 | + array( |
|
230 | + 'id' => 'settings_general_title', |
|
231 | + 'type' => 'title', |
|
232 | + 'name' => __( 'General', 'lsx-health-plan' ), |
|
233 | + 'default' => __( 'General', 'lsx-health-plan' ), |
|
234 | + ) |
|
235 | + ); |
|
236 | + $cmb->add_field( |
|
237 | + array( |
|
238 | + 'name' => __( 'Membership Product', 'lsx-health-plan' ), |
|
239 | + 'id' => 'membership_product', |
|
240 | + 'type' => 'post_search_ajax', |
|
241 | + 'limit' => 1, |
|
242 | + 'sortable' => false, |
|
243 | + 'query_args' => array( |
|
244 | + 'post_type' => array( 'product' ), |
|
245 | + 'post_status' => array( 'publish' ), |
|
246 | + 'posts_per_page' => -1, |
|
247 | + ), |
|
248 | + ) |
|
249 | + ); |
|
250 | + |
|
251 | + $cmb->add_field( |
|
252 | + array( |
|
253 | + 'name' => __( 'Your Warm-up Intro', 'lsx-health-plan' ), |
|
254 | + 'id' => 'warmup_intro', |
|
255 | + 'type' => 'textarea', |
|
256 | + 'value' => '', |
|
257 | + 'default' => __( "Don't forget your warm-up! It's a vital part of your daily workout routine.", 'lsx-health-plan' ), |
|
258 | + ) |
|
259 | + ); |
|
260 | + if ( post_type_exists( 'workout' ) ) { |
|
261 | + $cmb->add_field( |
|
262 | + array( |
|
263 | + 'name' => __( 'Your Workout Intro', 'lsx-health-plan' ), |
|
264 | + 'id' => 'workout_intro', |
|
265 | + 'type' => 'textarea', |
|
266 | + 'value' => '', |
|
267 | + 'default' => __( "Let's do this! Smash your daily workout and reach your fitness goals.", 'lsx-health-plan' ), |
|
268 | + ) |
|
269 | + ); |
|
270 | + } |
|
271 | + if ( post_type_exists( 'meal' ) ) { |
|
272 | + $cmb->add_field( |
|
273 | + array( |
|
274 | + 'name' => __( 'Your Meal Plan Intro', 'lsx-health-plan' ), |
|
275 | + 'id' => 'meal_plan_intro', |
|
276 | + 'type' => 'textarea', |
|
277 | + 'value' => '', |
|
278 | + 'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ), |
|
279 | + ) |
|
280 | + ); |
|
281 | + } |
|
282 | + if ( post_type_exists( 'recipe' ) ) { |
|
283 | + $cmb->add_field( |
|
284 | + array( |
|
285 | + 'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
|
286 | + 'id' => 'recipes_intro', |
|
287 | + 'type' => 'textarea', |
|
288 | + 'value' => '', |
|
289 | + 'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
|
290 | + ) |
|
291 | + ); |
|
292 | + } |
|
293 | + $cmb->add_field( |
|
294 | + array( |
|
295 | + 'id' => 'settings_general_closing', |
|
296 | + 'type' => 'tab_closing', |
|
297 | + ) |
|
298 | + ); |
|
299 | + } |
|
300 | + |
|
301 | + /** |
|
302 | + * Registers the global default settings. |
|
303 | + * |
|
304 | + * @param object $cmb new_cmb2_box(). |
|
305 | + * @return void |
|
306 | + */ |
|
307 | + public function global_defaults( $cmb ) { |
|
308 | + $cmb->add_field( |
|
309 | + array( |
|
310 | + 'id' => 'global_defaults_title', |
|
311 | + 'type' => 'title', |
|
312 | + 'name' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
313 | + 'default' => __( 'Global Defaults', 'lsx-health-plan' ), |
|
314 | + ) |
|
315 | + ); |
|
316 | + |
|
317 | + foreach ( $this->default_types as $type => $default_type ) { |
|
318 | + $limit = 5; |
|
319 | + $sortable = false; |
|
320 | + if ( isset( $default_type['limit'] ) ) { |
|
321 | + $limit = $default_type['limit']; |
|
322 | + $sortable = true; |
|
323 | + } |
|
324 | + |
|
325 | + if ( 'page' === $type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) { |
|
326 | + $type = array( 'page', 'workout' ); |
|
327 | + } |
|
328 | + |
|
329 | + $cmb->add_field( |
|
330 | + array( |
|
331 | + 'name' => $default_type['title'], |
|
332 | + 'desc' => $default_type['description'], |
|
333 | + 'id' => $default_type['id'], |
|
334 | + 'type' => 'post_search_ajax', |
|
335 | + 'limit' => $limit, |
|
336 | + 'sortable' => $sortable, |
|
337 | + 'query_args' => array( |
|
338 | + 'post_type' => $type, |
|
339 | + 'post_status' => array( 'publish' ), |
|
340 | + 'posts_per_page' => -1, |
|
341 | + ), |
|
342 | + ) |
|
343 | + ); |
|
344 | + } |
|
345 | + |
|
346 | + $cmb->add_field( |
|
347 | + array( |
|
348 | + 'id' => 'settings_global_defaults_closing', |
|
349 | + 'type' => 'tab_closing', |
|
350 | + ) |
|
351 | + ); |
|
352 | + } |
|
353 | + |
|
354 | + /** |
|
355 | + * Registers the global dowloads settings |
|
356 | + * |
|
357 | + * @param object $cmb new_cmb2_box(). |
|
358 | + * @return void |
|
359 | + */ |
|
360 | + public function global_downloads( $cmb ) { |
|
361 | + $cmb->add_field( |
|
362 | + array( |
|
363 | + 'id' => 'global_downloads_title', |
|
364 | + 'type' => 'title', |
|
365 | + 'name' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
366 | + 'default' => __( 'Global Downloads', 'lsx-health-plan' ), |
|
367 | + ) |
|
368 | + ); |
|
369 | + |
|
370 | + foreach ( $this->download_types as $type => $download_type ) { |
|
371 | + $limit = 5; |
|
372 | + $sortable = false; |
|
373 | + if ( isset( $download_type['limit'] ) ) { |
|
374 | + $limit = $download_type['limit']; |
|
375 | + $sortable = true; |
|
376 | + } |
|
377 | + |
|
378 | + $cmb->add_field( |
|
379 | + array( |
|
380 | + 'name' => $download_type['title'], |
|
381 | + 'id' => 'download_' . $type, |
|
382 | + 'type' => 'post_search_ajax', |
|
383 | + 'limit' => $limit, |
|
384 | + 'sortable' => $sortable, |
|
385 | + 'query_args' => array( |
|
386 | + 'post_type' => array( 'dlm_download' ), |
|
387 | + 'post_status' => array( 'publish' ), |
|
388 | + 'posts_per_page' => -1, |
|
389 | + ), |
|
390 | + ) |
|
391 | + ); |
|
392 | + } |
|
393 | + $cmb->add_field( |
|
394 | + array( |
|
395 | + 'id' => 'settings_global_downloads_closing', |
|
396 | + 'type' => 'tab_closing', |
|
397 | + ) |
|
398 | + ); |
|
399 | + } |
|
400 | + |
|
401 | + /** |
|
402 | + * Registers the endpoint translation settings. |
|
403 | + * |
|
404 | + * @param object $cmb new_cmb2_box(). |
|
405 | + * @return void |
|
406 | + */ |
|
407 | + public function endpoint_translations( $cmb ) { |
|
408 | + $cmb->add_field( |
|
409 | + array( |
|
410 | + 'id' => 'endpoints_title', |
|
411 | + 'type' => 'title', |
|
412 | + 'name' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
413 | + 'default' => __( 'Set Endpoint Translations', 'lsx-health-plan' ), |
|
414 | + 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
415 | + ) |
|
416 | + ); |
|
417 | + foreach ( $this->endpoints as $slug => $endpoint_vars ) { |
|
418 | + if ( 'exercise' === $slug ) { |
|
419 | + continue; |
|
420 | + } |
|
421 | + |
|
422 | + $cmb->add_field( |
|
423 | + array( |
|
424 | + 'name' => $endpoint_vars['title'], |
|
425 | + 'id' => $slug, |
|
426 | + 'type' => 'input', |
|
427 | + 'value' => '', |
|
428 | + 'default' => $endpoint_vars['default'], |
|
429 | + ) |
|
430 | + ); |
|
431 | + } |
|
432 | + $cmb->add_field( |
|
433 | + array( |
|
434 | + 'id' => 'settings_endpoints_closing', |
|
435 | + 'type' => 'tab_closing', |
|
436 | + ) |
|
437 | + ); |
|
438 | + } |
|
439 | + |
|
440 | + /** |
|
441 | + * Registers the endpoint translation settings. |
|
442 | + * |
|
443 | + * @param object $cmb new_cmb2_box(). |
|
444 | + * @return void |
|
445 | + */ |
|
446 | + public function exercise_translations( $cmb ) { |
|
447 | + if ( isset( $this->endpoints['exercise'] ) && '' !== $this->endpoints['exercise'] && ! empty( $this->endpoints['exercise'] ) ) { |
|
448 | + $cmb->add_field( |
|
449 | + array( |
|
450 | + 'id' => 'exercise_endpoints_title', |
|
451 | + 'type' => 'title', |
|
452 | + 'name' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
453 | + 'default' => __( 'Set Exercise Translations', 'lsx-health-plan' ), |
|
454 | + 'description' => __( 'You need to resave your permalinks after changing the endpoint settings.', 'lsx-health-plan' ), |
|
455 | + ) |
|
456 | + ); |
|
457 | + |
|
458 | + foreach ( $this->endpoints['exercise'] as $slug => $endpoint_vars ) { |
|
459 | + $cmb->add_field( |
|
460 | + array( |
|
461 | + 'name' => $endpoint_vars['title'], |
|
462 | + 'id' => 'endpoint_' . $slug, |
|
463 | + 'type' => 'input', |
|
464 | + 'value' => '', |
|
465 | + 'default' => $endpoint_vars['default'], |
|
466 | + ) |
|
467 | + ); |
|
468 | + } |
|
469 | + $cmb->add_field( |
|
470 | + array( |
|
471 | + 'id' => 'settings_exercise_closing', |
|
472 | + 'type' => 'tab_closing', |
|
473 | + ) |
|
474 | + ); |
|
475 | + } |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Registers the post type toggle settings |
|
480 | + * |
|
481 | + * @param object $cmb new_cmb2_box(). |
|
482 | + * @return void |
|
483 | + */ |
|
484 | + public function post_type_toggles( $cmb ) { |
|
485 | + $post_types = apply_filters( 'lsx_health_plan_post_types', isset( $this->post_types ) ); |
|
486 | + |
|
487 | + $cmb->add_field( |
|
488 | + array( |
|
489 | + 'id' => 'post_type_toggles_title', |
|
490 | + 'type' => 'title', |
|
491 | + 'name' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
492 | + 'default' => __( 'Disable Post Types', 'lsx-health-plan' ), |
|
493 | + 'description' => __( 'Disable post types if you are wanting a minimal site.', 'lsx-health-plan' ), |
|
494 | + ) |
|
495 | + ); |
|
496 | + |
|
497 | + foreach ( $post_types as $post_type ) { |
|
498 | + if ( 'plan' === $post_type || 'exercise' === $post_type || ( 'video' === $post_type && false !== \lsx_health_plan\functions\get_option( 'exercise_enabled', false ) ) ) { |
|
499 | + continue; |
|
500 | + } |
|
501 | + |
|
502 | + $cmb->add_field( |
|
503 | + array( |
|
504 | + 'name' => ucwords( $post_type ), |
|
505 | + 'id' => $post_type . '_disabled', |
|
506 | + 'type' => 'checkbox', |
|
507 | + 'value' => 1, |
|
508 | + 'default' => 0, |
|
509 | + ) |
|
510 | + ); |
|
511 | + } |
|
512 | + |
|
513 | + $cmb->add_field( |
|
514 | + array( |
|
515 | + 'id' => 'settings_post_type_toggles_closing', |
|
516 | + 'type' => 'tab_closing', |
|
517 | + ) |
|
518 | + ); |
|
519 | + |
|
520 | + $cmb->add_field( |
|
521 | + array( |
|
522 | + 'id' => 'post_type_toggles_enable_title', |
|
523 | + 'type' => 'title', |
|
524 | + 'name' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
525 | + 'default' => __( 'Enable Post Types', 'lsx-health-plan' ), |
|
526 | + 'description' => __( 'Enable new functionailty like the "exercise" post type.', 'lsx-health-plan' ), |
|
527 | + ) |
|
528 | + ); |
|
529 | + $cmb->add_field( |
|
530 | + array( |
|
531 | + 'name' => __( 'Exercises', 'lsx-health-plan' ), |
|
532 | + 'id' => 'exercise_enabled', |
|
533 | + 'type' => 'checkbox', |
|
534 | + 'value' => 1, |
|
535 | + 'default' => 0, |
|
536 | + 'description' => __( 'Enabling the exercise post type will automatically replace the Video post type.', 'lsx-health-plan' ), |
|
537 | + ) |
|
538 | + ); |
|
539 | + $cmb->add_field( |
|
540 | + array( |
|
541 | + 'id' => 'settings_post_type_toggles_enable_closing', |
|
542 | + 'type' => 'tab_closing', |
|
543 | + ) |
|
544 | + ); |
|
545 | + } |
|
546 | + /** |
|
547 | + * Registers the Profile Stat Toggle settings |
|
548 | + * |
|
549 | + * @param object $cmb new_cmb2_box(). |
|
550 | + * @return void |
|
551 | + */ |
|
552 | + |
|
553 | + public function stat_disable( $cmb ) { |
|
554 | + $cmb->add_field( |
|
555 | + array( |
|
556 | + 'id' => 'stat_disable_title', |
|
557 | + 'type' => 'title', |
|
558 | + 'name' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
559 | + 'default' => __( 'Disable Profile Stats', 'lsx-health-plan' ), |
|
560 | + ) |
|
561 | + ); |
|
562 | + $cmb->add_field( |
|
563 | + array( |
|
564 | + 'name' => __( 'Disable All Stats', 'lsx-health-plan' ), |
|
565 | + 'desc' => 'Disable All Stats', |
|
566 | + 'id' => 'disable_all_stats', |
|
567 | + 'type' => 'checkbox', |
|
568 | + 'value' => 1, |
|
569 | + 'default' => 0, |
|
570 | + ) |
|
571 | + ); |
|
572 | + $cmb->add_field( |
|
573 | + array( |
|
574 | + 'name' => __( 'Disable Weight', 'lsx-health-plan' ), |
|
575 | + 'id' => 'disable_weight_checkbox', |
|
576 | + 'type' => 'checkbox', |
|
577 | + 'value' => 1, |
|
578 | + 'default' => 0, |
|
579 | + ) |
|
580 | + ); |
|
581 | + $cmb->add_field( |
|
582 | + array( |
|
583 | + 'name' => __( 'Disable Waist', 'lsx-health-plan' ), |
|
584 | + 'id' => 'disable_waist_checkbox', |
|
585 | + 'type' => 'checkbox', |
|
586 | + 'value' => 1, |
|
587 | + 'default' => 0, |
|
588 | + ) |
|
589 | + ); |
|
590 | + $cmb->add_field( |
|
591 | + array( |
|
592 | + 'name' => __( 'Disable Fitness', 'lsx-health-plan' ), |
|
593 | + 'id' => 'disable_fitness_checkbox', |
|
594 | + 'type' => 'checkbox', |
|
595 | + 'value' => 1, |
|
596 | + 'default' => 0, |
|
597 | + ) |
|
598 | + ); |
|
599 | + $cmb->add_field( |
|
600 | + array( |
|
601 | + 'id' => 'settings_stat_disable_closing', |
|
602 | + 'type' => 'tab_closing', |
|
603 | + ) |
|
604 | + ); |
|
605 | + } |
|
606 | 606 | } |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | * Contructor |
33 | 33 | */ |
34 | 34 | public function __construct() { |
35 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
36 | - add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
|
37 | - add_action( 'lsx_hp_help', array( $this, 'header' ), 10 ); |
|
38 | - add_action( 'lsx_hp_help', array( $this, 'body' ), 20 ); |
|
39 | - add_action( 'lsx_hp_help', array( $this, 'footer' ), 30 ); |
|
35 | + add_action('admin_enqueue_scripts', array($this, 'assets')); |
|
36 | + add_action('admin_menu', array($this, 'register_menu')); |
|
37 | + add_action('lsx_hp_help', array($this, 'header'), 10); |
|
38 | + add_action('lsx_hp_help', array($this, 'body'), 20); |
|
39 | + add_action('lsx_hp_help', array($this, 'footer'), 30); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public static function get_instance() { |
50 | 50 | // If the single instance hasn't been set, set it now. |
51 | - if ( null === self::$instance ) { |
|
51 | + if (null === self::$instance) { |
|
52 | 52 | self::$instance = new self(); |
53 | 53 | } |
54 | 54 | return self::$instance; |
@@ -64,10 +64,10 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @param string $hook_suffix the current page hook suffix. |
66 | 66 | */ |
67 | - public function assets( $hook_suffix ) { |
|
68 | - if ( 'plan_page_help' === $hook_suffix ) { |
|
69 | - wp_enqueue_style( 'lsx-hp-help-screen', get_template_directory_uri() . '/assets/css/admin/help.css', array(), LSX_VERSION ); |
|
70 | - wp_style_add_data( 'lsx-hp-help-screen', 'rtl', 'replace' ); |
|
67 | + public function assets($hook_suffix) { |
|
68 | + if ('plan_page_help' === $hook_suffix) { |
|
69 | + wp_enqueue_style('lsx-hp-help-screen', get_template_directory_uri() . '/assets/css/admin/help.css', array(), LSX_VERSION); |
|
70 | + wp_style_add_data('lsx-hp-help-screen', 'rtl', 'replace'); |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @subpackage hp-help-page |
79 | 79 | */ |
80 | 80 | public function register_menu() { |
81 | - add_submenu_page( 'edit.php?post_type=plan', __( 'Help', 'lsx-health-plan' ), __( 'Help', 'lsx-health-plan' ), 'manage_options', 'help', array( $this, 'screen' ) ); |
|
81 | + add_submenu_page('edit.php?post_type=plan', __('Help', 'lsx-health-plan'), __('Help', 'lsx-health-plan'), 'manage_options', 'help', array($this, 'screen')); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @hooked lsx_hp_help_body - 20 |
103 | 103 | * @hooked lsx_hp_help_footer - 30 |
104 | 104 | */ |
105 | - do_action( 'lsx_hp_help' ); |
|
105 | + do_action('lsx_hp_help'); |
|
106 | 106 | ?> |
107 | 107 | </div> |
108 | 108 | <?php |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | public function header() { |
118 | 118 | ?> |
119 | 119 | <div class="box enrich"> |
120 | - <h2><?php esc_html_e( 'Built to enrich your WordPress experience.', 'lsx-health-plan' ); ?></h2> |
|
121 | - <p><?php esc_html_e( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris iaculis feugiat consectetur. Integer mollis ex lacus, sed ultrices felis mollis vitae.', 'lsx-health-plan' ); ?></p> |
|
120 | + <h2><?php esc_html_e('Built to enrich your WordPress experience.', 'lsx-health-plan'); ?></h2> |
|
121 | + <p><?php esc_html_e('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris iaculis feugiat consectetur. Integer mollis ex lacus, sed ultrices felis mollis vitae.', 'lsx-health-plan'); ?></p> |
|
122 | 122 | </div> |
123 | 123 | <?php |
124 | 124 | } |
@@ -12,125 +12,125 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class Help_Page { |
14 | 14 | |
15 | - /** |
|
16 | - * Holds class instance |
|
17 | - * |
|
18 | - * @since 1.0.0 |
|
19 | - * |
|
20 | - * @var object \lsx_health_plan\classes\admin\Help_Page() |
|
21 | - */ |
|
22 | - protected static $instance = null; |
|
23 | - |
|
24 | - /** |
|
25 | - * Option key, and option page slug |
|
26 | - * |
|
27 | - * @var string |
|
28 | - */ |
|
29 | - protected $screen_id = 'lsx_hp_help'; |
|
30 | - |
|
31 | - /** |
|
32 | - * Contructor |
|
33 | - */ |
|
34 | - public function __construct() { |
|
35 | - add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
36 | - add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
|
37 | - add_action( 'lsx_hp_help', array( $this, 'header' ), 10 ); |
|
38 | - add_action( 'lsx_hp_help', array( $this, 'body' ), 20 ); |
|
39 | - add_action( 'lsx_hp_help', array( $this, 'footer' ), 30 ); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Return an instance of this class. |
|
44 | - * |
|
45 | - * @since 1.0.0 |
|
46 | - * |
|
47 | - * @return object \lsx_health_plan\classes\admin\Help_Page() A single instance of this class. |
|
48 | - */ |
|
49 | - public static function get_instance() { |
|
50 | - // If the single instance hasn't been set, set it now. |
|
51 | - if ( null === self::$instance ) { |
|
52 | - self::$instance = new self(); |
|
53 | - } |
|
54 | - return self::$instance; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - |
|
59 | - /** |
|
60 | - * Load hp_help screen css. |
|
61 | - * |
|
62 | - * @package lsx |
|
63 | - * @subpackage hp-help-page |
|
64 | - * |
|
65 | - * @param string $hook_suffix the current page hook suffix. |
|
66 | - */ |
|
67 | - public function assets( $hook_suffix ) { |
|
68 | - if ( 'plan_page_help' === $hook_suffix ) { |
|
69 | - wp_enqueue_style( 'lsx-hp-help-screen', get_template_directory_uri() . '/assets/css/admin/help.css', array(), LSX_VERSION ); |
|
70 | - wp_style_add_data( 'lsx-hp-help-screen', 'rtl', 'replace' ); |
|
71 | - } |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Creates the dashboard page. |
|
76 | - * |
|
77 | - * @package lsx |
|
78 | - * @subpackage hp-help-page |
|
79 | - */ |
|
80 | - public function register_menu() { |
|
81 | - add_submenu_page( 'edit.php?post_type=plan', __( 'Help', 'lsx-health-plan' ), __( 'Help', 'lsx-health-plan' ), 'manage_options', 'help', array( $this, 'screen' ) ); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * The help screen. |
|
87 | - * |
|
88 | - * @package lsx |
|
89 | - * @subpackage hp-help-page |
|
90 | - */ |
|
91 | - public function screen() { |
|
92 | - require_once ABSPATH . 'wp-load.php'; |
|
93 | - require_once ABSPATH . 'wp-admin/admin.php'; |
|
94 | - require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
95 | - ?> |
|
15 | + /** |
|
16 | + * Holds class instance |
|
17 | + * |
|
18 | + * @since 1.0.0 |
|
19 | + * |
|
20 | + * @var object \lsx_health_plan\classes\admin\Help_Page() |
|
21 | + */ |
|
22 | + protected static $instance = null; |
|
23 | + |
|
24 | + /** |
|
25 | + * Option key, and option page slug |
|
26 | + * |
|
27 | + * @var string |
|
28 | + */ |
|
29 | + protected $screen_id = 'lsx_hp_help'; |
|
30 | + |
|
31 | + /** |
|
32 | + * Contructor |
|
33 | + */ |
|
34 | + public function __construct() { |
|
35 | + add_action( 'admin_enqueue_scripts', array( $this, 'assets' ) ); |
|
36 | + add_action( 'admin_menu', array( $this, 'register_menu' ) ); |
|
37 | + add_action( 'lsx_hp_help', array( $this, 'header' ), 10 ); |
|
38 | + add_action( 'lsx_hp_help', array( $this, 'body' ), 20 ); |
|
39 | + add_action( 'lsx_hp_help', array( $this, 'footer' ), 30 ); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Return an instance of this class. |
|
44 | + * |
|
45 | + * @since 1.0.0 |
|
46 | + * |
|
47 | + * @return object \lsx_health_plan\classes\admin\Help_Page() A single instance of this class. |
|
48 | + */ |
|
49 | + public static function get_instance() { |
|
50 | + // If the single instance hasn't been set, set it now. |
|
51 | + if ( null === self::$instance ) { |
|
52 | + self::$instance = new self(); |
|
53 | + } |
|
54 | + return self::$instance; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + |
|
59 | + /** |
|
60 | + * Load hp_help screen css. |
|
61 | + * |
|
62 | + * @package lsx |
|
63 | + * @subpackage hp-help-page |
|
64 | + * |
|
65 | + * @param string $hook_suffix the current page hook suffix. |
|
66 | + */ |
|
67 | + public function assets( $hook_suffix ) { |
|
68 | + if ( 'plan_page_help' === $hook_suffix ) { |
|
69 | + wp_enqueue_style( 'lsx-hp-help-screen', get_template_directory_uri() . '/assets/css/admin/help.css', array(), LSX_VERSION ); |
|
70 | + wp_style_add_data( 'lsx-hp-help-screen', 'rtl', 'replace' ); |
|
71 | + } |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Creates the dashboard page. |
|
76 | + * |
|
77 | + * @package lsx |
|
78 | + * @subpackage hp-help-page |
|
79 | + */ |
|
80 | + public function register_menu() { |
|
81 | + add_submenu_page( 'edit.php?post_type=plan', __( 'Help', 'lsx-health-plan' ), __( 'Help', 'lsx-health-plan' ), 'manage_options', 'help', array( $this, 'screen' ) ); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * The help screen. |
|
87 | + * |
|
88 | + * @package lsx |
|
89 | + * @subpackage hp-help-page |
|
90 | + */ |
|
91 | + public function screen() { |
|
92 | + require_once ABSPATH . 'wp-load.php'; |
|
93 | + require_once ABSPATH . 'wp-admin/admin.php'; |
|
94 | + require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
95 | + ?> |
|
96 | 96 | <div class="wrap about-wrap"> |
97 | 97 | <?php |
98 | - /** |
|
99 | - * Functions hooked into lsx_hp_help action |
|
100 | - * |
|
101 | - * @hooked lsx_hp_help_header - 10 |
|
102 | - * @hooked lsx_hp_help_body - 20 |
|
103 | - * @hooked lsx_hp_help_footer - 30 |
|
104 | - */ |
|
105 | - do_action( 'lsx_hp_help' ); |
|
106 | - ?> |
|
98 | + /** |
|
99 | + * Functions hooked into lsx_hp_help action |
|
100 | + * |
|
101 | + * @hooked lsx_hp_help_header - 10 |
|
102 | + * @hooked lsx_hp_help_body - 20 |
|
103 | + * @hooked lsx_hp_help_footer - 30 |
|
104 | + */ |
|
105 | + do_action( 'lsx_hp_help' ); |
|
106 | + ?> |
|
107 | 107 | </div> |
108 | 108 | <?php |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Help screen intro. |
|
113 | - * |
|
114 | - * @package lsx |
|
115 | - * @subpackage hp-help-page |
|
116 | - */ |
|
117 | - public function header() { |
|
118 | - ?> |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Help screen intro. |
|
113 | + * |
|
114 | + * @package lsx |
|
115 | + * @subpackage hp-help-page |
|
116 | + */ |
|
117 | + public function header() { |
|
118 | + ?> |
|
119 | 119 | <div class="box enrich"> |
120 | 120 | <h2><?php esc_html_e( 'Built to enrich your WordPress experience.', 'lsx-health-plan' ); ?></h2> |
121 | 121 | <p><?php esc_html_e( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris iaculis feugiat consectetur. Integer mollis ex lacus, sed ultrices felis mollis vitae.', 'lsx-health-plan' ); ?></p> |
122 | 122 | </div> |
123 | 123 | <?php |
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Help screen body section. |
|
128 | - * |
|
129 | - * @package lsx |
|
130 | - * @subpackage hp-help-page |
|
131 | - */ |
|
132 | - public function body() { |
|
133 | - ?> |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Help screen body section. |
|
128 | + * |
|
129 | + * @package lsx |
|
130 | + * @subpackage hp-help-page |
|
131 | + */ |
|
132 | + public function body() { |
|
133 | + ?> |
|
134 | 134 | <div> |
135 | 135 | <ul> |
136 | 136 | <li>Getting started: Setup a new Health Plan site from scratch.</li> |
@@ -153,15 +153,15 @@ discard block |
||
153 | 153 | </ul> |
154 | 154 | </div> |
155 | 155 | <?php |
156 | - } |
|
156 | + } |
|
157 | 157 | |
158 | - /** |
|
159 | - * Help screen contribute section. |
|
160 | - * |
|
161 | - * @package lsx |
|
162 | - * @subpackage hp-help-page |
|
163 | - */ |
|
164 | - public function footer() { |
|
158 | + /** |
|
159 | + * Help screen contribute section. |
|
160 | + * |
|
161 | + * @package lsx |
|
162 | + * @subpackage hp-help-page |
|
163 | + */ |
|
164 | + public function footer() { |
|
165 | 165 | |
166 | - } |
|
166 | + } |
|
167 | 167 | } |
@@ -22,74 +22,74 @@ discard block |
||
22 | 22 | */ |
23 | 23 | public static function get_instance() { |
24 | 24 | // If the single instance hasn't been set, set it now. |
25 | - if ( null == self::$instance ) { |
|
25 | + if (null == self::$instance) { |
|
26 | 26 | self::$instance = new self; |
27 | 27 | } |
28 | 28 | return self::$instance; |
29 | 29 | } |
30 | 30 | |
31 | 31 | public function __construct() { |
32 | - if ( ! get_option( 'lsx_to_scporder_install' ) ) { |
|
32 | + if ( ! get_option('lsx_to_scporder_install')) { |
|
33 | 33 | $this->lsx_to_scporder_install(); |
34 | 34 | } |
35 | 35 | |
36 | - add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
37 | - add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
36 | + add_action('admin_init', array($this, 'refresh')); |
|
37 | + add_action('admin_init', array($this, 'load_script_css')); |
|
38 | 38 | |
39 | - add_action( 'wp_ajax_update-menu-order', array( |
|
39 | + add_action('wp_ajax_update-menu-order', array( |
|
40 | 40 | $this, |
41 | 41 | 'update_menu_order', |
42 | - ) ); |
|
43 | - add_action( 'wp_ajax_update-menu-order-tags', array( |
|
42 | + )); |
|
43 | + add_action('wp_ajax_update-menu-order-tags', array( |
|
44 | 44 | $this, |
45 | 45 | 'update_menu_order_tags', |
46 | - ) ); |
|
46 | + )); |
|
47 | 47 | |
48 | - add_action( 'pre_get_posts', array( |
|
48 | + add_action('pre_get_posts', array( |
|
49 | 49 | $this, |
50 | 50 | 'lsx_to_scporder_pre_get_posts', |
51 | - ) ); |
|
51 | + )); |
|
52 | 52 | |
53 | - add_filter( 'get_previous_post_where', array( |
|
53 | + add_filter('get_previous_post_where', array( |
|
54 | 54 | $this, |
55 | 55 | 'lsx_to_scporder_previous_post_where', |
56 | - ) ); |
|
57 | - add_filter( 'get_previous_post_sort', array( |
|
56 | + )); |
|
57 | + add_filter('get_previous_post_sort', array( |
|
58 | 58 | $this, |
59 | 59 | 'lsx_to_scporder_previous_post_sort', |
60 | - ) ); |
|
61 | - add_filter( 'get_next_post_where', array( |
|
60 | + )); |
|
61 | + add_filter('get_next_post_where', array( |
|
62 | 62 | $this, |
63 | 63 | 'lsx_to_scporder_next_post_where', |
64 | - ) ); |
|
65 | - add_filter( 'get_next_post_sort', array( |
|
64 | + )); |
|
65 | + add_filter('get_next_post_sort', array( |
|
66 | 66 | $this, |
67 | 67 | 'lsx_to_scporder_next_post_sort', |
68 | - ) ); |
|
68 | + )); |
|
69 | 69 | |
70 | - add_filter( 'get_terms_orderby', array( |
|
70 | + add_filter('get_terms_orderby', array( |
|
71 | 71 | $this, |
72 | 72 | 'lsx_to_scporder_get_terms_orderby', |
73 | - ), 10, 3 ); |
|
74 | - add_filter( 'wp_get_object_terms', array( |
|
73 | + ), 10, 3); |
|
74 | + add_filter('wp_get_object_terms', array( |
|
75 | 75 | $this, |
76 | 76 | 'lsx_to_scporder_get_object_terms', |
77 | - ), 10, 4 ); |
|
78 | - add_filter( 'get_terms', array( |
|
77 | + ), 10, 4); |
|
78 | + add_filter('get_terms', array( |
|
79 | 79 | $this, |
80 | 80 | 'lsx_to_scporder_get_object_terms', |
81 | - ), 10, 4 ); |
|
81 | + ), 10, 4); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | public function lsx_to_scporder_install() { |
85 | 85 | global $wpdb; |
86 | - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); |
|
86 | + $result = $wpdb->query("DESCRIBE $wpdb->terms `lsx_to_term_order`"); |
|
87 | 87 | |
88 | - if ( ! $result ) { |
|
89 | - $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); |
|
88 | + if ( ! $result) { |
|
89 | + $result = $wpdb->query("ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'"); |
|
90 | 90 | } |
91 | 91 | |
92 | - update_option( 'lsx_to_scporder_install', 1 ); |
|
92 | + update_option('lsx_to_scporder_install', 1); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | public function _check_load_script_css() { |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | $objects = $this->get_to_scporder_options_objects(); |
99 | 99 | $tags = $this->get_to_scporder_options_tags(); |
100 | 100 | |
101 | - if ( empty( $objects ) && empty( $tags ) ) { |
|
101 | + if (empty($objects) && empty($tags)) { |
|
102 | 102 | return false; |
103 | 103 | } |
104 | 104 | |
105 | - if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { |
|
105 | + if (isset($_GET['orderby']) || strstr(sanitize_text_field($_SERVER['REQUEST_URI']), 'action=edit') || strstr(sanitize_text_field($_SERVER['REQUEST_URI']), 'wp-admin/post-new.php')) { |
|
106 | 106 | return false; |
107 | 107 | } |
108 | 108 | |
109 | - if ( ! empty( $objects ) ) { |
|
110 | - if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types |
|
109 | + if ( ! empty($objects)) { |
|
110 | + if (isset($_GET['post_type']) && ! isset($_GET['taxonomy']) && array_key_exists(sanitize_text_field($_GET['post_type']), $objects)) { // if page or custom post types |
|
111 | 111 | $active = true; |
112 | 112 | } |
113 | - if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post |
|
113 | + if ( ! isset($_GET['post_type']) && strstr(sanitize_text_field($_SERVER['REQUEST_URI']), 'wp-admin/edit.php') && array_key_exists('post', $objects)) { // if post |
|
114 | 114 | $active = true; |
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - if ( ! empty( $tags ) ) { |
|
119 | - if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { |
|
118 | + if ( ! empty($tags)) { |
|
119 | + if (isset($_GET['taxonomy']) && array_key_exists(sanitize_text_field($_GET['taxonomy']), $tags)) { |
|
120 | 120 | $active = true; |
121 | 121 | } |
122 | 122 | } |
@@ -125,18 +125,18 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | public function load_script_css() { |
128 | - if ( $this->_check_load_script_css() ) { |
|
129 | - wp_enqueue_script( 'scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
128 | + if ($this->_check_load_script_css()) { |
|
129 | + wp_enqueue_script('scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array('jquery', 'jquery-ui-sortable'), null, true); |
|
130 | 130 | |
131 | 131 | $scporderjs_params = array( |
132 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
133 | - 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
132 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
133 | + 'ajax_nonce' => wp_create_nonce('scporder'), |
|
134 | 134 | ); |
135 | 135 | |
136 | - wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
136 | + wp_localize_script('scporderjs', 'scporderjs_params', $scporderjs_params); |
|
137 | 137 | |
138 | - wp_enqueue_style( 'scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null ); |
|
139 | - wp_style_add_data( 'scporder', 'rtl', 'replace' ); |
|
138 | + wp_enqueue_style('scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null); |
|
139 | + wp_style_add_data('scporder', 'rtl', 'replace'); |
|
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
@@ -145,26 +145,26 @@ discard block |
||
145 | 145 | $objects = $this->get_to_scporder_options_objects(); |
146 | 146 | $tags = $this->get_to_scporder_options_tags(); |
147 | 147 | |
148 | - if ( ! empty( $objects ) ) { |
|
149 | - foreach ( $objects as $object => $object_data ) { |
|
150 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
148 | + if ( ! empty($objects)) { |
|
149 | + foreach ($objects as $object => $object_data) { |
|
150 | + $result = $wpdb->get_results($wpdb->prepare(" |
|
151 | 151 | SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min |
152 | 152 | FROM $wpdb->posts |
153 | 153 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
154 | - ", $object ) ); |
|
154 | + ", $object)); |
|
155 | 155 | |
156 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
156 | + if (0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max) { |
|
157 | 157 | continue; |
158 | 158 | } |
159 | 159 | |
160 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
160 | + $results = $wpdb->get_results($wpdb->prepare(" |
|
161 | 161 | SELECT ID |
162 | 162 | FROM $wpdb->posts |
163 | 163 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
164 | 164 | ORDER BY menu_order ASC |
165 | - ", $object ) ); |
|
165 | + ", $object)); |
|
166 | 166 | |
167 | - foreach ( $results as $key => $result ) { |
|
167 | + foreach ($results as $key => $result) { |
|
168 | 168 | $wpdb->update( |
169 | 169 | $wpdb->posts, |
170 | 170 | array( |
@@ -178,28 +178,28 @@ discard block |
||
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - if ( ! empty( $tags ) ) { |
|
182 | - foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
183 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
181 | + if ( ! empty($tags)) { |
|
182 | + foreach ($tags as $taxonomy => $taxonomy_data) { |
|
183 | + $result = $wpdb->get_results($wpdb->prepare(" |
|
184 | 184 | SELECT count(*) as cnt, max(lsx_to_term_order) as max, min(lsx_to_term_order) as min |
185 | 185 | FROM $wpdb->terms AS terms |
186 | 186 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
187 | 187 | WHERE term_taxonomy.taxonomy = '%s' |
188 | - ", $taxonomy ) ); |
|
188 | + ", $taxonomy)); |
|
189 | 189 | |
190 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
190 | + if (0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max) { |
|
191 | 191 | continue; |
192 | 192 | } |
193 | 193 | |
194 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
194 | + $results = $wpdb->get_results($wpdb->prepare(" |
|
195 | 195 | SELECT terms.term_id |
196 | 196 | FROM $wpdb->terms AS terms |
197 | 197 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
198 | 198 | WHERE term_taxonomy.taxonomy = '%s' |
199 | 199 | ORDER BY lsx_to_term_order ASC |
200 | - ", $taxonomy ) ); |
|
200 | + ", $taxonomy)); |
|
201 | 201 | |
202 | - foreach ( $results as $key => $result ) { |
|
202 | + foreach ($results as $key => $result) { |
|
203 | 203 | $wpdb->update( |
204 | 204 | $wpdb->terms, |
205 | 205 | array( |
@@ -215,13 +215,13 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | public function update_menu_order() { |
218 | - check_ajax_referer( 'scporder', 'security' ); |
|
218 | + check_ajax_referer('scporder', 'security'); |
|
219 | 219 | |
220 | 220 | global $wpdb; |
221 | 221 | |
222 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
222 | + parse_str(sanitize_text_field($_POST['order']), $data); |
|
223 | 223 | |
224 | - if ( ! is_array( $data ) ) { |
|
224 | + if ( ! is_array($data)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | |
245 | 245 | sort( $menu_order_arr );*/ |
246 | 246 | |
247 | - foreach ( $data as $key => $values ) { |
|
248 | - foreach ( $values as $position => $id ) { |
|
247 | + foreach ($data as $key => $values) { |
|
248 | + foreach ($values as $position => $id) { |
|
249 | 249 | $wpdb->update( |
250 | 250 | $wpdb->posts, |
251 | 251 | array( |
252 | 252 | 'menu_order' => $position, |
253 | 253 | ), |
254 | 254 | array( |
255 | - 'ID' => intval( $id ), |
|
255 | + 'ID' => intval($id), |
|
256 | 256 | ) |
257 | 257 | ); |
258 | 258 | } |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | } |
261 | 261 | |
262 | 262 | public function update_menu_order_tags() { |
263 | - check_ajax_referer( 'scporder', 'security' ); |
|
263 | + check_ajax_referer('scporder', 'security'); |
|
264 | 264 | |
265 | 265 | global $wpdb; |
266 | 266 | |
267 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
267 | + parse_str(sanitize_text_field($_POST['order']), $data); |
|
268 | 268 | |
269 | - if ( ! is_array( $data ) ) { |
|
269 | + if ( ! is_array($data)) { |
|
270 | 270 | return false; |
271 | 271 | } |
272 | 272 | |
@@ -294,33 +294,33 @@ discard block |
||
294 | 294 | |
295 | 295 | sort( $menu_order_arr );*/ |
296 | 296 | |
297 | - foreach ( $data as $key => $values ) { |
|
297 | + foreach ($data as $key => $values) { |
|
298 | 298 | $term_ids = array(); |
299 | - foreach ( $values as $position => $id ) { |
|
299 | + foreach ($values as $position => $id) { |
|
300 | 300 | $wpdb->update( |
301 | 301 | $wpdb->terms, |
302 | 302 | array( |
303 | 303 | 'lsx_to_term_order' => $position + 1, |
304 | 304 | ), |
305 | 305 | array( |
306 | - 'term_id' => intval( $id ), |
|
306 | + 'term_id' => intval($id), |
|
307 | 307 | ) |
308 | 308 | ); |
309 | - $term_ids[] = intval( $id ); |
|
309 | + $term_ids[] = intval($id); |
|
310 | 310 | } |
311 | - clean_term_cache( $term_ids ); |
|
311 | + clean_term_cache($term_ids); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | - public function lsx_to_scporder_previous_post_where( $where ) { |
|
315 | + public function lsx_to_scporder_previous_post_where($where) { |
|
316 | 316 | global $post; |
317 | 317 | $objects = $this->get_to_scporder_options_objects(); |
318 | 318 | |
319 | - if ( empty( $objects ) ) { |
|
319 | + if (empty($objects)) { |
|
320 | 320 | return $where; |
321 | 321 | } |
322 | 322 | |
323 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
323 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
324 | 324 | $current_menu_order = $post->menu_order; |
325 | 325 | $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
326 | 326 | } |
@@ -328,30 +328,30 @@ discard block |
||
328 | 328 | return $where; |
329 | 329 | } |
330 | 330 | |
331 | - public function lsx_to_scporder_previous_post_sort( $orderby ) { |
|
331 | + public function lsx_to_scporder_previous_post_sort($orderby) { |
|
332 | 332 | global $post; |
333 | 333 | $objects = $this->get_to_scporder_options_objects(); |
334 | 334 | |
335 | - if ( empty( $objects ) ) { |
|
335 | + if (empty($objects)) { |
|
336 | 336 | return $orderby; |
337 | 337 | } |
338 | 338 | |
339 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
339 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
340 | 340 | $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
341 | 341 | } |
342 | 342 | |
343 | 343 | return $orderby; |
344 | 344 | } |
345 | 345 | |
346 | - public function lsx_to_scporder_next_post_where( $where ) { |
|
346 | + public function lsx_to_scporder_next_post_where($where) { |
|
347 | 347 | global $post; |
348 | 348 | $objects = $this->get_to_scporder_options_objects(); |
349 | 349 | |
350 | - if ( empty( $objects ) ) { |
|
350 | + if (empty($objects)) { |
|
351 | 351 | return $where; |
352 | 352 | } |
353 | 353 | |
354 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
354 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
355 | 355 | $current_menu_order = $post->menu_order; |
356 | 356 | $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
357 | 357 | } |
@@ -359,97 +359,97 @@ discard block |
||
359 | 359 | return $where; |
360 | 360 | } |
361 | 361 | |
362 | - public function lsx_to_scporder_next_post_sort( $orderby ) { |
|
362 | + public function lsx_to_scporder_next_post_sort($orderby) { |
|
363 | 363 | global $post; |
364 | 364 | $objects = $this->get_to_scporder_options_objects(); |
365 | 365 | |
366 | - if ( empty( $objects ) ) { |
|
366 | + if (empty($objects)) { |
|
367 | 367 | return $orderby; |
368 | 368 | } |
369 | 369 | |
370 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
370 | + if (isset($post->post_type) && array_key_exists($post->post_type, $objects)) { |
|
371 | 371 | $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
372 | 372 | } |
373 | 373 | |
374 | 374 | return $orderby; |
375 | 375 | } |
376 | 376 | |
377 | - public function lsx_to_scporder_pre_get_posts( $wp_query ) { |
|
377 | + public function lsx_to_scporder_pre_get_posts($wp_query) { |
|
378 | 378 | $objects = $this->get_to_scporder_options_objects(); |
379 | 379 | |
380 | - if ( empty( $objects ) ) { |
|
380 | + if (empty($objects)) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | |
384 | - if ( is_admin() ) { |
|
385 | - if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
386 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
387 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
388 | - $wp_query->set( 'order', 'ASC' ); |
|
384 | + if (is_admin()) { |
|
385 | + if (isset($wp_query->query['post_type']) && ! isset($_GET['orderby'])) { |
|
386 | + if (array_key_exists($wp_query->query['post_type'], $objects)) { |
|
387 | + $wp_query->set('orderby', 'menu_order'); |
|
388 | + $wp_query->set('order', 'ASC'); |
|
389 | 389 | } |
390 | 390 | } |
391 | 391 | } else { |
392 | 392 | $active = false; |
393 | 393 | |
394 | - if ( isset( $wp_query->query['post_type'] ) ) { |
|
395 | - if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
396 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
394 | + if (isset($wp_query->query['post_type'])) { |
|
395 | + if ( ! is_array($wp_query->query['post_type'])) { |
|
396 | + if (array_key_exists($wp_query->query['post_type'], $objects)) { |
|
397 | 397 | $active = true; |
398 | 398 | } |
399 | 399 | } |
400 | 400 | } else { |
401 | - if ( array_key_exists( 'post', $objects ) ) { |
|
401 | + if (array_key_exists('post', $objects)) { |
|
402 | 402 | $active = true; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | - if ( ! $active ) { |
|
406 | + if ( ! $active) { |
|
407 | 407 | return false; |
408 | 408 | } |
409 | 409 | |
410 | - if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { |
|
410 | + if (isset($wp_query->query['disabled_custom_post_order'])) { |
|
411 | 411 | return false; |
412 | 412 | } |
413 | 413 | |
414 | - if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
415 | - if ( $wp_query->get( 'orderby' ) == 'date' ) { |
|
416 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
414 | + if (isset($wp_query->query['suppress_filters'])) { |
|
415 | + if ($wp_query->get('orderby') == 'date') { |
|
416 | + $wp_query->set('orderby', 'menu_order'); |
|
417 | 417 | } |
418 | - if ( $wp_query->get( 'order' ) == 'DESC' ) { |
|
419 | - $wp_query->set( 'order', 'ASC' ); |
|
418 | + if ($wp_query->get('order') == 'DESC') { |
|
419 | + $wp_query->set('order', 'ASC'); |
|
420 | 420 | } |
421 | 421 | } else { |
422 | - if ( ! $wp_query->get( 'orderby' ) ) { |
|
423 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
422 | + if ( ! $wp_query->get('orderby')) { |
|
423 | + $wp_query->set('orderby', 'menu_order'); |
|
424 | 424 | } |
425 | - if ( ! $wp_query->get( 'order' ) ) { |
|
426 | - $wp_query->set( 'order', 'ASC' ); |
|
425 | + if ( ! $wp_query->get('order')) { |
|
426 | + $wp_query->set('order', 'ASC'); |
|
427 | 427 | } |
428 | 428 | } |
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
432 | - public function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { |
|
432 | + public function lsx_to_scporder_get_terms_orderby($orderby, $args) { |
|
433 | 433 | |
434 | - if ( is_admin() ) { |
|
434 | + if (is_admin()) { |
|
435 | 435 | return $orderby; |
436 | 436 | } |
437 | 437 | |
438 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
438 | + if (isset($args['disabled_custom_post_order'])) { |
|
439 | 439 | return $orderby; |
440 | 440 | } |
441 | 441 | |
442 | 442 | $tags = $this->get_to_scporder_options_tags(); |
443 | 443 | |
444 | - if ( ! isset( $args['taxonomy'] ) ) { |
|
444 | + if ( ! isset($args['taxonomy'])) { |
|
445 | 445 | return $orderby; |
446 | 446 | } |
447 | 447 | |
448 | 448 | $taxonomy = $args['taxonomy']; |
449 | - if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { |
|
449 | + if (is_array($taxonomy) && count($taxonomy) == 1) { |
|
450 | 450 | $taxonomy = $taxonomy[0]; |
451 | 451 | } |
452 | - if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { |
|
452 | + if ( ! is_array($taxonomy) && ! array_key_exists($taxonomy, $tags)) { |
|
453 | 453 | return $orderby; |
454 | 454 | } |
455 | 455 | |
@@ -458,38 +458,38 @@ discard block |
||
458 | 458 | return $orderby; |
459 | 459 | } |
460 | 460 | |
461 | - public function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { |
|
461 | + public function lsx_to_scporder_get_object_terms($terms, $not_used, $args_1, $args_2 = null) { |
|
462 | 462 | $tags = $this->get_to_scporder_options_tags(); |
463 | 463 | |
464 | - if ( is_admin() && isset( $_GET['orderby'] ) ) { |
|
464 | + if (is_admin() && isset($_GET['orderby'])) { |
|
465 | 465 | return $terms; |
466 | 466 | } |
467 | 467 | |
468 | - $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; |
|
468 | + $args = is_null($args_2) || ! is_array($args_2) ? $args_1 : $args_2; |
|
469 | 469 | |
470 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
470 | + if (isset($args['disabled_custom_post_order'])) { |
|
471 | 471 | return $terms; |
472 | 472 | } |
473 | 473 | |
474 | - foreach ( $terms as $key => $term ) { |
|
475 | - if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
474 | + foreach ($terms as $key => $term) { |
|
475 | + if (is_object($term) && isset($term->taxonomy)) { |
|
476 | 476 | $taxonomy = $term->taxonomy; |
477 | - if ( ! array_key_exists( $taxonomy, $tags ) ) { |
|
477 | + if ( ! array_key_exists($taxonomy, $tags)) { |
|
478 | 478 | return $terms; |
479 | 479 | } |
480 | 480 | } else { |
481 | 481 | return $terms; |
482 | 482 | } |
483 | 483 | } |
484 | - usort( $terms, array( $this, 'taxcmp' ) ); |
|
484 | + usort($terms, array($this, 'taxcmp')); |
|
485 | 485 | return $terms; |
486 | 486 | } |
487 | 487 | |
488 | - public function taxcmp( $a, $b ) { |
|
489 | - if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { |
|
488 | + public function taxcmp($a, $b) { |
|
489 | + if ($a->lsx_to_term_order == $b->lsx_to_term_order) { |
|
490 | 490 | return 0; |
491 | 491 | } |
492 | - return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; |
|
492 | + return ($a->lsx_to_term_order < $b->lsx_to_term_order) ? -1 : 1; |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | public function get_to_scporder_options_objects() { |
@@ -4,194 +4,194 @@ discard block |
||
4 | 4 | |
5 | 5 | class SCPO_Engine { |
6 | 6 | |
7 | - /** |
|
8 | - * Holds class instance |
|
9 | - * |
|
10 | - * @since 1.0.0 |
|
11 | - * |
|
12 | - * @var object \lsx_health_plan\classes\SCPO_Engine() |
|
13 | - */ |
|
14 | - protected static $instance = null; |
|
15 | - |
|
16 | - /** |
|
17 | - * Return an instance of this class. |
|
18 | - * |
|
19 | - * @since 1.0.0 |
|
20 | - * |
|
21 | - * @return object \lsx_health_plan\classes\SCPO_Engine() A single instance of this class. |
|
22 | - */ |
|
23 | - public static function get_instance() { |
|
24 | - // If the single instance hasn't been set, set it now. |
|
25 | - if ( null == self::$instance ) { |
|
26 | - self::$instance = new self; |
|
27 | - } |
|
28 | - return self::$instance; |
|
29 | - } |
|
30 | - |
|
31 | - public function __construct() { |
|
32 | - if ( ! get_option( 'lsx_to_scporder_install' ) ) { |
|
33 | - $this->lsx_to_scporder_install(); |
|
34 | - } |
|
35 | - |
|
36 | - add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
37 | - add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
38 | - |
|
39 | - add_action( 'wp_ajax_update-menu-order', array( |
|
40 | - $this, |
|
41 | - 'update_menu_order', |
|
42 | - ) ); |
|
43 | - add_action( 'wp_ajax_update-menu-order-tags', array( |
|
44 | - $this, |
|
45 | - 'update_menu_order_tags', |
|
46 | - ) ); |
|
47 | - |
|
48 | - add_action( 'pre_get_posts', array( |
|
49 | - $this, |
|
50 | - 'lsx_to_scporder_pre_get_posts', |
|
51 | - ) ); |
|
52 | - |
|
53 | - add_filter( 'get_previous_post_where', array( |
|
54 | - $this, |
|
55 | - 'lsx_to_scporder_previous_post_where', |
|
56 | - ) ); |
|
57 | - add_filter( 'get_previous_post_sort', array( |
|
58 | - $this, |
|
59 | - 'lsx_to_scporder_previous_post_sort', |
|
60 | - ) ); |
|
61 | - add_filter( 'get_next_post_where', array( |
|
62 | - $this, |
|
63 | - 'lsx_to_scporder_next_post_where', |
|
64 | - ) ); |
|
65 | - add_filter( 'get_next_post_sort', array( |
|
66 | - $this, |
|
67 | - 'lsx_to_scporder_next_post_sort', |
|
68 | - ) ); |
|
69 | - |
|
70 | - add_filter( 'get_terms_orderby', array( |
|
71 | - $this, |
|
72 | - 'lsx_to_scporder_get_terms_orderby', |
|
73 | - ), 10, 3 ); |
|
74 | - add_filter( 'wp_get_object_terms', array( |
|
75 | - $this, |
|
76 | - 'lsx_to_scporder_get_object_terms', |
|
77 | - ), 10, 4 ); |
|
78 | - add_filter( 'get_terms', array( |
|
79 | - $this, |
|
80 | - 'lsx_to_scporder_get_object_terms', |
|
81 | - ), 10, 4 ); |
|
82 | - } |
|
83 | - |
|
84 | - public function lsx_to_scporder_install() { |
|
85 | - global $wpdb; |
|
86 | - $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); |
|
87 | - |
|
88 | - if ( ! $result ) { |
|
89 | - $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); |
|
90 | - } |
|
91 | - |
|
92 | - update_option( 'lsx_to_scporder_install', 1 ); |
|
93 | - } |
|
94 | - |
|
95 | - public function _check_load_script_css() { |
|
96 | - $active = false; |
|
97 | - |
|
98 | - $objects = $this->get_to_scporder_options_objects(); |
|
99 | - $tags = $this->get_to_scporder_options_tags(); |
|
100 | - |
|
101 | - if ( empty( $objects ) && empty( $tags ) ) { |
|
102 | - return false; |
|
103 | - } |
|
104 | - |
|
105 | - if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { |
|
106 | - return false; |
|
107 | - } |
|
108 | - |
|
109 | - if ( ! empty( $objects ) ) { |
|
110 | - if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types |
|
111 | - $active = true; |
|
112 | - } |
|
113 | - if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post |
|
114 | - $active = true; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - if ( ! empty( $tags ) ) { |
|
119 | - if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { |
|
120 | - $active = true; |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - return $active; |
|
125 | - } |
|
126 | - |
|
127 | - public function load_script_css() { |
|
128 | - if ( $this->_check_load_script_css() ) { |
|
129 | - wp_enqueue_script( 'scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
130 | - |
|
131 | - $scporderjs_params = array( |
|
132 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
133 | - 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
134 | - ); |
|
135 | - |
|
136 | - wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
137 | - |
|
138 | - wp_enqueue_style( 'scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null ); |
|
139 | - wp_style_add_data( 'scporder', 'rtl', 'replace' ); |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - public function refresh() { |
|
144 | - global $wpdb; |
|
145 | - $objects = $this->get_to_scporder_options_objects(); |
|
146 | - $tags = $this->get_to_scporder_options_tags(); |
|
147 | - |
|
148 | - if ( ! empty( $objects ) ) { |
|
149 | - foreach ( $objects as $object => $object_data ) { |
|
150 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
7 | + /** |
|
8 | + * Holds class instance |
|
9 | + * |
|
10 | + * @since 1.0.0 |
|
11 | + * |
|
12 | + * @var object \lsx_health_plan\classes\SCPO_Engine() |
|
13 | + */ |
|
14 | + protected static $instance = null; |
|
15 | + |
|
16 | + /** |
|
17 | + * Return an instance of this class. |
|
18 | + * |
|
19 | + * @since 1.0.0 |
|
20 | + * |
|
21 | + * @return object \lsx_health_plan\classes\SCPO_Engine() A single instance of this class. |
|
22 | + */ |
|
23 | + public static function get_instance() { |
|
24 | + // If the single instance hasn't been set, set it now. |
|
25 | + if ( null == self::$instance ) { |
|
26 | + self::$instance = new self; |
|
27 | + } |
|
28 | + return self::$instance; |
|
29 | + } |
|
30 | + |
|
31 | + public function __construct() { |
|
32 | + if ( ! get_option( 'lsx_to_scporder_install' ) ) { |
|
33 | + $this->lsx_to_scporder_install(); |
|
34 | + } |
|
35 | + |
|
36 | + add_action( 'admin_init', array( $this, 'refresh' ) ); |
|
37 | + add_action( 'admin_init', array( $this, 'load_script_css' ) ); |
|
38 | + |
|
39 | + add_action( 'wp_ajax_update-menu-order', array( |
|
40 | + $this, |
|
41 | + 'update_menu_order', |
|
42 | + ) ); |
|
43 | + add_action( 'wp_ajax_update-menu-order-tags', array( |
|
44 | + $this, |
|
45 | + 'update_menu_order_tags', |
|
46 | + ) ); |
|
47 | + |
|
48 | + add_action( 'pre_get_posts', array( |
|
49 | + $this, |
|
50 | + 'lsx_to_scporder_pre_get_posts', |
|
51 | + ) ); |
|
52 | + |
|
53 | + add_filter( 'get_previous_post_where', array( |
|
54 | + $this, |
|
55 | + 'lsx_to_scporder_previous_post_where', |
|
56 | + ) ); |
|
57 | + add_filter( 'get_previous_post_sort', array( |
|
58 | + $this, |
|
59 | + 'lsx_to_scporder_previous_post_sort', |
|
60 | + ) ); |
|
61 | + add_filter( 'get_next_post_where', array( |
|
62 | + $this, |
|
63 | + 'lsx_to_scporder_next_post_where', |
|
64 | + ) ); |
|
65 | + add_filter( 'get_next_post_sort', array( |
|
66 | + $this, |
|
67 | + 'lsx_to_scporder_next_post_sort', |
|
68 | + ) ); |
|
69 | + |
|
70 | + add_filter( 'get_terms_orderby', array( |
|
71 | + $this, |
|
72 | + 'lsx_to_scporder_get_terms_orderby', |
|
73 | + ), 10, 3 ); |
|
74 | + add_filter( 'wp_get_object_terms', array( |
|
75 | + $this, |
|
76 | + 'lsx_to_scporder_get_object_terms', |
|
77 | + ), 10, 4 ); |
|
78 | + add_filter( 'get_terms', array( |
|
79 | + $this, |
|
80 | + 'lsx_to_scporder_get_object_terms', |
|
81 | + ), 10, 4 ); |
|
82 | + } |
|
83 | + |
|
84 | + public function lsx_to_scporder_install() { |
|
85 | + global $wpdb; |
|
86 | + $result = $wpdb->query( "DESCRIBE $wpdb->terms `lsx_to_term_order`" ); |
|
87 | + |
|
88 | + if ( ! $result ) { |
|
89 | + $result = $wpdb->query( "ALTER TABLE $wpdb->terms ADD `lsx_to_term_order` INT(4) NULL DEFAULT '0'" ); |
|
90 | + } |
|
91 | + |
|
92 | + update_option( 'lsx_to_scporder_install', 1 ); |
|
93 | + } |
|
94 | + |
|
95 | + public function _check_load_script_css() { |
|
96 | + $active = false; |
|
97 | + |
|
98 | + $objects = $this->get_to_scporder_options_objects(); |
|
99 | + $tags = $this->get_to_scporder_options_tags(); |
|
100 | + |
|
101 | + if ( empty( $objects ) && empty( $tags ) ) { |
|
102 | + return false; |
|
103 | + } |
|
104 | + |
|
105 | + if ( isset( $_GET['orderby'] ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'action=edit' ) || strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/post-new.php' ) ) { |
|
106 | + return false; |
|
107 | + } |
|
108 | + |
|
109 | + if ( ! empty( $objects ) ) { |
|
110 | + if ( isset( $_GET['post_type'] ) && ! isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['post_type'] ), $objects ) ) { // if page or custom post types |
|
111 | + $active = true; |
|
112 | + } |
|
113 | + if ( ! isset( $_GET['post_type'] ) && strstr( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'wp-admin/edit.php' ) && array_key_exists( 'post', $objects ) ) { // if post |
|
114 | + $active = true; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + if ( ! empty( $tags ) ) { |
|
119 | + if ( isset( $_GET['taxonomy'] ) && array_key_exists( sanitize_text_field( $_GET['taxonomy'] ), $tags ) ) { |
|
120 | + $active = true; |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + return $active; |
|
125 | + } |
|
126 | + |
|
127 | + public function load_script_css() { |
|
128 | + if ( $this->_check_load_script_css() ) { |
|
129 | + wp_enqueue_script( 'scporderjs', LSX_HEALTH_PLAN_URL . '/assets/js/scporder.min.js', array( 'jquery', 'jquery-ui-sortable' ), null, true ); |
|
130 | + |
|
131 | + $scporderjs_params = array( |
|
132 | + 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
133 | + 'ajax_nonce' => wp_create_nonce( 'scporder' ), |
|
134 | + ); |
|
135 | + |
|
136 | + wp_localize_script( 'scporderjs', 'scporderjs_params', $scporderjs_params ); |
|
137 | + |
|
138 | + wp_enqueue_style( 'scporder', LSX_HEALTH_PLAN_URL . '/assets/css/scporder.css', array(), null ); |
|
139 | + wp_style_add_data( 'scporder', 'rtl', 'replace' ); |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + public function refresh() { |
|
144 | + global $wpdb; |
|
145 | + $objects = $this->get_to_scporder_options_objects(); |
|
146 | + $tags = $this->get_to_scporder_options_tags(); |
|
147 | + |
|
148 | + if ( ! empty( $objects ) ) { |
|
149 | + foreach ( $objects as $object => $object_data ) { |
|
150 | + $result = $wpdb->get_results( $wpdb->prepare( " |
|
151 | 151 | SELECT count(*) as cnt, max(menu_order) as max, min(menu_order) as min |
152 | 152 | FROM $wpdb->posts |
153 | 153 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
154 | 154 | ", $object ) ); |
155 | 155 | |
156 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
157 | - continue; |
|
158 | - } |
|
156 | + if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
157 | + continue; |
|
158 | + } |
|
159 | 159 | |
160 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
160 | + $results = $wpdb->get_results( $wpdb->prepare( " |
|
161 | 161 | SELECT ID |
162 | 162 | FROM $wpdb->posts |
163 | 163 | WHERE post_type = '%s' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') |
164 | 164 | ORDER BY menu_order ASC |
165 | 165 | ", $object ) ); |
166 | 166 | |
167 | - foreach ( $results as $key => $result ) { |
|
168 | - $wpdb->update( |
|
169 | - $wpdb->posts, |
|
170 | - array( |
|
171 | - 'menu_order' => $key + 1, |
|
172 | - ), |
|
173 | - array( |
|
174 | - 'ID' => $result->ID, |
|
175 | - ) |
|
176 | - ); |
|
177 | - } |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - if ( ! empty( $tags ) ) { |
|
182 | - foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
183 | - $result = $wpdb->get_results( $wpdb->prepare( " |
|
167 | + foreach ( $results as $key => $result ) { |
|
168 | + $wpdb->update( |
|
169 | + $wpdb->posts, |
|
170 | + array( |
|
171 | + 'menu_order' => $key + 1, |
|
172 | + ), |
|
173 | + array( |
|
174 | + 'ID' => $result->ID, |
|
175 | + ) |
|
176 | + ); |
|
177 | + } |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + if ( ! empty( $tags ) ) { |
|
182 | + foreach ( $tags as $taxonomy => $taxonomy_data ) { |
|
183 | + $result = $wpdb->get_results( $wpdb->prepare( " |
|
184 | 184 | SELECT count(*) as cnt, max(lsx_to_term_order) as max, min(lsx_to_term_order) as min |
185 | 185 | FROM $wpdb->terms AS terms |
186 | 186 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
187 | 187 | WHERE term_taxonomy.taxonomy = '%s' |
188 | 188 | ", $taxonomy ) ); |
189 | 189 | |
190 | - if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
191 | - continue; |
|
192 | - } |
|
190 | + if ( 0 == $result[0]->cnt || $result[0]->cnt == $result[0]->max ) { |
|
191 | + continue; |
|
192 | + } |
|
193 | 193 | |
194 | - $results = $wpdb->get_results( $wpdb->prepare( " |
|
194 | + $results = $wpdb->get_results( $wpdb->prepare( " |
|
195 | 195 | SELECT terms.term_id |
196 | 196 | FROM $wpdb->terms AS terms |
197 | 197 | INNER JOIN $wpdb->term_taxonomy AS term_taxonomy ON ( terms.term_id = term_taxonomy.term_id ) |
@@ -199,33 +199,33 @@ discard block |
||
199 | 199 | ORDER BY lsx_to_term_order ASC |
200 | 200 | ", $taxonomy ) ); |
201 | 201 | |
202 | - foreach ( $results as $key => $result ) { |
|
203 | - $wpdb->update( |
|
204 | - $wpdb->terms, |
|
205 | - array( |
|
206 | - 'lsx_to_term_order' => $key + 1, |
|
207 | - ), |
|
208 | - array( |
|
209 | - 'term_id' => $result->term_id, |
|
210 | - ) |
|
211 | - ); |
|
212 | - } |
|
213 | - } |
|
214 | - } |
|
215 | - } |
|
202 | + foreach ( $results as $key => $result ) { |
|
203 | + $wpdb->update( |
|
204 | + $wpdb->terms, |
|
205 | + array( |
|
206 | + 'lsx_to_term_order' => $key + 1, |
|
207 | + ), |
|
208 | + array( |
|
209 | + 'term_id' => $result->term_id, |
|
210 | + ) |
|
211 | + ); |
|
212 | + } |
|
213 | + } |
|
214 | + } |
|
215 | + } |
|
216 | 216 | |
217 | - public function update_menu_order() { |
|
218 | - check_ajax_referer( 'scporder', 'security' ); |
|
217 | + public function update_menu_order() { |
|
218 | + check_ajax_referer( 'scporder', 'security' ); |
|
219 | 219 | |
220 | - global $wpdb; |
|
220 | + global $wpdb; |
|
221 | 221 | |
222 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
222 | + parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
223 | 223 | |
224 | - if ( ! is_array( $data ) ) { |
|
225 | - return false; |
|
226 | - } |
|
224 | + if ( ! is_array( $data ) ) { |
|
225 | + return false; |
|
226 | + } |
|
227 | 227 | |
228 | - /*$id_arr = array(); |
|
228 | + /*$id_arr = array(); |
|
229 | 229 | |
230 | 230 | foreach ( $data as $key => $values ) { |
231 | 231 | foreach ( $values as $position => $id ) { |
@@ -244,38 +244,38 @@ discard block |
||
244 | 244 | |
245 | 245 | sort( $menu_order_arr );*/ |
246 | 246 | |
247 | - foreach ( $data as $key => $values ) { |
|
248 | - foreach ( $values as $position => $id ) { |
|
249 | - $wpdb->update( |
|
250 | - $wpdb->posts, |
|
251 | - array( |
|
252 | - 'menu_order' => $position, |
|
253 | - ), |
|
254 | - array( |
|
255 | - 'ID' => intval( $id ), |
|
256 | - ) |
|
257 | - ); |
|
258 | - } |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - public function update_menu_order_tags() { |
|
263 | - check_ajax_referer( 'scporder', 'security' ); |
|
264 | - |
|
265 | - global $wpdb; |
|
266 | - |
|
267 | - parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
268 | - |
|
269 | - if ( ! is_array( $data ) ) { |
|
270 | - return false; |
|
271 | - } |
|
272 | - |
|
273 | - /*$current_user = wp_get_current_user(); |
|
247 | + foreach ( $data as $key => $values ) { |
|
248 | + foreach ( $values as $position => $id ) { |
|
249 | + $wpdb->update( |
|
250 | + $wpdb->posts, |
|
251 | + array( |
|
252 | + 'menu_order' => $position, |
|
253 | + ), |
|
254 | + array( |
|
255 | + 'ID' => intval( $id ), |
|
256 | + ) |
|
257 | + ); |
|
258 | + } |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + public function update_menu_order_tags() { |
|
263 | + check_ajax_referer( 'scporder', 'security' ); |
|
264 | + |
|
265 | + global $wpdb; |
|
266 | + |
|
267 | + parse_str( sanitize_text_field( $_POST['order'] ), $data ); |
|
268 | + |
|
269 | + if ( ! is_array( $data ) ) { |
|
270 | + return false; |
|
271 | + } |
|
272 | + |
|
273 | + /*$current_user = wp_get_current_user(); |
|
274 | 274 | if ( false === $current_user || 'lightspeed' !== $current_user->data->user_login ) { |
275 | 275 | return false; |
276 | 276 | }*/ |
277 | 277 | |
278 | - /*$id_arr = array(); |
|
278 | + /*$id_arr = array(); |
|
279 | 279 | |
280 | 280 | foreach ( $data as $key => $values ) { |
281 | 281 | foreach ( $values as $position => $id ) { |
@@ -294,217 +294,217 @@ discard block |
||
294 | 294 | |
295 | 295 | sort( $menu_order_arr );*/ |
296 | 296 | |
297 | - foreach ( $data as $key => $values ) { |
|
298 | - $term_ids = array(); |
|
299 | - foreach ( $values as $position => $id ) { |
|
300 | - $wpdb->update( |
|
301 | - $wpdb->terms, |
|
302 | - array( |
|
303 | - 'lsx_to_term_order' => $position + 1, |
|
304 | - ), |
|
305 | - array( |
|
306 | - 'term_id' => intval( $id ), |
|
307 | - ) |
|
308 | - ); |
|
309 | - $term_ids[] = intval( $id ); |
|
310 | - } |
|
311 | - clean_term_cache( $term_ids ); |
|
312 | - } |
|
313 | - } |
|
314 | - |
|
315 | - public function lsx_to_scporder_previous_post_where( $where ) { |
|
316 | - global $post; |
|
317 | - $objects = $this->get_to_scporder_options_objects(); |
|
318 | - |
|
319 | - if ( empty( $objects ) ) { |
|
320 | - return $where; |
|
321 | - } |
|
322 | - |
|
323 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
324 | - $current_menu_order = $post->menu_order; |
|
325 | - $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
326 | - } |
|
327 | - |
|
328 | - return $where; |
|
329 | - } |
|
330 | - |
|
331 | - public function lsx_to_scporder_previous_post_sort( $orderby ) { |
|
332 | - global $post; |
|
333 | - $objects = $this->get_to_scporder_options_objects(); |
|
334 | - |
|
335 | - if ( empty( $objects ) ) { |
|
336 | - return $orderby; |
|
337 | - } |
|
338 | - |
|
339 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
340 | - $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
|
341 | - } |
|
342 | - |
|
343 | - return $orderby; |
|
344 | - } |
|
345 | - |
|
346 | - public function lsx_to_scporder_next_post_where( $where ) { |
|
347 | - global $post; |
|
348 | - $objects = $this->get_to_scporder_options_objects(); |
|
349 | - |
|
350 | - if ( empty( $objects ) ) { |
|
351 | - return $where; |
|
352 | - } |
|
353 | - |
|
354 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
355 | - $current_menu_order = $post->menu_order; |
|
356 | - $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
357 | - } |
|
358 | - |
|
359 | - return $where; |
|
360 | - } |
|
361 | - |
|
362 | - public function lsx_to_scporder_next_post_sort( $orderby ) { |
|
363 | - global $post; |
|
364 | - $objects = $this->get_to_scporder_options_objects(); |
|
365 | - |
|
366 | - if ( empty( $objects ) ) { |
|
367 | - return $orderby; |
|
368 | - } |
|
369 | - |
|
370 | - if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
371 | - $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
|
372 | - } |
|
373 | - |
|
374 | - return $orderby; |
|
375 | - } |
|
376 | - |
|
377 | - public function lsx_to_scporder_pre_get_posts( $wp_query ) { |
|
378 | - $objects = $this->get_to_scporder_options_objects(); |
|
379 | - |
|
380 | - if ( empty( $objects ) ) { |
|
381 | - return false; |
|
382 | - } |
|
383 | - |
|
384 | - if ( is_admin() ) { |
|
385 | - if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
386 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
387 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
388 | - $wp_query->set( 'order', 'ASC' ); |
|
389 | - } |
|
390 | - } |
|
391 | - } else { |
|
392 | - $active = false; |
|
393 | - |
|
394 | - if ( isset( $wp_query->query['post_type'] ) ) { |
|
395 | - if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
396 | - if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
397 | - $active = true; |
|
398 | - } |
|
399 | - } |
|
400 | - } else { |
|
401 | - if ( array_key_exists( 'post', $objects ) ) { |
|
402 | - $active = true; |
|
403 | - } |
|
404 | - } |
|
405 | - |
|
406 | - if ( ! $active ) { |
|
407 | - return false; |
|
408 | - } |
|
409 | - |
|
410 | - if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { |
|
411 | - return false; |
|
412 | - } |
|
413 | - |
|
414 | - if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
415 | - if ( $wp_query->get( 'orderby' ) == 'date' ) { |
|
416 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
417 | - } |
|
418 | - if ( $wp_query->get( 'order' ) == 'DESC' ) { |
|
419 | - $wp_query->set( 'order', 'ASC' ); |
|
420 | - } |
|
421 | - } else { |
|
422 | - if ( ! $wp_query->get( 'orderby' ) ) { |
|
423 | - $wp_query->set( 'orderby', 'menu_order' ); |
|
424 | - } |
|
425 | - if ( ! $wp_query->get( 'order' ) ) { |
|
426 | - $wp_query->set( 'order', 'ASC' ); |
|
427 | - } |
|
428 | - } |
|
429 | - } |
|
430 | - } |
|
431 | - |
|
432 | - public function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { |
|
433 | - |
|
434 | - if ( is_admin() ) { |
|
435 | - return $orderby; |
|
436 | - } |
|
437 | - |
|
438 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
439 | - return $orderby; |
|
440 | - } |
|
441 | - |
|
442 | - $tags = $this->get_to_scporder_options_tags(); |
|
443 | - |
|
444 | - if ( ! isset( $args['taxonomy'] ) ) { |
|
445 | - return $orderby; |
|
446 | - } |
|
447 | - |
|
448 | - $taxonomy = $args['taxonomy']; |
|
449 | - if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { |
|
450 | - $taxonomy = $taxonomy[0]; |
|
451 | - } |
|
452 | - if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { |
|
453 | - return $orderby; |
|
454 | - } |
|
455 | - |
|
456 | - $orderby = 't.lsx_to_term_order'; |
|
457 | - |
|
458 | - return $orderby; |
|
459 | - } |
|
460 | - |
|
461 | - public function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { |
|
462 | - $tags = $this->get_to_scporder_options_tags(); |
|
463 | - |
|
464 | - if ( is_admin() && isset( $_GET['orderby'] ) ) { |
|
465 | - return $terms; |
|
466 | - } |
|
467 | - |
|
468 | - $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; |
|
469 | - |
|
470 | - if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
471 | - return $terms; |
|
472 | - } |
|
473 | - |
|
474 | - foreach ( $terms as $key => $term ) { |
|
475 | - if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
476 | - $taxonomy = $term->taxonomy; |
|
477 | - if ( ! array_key_exists( $taxonomy, $tags ) ) { |
|
478 | - return $terms; |
|
479 | - } |
|
480 | - } else { |
|
481 | - return $terms; |
|
482 | - } |
|
483 | - } |
|
484 | - usort( $terms, array( $this, 'taxcmp' ) ); |
|
485 | - return $terms; |
|
486 | - } |
|
487 | - |
|
488 | - public function taxcmp( $a, $b ) { |
|
489 | - if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { |
|
490 | - return 0; |
|
491 | - } |
|
492 | - return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; |
|
493 | - } |
|
494 | - |
|
495 | - public function get_to_scporder_options_objects() { |
|
496 | - $ordering = array( |
|
497 | - 'plan' => 'plan', |
|
498 | - ); |
|
499 | - return $ordering; |
|
500 | - } |
|
501 | - |
|
502 | - public function get_to_scporder_options_tags() { |
|
503 | - $ordering = array( |
|
504 | - 'week' => 'week', |
|
505 | - 'recipe-type' => 'recipe-type', |
|
506 | - ); |
|
507 | - return $ordering; |
|
508 | - } |
|
297 | + foreach ( $data as $key => $values ) { |
|
298 | + $term_ids = array(); |
|
299 | + foreach ( $values as $position => $id ) { |
|
300 | + $wpdb->update( |
|
301 | + $wpdb->terms, |
|
302 | + array( |
|
303 | + 'lsx_to_term_order' => $position + 1, |
|
304 | + ), |
|
305 | + array( |
|
306 | + 'term_id' => intval( $id ), |
|
307 | + ) |
|
308 | + ); |
|
309 | + $term_ids[] = intval( $id ); |
|
310 | + } |
|
311 | + clean_term_cache( $term_ids ); |
|
312 | + } |
|
313 | + } |
|
314 | + |
|
315 | + public function lsx_to_scporder_previous_post_where( $where ) { |
|
316 | + global $post; |
|
317 | + $objects = $this->get_to_scporder_options_objects(); |
|
318 | + |
|
319 | + if ( empty( $objects ) ) { |
|
320 | + return $where; |
|
321 | + } |
|
322 | + |
|
323 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
324 | + $current_menu_order = $post->menu_order; |
|
325 | + $where = "WHERE p.menu_order > '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
326 | + } |
|
327 | + |
|
328 | + return $where; |
|
329 | + } |
|
330 | + |
|
331 | + public function lsx_to_scporder_previous_post_sort( $orderby ) { |
|
332 | + global $post; |
|
333 | + $objects = $this->get_to_scporder_options_objects(); |
|
334 | + |
|
335 | + if ( empty( $objects ) ) { |
|
336 | + return $orderby; |
|
337 | + } |
|
338 | + |
|
339 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
340 | + $orderby = 'ORDER BY p.menu_order ASC LIMIT 1'; |
|
341 | + } |
|
342 | + |
|
343 | + return $orderby; |
|
344 | + } |
|
345 | + |
|
346 | + public function lsx_to_scporder_next_post_where( $where ) { |
|
347 | + global $post; |
|
348 | + $objects = $this->get_to_scporder_options_objects(); |
|
349 | + |
|
350 | + if ( empty( $objects ) ) { |
|
351 | + return $where; |
|
352 | + } |
|
353 | + |
|
354 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
355 | + $current_menu_order = $post->menu_order; |
|
356 | + $where = "WHERE p.menu_order < '" . $current_menu_order . "' AND p.post_type = '" . $post->post_type . "' AND p.post_status = 'publish'"; |
|
357 | + } |
|
358 | + |
|
359 | + return $where; |
|
360 | + } |
|
361 | + |
|
362 | + public function lsx_to_scporder_next_post_sort( $orderby ) { |
|
363 | + global $post; |
|
364 | + $objects = $this->get_to_scporder_options_objects(); |
|
365 | + |
|
366 | + if ( empty( $objects ) ) { |
|
367 | + return $orderby; |
|
368 | + } |
|
369 | + |
|
370 | + if ( isset( $post->post_type ) && array_key_exists( $post->post_type, $objects ) ) { |
|
371 | + $orderby = 'ORDER BY p.menu_order DESC LIMIT 1'; |
|
372 | + } |
|
373 | + |
|
374 | + return $orderby; |
|
375 | + } |
|
376 | + |
|
377 | + public function lsx_to_scporder_pre_get_posts( $wp_query ) { |
|
378 | + $objects = $this->get_to_scporder_options_objects(); |
|
379 | + |
|
380 | + if ( empty( $objects ) ) { |
|
381 | + return false; |
|
382 | + } |
|
383 | + |
|
384 | + if ( is_admin() ) { |
|
385 | + if ( isset( $wp_query->query['post_type'] ) && ! isset( $_GET['orderby'] ) ) { |
|
386 | + if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
387 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
388 | + $wp_query->set( 'order', 'ASC' ); |
|
389 | + } |
|
390 | + } |
|
391 | + } else { |
|
392 | + $active = false; |
|
393 | + |
|
394 | + if ( isset( $wp_query->query['post_type'] ) ) { |
|
395 | + if ( ! is_array( $wp_query->query['post_type'] ) ) { |
|
396 | + if ( array_key_exists( $wp_query->query['post_type'], $objects ) ) { |
|
397 | + $active = true; |
|
398 | + } |
|
399 | + } |
|
400 | + } else { |
|
401 | + if ( array_key_exists( 'post', $objects ) ) { |
|
402 | + $active = true; |
|
403 | + } |
|
404 | + } |
|
405 | + |
|
406 | + if ( ! $active ) { |
|
407 | + return false; |
|
408 | + } |
|
409 | + |
|
410 | + if ( isset( $wp_query->query['disabled_custom_post_order'] ) ) { |
|
411 | + return false; |
|
412 | + } |
|
413 | + |
|
414 | + if ( isset( $wp_query->query['suppress_filters'] ) ) { |
|
415 | + if ( $wp_query->get( 'orderby' ) == 'date' ) { |
|
416 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
417 | + } |
|
418 | + if ( $wp_query->get( 'order' ) == 'DESC' ) { |
|
419 | + $wp_query->set( 'order', 'ASC' ); |
|
420 | + } |
|
421 | + } else { |
|
422 | + if ( ! $wp_query->get( 'orderby' ) ) { |
|
423 | + $wp_query->set( 'orderby', 'menu_order' ); |
|
424 | + } |
|
425 | + if ( ! $wp_query->get( 'order' ) ) { |
|
426 | + $wp_query->set( 'order', 'ASC' ); |
|
427 | + } |
|
428 | + } |
|
429 | + } |
|
430 | + } |
|
431 | + |
|
432 | + public function lsx_to_scporder_get_terms_orderby( $orderby, $args ) { |
|
433 | + |
|
434 | + if ( is_admin() ) { |
|
435 | + return $orderby; |
|
436 | + } |
|
437 | + |
|
438 | + if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
439 | + return $orderby; |
|
440 | + } |
|
441 | + |
|
442 | + $tags = $this->get_to_scporder_options_tags(); |
|
443 | + |
|
444 | + if ( ! isset( $args['taxonomy'] ) ) { |
|
445 | + return $orderby; |
|
446 | + } |
|
447 | + |
|
448 | + $taxonomy = $args['taxonomy']; |
|
449 | + if ( is_array( $taxonomy ) && count( $taxonomy ) == 1 ) { |
|
450 | + $taxonomy = $taxonomy[0]; |
|
451 | + } |
|
452 | + if ( ! is_array( $taxonomy ) && ! array_key_exists( $taxonomy, $tags ) ) { |
|
453 | + return $orderby; |
|
454 | + } |
|
455 | + |
|
456 | + $orderby = 't.lsx_to_term_order'; |
|
457 | + |
|
458 | + return $orderby; |
|
459 | + } |
|
460 | + |
|
461 | + public function lsx_to_scporder_get_object_terms( $terms, $not_used, $args_1, $args_2 = null ) { |
|
462 | + $tags = $this->get_to_scporder_options_tags(); |
|
463 | + |
|
464 | + if ( is_admin() && isset( $_GET['orderby'] ) ) { |
|
465 | + return $terms; |
|
466 | + } |
|
467 | + |
|
468 | + $args = is_null( $args_2 ) || ! is_array( $args_2 ) ? $args_1 : $args_2; |
|
469 | + |
|
470 | + if ( isset( $args['disabled_custom_post_order'] ) ) { |
|
471 | + return $terms; |
|
472 | + } |
|
473 | + |
|
474 | + foreach ( $terms as $key => $term ) { |
|
475 | + if ( is_object( $term ) && isset( $term->taxonomy ) ) { |
|
476 | + $taxonomy = $term->taxonomy; |
|
477 | + if ( ! array_key_exists( $taxonomy, $tags ) ) { |
|
478 | + return $terms; |
|
479 | + } |
|
480 | + } else { |
|
481 | + return $terms; |
|
482 | + } |
|
483 | + } |
|
484 | + usort( $terms, array( $this, 'taxcmp' ) ); |
|
485 | + return $terms; |
|
486 | + } |
|
487 | + |
|
488 | + public function taxcmp( $a, $b ) { |
|
489 | + if ( $a->lsx_to_term_order == $b->lsx_to_term_order ) { |
|
490 | + return 0; |
|
491 | + } |
|
492 | + return ( $a->lsx_to_term_order < $b->lsx_to_term_order ) ? - 1 : 1; |
|
493 | + } |
|
494 | + |
|
495 | + public function get_to_scporder_options_objects() { |
|
496 | + $ordering = array( |
|
497 | + 'plan' => 'plan', |
|
498 | + ); |
|
499 | + return $ordering; |
|
500 | + } |
|
501 | + |
|
502 | + public function get_to_scporder_options_tags() { |
|
503 | + $ordering = array( |
|
504 | + 'week' => 'week', |
|
505 | + 'recipe-type' => 'recipe-type', |
|
506 | + ); |
|
507 | + return $ordering; |
|
508 | + } |
|
509 | 509 | } |
510 | 510 |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * Contructor |
58 | 58 | */ |
59 | 59 | public function __construct() { |
60 | - add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
|
61 | - add_action( 'init', array( $this, 'download_monitor_init' ) ); |
|
62 | - add_action( 'init', array( $this, 'woocommerce_init' ) ); |
|
63 | - add_action( 'init', array( $this, 'wp_user_avatar_init' ) ); |
|
60 | + add_action('init', array($this, 'cmb2_post_search_ajax')); |
|
61 | + add_action('init', array($this, 'download_monitor_init')); |
|
62 | + add_action('init', array($this, 'woocommerce_init')); |
|
63 | + add_action('init', array($this, 'wp_user_avatar_init')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public static function get_instance() { |
74 | 74 | // If the single instance hasn't been set, set it now. |
75 | - if ( null === self::$instance ) { |
|
75 | + if (null === self::$instance) { |
|
76 | 76 | self::$instance = new self(); |
77 | 77 | } |
78 | 78 | return self::$instance; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return void |
95 | 95 | */ |
96 | 96 | public function download_monitor_init() { |
97 | - if ( function_exists( 'download_monitor' ) ) { |
|
97 | + if (function_exists('download_monitor')) { |
|
98 | 98 | require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-download-monitor.php'; |
99 | 99 | $this->download_monitor = Download_Monitor::get_instance(); |
100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return void |
107 | 107 | */ |
108 | 108 | public function woocommerce_init() { |
109 | - if ( function_exists( 'WC' ) ) { |
|
109 | + if (function_exists('WC')) { |
|
110 | 110 | require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-woocommerce.php'; |
111 | 111 | $this->woocommerce = Woocommerce::get_instance(); |
112 | 112 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @return void |
119 | 119 | */ |
120 | 120 | public function wp_user_avatar_init() { |
121 | - if ( class_exists( 'WP_User_Avatar_Setup' ) ) { |
|
121 | + if (class_exists('WP_User_Avatar_Setup')) { |
|
122 | 122 | require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-wp-user-avatar.php'; |
123 | 123 | $this->wp_user_avatar = WP_User_Avatar::get_instance(); |
124 | 124 | } |
@@ -8,119 +8,119 @@ |
||
8 | 8 | */ |
9 | 9 | class Integrations { |
10 | 10 | |
11 | - /** |
|
12 | - * Holds class instance |
|
13 | - * |
|
14 | - * @since 1.0.0 |
|
15 | - * |
|
16 | - * @var object \lsx_health_plan\classes\Integrations() |
|
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\Integrations() |
|
17 | + */ |
|
18 | + protected static $instance = null; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Holds class instance |
|
22 | - * |
|
23 | - * @since 1.0.0 |
|
24 | - * |
|
25 | - * @var object \MAG_CMB2_Field_Post_Search_Ajax() |
|
26 | - */ |
|
27 | - public $cmb2_post_search_ajax = false; |
|
20 | + /** |
|
21 | + * Holds class instance |
|
22 | + * |
|
23 | + * @since 1.0.0 |
|
24 | + * |
|
25 | + * @var object \MAG_CMB2_Field_Post_Search_Ajax() |
|
26 | + */ |
|
27 | + public $cmb2_post_search_ajax = false; |
|
28 | 28 | |
29 | - /** |
|
30 | - * Holds class instance |
|
31 | - * |
|
32 | - * @since 1.0.0 |
|
33 | - * |
|
34 | - * @var object \lsx_health_plan\classes\Download_Monitor() |
|
35 | - */ |
|
36 | - public $download_monitor = false; |
|
29 | + /** |
|
30 | + * Holds class instance |
|
31 | + * |
|
32 | + * @since 1.0.0 |
|
33 | + * |
|
34 | + * @var object \lsx_health_plan\classes\Download_Monitor() |
|
35 | + */ |
|
36 | + public $download_monitor = false; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Holds class instance |
|
40 | - * |
|
41 | - * @since 1.0.0 |
|
42 | - * |
|
43 | - * @var object \lsx_health_plan\classes\Woocommerce() |
|
44 | - */ |
|
45 | - public $woocommerce = false; |
|
38 | + /** |
|
39 | + * Holds class instance |
|
40 | + * |
|
41 | + * @since 1.0.0 |
|
42 | + * |
|
43 | + * @var object \lsx_health_plan\classes\Woocommerce() |
|
44 | + */ |
|
45 | + public $woocommerce = false; |
|
46 | 46 | |
47 | - /** |
|
48 | - * Holds class instance |
|
49 | - * |
|
50 | - * @since 1.0.0 |
|
51 | - * |
|
52 | - * @var object \lsx_health_plan\classes\WP_User_Avatar() |
|
53 | - */ |
|
54 | - public $wp_user_avatar = false; |
|
47 | + /** |
|
48 | + * Holds class instance |
|
49 | + * |
|
50 | + * @since 1.0.0 |
|
51 | + * |
|
52 | + * @var object \lsx_health_plan\classes\WP_User_Avatar() |
|
53 | + */ |
|
54 | + public $wp_user_avatar = false; |
|
55 | 55 | |
56 | - /** |
|
57 | - * Contructor |
|
58 | - */ |
|
59 | - public function __construct() { |
|
60 | - add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
|
61 | - add_action( 'init', array( $this, 'download_monitor_init' ) ); |
|
62 | - add_action( 'init', array( $this, 'woocommerce_init' ) ); |
|
63 | - add_action( 'init', array( $this, 'wp_user_avatar_init' ) ); |
|
64 | - } |
|
56 | + /** |
|
57 | + * Contructor |
|
58 | + */ |
|
59 | + public function __construct() { |
|
60 | + add_action( 'init', array( $this, 'cmb2_post_search_ajax' ) ); |
|
61 | + add_action( 'init', array( $this, 'download_monitor_init' ) ); |
|
62 | + add_action( 'init', array( $this, 'woocommerce_init' ) ); |
|
63 | + add_action( 'init', array( $this, 'wp_user_avatar_init' ) ); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Return an instance of this class. |
|
68 | - * |
|
69 | - * @since 1.0.0 |
|
70 | - * |
|
71 | - * @return object \lsx_health_plan\classes\Integrations() A single instance of this class. |
|
72 | - */ |
|
73 | - public static function get_instance() { |
|
74 | - // If the single instance hasn't been set, set it now. |
|
75 | - if ( null === self::$instance ) { |
|
76 | - self::$instance = new self(); |
|
77 | - } |
|
78 | - return self::$instance; |
|
79 | - } |
|
66 | + /** |
|
67 | + * Return an instance of this class. |
|
68 | + * |
|
69 | + * @since 1.0.0 |
|
70 | + * |
|
71 | + * @return object \lsx_health_plan\classes\Integrations() A single instance of this class. |
|
72 | + */ |
|
73 | + public static function get_instance() { |
|
74 | + // If the single instance hasn't been set, set it now. |
|
75 | + if ( null === self::$instance ) { |
|
76 | + self::$instance = new self(); |
|
77 | + } |
|
78 | + return self::$instance; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Includes the Post Search Ajax if it is there. |
|
83 | - * |
|
84 | - * @return void |
|
85 | - */ |
|
86 | - public function cmb2_post_search_ajax() { |
|
87 | - require_once LSX_HEALTH_PLAN_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php'; |
|
88 | - $this->cmb2_post_search_ajax = new \MAG_CMB2_Field_Post_Search_Ajax(); |
|
89 | - } |
|
81 | + /** |
|
82 | + * Includes the Post Search Ajax if it is there. |
|
83 | + * |
|
84 | + * @return void |
|
85 | + */ |
|
86 | + public function cmb2_post_search_ajax() { |
|
87 | + require_once LSX_HEALTH_PLAN_PATH . 'vendor/lsx-field-post-search-ajax/cmb-field-post-search-ajax.php'; |
|
88 | + $this->cmb2_post_search_ajax = new \MAG_CMB2_Field_Post_Search_Ajax(); |
|
89 | + } |
|
90 | 90 | |
91 | - /** |
|
92 | - * Includes the Post Search Ajax if it is there. |
|
93 | - * |
|
94 | - * @return void |
|
95 | - */ |
|
96 | - public function download_monitor_init() { |
|
97 | - if ( function_exists( 'download_monitor' ) ) { |
|
98 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-download-monitor.php'; |
|
99 | - $this->download_monitor = Download_Monitor::get_instance(); |
|
100 | - } |
|
101 | - } |
|
91 | + /** |
|
92 | + * Includes the Post Search Ajax if it is there. |
|
93 | + * |
|
94 | + * @return void |
|
95 | + */ |
|
96 | + public function download_monitor_init() { |
|
97 | + if ( function_exists( 'download_monitor' ) ) { |
|
98 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-download-monitor.php'; |
|
99 | + $this->download_monitor = Download_Monitor::get_instance(); |
|
100 | + } |
|
101 | + } |
|
102 | 102 | |
103 | - /** |
|
104 | - * Includes the Woocommerce functions. |
|
105 | - * |
|
106 | - * @return void |
|
107 | - */ |
|
108 | - public function woocommerce_init() { |
|
109 | - if ( function_exists( 'WC' ) ) { |
|
110 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-woocommerce.php'; |
|
111 | - $this->woocommerce = Woocommerce::get_instance(); |
|
112 | - } |
|
113 | - } |
|
103 | + /** |
|
104 | + * Includes the Woocommerce functions. |
|
105 | + * |
|
106 | + * @return void |
|
107 | + */ |
|
108 | + public function woocommerce_init() { |
|
109 | + if ( function_exists( 'WC' ) ) { |
|
110 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-woocommerce.php'; |
|
111 | + $this->woocommerce = Woocommerce::get_instance(); |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * Includes the Woocommerce functions. |
|
117 | - * |
|
118 | - * @return void |
|
119 | - */ |
|
120 | - public function wp_user_avatar_init() { |
|
121 | - if ( class_exists( 'WP_User_Avatar_Setup' ) ) { |
|
122 | - require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-wp-user-avatar.php'; |
|
123 | - $this->wp_user_avatar = WP_User_Avatar::get_instance(); |
|
124 | - } |
|
125 | - } |
|
115 | + /** |
|
116 | + * Includes the Woocommerce functions. |
|
117 | + * |
|
118 | + * @return void |
|
119 | + */ |
|
120 | + public function wp_user_avatar_init() { |
|
121 | + if ( class_exists( 'WP_User_Avatar_Setup' ) ) { |
|
122 | + require_once LSX_HEALTH_PLAN_PATH . 'classes/integrations/class-wp-user-avatar.php'; |
|
123 | + $this->wp_user_avatar = WP_User_Avatar::get_instance(); |
|
124 | + } |
|
125 | + } |
|
126 | 126 | } |