PluginProbe
Filter Everything — WordPress & WooCommerce Filters / trunk
Filter Everything — WordPress & WooCommerce Filters vtrunk
1.9.6 1.9.5 1.9.4 1.9.3 1.9.2.2 1.9.2.1 trunk 1.2.1 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.1 1.4.4 1.4.5 1.4.8 1.4.9 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 All 51 releases
filter-everything / src / Settings / Tabs / SeoTabTrait.php

SeoTabTrait.php in Filter Everything — WordPress & WooCommerce Filters trunk, at src/Settings/Tabs/SeoTabTrait.php

120 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace FilterEverything\Filter;
3
4 trait SeoTabTrait
5 {
6
7 public function render()
8 {
9 print('<form action="' . esc_url( admin_url( 'admin-post.php' ) ) . '" method="post" id="wpc-seo-settings">');
10
11 if ( ! empty( $_GET['settings-updated'] ) ) {
12 add_settings_error(
13 'wpc_seo_settings',
14 'wpc_seo_settings_updated',
15 __( 'SEO settings saved successfully' ),
16 'updated'
17 );
18 }
19
20 settings_errors();
21
22 echo '<input type="hidden" name="action" value="wpc_seo_settings">';
23 wp_nonce_field( 'wpc_seo_settings' );
24
25 $this->doSettingsSections($this->page);
26
27 if( apply_filters('wpc_settings_submit_button', true ) ){
28 submit_button();
29 }
30
31 print('</form>');
32 }
33
34 public function doSettingsSections( $page ) {
35 global $wp_settings_sections, $wp_settings_fields;
36
37 if ( ! isset( $wp_settings_sections[ $page ] ) ) {
38 return;
39 }
40
41
42 echo '<h2 class="nav-tab-wrapper">';
43 foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
44 if(!empty($section['before_section'])){
45 $css_classes = ($section['id'] === 'wpc_slugs') ? ' nav-tab-active' : '';
46 echo '<a href="#' . $section['id'] . '" class="nav-tab' . $css_classes . '">' . $section['before_section'] . '</a>';
47 }
48 }
49 if(method_exists($this, 'proSettingsLink')){
50 $link = $this->proSettingsLink();
51 if(!empty($link)){
52 foreach ($link as $key => $val) {
53 echo '<a href="'. admin_url($val['link']) .'" class="nav-tab wpc-pro-tab disabled wpc-pro-badge-text">'. $val['text'] .'</a>';
54 }
55 }
56 }
57 echo '</h2>';
58
59
60 foreach ( (array) $wp_settings_sections[ $page ] as $section ) {
61
62 if(!empty($section['before_section'])){
63 $class = '';
64 if( $section['id'] === 'wpc_slugs' ){
65 $class = ' active';
66 }
67 echo '<div id="' . $section['id'] . '" class="tab-content' .$class. '">';
68 do_action('wpc_before_seo_setting_section_title_' . $section['id'], $page);
69 do_action('wpc_before_sections_settings_fields', $this->page );
70 }
71
72 if ( !empty($section['title']) ) {
73 echo "<h3>". wp_kses( $section['title'], array( 'span' => array( 'class' => true ) )) ."</h3>\n";
74 }
75
76 if(!empty($section['before_section'])){
77 do_action('wpc_after_seo_setting_section_title_' . $section['id'], $page);
78 }
79
80 if ( $section['callback'] ) {
81 call_user_func( $section['callback'], $section );
82 }
83
84 $sortable = ( $section['id'] === 'wpc_slugs' ) ? ' wpc-sortable-table' : '';
85
86 echo '<table class="wpc-form-table form-table'.esc_attr($sortable).'" role="presentation">';
87 $this->doSettingsFields( $page, $section['id'] );
88 echo '</table>';
89
90 if(!empty($section['after_section'])){
91 do_action('wpc_after_sections_settings_fields_' . $section['id'], $this->page );
92 echo '</div>';
93 }
94 }
95 do_action('wpc_after_settings_fields', $page );
96 }
97
98 public function start_section_html($is_open = false) {
99 return $this->sectionName();
100 }
101
102 public function end_section_html() {
103 return 'true';
104 }
105
106 protected function addSectionSettingsWrapper($settings, $is_open = false)
107 {
108 $first_key = array_key_first($settings);
109 $last_key = array_key_last($settings);
110
111 if ($first_key !== $last_key) {
112 $settings[$first_key]['args'] = ['before_section' => $this->start_section_html($is_open)];
113 $settings[$last_key]['args'] = ['after_section' => $this->end_section_html()];
114 }
115 if ($first_key === $last_key) {
116 $settings[$first_key]['args'] = ['before_section' => $this->start_section_html($is_open), 'after_section' => $this->end_section_html()];
117 }
118 return $settings;
119 }
120 }