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\Recipe(). |
12
|
|
|
*/ |
13
|
|
|
class Recipe { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Holds class instance |
17
|
|
|
* |
18
|
|
|
* @since 1.0.0 |
19
|
|
|
* |
20
|
|
|
* @var object \lsx_health_plan\classes\admin\Recipe() |
21
|
|
|
*/ |
22
|
|
|
protected static $instance = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Constructor |
26
|
|
|
*/ |
27
|
|
|
public function __construct() { |
|
|
|
|
28
|
|
|
add_action( 'lsx_hp_settings_page_recipe_top', array( $this, 'settings' ), 1, 1 ); |
29
|
|
|
} |
|
|
|
|
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Return an instance of this class. |
33
|
|
|
* |
34
|
|
|
* @since 1.0.0 |
35
|
|
|
* |
36
|
|
|
* @return object \lsx_health_plan\classes\admin\Recipe() A single instance of this class. |
37
|
|
|
*/ |
38
|
|
|
public static function get_instance() { |
39
|
|
|
// If the single instance hasn't been set, set it now. |
40
|
|
|
if ( null === self::$instance ) { |
|
|
|
|
41
|
|
|
self::$instance = new self(); |
42
|
|
|
} |
|
|
|
|
43
|
|
|
return self::$instance; |
44
|
|
|
} |
|
|
|
|
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Registers the general settings. |
48
|
|
|
* |
49
|
|
|
* @param object $cmb new_cmb2_box(). |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
public function settings( $cmb ) { |
53
|
|
|
$cmb->add_field( |
54
|
|
|
array( |
55
|
|
|
'name' => __( 'Disable Recipes', 'lsx-health-plan' ), |
56
|
|
|
'id' => 'recipe_disabled', |
57
|
|
|
'type' => 'checkbox', |
58
|
|
|
'value' => 1, |
59
|
|
|
'default' => 0, |
60
|
|
|
'description' => __( 'Disable recipe post type if you are wanting a minimal site.', 'lsx-health-plan' ), |
61
|
|
|
) |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
$cmb->add_field( |
65
|
|
|
array( |
66
|
|
|
'id' => 'recipe_archive_description', |
67
|
|
|
'type' => 'wysiwyg', |
68
|
|
|
'name' => __( 'Archive Description', 'lsx-health-plan' ), |
69
|
|
|
'description' => __( 'This will show up on the post type archive.', 'lsx-health-plan' ), |
70
|
|
|
'options' => array( |
71
|
|
|
'textarea_rows' => get_option('default_post_edit_rows', 6), |
|
|
|
|
72
|
|
|
), |
73
|
|
|
) |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
$cmb->add_field( |
77
|
|
|
array( |
78
|
|
|
'name' => __( 'Recipes Intro', 'lsx-health-plan' ), |
79
|
|
|
'id' => 'recipes_intro', |
80
|
|
|
'type' => 'textarea_small', |
81
|
|
|
'value' => '', |
82
|
|
|
'default' => __( "Let's get cooking! Delicious and easy to follow recipes.", 'lsx-health-plan' ), |
83
|
|
|
) |
84
|
|
|
); |
85
|
|
|
|
86
|
|
|
$cmb->add_field( |
87
|
|
|
array( |
88
|
|
|
'before_row' => '<h4><b><u>URL Slug Options</u></b></h4><p style="font-style: italic;">If you need to translate the custom slug for this custom post type, do so below.</p>', |
89
|
|
|
'name' => __( 'Recipes Endpoint', 'lsx-health-plan' ), |
|
|
|
|
90
|
|
|
'id' => 'endpoint_recipe', |
91
|
|
|
'type' => 'input', |
92
|
|
|
'value' => '', |
93
|
|
|
'default' => 'recipe', |
94
|
|
|
) |
95
|
|
|
); |
96
|
|
|
|
97
|
|
|
$cmb->add_field( |
98
|
|
|
array( |
99
|
|
|
'before_row' => '<h4><b><u>Default Options</u></b></h4>', |
100
|
|
|
'name' => __( 'Recipe', 'lsx-health-plan' ), |
101
|
|
|
'description' => __( 'Set a default recipe.', 'lsx-health-plan' ), |
102
|
|
|
'limit' => 1, |
103
|
|
|
'id' => 'connected_recipes', |
104
|
|
|
'type' => 'post_search_ajax', |
105
|
|
|
'query_args' => array( |
106
|
|
|
'post_type' => 'recipe', |
107
|
|
|
'post_status' => array( 'publish' ), |
108
|
|
|
'posts_per_page' => -1, |
109
|
|
|
), |
110
|
|
|
) |
111
|
|
|
); |
112
|
|
|
if ( function_exists( 'download_monitor' ) ) { |
|
|
|
|
113
|
|
|
$page_url = 'https://wordpress.org/plugins/download-monitor/'; |
114
|
|
|
$plugin_name = 'Download Monitor'; |
115
|
|
|
$description = sprintf( |
116
|
|
|
/* translators: %s: The subscription info */ |
117
|
|
|
__( 'If you are using <a target="_blank" href="%1$s">%2$s</a> you can set a default download file for your recipe here.', 'lsx-search' ), |
118
|
|
|
$page_url, |
119
|
|
|
$plugin_name |
120
|
|
|
); |
121
|
|
|
$cmb->add_field( |
122
|
|
|
array( |
123
|
|
|
'name' => __( 'Default Recipe PDF', 'lsx-health-plan' ), |
124
|
|
|
'description' => $description, |
125
|
|
|
'id' => 'download_recipe', |
126
|
|
|
'type' => 'post_search_ajax', |
127
|
|
|
'limit' => 1, |
128
|
|
|
'query_args' => array( |
129
|
|
|
'post_type' => array( 'dlm_download' ), |
130
|
|
|
'post_status' => array( 'publish' ), |
131
|
|
|
'posts_per_page' => -1, |
132
|
|
|
), |
133
|
|
|
) |
134
|
|
|
); |
135
|
|
|
} |
136
|
|
|
} |
|
|
|
|
137
|
|
|
} |
138
|
|
|
Recipe::get_instance(); |
139
|
|
|
|