PluginProbe
Related Posts By PickPlugins / trunk
Related Posts By PickPlugins vtrunk
trunk 1.0 1.1 1.2 2.0.0 2.0.1 2.0.10 2.0.11 2.0.14 2.0.16 2.0.17 2.0.18 2.0.19 2.0.2 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.25 2.0.26 2.0.27 2.0.28 2.0.29 2.0.30 All 60 releases
related-post / includes / menu / settings.php

settings.php in Related Posts By PickPlugins trunk, at includes/menu/settings.php

252 lines 8.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (! defined('ABSPATH')) exit; // if direct access
3
4
5 $current_tab = isset($_POST['tab']) ? sanitize_text_field($_POST['tab']) : 'general';
6
7 $related_post_settings_tab = array();
8
9 $related_post_settings_tab[] = array(
10 'id' => 'general',
11 /* translators: %s: Icon HTML */
12 'title' => sprintf(__('%s General', 'related-post'), '<i class="fas fa-list-ul"></i>'),
13 'priority' => 1,
14 'active' => ($current_tab == 'general') ? true : false,
15
16 );
17
18 $related_post_settings_tab[] = array(
19 'id' => 'query',
20 /* translators: %s: Icon HTML */
21 'title' => sprintf(__('%s Query', 'related-post'), '<i class="fas fa-filter"></i>'),
22 'priority' => 2,
23 'active' => ($current_tab == 'query') ? true : false,
24 );
25
26 $related_post_settings_tab[] = array(
27 'id' => 'style',
28 /* translators: %s: Icon HTML */
29 'title' => sprintf(__('%s Style', 'related-post'), '<i class="fas fa-palette"></i>'),
30 'priority' => 3,
31 'active' => ($current_tab == 'style') ? true : false,
32 );
33
34 $related_post_settings_tab[] = array(
35 'id' => 'elements',
36 /* translators: %s: Icon HTML */
37 'title' => sprintf(__('%s Elements', 'related-post'), '<i class="fab fa-buffer"></i>'),
38 'priority' => 4,
39 'active' => ($current_tab == 'elements') ? true : false,
40 );
41
42 $related_post_settings_tab[] = array(
43 'id' => 'slider',
44 /* translators: %s: Icon HTML */
45 'title' => sprintf(__('%s Slider', 'related-post'), '<i class="fas fa-photo-video"></i>'),
46 'priority' => 5,
47 'active' => ($current_tab == 'slider') ? true : false,
48 );
49
50 $related_post_settings_tab[] = array(
51 'id' => 'stats',
52 /* translators: %s: Icon HTML */
53 'title' => sprintf(__('%s Stats', 'related-post'), '<i class="fas fa-tachometer-alt"></i>'),
54 'priority' => 6,
55 'active' => ($current_tab == 'stats') ? true : false,
56 );
57
58
59 $related_post_settings_tab[] = array(
60 'id' => 'scripts',
61 /* translators: %s: Icon HTML */
62 'title' => sprintf(__('%s Scripts', 'related-post'), '<i class="fas fa-code"></i>'),
63 'priority' => 6,
64 'active' => ($current_tab == 'scripts') ? true : false,
65 );
66
67 $related_post_settings_tab[] = array(
68 'id' => 'help_support',
69 /* translators: %s: Icon HTML */
70 'title' => sprintf(__('%s Help & Support', 'related-post'), '<i class="fas fa-hands-helping"></i>'),
71 'priority' => 7,
72 'active' => ($current_tab == 'help_support') ? true : false,
73 );
74
75 $related_post_settings_tab[] = array(
76 'id' => 'buy_pro',
77 /* translators: %s: Icon HTML */
78 'title' => sprintf(__('%s Buy Pro', 'related-post'), '<i class="fas fa-store"></i>'),
79 'priority' => 8,
80 'active' => ($current_tab == 'buy_pro') ? true : false,
81 );
82
83
84 $related_post_settings_tab = apply_filters('related_post_settings_tabs', $related_post_settings_tab);
85
86 $tabs_sorted = array();
87 foreach ($related_post_settings_tab as $page_key => $tab) $tabs_sorted[$page_key] = isset($tab['priority']) ? $tab['priority'] : 0;
88 array_multisort($tabs_sorted, SORT_ASC, $related_post_settings_tab);
89
90
91 $settings_tabs_field = new settings_tabs_field();
92 $settings_tabs_field->admin_scripts();
93
94
95 $review_status = isset($_GET['review_status']) ? sanitize_text_field($_GET['review_status']) : '';
96 $related_post_info = get_option('related_post_info');
97 $related_post_settings = get_option('related_post_settings');
98
99 ?>
100 <div class="wrap">
101 <div id="icon-tools" class="icon32"><br></div>
102 <h2><?php
103 /* translators: %s: Icon HTML */
104 echo esc_html(sprintf(__('%s Settings', 'related-post'), related_post_plugin_name)); ?></h2>
105
106
107 <?php
108 $gmt_offset = get_option('gmt_offset');
109 $current_date = wp_date('Y-m-d H:i:s', strtotime('+' . $gmt_offset . ' hour'));
110 //echo '<pre>'.var_export($current_date, true).'</pre>';
111
112
113 if ($review_status == 'remind_later'):
114
115 $related_post_info['review_status'] = 'remind_later';
116 $related_post_info['remind_date'] = wp_date('Y-m-d H:i:s', strtotime('+30 days'));
117
118
119 ?>
120 <div class="update-nag is-dismissible">We will remind you later.</div>
121 <?php
122 update_option('related_post_info', $related_post_info);
123
124 elseif ($review_status == 'done'):
125
126 $related_post_info['review_status'] = 'done';
127 ?>
128 <div class="update-nag notice is-dismissible">Thanks for your time and feedback.</div>
129 <?php
130
131 update_option('related_post_info', $related_post_info);
132
133 endif;
134
135 ?>
136
137
138
139 <form method="post" action="<?php echo esc_url(str_replace('%7E', '~', ($_SERVER['REQUEST_URI']))); ?>">
140 <input type="hidden" name="related_post_hidden" value="Y">
141 <input type="hidden" name="tab" value="<?php echo esc_attr($current_tab); ?>">
142
143 <?php
144 if (!empty($_POST['related_post_hidden'])) {
145
146 $nonce = sanitize_text_field($_POST['_wpnonce']);
147
148 if (wp_verify_nonce($nonce, 'related_post_nonce') && $_POST['related_post_hidden'] == 'Y') {
149
150
151 $related_post_settings = isset($_POST['related_post_settings']) ? related_post_recursive_sanitize_arr($_POST['related_post_settings']) : '';
152 update_option('related_post_settings', $related_post_settings);
153
154
155 do_action('related_post_settings_save');
156
157 ?>
158 <div class="updated notice is-dismissible">
159 <p><strong><?php esc_html_e('Changes Saved.', 'related-post'); ?></strong></p>
160 </div>
161
162 <?php
163 }
164 }
165 ?>
166
167 <div class="settings-tabs-loading" style="">Loading...</div>
168 <div class="settings-tabs vertical has-right-panel" style="display: none">
169
170
171 <div class="settings-tabs-right-panel">
172 <?php
173 foreach ($related_post_settings_tab as $tab) {
174 $id = $tab['id'];
175 $active = $tab['active'];
176
177 ?>
178 <div class="right-panel-content <?php if ($active) echo 'active'; ?> right-panel-content-<?php echo esc_attr($id); ?>">
179 <?php
180
181 do_action('related_post_settings_tabs_right_panel_' . $id);
182 ?>
183
184 </div>
185 <?php
186
187 }
188 ?>
189 </div>
190
191 <ul class="tab-navs">
192 <?php
193 foreach ($related_post_settings_tab as $tab) {
194 $id = $tab['id'];
195 $title = $tab['title'];
196 $active = $tab['active'];
197 $data_visible = isset($tab['data_visible']) ? $tab['data_visible'] : '';
198 $hidden = isset($tab['hidden']) ? $tab['hidden'] : false;
199 $is_pro = isset($tab['is_pro']) ? $tab['is_pro'] : false;
200 $pro_text = isset($tab['pro_text']) ? $tab['pro_text'] : '';
201
202
203 ?>
204 <li <?php if (!empty($data_visible)): ?> data_visible="<?php echo esc_attr($data_visible); ?>" <?php endif; ?> class="tab-nav <?php if ($hidden) echo 'hidden'; ?> <?php if ($active) echo 'active'; ?>" data-id="<?php echo esc_attr($id); ?>">
205 <?php echo wp_kses_post($title); ?>
206 <?php
207 if ($is_pro):
208 ?><span class="pro-feature"><?php echo esc_html($pro_text); ?></span> <?php
209 endif;
210 ?>
211
212 </li>
213 <?php
214 }
215 ?>
216
217
218
219 </ul>
220
221
222
223 <?php
224 foreach ($related_post_settings_tab as $tab) {
225 $id = $tab['id'];
226 $title = $tab['title'];
227 $active = $tab['active'];
228 ?>
229
230 <div class="tab-content <?php if ($active) echo 'active'; ?>" id="<?php echo esc_attr($id); ?>">
231 <?php
232 do_action('related_post_settings_content_' . $id, $tab);
233 ?>
234
235
236 </div>
237
238 <?php
239 }
240 ?>
241
242 <div class="clear clearfix"></div>
243 <p class="submit">
244 <?php wp_nonce_field('related_post_nonce'); ?>
245 <input class="button button-primary" type="submit" name="Submit" value="<?php esc_html_e('Save Changes', 'related-post'); ?>" />
246 </p>
247
248 </div>
249
250
251 </form>
252 </div>