-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathclass.bcn_admin.php
830 lines (824 loc) · 36.4 KB
/
class.bcn_admin.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
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
<?php
/*
Copyright 2015-2025 John Havlik (email : [email protected])
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 2 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, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
//Do a PHP version check, require 5.6.0 or newer
if(version_compare(phpversion(), '5.6.0', '<'))
{
//Only purpose of this function is to echo out the PHP version error
function bcn_phpold()
{
printf('<div class="notice notice-error"><p>' . __('Your PHP version is too old, please upgrade to a newer version. Your version is %1$s, Breadcrumb NavXT requires %2$s', 'breadcrumb-navxt') . '</p></div>', phpversion(), '5.6.0');
}
//If we are in the admin, let's print a warning then return
if(is_admin())
{
add_action('admin_notices', 'bcn_phpold');
}
return;
}
//Include admin base class
if(!class_exists('\mtekk\adminKit\adminKit'))
{
require_once(dirname(__FILE__) . '/includes/adminKit/class-mtekk_adminkit.php');
}
use mtekk\adminKit\{adminKit, form, message, setting};
/**
* The administrative interface class
*
*/
class bcn_admin extends adminKit
{
const version = '7.4.1';
protected $full_name = 'Breadcrumb NavXT Settings';
protected $short_name = 'Breadcrumb NavXT';
protected $access_level = 'bcn_manage_options';
protected $identifier = 'breadcrumb-navxt';
protected $unique_prefix = 'bcn';
protected $plugin_basename = null;
protected $support_url = 'https://wordpress.org/support/plugin/breadcrumb-navxt/';
/**
* Administrative interface class default constructor
*
* @param array $opts The breadcrumb trail object's settings array
* @param string $basename The basename of the plugin
* @param array $settings The array of settings objects
*/
function __construct(array &$opts, $basename, array &$settings)
{
$this->plugin_basename = $basename;
$this->full_name = esc_html__('Breadcrumb NavXT Settings', 'breadcrumb-navxt');
$this->settings =& $settings;
$this->opt =& $opts;
//We're going to make sure we load the parent's constructor
parent::__construct();
}
function is_network_admin()
{
return false;
}
/**
* Loads opts array values into the local settings array
*
* @param array $opts The opts array
*/
function setting_merge($opts)
{
$unknown = array();
foreach($opts as $key => $value)
{
if(isset($this->settings[$key]) && $this->settings[$key] instanceof setting\setting)
{
$this->settings[$key]->set_value($this->settings[$key]->validate($value));
}
else if(isset($this->settings[$key]) && is_array($this->settings[$key]) && is_array($value))
{
foreach($value as $subkey => $subvalue)
{
if(isset($this->settings[$key][$subkey]) && $this->settings[$key][$subkey]instanceof setting\setting)
{
$this->settings[$key][$subkey]->set_value($this->settings[$key][$subkey]->validate($subvalue));
}
}
}
else
{
$unknown[] = $key;
}
}
//Add a message if we found some unknown settings while merging
if(count($unknown) > 0)
{
$this->messages[] = new message(
sprintf(__('Found %u unknown legacy settings: %s','breadcrumb-navxt'), count($unknown), implode(', ', $unknown)),
'warning',
true,
'bcn_unkonwn_legacy_settings');
}
}
/**
* admin initialization callback function
*
* is bound to wordpress action 'admin_init' on instantiation
*
* @since 3.2.0
* @return void
*/
function init()
{
//We're going to make sure we run the parent's version of this function as well
parent::init();
$this->setting_merge($this->opt);
}
/**
* Upgrades input options array, sets to $this->opt
*
* @param array $opts
* @param string $version the version of the passed in options
*/
function opts_upgrade($opts, $version)
{
//If our version is not the same as in the db, time to update
if(version_compare($version, $this::version, '<'))
{
require_once(dirname(__FILE__) . '/options_upgrade.php');
bcn_options_upgrade_handler($opts, $version, $this->opt);
}
//Merge in the defaults
$this->opt = adminKit::parse_args($opts, adminKit::settings_to_opts($this->settings));
}
/**
* Fills in the help tab contents
*
* @param WP_Screen $screen The screen to add the help tab items to
*/
function help_contents(\WP_Screen &$screen)
{
$general_tab = '<p>' . esc_html__('Tips for the settings are located below select options.', 'breadcrumb-navxt') .
'</p><h5>' . esc_html__('Resources', 'breadcrumb-navxt') . '</h5><ul><li>' .
'<a title="' . esc_attr__('Go to the Breadcrumb NavXT tag archive.', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/tag/breadcrumb-navxt">' . esc_html__('Tutorials and How Tos', 'breadcrumb-navxt') . '</a>: ' .
esc_html__("There are several guides, tutorials, and how tos available on the author's website.", 'breadcrumb-navxt') . '</li><li>' .
'<a title="' . esc_attr__('Go to the Breadcrumb NavXT online documentation', 'breadcrumb-navxt') . '" href="https://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/">' . esc_html__('Online Documentation', 'breadcrumb-navxt') . '</a>: '.
esc_html__('Check out the documentation for more indepth technical information.', 'breadcrumb-navxt') . '</li><li>' .
'<a title="' . esc_attr__('Go to the Breadcrumb NavXT support post for your version.', 'breadcrumb-navxt') . '" href="https://wordpress.org/support/plugin/breadcrumb-navxt/">' . esc_html__('Report a Bug', 'breadcrumb-navxt') . '</a>: ' .
esc_html__('If you think you have found a bug, please include your WordPress version and details on how to reproduce the bug.', 'breadcrumb-navxt') . '</li></ul>' .
'<h5>' . esc_html__('Giving Back', 'breadcrumb-navxt') . '</h5><ul><li>' .
'<a title="' . esc_attr__('Go to PayPal to give a donation to Breadcrumb NavXT.', 'breadcrumb-navxt') . '" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=FD5XEU783BR8U&lc=US&item_name=Breadcrumb%20NavXT%20Donation¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">' .
esc_html__('Donate', 'breadcrumb-navxt') . '</a>: ' .
esc_html__('Love Breadcrumb NavXT and want to help development? Consider buying the author a beer.', 'breadcrumb-navxt') . '</li><li>' .
'<a title="' . esc_attr__('Go to the Breadcrumb NavXT translation project.', 'breadcrumb-navxt') . '" href="https://translate.wordpress.org/projects/wp-plugins/breadcrumb-navxt">' . esc_html__('Translate', 'breadcrumb-navxt') . '</a>: ' .
esc_html__('Is your language not available? Visit the Breadcrumb NavXT translation project on WordPress.org to start translating.', 'breadcrumb-navxt') . '</li></ul>';
$screen->add_help_tab(
array(
'id' => $this->identifier . '-base',
'title' => __('General', 'breadcrumb-navxt'),
'content' => $general_tab
));
$quickstart_tab = '<p>' . esc_html__('For the settings on this page to take effect, you must either use the included Breadcrumb NavXT widget, or place either of the code sections below into your theme.', 'breadcrumb-navxt') .
'</p><h5>' . esc_html__('Breadcrumb trail with separators', 'breadcrumb-navxt') . '</h5><pre><code><div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . "
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div></code></pre>" .
'<h5>' . esc_html__('Breadcrumb trail in list form', 'breadcrumb-navxt').'</h5><pre><code><ol class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">'."
<?php if(function_exists('bcn_display_list'))
{
bcn_display_list();
}?>
</ol></code></pre>";
$screen->add_help_tab(
array(
'id' => $this->identifier . '-quick-start',
'title' => __('Quick Start', 'breadcrumb-navxt'),
'content' => $quickstart_tab
));
$styling_tab = '<p>' . esc_html__('Using the code from the Quick Start section above, the following CSS can be used as base for styling your breadcrumb trail.', 'breadcrumb-navxt') . '</p>' .
'<pre><code>.breadcrumbs
{
font-size: 1.1em;
color: #fff;
margin: 30px 0 0 10px;
position: relative;
float: left;
}</code></pre>';
$screen->add_help_tab(
array(
'id' => $this->identifier . '-styling',
'title' => __('Styling', 'breadcrumb-navxt'),
'content' => $styling_tab
));
$screen->add_help_tab(
array(
'id' => $this->identifier . '-import-export-reset',
'title' => __('Import/Export/Reset', 'breadcrumb-navxt'),
'content' => $this->import_form()
));
}
/**
* enqueue's the tab style sheet on the settings page
*/
function admin_styles()
{
wp_enqueue_style('mtekk_adminkit_tabs');
}
/**
* enqueue's the tab js and translation js on the settings page
*/
function admin_scripts()
{
//Enqueue ui-tabs
wp_enqueue_script('jquery-ui-tabs');
//Enqueue the admin tabs javascript
wp_enqueue_script('mtekk_adminkit_tabs');
//Load the translations for the tabs
wp_localize_script('mtekk_adminkit_tabs', 'objectL10n', array(
'mtad_uid' => 'bcn_admin',
'mtad_import' => __('Import', 'breadcrumb-navxt'),
'mtad_export' => __('Export', 'breadcrumb-navxt'),
'mtad_reset' => __('Reset', 'breadcrumb-navxt'),
));
//Enqueue the admin enable/disable groups javascript
wp_enqueue_script('mtekk_adminkit_engroups');
}
/**
* A message function that checks for the BCN_SETTINGS_* define statement
*/
function multisite_settings_warn()
{
if(is_multisite())
{
if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL)
{
}
else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK)
{
$this->messages[] = new message(esc_html__('Warning: Your network settings will override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_nsiteoveride');
}
else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL)
{
$this->messages[] = new message(esc_html__('Warning: Your network settings may override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_isitemayoveride');
}
else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)
{
$this->messages[] = new message(esc_html__('Warning: Your network settings may override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_nsitemayoveride');
}
//Fall through if no settings mode was set
else
{
$this->messages[] = new message(esc_html__('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_nosetting');
}
}
}
/**
* A message function that checks for deprecated settings that are set and warns the user
*/
function deprecated_settings_warn()
{
//We're deprecating the limit title length setting, let the user know the new method of accomplishing this
if(isset($this->settings['blimit_title']) && $this->settings['blimit_title']->get_value())
{
$this->messages[] = new message(
sprintf(
esc_html__('Error: The deprecated setting "Title Length" (see Miscellaneous > Deprecated) has no effect in this version Breadcrumb NavXT. Please %1$suse CSS instead%2$s.', 'breadcrumb-navxt'),
'<a title="' . __('Go to the guide on trimming breadcrumb title lengths with CSS', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/">', '</a>'),
'error');
}
foreach($this->settings as $key => $setting)
{
if($key[0] == "H" && substr_count($key, '_template') >= 1)
{
$deprecated_tags = array();
$replacement_tags = array();
//Deprecated ftitle check
if(substr_count($setting->get_value(), '%ftitle%') >= 1)
{
$deprecated_tags[] = '%ftitle%';
$replacement_tags[] = '%title%';
}
//Deprecated fhtitle check
if(substr_count($setting->get_value(), '%fhtitle%') >= 1)
{
$deprecated_tags[] = '%fhtitle%';
$replacement_tags[] = '%htitle%';
}
if(count($deprecated_tags) > 0)
{
$setting_link = sprintf('<a href="#%1$s">%2$s</a>', $key, $setting->get_title());
$this->messages[] = new message(
sprintf(
esc_html__('Error: The deprecated template tag %1$s found in setting %3$s. Please use %2$s instead.', 'breadcrumb-navxt'),
implode(' and ', $deprecated_tags),
implode(' and ', $replacement_tags),
$setting_link),
'error');
}
}
}
}
/**
* A message function that checks for post types added after the settings defaults were established
*/
function unknown_custom_types_warn()
{
foreach($GLOBALS['wp_post_types'] as $post_type)
{
if(!($post_type instanceof WP_Post_Type))
{
$this->messages[] = new message(
sprintf(
esc_html__('Error: WP_Post_Types global contains non WP_Post_Type object. Debug information: %1$s', 'breadcrumb-navxt'),
var_export($post_type, true)),
'error',
true,
'badtypeWP_Post_Types');
continue;
}
//If we haven't seen this post type before, warn the user
if(!isset($this->settings['Hpost_' . $post_type->name . '_template']))
{
$this->messages[] = new message(
sprintf(
esc_html__('Warning: The post type %1$s (%2$s) was registered after the Breadcrumb NavXT default settings. It will not show up in the settings.', 'breadcrumb-navxt'),
$post_type->labels->singular_name,
$post_type->name),
'warning',
true,
$post_type->name);
}
}
foreach($GLOBALS['wp_taxonomies'] as $taxonomy)
{
if(!($taxonomy instanceof WP_Taxonomy))
{
//If we haven't seen this taxonomy before, warn the user
$this->messages[] = new message(
sprintf(
esc_html__('Error: WP_Taxonomies global contains non WP_Taxonomy object. Debug information: %1$s', 'breadcrumb-navxt'),
var_export($taxonomy, true)),
'error',
true,
'badtypeWP_Taxonomies');
continue;
}
if(!isset($this->settings['Htax_' . $taxonomy->name . '_template']))
{
//If we haven't seen this taxonomy before, warn the user
$this->messages[] = new message(
sprintf(
esc_html__('Warning: The taxonomy %1$s (%2$s) was registered after the Breadcrumb NavXT default settings. It will not show up in the settings.', 'breadcrumb-navxt'),
$taxonomy->label,
$taxonomy->name),
'warning',
true,
$taxonomy->name);
}
}
}
/**
* Function checks the current site to see if the blog options should be disabled
*
* @return boool Whether or not the blog options should be disabled
*/
function maybe_disable_blog_options()
{
return (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1);
}
/**
* Function checks the current site to see if the mainsite options should be disabled
*
* @return bool Whether or not the mainsite options should be disabled
*/
function maybe_disable_mainsite_options()
{
return !is_multisite();
}
/**
* The administrative page for Breadcrumb NavXT
*/
function admin_page()
{
global $wp_taxonomies, $wp_post_types;
$this->security();
//Do a check on deprecated settings
$this->deprecated_settings_warn();
//Do a check for unknown CPTs and Taxnomies
$this->unknown_custom_types_warn();
//Do a check for multisite settings mode
$this->multisite_settings_warn();
do_action($this->unique_prefix . '_settings_pre_messages', $this->settings);
//Display our messages
$this->messages();
//Grab the network options, if multisite
$network_opts = array();
$local_opts = array();
$overriden = array();
$overriden_style = array();
if(is_multisite() && !$this->is_network_admin())
{
$network_opts = get_site_option('bcn_options');
$local_opts = get_option('bcn_options');
}
foreach($this->settings as $key => $setting)
{
if(isset($network_opts[$key]) && ((defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) || (defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)))
{
$overriden[$key] = ' ' . __('Value has been set via network wide setting.', 'breadcrumb-navxt');
$overriden_style[$key] = ' disabled';
}
else
{
$overriden[$key] = '';
$overriden_style[$key] = '';
}
}
?>
<div class="wrap"><h1><?php echo $this->full_name; ?></h1>
<?php
//We exit after the version check if there is an action the user needs to take before saving settings
if(!$this->version_check($this->get_option($this->unique_prefix . '_version')))
{
return;
}
?>
<form action="<?php echo $this->admin_url(); ?>" method="post" id="bcn_admin-options">
<?php settings_fields('bcn_options');?>
<div id="hasadmintabs">
<fieldset id="general" class="bcn_options">
<legend class="screen-reader-text" data-title="<?php _e( 'A collection of settings most likely to be modified are located under this tab.', 'breadcrumb-navxt' );?>"><?php _e( 'General', 'breadcrumb-navxt' ); ?></legend>
<h2><?php _e('General', 'breadcrumb-navxt'); ?></h2>
<table class="form-table">
<?php
$this->form->textbox($this->settings['hseparator'], '2', false, __('Placed in between each breadcrumb.', 'breadcrumb-navxt') . $overriden['hseparator'], $overriden_style['hseparator']);
do_action($this->unique_prefix . '_settings_general', $this->settings);
?>
</table>
<h2><?php _e('Current Item', 'breadcrumb-navxt'); ?></h2>
<table class="form-table adminkit-enset-top">
<?php
$this->form->input_check(
$this->settings['bcurrent_item_linked'],
__('Yes', 'breadcrumb-navxt'),
false,
$overriden['bcurrent_item_linked'],
$overriden_style['bcurrent_item_linked']);
$this->form->input_check(
$this->settings['bpaged_display'],
__('Place the page number breadcrumb in the trail.', 'breadcrumb-navxt'),
false,
__('Indicates that the user is on a page other than the first of a paginated archive or post.', 'breadcrumb-navxt') . $overriden['bpaged_display'],
'adminkit-enset-ctrl adminkit-enset' . $overriden_style['bpaged_display']);
$this->form->textbox(
$this->settings['Hpaged_template'],
'4',
false,
__('The template for paged breadcrumbs.', 'breadcrumb-navxt') . $overriden['Hpaged_template'],
'adminkit-enset' . $overriden_style['Hpaged_template']);
do_action($this->unique_prefix . '_settings_current_item', $this->settings);
?>
</table>
<h2><?php _e('Home Breadcrumb', 'breadcrumb-navxt'); ?></h2>
<table class="form-table adminkit-enset-top">
<?php
$this->form->input_check(
$this->settings['bhome_display'],
__('Place the home breadcrumb in the trail.', 'breadcrumb-navxt'),
false,
$overriden['bhome_display'],
'adminkit-enset-ctrl adminkit-enset' . $overriden_style['bhome_display']);
$this->form->textbox(
$this->settings['Hhome_template'],
'6',
false,
__('The template for the home breadcrumb.', 'breadcrumb-navxt') . $overriden['Hhome_template'],
'adminkit-enset' . $overriden_style['Hhome_template']);
$this->form->textbox(
$this->settings['Hhome_template_no_anchor'],
'4',
false,
__('The template for the home breadcrumb, used when the breadcrumb is not linked.', 'breadcrumb-navxt') . $overriden['Hhome_template_no_anchor'],
'adminkit-enset' . $overriden_style['Hhome_template_no_anchor']);
do_action($this->unique_prefix . '_settings_home', $this->settings);
?>
</table>
<h2><?php _e('Blog Breadcrumb', 'breadcrumb-navxt'); ?></h2>
<table class="form-table adminkit-enset-top">
<?php
$this->form->input_check(
$this->settings['bblog_display'],
__('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt'),
$this->maybe_disable_blog_options(),
$overriden['bblog_display'],
'adminkit-enset-ctrl adminkit-enset' . $overriden_style['bblog_display']);
do_action($this->unique_prefix . '_settings_blog', $this->settings);
?>
</table>
<h2><?php _e('Mainsite Breadcrumb', 'breadcrumb-navxt'); ?></h2>
<table class="form-table adminkit-enset-top">
<?php
$this->form->input_check(
$this->settings['bmainsite_display'],
__('Place the main site home breadcrumb in the trail in an multisite setup.', 'breadcrumb-navxt'),
$this->maybe_disable_mainsite_options(),
$overriden['bmainsite_display'],
'adminkit-enset-ctrl adminkit-enset' . $overriden_style['bmainsite_display']);
$this->form->textbox(
$this->settings['Hmainsite_template'],
'6',
$this->maybe_disable_mainsite_options(),
__('The template for the main site home breadcrumb, used only in multisite environments.', 'breadcrumb-navxt') . $overriden['Hmainsite_template'],
'adminkit-enset' . $overriden_style['Hmainsite_template']);
$this->form->textbox(
$this->settings['Hmainsite_template_no_anchor'],
'4',
$this->maybe_disable_mainsite_options(),
__('The template for the main site home breadcrumb, used only in multisite environments and when the breadcrumb is not linked.', 'breadcrumb-navxt') . $overriden['Hmainsite_template_no_anchor'],
'adminkit-enset' . $overriden_style['Hmainsite_template_no_anchor']);
do_action($this->unique_prefix . '_settings_mainsite', $this->settings);
?>
</table>
<?php do_action($this->unique_prefix . '_after_settings_tab_general', $this->settings); ?>
</fieldset>
<fieldset id="post" class="bcn_options">
<legend class="screen-reader-text" data-title="<?php _e( 'The settings for all post types (Posts, Pages, and Custom Post Types) are located under this tab.', 'breadcrumb-navxt' );?>"><?php _e( 'Post Types', 'breadcrumb-navxt' ); ?></legend>
<?php
//Loop through all of the post types in the array
foreach($wp_post_types as $post_type)
{
//Check for bad post type objects, for non-public CPTs, and if the CPT wasn't known when defaults were generated
if(!($post_type instanceof WP_Post_Type) || !apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name) || !isset($this->settings['Hpost_' . $post_type->name . '_template']))
{
continue;
}
$singular_name_lc = mb_strtolower($post_type->labels->singular_name, 'UTF-8');
?>
<h2><?php echo $post_type->labels->singular_name; ?></h2>
<table class="form-table adminkit-enset-top">
<?php
$this->form->textbox(
$this->settings['Hpost_' . $post_type->name . '_template'],
'6',
false,
sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $singular_name_lc) . $overriden['Hpost_' . $post_type->name . '_template'],
$overriden_style['Hpost_' . $post_type->name . '_template']);
$this->form->textbox(
$this->settings['Hpost_' . $post_type->name . '_template_no_anchor'],
'4',
false,
sprintf(__('The template for %s breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt'), $singular_name_lc) . $overriden['Hpost_' . $post_type->name . '_template_no_anchor'],
$overriden_style['Hpost_' . $post_type->name . '_template_no_anchor']);
if(!in_array($post_type->name, array('page', 'post')))
{
$optid = form::get_valid_id('apost_' . $post_type->name . '_root');
?>
<tr valign="top">
<th scope="row">
<label for="<?php echo $optid;?>"><?php printf(esc_html__('%s Root Page', 'breadcrumb-navxt'), $post_type->labels->singular_name);?></label>
</th>
<td>
<?php wp_dropdown_pages( apply_filters(
'bcn_admin_post_root_args',
array('name' => $this->unique_prefix . '_options[apost_' . $post_type->name . '_root]',
'id' => $optid,
'echo' => 1,
'show_option_none' => __( '— Select —' ),
'option_none_value' => '0',
'selected' => $this->settings['apost_' . $post_type->name . '_root']->get_value(),
'class' => $overriden_style['apost_' . $post_type->name . '_root']),
$post_type->name
));
if(isset($overriden['apost_' . $post_type->name . '_root']) && $overriden['apost_' . $post_type->name . '_root'] !== '')
{
printf('<p class="description">%s</p>', $overriden['apost_' . $post_type->name . '_root']);
}
?>
</td>
</tr>
<?php
$this->form->input_check(
$this->settings['bpost_' . $post_type->name . '_archive_display'],
sprintf(__('Show the breadcrumb for the %s post type archives in the breadcrumb trail.', 'breadcrumb-navxt'), $singular_name_lc),
!$post_type->has_archive,
$overriden['bpost_' . $post_type->name . '_archive_display'],
$overriden_style['bpost_' . $post_type->name . '_archive_display']);
}
if(in_array($post_type->name, array('page')))
{
$this->form->input_hidden($this->settings['bpost_' . $post_type->name . '_hierarchy_display']);
$this->form->input_hidden($this->settings['bpost_' . $post_type->name . '_hierarchy_parent_first']);
$this->form->input_hidden($this->settings['bpost_' . $post_type->name . '_taxonomy_referer']);
}
else
{
$this->form->input_check(
$this->settings['bpost_' . $post_type->name . '_hierarchy_display'],
sprintf(__('Show the hierarchy (specified below) leading to a %s in the breadcrumb trail.', 'breadcrumb-navxt'), $singular_name_lc),
false,
$overriden['bpost_' . $post_type->name . '_hierarchy_display'],
'adminkit-enset-ctrl adminkit-enset' . $overriden_style['bpost_' . $post_type->name . '_hierarchy_display']);
$this->form->input_check(
$this->settings['bpost_' . $post_type->name . '_hierarchy_parent_first'],
sprintf(__('Use the parent of the %s as the primary hierarchy, falling back to the hierarchy selected below when the parent hierarchy is exhausted.', 'breadcrumb-navxt'), $singular_name_lc),
false,
$overriden['bpost_' . $post_type->name . '_hierarchy_parent_first'],
'adminkit-enset' . $overriden_style['bpost_' . $post_type->name . '_hierarchy_parent_first']);
$this->form->input_check(
$this->settings['bpost_' . $post_type->name . '_taxonomy_referer'],
__('Allow the referring page to influence the taxonomy selected for the hierarchy.', 'breadcrumb-navxt'),
false,
$overriden['bpost_' . $post_type->name . '_taxonomy_referer'],
'adminkit-enset' . $overriden_style['bpost_' . $post_type->name . '_taxonomy_referer']);
?>
<tr valign="top">
<th scope="row">
<?php printf(__('%s Hierarchy', 'breadcrumb-navxt'), $post_type->labels->singular_name); ?>
</th>
<td>
<?php
//We use the value 'page' but really, this will follow the parent post hierarchy
$this->form->input_radio($this->settings['Epost_' . $post_type->name . '_hierarchy_type'], 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset' . $overriden_style['Epost_' . $post_type->name . '_hierarchy_type']);
$this->form->input_radio($this->settings['Epost_' . $post_type->name . '_hierarchy_type'], 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset' . $overriden_style['Epost_' . $post_type->name . '_hierarchy_type']);
//Loop through all of the taxonomies in the array
foreach($wp_taxonomies as $taxonomy)
{
//Check for non-public taxonomies
if(!($taxonomy instanceof WP_Taxonomy) || !apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, $post_type->name))
{
continue;
}
//We only want custom taxonomies
if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type))
{
$this->form->input_radio($this->settings['Epost_' . $post_type->name . '_hierarchy_type'], $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset' . $overriden_style['Epost_' . $post_type->name . '_hierarchy_type']);
}
}
?>
<p class="description">
<?php
if($post_type->hierarchical)
{
esc_html_e('The hierarchy which the breadcrumb trail will show.', 'breadcrumb-navxt');
}
else
{
esc_html_e('The hierarchy which the breadcrumb trail will show. Note that the "Post Parent" option may require an additional plugin to behave as expected since this is a non-hierarchical post type.', 'breadcrumb-navxt');
}
echo $overriden['Epost_' . $post_type->name . '_hierarchy_type'];
?>
</p>
</td>
</tr>
<?php
}
?>
</table>
<?php
}
do_action($this->unique_prefix . '_after_settings_tab_post', $this->settings);
?>
</fieldset>
<fieldset id="tax" class="bcn_options alttab">
<legend class="screen-reader-text" data-title="<?php _e( 'The settings for all taxonomies (including Categories, Tags, and custom taxonomies) are located under this tab.', 'breadcrumb-navxt' );?>"><?php _e( 'Taxonomies', 'breadcrumb-navxt' ); ?></legend>
<?php
//Loop through all of the taxonomies in the array
foreach($wp_taxonomies as $taxonomy)
{
//Check for non-public taxonomies and if the taxonomy wasn't known when defaults were generated
if(!($taxonomy instanceof WP_Taxonomy) || !apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, null) || !isset($this->settings['Htax_' . $taxonomy->name . '_template']))
{
continue;
}
$label_lc = mb_strtolower($taxonomy->label, 'UTF-8');
?>
<h2><?php echo mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'); ?></h2>
<table class="form-table">
<?php
$this->form->textbox(
$this->settings['Htax_' . $taxonomy->name . '_template'],
'6',
false,
sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt') . $overriden['Htax_' . $taxonomy->name . '_template'], $label_lc),
$overriden_style['Htax_' . $taxonomy->name . '_template']);
$this->form->textbox(
$this->settings['Htax_' . $taxonomy->name . '_template_no_anchor'],
'4',
false,
sprintf(__('The template for %s breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt') . $overriden['Htax_' . $taxonomy->name . '_template_no_anchor'], $label_lc),
$overriden_style['Htax_' . $taxonomy->name . '_template_no_anchor']);
?>
</table>
<?php
}
do_action($this->unique_prefix . '_after_settings_tab_taxonomy', $this->settings); ?>
</fieldset>
<fieldset id="miscellaneous" class="bcn_options">
<legend class="screen-reader-text" data-title="<?php _e( 'The settings for author and date archives, searches, and 404 pages are located under this tab.', 'breadcrumb-navxt' );?>"><?php _e( 'Miscellaneous', 'breadcrumb-navxt' ); ?></legend>
<h2><?php _e('Author Archives', 'breadcrumb-navxt'); ?></h2>
<table class="form-table">
<?php
$this->form->textbox(
$this->settings['Hauthor_template'],
'6',
false,
__('The template for author breadcrumbs.', 'breadcrumb-navxt') . $overriden['Hauthor_template'],
$overriden_style['Hauthor_template']);
$this->form->textbox(
$this->settings['Hauthor_template_no_anchor'],
'4',
false,
__('The template for author breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt') . $overriden['Hauthor_template_no_anchor'],
$overriden_style['Hauthor_template_no_anchor']);
$this->form->input_select(
$this->settings['Eauthor_name'],
$this->settings['Eauthor_name']->get_allowed_vals(),
false,
__('display_name uses the name specified in "Display name publicly as" under the user profile the others correspond to options in the user profile.', 'breadcrumb-navxt') . $overriden['Eauthor_name'],
$overriden_style['Eauthor_name']);
$optid = form::get_valid_id('aauthor_root');
?>
<tr valign="top">
<th scope="row">
<label for="<?php echo $optid;?>"><?php esc_html_e('Author Root Page', 'breadcrumb-navxt');?></label>
</th>
<td>
<?php wp_dropdown_pages(array(
'name' => $this->unique_prefix . '_options[aauthor_root]',
'id' => $optid,
'echo' => 1,
'show_option_none' => __( '— Select —' ),
'option_none_value' => '0',
'selected' => $this->settings['aauthor_root']->get_value(),
'class' => $overriden_style['aauthor_root']
));
if(isset($overriden['aauthor_root']) && $overriden['aauthor_root'] !== '')
{
printf('<p class="description">%s</p>', $overriden['aauthor_root']);
}
?>
</td>
</tr>
</table>
<h2><?php _e('Miscellaneous', 'breadcrumb-navxt'); ?></h2>
<table class="form-table">
<?php
$this->form->textbox(
$this->settings['Hdate_template'],
'6',
false,
__('The template for date breadcrumbs.', 'breadcrumb-navxt') . $overriden['Hdate_template'],
$overriden_style['Hdate_template']);
$this->form->textbox(
$this->settings['Hdate_template_no_anchor'],
'4',
false,
__('The template for date breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt') . $overriden['Hdate_template_no_anchor'],
$overriden_style['Hdate_template_no_anchor']);
$this->form->textbox(
$this->settings['Hsearch_template'],
'6',
false,
__('The anchor template for search breadcrumbs, used only when the search results span several pages.', 'breadcrumb-navxt') . $overriden['Hsearch_template'],
$overriden_style['Hsearch_template']);
$this->form->textbox(
$this->settings['Hsearch_template_no_anchor'],
'4',
false,
__('The anchor template for search breadcrumbs, used only when the search results span several pages and the breadcrumb is not linked.', 'breadcrumb-navxt') . $overriden['Hsearch_template_no_anchor'],
$overriden_style['Hsearch_template_no_anchor']);
$this->form->input_text(
$this->settings['S404_title'],
'regular-text' . $overriden_style['S404_title'],
false,
$overriden['S404_title']);
$this->form->textbox(
$this->settings['H404_template'],
'4',
false,
__('The template for 404 breadcrumbs.', 'breadcrumb-navxt') . $overriden['H404_template'],
$overriden_style['H404_template']);
?>
</table>
<h2><?php _e('Deprecated', 'breadcrumb-navxt'); ?></h2>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php esc_html_e('Title Length', 'breadcrumb-navxt'); ?>
</th>
<td>
<label>
<input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" class="disabled" <?php checked(true, $this->settings['blimit_title']->get_value()); ?> />
<?php printf(esc_html__('Limit the length of the breadcrumb title. (Deprecated, %suse CSS instead%s)', 'breadcrumb-navxt'), '<a title="' . esc_attr__('Go to the guide on trimming breadcrumb title lengths with CSS', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/">', '</a>');?>
</label><br />
<ul>
<li>
<label for="amax_title_length">
<?php esc_html_e('Max Title Length: ','breadcrumb-navxt');?>
<input type="number" name="bcn_options[amax_title_length]" id="amax_title_length" min="1" step="1" value="<?php echo esc_html($this->settings['amax_title_length']->get_value(), ENT_COMPAT, 'UTF-8'); ?>" class="small-text disabled" />
</label>
</li>
</ul>
</td>
</tr>
</table>
<?php do_action($this->unique_prefix . '_after_settings_tab_miscellaneous', $this->settings); ?>
</fieldset>
<?php do_action($this->unique_prefix . '_after_settings_tabs', $this->settings); ?>
</div>
<p class="submit"><input type="submit" class="button-primary" name="bcn_admin_options" value="<?php esc_attr_e('Save Changes') ?>" /></p>
</form>
</div>
<?php
}
}