PluginProbe
Head Meta Data / 20260810
Head Meta Data v20260810
20260810 trunk 20170324 20170731 20171022 20171103 20180507 20180817 20181114 20190220 20190306 20190428 20190902 20191027 20200313 20200805 20201110 20210209 20210713 20220113 20220515 20220925 20230227 20230715 20231026 All 33 releases
head-meta-data / head-meta-data.php

head-meta-data.php in Head Meta Data 20260810, at head-meta-data.php

1,244 lines 50.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Head Meta Data
4 Plugin URI: https://perishablepress.com/head-metadata-plus/
5 Description: Adds a custom set of &lt;meta&gt; tags to the &lt;head&gt; section of all posts &amp; pages.
6 Tags: meta, metadata, seo, robots
7 Author: Jeff Starr
8 Author URI: https://plugin-planet.com/
9 Donate link: https://monzillamedia.com/donate.html
10 Contributors: specialk
11 Requires at least: 4.7
12 Tested up to: 7.1
13 Stable tag: 20260810
14 Version: 20260810
15 Requires PHP: 5.6.20
16 Text Domain: head-meta-data
17 Domain Path: /languages
18 License: GPL v2 or later
19
20 This program is free software; you can redistribute it and/or
21 modify it under the terms of the GNU General Public License
22 as published by the Free Software Foundation; either version
23 2 of the License, or (at your option) any later version.
24
25 This program is distributed in the hope that it will be useful,
26 but WITHOUT ANY WARRANTY; without even the implied warranty of
27 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 GNU General Public License for more details.
29
30 You should have received a copy of the GNU General Public License
31 with this program. If not, visit: https://www.gnu.org/licenses/
32
33 Copyright 2006-2026 Monzilla Media. All rights reserved.
34 */
35
36 if (!defined('ABSPATH')) die();
37
38
39 $head_meta_data_version_wp = '4.7';
40 $head_meta_data_version = '20260810';
41 $head_meta_data_plugin = 'Head Meta Data';
42 $head_meta_data_options = get_option('hmd_options');
43 $head_meta_data_path = plugin_basename(__FILE__); // head-meta-data/head-meta-data.php
44 $head_meta_data_homeurl = 'https://perishablepress.com/head-metadata-plus/';
45
46
47 function hmd_check_pro() {
48
49 global $head_meta_data_path;
50
51 if (function_exists('head_meta_pro_options')) deactivate_plugins($head_meta_data_path);
52
53 }
54 add_action('admin_init', 'hmd_check_pro');
55
56
57 function hmd_i18n_init() {
58
59 global $head_meta_data_path;
60
61 $path = $head_meta_data_path; // don't modify global variable
62
63 $path = $path ? dirname($path) : null;
64
65 if ($path) load_plugin_textdomain('head-meta-data', false, $path .'/languages/');
66
67 }
68 add_action('init', 'hmd_i18n_init');
69
70
71 function hmd_require_wp_version() {
72
73 global $head_meta_data_path, $head_meta_data_plugin, $head_meta_data_version_wp;
74
75 if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
76
77 $wp_version = get_bloginfo('version');
78
79 if (version_compare($wp_version, $head_meta_data_version_wp, '<')) {
80
81 if (is_plugin_active($head_meta_data_path)) {
82
83 deactivate_plugins($head_meta_data_path);
84
85 $msg = '<strong>'. $head_meta_data_plugin .'</strong> '. esc_html__('requires WordPress ', 'head-meta-data');
86 $msg .= $head_meta_data_version_wp . esc_html__(' or higher, and has been deactivated. ', 'head-meta-data');
87 $msg .= esc_html__('Please return to the', 'head-meta-data') .' <a href="'. admin_url('plugins.php') .'">';
88 $msg .= esc_html__('WordPress Admin Area', 'head-meta-data') .'</a> ';
89 $msg .= esc_html__('to upgrade WordPress and try again.', 'head-meta-data');
90
91 wp_die($msg);
92
93 }
94
95 }
96
97 }
98
99 }
100 add_action('admin_init', 'hmd_require_wp_version');
101
102
103 function head_meta_data() {
104
105 echo hmd_display_content();
106
107 }
108 add_action('wp_head', 'head_meta_data');
109
110
111 function hmd_shortcode() { // internal use only
112
113 $get_meta_data = hmd_display_content();
114
115 $the_meta_data = str_replace(array('>', '<'), array('&gt;','&lt;'), $get_meta_data);
116
117 return $the_meta_data;
118
119 }
120 add_shortcode('head_meta_data','hmd_shortcode');
121
122
123 function hmd_disable_default() {
124
125 if (!is_singular()) return;
126
127 global $post;
128
129 return get_post_meta($post->ID, 'hmd_disable_default', true);
130
131 }
132
133
134 function hmd_allowed_html() {
135
136 $global = array(
137 'accesskey' => array(),
138 'class' => array(),
139 'contenteditable' => array(),
140 'dir' => array(),
141 'draggable' => array(),
142 'enterkeyhint' => array(),
143 'hidden' => array(),
144 'id' => array(),
145 'inert' => array(),
146 'inputmode' => array(),
147 'lang' => array(),
148 'popover' => array(),
149 'spellcheck' => array(),
150 'style' => array(),
151 'tabindex' => array(),
152 'title' => array(),
153 'translate' => array()
154 );
155
156 $style = array(
157 'media' => array(),
158 'type' => array()
159 );
160
161 $meta = array(
162 'charset' => array(),
163 'content' => array(),
164 'http-equiv' => array(),
165 'name' => array()
166 );
167
168 $link = array(
169 'crossorigin' => array(),
170 'href' => array(),
171 'hreflang' => array(),
172 'media' => array(),
173 'referrerpolicy' => array(),
174 'rel' => array(),
175 'sizes' => array(),
176 'title' => array(),
177 'type' => array()
178 );
179
180 $base = array(
181 'href' => array(),
182 'target' => array()
183 );
184
185 return array(
186 'title' => $global,
187 'style' => array_merge($global, $style),
188 'meta' => array_merge($global, $meta),
189 'link' => array_merge($global, $link),
190 'base' => array_merge($global, $base),
191 );
192
193 }
194
195
196 function hmd_display_custom() {
197
198 if (!is_singular()) return;
199
200 global $post;
201
202 $custom = '';
203
204 $value = get_post_meta($post->ID, 'head-meta-data', false);
205
206 if (is_array($value)) {
207
208 foreach ($value as $v) {
209
210 $v = hmd_filter_shortcodes($v);
211
212 $custom .= wp_kses($v, hmd_allowed_html()) . "\n";
213
214 }
215
216 }
217
218 return $custom;
219
220 }
221
222
223 function hmd_primary_tags($options, $close) {
224
225 $output = '';
226
227 if (isset($options['hmd_charset']) && $options['hmd_charset'] !== '') $output = "\t\t" .'<meta charset="' . $options['hmd_charset'] . $close;
228 if (isset($options['hmd_abstract']) && $options['hmd_abstract'] !== '') $output .= "\t\t" .'<meta name="abstract" content="' . $options['hmd_abstract'] . $close;
229 if (isset($options['hmd_author']) && $options['hmd_author'] !== '') $output .= "\t\t" .'<meta name="author" content="' . $options['hmd_author'] . $close;
230 if (isset($options['hmd_classify']) && $options['hmd_classify'] !== '') $output .= "\t\t" .'<meta name="classification" content="' . $options['hmd_classify'] . $close;
231 if (isset($options['hmd_copyright']) && $options['hmd_copyright'] !== '') $output .= "\t\t" .'<meta name="copyright" content="' . $options['hmd_copyright'] . $close;
232 if (isset($options['hmd_desc']) && $options['hmd_desc'] !== '') $output .= "\t\t" .'<meta name="description" content="' . $options['hmd_desc'] . $close;
233 if (isset($options['hmd_designer']) && $options['hmd_designer'] !== '') $output .= "\t\t" .'<meta name="designer" content="' . $options['hmd_designer'] . $close;
234 if (isset($options['hmd_distribute']) && $options['hmd_distribute'] !== '') $output .= "\t\t" .'<meta name="distribution" content="' . $options['hmd_distribute'] . $close;
235 if (isset($options['hmd_keywords']) && $options['hmd_keywords'] !== '') $output .= "\t\t" .'<meta name="keywords" content="' . $options['hmd_keywords'] . $close;
236 if (isset($options['hmd_language']) && $options['hmd_language'] !== '') $output .= "\t\t" .'<meta name="language" content="' . $options['hmd_language'] . $close;
237 if (isset($options['hmd_publisher']) && $options['hmd_publisher'] !== '') $output .= "\t\t" .'<meta name="publisher" content="' . $options['hmd_publisher'] . $close;
238 if (isset($options['hmd_rating']) && $options['hmd_rating'] !== '') $output .= "\t\t" .'<meta name="rating" content="' . $options['hmd_rating'] . $close;
239 if (isset($options['hmd_resource']) && $options['hmd_resource'] !== '') $output .= "\t\t" .'<meta name="resource-type" content="' . $options['hmd_resource'] . $close;
240 if (isset($options['hmd_revisit']) && $options['hmd_revisit'] !== '') $output .= "\t\t" .'<meta name="revisit-after" content="' . $options['hmd_revisit'] . $close;
241 if (isset($options['hmd_subject']) && $options['hmd_subject'] !== '') $output .= "\t\t" .'<meta name="subject" content="' . $options['hmd_subject'] . $close;
242 if (isset($options['hmd_template']) && $options['hmd_template'] !== '') $output .= "\t\t" .'<meta name="template" content="' . $options['hmd_template'] . $close;
243 if (isset($options['hmd_robots']) && $options['hmd_robots'] !== '') $output .= "\t\t" .'<meta name="robots" content="' . $options['hmd_robots'] . $close;
244
245 $output = hmd_filter_shortcodes($output);
246
247 return $output;
248
249 }
250
251
252 function hmd_display_content() {
253
254 global $head_meta_data_options;
255
256 $hmd_output = '';
257
258 $hmd_enable = isset($head_meta_data_options['hmd_enable']) ? $head_meta_data_options['hmd_enable'] : false;
259 $hmd_format = isset($head_meta_data_options['hmd_format']) ? $head_meta_data_options['hmd_format'] : false;
260
261 $close_tag = ($hmd_format == false) ? '" />'. "\n" : $close_tag = '">'. "\n";
262
263 if ($hmd_enable == true && !hmd_disable_default()) {
264
265 $hmd_output .= hmd_primary_tags($head_meta_data_options, $close_tag);
266
267 }
268
269 $hmd_output .= hmd_display_custom();
270
271 return $hmd_output;
272
273 }
274
275
276 function hmd_custom_shortcode() { // internal use only
277
278 global $head_meta_data_options;
279
280 if ($head_meta_data_options['hmd_custom'] !== '') {
281
282 $get_custom_data = $head_meta_data_options['hmd_custom'];
283
284 $the_custom_data = "\t\t" . str_replace(array('>', '<'), array('&gt;','&lt;'), $get_custom_data);
285
286 return $the_custom_data;
287
288 }
289
290 }
291 add_shortcode('hmd_custom','hmd_custom_shortcode');
292
293
294 function hmd_filter_shortcodes($content) {
295
296 global $post;
297
298 if (empty($post)) return $content;
299
300 $post_id = $post->ID;
301 $author_id = $post->post_author;
302
303 $format = apply_filters('hmd_date_format', 'Y-m-d');
304 $tagline = get_bloginfo('description');
305 $title = get_bloginfo('name');
306
307 //
308
309 if (is_singular()) {
310
311 $post_excerpt = get_the_excerpt($post_id); // fyi: https://bit.ly/30uneVr
312 $post_date = get_the_modified_date($format);
313 $post_author = get_the_author_meta('display_name', $author_id);
314 $post_title = get_the_title($post_id);
315 $post_cats = get_the_category($post_id);
316 $post_tags = get_the_tags($post_id);
317
318 } else {
319
320 $post_excerpt = $tagline;
321 $post_date = hmd_latest_post_date($format);
322 $post_author = $title;
323 $post_title = $tagline;
324 $post_cats = get_the_terms($post_id, 'category');
325 $post_tags = get_the_terms($post_id, 'post_tag');
326
327 }
328
329 //
330
331 if ($post_excerpt && !is_wp_error($post_excerpt)) {
332
333 $length = apply_filters('hmd_excerpt_length', 160);
334 $post_excerpt = wp_strip_all_tags($post_excerpt, true);
335 $post_excerpt = substr($post_excerpt, 0, $length);
336
337 } else {
338
339 $post_excerpt = $tagline;
340
341 }
342
343 if ($post_cats && !is_wp_error($post_cats)) {
344
345 $names = wp_list_pluck($post_cats, 'name');
346 $post_cats = implode(', ', $names);
347
348 } else {
349
350 $post_cats = get_bloginfo('name');
351
352 }
353
354 if ($post_tags && !is_wp_error($post_tags)) {
355
356 $names = wp_list_pluck($post_tags, 'name');
357 $post_tags = implode(', ', $names);
358
359 } else {
360
361 $post_tags = $title;
362
363 }
364
365 //
366
367 $patterns = array();
368 $patterns[0] = "/\[hmd_tab\]/";
369 $patterns[1] = "/\[hmd_post_excerpt\]/";
370 $patterns[2] = "/\[hmd_post_date\]/";
371 $patterns[3] = "/\[hmd_post_author\]/";
372 $patterns[4] = "/\[hmd_post_title\]/";
373 $patterns[5] = "/\[hmd_post_cats\]/";
374 $patterns[6] = "/\[hmd_post_tags\]/";
375 $patterns[7] = "/\[hmd_year\]/";
376 $patterns[8] = "/\[hmd_site_tagline\]/";
377 $patterns[9] = "/\[hmd_site_title\]/";
378
379 $replacements = array();
380 $replacements[0] = "\t";
381 $replacements[1] = $post_excerpt;
382 $replacements[2] = $post_date;
383 $replacements[3] = $post_author;
384 $replacements[4] = $post_title;
385 $replacements[5] = $post_cats;
386 $replacements[6] = $post_tags;
387 $replacements[7] = date('Y');
388 $replacements[8] = $tagline;
389 $replacements[9] = $title;
390
391 $content = preg_replace($patterns, $replacements, $content);
392
393 return $content;
394
395 }
396
397
398 function hmd_custom_content() {
399
400 global $head_meta_data_options;
401
402 $custom = isset($head_meta_data_options['hmd_custom']) ? $head_meta_data_options['hmd_custom'] : '';
403
404 $custom = hmd_filter_shortcodes($custom);
405
406 echo "\t\t" . $custom . "\n";
407
408 }
409 add_action('wp_head', 'hmd_custom_content');
410
411
412 function hmd_latest_post_date($format) {
413
414 $args = array(
415 'posts_per_page' => 1,
416 'orderby' => 'date',
417 'post_status' => 'publish',
418 );
419 $posts = get_posts($args);
420
421 $updated = '';
422
423 foreach ($posts as $post) {
424
425 setup_postdata($post);
426
427 $updated = get_the_modified_date($format);
428
429 }
430
431 wp_reset_postdata();
432
433 return $updated;
434
435 }
436
437
438 function hmd_plugin_action_links($links, $file) {
439
440 global $head_meta_data_path;
441
442 if ($file === $head_meta_data_path && (current_user_can('manage_options'))) {
443
444 $hmd_links = '<a href="'. admin_url('options-general.php?page=head-meta-data') .'">'. esc_html__('Settings', 'head-meta-data') .'</a>';
445
446 array_unshift($links, $hmd_links);
447
448 }
449
450 if ($file === $head_meta_data_path) {
451
452 $pro_href = 'https://plugin-planet.com/head-meta-pro/';
453 $pro_title = esc_attr__('Get Head Meta Pro!', 'head-meta-data');
454 $pro_text = esc_html__('Go&nbsp;Pro', 'head-meta-data');
455 $pro_style = 'padding:2px 4px;font-weight:bold;border:1px solid #00CCCC;border-radius:2px;background-color:#fff;';
456
457 $pro = '<a target="_blank" rel="noopener noreferrer" href="'. $pro_href .'" title="'. $pro_title .'" style="'. $pro_style .'">'. $pro_text .'</a>';
458
459 array_unshift($links, $pro);
460
461 }
462
463 return $links;
464
465 }
466 add_filter ('plugin_action_links', 'hmd_plugin_action_links', 10, 2);
467
468
469 function add_hmd_links($links, $file) {
470
471 global $head_meta_data_path;
472
473 if ($file === $head_meta_data_path) {
474
475 $home_href = 'https://perishablepress.com/head-metadata-plus/';
476 $home_title = esc_attr__('Plugin Homepage', 'head-meta-data');
477 $home_text = esc_html__('Homepage', 'head-meta-data');
478
479 $links[] = '<a target="_blank" rel="noopener noreferrer" href="'. $home_href .'" title="'. $home_title .'">'. $home_text .'</a>';
480
481 $href = 'https://wordpress.org/support/plugin/head-meta-data/reviews/?rate=5#new-post';
482 $title = esc_html__('Give us a 5-star rating at WordPress.org', 'head-meta-data');
483 $text = esc_html__('Rate this plugin', 'head-meta-data') .'&nbsp;&raquo;';
484
485 $links[] = '<a target="_blank" rel="noopener noreferrer" href="'. $href .'" title="'. $title .'">'. $text .'</a>';
486
487 }
488
489 return $links;
490
491 }
492 add_filter('plugin_row_meta', 'add_hmd_links', 10, 2);
493
494
495 function hmd_footer_text($text) {
496
497 $screen_id = hmd_get_current_screen_id();
498
499 $ids = array('settings_page_head-meta-data/head-meta-data');
500
501 if ($screen_id && apply_filters('head_meta_data_admin_footer_text', in_array($screen_id, $ids))) {
502
503 $text = __('Like this plugin? Give it a', 'head-meta-data');
504
505 $text .= ' <a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/support/plugin/head-meta-data/reviews/?rate=5#new-post">';
506
507 $text .= __('�
508
509
510
511
512 rating&nbsp;&raquo;', 'head-meta-data') .'</a>';
513
514 }
515
516 return $text;
517
518 }
519 add_filter('admin_footer_text', 'hmd_footer_text', 10, 1);
520
521
522 function hmd_get_current_screen_id() {
523
524 if (!function_exists('get_current_screen')) require_once ABSPATH .'/wp-admin/includes/screen.php';
525
526 $screen = get_current_screen();
527
528 if ($screen && property_exists($screen, 'id')) return $screen->id;
529
530 return false;
531
532 }
533
534
535 function hmd_delete_plugin_options() {
536
537 delete_option('hmd_options');
538 delete_option('head-meta-data-dismiss-notice');
539
540 }
541 if (isset($head_meta_data_options['default_options']) && $head_meta_data_options['default_options'] == 1) {
542
543 register_uninstall_hook(__FILE__, 'hmd_delete_plugin_options');
544
545 }
546
547
548 function hmd_add_defaults() {
549
550 // meta subject
551
552 $categories = get_categories(array('orderby'=>'name', 'order'=>'ASC'));
553 $num_cats = count($categories);
554 $subjects = '';
555
556 $i = 0;
557
558 foreach ($categories as $category) {
559
560 $subjects .= $category->name;
561
562 if (++$i !== $num_cats) $subjects .= ', ';
563
564 }
565
566 // name, description, language
567
568 $site_name = get_bloginfo('name');
569 $site_desc = get_bloginfo('description');
570 $site_lang = get_bloginfo('language');
571
572 // template and designer
573
574 $get_theme = wp_get_theme();
575 $the_theme = $get_theme->Name;
576 $designer = $get_theme->display('Author', FALSE);
577
578 // author name
579
580 $user_info = get_userdata(1);
581
582 if ($user_info == true) {
583
584 $admin_name = $user_info->user_login;
585
586 } else {
587
588 $admin_name = 'Administrator';
589
590 }
591
592 //
593
594 $tmp = get_option('hmd_options');
595
596 if ((isset($tmp['default_options']) && $tmp['default_options'] == 1) || (!is_array($tmp))) {
597
598 $arr = array(
599
600 'default_options' => 0,
601 'hmd_charset' => 'utf-8',
602 'hmd_abstract' => $site_desc,
603 'hmd_author' => $admin_name,
604 'hmd_classify' => $subjects,
605 'hmd_copyright' => 'Copyright '. $site_name .' - All rights Reserved.',
606 'hmd_designer' => $designer,
607 'hmd_distribute' => 'Global',
608 'hmd_language' => $site_lang,
609 'hmd_publisher' => $site_name,
610 'hmd_rating' => 'General',
611 'hmd_resource' => 'Document',
612 'hmd_revisit' => '3',
613 'hmd_subject' => $subjects,
614 'hmd_template' => $the_theme,
615 'hmd_enable' => 1,
616 'hmd_custom' => '',
617 'hmd_format' => 1,
618 'hmd_robots' => 'index,follow',
619 'hmd_keywords' => '',
620 'hmd_desc' => '',
621
622 );
623
624 update_option('hmd_options', $arr);
625
626 }
627
628 }
629 register_activation_hook(__FILE__, 'hmd_add_defaults');
630
631
632 function hmd_init() {
633
634 register_setting('hmd_plugin_options', 'hmd_options', 'hmd_validate_options');
635
636 }
637 add_action('admin_init', 'hmd_init');
638
639
640 function hmd_validate_options($input) {
641
642 if (!isset($input['default_options'])) $input['default_options'] = null;
643 $input['default_options'] = ($input['default_options'] == 1 ? 1 : 0);
644
645 $input['hmd_charset'] = esc_attr($input['hmd_charset']);
646 $input['hmd_abstract'] = esc_attr($input['hmd_abstract']);
647 $input['hmd_author'] = esc_attr($input['hmd_author']);
648 $input['hmd_classify'] = esc_attr($input['hmd_classify']);
649 $input['hmd_copyright'] = esc_attr($input['hmd_copyright']);
650 $input['hmd_designer'] = esc_attr($input['hmd_designer']);
651 $input['hmd_distribute'] = esc_attr($input['hmd_distribute']);
652 $input['hmd_language'] = esc_attr($input['hmd_language']);
653 $input['hmd_publisher'] = esc_attr($input['hmd_publisher']);
654 $input['hmd_rating'] = esc_attr($input['hmd_rating']);
655 $input['hmd_resource'] = esc_attr($input['hmd_resource']);
656 $input['hmd_revisit'] = esc_attr($input['hmd_revisit']);
657 $input['hmd_subject'] = esc_attr($input['hmd_subject']);
658 $input['hmd_template'] = esc_attr($input['hmd_template']);
659 $input['hmd_robots'] = esc_attr($input['hmd_robots']);
660 $input['hmd_keywords'] = esc_attr($input['hmd_keywords']);
661 $input['hmd_desc'] = esc_attr($input['hmd_desc']);
662
663 if (!isset($input['hmd_enable'])) $input['hmd_enable'] = null;
664 $input['hmd_enable'] = ($input['hmd_enable'] == 1 ? 1 : 0);
665
666 // dealing with kses
667 global $allowedposttags;
668 $default_allowedposttags = $allowedposttags;
669 $allowed_atts = array(
670 'align'=>array(), 'class'=>array(), 'id'=>array(), 'dir'=>array(), 'lang'=>array(), 'style'=>array(), 'label'=>array(), 'url'=>array(),
671 'xml:lang'=>array(), 'src'=>array(), 'alt'=>array(), 'name'=>array(), 'content'=>array(), 'http-equiv'=>array(), 'profile'=>array(),
672 'href'=>array(), 'property'=>array(), 'title'=>array(), 'rel'=>array(), 'type'=>array(), 'charset'=>array(), 'media'=>array(), 'rev'=>array(),
673 );
674 $allowedposttags['strong'] = $allowed_atts;
675 $allowedposttags['script'] = $allowed_atts;
676 $allowedposttags['style'] = $allowed_atts;
677 $allowedposttags['small'] = $allowed_atts;
678 $allowedposttags['span'] = $allowed_atts;
679 $allowedposttags['meta'] = $allowed_atts;
680 $allowedposttags['item'] = $allowed_atts;
681 $allowedposttags['base'] = $allowed_atts;
682 $allowedposttags['link'] = $allowed_atts;
683 $allowedposttags['abbr'] = $allowed_atts;
684 $allowedposttags['code'] = $allowed_atts;
685 $allowedposttags['div'] = $allowed_atts;
686 $allowedposttags['img'] = $allowed_atts;
687 $allowedposttags['h1'] = $allowed_atts;
688 $allowedposttags['h2'] = $allowed_atts;
689 $allowedposttags['h3'] = $allowed_atts;
690 $allowedposttags['h4'] = $allowed_atts;
691 $allowedposttags['h5'] = $allowed_atts;
692 $allowedposttags['ol'] = $allowed_atts;
693 $allowedposttags['ul'] = $allowed_atts;
694 $allowedposttags['li'] = $allowed_atts;
695 $allowedposttags['em'] = $allowed_atts;
696 $allowedposttags['p'] = $allowed_atts;
697 $allowedposttags['a'] = $allowed_atts;
698
699 $input['hmd_custom'] = wp_kses($input['hmd_custom'], $allowedposttags);
700
701 if (!isset($input['hmd_format'])) $input['hmd_format'] = null;
702 $input['hmd_format'] = ($input['hmd_format'] == 1 ? 1 : 0);
703
704 $allowedposttags = $default_allowedposttags;
705
706 return $input;
707
708 }
709
710
711 function hmd_add_options_page() {
712
713 global $head_meta_data_plugin;
714
715 // add_options_page($page_title, $menu_title, $capability, $menu_slug, $callback, $position)
716 add_options_page($head_meta_data_plugin, $head_meta_data_plugin, 'manage_options', 'head-meta-data', 'hmd_render_form');
717
718 }
719 add_action ('admin_menu', 'hmd_add_options_page');
720
721
722 function hmd_render_form() {
723
724 global $head_meta_data_plugin, $head_meta_data_options, $head_meta_data_homeurl, $head_meta_data_version; ?>
725
726 <style type="text/css">
727 #mm-plugin-options .mm-panel-overview {
728 box-sizing: border-box; width: 100%; overflow: hidden; position: relative; padding: 0 15px 15px 140px;
729 background-image: url(<?php echo plugins_url('/head-meta-data/images/hmd-logo.jpg'); ?>);
730 background-repeat: no-repeat; background-position: 15px 0; background-size: 120px 88px;
731 }
732 .mm-panel-overview .main { width: 100%; }
733 .mm-panel-overview .info {
734 position: absolute; width: 30%; bottom: 0; right: 0;
735 background-color: #FDF2D2; background-image: linear-gradient(to right, #FDF2D2, #fff);
736 }
737 @media (max-width: 880px) {
738 .mm-panel-overview .main { width: 60%; }
739 }
740 @media (max-width: 680px) {
741 .mm-panel-overview .main, .mm-panel-overview .info { width: 100%; float: none; position: static; }
742 .mm-panel-overview .info { padding: 5px 15px 5px 0; }
743 }
744
745 #mm-plugin-options .mm-panel-toggle { margin: 5px 0; }
746 #mm-plugin-options .mm-credit-info { margin: -10px 0 10px 5px; font-size: 12px; }
747 #mm-plugin-options .button-primary { margin: 0 0 15px 15px; }
748
749 #mm-plugin-options #setting-error-settings_updated { margin: 5px 0 15px 0; }
750 #mm-plugin-options #setting-error-settings_updated p { margin: 7px 0 6px 0; }
751
752 #mm-plugin-options .mm-table-wrap { margin: 15px; }
753 #mm-plugin-options .mm-table-wrap td { padding: 5px 10px; vertical-align: middle; }
754 #mm-plugin-options .mm-table-wrap .mm-table { padding: 10px 0; }
755 #mm-plugin-options .mm-table-wrap .widefat th { padding: 10px 15px; vertical-align: middle; }
756 #mm-plugin-options .mm-table-wrap .widefat td { padding: 10px; vertical-align: middle; }
757
758 #mm-plugin-options h1 small { line-height: 12px; font-size: 12px; color: #bbb; }
759 #mm-plugin-options h2 { margin: 0; padding: 12px 0 12px 15px; font-size: 16px; cursor: pointer; }
760 #mm-plugin-options h3 { margin: 20px 15px; font-size: 14px; }
761 .wrap form p { margin-left: 15px; }
762 #mm-plugin-options ul { margin: 15px 15px 20px 40px; line-height: 16px; }
763 #mm-plugin-options li { margin: 8px 0; list-style-type: disc; }
764
765 #mm-plugin-options textarea { width: 80%; }
766 #mm-plugin-options input[type=text] { width: 70%; }
767 #mm-plugin-options input[type=checkbox] { margin-top: -3px; }
768 #mm-plugin-options .mm-radio-inputs { margin: 5px 0; }
769 #mm-plugin-options .mm-code {
770 display: inline-block; margin: 0 1px; padding: 3px; direction: ltr; unicode-bidi: embed;
771 color: #333; background-color: #eaeaea; background-color: rgba(0,0,0,0.07);
772 font-size: 12px; font-family: Consolas, Monaco, monospace;
773 }
774 #mm-plugin-options .mm-item-caption { margin: 3px 0 0 3px; line-height: 17px; font-size: 12px; color: #777; }
775 #mm-plugin-options .mm-item-caption code { margin: 0; padding: 3px; font-size: 12px; background: #f2f2f2; background-color: rgba(0,0,0,0.05); }
776 #mm-plugin-options .mm-item-caption-nomargin { margin: 0; }
777 #mm-plugin-options textarea + .mm-item-caption { margin: 0 0 0 3px; }
778
779 #mm-plugin-options .mm-code-example { margin: 10px 0 20px 0; }
780 #mm-plugin-options .mm-code-example div { margin-left: 15px; }
781 #mm-plugin-options .mm-code-example pre {
782 box-sizing: border-box; width: 90%; overflow: auto; margin: 10px 20px; padding: 10px;
783 border: 1px solid #efefef; background-color: #fffeee;
784 }
785
786 .wp-admin .notice code { line-height: 1; font-size: 12px; }
787 .wp-admin .hmd-dismiss-notice { float: right; }
788
789 .wp-admin .notice-lh p { line-height: 1.8; }
790 .wp-admin .notice-custom { background-image: url(<?php echo plugins_url('/head-meta-data/images/sun-icon.png'); ?>); background-repeat: no-repeat; background-position: left 5px center; background-size: 60px 40px; }
791 .wp-admin .notice-custom p { margin: 15px 0; padding-left: 60px; line-height: 1.6; }
792 .wp-admin .notice-link { display: inline-block; margin-right: 5px; }
793 @media (max-width: 782px) {
794 .wp-admin .notice-custom p { margin: 10px 0; }
795 }
796
797 @media (max-width: 1000px) {
798 #mm-plugin-options input[type=text] { width: 80%; }
799 #mm-plugin-options textarea { width: 90%; }
800 }
801 @media (max-width: 782px) {
802 #mm-plugin-options .mm-radio-inputs { margin: 10px 0; }
803 }
804 @media (max-width: 600px) {
805 #mm-plugin-options input[type=text],
806 #mm-plugin-options textarea { width: 98%; }
807 }
808 @media (max-width: 1100px) {
809 .wp-admin .hmd-dismiss-notice { float: none; }
810 }
811 </style>
812
813 <div id="mm-plugin-options" class="wrap">
814 <h1><?php echo $head_meta_data_plugin; ?> <small><?php echo 'v'. $head_meta_data_version; ?></small></h1>
815 <div class="mm-panel-toggle"><a href="<?php echo admin_url('options-general.php?page=head-meta-data'); ?>"><?php esc_html_e('Toggle all panels', 'head-meta-data'); ?></a></div>
816
817 <form method="post" action="options.php">
818 <?php $head_meta_data_options = get_option('hmd_options'); settings_fields('hmd_plugin_options'); ?>
819
820 <div class="metabox-holder">
821 <div class="meta-box-sortables ui-sortable">
822
823 <div id="mm-panel-overview" class="postbox">
824 <h2><?php esc_html_e('Overview', 'head-meta-data'); ?></h2>
825 <div class="toggle<?php if (isset($_GET["settings-updated"])) { echo ' default-hidden'; } ?>">
826 <div class="mm-panel-overview">
827 <div class="main">
828 <p>
829 <strong><?php echo $head_meta_data_plugin; ?></strong> <?php esc_html_e('(HMD) adds a custom set of', 'head-meta-data'); ?>
830 <code>&lt;meta&gt;</code> <?php esc_html_e('tags to the', 'head-meta-data'); ?>
831 <code>&lt;head&gt;</code> <?php esc_html_e('section of all posts and pages.', 'head-meta-data'); ?>
832 </p>
833 <ul>
834 <li><a id="mm-panel-primary-link" href="#mm-panel-primary"><?php esc_html_e('Plugin Settings', 'head-meta-data'); ?></a></li>
835 <li><a id="mm-panel-secondary-link" href="#mm-panel-secondary"><?php esc_html_e('Live Preview', 'head-meta-data'); ?></a></li>
836 <li><a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/plugins/head-meta-data/"><?php esc_html_e('Plugin Homepage', 'head-meta-data'); ?></a></li>
837 </ul>
838 <p>
839 <?php esc_html_e('If you like this plugin, please', 'head-meta-data'); ?>
840 <a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/support/plugin/head-meta-data/reviews/?rate=5#new-post" title="<?php esc_attr_e('THANK YOU for your support!', 'head-meta-data'); ?>"><?php esc_html_e('give it a 5-star rating', 'head-meta-data'); ?>&nbsp;&raquo;</a>
841 </p>
842 </div>
843 <div class="info">
844 <p>
845 🔥 <strong><?php esc_html_e('Go Pro!', 'head-meta-data'); ?></strong> <?php esc_html_e('Check out', 'head-meta-data'); ?>
846 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/head-meta-pro/" title="<?php esc_html_e('Get Head Meta Pro!', 'head-meta-data'); ?>"><?php esc_html_e('Head Meta Pro', 'head-meta-data'); ?>&nbsp;&raquo;</a>
847 </p>
848 </div>
849 </div>
850 </div>
851 </div>
852
853 <div id="mm-panel-primary" class="postbox">
854 <h2><?php esc_html_e('Plugin Settings', 'head-meta-data'); ?></h2>
855 <div class="toggle<?php if (!isset($_GET["settings-updated"])) { echo ' default-hidden'; } ?>">
856 <h3><?php esc_html_e('Meta Tags', 'head-meta-data'); ?></h3>
857 <p>
858 <?php esc_html_e('Here you may define your', 'head-meta-data'); ?> <code>&lt;meta&gt;</code> <?php esc_html_e('tags. To disable any tag, leave it blank.', 'head-meta-data'); ?>
859 <?php esc_html_e('To add more tags, visit the option &ldquo;Custom Tags&rdquo; below.', 'head-meta-data'); ?>
860 </p>
861 <div class="mm-table-wrap">
862 <table class="widefat mm-table">
863 <colgroup>
864 <col span="1" style="width: 17%;">
865 <col span="1" style="width: 77%;">
866 </colgroup>
867 <tr>
868 <th scope="row"><label for="hmd_options[hmd_enable]"><?php esc_html_e('Enable tags', 'head-meta-data'); ?></label></th>
869 <td><input type="checkbox" name="hmd_options[hmd_enable]" value="1" <?php if (isset($head_meta_data_options['hmd_enable'])) checked('1', $head_meta_data_options['hmd_enable']); ?>>
870 <span><?php esc_html_e('Enable meta tags', 'head-meta-data'); ?></span></td>
871 </tr>
872 <tr>
873 <th scope="row"><label for="hmd_options[hmd_format]"><?php esc_html_e('HTML format', 'head-meta-data'); ?></label></th>
874 <td><input type="checkbox" name="hmd_options[hmd_format]" value="1" <?php if (isset($head_meta_data_options['hmd_format'])) checked('1', $head_meta_data_options['hmd_format']); ?>>
875 <span><?php esc_html_e('Check box for HTML format (default), or leave unchecked for XHTML format', 'head-meta-data'); ?></span></td>
876 </tr>
877 <tr>
878 <th scope="row"><label for="hmd_options[hmd_charset]"><?php esc_html_e('Meta charset', 'head-meta-data'); ?></label></th>
879 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_charset]" value="<?php if (isset($head_meta_data_options['hmd_charset'])) echo esc_attr($head_meta_data_options['hmd_charset']); ?>">
880 <div class="mm-item-caption"><?php esc_html_e('Specify the character encoding for your web pages (default: utf-8)', 'head-meta-data'); ?></div></td>
881 </tr>
882 <tr>
883 <th scope="row"><label for="hmd_options[hmd_abstract]"><?php esc_html_e('Meta abstract', 'head-meta-data'); ?></label></th>
884 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_abstract]" value="<?php if (isset($head_meta_data_options['hmd_abstract'])) echo esc_attr($head_meta_data_options['hmd_abstract']); ?>">
885 <div class="mm-item-caption"><?php esc_html_e('Summarize your site&rsquo;s content in a short sentence', 'head-meta-data'); ?></div></td>
886 </tr>
887 <tr>
888 <th scope="row"><label for="hmd_options[hmd_author]"><?php esc_html_e('Meta author', 'head-meta-data'); ?></label></th>
889 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_author]" value="<?php if (isset($head_meta_data_options['hmd_author'])) echo esc_attr($head_meta_data_options['hmd_author']); ?>">
890 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s author(s)', 'head-meta-data'); ?></div></td>
891 </tr>
892 <tr>
893 <th scope="row"><label for="hmd_options[hmd_classify]"><?php esc_html_e('Meta classification', 'head-meta-data'); ?></label></th>
894 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_classify]" value="<?php if (isset($head_meta_data_options['hmd_classify'])) echo esc_attr($head_meta_data_options['hmd_classify']); ?>">
895 <div class="mm-item-caption"><?php esc_html_e('Classify your site, examples: Shopping, Movies, Food', 'head-meta-data'); ?></div></td>
896 </tr>
897 <tr>
898 <th scope="row"><label for="hmd_options[hmd_copyright]"><?php esc_html_e('Meta copyright', 'head-meta-data'); ?></label></th>
899 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_copyright]" value="<?php if (isset($head_meta_data_options['hmd_copyright'])) echo esc_attr($head_meta_data_options['hmd_copyright']); ?>">
900 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s copyright information', 'head-meta-data'); ?></div></td>
901 </tr>
902 <tr>
903 <th scope="row"><label for="hmd_options[hmd_desc]"><?php esc_html_e('Meta description', 'head-meta-data'); ?></label></th>
904 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_desc]" value="<?php if (isset($head_meta_data_options['hmd_desc'])) echo esc_attr($head_meta_data_options['hmd_desc']); ?>">
905 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s description', 'head-meta-data'); ?></div></td>
906 </tr>
907 <tr>
908 <th scope="row"><label for="hmd_options[hmd_designer]"><?php esc_html_e('Meta designer', 'head-meta-data'); ?></label></th>
909 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_designer]" value="<?php if (isset($head_meta_data_options['hmd_designer'])) echo esc_attr($head_meta_data_options['hmd_designer']); ?>">
910 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s designer/developer', 'head-meta-data'); ?></div></td>
911 </tr>
912 <tr>
913 <th scope="row"><label for="hmd_options[hmd_distribute]"><?php esc_html_e('Meta distribution', 'head-meta-data'); ?></label></th>
914 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_distribute]" value="<?php if (isset($head_meta_data_options['hmd_distribute'])) echo esc_attr($head_meta_data_options['hmd_distribute']); ?>">
915 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s distribution level, examples: Global, Regional, Local', 'head-meta-data'); ?></div></td>
916 </tr>
917 <tr>
918 <th scope="row"><label for="hmd_options[hmd_keywords]"><?php esc_html_e('Meta keywords', 'head-meta-data'); ?></label></th>
919 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_keywords]" value="<?php if (isset($head_meta_data_options['hmd_keywords'])) echo esc_attr($head_meta_data_options['hmd_keywords']); ?>">
920 <div class="mm-item-caption"><?php esc_html_e('Indicate some keywords for your site', 'head-meta-data'); ?></div></td>
921 </tr>
922 <tr>
923 <th scope="row"><label for="hmd_options[hmd_language]"><?php esc_html_e('Meta language', 'head-meta-data'); ?></label></th>
924 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_language]" value="<?php if (isset($head_meta_data_options['hmd_language'])) echo esc_attr($head_meta_data_options['hmd_language']); ?>">
925 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s primary language, examples: EN-US, EN, FR', 'head-meta-data'); ?></div></td>
926 </tr>
927 <tr>
928 <th scope="row"><label for="hmd_options[hmd_publisher]"><?php esc_html_e('Meta publisher', 'head-meta-data'); ?></label></th>
929 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_publisher]" value="<?php if (isset($head_meta_data_options['hmd_publisher'])) echo esc_attr($head_meta_data_options['hmd_publisher']); ?>">
930 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s publisher', 'head-meta-data'); ?></div></td>
931 </tr>
932 <tr>
933 <th scope="row"><label for="hmd_options[hmd_rating]"><?php esc_html_e('Meta rating', 'head-meta-data'); ?></label></th>
934 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_rating]" value="<?php if (isset($head_meta_data_options['hmd_rating'])) echo esc_attr($head_meta_data_options['hmd_rating']); ?>">
935 <div class="mm-item-caption"><?php esc_html_e('Indicate the rating of your site&rsquo;s content, examples: General, Mature, Restricted', 'head-meta-data'); ?></div></td>
936 </tr>
937 <tr>
938 <th scope="row"><label for="hmd_options[hmd_resource]"><?php esc_html_e('Meta resource-type', 'head-meta-data'); ?></label></th>
939 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_resource]" value="<?php if (isset($head_meta_data_options['hmd_resource'])) echo esc_attr($head_meta_data_options['hmd_resource']); ?>">
940 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s primary resource type, examples: Document', 'head-meta-data'); ?></div></td>
941 </tr>
942 <tr>
943 <th scope="row"><label for="hmd_options[hmd_revisit]"><?php esc_html_e('Meta revisit-after', 'head-meta-data'); ?></label></th>
944 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_revisit]" value="<?php if (isset($head_meta_data_options['hmd_revisit'])) echo esc_attr($head_meta_data_options['hmd_revisit']); ?>">
945 <div class="mm-item-caption"><?php esc_html_e('Frequency (in days) for search engines to revisit your site for re-indexing, examples: 1, 2, 3', 'head-meta-data'); ?></div></td>
946 </tr>
947 <tr>
948 <th scope="row"><label for="hmd_options[hmd_subject]"><?php esc_html_e('Meta subject', 'head-meta-data'); ?></label></th>
949 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_subject]" value="<?php if (isset($head_meta_data_options['hmd_subject'])) echo esc_attr($head_meta_data_options['hmd_subject']); ?>">
950 <div class="mm-item-caption"><?php esc_html_e('Indicate your site&rsquo;s primary subject(s), examples: Photography, Sports, Pancakes', 'head-meta-data'); ?></div></td>
951 </tr>
952 <tr>
953 <th scope="row"><label for="hmd_options[hmd_template]"><?php esc_html_e('Meta template', 'head-meta-data'); ?></label></th>
954 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_template]" value="<?php if (isset($head_meta_data_options['hmd_template'])) echo esc_attr($head_meta_data_options['hmd_template']); ?>">
955 <div class="mm-item-caption"><?php esc_html_e('Indicate any template used by your site, example: Awesome WordPress Theme', 'head-meta-data'); ?></div></td>
956 </tr>
957 <tr>
958 <th scope="row"><label for="hmd_options[hmd_robots]"><?php esc_html_e('Meta robots', 'head-meta-data'); ?></label></th>
959 <td><input type="text" size="50" maxlength="200" name="hmd_options[hmd_robots]" value="<?php if (isset($head_meta_data_options['hmd_robots'])) echo esc_attr($head_meta_data_options['hmd_robots']); ?>">
960 <div class="mm-item-caption"><?php esc_html_e('Indicate any robots directives for your site, example: index,follow', 'head-meta-data'); ?></div></td>
961 </tr>
962 <tr>
963 <th scope="row"><label><?php esc_html_e('More tags', 'head-meta-data'); ?></label></th>
964 <td>
965 <?php esc_html_e('Want more tags? PRO gives you more tags and', 'head-meta-data'); ?>
966 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/head-meta-pro-shortcut-variables/" title="<?php esc_html_e('Shortcut variables for Pro version', 'head-meta-data'); ?>"><?php esc_html_e('shortcut variables', 'head-meta-data'); ?></a>.
967 <?php esc_html_e('Add tags for Facebook, Twitter, and', 'head-meta-data'); ?>
968 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/wp/wp-content/themes/planet/img/plugins/hmp/hmp-settings.png" title="<?php esc_html_e('View screenshot of Pro settings', 'head-meta-data'); ?>"><?php esc_html_e('each type of page-view', 'head-meta-data'); ?></a>
969 <?php esc_html_e('(home, posts, archives, and more). Level up your meta game with', 'head-meta-data'); ?>
970 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/head-meta-pro/" title="<?php esc_html_e('Get Head Meta Pro!', 'head-meta-data'); ?>"><?php esc_html_e('Head Meta Pro', 'head-meta-data'); ?>&nbsp;&raquo;</a>
971 </td>
972 </tr>
973 </table>
974 </div>
975 <h3><?php esc_html_e('Custom Tags', 'head-meta-data'); ?></h3>
976 <p>
977 <?php esc_html_e('Here you may define any custom tags or markup that should be included in the head section of your pages. You also can add custom tags to specific posts and pages. Check the', 'head-meta-data'); ?>
978 <a target="_blank" rel="noopener noreferrer" href="https://wordpress.org/plugins/head-meta-data/#installation"><?php esc_html_e('Installation docs', 'head-meta-data'); ?></a>
979 <?php esc_html_e('(under &ldquo;Custom meta tags&rdquo;) for more details about this setting and the following shortcodes.', 'head-meta-data'); ?>
980 </p>
981 <p>
982 <?php esc_html_e('You may include shortcodes to display dynamic information:', 'head-meta-data'); ?>
983 <span class="mm-code">[hmd_post_excerpt]</span>, <span class="mm-code">[hmd_post_date]</span>, <span class="mm-code">[hmd_post_author]</span>, <span class="mm-code">[hmd_post_title]</span>,
984 <span class="mm-code">[hmd_post_cats]</span>, <span class="mm-code">[hmd_post_tags]</span>, <span class="mm-code">[hmd_site_tagline]</span>, <span class="mm-code">[hmd_site_title]</span>,
985 <span class="mm-code">[hmd_year]</span>, <span class="mm-code">[hmd_tab]</span>
986 </p>
987 <p><?php esc_html_e('Example meta tag:', 'head-meta-data'); ?> <code>&lt;meta name="example" content="custom: [hmd_post_date]"&gt;</code></p>
988 <div class="mm-table-wrap">
989 <table class="widefat mm-table">
990 <colgroup>
991 <col span="1" style="width: 17%;">
992 <col span="1" style="width: 77%;">
993 </colgroup>
994 <tr>
995 <th scope="row"><label for="hmd_options[hmd_custom]"><?php esc_html_e('Custom Tags', 'head-meta-data'); ?></label></th>
996 <td>
997 <textarea class="large-text code" type="textarea" rows="7" cols="55" name="hmd_options[hmd_custom]"><?php if (isset($head_meta_data_options['hmd_custom'])) echo esc_textarea($head_meta_data_options['hmd_custom']); ?></textarea>
998 <div class="mm-item-caption">
999 <?php esc_html_e('Optional tags for the', 'head-meta-data'); ?> <code>&lt;head&gt;</code>
1000 <?php esc_html_e('section (leave blank to disable). For way more', 'head-meta-data'); ?>
1001 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/head-meta-pro-shortcut-variables/" title="<?php esc_html_e('Shortcut variables for Pro version', 'head-meta-data'); ?>"><?php esc_html_e('shortcut variables', 'head-meta-data'); ?></a>,
1002 <?php esc_html_e('check out the', 'head-meta-data'); ?>
1003 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/head-meta-pro/" title="<?php esc_html_e('Get Head Meta Pro!', 'head-meta-data'); ?>"><?php esc_html_e('Pro version', 'head-meta-data'); ?>&nbsp;&raquo;</a>
1004 </div>
1005 </td>
1006 </tr>
1007 </table>
1008 </div>
1009 <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'head-meta-data'); ?>">
1010 </div>
1011 </div>
1012
1013 <div id="mm-panel-secondary" class="postbox">
1014 <h2><?php esc_html_e('Live Preview', 'head-meta-data'); ?></h2>
1015 <div class="toggle default-hidden">
1016 <p><?php esc_html_e('Here is a preview of your meta tags. Note that any special characters will be encoded in the actual page markup.', 'head-meta-data'); ?></p>
1017 <div class="mm-code-example">
1018
1019 <h3><?php esc_html_e('Meta Tags', 'head-meta-data'); ?></h3>
1020 <p><?php esc_html_e('When meta tags are enabled, the following code will be added to the head section of your web pages.', 'head-meta-data'); ?></p>
1021 <pre><?php echo do_shortcode('[head_meta_data]', 'head-meta-data'); ?></pre>
1022
1023 <h3><?php esc_html_e('Custom Tags', 'head-meta-data'); ?></h3>
1024 <p><?php esc_html_e('Visit your front-end pages to view any dynamic shortcode output.', 'head-meta-data'); ?></p>
1025
1026
1027 <pre><?php $shortcode = do_shortcode('[hmd_custom]', 'head-meta-data');
1028
1029 if ($shortcode) {
1030
1031 echo do_shortcode('[hmd_custom]', 'head-meta-data');
1032
1033 } else {
1034
1035 esc_html_e('No custom tags defined.', 'head-meta-data');
1036
1037 }
1038
1039 ?></pre>
1040
1041 <h3><?php esc_html_e('More infos', 'head-meta-data'); ?></h3>
1042 <ul>
1043 <li>
1044 <?php esc_html_e('For more information on document headers:', 'head-meta-data'); ?>
1045 <a target="_blank" rel="noopener noreferrer" href="https://m0n.co/c" title="<?php esc_attr_e('XHTML Document Header Resource', 'head-meta-data'); ?>">https://m0n.co/c</a>
1046 </li>
1047 <li>
1048 <?php esc_html_e('And more specifically the section on meta tags:', 'head-meta-data'); ?>
1049 <a target="_blank" rel="noopener noreferrer" href="https://m0n.co/d" title="<?php esc_attr_e('XHTML Document Header Resource: meta tags', 'head-meta-data'); ?>">https://m0n.co/d</a>
1050 </li>
1051 <li>
1052 <?php esc_html_e('Level up your meta game with', 'head-meta-data'); ?>
1053 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/head-meta-pro/" title="<?php esc_html_e('Get Head Meta Pro!', 'head-meta-data'); ?>"><?php esc_html_e('Head Meta Pro', 'head-meta-data'); ?>&nbsp;&raquo;</a>
1054 </li>
1055 </ul>
1056 </div>
1057 </div>
1058 </div>
1059
1060 <div id="mm-restore-settings" class="postbox">
1061 <h2><?php esc_html_e('Restore Defaults', 'head-meta-data'); ?></h2>
1062 <div class="toggle default-hidden">
1063 <p>
1064 <input name="hmd_options[default_options]" type="checkbox" value="1" id="mm_restore_defaults" <?php if (isset($head_meta_data_options['default_options'])) { checked('1', $head_meta_data_options['default_options']); } ?>>
1065 <?php esc_html_e('Restore default options upon plugin deactivation/reactivation.', 'head-meta-data'); ?>
1066 </p>
1067 <p>
1068 <span class="mm-item-caption mm-item-caption-nomargin">
1069 <strong><?php esc_html_e('Tip:', 'head-meta-data'); ?></strong>
1070 <?php esc_html_e('leave this option unchecked to remember your settings. Or, to go ahead and restore all default options, check the box, save your settings, and then deactivate/reactivate the plugin.', 'head-meta-data'); ?>
1071 </span>
1072 </p>
1073 <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings', 'head-meta-data'); ?>">
1074 </div>
1075 </div>
1076
1077 <div id="mm-panel-current" class="postbox">
1078 <h2><?php esc_html_e('WP Resources', 'head-meta-data'); ?></h2>
1079 <div class="toggle">
1080 <?php require_once('support-panel.php'); ?>
1081 </div>
1082 </div>
1083
1084 </div>
1085 </div>
1086
1087 <div class="mm-credit-info">
1088 <a target="_blank" rel="noopener noreferrer" href="<?php echo esc_url($head_meta_data_homeurl); ?>" title="<?php esc_attr_e('Plugin Homepage', 'head-meta-data'); ?>"><?php echo esc_html($head_meta_data_plugin); ?></a> <?php esc_html_e('by', 'head-meta-data'); ?>
1089 <a target="_blank" rel="noopener noreferrer" href="https://x.com/perishable" title="<?php esc_attr_e('Jeff Starr on X (Twitter)', 'head-meta-data'); ?>">Jeff Starr</a> @
1090 <a target="_blank" rel="noopener noreferrer" href="https://monzillamedia.com/" title="<?php esc_attr_e('Obsessive Web Design &amp; Development', 'head-meta-data'); ?>">Monzilla Media</a>
1091 </div>
1092
1093 </form>
1094 </div>
1095
1096 <script type="text/javascript">
1097 jQuery(document).ready(function(){
1098 // toggle panels
1099 jQuery('.default-hidden').hide();
1100 jQuery('.mm-panel-toggle a').click(function(){
1101 jQuery('.toggle').slideToggle(300);
1102 return false;
1103 });
1104 jQuery('h2').click(function(){
1105 jQuery(this).next().slideToggle(300);
1106 });
1107 jQuery('#mm-panel-primary-link').click(function(){
1108 jQuery('.toggle').hide();
1109 jQuery('#mm-panel-primary .toggle').slideToggle(300);
1110 return true;
1111 });
1112 jQuery('#mm-panel-secondary-link').click(function(){
1113 jQuery('.toggle').hide();
1114 jQuery('#mm-panel-secondary .toggle').slideToggle(300);
1115 return true;
1116 });
1117 // prevent accidents
1118 if(!jQuery("#mm_restore_defaults").is(":checked")){
1119 jQuery('#mm_restore_defaults').click(function(event){
1120 var r = confirm("<?php esc_html_e('Are you sure you want to restore all default options?', 'head-meta-data'); ?>");
1121 if (r == true){
1122 jQuery("#mm_restore_defaults").attr('checked', true);
1123 } else {
1124 jQuery("#mm_restore_defaults").attr('checked', false);
1125 }
1126 });
1127 }
1128 });
1129 </script>
1130
1131 <?php }
1132
1133
1134 function hmd_admin_notice() {
1135
1136 if (hmd_get_current_screen_id() === 'settings_page_head-meta-data') {
1137
1138 if (!hmd_check_date_expired() && !hmd_dismiss_notice_check()) {
1139
1140 ?>
1141
1142 <div class="notice notice-success notice-lh">
1143 <p>
1144 <strong><?php esc_html_e('☀️ Summer Sale!', 'head-meta-data'); ?></strong>
1145 <?php esc_html_e('Take 35% OFF any of our', 'head-meta-data'); ?>
1146 <a target="_blank" rel="noopener noreferrer" href="https://plugin-planet.com/"><?php esc_html_e('Pro WordPress plugins', 'head-meta-data'); ?></a>
1147 <?php esc_html_e('and', 'head-meta-data'); ?>
1148 <a target="_blank" rel="noopener noreferrer" href="https://books.perishablepress.com/"><?php esc_html_e('books', 'head-meta-data'); ?></a>.
1149 <?php esc_html_e('Apply code', 'head-meta-data'); ?> <code>SUMMER</code> <?php esc_html_e('at checkout. Sale ends 9/20/2026.', 'head-meta-data'); ?>
1150 <?php echo hmd_dismiss_notice_link(); ?>
1151 </p>
1152 </div>
1153
1154 <?php
1155
1156 }
1157
1158 }
1159
1160 }
1161 add_action('admin_notices', 'hmd_admin_notice');
1162
1163
1164 function hmd_dismiss_notice_activate() {
1165
1166 delete_option('head-meta-data-dismiss-notice');
1167
1168 }
1169 register_activation_hook(__FILE__, 'hmd_dismiss_notice_activate');
1170
1171
1172 function hmd_dismiss_notice_version() {
1173
1174 global $head_meta_data_version_wp;
1175
1176 $version_current = $head_meta_data_version_wp;
1177
1178 $version_previous = get_option('head-meta-data-dismiss-notice');
1179
1180 $version_previous = ($version_previous) ? $version_previous : $version_current;
1181
1182 if (version_compare($version_current, $version_previous, '>')) {
1183
1184 delete_option('head-meta-data-dismiss-notice');
1185
1186 }
1187
1188 }
1189 add_action('admin_init', 'hmd_dismiss_notice_version');
1190
1191
1192 function hmd_dismiss_notice_check() {
1193
1194 $check = get_option('head-meta-data-dismiss-notice');
1195
1196 return ($check) ? true : false;
1197
1198 }
1199
1200
1201 function hmd_dismiss_notice_save() {
1202
1203 if (isset($_GET['dismiss-notice-verify']) && wp_verify_nonce($_GET['dismiss-notice-verify'], 'hmd_dismiss_notice')) {
1204
1205 if (!current_user_can('manage_options')) exit;
1206
1207 global $head_meta_data_version_wp;
1208
1209 $result = update_option('head-meta-data-dismiss-notice', $head_meta_data_version_wp, false);
1210
1211 $result = $result ? 'true' : 'false';
1212
1213 $location = admin_url('options-general.php?page=head-meta-data&dismiss-notice='. $result);
1214
1215 wp_redirect($location);
1216
1217 exit;
1218
1219 }
1220
1221 }
1222 add_action('admin_init', 'hmd_dismiss_notice_save');
1223
1224
1225 function hmd_dismiss_notice_link() {
1226
1227 $nonce = wp_create_nonce('hmd_dismiss_notice');
1228
1229 $href = add_query_arg(array('dismiss-notice-verify' => $nonce), admin_url('options-general.php?page=head-meta-data'));
1230
1231 $label = esc_html__('Dismiss', 'head-meta-data');
1232
1233 return '<a class="hmd-dismiss-notice" href="'. esc_url($href) .'">'. esc_html($label) .'</a>';
1234
1235 }
1236
1237
1238 function hmd_check_date_expired() {
1239
1240 $expires = apply_filters('hmd_check_date_expired', '2026-09-20');
1241
1242 return (new DateTime() > new DateTime($expires)) ? true : false;
1243
1244 }