forked from iamsayan/wp-last-modified-info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-last-modified-info.php
629 lines (526 loc) · 41.8 KB
/
wp-last-modified-info.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
<?php
/*
Plugin Name: WP Last Modified Info
Plugin URI: https://iamsayan.github.io/wp-last-modified-info/
Description: Show or hide last update date and time on pages and posts very easily. You can use shortcode also to dispaly last modified info anywhere.
Version: 1.2.5
Author: Sayan Datta
Author URI: https://profiles.wordpress.org/infosatech/
License: GPLv3
Text Domain: wp-last-modified-info
*/
/* This plugin helps to add anything as WordPress Page Extention.
Copyright 2018 Sayan Datta
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
//add admin styles and scripts
function lmt_custom_admin_styles_scripts() {
$current_screen = get_current_screen();
if ( strpos($current_screen->base, 'wp-last-modified-info') !== false) {
wp_enqueue_style( 'lmt-admin-style', plugins_url( 'css/admin-style.min.css', __FILE__ ) );
wp_enqueue_style( 'lmt-cb-style', plugins_url( 'css/style.min.css', __FILE__ ) );
wp_enqueue_script( 'lmt-script', plugins_url( 'js/main.min.js', __FILE__ ) );
}
}
add_action( 'admin_enqueue_scripts', 'lmt_custom_admin_styles_scripts' );
function lmt_ajax_save_admin_scripts() {
if ( is_admin() ) {
// Embed the Script on our Plugin's Option Page Only
if ( isset($_GET['page']) && $_GET['page'] == 'wp-last-modified-info' ) {
wp_enqueue_script('jquery');
wp_enqueue_script( 'jquery-form' );
}
}
}
add_action( 'admin_init', 'lmt_ajax_save_admin_scripts' );
// caling tools
include plugin_dir_path( __FILE__ ) . 'admin/tools.php';
/* ==============================================================================================
register settings
============================================================================================== */
// add settings page
function lmt_plug_settings_page() {
// start post fields
add_settings_section("lmt_post_option_section", "Post Options<p><hr></p>", null, "lmt_post_option");
add_settings_field("lmt_enable_last_modified_cb", "<label for='post-enable'>Enable for Posts on Frontend:</label>", "lmt_enable_last_modified_cb_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_enable_human_format_cb", "<label for='post-human'>Show as 'Days Ago' Format:</label>", "lmt_enable_human_format_cb_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_enable_last_modified_time_cb", "<label for='post-enable-time'>Show Last Modified Time on Posts:</label>", "lmt_enable_last_modified_time_cb_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_custom_post_time_format", "<label for='custom-post-time-format'>Custom Time Format for Posts:</label>", "lmt_custom_post_time_format_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_enable_last_modified_date_cb", "<label for='post-enable-date'>Show Last Modified Date on Posts:</label>", "lmt_enable_last_modified_date_cb_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_custom_post_date_format", "<label for='custom-post-date-format'>Custom Date Format for Posts:</label>", "lmt_custom_post_date_format_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_post_date_time_sep", "<label for='post-dt-sep'>Post Date / Time Seperator:</label>", "lmt_post_date_time_sep_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_show_last_modified_time_date_post", "<label for='post-show-status'>Last Modified Info Display Position:</label>", "lmt_show_last_modified_time_date_post_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_post_custom_text", "<label for='post-custom-text'>Set Custom Message for Posts:</label>", "lmt_post_custom_text_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_show_author_cb", "<label for='post-sa'>Display Last Modified Author Name:</label>", "lmt_show_author_cb_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_use_as_sc_cb", "<label for='post-sc'>Use as Shortcode on Posts:</label>", "lmt_use_as_sc_cb_display", "lmt_post_option", "lmt_post_option_section");
add_settings_field("lmt_post_disable_auto_insert", "<label for='post-disable-auto-insert'>Disable Auto Insert on Post IDs:</label>", "lmt_post_disable_auto_insert_display", "lmt_post_option", "lmt_post_option_section");
// start page fields
add_settings_section("lmt_page_option_section", "Page Options<p><hr></p>", null, "lmt_page_option");
add_settings_field("lmt_enable_last_modified_page_cb", "<label for='page-enable'>Enable for Pages on Frontend:</label>", "lmt_enable_last_modified_page_cb_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_enable_human_format_page_cb", "<label for='page-human'>Show as 'Days Ago' Format:</label>", "lmt_enable_human_format_page_cb_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_enable_last_modified_time_page_cb", "<label for='page-enable-time'>Show Last Modified Time on Pages:</label>", "lmt_enable_last_modified_time_page_cb_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_custom_page_time_format", "<label for='custom-page-time-format'>Custom Time Format for Pages:</label>", "lmt_custom_page_time_format_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_enable_last_modified_date_page_cb", "<label for='page-enable-date'>Show Last Modified Date on Pages:</label>", "lmt_enable_last_modified_date_page_cb_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_custom_page_date_format", "<label for='custom-page-date-format'>Custom Date Format for Pages:</label>", "lmt_custom_page_date_format_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_page_date_time_sep", "<label for='page-dt-sep'>Page Date / Time Seperator:</label>", "lmt_page_date_time_sep_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_show_last_modified_time_date_page", "<label for='page-show-status'>Last Modified Info Display Position:</label>", "lmt_show_last_modified_time_date_page_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_page_custom_text", "<label for='page-custom-text'>Set Custom Message for Pages:</label>", "lmt_page_custom_text_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_show_author_page_cb", "<label for='page-sa'>Display Last Modified Author Name:</label>", "lmt_show_author_page_cb_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_use_as_sc_page_cb", "<label for='page-sc'>Use as Shortcode for Pages:</label>", "lmt_use_as_sc_page_cb_display", "lmt_page_option", "lmt_page_option_section");
add_settings_field("lmt_page_disable_auto_insert", "<label for='page-disable-auto-insert'>Disable Auto Insert on Page IDs:</label>", "lmt_page_disable_auto_insert_display", "lmt_page_option", "lmt_page_option_section");
// start dashboard fields
add_settings_section("lmt_dashboard_option_section", "Dashboard Options<p><hr></p>", null, "lmt_dashboard_option");
add_settings_field("lmt_enable_on_dashboard_cb", "<label for='dashboard-display'>Show Last Modified Info on Dashboard:</label>", "lmt_enable_on_dashboard_cb_display", "lmt_dashboard_option", "lmt_dashboard_option_section");
add_settings_field("lmt_enable_on_admin_bar_cb", "<label for='admin-bar-display'>Show Last Modified Info on Admin Bar:</label>", "lmt_enable_on_admin_bar_cb_display", "lmt_dashboard_option", "lmt_dashboard_option_section");
add_settings_field("lmt_set_widget_post_num", "<label for='widget-post-no'>No. of Posts to Show on Widget:</label>", "lmt_set_widget_post_num_display", "lmt_dashboard_option", "lmt_dashboard_option_section");
// start template tags
add_settings_section("lmt_template_tag_section", "Template Tags Options<p><hr></p>", null, "lmt_template_tag_option");
add_settings_field("lmt_tt_enable_cb", "<label for='lmt-tt'>Enable Template Tags Functioality:</label>", "lmt_tt_enable_cb_display", "lmt_template_tag_option", "lmt_template_tag_section");
add_settings_field("lmt_enable_human_format_tt_cb", "<label for='lmt-tt-human'>Show as 'Days Ago' Format:</label>", "lmt_enable_human_format_tt_cb_display", "lmt_template_tag_option", "lmt_template_tag_section");
add_settings_field("lmt_tt_set_format_box", "<label for='lmt-tt-format'>Set Modified date/time format:</label>", "lmt_tt_set_format_box_display", "lmt_template_tag_option", "lmt_template_tag_section");
add_settings_field("lmt_tt_updated_text_box", "<label for='lmt-tt-updated-text'>Set Custom Message before LMI:</label>", "lmt_tt_updated_text_box_display", "lmt_template_tag_option", "lmt_template_tag_section");
add_settings_field("lmt_show_author_tt_cb", "<label for='lmt-tt-sa'>Display Last Modified Author Name:</label>", "lmt_show_author_tt_cb_display", "lmt_template_tag_option", "lmt_template_tag_section");
add_settings_field("lmt_tt_class_box", "<label for='lmt-tt-class'>Set Custom CSS Class (if applicable):</label>", "lmt_tt_class_box_display", "lmt_template_tag_option", "lmt_template_tag_section");
// start custom css field
add_settings_section("lmt_cus_style_section", "Custom CSS<p><hr></p>", null, "lmt_cus_style_option");
add_settings_field("lmt_custom_style_box", "<label for='lmt-cus-style'>Write Custom CSS Here:</label>", "lmt_custom_style_box_display", "lmt_cus_style_option", "lmt_cus_style_section");
// register settings
register_setting("lmt_post_page_plugin_section", "lmt_plugin_global_settings");
}
/* ==============================================================================================
post options
============================================================================================== */
function lmt_enable_last_modified_cb_display() {
?> <label class="switch">
<input type="checkbox" id="post-enable" name="lmt_plugin_global_settings[lmt_enable_last_modified_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_last_modified_cb'])); ?> />
<div class="slider round"></div></label> <span class="tooltip" title="Enable this if you want to show last modified info on single posts page."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_human_format_cb_display() {
?> <label class="switch">
<input type="checkbox" id="post-human" name="lmt_plugin_global_settings[lmt_enable_human_format_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_human_format_cb'])); ?> />
<div class="slider round"></div></label> <span class="tooltip" title="Enable this if you want to show last modified info on posts as human readable format i.e. days/weeks/years ago."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_last_modified_time_cb_display() {
?> <label class="switch">
<input type="checkbox" id="post-enable-time" name="lmt_plugin_global_settings[lmt_enable_last_modified_time_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_last_modified_time_cb'])); ?> />
<div class="slider round"></div></label> <span class="tooltip" title="Enable this if you want to show last modified time on posts."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_custom_post_time_format_display() {
?> <input id="custom-post-time-format" name="lmt_plugin_global_settings[lmt_custom_post_time_format]" type="text" size="10" style="width:10%;" placeholder="h:i a" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_custom_post_time_format'])) { echo get_option('lmt_plugin_global_settings')['lmt_custom_post_time_format']; } ?>" />
<span class="tooltip" title="Enter custom time format here. Default: h:i a. Go to help tab for more."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_last_modified_date_cb_display() {
?> <label class="switch">
<input type="checkbox" id="post-enable-date" name="lmt_plugin_global_settings[lmt_enable_last_modified_date_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_last_modified_date_cb'])); ?> />
<div class="slider round"></div></label> <span class="tooltip" title="Enable this if you want to show last modified date on posts."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_custom_post_date_format_display() {
?> <input id="custom-post-date-format" name="lmt_plugin_global_settings[lmt_custom_post_date_format]" type="text" size="10" style="width:10%;" placeholder="F jS, Y" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_custom_post_date_format'])) { echo get_option('lmt_plugin_global_settings')['lmt_custom_post_date_format']; } ?>" />
<span class="tooltip" title="Enter custom date format here. Default: F, jS, Y. Go to help tab for more."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_post_date_time_sep_display() {
?> <input id="post-dt-sep" name="lmt_plugin_global_settings[lmt_post_date_time_sep]" type="text" size="8" style="width:8%;" placeholder="at" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_post_date_time_sep'])) { echo get_option('lmt_plugin_global_settings')['lmt_post_date_time_sep']; } ?>" />
<span class="tooltip" title="If you want to customize date/time seperator on posts, set custom date and time seperator from here. Default: at."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_show_last_modified_time_date_post_display() {
$options = get_option('lmt_plugin_global_settings');
if(!isset($options['lmt_show_last_modified_time_date_post'])){
$options['lmt_show_last_modified_time_date_post'] = 'Before Content';
}
$items = array("Before Content", "After Content");
echo "<select id='post-show-status' name='lmt_plugin_global_settings[lmt_show_last_modified_time_date_post]'>";
foreach($items as $item) {
$selected = ($options['lmt_show_last_modified_time_date_post'] == $item) ? 'selected="selected"' : '';
echo "<option value='$item' $selected>$item</option>";
}
echo "</select>";
?>
<span class="tooltip" title="Select where you want to show last modified info on a single posts page."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_post_custom_text_display() {
?> <input id="post-custom-text" name="lmt_plugin_global_settings[lmt_post_custom_text]" type="text" size="30" style="width:30%;" placeholder="Last Updated on" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_post_custom_text'])) { echo get_option('lmt_plugin_global_settings')['lmt_post_custom_text']; } ?>" />
<span class="tooltip" title="Enter your custom text which will be shown on single posts page. You can also set a custom style from 'Custom CSS tab' for this. Use 'post-last-modified' as css class."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_show_author_cb_display() {
$options = get_option('lmt_plugin_global_settings');
if(!isset($options['lmt_show_author_cb'])){
$options['lmt_show_author_cb'] = 'Do not show';
}
$items = array("Do not show", "Show only", "Show with Link");
echo "<select id='post-sa' name='lmt_plugin_global_settings[lmt_show_author_cb]'>";
foreach($items as $item) {
$selected = ($options['lmt_show_author_cb'] == $item) ? 'selected="selected"' : '';
echo "<option value='$item' $selected>$item</option>";
}
echo "</select>";
?>
<span class="tooltip" title="Set how you want to display last modified author name on posts."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_use_as_sc_cb_display() {
?> <label class="switch">
<input type="checkbox" id="post-sc" name="lmt_plugin_global_settings[lmt_use_as_sc_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_use_as_sc_cb'])); ?> />
<div class="slider round"></div></label> Shortcode: <code>[lmt-post-modified-info]</code> <span class="tooltip" title="Enable this if you want to show last modified info on posts using only shortcode. It will disable auto insert process."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_post_disable_auto_insert_display() {
?> <input id="post-disable-auto-insert" name="lmt_plugin_global_settings[lmt_post_disable_auto_insert]" type="text" size="60" style="width:60%;" placeholder="Enter post ids separated by commas" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_post_disable_auto_insert'])) { echo get_option('lmt_plugin_global_settings')['lmt_post_disable_auto_insert']; } ?>" />
<span class="tooltip" title="Enter comma separated list of Post IDs to exclude them from auto insert process."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
/* ==============================================================================================
page options
============================================================================================== */
function lmt_enable_last_modified_page_cb_display() {
?> <label class="switch-pg">
<input type="checkbox" id="page-enable" name="lmt_plugin_global_settings[lmt_enable_last_modified_page_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_last_modified_page_cb'])); ?> />
<div class="slider-pg round-pg"></div></label> <span class="tooltip" title="Enable this if you want to show last modified info on pages."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_human_format_page_cb_display() {
?> <label class="switch-pg">
<input type="checkbox" id="page-human" name="lmt_plugin_global_settings[lmt_enable_human_format_page_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_human_format_page_cb'])); ?> />
<div class="slider-pg round-pg"></div></label> <span class="tooltip" title="Enable this if you want to show last modified info on pages as human readable format i.e. days/weeks/years ago."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_last_modified_time_page_cb_display() {
?> <label class="switch-pg">
<input type="checkbox" id="page-enable-time" name="lmt_plugin_global_settings[lmt_enable_last_modified_time_page_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_last_modified_time_page_cb'])); ?> />
<div class="slider-pg round-pg"></div></label> <span class="tooltip" title="Enable this if you want to show last modified time on pages."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_custom_page_time_format_display() {
?> <input id="custom-page-time-format" name="lmt_plugin_global_settings[lmt_custom_page_time_format]" type="text" size="10" style="width:10%;" placeholder="h:i a" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_custom_page_time_format'])) { echo get_option('lmt_plugin_global_settings')['lmt_custom_page_time_format']; } ?>" />
<span class="tooltip" title="Enter custom time format here. Default: h:i a. Go to help tab for more."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_last_modified_date_page_cb_display() {
?> <label class="switch-pg">
<input type="checkbox" id="page-enable-date" name="lmt_plugin_global_settings[lmt_enable_last_modified_date_page_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_last_modified_date_page_cb'])); ?> />
<div class="slider-pg round-pg"></div></label> <span class="tooltip" title="Enable this if you want to show last modified date on pages."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_custom_page_date_format_display() {
?> <input id="custom-page-date-format" name="lmt_plugin_global_settings[lmt_custom_page_date_format]" type="text" size="10" style="width:10%;" placeholder="F jS, Y" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_custom_page_date_format'])) { echo get_option('lmt_plugin_global_settings')['lmt_custom_page_date_format']; } ?>" />
<span class="tooltip" title="Enter custom date format here. Default: F, jS, Y. Go to help tab for more."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_page_date_time_sep_display() {
?> <input id="page-dt-sep" name="lmt_plugin_global_settings[lmt_page_date_time_sep]" type="text" size="8" style="width:8%;" placeholder="at" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_page_date_time_sep'])) { echo get_option('lmt_plugin_global_settings')['lmt_page_date_time_sep']; } ?>" />
<span class="tooltip" title="If you want to customize date/time seperator on pages, set custom date and time seperator from here. Default: at."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_show_last_modified_time_date_page_display() {
$options = get_option('lmt_plugin_global_settings');
if(!isset($options['lmt_show_last_modified_time_date_page'])){
$options['lmt_show_last_modified_time_date_page'] = 'Before Content';
}
$items = array("Before Content", "After Content");
echo "<select id='page-show-status' name='lmt_plugin_global_settings[lmt_show_last_modified_time_date_page]'>";
foreach($items as $item) {
$selected = ($options['lmt_show_last_modified_time_date_page'] == $item) ? 'selected="selected"' : '';
echo "<option value='$item' $selected>$item</option>";
}
echo "</select>";
?>
<span class="tooltip" title="Select where you want to show last modified info on a single page."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_page_custom_text_display() {
?> <input id="page-custom-text" name="lmt_plugin_global_settings[lmt_page_custom_text]" type="text" size="30" style="width:30%;" placeholder="Last Updated on" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_page_custom_text'])) { echo get_option('lmt_plugin_global_settings')['lmt_page_custom_text']; } ?>" />
<span class="tooltip" title="Enter your custom text which will be shown on single page. You can also set a custom style from 'Custom CSS tab' for this. Use 'page-last-modified' as css class."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_show_author_page_cb_display() {
$options = get_option('lmt_plugin_global_settings');
if(!isset($options['lmt_show_author_page_cb'])){
$options['lmt_show_author_page_cb'] = 'Do not show';
}
$items = array("Do not show", "Show only", "Show with Link");
echo "<select id='page-sa' name='lmt_plugin_global_settings[lmt_show_author_page_cb]'>";
foreach($items as $item) {
$selected = ($options['lmt_show_author_page_cb'] == $item) ? 'selected="selected"' : '';
echo "<option value='$item' $selected>$item</option>";
}
echo "</select>";
?>
<span class="tooltip" title="Set how you want to display last modified author name on pages."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_use_as_sc_page_cb_display() {
?> <label class="switch-pg">
<input type="checkbox" id="page-sc" name="lmt_plugin_global_settings[lmt_use_as_sc_page_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_use_as_sc_page_cb'])); ?> />
<div class="slider-pg round-pg"></div></label> Shortcode: <code>[lmt-page-modified-info]</code> <span class="tooltip" title="Enable this if you want to show last modified info on pages using shortcode. It will disable auto insert function."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_page_disable_auto_insert_display() {
?> <input id="page-disable-auto-insert" name="lmt_plugin_global_settings[lmt_page_disable_auto_insert]" type="text" size="60" style="width:60%;" placeholder="Separated by commas" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_page_disable_auto_insert'])) { echo get_option('lmt_plugin_global_settings')['lmt_page_disable_auto_insert']; } ?>" />
<span class="tooltip" title="Enter comma separated list of Page IDs to exclude them from auto insert process."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
/* ==============================================================================================
dashboard options
============================================================================================== */
function lmt_enable_on_dashboard_cb_display() {
?> <label class="switch-db">
<input type="checkbox" id="dashboard-display" name="lmt_plugin_global_settings[lmt_enable_on_dashboard_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_on_dashboard_cb'])); ?> />
<div class="slider-db round-db"></div></label> <span class="tooltip" title="Enable this if you want to display last modified info on all posts, pages admin column, publish meta box and on the dashboard widget."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_on_admin_bar_cb_display() {
?> <label class="switch-db">
<input type="checkbox" id="admin-bar-display" name="lmt_plugin_global_settings[lmt_enable_on_admin_bar_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_on_admin_bar_cb'])); ?> />
<div class="slider-db round-db"></div></label> <span class="tooltip" title="Enable this if you want to show last modified info on wordpress admin bar."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_set_widget_post_num_display() {
?> <input id="widget-post-no" name="lmt_plugin_global_settings[lmt_set_widget_post_num]" type="number" size="6" style="width:6%;" placeholder="5" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_set_widget_post_num'])) { echo get_option('lmt_plugin_global_settings')['lmt_set_widget_post_num']; } ?>" />
<span class="tooltip" title="Set the number of posts you want to display on dashboard widget."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
/* ==============================================================================================
template tags options
============================================================================================== */
function lmt_tt_enable_cb_display() {
?> <label class="switch-tt">
<input type="checkbox" id="lmt-tt" name="lmt_plugin_global_settings[lmt_tt_enable_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_tt_enable_cb'])); ?> />
<div class="slider-tt round-tt"></div></label> <span class="tooltip" title="Enable this if you want to use template tag functionality. Go to Help tab for more info."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_enable_human_format_tt_cb_display() {
?> <label class="switch-tt">
<input type="checkbox" id="lmt-tt-human" name="lmt_plugin_global_settings[lmt_enable_human_format_tt_cb]" value="1" <?php checked(1 == isset(get_option('lmt_plugin_global_settings')['lmt_enable_human_format_tt_cb'])); ?> />
<div class="slider-tt round-tt"></div></label> <span class="tooltip" title="Enable this if you want to show last modified info as human readable format i.e. days/weeks/years ago using template tags."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_tt_set_format_box_display() {
?> <input id="lmt-tt-format" name="lmt_plugin_global_settings[lmt_tt_set_format_box]" type="text" size="20" style="width:20%;" placeholder="e.g. F jS, Y @ h:i a" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_tt_set_format_box'])) { echo get_option('lmt_plugin_global_settings')['lmt_tt_set_format_box']; } ?>" />
<span class="tooltip" title="Set custom date/time format here. Default: F jS, Y @ h:i a. go to help tab for details."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_tt_updated_text_box_display() {
?> <input id="lmt-tt-updated-text" name="lmt_plugin_global_settings[lmt_tt_updated_text_box]" type="text" size="30" style="width:30%;" placeholder="e.g. updated on" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_tt_updated_text_box'])) { echo get_option('lmt_plugin_global_settings')['lmt_tt_updated_text_box']; } ?>" />
<span class="tooltip" title="If you want to display any message before last modified date/time, set here."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_show_author_tt_cb_display() {
$options = get_option('lmt_plugin_global_settings');
if(!isset($options['lmt_show_author_tt_cb'])){
$options['lmt_show_author_tt_cb'] = 'Do not show';
}
$items = array("Do not show", "Show only", "Show with Link");
echo "<select id='lmt-tt-sa' name='lmt_plugin_global_settings[lmt_show_author_tt_cb]'>";
foreach($items as $item) {
$selected = ($options['lmt_show_author_tt_cb'] == $item) ? 'selected="selected"' : '';
echo "<option value='$item' $selected>$item</option>";
}
echo "</select>";
?>
<span class="tooltip" title="Set how you want to display last modified author name using template tags."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
function lmt_tt_class_box_display() {
?> <input id="lmt-tt-class" name="lmt_plugin_global_settings[lmt_tt_class_box]" type="text" size="40" style="width:40%;" placeholder="e.g. entry-time" value="<?php if (isset(get_option('lmt_plugin_global_settings')['lmt_tt_class_box'])) { echo get_option('lmt_plugin_global_settings')['lmt_tt_class_box']; } ?>" />
<span class="tooltip" title="If you want to set any CSS Class, write here."><span title="" class="dashicons dashicons-editor-help"></span></span>
<?php
}
/* ==============================================================================================
custom css
============================================================================================== */
function lmt_custom_style_box_display() {
?>
<textarea id="lmt-cus-style" placeholder="Write your custom css here." name="lmt_plugin_global_settings[lmt_custom_style_box]" rows="12" cols="100" style="width:90%;"><?php if (isset(get_option('lmt_plugin_global_settings')['lmt_custom_style_box'])) { echo get_option('lmt_plugin_global_settings')['lmt_custom_style_box']; } ?></textarea>
<?php
}
// add settings page
add_action("admin_init", "lmt_plug_settings_page");
/* ==============================================================================================
Start plugin functions
============================================================================================== */
// add custom css
add_action ('wp_head','lmt_style_hook_inHeader', 10);
function lmt_style_hook_inHeader() {
if( !empty( get_option('lmt_plugin_global_settings')['lmt_custom_style_box']) ) {
echo '<style type="text/css" id="lmt-custom-css">' . get_option('lmt_plugin_global_settings')['lmt_custom_style_box'] . '</style>'."\n";
}
}
function lmt_remove_footer_admin () {
// fetch plugin version
$lmtpluginfo = get_plugin_data(__FILE__);
$lmtversion = $lmtpluginfo['Version'];
// pring plugin version
echo 'Thanks for using <strong>WP Last Modified Info v'. $lmtversion .'</strong> | Developed with <span style="color:#e25555;">♥</span> by <a href="https://profiles.wordpress.org/infosatech/" target="_blank" style="font-weight: 500;">Sayan Datta</a> | <a href="https://github.com/iamsayan/wp-last-modified-info" target="_blank" style="font-weight: 500;">GitHub</a> | <a href="https://wordpress.org/support/plugin/wp-last-modified-info" target="_blank" style="font-weight: 500;">Support</a> | <a href="https://wordpress.org/support/plugin/wp-last-modified-info/reviews/" target="_blank" style="font-weight: 500;">Rate it</a> (<span style="color:#ffa000;">★★★★★</span>), if you like this plugin.';
}
// page elements
function lmt_show_page() {
include plugin_dir_path( __FILE__ ) . 'admin/settings-page.php';
/*function lmt_remove_footer_admin_version () {
$lmtpluginfo = get_plugin_data(__FILE__);
$lmtversion = $lmtpluginfo['Version'];
// pring plugin version
echo 'Version '. $lmtversion;
}*/
add_filter('admin_footer_text', 'lmt_remove_footer_admin');
//add_filter( 'update_footer', 'lmt_remove_footer_admin_version');
}
function lmt_tools_page() {
?>
<div class="wrap">
<h1>Import & Export</h1>
<div class="metabox-holder">
<div class="postbox">
<h3><span><?php _e( 'Export Settings' ); ?></span></h3>
<div class="inside">
<p><?php _e( 'Export the plugin settings for this site as a .json file. This allows you to easily import the configuration into another site.' ); ?></p>
<form method="post">
<p><input type="hidden" name="lmt_export_action" value="lmt_export_settings" /></p>
<p>
<?php wp_nonce_field( 'lmt_export_nonce', 'lmt_export_nonce' ); ?>
<?php submit_button( __( 'Export Settings' ), 'secondary', 'submit', false ); ?>
</p>
</form>
</div><!-- .inside -->
</div><!-- .postbox -->
<div class="postbox">
<h3><span><?php _e( 'Import Settings' ); ?></span></h3>
<div class="inside">
<p><?php _e( 'Import the plugin settings from a .json file. This file can be obtained by exporting the settings on another site using the form above.' ); ?></p>
<form method="post" enctype="multipart/form-data">
<p>
<input type="file" name="import_file"/>
</p>
<p>
<input type="hidden" name="lmt_import_action" value="lmt_import_settings" />
<?php wp_nonce_field( 'lmt_import_nonce', 'lmt_import_nonce' ); ?>
<?php submit_button( __( 'Import Settings' ), 'secondary', 'submit', false ); ?>
</p>
</form>
</div><!-- .inside -->
</div><!-- .postbox -->
<div class="postbox">
<h3><span><?php _e( 'Reset Settings' ); ?></span></h3>
<div class="inside">
<p><?php _e( 'Reset the plugin settings to default for this site.' ); ?></p>
<form method="post">
<p><input type="hidden" name="lmt_reset_action" value="lmt_reset_settings" /></p>
<p>
<?php wp_nonce_field( 'lmt_reset_nonce', 'lmt_reset_nonce' ); ?>
<?php submit_button( __( 'Reset Settings' ), 'secondary', 'submit', false ); ?>
</p>
</form>
</div><!-- .inside -->
</div><!-- .postbox -->
</div>
</div><!--end .wrap-->
<?php
add_filter('admin_footer_text', 'lmt_remove_footer_admin');
}
// add menu options
function lmt_menu_item_options() {
add_menu_page('WP Last Modified Info', 'WP LMI', 'manage_options', 'wp-last-modified-info', 'lmt_show_page', 'dashicons-clock', 100);
//add_submenu_page("options-general.php", "WP Last Modified Info", "Last Modified Info", "manage_options", "wp-last-modified-info", "lmt_show_page");
add_submenu_page('wp-last-modified-info', 'WP Last Modified Info', 'Last Modified Info', 'manage_options', 'wp-last-modified-info', 'lmt_show_page');
add_submenu_page('wp-last-modified-info', 'Tools - WP Last Modified Info', 'Tools', 'manage_options', 'lmt-import-export', 'lmt_tools_page');
}
if(!is_network_admin()) {
add_action('admin_menu', 'lmt_menu_item_options');
}
$options = get_option('lmt_plugin_global_settings');
// lmi output for posts
if( isset($options['lmt_enable_last_modified_cb']) && ($options['lmt_enable_last_modified_cb'] == 1) ) {
include plugin_dir_path( __FILE__ ) . 'inc/class-post-options.php';
}
// enable lmi output for pages
if( isset($options['lmt_enable_last_modified_page_cb']) && ($options['lmt_enable_last_modified_page_cb'] == 1) ) {
require plugin_dir_path( __FILE__ ) . 'inc/class-page-options.php';
}
// last modified info of posts column
if( isset($options['lmt_enable_on_dashboard_cb']) && ($options['lmt_enable_on_dashboard_cb'] == 1 ) ) {
include plugin_dir_path( __FILE__ ) . 'inc/class-dashboard-post.php';
include plugin_dir_path( __FILE__ ) . 'inc/class-dashboard-page.php';
include plugin_dir_path( __FILE__ ) . 'inc/class-dashboard-last-login.php';
include plugin_dir_path( __FILE__ ) . 'inc/class-dashboard-profile-modified.php';
include plugin_dir_path( __FILE__ ) . 'inc/class-dashboard-widget.php';
function lmt_show_on_dashboard () {
$lmt_updated_time = get_the_modified_time('M j, Y @ H:i');
if (get_the_modified_time('U') > get_the_time('U')) {
echo '<div class="misc-pub-section curtime misc-pub-last-updated"><span id="lmt-timestamp"> Updated on: <b>' . $lmt_updated_time . '</b></span></div>';
}
}
add_action( 'post_submitbox_misc_actions', 'lmt_show_on_dashboard');
function lmt_print_admin_css() {
echo '<style type="text/css">
.fixed .column-modified {
width:18%;
}
.fixed .column-last-updated {
width:12%;
}
.fixed .column-last-login {
width:12%;
}
.curtime #lmt-timestamp:before {
content:"\f469";
font: 400 20px/1 dashicons;
speak: none;
display: inline-block;
margin-left: -1px;
padding-right: 3px;
vertical-align: top;
-webkit-font-smoothing: antialiased;
color: #82878c;
}
</style>'."\n";
}
add_action( 'admin_head', 'lmt_print_admin_css' );
}
// showw on admin bar
if( isset($options['lmt_enable_on_admin_bar_cb']) && ($options['lmt_enable_on_admin_bar_cb'] == 1) ) {
require plugin_dir_path( __FILE__ ) . 'inc/class-admin-bar.php';
}
// enable template tags functionality
if( isset($options['lmt_tt_enable_cb']) && ($options['lmt_tt_enable_cb'] == 1) ) {
require plugin_dir_path( __FILE__ ) . 'inc/class-template-tags.php';
}
// add action links
add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'lmt_add_action_links', 10, 2 );
function lmt_add_action_links ( $links ) {
$lmtlinks = array(
'<a href="' . admin_url( 'admin.php?page=wp-last-modified-info' ) . '">Settings</a>',
);
return array_merge( $lmtlinks, $links );
}
function lmt_plugin_meta_links($links, $file) {
$plugin = plugin_basename(__FILE__);
if ($file == $plugin) // only for this plugin
return array_merge( $links,
array( '<a href="https://github.com/iamsayan/wp-last-modified-info" target="_blank">' . __('GitHub') . '</a>' ),
array( '<a href="https://wordpress.org/support/plugin/wp-last-modified-info" target="_blank">' . __('Support') . '</a>' ),
array( '<a href="https://bit.ly/2I0Gj60" target="_blank">' . __('Donate') . '</a>' )
);
return $links;
}
add_filter( 'plugin_row_meta', 'lmt_plugin_meta_links', 10, 2 );
?>