Issues (4138)

classes/admin/settings/class-meal.php (17 issues)

1
<?php
2
/**
3
 * Contains the settings class for LSX
4
 *
5
 * @package lsx-health-plan
6
 */
7
8
namespace lsx_health_plan\classes\admin;
9
10
/**
11
 * Contains the settings for each post type \lsx_health_plan\classes\admin\Meal().
12
 */
13
class Meal {
14
15
	/**
16
	 * Holds class instance
17
	 *
18
	 * @since 1.0.0
19
	 *
20
	 * @var      object \lsx_health_plan\classes\admin\Meal()
21
	 */
22
	protected static $instance = null;
23
24
	/**
25
	 * Constructor
26
	 */
27
	public function __construct() {
0 ignored issues
show
Expected 2 blank lines before function; 1 found
Loading history...
28
		add_action( 'lsx_hp_settings_page_meal_top', array( $this, 'settings' ), 1, 1 );
29
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
30
31
	/**
32
	 * Return an instance of this class.
33
	 *
34
	 * @since 1.0.0
35
	 *
36
	 * @return    object \lsx_health_plan\classes\admin\Meal()    A single instance of this class.
37
	 */
38
	public static function get_instance() {
39
		// If the single instance hasn't been set, set it now.
40
		if ( null === self::$instance ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
41
			self::$instance = new self();
42
		}
0 ignored issues
show
No blank line found after control structure
Loading history...
43
		return self::$instance;
44
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 1 found
Loading history...
45
46
	/**
47
	 * Registers the general settings.
48
	 *
49
	 * @param object $cmb new_cmb2_box().
50
	 * @return void
51
	 */
52
	public function settings( $cmb ) {
53
		$cmb->add_field(
54
			array(
55
				'name'        => __( 'Disable Meals', 'lsx-health-plan' ),
56
				'id'          => 'meal_disabled',
57
				'type'        => 'checkbox',
58
				'value'       => 1,
59
				'default'     => 0,
60
				'description' => __( 'Disable meal post type if you are wanting a minimal site.', 'lsx-health-plan' ),
61
			)
62
		);
63
64
		$cmb->add_field(
65
			array(
66
				'id'          => 'meal_archive_description',
67
				'type'        => 'wysiwyg',
68
				'name'        => __( 'Archive Description', 'lsx-health-plan' ),
69
				'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ),
70
				'options'     => array(
71
					'textarea_rows' => get_option('default_post_edit_rows', 6),
0 ignored issues
show
Expected 1 spaces after opening parenthesis; 0 found
Loading history...
Expected 1 spaces before closing parenthesis; 0 found
Loading history...
72
				),
73
			)
74
		);
75
76
		$cmb->add_field(
77
			array(
78
				'name'    => __( 'Your Meal Plan Intro', 'lsx-health-plan' ),
79
				'id'      => 'meal_plan_intro',
80
				'type'    => 'textarea_small',
81
				'value'   => '',
82
				'default' => __( 'Get the right mix of nutrients to keep muscles strong & healthy.', 'lsx-health-plan' ),
83
			)
84
		);
85
86
		$cmb->add_field(
87
			array(
88
				'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>',
89
				'name'       =>  __( 'Meal Slug', 'lsx-health-plan' ),
0 ignored issues
show
Expected 1 space after "=>"; 2 found
Loading history...
90
				'id'         => 'endpoint_meal',
91
				'type'       => 'input',
92
				'value'      => '',
93
				'default'    => 'meal',
94
			)
95
		);
96
		$cmb->add_field(
97
			array(
98
				'name'    =>  __( 'Meals Archive Slug', 'lsx-health-plan' ),
0 ignored issues
show
Expected 1 space after "=>"; 2 found
Loading history...
99
				'id'      => 'endpoint_meal_archive',
100
				'type'    => 'input',
101
				'value'   => '',
102
				'default' => 'meals',
103
			)
104
		);
105
		$cmb->add_field(
106
			array(
107
				'name'    =>  __( 'Single Meal Slug', 'lsx-health-plan' ),
0 ignored issues
show
Expected 1 space after "=>"; 2 found
Loading history...
108
				'id'      => 'meal_single_slug',
109
				'type'    => 'input',
110
				'value'   => '',
111
				'default' => 'meal',
112
			)
113
		);
114
115
		$cmb->add_field(
116
			array(
117
				'before_row'  => '<h4><b><u>Default Options</u></b></h4>',
118
				'name'        => __( 'Default Meal Plan', 'lsx-health-plan' ),
119
				'description' => __( 'Set a default meal plan.', 'lsx-health-plan' ),
120
				'limit'       => 1,
121
				'id'          => 'connected_meals',
122
				'type'        => 'post_search_ajax',
123
				'query_args'  => array(
124
					'post_type'      => 'meal',
125
					'post_status'    => array( 'publish' ),
126
					'posts_per_page' => -1,
127
				),
128
			)
129
		);
130
		if ( function_exists( 'download_monitor' ) ) {
0 ignored issues
show
Expected 0 spaces after opening bracket; 1 found
Loading history...
Expected 0 spaces before closing bracket; 1 found
Loading history...
131
			$page_url    = 'https://wordpress.org/plugins/download-monitor/';
132
			$plugin_name = 'Download Monitor';
133
			$description = sprintf(
134
				/* translators: %s: The subscription info */
135
				__( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your meal here.', 'lsx-search' ),
136
				$page_url,
137
				$plugin_name
138
			);
139
			$cmb->add_field(
140
				array(
141
					'name'        => __( 'Default Meal Plan PDF', 'lsx-health-plan' ),
142
					'description' => $description,
143
					'id'          => 'download_meal',
144
					'type'        => 'post_search_ajax',
145
					'limit'       => 1,
146
					'query_args'  => array(
147
						'post_type'      => array( 'dlm_download' ),
148
						'post_status'    => array( 'publish' ),
149
						'posts_per_page' => -1,
150
					),
151
					'after_row'   => __( '<p style="font-style: italic;">If you have changed any URL slugs, please remember re-save your permalinks in Settings > Permalinks.</p>', 'lsx-health-plan' ),
152
				)
153
			);
154
		}
155
	}
0 ignored issues
show
Expected 1 blank line before closing function brace; 0 found
Loading history...
Expected 2 blank lines after function; 0 found
Loading history...
156
}
157
Meal::get_instance();
158