SEOPress - Version 2.7.1

Version Description

  • NEW Add seopress_titles_title hook to filter title tag
  • NEW Add seopress_titles_desc hook to filter meta description
  • NEW Add seopress_titles_robots hook to filter meta robots (complete tag)
  • NEW Add seopress_titles_noindex hook to filter meta robots noindex value
  • NEW Add seopress_titles_nofollow hook to filter meta robots nofollow value
  • NEW Add seopress_titles_nosnippet hook to filter meta robots nosnippet value
  • NEW Add seopress_titles_noarchive hook to filter meta robots noarchive value
  • NEW Add seopress_titles_noodp hook to filter meta robots noodp value
  • NEW Add seopress_titles_noimageindex hook to filter meta google noimageindex
  • NEW Add seopress_ga_dashboard_widget filter to remove Google Analytics Widget in Dashboard (PRO Only, feature requested by @wpchannel)
  • INFO "Discourage search engines from indexing this site" option (Settings > Reading), is not impacting anymore Titles & metas in frontend
  • INFO Improve Post type title in HTML Sitemap (suggested by @mickaelgris)
  • INFO Autoredirect sitemap.xml to sitemaps.xml
  • FIX Export redirections CSV file
  • FIX backslashes in metas
  • FIX Google Snippet Preview
Download this release

Release Info

Developer rainbowgeek
Plugin Icon 128x128 SEOPress
Version 2.7.1
Comparing to
See all releases

Code changes from version 2.7 to 2.7.1

inc/admin/admin.php CHANGED
@@ -286,13 +286,7 @@ class seopress_options
286
}
287
?>
288
<form method="post" action="<?php echo admin_url('options.php'); ?>" class="seopress-option">
289
- <?php
290
- if (get_option('blog_public') =='0') {
291
- echo '<div class="error notice is-dismissable">';
292
- echo '<p>'. __('Discourage search engines from indexing this site is <strong>ON!</strong> None of the following settings will be applied.','wp-seopress');
293
- echo ' <a href="'.admin_url("options-reading.php").'">'.__('Change this settings','wp-seopress').'</a></p>';
294
- echo '</div>';
295
- }
296
global $wp_version, $title;
297
$current_tab = '';
298
$tag = version_compare( $wp_version, '4.4' ) >= 0 ? 'h1' : 'h2';
286
}
287
?>
288
<form method="post" action="<?php echo admin_url('options.php'); ?>" class="seopress-option">
289
+ <?php
290
global $wp_version, $title;
291
$current_tab = '';
292
$tag = version_compare( $wp_version, '4.4' ) >= 0 ? 'h1' : 'h2';
inc/admin/ajax.php CHANGED
@@ -53,7 +53,7 @@ function seopress_do_real_preview() {
53
$list = $dom->getElementsByTagName("title");
54
if ($list->length > 0) {
55
$title = $list->item(0)->textContent;
56
- $data['title'] = $title;
57
}
58
59
//Meta desc
@@ -61,7 +61,7 @@ function seopress_do_real_preview() {
61
$meta_description = $xpath->query('//meta[@name="description"]/@content');
62
63
foreach ($meta_description as $key=>$mdesc) {
64
- $data['meta_desc'] = $mdesc->nodeValue;
65
}
66
}
67
}
53
$list = $dom->getElementsByTagName("title");
54
if ($list->length > 0) {
55
$title = $list->item(0)->textContent;
56
+ $data['title'] = esc_attr(stripslashes_deep(wp_filter_nohtml_kses($title)));
57
}
58
59
//Meta desc
61
$meta_description = $xpath->query('//meta[@name="description"]/@content');
62
63
foreach ($meta_description as $key=>$mdesc) {
64
+ $data['meta_desc'] = esc_attr(stripslashes_deep(wp_filter_nohtml_kses($mdesc->nodeValue)));
65
}
66
}
67
}
inc/functions/options-import-export.php CHANGED
@@ -137,11 +137,11 @@ function seopress_export_redirections_settings() {
137
$seopress_redirects_query->the_post();
138
$redirects_html .= get_the_title();
139
$redirects_html .= ';';
140
- $redirects_html .= get_post_meta($post->ID,'_seopress_redirections_enabled',true);
141
$redirects_html .= ';';
142
- $redirects_html .= get_post_meta($post->ID,'_seopress_redirections_type',true);
143
$redirects_html .= ';';
144
- $redirects_html .= get_post_meta($post->ID,'_seopress_redirections_value',true);
145
$redirects_html .= ';';
146
$redirects_html .= "\n";
147
}
137
$seopress_redirects_query->the_post();
138
$redirects_html .= get_the_title();
139
$redirects_html .= ';';
140
+ $redirects_html .= get_post_meta(get_the_ID(),'_seopress_redirections_enabled',true);
141
$redirects_html .= ';';
142
+ $redirects_html .= get_post_meta(get_the_ID(),'_seopress_redirections_type',true);
143
$redirects_html .= ';';
144
+ $redirects_html .= get_post_meta(get_the_ID(),'_seopress_redirections_value',true);
145
$redirects_html .= ';';
146
$redirects_html .= "\n";
147
}
inc/functions/options-sitemap.php CHANGED
@@ -69,7 +69,7 @@ if (seopress_xml_sitemap_html_enable_option() =='1') {
69
$content .= '<div class="wrap-html-sitemap">';
70
foreach (seopress_xml_sitemap_post_types_list_option() as $cpt_key => $cpt_value) {
71
$obj = get_post_type_object( $cpt_key );
72
- $content .= '<h2>'.$obj->labels->singular_name.'</h2>';
73
foreach ($cpt_value as $_cpt_key => $_cpt_value) {
74
if($_cpt_value =='1') {
75
$args = array( 'posts_per_page' => 1000, 'order'=> 'DESC', 'orderby' => 'date', 'post_type' => $cpt_key, 'post_status' => 'publish', 'meta_key' => '_seopress_robots_index', 'meta_value' => 'yes', 'meta_compare' => 'NOT EXISTS', 'fields' => 'ids', 'exclude' => $seopress_xml_sitemap_html_exclude_option );
69
$content .= '<div class="wrap-html-sitemap">';
70
foreach (seopress_xml_sitemap_post_types_list_option() as $cpt_key => $cpt_value) {
71
$obj = get_post_type_object( $cpt_key );
72
+ $content .= '<h2>'.$obj->labels->name.'</h2>';
73
foreach ($cpt_value as $_cpt_key => $_cpt_value) {
74
if($_cpt_value =='1') {
75
$args = array( 'posts_per_page' => 1000, 'order'=> 'DESC', 'orderby' => 'date', 'post_type' => $cpt_key, 'post_status' => 'publish', 'meta_key' => '_seopress_robots_index', 'meta_value' => 'yes', 'meta_compare' => 'NOT EXISTS', 'fields' => 'ids', 'exclude' => $seopress_xml_sitemap_html_exclude_option );
inc/functions/options-social.php CHANGED
@@ -488,7 +488,7 @@ function seopress_social_fb_desc_hook() {
488
echo '<meta property="og:description" content="'.seopress_social_fb_desc_term_option().'" />';
489
echo "\n";
490
} elseif (term_description() !='') {
491
- echo '<meta property="og:description" content="'.wp_filter_nohtml_kses(term_description()).' - '.get_bloginfo('name').'" />';
492
echo "\n";
493
}
494
} elseif (is_singular() && seopress_social_facebook_og_option() =='1' && seopress_social_fb_desc_post_option() !='') {
@@ -498,7 +498,7 @@ function seopress_social_fb_desc_hook() {
498
echo '<meta property="og:description" content="'.seopress_titles_the_description_content().'" />';
499
echo "\n";
500
} elseif (seopress_social_facebook_og_option() =='1' && get_the_excerpt() !='') {
501
- echo '<meta property="og:description" content="'.wp_trim_words(esc_attr(wp_filter_nohtml_kses(get_the_excerpt()), 30)).'" />';
502
echo "\n";
503
}
504
}
@@ -822,7 +822,7 @@ function seopress_social_twitter_desc_hook() {
822
echo '<meta name="twitter:description" content="'.seopress_social_fb_desc_term_option().'" />';
823
echo "\n";
824
} elseif (term_description() !='') {
825
- echo '<meta name="twitter:description" content="'.wp_filter_nohtml_kses(term_description()).' - '.get_bloginfo('name').'" />';
826
echo "\n";
827
}
828
} elseif (is_singular() && seopress_social_facebook_og_option() =='1' && seopress_social_fb_desc_post_option() !='') {
@@ -833,7 +833,7 @@ function seopress_social_twitter_desc_hook() {
833
echo "\n";
834
} elseif (seopress_social_facebook_og_option() =='1' && get_the_excerpt() !='') {
835
setup_postdata( $post );
836
- echo '<meta name="twitter:description" content="'.wp_trim_words(esc_attr(wp_filter_nohtml_kses(get_the_excerpt()), 30)).'" />';
837
echo "\n";
838
}
839
} else {
@@ -850,7 +850,7 @@ function seopress_social_twitter_desc_hook() {
850
echo '<meta name="twitter:description" content="'.seopress_social_twitter_desc_term_option().'" />';
851
echo "\n";
852
} elseif (term_description() !='') {
853
- echo '<meta name="twitter:description" content="'.wp_filter_nohtml_kses(term_description()).' - '.get_bloginfo('name').'" />';
854
echo "\n";
855
}
856
} elseif (is_singular() && seopress_social_twitter_card_option() =='1' && seopress_social_twitter_desc_post_option() !='') {
@@ -861,7 +861,7 @@ function seopress_social_twitter_desc_hook() {
861
echo "\n";
862
} elseif (seopress_social_twitter_card_option() =='1' && get_the_excerpt() !='') {
863
setup_postdata( $post );
864
- echo '<meta name="twitter:description" content="'.wp_trim_words(esc_attr(wp_filter_nohtml_kses(get_the_excerpt()), 30)).'" />';
865
echo "\n";
866
}
867
}
488
echo '<meta property="og:description" content="'.seopress_social_fb_desc_term_option().'" />';
489
echo "\n";
490
} elseif (term_description() !='') {
491
+ echo '<meta property="og:description" content="'.stripslashes_deep(wp_filter_nohtml_kses(term_description())).' - '.get_bloginfo('name').'" />';
492
echo "\n";
493
}
494
} elseif (is_singular() && seopress_social_facebook_og_option() =='1' && seopress_social_fb_desc_post_option() !='') {
498
echo '<meta property="og:description" content="'.seopress_titles_the_description_content().'" />';
499
echo "\n";
500
} elseif (seopress_social_facebook_og_option() =='1' && get_the_excerpt() !='') {
501
+ echo '<meta property="og:description" content="'.wp_trim_words(esc_attr(stripslashes_deep(wp_filter_nohtml_kses(get_the_excerpt()))), 30).'" />';
502
echo "\n";
503
}
504
}
822
echo '<meta name="twitter:description" content="'.seopress_social_fb_desc_term_option().'" />';
823
echo "\n";
824
} elseif (term_description() !='') {
825
+ echo '<meta name="twitter:description" content="'.stripslashes_deep(wp_filter_nohtml_kses(term_description())).' - '.get_bloginfo('name').'" />';
826
echo "\n";
827
}
828
} elseif (is_singular() && seopress_social_facebook_og_option() =='1' && seopress_social_fb_desc_post_option() !='') {
833
echo "\n";
834
} elseif (seopress_social_facebook_og_option() =='1' && get_the_excerpt() !='') {
835
setup_postdata( $post );
836
+ echo '<meta name="twitter:description" content="'.wp_trim_words(esc_attr(stripslashes_deep(wp_filter_nohtml_kses(get_the_excerpt()))), 30).'" />';
837
echo "\n";
838
}
839
} else {
850
echo '<meta name="twitter:description" content="'.seopress_social_twitter_desc_term_option().'" />';
851
echo "\n";
852
} elseif (term_description() !='') {
853
+ echo '<meta name="twitter:description" content="'.stripslashes_deep(wp_filter_nohtml_kses(term_description())).' - '.get_bloginfo('name').'" />';
854
echo "\n";
855
}
856
} elseif (is_singular() && seopress_social_twitter_card_option() =='1' && seopress_social_twitter_desc_post_option() !='') {
861
echo "\n";
862
} elseif (seopress_social_twitter_card_option() =='1' && get_the_excerpt() !='') {
863
setup_postdata( $post );
864
+ echo '<meta name="twitter:description" content="'.wp_trim_words(esc_attr(stripslashes_deep(wp_filter_nohtml_kses(get_the_excerpt()))), 30).'" />';
865
echo "\n";
866
}
867
}
inc/functions/options-titles-metas.php CHANGED
@@ -4,1247 +4,1266 @@ defined( 'ABSPATH' ) or die( 'Please don&rsquo;t call the plugin directly. Thank
4
//Titles & metas
5
//=================================================================================================
6
//Titles
7
- //IF WP Site is public
8
- if (get_option('blog_public') =='1') {
9
- //Titles & Metas
10
-
11
- //Homepage Title
12
- function seopress_titles_home_site_title_option() {
13
- $seopress_titles_home_site_title_option = get_option("seopress_titles_option_name");
14
- if ( ! empty ( $seopress_titles_home_site_title_option ) ) {
15
- foreach ($seopress_titles_home_site_title_option as $key => $seopress_titles_home_site_title_value)
16
- $options[$key] = $seopress_titles_home_site_title_value;
17
- if (isset($seopress_titles_home_site_title_option['seopress_titles_home_site_title'])) {
18
- return $seopress_titles_home_site_title_option['seopress_titles_home_site_title'];
19
- }
20
- }
21
- };
22
-
23
- //Single CPT Titles
24
- function seopress_titles_single_titles_option() {
25
- global $post;
26
- $seopress_get_current_cpt = get_post_type($post);
27
-
28
- $seopress_titles_single_titles_option = get_option("seopress_titles_option_name");
29
- if ( ! empty ( $seopress_titles_single_titles_option ) ) {
30
- foreach ($seopress_titles_single_titles_option as $key => $seopress_titles_single_titles_value)
31
- $options[$key] = $seopress_titles_single_titles_value;
32
- if (isset($seopress_titles_single_titles_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['title'])) {
33
- return $seopress_titles_single_titles_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['title'];
34
- }
35
- }
36
- };
37
-
38
- //Archive CPT Titles
39
- function seopress_titles_archive_titles_option() {
40
- global $post;
41
- $seopress_get_current_cpt = get_post_type($post);
42
-
43
- $seopress_titles_archive_titles_option = get_option("seopress_titles_option_name");
44
- if ( ! empty ( $seopress_titles_archive_titles_option ) ) {
45
- foreach ($seopress_titles_archive_titles_option as $key => $seopress_titles_archive_titles_value)
46
- $options[$key] = $seopress_titles_archive_titles_value;
47
- if (isset($seopress_titles_archive_titles_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['title'])) {
48
- return $seopress_titles_archive_titles_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['title'];
49
- }
50
- }
51
- };
52
-
53
- //Tax archives Titles
54
- function seopress_titles_tax_titles_option() {
55
- $queried_object = get_queried_object();
56
- $seopress_get_current_tax = $queried_object->taxonomy;
57
-
58
- $seopress_titles_tax_titles_option = get_option("seopress_titles_option_name");
59
- if ( ! empty ( $seopress_titles_tax_titles_option ) ) {
60
- foreach ($seopress_titles_tax_titles_option as $key => $seopress_titles_tax_titles_value)
61
- $options[$key] = $seopress_titles_tax_titles_value;
62
- if (isset($seopress_titles_tax_titles_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['title'])) {
63
- return $seopress_titles_tax_titles_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['title'];
64
- }
65
- }
66
- };
67
-
68
- //Author archive Titles
69
- function seopress_titles_archives_author_title_option() {
70
- $seopress_titles_archives_author_title_option = get_option("seopress_titles_option_name");
71
- if ( ! empty ( $seopress_titles_archives_author_title_option ) ) {
72
- foreach ($seopress_titles_archives_author_title_option as $key => $seopress_titles_archives_author_title_value)
73
- $options[$key] = $seopress_titles_archives_author_title_value;
74
- if (isset($seopress_titles_archives_author_title_option['seopress_titles_archives_author_title'])) {
75
- return $seopress_titles_archives_author_title_option['seopress_titles_archives_author_title'];
76
- }
77
- }
78
- };
79
-
80
- //Date archive Titles
81
- function seopress_titles_archives_date_title_option() {
82
- $seopress_titles_archives_date_title_option = get_option("seopress_titles_option_name");
83
- if ( ! empty ( $seopress_titles_archives_date_title_option ) ) {
84
- foreach ($seopress_titles_archives_date_title_option as $key => $seopress_titles_archives_date_title_value)
85
- $options[$key] = $seopress_titles_archives_date_title_value;
86
- if (isset($seopress_titles_archives_date_title_option['seopress_titles_archives_date_title'])) {
87
- return $seopress_titles_archives_date_title_option['seopress_titles_archives_date_title'];
88
- }
89
- }
90
- };
91
-
92
- //Search archive Titles
93
- function seopress_titles_archives_search_title_option() {
94
- $seopress_titles_archives_search_title_option = get_option("seopress_titles_option_name");
95
- if ( ! empty ( $seopress_titles_archives_search_title_option ) ) {
96
- foreach ($seopress_titles_archives_search_title_option as $key => $seopress_titles_archives_search_title_value)
97
- $options[$key] = $seopress_titles_archives_search_title_value;
98
- if (isset($seopress_titles_archives_search_title_option['seopress_titles_archives_search_title'])) {
99
- return $seopress_titles_archives_search_title_option['seopress_titles_archives_search_title'];
100
- }
101
- }
102
- };
103
-
104
- //404 archive Titles
105
- function seopress_titles_archives_404_title_option() {
106
- $seopress_titles_archives_404_title_option = get_option("seopress_titles_option_name");
107
- if ( ! empty ( $seopress_titles_archives_404_title_option ) ) {
108
- foreach ($seopress_titles_archives_404_title_option as $key => $seopress_titles_archives_404_title_value)
109
- $options[$key] = $seopress_titles_archives_404_title_value;
110
- if (isset($seopress_titles_archives_404_title_option['seopress_titles_archives_404_title'])) {
111
- return $seopress_titles_archives_404_title_option['seopress_titles_archives_404_title'];
112
- }
113
- }
114
- };
115
-
116
- //Link rel prev/next
117
- function seopress_titles_paged_rel_option() {
118
- $seopress_titles_paged_rel_option = get_option("seopress_titles_option_name");
119
- if ( ! empty ( $seopress_titles_paged_rel_option ) ) {
120
- foreach ($seopress_titles_paged_rel_option as $key => $seopress_titles_paged_rel_value)
121
- $options[$key] = $seopress_titles_paged_rel_value;
122
- if (isset($seopress_titles_paged_rel_option['seopress_titles_paged_rel'])) {
123
- return $seopress_titles_paged_rel_option['seopress_titles_paged_rel'];
124
- }
125
- }
126
- };
127
-
128
- //Homepage Description
129
- function seopress_titles_home_site_desc_option() {
130
- $seopress_titles_home_site_desc_option = get_option("seopress_titles_option_name");
131
- if ( ! empty ( $seopress_titles_home_site_desc_option ) ) {
132
- foreach ($seopress_titles_home_site_desc_option as $key => $seopress_titles_home_site_desc_value)
133
- $options[$key] = $seopress_titles_home_site_desc_value;
134
- if (isset($seopress_titles_home_site_desc_option['seopress_titles_home_site_desc'])) {
135
- return $seopress_titles_home_site_desc_option['seopress_titles_home_site_desc'];
136
- }
137
- }
138
- };
139
-
140
- //Single CPT Description
141
- function seopress_titles_single_desc_option() {
142
- global $post;
143
- $seopress_get_current_cpt = get_post_type($post);
144
-
145
- $seopress_titles_single_desc_option = get_option("seopress_titles_option_name");
146
- if ( ! empty ( $seopress_titles_single_desc_option ) ) {
147
- foreach ($seopress_titles_single_desc_option as $key => $seopress_titles_single_desc_value)
148
- $options[$key] = $seopress_titles_single_desc_value;
149
- if (isset($seopress_titles_single_desc_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['description'])) {
150
- return $seopress_titles_single_desc_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['description'];
151
- }
152
- }
153
- };
154
-
155
- //Archive CPT Description
156
- function seopress_titles_archive_desc_option() {
157
- global $post;
158
- $seopress_get_current_cpt = get_post_type($post);
159
-
160
- $seopress_titles_archive_desc_option = get_option("seopress_titles_option_name");
161
- if ( ! empty ( $seopress_titles_archive_desc_option ) ) {
162
- foreach ($seopress_titles_archive_desc_option as $key => $seopress_titles_archive_desc_value)
163
- $options[$key] = $seopress_titles_archive_desc_value;
164
- if (isset($seopress_titles_archive_desc_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['description'])) {
165
- return $seopress_titles_archive_desc_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['description'];
166
- }
167
- }
168
- };
169
-
170
- //Tax archives Desc
171
- function seopress_titles_tax_desc_option() {
172
- $queried_object = get_queried_object();
173
- $seopress_get_current_tax = $queried_object->taxonomy;
174
-
175
- $seopress_titles_tax_desc_option = get_option("seopress_titles_option_name");
176
- if ( ! empty ( $seopress_titles_tax_desc_option ) ) {
177
- foreach ($seopress_titles_tax_desc_option as $key => $seopress_titles_tax_desc_value)
178
- $options[$key] = $seopress_titles_tax_desc_value;
179
- if (isset($seopress_titles_tax_desc_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['description'])) {
180
- return $seopress_titles_tax_desc_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['description'];
181
- }
182
- }
183
- };
184
-
185
- //Author archives Desc
186
- function seopress_titles_archives_author_desc_option() {
187
- $seopress_titles_archives_author_desc_option = get_option("seopress_titles_option_name");
188
- if ( ! empty ( $seopress_titles_archives_author_desc_option ) ) {
189
- foreach ($seopress_titles_archives_author_desc_option as $key => $seopress_titles_archives_author_desc_value)
190
- $options[$key] = $seopress_titles_archives_author_desc_value;
191
- if (isset($seopress_titles_archives_author_desc_option['seopress_titles_archives_author_desc'])) {
192
- return $seopress_titles_archives_author_desc_option['seopress_titles_archives_author_desc'];
193
- }
194
- }
195
- };
196
-
197
- //Date archives Desc
198
- function seopress_titles_archives_date_desc_option() {
199
- $seopress_titles_archives_date_desc_option = get_option("seopress_titles_option_name");
200
- if ( ! empty ( $seopress_titles_archives_date_desc_option ) ) {
201
- foreach ($seopress_titles_archives_date_desc_option as $key => $seopress_titles_archives_date_desc_value)
202
- $options[$key] = $seopress_titles_archives_date_desc_value;
203
- if (isset($seopress_titles_archives_date_desc_option['seopress_titles_archives_date_desc'])) {
204
- return $seopress_titles_archives_date_desc_option['seopress_titles_archives_date_desc'];
205
- }
206
- }
207
- };
208
-
209
- //Search archives Desc
210
- function seopress_titles_archives_search_desc_option() {
211
- $seopress_titles_archives_search_desc_option = get_option("seopress_titles_option_name");
212
- if ( ! empty ( $seopress_titles_archives_search_desc_option ) ) {
213
- foreach ($seopress_titles_archives_search_desc_option as $key => $seopress_titles_archives_search_desc_value)
214
- $options[$key] = $seopress_titles_archives_search_desc_value;
215
- if (isset($seopress_titles_archives_search_desc_option['seopress_titles_archives_search_desc'])) {
216
- return $seopress_titles_archives_search_desc_option['seopress_titles_archives_search_desc'];
217
- }
218
- }
219
- };
220
-
221
- //404 archives Desc
222
- function seopress_titles_archives_404_desc_option() {
223
- $seopress_titles_archives_404_desc_option = get_option("seopress_titles_option_name");
224
- if ( ! empty ( $seopress_titles_archives_404_desc_option ) ) {
225
- foreach ($seopress_titles_archives_404_desc_option as $key => $seopress_titles_archives_404_desc_value)
226
- $options[$key] = $seopress_titles_archives_404_desc_value;
227
- if (isset($seopress_titles_archives_404_desc_option['seopress_titles_archives_404_desc'])) {
228
- return $seopress_titles_archives_404_desc_option['seopress_titles_archives_404_desc'];
229
- }
230
- }
231
- };
232
233
- //THE Title Tag
234
- function seopress_titles_the_title() {
235
236
- global $post;
237
- global $term;
238
239
- //Remove WordPress Filters
240
- $seopress_array_filters = array('category_description', 'tag_description', 'term_description');
241
- foreach ($seopress_array_filters as $key => $value) {
242
- remove_filter($value,'wpautop');
243
- }
244
-
245
- //Template variables
246
- $seopress_paged ='';
247
- if (get_query_var('paged') >='1') {
248
- $seopress_paged = get_query_var('paged');
249
- $seopress_paged = apply_filters('seopress_paged', $seopress_paged);
250
- }
251
252
- $seopress_excerpt ='';
253
- if (!is_404() && $post !='') {
254
- if (has_excerpt($post->ID)) {
255
- $seopress_excerpt = get_the_excerpt();
256
- }
257
}
258
259
- $the_author_meta ='';
260
- if(is_single() || is_author()){
261
- $the_author_meta = get_the_author_meta('display_name', $post->post_author);
262
- }
263
264
- $post_category ='';
265
- if (is_single() && has_category()) {
266
- $post_category_array = get_the_terms(get_the_id(), 'category');
267
- $post_category = $post_category_array[0]->name;
268
- }
269
270
- $post_tag ='';
271
- if (is_single() && has_tag()) {
272
- $post_tag_array = get_the_terms(get_the_id(), 'post_tag');
273
- $post_tag = $post_tag_array[0]->name;
274
- }
275
276
- $get_search_query ='';
277
- if (get_search_query() !='') {
278
- $get_search_query = '"'.get_search_query().'"';
279
- } else {
280
- $get_search_query = esc_attr('" "');
281
- }
282
- $get_search_query = apply_filters('seopress_get_search_query', $get_search_query);
283
-
284
- $woo_single_cat_html ='';
285
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
286
- if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
287
- if (is_product()) {
288
- $woo_single_cats = get_the_terms( $post->ID, 'product_cat' );
289
-
290
- if ( $woo_single_cats && ! is_wp_error( $woo_single_cats ) ) {
291
-
292
- $woo_single_cat = array();
293
-
294
- foreach ( $woo_single_cats as $term ) {
295
- $woo_single_cat[] = $term->name;
296
- }
297
-
298
- $woo_single_cat_html = wp_filter_nohtml_kses(join( ", ", $woo_single_cat ));
299
- }
300
}
301
}
302
303
- $woo_single_tag_html ='';
304
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
305
- if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
306
- if (is_product()) {
307
- $woo_single_tags = get_the_terms( $post->ID, 'product_tag' );
308
-
309
- if ( $woo_single_tags && ! is_wp_error( $woo_single_tags ) ) {
310
-
311
- $woo_single_tag = array();
312
-
313
- foreach ( $woo_single_tags as $term ) {
314
- $woo_single_tag[] = $term->name;
315
- }
316
-
317
- $woo_single_tag_html = wp_filter_nohtml_kses(join( ", ", $woo_single_tag ));
318
- }
319
}
320
}
321
322
- $seopress_titles_template_variables_array = array(
323
- '%%sitetitle%%',
324
- '%%tagline%%',
325
- '%%post_title%%',
326
- '%%post_excerpt%%',
327
- '%%post_date%%',
328
- '%%post_author%%',
329
- '%%post_category%%',
330
- '%%post_tag%%',
331
- '%%_category_title%%',
332
- '%%_category_description%%',
333
- '%%tag_title%%',
334
- '%%tag_description%%',
335
- '%%term_title%%',
336
- '%%term_description%%',
337
- '%%search_keywords%%',
338
- '%%current_pagination%%',
339
- '%%cpt_plural%%',
340
- '%%archive_date%%',
341
- '%%wc_single_cat%%',
342
- '%%wc_single_tag%%',
343
- '%%wc_single_short_desc%%',
344
- );
345
- $seopress_titles_template_replace_array = array(
346
- get_bloginfo('name'),
347
- get_bloginfo('description'),
348
- the_title_attribute('echo=0'),
349
- $seopress_excerpt,
350
- get_the_date(),
351
- $the_author_meta,
352
- $post_category,
353
- $post_tag,
354
- single_cat_title('', false),
355
- wp_filter_nohtml_kses(category_description()),
356
- single_tag_title('', false),
357
- wp_filter_nohtml_kses(tag_description()),
358
- single_term_title('', false),
359
- wp_filter_nohtml_kses(term_description()),
360
- $get_search_query,
361
- $seopress_paged,
362
- post_type_archive_title('', false),
363
- get_the_archive_title(),
364
- $woo_single_cat_html,
365
- $woo_single_tag_html,
366
- $seopress_excerpt,
367
- );
368
-
369
- if ( is_front_page() && is_home() && get_post_meta($post->ID,'_seopress_titles_title',true) =='') { //HOMEPAGE
370
- if (seopress_titles_home_site_title_option() !='') {
371
- $seopress_titles_the_title = esc_attr(seopress_titles_home_site_title_option());
372
-
373
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
374
- return $seopress_titles_title_template;
375
- }
376
- } elseif ( is_front_page() && get_post_meta($post->ID,'_seopress_titles_title',true) ==''){ //STATIC HOMEPAGE
377
- if (seopress_titles_home_site_title_option() !='') {
378
- $seopress_titles_the_title = esc_attr(seopress_titles_home_site_title_option());
379
-
380
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
381
- return $seopress_titles_title_template;
382
- }
383
- } elseif ( is_home() && get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_title',true) !=''){ //BLOG PAGE
384
- if (get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_title',true)) { //IS METABOXE
385
- $seopress_titles_the_title = esc_attr(get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_title',true));
386
387
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
388
- return $seopress_titles_title_template;
389
- }
390
- } elseif ( is_home() && (get_option( 'show_on_front' ) =='posts')) { //YOUR LATEST POSTS
391
- if (seopress_titles_home_site_title_option() !='') {
392
- $seopress_titles_the_title = esc_attr(seopress_titles_home_site_title_option());
393
-
394
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
395
- return $seopress_titles_title_template;
396
}
397
- } elseif (is_singular()) { //IS SINGULAR
398
- if (get_post_meta($post->ID,'_seopress_titles_title',true)) { //IS METABOXE
399
- $seopress_titles_the_title = esc_attr(get_post_meta($post->ID,'_seopress_titles_title',true));
400
401
- preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_the_title, $matches);
402
403
- if (!empty($matches)) {
404
- $seopress_titles_cf_template_variables_array = array();
405
- $seopress_titles_cf_template_replace_array = array();
406
407
- foreach ($matches['0'] as $key => $value) {
408
- $seopress_titles_cf_template_variables_array[] = $value;
409
- }
410
411
- foreach ($matches['1'] as $key => $value) {
412
- $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
413
- }
414
- }
415
416
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
417
418
- if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
419
- $seopress_titles_title_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_title_template);
420
}
421
422
- return $seopress_titles_title_template;
423
}
424
- else { //DEFAULT GLOBAL
425
426
- $seopress_titles_single_titles_option = esc_attr(seopress_titles_single_titles_option());
427
428
- preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_single_titles_option, $matches);
429
430
- if (!empty($matches)) {
431
- $seopress_titles_cf_template_variables_array = array();
432
- $seopress_titles_cf_template_replace_array = array();
433
434
- foreach ($matches['0'] as $key => $value) {
435
- $seopress_titles_cf_template_variables_array[] = $value;
436
- }
437
438
- foreach ($matches['1'] as $key => $value) {
439
- $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
440
- }
441
- }
442
443
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_single_titles_option);
444
-
445
- if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
446
- $seopress_titles_title_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_title_template);
447
- }
448
449
- return $seopress_titles_title_template;
450
- }
451
- } elseif (is_post_type_archive() && seopress_titles_archive_titles_option()) { //IS POST TYPE ARCHIVE
452
- $seopress_titles_archive_titles_option = esc_attr(seopress_titles_archive_titles_option());
453
-
454
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archive_titles_option);
455
- return $seopress_titles_title_template;
456
- } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_titles_option()) { //IS TAX
457
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_title',true)) {
458
- return esc_attr(get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_title',true));
459
- } else {
460
- $seopress_titles_tax_titles_option = esc_attr(seopress_titles_tax_titles_option());
461
-
462
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_tax_titles_option);
463
- return $seopress_titles_title_template;
464
- }
465
- } elseif (is_author() && seopress_titles_archives_author_title_option()) { //IS AUTHOR
466
- $seopress_titles_archives_author_title_option = esc_attr(seopress_titles_archives_author_title_option());
467
-
468
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_author_title_option);
469
- return $seopress_titles_title_template;
470
- } elseif (is_date() && seopress_titles_archives_date_title_option()) { //IS DATE
471
- $seopress_titles_archives_date_title_option = esc_attr(seopress_titles_archives_date_title_option());
472
-
473
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_date_title_option);
474
- return $seopress_titles_title_template;
475
- } elseif (is_search() && seopress_titles_archives_search_title_option()) { //IS SEARCH
476
- $seopress_titles_archives_search_title_option = esc_attr(seopress_titles_archives_search_title_option());
477
-
478
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_search_title_option);
479
- return $seopress_titles_title_template;
480
- } elseif (is_404() && seopress_titles_archives_404_title_option()) { //IS 404
481
- $seopress_titles_archives_404_title_option = esc_attr(seopress_titles_archives_404_title_option());
482
-
483
- $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_404_title_option);
484
- return $seopress_titles_title_template;
485
- }
486
- }
487
- add_filter( 'pre_get_document_title', 'seopress_titles_the_title', 10 );
488
489
- //THE Meta Description
490
- function seopress_titles_the_description_content() {
491
- global $post;
492
493
- //Template variables
494
- $seopress_paged ='';
495
- $seopress_get_author ='';
496
497
- if (get_query_var('paged') >='1') {
498
- $seopress_paged = get_query_var('paged');
499
}
500
501
- $seopress_excerpt ='';
502
- if (!is_404() && $post !='') {
503
- if (has_excerpt($post->ID)) {
504
- $seopress_excerpt = get_the_excerpt();
505
- }
506
- }
507
508
- if (get_query_var('paged') >='1') {
509
- $seopress_paged = get_query_var('paged');
510
- $seopress_paged = apply_filters('seopress_paged', $seopress_paged);
511
- }
512
513
- if (get_the_author_meta() !='') {
514
- $seopress_get_author = get_the_author_meta( 'display_name', $post->post_author );
515
- }
516
517
- $post_category ='';
518
- if (is_single() && has_category()) {
519
- $post_category_array = get_the_terms(get_the_id(), 'category');
520
- $post_category = $post_category_array[0]->name;
521
- }
522
523
- $post_tag ='';
524
- if (is_single() && has_tag()) {
525
- $post_tag_array = get_the_terms(get_the_id(), 'post_tag');
526
- $post_tag = $post_tag_array[0]->name;
527
- }
528
529
- $get_search_query ='';
530
- if (get_search_query() !='') {
531
- $get_search_query = '"'.get_search_query().'"';
532
- } else {
533
- $get_search_query = esc_attr('" "');
534
- }
535
- $get_search_query = apply_filters('seopress_get_search_query', $get_search_query);
536
-
537
- if ($seopress_excerpt !='') {
538
- $seopress_get_the_excerpt = wp_trim_words(esc_attr(wp_filter_nohtml_kses($seopress_excerpt), 30));
539
- } elseif ($post !='') {
540
- if (get_post_field('post_content', $post->ID) !='') {
541
- $seopress_get_the_excerpt = wp_trim_words(esc_attr(wp_filter_nohtml_kses(get_post_field('post_content', $post->ID)), 30));
542
- } else {
543
- $seopress_get_the_excerpt = null;
544
- }
545
} else {
546
$seopress_get_the_excerpt = null;
547
}
548
549
- $woo_single_cat_html ='';
550
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
551
- if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
552
- if (is_product()) {
553
- $woo_single_cats = get_the_terms( $post->ID, 'product_cat' );
554
-
555
- if ( $woo_single_cats && ! is_wp_error( $woo_single_cats ) ) {
556
-
557
- $woo_single_cat = array();
558
-
559
- foreach ( $woo_single_cats as $term ) {
560
- $woo_single_cat[] = $term->name;
561
- }
562
-
563
- $woo_single_cat_html = wp_filter_nohtml_kses(join( ", ", $woo_single_cat ));
564
- }
565
}
566
}
567
568
- $woo_single_tag_html ='';
569
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
570
- if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
571
- if (is_product()) {
572
- $woo_single_tags = get_the_terms( $post->ID, 'product_tag' );
573
-
574
- if ( $woo_single_tags && ! is_wp_error( $woo_single_tags ) ) {
575
-
576
- $woo_single_tag = array();
577
-
578
- foreach ( $woo_single_tags as $term ) {
579
- $woo_single_tag[] = $term->name;
580
- }
581
-
582
- $woo_single_tag_html = wp_filter_nohtml_kses(join( ", ", $woo_single_tag ));
583
- }
584
}
585
}
586
587
- $seopress_titles_template_variables_array = array(
588
- '%%sitetitle%%',
589
- '%%tagline%%',
590
- '%%post_title%%',
591
- '%%post_excerpt%%',
592
- '%%post_date%%',
593
- '%%post_author%%',
594
- '%%post_category%%',
595
- '%%post_tag%%',
596
- '%%_category_title%%',
597
- '%%_category_description%%',
598
- '%%tag_title%%',
599
- '%%tag_description%%',
600
- '%%term_title%%',
601
- '%%term_description%%',
602
- '%%search_keywords%%',
603
- '%%current_pagination%%',
604
- '%%cpt_plural%%',
605
- '%%archive_date%%',
606
- '%%wc_single_cat%%',
607
- '%%wc_single_tag%%',
608
- '%%wc_single_short_desc%%',
609
- );
610
- $seopress_titles_template_replace_array = array(
611
- get_bloginfo('name'),
612
- get_bloginfo('description'),
613
- the_title_attribute('echo=0'),
614
- $seopress_get_the_excerpt,
615
- get_the_date(),
616
- $seopress_get_author,
617
- $post_category,
618
- $post_tag,
619
- single_cat_title('', false),
620
- wp_filter_nohtml_kses(category_description()),
621
- single_tag_title('', false),
622
- wp_filter_nohtml_kses(tag_description()),
623
- single_term_title('', false),
624
- wp_filter_nohtml_kses(term_description()),
625
- $get_search_query,
626
- $seopress_paged,
627
- post_type_archive_title('', false),
628
- get_the_archive_title(),
629
- $woo_single_cat_html,
630
- $woo_single_tag_html,
631
- $seopress_excerpt,
632
- );
633
-
634
- if ( is_front_page() && is_home() && get_post_meta($post->ID,'_seopress_titles_desc',true) =='' ) { //HOMEPAGE
635
- if (seopress_titles_home_site_desc_option() !='') { //IS GLOBAL
636
- $seopress_titles_the_description = esc_attr(seopress_titles_home_site_desc_option());
637
638
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
639
- return $seopress_titles_description_template;
640
- }
641
- } elseif ( is_front_page() && get_post_meta($post->ID,'_seopress_titles_desc',true) ==''){ //STATIC HOMEPAGE
642
- if (seopress_titles_home_site_desc_option() !='' && get_post_meta($post->ID,'_seopress_titles_desc',true) =='') { //IS GLOBAL
643
- $seopress_titles_the_description = esc_attr(seopress_titles_home_site_desc_option());
644
-
645
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
646
- return $seopress_titles_description_template;
647
- }
648
- } elseif ( is_home() && get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_desc',true) !=''){ //BLOG PAGE
649
- if (get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_desc',true)) { //IS METABOXE
650
- $seopress_titles_the_description_meta = get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_desc',true);
651
- $seopress_titles_the_description = esc_attr($seopress_titles_the_description_meta);
652
-
653
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
654
- return $seopress_titles_description_template;
655
- }
656
- } elseif ( is_home() && (get_option( 'show_on_front' ) =='posts')) { //YOUR LATEST POSTS
657
- if (seopress_titles_home_site_desc_option() !='') { //IS GLOBAL
658
- $seopress_titles_the_description = esc_attr(seopress_titles_home_site_desc_option());
659
660
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
661
- return $seopress_titles_description_template;
662
- }
663
- } elseif (is_singular()) { //IS SINGLE
664
- if (get_post_meta($post->ID,'_seopress_titles_desc',true)) { //IS METABOXE
665
- $seopress_titles_the_description = esc_attr(get_post_meta($post->ID,'_seopress_titles_desc',true));
666
667
- preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_the_description, $matches);
668
669
- if (!empty($matches)) {
670
- $seopress_titles_cf_template_variables_array = array();
671
- $seopress_titles_cf_template_replace_array = array();
672
673
- foreach ($matches['0'] as $key => $value) {
674
- $seopress_titles_cf_template_variables_array[] = $value;
675
- }
676
677
- foreach ($matches['1'] as $key => $value) {
678
- $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
679
- }
680
}
681
682
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
683
-
684
- if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
685
- $seopress_titles_description_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_description_template);
686
}
687
688
- return $seopress_titles_description_template;
689
- } elseif (seopress_titles_single_desc_option() !='') { //IS GLOBAL
690
- $seopress_titles_the_description = esc_attr(seopress_titles_single_desc_option());
691
-
692
- preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_the_description, $matches);
693
694
- if (!empty($matches)) {
695
- $seopress_titles_cf_template_variables_array = array();
696
- $seopress_titles_cf_template_replace_array = array();
697
698
- foreach ($matches['0'] as $key => $value) {
699
- $seopress_titles_cf_template_variables_array[] = $value;
700
- }
701
702
- foreach ($matches['1'] as $key => $value) {
703
- $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
704
- }
705
}
706
707
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
708
-
709
- if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
710
- $seopress_titles_description_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_description_template);
711
- }
712
-
713
- return $seopress_titles_description_template;
714
- } else {
715
- setup_postdata( $post );
716
- if ($seopress_excerpt !='' || get_the_content() !='') { //DEFAULT EXCERPT OR THE CONTENT
717
- $seopress_titles_the_description = wp_trim_words(wp_filter_nohtml_kses($seopress_excerpt), 30);
718
-
719
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
720
- return $seopress_titles_description_template;
721
}
722
}
723
- } elseif (is_post_type_archive() && seopress_titles_archive_desc_option()) { //IS POST TYPE ARCHIVE
724
- $seopress_titles_the_description = esc_attr(seopress_titles_archive_desc_option());
725
-
726
$seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
727
- return $seopress_titles_description_template;
728
- } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_desc_option()) { //IS TAX
729
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_desc',true)) {
730
- $seopress_titles_the_description = esc_attr(get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_desc',true));
731
-
732
- return $seopress_titles_the_description;
733
- } else {
734
- $seopress_titles_the_description = esc_attr(seopress_titles_tax_desc_option());
735
736
$seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
737
- return $seopress_titles_description_template;
738
}
739
- } elseif (is_author() && seopress_titles_archives_author_desc_option()) { //IS AUTHOR
740
- $seopress_titles_the_description = esc_attr(seopress_titles_archives_author_desc_option());
741
742
$seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
743
- return $seopress_titles_description_template;
744
- } elseif (is_date() && seopress_titles_archives_date_desc_option()) { //IS DATE
745
- $seopress_titles_the_description = esc_attr(seopress_titles_archives_date_desc_option());
746
747
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
748
- return $seopress_titles_description_template;
749
- } elseif (is_search() && seopress_titles_archives_search_desc_option()) { //IS SEARCH
750
- $seopress_titles_the_description = esc_attr(seopress_titles_archives_search_desc_option());
751
752
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
753
- return $seopress_titles_description_template;
754
- } elseif (is_404() && seopress_titles_archives_404_desc_option()) { //IS 404
755
- $seopress_titles_the_description = esc_attr(seopress_titles_archives_404_desc_option());
756
-
757
- $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
758
- return $seopress_titles_description_template;
759
- }
760
}
761
- function seopress_titles_the_description() {
762
- $html = '<meta name="description" content="'.seopress_titles_the_description_content().'" />';
763
- $html .= "\n";
764
- echo $html;
765
- }
766
- add_action( 'wp_head', 'seopress_titles_the_description', 1 );
767
-
768
- //Advanced
769
- //noindex
770
- //Single CPT noindex
771
- function seopress_titles_single_cpt_noindex_option() {
772
- global $post;
773
- $seopress_get_current_cpt = get_post_type($post);
774
-
775
- $seopress_titles_single_cpt_noindex_option = get_option("seopress_titles_option_name");
776
- if ( ! empty ( $seopress_titles_single_cpt_noindex_option ) ) {
777
- foreach ($seopress_titles_single_cpt_noindex_option as $key => $seopress_titles_single_cpt_noindex_value)
778
- $options[$key] = $seopress_titles_single_cpt_noindex_value;
779
- if (isset($seopress_titles_single_cpt_noindex_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['noindex'])) {
780
- return $seopress_titles_single_cpt_noindex_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['noindex'];
781
- }
782
- }
783
- };
784
-
785
- //Archive CPT noindex
786
- function seopress_titles_archive_cpt_noindex_option() {
787
- global $post;
788
- $seopress_get_current_cpt = get_post_type($post);
789
-
790
- $seopress_titles_archive_cpt_noindex_option = get_option("seopress_titles_option_name");
791
- if ( ! empty ( $seopress_titles_archive_cpt_noindex_option ) ) {
792
- foreach ($seopress_titles_archive_cpt_noindex_option as $key => $seopress_titles_archive_cpt_noindex_value)
793
- $options[$key] = $seopress_titles_archive_cpt_noindex_value;
794
- if (isset($seopress_titles_archive_cpt_noindex_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['noindex'])) {
795
- return $seopress_titles_archive_cpt_noindex_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['noindex'];
796
}
797
}
798
- };
799
-
800
- //Tax archive noindex
801
- function seopress_titles_tax_noindex_option() {
802
- $queried_object = get_queried_object();
803
- $seopress_get_current_tax = $queried_object->taxonomy;
804
805
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_index',true) == 'yes') {
806
- return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_index',true);
807
- } else {
808
- $seopress_titles_tax_noindex_option = get_option("seopress_titles_option_name");
809
- if ( ! empty ( $seopress_titles_tax_noindex_option ) ) {
810
- foreach ($seopress_titles_tax_noindex_option as $key => $seopress_titles_tax_noindex_value)
811
- $options[$key] = $seopress_titles_tax_noindex_value;
812
- if (isset($seopress_titles_tax_noindex_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['noindex'])) {
813
- return $seopress_titles_tax_noindex_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['noindex'];
814
- }
815
- }
816
- }
817
- };
818
-
819
- //noindex Author archives
820
- function seopress_titles_archives_author_noindex_option() {
821
- $seopress_titles_archives_author_noindex_option = get_option("seopress_titles_option_name");
822
- if ( ! empty ( $seopress_titles_archives_author_noindex_option ) ) {
823
- foreach ($seopress_titles_archives_author_noindex_option as $key => $seopress_titles_archives_author_noindex_value)
824
- $options[$key] = $seopress_titles_archives_author_noindex_value;
825
- if (isset($seopress_titles_archives_author_noindex_option['seopress_titles_archives_author_noindex'])) {
826
- return $seopress_titles_archives_author_noindex_option['seopress_titles_archives_author_noindex'];
827
- }
828
- }
829
- };
830
-
831
- //noindex Date archives
832
- function seopress_titles_archives_date_noindex_option() {
833
- $seopress_titles_archives_date_noindex_option = get_option("seopress_titles_option_name");
834
- if ( ! empty ( $seopress_titles_archives_date_noindex_option ) ) {
835
- foreach ($seopress_titles_archives_date_noindex_option as $key => $seopress_titles_archives_date_noindex_value)
836
- $options[$key] = $seopress_titles_archives_date_noindex_value;
837
- if (isset($seopress_titles_archives_date_noindex_option['seopress_titles_archives_date_noindex'])) {
838
- return $seopress_titles_archives_date_noindex_option['seopress_titles_archives_date_noindex'];
839
}
840
}
841
- };
842
-
843
- //noindex Search
844
- function seopress_titles_archives_search_title_noindex_option() {
845
- $seopress_titles_archives_search_title_noindex_option = get_option("seopress_titles_option_name");
846
- if ( ! empty ( $seopress_titles_archives_search_title_noindex_option ) ) {
847
- foreach ($seopress_titles_archives_search_title_noindex_option as $key => $seopress_titles_archives_search_title_noindex_value)
848
- $options[$key] = $seopress_titles_archives_search_title_noindex_value;
849
- if (isset($seopress_titles_archives_search_title_noindex_option['seopress_titles_archives_search_title_noindex'])) {
850
- return $seopress_titles_archives_search_title_noindex_option['seopress_titles_archives_search_title_noindex'];
851
}
852
}
853
- };
854
-
855
- //noindex Global Advanced tab
856
- function seopress_titles_noindex_option() {
857
- $seopress_titles_noindex_option = get_option("seopress_titles_option_name");
858
- if ( ! empty ( $seopress_titles_noindex_option ) ) {
859
- foreach ($seopress_titles_noindex_option as $key => $seopress_titles_noindex_value)
860
- $options[$key] = $seopress_titles_noindex_value;
861
- if (isset($seopress_titles_noindex_option['seopress_titles_noindex'])) {
862
- return $seopress_titles_noindex_option['seopress_titles_noindex'];
863
}
864
}
865
- };
866
-
867
- //noindex single CPT
868
- function seopress_titles_noindex_post_option() {
869
- $_seopress_robots_index = get_post_meta(get_the_ID(),'_seopress_robots_index',true);
870
- if ($_seopress_robots_index == 'yes') {
871
- return $_seopress_robots_index;
872
- }
873
- };
874
-
875
- //noindex WooCommerce page
876
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
877
- if (is_plugin_active('wp-seopress-pro/seopress-pro.php')) {
878
- //Cart page
879
- function seopress_woocommerce_cart_page_no_index_option() {
880
- $seopress_woocommerce_cart_page_no_index_option = get_option("seopress_pro_option_name");
881
- if ( ! empty ( $seopress_woocommerce_cart_page_no_index_option ) ) {
882
- foreach ($seopress_woocommerce_cart_page_no_index_option as $key => $seopress_woocommerce_cart_page_no_index_value)
883
- $options[$key] = $seopress_woocommerce_cart_page_no_index_value;
884
- if (isset($seopress_woocommerce_cart_page_no_index_option['seopress_woocommerce_cart_page_no_index'])) {
885
- return $seopress_woocommerce_cart_page_no_index_option['seopress_woocommerce_cart_page_no_index'];
886
- }
887
- }
888
- }
889
- //Checkout page
890
- function seopress_woocommerce_checkout_page_no_index_option() {
891
- $seopress_woocommerce_checkout_page_no_index_option = get_option("seopress_pro_option_name");
892
- if ( ! empty ( $seopress_woocommerce_checkout_page_no_index_option ) ) {
893
- foreach ($seopress_woocommerce_checkout_page_no_index_option as $key => $seopress_woocommerce_checkout_page_no_index_value)
894
- $options[$key] = $seopress_woocommerce_checkout_page_no_index_value;
895
- if (isset($seopress_woocommerce_checkout_page_no_index_option['seopress_woocommerce_checkout_page_no_index'])) {
896
- return $seopress_woocommerce_checkout_page_no_index_option['seopress_woocommerce_checkout_page_no_index'];
897
- }
898
- }
899
- }
900
- //Customer Account
901
- function seopress_woocommerce_customer_account_page_no_index_option() {
902
- $seopress_woocommerce_customer_account_page_no_index_option = get_option("seopress_pro_option_name");
903
- if ( ! empty ( $seopress_woocommerce_customer_account_page_no_index_option ) ) {
904
- foreach ($seopress_woocommerce_customer_account_page_no_index_option as $key => $seopress_woocommerce_customer_account_page_no_index_value)
905
- $options[$key] = $seopress_woocommerce_customer_account_page_no_index_value;
906
- if (isset($seopress_woocommerce_customer_account_page_no_index_option['seopress_woocommerce_customer_account_page_no_index'])) {
907
- return $seopress_woocommerce_customer_account_page_no_index_option['seopress_woocommerce_customer_account_page_no_index'];
908
- }
909
- }
910
- }
911
}
912
913
- function seopress_titles_noindex_bypass() {
914
- if (seopress_titles_noindex_option()) { //Single CPT Global Advanced tab
915
- return seopress_titles_noindex_option();
916
- } elseif (is_singular() && seopress_titles_single_cpt_noindex_option()) { //Single CPT Global
917
- return seopress_titles_single_cpt_noindex_option();
918
- } elseif (is_singular() && seopress_titles_noindex_post_option() ) { //Single CPT Metaboxe
919
- return seopress_titles_noindex_post_option();
920
- } elseif (is_post_type_archive() && seopress_titles_archive_cpt_noindex_option() ) { //IS POST TYPE ARCHIVE
921
- return seopress_titles_archive_cpt_noindex_option();
922
- } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_noindex_option()) { //IS TAX
923
- return seopress_titles_tax_noindex_option();
924
- } elseif (is_author() && seopress_titles_archives_author_noindex_option()) { //IS Author archive
925
- return seopress_titles_archives_author_noindex_option();
926
- } elseif (is_date() && seopress_titles_archives_date_noindex_option()) { //IS Date archive
927
- return seopress_titles_archives_date_noindex_option();
928
- } elseif (is_search() && seopress_titles_archives_search_title_noindex_option()) {
929
- return seopress_titles_archives_search_title_noindex_option();
930
- } elseif (function_exists('is_cart') && function_exists('seopress_woocommerce_cart_page_no_index_option') && (is_cart() && seopress_woocommerce_cart_page_no_index_option())) { //IS WooCommerce Cart page
931
- return seopress_woocommerce_cart_page_no_index_option();
932
- } elseif (function_exists('is_checkout') && function_exists('seopress_woocommerce_checkout_page_no_index_option') && (is_checkout() && seopress_woocommerce_checkout_page_no_index_option())) { //IS WooCommerce Checkout page
933
- return seopress_woocommerce_checkout_page_no_index_option();
934
- } elseif (function_exists('is_account_page') && function_exists('seopress_woocommerce_customer_account_page_no_index_option') && (is_account_page() && seopress_woocommerce_customer_account_page_no_index_option())) { //IS WooCommerce Customer account pages
935
- return seopress_woocommerce_customer_account_page_no_index_option();
936
- } elseif (function_exists('is_wc_endpoint_url') && function_exists('seopress_woocommerce_customer_account_page_no_index_option') && (is_wc_endpoint_url() && seopress_woocommerce_customer_account_page_no_index_option())) { //IS WooCommerce Customer account pages
937
- return seopress_woocommerce_customer_account_page_no_index_option();
938
- } elseif(is_404()) { //Is 404 page
939
- return "noindex";
940
- }
941
}
942
943
- //nofollow
944
- //Single CPT nofollow
945
- function seopress_titles_single_cpt_nofollow_option() {
946
- global $post;
947
- $seopress_get_current_cpt = get_post_type($post);
948
-
949
- $seopress_titles_single_cpt_nofollow_option = get_option("seopress_titles_option_name");
950
- if ( ! empty ( $seopress_titles_single_cpt_nofollow_option ) ) {
951
- foreach ($seopress_titles_single_cpt_nofollow_option as $key => $seopress_titles_single_cpt_nofollow_value)
952
- $options[$key] = $seopress_titles_single_cpt_nofollow_value;
953
- if (isset($seopress_titles_single_cpt_nofollow_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['nofollow'])) {
954
- return $seopress_titles_single_cpt_nofollow_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['nofollow'];
955
- }
956
- }
957
- };
958
-
959
- //Archive CPT nofollow
960
- function seopress_titles_archive_cpt_nofollow_option() {
961
- global $post;
962
- $seopress_get_current_cpt = get_post_type($post);
963
-
964
- $seopress_titles_archive_cpt_nofollow_option = get_option("seopress_titles_option_name");
965
- if ( ! empty ( $seopress_titles_archive_cpt_nofollow_option ) ) {
966
- foreach ($seopress_titles_archive_cpt_nofollow_option as $key => $seopress_titles_archive_cpt_nofollow_value)
967
- $options[$key] = $seopress_titles_archive_cpt_nofollow_value;
968
- if (isset($seopress_titles_archive_cpt_nofollow_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['nofollow'])) {
969
- return $seopress_titles_archive_cpt_nofollow_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['nofollow'];
970
- }
971
- }
972
- };
973
-
974
- //Tax archive nofollow
975
- function seopress_titles_tax_nofollow_option() {
976
- $queried_object = get_queried_object();
977
- $seopress_get_current_tax = $queried_object->taxonomy;
978
-
979
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_follow',true) == 'yes') {
980
- return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_follow',true);
981
- } else {
982
- $seopress_titles_tax_nofollow_option = get_option("seopress_titles_option_name");
983
- if ( ! empty ( $seopress_titles_tax_nofollow_option ) ) {
984
- foreach ($seopress_titles_tax_nofollow_option as $key => $seopress_titles_tax_nofollow_value)
985
- $options[$key] = $seopress_titles_tax_nofollow_value;
986
- if (isset($seopress_titles_tax_nofollow_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['nofollow'])) {
987
- return $seopress_titles_tax_nofollow_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['nofollow'];
988
- }
989
- }
990
- }
991
- };
992
-
993
- //nofollow Global Avanced tab
994
- function seopress_titles_nofollow_option() {
995
- $seopress_titles_nofollow_option = get_option("seopress_titles_option_name");
996
- if ( ! empty ( $seopress_titles_nofollow_option ) ) {
997
- foreach ($seopress_titles_nofollow_option as $key => $seopress_titles_nofollow_value)
998
- $options[$key] = $seopress_titles_nofollow_value;
999
- if (isset($seopress_titles_nofollow_option['seopress_titles_nofollow'])) {
1000
- return $seopress_titles_nofollow_option['seopress_titles_nofollow'];
1001
- }
1002
- }
1003
- };
1004
-
1005
- function seopress_titles_nofollow_post_option() {
1006
- $_seopress_robots_follow = get_post_meta(get_the_ID(),'_seopress_robots_follow',true);
1007
- if ($_seopress_robots_follow == 'yes') {
1008
- return $_seopress_robots_follow;
1009
- }
1010
- };
1011
-
1012
- function seopress_titles_nofollow_bypass() {
1013
- if (seopress_titles_nofollow_option()) { //Single CPT Global Advanced tab
1014
- return seopress_titles_nofollow_option();
1015
- } elseif (is_singular() && seopress_titles_single_cpt_nofollow_option()) { //Single CPT Global
1016
- return seopress_titles_single_cpt_nofollow_option();
1017
- } elseif (is_singular() && seopress_titles_nofollow_post_option() ) { //Single CPT Metaboxe
1018
- return seopress_titles_nofollow_post_option();
1019
- } elseif (is_post_type_archive() && seopress_titles_archive_cpt_nofollow_option() ) { //IS POST TYPE ARCHIVE
1020
- return seopress_titles_archive_cpt_nofollow_option();
1021
- } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_nofollow_option()) { //IS TAX
1022
- return seopress_titles_tax_nofollow_option();
1023
- }
1024
- };
1025
-
1026
- //date in SERPs
1027
- function seopress_titles_single_cpt_date_option() {
1028
- global $post;
1029
- $seopress_get_current_cpt = get_post_type($post);
1030
-
1031
- $seopress_titles_single_cpt_date_option = get_option("seopress_titles_option_name");
1032
- if ( ! empty ( $seopress_titles_single_cpt_date_option ) ) {
1033
- foreach ($seopress_titles_single_cpt_date_option as $key => $seopress_titles_single_cpt_date_value)
1034
- $options[$key] = $seopress_titles_single_cpt_date_value;
1035
- if (isset($seopress_titles_single_cpt_date_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['date'])) {
1036
- return $seopress_titles_single_cpt_date_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['date'];
1037
}
1038
}
1039
- };
1040
-
1041
- function seopress_titles_single_cpt_date_hook() {
1042
- if (!is_front_page() && !is_home()) {
1043
- if (is_singular() && seopress_titles_single_cpt_date_option() =='1') {
1044
- $seopress_get_current_pub_post_date = get_the_date('c');
1045
- $seopress_get_current_up_post_date = get_the_modified_date('c');
1046
- echo '<meta property="article:published_time" content="'.$seopress_get_current_pub_post_date.'" />';
1047
- echo "\n";
1048
- echo '<meta property="article:modified_time" content="'.$seopress_get_current_up_post_date.'" />';
1049
- echo "\n";
1050
- echo '<meta property="og:updated_time" content="'.$seopress_get_current_up_post_date.'" />';
1051
- echo "\n";
1052
- }
1053
- }
1054
}
1055
- add_action( 'wp_head', 'seopress_titles_single_cpt_date_hook', 1 );
1056
1057
- //noodp
1058
- function seopress_titles_noodp_option() {
1059
- $seopress_titles_noodp_option = get_option("seopress_titles_option_name");
1060
- if ( ! empty ( $seopress_titles_noodp_option ) ) {
1061
- foreach ($seopress_titles_noodp_option as $key => $seopress_titles_noodp_value)
1062
- $options[$key] = $seopress_titles_noodp_value;
1063
- if (isset($seopress_titles_noodp_option['seopress_titles_noodp'])) {
1064
- return $seopress_titles_noodp_option['seopress_titles_noodp'];
1065
- }
1066
}
1067
- };
1068
1069
- function seopress_titles_noodp_post_option() {
1070
- $_seopress_robots_odp = get_post_meta(get_the_ID(),'_seopress_robots_odp',true);
1071
- if ($_seopress_robots_odp == 'yes') {
1072
- return $_seopress_robots_odp;
1073
- }
1074
- };
1075
1076
- function seopress_titles_noodp_bypass() {
1077
- if (seopress_titles_noodp_option()) {
1078
- return seopress_titles_noodp_option();
1079
- }
1080
- elseif (is_singular() && seopress_titles_noodp_post_option()) {
1081
- return seopress_titles_noodp_post_option();
1082
- } elseif (is_tax() || is_category() || is_tag()) {
1083
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_odp',true) == 'yes') {
1084
- return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_odp',true);
1085
- }
1086
- }
1087
- };
1088
-
1089
- //noarchive
1090
- function seopress_titles_noarchive_option() {
1091
- $seopress_titles_noarchive_option = get_option("seopress_titles_option_name");
1092
- if ( ! empty ( $seopress_titles_noarchive_option ) ) {
1093
- foreach ($seopress_titles_noarchive_option as $key => $seopress_titles_noarchive_value)
1094
- $options[$key] = $seopress_titles_noarchive_value;
1095
- if (isset($seopress_titles_noarchive_option['seopress_titles_noarchive'])) {
1096
- return $seopress_titles_noarchive_option['seopress_titles_noarchive'];
1097
- }
1098
}
1099
- };
1100
1101
- function seopress_titles_noarchive_post_option() {
1102
- $_seopress_robots_archive = get_post_meta(get_the_ID(),'_seopress_robots_archive',true);
1103
- if ($_seopress_robots_archive == 'yes') {
1104
- return $_seopress_robots_archive;
1105
- }
1106
- };
1107
1108
- function seopress_titles_noarchive_bypass() {
1109
- if (seopress_titles_noarchive_option()) {
1110
- return seopress_titles_noarchive_option();
1111
- }
1112
- elseif (is_singular() && seopress_titles_noarchive_post_option()) {
1113
- return seopress_titles_noarchive_post_option();
1114
- } elseif (is_tax() || is_category() || is_tag()) {
1115
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_archive',true) == 'yes') {
1116
- return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_archive',true);
1117
- }
1118
- }
1119
- };
1120
-
1121
- //nosnippet
1122
- function seopress_titles_nosnippet_option() {
1123
- $seopress_titles_nosnippet_option = get_option("seopress_titles_option_name");
1124
- if ( ! empty ( $seopress_titles_nosnippet_option ) ) {
1125
- foreach ($seopress_titles_nosnippet_option as $key => $seopress_titles_nosnippet_value)
1126
- $options[$key] = $seopress_titles_nosnippet_value;
1127
- if (isset($seopress_titles_nosnippet_option['seopress_titles_nosnippet'])) {
1128
- return $seopress_titles_nosnippet_option['seopress_titles_nosnippet'];
1129
- }
1130
}
1131
- };
1132
1133
- function seopress_titles_nosnippet_post_option() {
1134
- $_seopress_robots_snippet = get_post_meta(get_the_ID(),'_seopress_robots_snippet',true);
1135
- if ($_seopress_robots_snippet == 'yes') {
1136
- return $_seopress_robots_snippet;
1137
- }
1138
- };
1139
1140
- function seopress_titles_nosnippet_bypass() {
1141
- if (seopress_titles_nosnippet_option()) {
1142
- return seopress_titles_nosnippet_option();
1143
- }
1144
- elseif (is_singular() && seopress_titles_nosnippet_post_option()) {
1145
- return seopress_titles_nosnippet_post_option();
1146
- } elseif (is_tax() || is_category() || is_tag()) {
1147
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_snippet',true) == 'yes') {
1148
- return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_snippet',true);
1149
- }
1150
}
1151
}
1152
1153
- if (seopress_titles_noindex_bypass() || seopress_titles_nofollow_bypass() || seopress_titles_noodp_bypass() || seopress_titles_noarchive_bypass() || seopress_titles_nosnippet_bypass() ) {
1154
- function seopress_titles_advanced_robots_hook() {
1155
-
1156
- $seopress_comma_array = array();
1157
-
1158
- if (seopress_titles_noindex_bypass() !='') {
1159
- $seopress_titles_noindex = 'noindex';
1160
- array_push($seopress_comma_array, $seopress_titles_noindex);
1161
- }
1162
- if (seopress_titles_nofollow_bypass() !='') {
1163
- $seopress_titles_nofollow = 'nofollow';
1164
- array_push($seopress_comma_array, $seopress_titles_nofollow);
1165
- }
1166
- if (seopress_titles_noodp_bypass() !='') {
1167
- $seopress_titles_noodp = 'noodp';
1168
- array_push($seopress_comma_array, $seopress_titles_noodp);
1169
- }
1170
- if (seopress_titles_noarchive_bypass() !='') {
1171
- $seopress_titles_noarchive = 'noarchive';
1172
- array_push($seopress_comma_array, $seopress_titles_noarchive);
1173
- }
1174
- if (seopress_titles_nosnippet_bypass() !='') {
1175
- $seopress_titles_nosnippet = 'nosnippet';
1176
- array_push($seopress_comma_array, $seopress_titles_nosnippet);
1177
- }
1178
-
1179
- echo '<meta name="robots" content="';
1180
-
1181
- $seopress_comma_count = count($seopress_comma_array);
1182
- for ($i = 0; $i < $seopress_comma_count; $i++) {
1183
- echo $seopress_comma_array[$i];
1184
- if ($i < ($seopress_comma_count - 1)) {
1185
- echo ', ';
1186
- }
1187
- }
1188
-
1189
- echo '" />';
1190
- echo "\n";
1191
- }
1192
- add_action( 'wp_head', 'seopress_titles_advanced_robots_hook', 1 );
1193
- };
1194
-
1195
- //noimageindex
1196
- function seopress_titles_noimageindex_option() {
1197
- $seopress_titles_noimageindex_option = get_option("seopress_titles_option_name");
1198
- if ( ! empty ( $seopress_titles_noimageindex_option ) ) {
1199
- foreach ($seopress_titles_noimageindex_option as $key => $seopress_titles_noimageindex_value)
1200
- $options[$key] = $seopress_titles_noimageindex_value;
1201
- if (isset($seopress_titles_noimageindex_option['seopress_titles_noimageindex'])) {
1202
- return $seopress_titles_noimageindex_option['seopress_titles_noimageindex'];
1203
- }
1204
- }
1205
- };
1206
1207
- function seopress_titles_noimageindex_post_option() {
1208
- $_seopress_robots_imageindex = get_post_meta(get_the_ID(),'_seopress_robots_imageindex',true);
1209
- if ($_seopress_robots_imageindex == 'yes') {
1210
- return $_seopress_robots_imageindex;
1211
- }
1212
- };
1213
1214
- function seopress_titles_noimageindex_bypass() {
1215
- if (seopress_titles_noimageindex_option()) {
1216
- return seopress_titles_noimageindex_option();
1217
- }
1218
- elseif (is_singular() && seopress_titles_noimageindex_post_option()) {
1219
- return seopress_titles_noimageindex_post_option();
1220
- } elseif (is_tax() || is_category() || is_tag()) {
1221
- if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_imageindex',true) == 'yes') {
1222
- return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_imageindex',true);
1223
- }
1224
- }
1225
- };
1226
-
1227
- if (seopress_titles_noimageindex_bypass()) {
1228
- function seopress_titles_advanced_google_hook() {
1229
- $seopress_titles_noimageindex = '<meta name="google" content="noimageindex" />';
1230
- echo $seopress_titles_noimageindex."\n";
1231
- }
1232
- add_action( 'wp_head', 'seopress_titles_advanced_google_hook', 1 );
1233
- };
1234
-
1235
- //link rel prev/next
1236
- if (seopress_titles_paged_rel_option()) {
1237
- function seopress_titles_paged_rel_hook() {
1238
- global $paged;
1239
- if ( get_previous_posts_link() ) { ?>
1240
- <link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>" />
1241
- <?php } if ( get_next_posts_link() ) { ?>
1242
- <link rel="next" href="<?php echo get_pagenum_link( $paged + 1 ); ?>" />
1243
- <?php }
1244
}
1245
- add_action( 'wp_head', 'seopress_titles_paged_rel_hook', 9 );
1246
}
1247
- } //END blog_public
1248
1249
//canonical
1250
function seopress_titles_canonical_post_option() {
4
//Titles & metas
5
//=================================================================================================
6
//Titles
7
+ //Titles & Metas
8
+
9
+ //Homepage Title
10
+ function seopress_titles_home_site_title_option() {
11
+ $seopress_titles_home_site_title_option = get_option("seopress_titles_option_name");
12
+ if ( ! empty ( $seopress_titles_home_site_title_option ) ) {
13
+ foreach ($seopress_titles_home_site_title_option as $key => $seopress_titles_home_site_title_value)
14
+ $options[$key] = $seopress_titles_home_site_title_value;
15
+ if (isset($seopress_titles_home_site_title_option['seopress_titles_home_site_title'])) {
16
+ return $seopress_titles_home_site_title_option['seopress_titles_home_site_title'];
17
+ }
18
+ }
19
+ };
20
+
21
+ //Single CPT Titles
22
+ function seopress_titles_single_titles_option() {
23
+ global $post;
24
+ $seopress_get_current_cpt = get_post_type($post);
25
+
26
+ $seopress_titles_single_titles_option = get_option("seopress_titles_option_name");
27
+ if ( ! empty ( $seopress_titles_single_titles_option ) ) {
28
+ foreach ($seopress_titles_single_titles_option as $key => $seopress_titles_single_titles_value)
29
+ $options[$key] = $seopress_titles_single_titles_value;
30
+ if (isset($seopress_titles_single_titles_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['title'])) {
31
+ return $seopress_titles_single_titles_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['title'];
32
+ }
33
+ }
34
+ };
35
+
36
+ //Archive CPT Titles
37
+ function seopress_titles_archive_titles_option() {
38
+ global $post;
39
+ $seopress_get_current_cpt = get_post_type($post);
40
+
41
+ $seopress_titles_archive_titles_option = get_option("seopress_titles_option_name");
42
+ if ( ! empty ( $seopress_titles_archive_titles_option ) ) {
43
+ foreach ($seopress_titles_archive_titles_option as $key => $seopress_titles_archive_titles_value)
44
+ $options[$key] = $seopress_titles_archive_titles_value;
45
+ if (isset($seopress_titles_archive_titles_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['title'])) {
46
+ return $seopress_titles_archive_titles_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['title'];
47
+ }
48
+ }
49
+ };
50
+
51
+ //Tax archives Titles
52
+ function seopress_titles_tax_titles_option() {
53
+ $queried_object = get_queried_object();
54
+ $seopress_get_current_tax = $queried_object->taxonomy;
55
+
56
+ $seopress_titles_tax_titles_option = get_option("seopress_titles_option_name");
57
+ if ( ! empty ( $seopress_titles_tax_titles_option ) ) {
58
+ foreach ($seopress_titles_tax_titles_option as $key => $seopress_titles_tax_titles_value)
59
+ $options[$key] = $seopress_titles_tax_titles_value;
60
+ if (isset($seopress_titles_tax_titles_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['title'])) {
61
+ return $seopress_titles_tax_titles_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['title'];
62
+ }
63
+ }
64
+ };
65
+
66
+ //Author archive Titles
67
+ function seopress_titles_archives_author_title_option() {
68
+ $seopress_titles_archives_author_title_option = get_option("seopress_titles_option_name");
69
+ if ( ! empty ( $seopress_titles_archives_author_title_option ) ) {
70
+ foreach ($seopress_titles_archives_author_title_option as $key => $seopress_titles_archives_author_title_value)
71
+ $options[$key] = $seopress_titles_archives_author_title_value;
72
+ if (isset($seopress_titles_archives_author_title_option['seopress_titles_archives_author_title'])) {
73
+ return $seopress_titles_archives_author_title_option['seopress_titles_archives_author_title'];
74
+ }
75
+ }
76
+ };
77
+
78
+ //Date archive Titles
79
+ function seopress_titles_archives_date_title_option() {
80
+ $seopress_titles_archives_date_title_option = get_option("seopress_titles_option_name");
81
+ if ( ! empty ( $seopress_titles_archives_date_title_option ) ) {
82
+ foreach ($seopress_titles_archives_date_title_option as $key => $seopress_titles_archives_date_title_value)
83
+ $options[$key] = $seopress_titles_archives_date_title_value;
84
+ if (isset($seopress_titles_archives_date_title_option['seopress_titles_archives_date_title'])) {
85
+ return $seopress_titles_archives_date_title_option['seopress_titles_archives_date_title'];
86
+ }
87
+ }
88
+ };
89
+
90
+ //Search archive Titles
91
+ function seopress_titles_archives_search_title_option() {
92
+ $seopress_titles_archives_search_title_option = get_option("seopress_titles_option_name");
93
+ if ( ! empty ( $seopress_titles_archives_search_title_option ) ) {
94
+ foreach ($seopress_titles_archives_search_title_option as $key => $seopress_titles_archives_search_title_value)
95
+ $options[$key] = $seopress_titles_archives_search_title_value;
96
+ if (isset($seopress_titles_archives_search_title_option['seopress_titles_archives_search_title'])) {
97
+ return $seopress_titles_archives_search_title_option['seopress_titles_archives_search_title'];
98
+ }
99
+ }
100
+ };
101
+
102
+ //404 archive Titles
103
+ function seopress_titles_archives_404_title_option() {
104
+ $seopress_titles_archives_404_title_option = get_option("seopress_titles_option_name");
105
+ if ( ! empty ( $seopress_titles_archives_404_title_option ) ) {
106
+ foreach ($seopress_titles_archives_404_title_option as $key => $seopress_titles_archives_404_title_value)
107
+ $options[$key] = $seopress_titles_archives_404_title_value;
108
+ if (isset($seopress_titles_archives_404_title_option['seopress_titles_archives_404_title'])) {
109
+ return $seopress_titles_archives_404_title_option['seopress_titles_archives_404_title'];
110
+ }
111
+ }
112
+ };
113
+
114
+ //Link rel prev/next
115
+ function seopress_titles_paged_rel_option() {
116
+ $seopress_titles_paged_rel_option = get_option("seopress_titles_option_name");
117
+ if ( ! empty ( $seopress_titles_paged_rel_option ) ) {
118
+ foreach ($seopress_titles_paged_rel_option as $key => $seopress_titles_paged_rel_value)
119
+ $options[$key] = $seopress_titles_paged_rel_value;
120
+ if (isset($seopress_titles_paged_rel_option['seopress_titles_paged_rel'])) {
121
+ return $seopress_titles_paged_rel_option['seopress_titles_paged_rel'];
122
+ }
123
+ }
124
+ };
125
+
126
+ //Homepage Description
127
+ function seopress_titles_home_site_desc_option() {
128
+ $seopress_titles_home_site_desc_option = get_option("seopress_titles_option_name");
129
+ if ( ! empty ( $seopress_titles_home_site_desc_option ) ) {
130
+ foreach ($seopress_titles_home_site_desc_option as $key => $seopress_titles_home_site_desc_value)
131
+ $options[$key] = $seopress_titles_home_site_desc_value;
132
+ if (isset($seopress_titles_home_site_desc_option['seopress_titles_home_site_desc'])) {
133
+ return $seopress_titles_home_site_desc_option['seopress_titles_home_site_desc'];
134
+ }
135
+ }
136
+ };
137
+
138
+ //Single CPT Description
139
+ function seopress_titles_single_desc_option() {
140
+ global $post;
141
+ $seopress_get_current_cpt = get_post_type($post);
142
+
143
+ $seopress_titles_single_desc_option = get_option("seopress_titles_option_name");
144
+ if ( ! empty ( $seopress_titles_single_desc_option ) ) {
145
+ foreach ($seopress_titles_single_desc_option as $key => $seopress_titles_single_desc_value)
146
+ $options[$key] = $seopress_titles_single_desc_value;
147
+ if (isset($seopress_titles_single_desc_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['description'])) {
148
+ return $seopress_titles_single_desc_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['description'];
149
+ }
150
+ }
151
+ };
152
+
153
+ //Archive CPT Description
154
+ function seopress_titles_archive_desc_option() {
155
+ global $post;
156
+ $seopress_get_current_cpt = get_post_type($post);
157
+
158
+ $seopress_titles_archive_desc_option = get_option("seopress_titles_option_name");
159
+ if ( ! empty ( $seopress_titles_archive_desc_option ) ) {
160
+ foreach ($seopress_titles_archive_desc_option as $key => $seopress_titles_archive_desc_value)
161
+ $options[$key] = $seopress_titles_archive_desc_value;
162
+ if (isset($seopress_titles_archive_desc_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['description'])) {
163
+ return $seopress_titles_archive_desc_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['description'];
164
+ }
165
+ }
166
+ };
167
+
168
+ //Tax archives Desc
169
+ function seopress_titles_tax_desc_option() {
170
+ $queried_object = get_queried_object();
171
+ $seopress_get_current_tax = $queried_object->taxonomy;
172
+
173
+ $seopress_titles_tax_desc_option = get_option("seopress_titles_option_name");
174
+ if ( ! empty ( $seopress_titles_tax_desc_option ) ) {
175
+ foreach ($seopress_titles_tax_desc_option as $key => $seopress_titles_tax_desc_value)
176
+ $options[$key] = $seopress_titles_tax_desc_value;
177
+ if (isset($seopress_titles_tax_desc_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['description'])) {
178
+ return $seopress_titles_tax_desc_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['description'];
179
+ }
180
+ }
181
+ };
182
+
183
+ //Author archives Desc
184
+ function seopress_titles_archives_author_desc_option() {
185
+ $seopress_titles_archives_author_desc_option = get_option("seopress_titles_option_name");
186
+ if ( ! empty ( $seopress_titles_archives_author_desc_option ) ) {
187
+ foreach ($seopress_titles_archives_author_desc_option as $key => $seopress_titles_archives_author_desc_value)
188
+ $options[$key] = $seopress_titles_archives_author_desc_value;
189
+ if (isset($seopress_titles_archives_author_desc_option['seopress_titles_archives_author_desc'])) {
190
+ return $seopress_titles_archives_author_desc_option['seopress_titles_archives_author_desc'];
191
+ }
192
+ }
193
+ };
194
+
195
+ //Date archives Desc
196
+ function seopress_titles_archives_date_desc_option() {
197
+ $seopress_titles_archives_date_desc_option = get_option("seopress_titles_option_name");
198
+ if ( ! empty ( $seopress_titles_archives_date_desc_option ) ) {
199
+ foreach ($seopress_titles_archives_date_desc_option as $key => $seopress_titles_archives_date_desc_value)
200
+ $options[$key] = $seopress_titles_archives_date_desc_value;
201
+ if (isset($seopress_titles_archives_date_desc_option['seopress_titles_archives_date_desc'])) {
202
+ return $seopress_titles_archives_date_desc_option['seopress_titles_archives_date_desc'];
203
+ }
204
+ }
205
+ };
206
+
207
+ //Search archives Desc
208
+ function seopress_titles_archives_search_desc_option() {
209
+ $seopress_titles_archives_search_desc_option = get_option("seopress_titles_option_name");
210
+ if ( ! empty ( $seopress_titles_archives_search_desc_option ) ) {
211
+ foreach ($seopress_titles_archives_search_desc_option as $key => $seopress_titles_archives_search_desc_value)
212
+ $options[$key] = $seopress_titles_archives_search_desc_value;
213
+ if (isset($seopress_titles_archives_search_desc_option['seopress_titles_archives_search_desc'])) {
214
+ return $seopress_titles_archives_search_desc_option['seopress_titles_archives_search_desc'];
215
+ }
216
+ }
217
+ };
218
+
219
+ //404 archives Desc
220
+ function seopress_titles_archives_404_desc_option() {
221
+ $seopress_titles_archives_404_desc_option = get_option("seopress_titles_option_name");
222
+ if ( ! empty ( $seopress_titles_archives_404_desc_option ) ) {
223
+ foreach ($seopress_titles_archives_404_desc_option as $key => $seopress_titles_archives_404_desc_value)
224
+ $options[$key] = $seopress_titles_archives_404_desc_value;
225
+ if (isset($seopress_titles_archives_404_desc_option['seopress_titles_archives_404_desc'])) {
226
+ return $seopress_titles_archives_404_desc_option['seopress_titles_archives_404_desc'];
227
+ }
228
+ }
229
+ };
230
231
+ //THE Title Tag
232
+ function seopress_titles_the_title() {
233
234
+ global $post;
235
+ global $term;
236
237
+ //Remove WordPress Filters
238
+ $seopress_array_filters = array('category_description', 'tag_description', 'term_description');
239
+ foreach ($seopress_array_filters as $key => $value) {
240
+ remove_filter($value,'wpautop');
241
+ }
242
+
243
+ //Template variables
244
+ $seopress_paged ='';
245
+ if (get_query_var('paged') >='1') {
246
+ $seopress_paged = get_query_var('paged');
247
+ $seopress_paged = apply_filters('seopress_paged', $seopress_paged);
248
+ }
249
250
+ $seopress_excerpt ='';
251
+ if (!is_404() && $post !='') {
252
+ if (has_excerpt($post->ID)) {
253
+ $seopress_excerpt = get_the_excerpt();
254
}
255
+ }
256
257
+ $the_author_meta ='';
258
+ if(is_single() || is_author()){
259
+ $the_author_meta = get_the_author_meta('display_name', $post->post_author);
260
+ }
261
262
+ $post_category ='';
263
+ if (is_single() && has_category()) {
264
+ $post_category_array = get_the_terms(get_the_id(), 'category');
265
+ $post_category = $post_category_array[0]->name;
266
+ }
267
268
+ $post_tag ='';
269
+ if (is_single() && has_tag()) {
270
+ $post_tag_array = get_the_terms(get_the_id(), 'post_tag');
271
+ $post_tag = $post_tag_array[0]->name;
272
+ }
273
274
+ $get_search_query ='';
275
+ if (get_search_query() !='') {
276
+ $get_search_query = '"'.get_search_query().'"';
277
+ } else {
278
+ $get_search_query = esc_attr('" "');
279
+ }
280
+ $get_search_query = apply_filters('seopress_get_search_query', $get_search_query);
281
+
282
+ $woo_single_cat_html ='';
283
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
284
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
285
+ if (is_product()) {
286
+ $woo_single_cats = get_the_terms( $post->ID, 'product_cat' );
287
+
288
+ if ( $woo_single_cats && ! is_wp_error( $woo_single_cats ) ) {
289
+
290
+ $woo_single_cat = array();
291
+
292
+ foreach ( $woo_single_cats as $term ) {
293
+ $woo_single_cat[] = $term->name;
294
+ }
295
+
296
+ $woo_single_cat_html = stripslashes_deep(wp_filter_nohtml_kses(join( ", ", $woo_single_cat )));
297
}
298
}
299
+ }
300
301
+ $woo_single_tag_html ='';
302
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
303
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
304
+ if (is_product()) {
305
+ $woo_single_tags = get_the_terms( $post->ID, 'product_tag' );
306
+
307
+ if ( $woo_single_tags && ! is_wp_error( $woo_single_tags ) ) {
308
+
309
+ $woo_single_tag = array();
310
+
311
+ foreach ( $woo_single_tags as $term ) {
312
+ $woo_single_tag[] = $term->name;
313
+ }
314
+
315
+ $woo_single_tag_html = stripslashes_deep(wp_filter_nohtml_kses(join( ", ", $woo_single_tag )));
316
}
317
}
318
+ }
319
320
+ $seopress_titles_template_variables_array = array(
321
+ '%%sitetitle%%',
322
+ '%%tagline%%',
323
+ '%%post_title%%',
324
+ '%%post_excerpt%%',
325
+ '%%post_date%%',
326
+ '%%post_author%%',
327
+ '%%post_category%%',
328
+ '%%post_tag%%',
329
+ '%%_category_title%%',
330
+ '%%_category_description%%',
331
+ '%%tag_title%%',
332
+ '%%tag_description%%',
333
+ '%%term_title%%',
334
+ '%%term_description%%',
335
+ '%%search_keywords%%',
336
+ '%%current_pagination%%',
337
+ '%%cpt_plural%%',
338
+ '%%archive_date%%',
339
+ '%%wc_single_cat%%',
340
+ '%%wc_single_tag%%',
341
+ '%%wc_single_short_desc%%',
342
+ );
343
+ $seopress_titles_template_replace_array = array(
344
+ get_bloginfo('name'),
345
+ get_bloginfo('description'),
346
+ the_title_attribute('echo=0'),
347
+ $seopress_excerpt,
348
+ get_the_date(),
349
+ $the_author_meta,
350
+ $post_category,
351
+ $post_tag,
352
+ single_cat_title('', false),
353
+ stripslashes_deep(wp_filter_nohtml_kses(category_description())),
354
+ single_tag_title('', false),
355
+ stripslashes_deep(wp_filter_nohtml_kses(tag_description())),
356
+ single_term_title('', false),
357
+ stripslashes_deep(wp_filter_nohtml_kses(term_description())),
358
+ $get_search_query,
359
+ $seopress_paged,
360
+ post_type_archive_title('', false),
361
+ get_the_archive_title(),
362
+ $woo_single_cat_html,
363
+ $woo_single_tag_html,
364
+ $seopress_excerpt,
365
+ );
366
+
367
+ if ( is_front_page() && is_home() && get_post_meta($post->ID,'_seopress_titles_title',true) =='') { //HOMEPAGE
368
+ if (seopress_titles_home_site_title_option() !='') {
369
+ $seopress_titles_the_title = esc_attr(seopress_titles_home_site_title_option());
370
+
371
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
372
+ }
373
+ } elseif ( is_front_page() && get_post_meta($post->ID,'_seopress_titles_title',true) ==''){ //STATIC HOMEPAGE
374
+ if (seopress_titles_home_site_title_option() !='') {
375
+ $seopress_titles_the_title = esc_attr(seopress_titles_home_site_title_option());
376
+
377
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
378
+ }
379
+ } elseif ( is_home() && get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_title',true) !=''){ //BLOG PAGE
380
+ if (get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_title',true)) { //IS METABOXE
381
+ $seopress_titles_the_title = esc_attr(get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_title',true));
382
+
383
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
384
+ }
385
+ } elseif ( is_home() && (get_option( 'show_on_front' ) =='posts')) { //YOUR LATEST POSTS
386
+ if (seopress_titles_home_site_title_option() !='') {
387
+ $seopress_titles_the_title = esc_attr(seopress_titles_home_site_title_option());
388
+
389
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
390
+ }
391
+ } elseif (is_singular()) { //IS SINGULAR
392
+ if (get_post_meta($post->ID,'_seopress_titles_title',true)) { //IS METABOXE
393
+ $seopress_titles_the_title = esc_attr(get_post_meta($post->ID,'_seopress_titles_title',true));
394
+
395
+ preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_the_title, $matches);
396
+
397
+ if (!empty($matches)) {
398
+ $seopress_titles_cf_template_variables_array = array();
399
+ $seopress_titles_cf_template_replace_array = array();
400
+
401
+ foreach ($matches['0'] as $key => $value) {
402
+ $seopress_titles_cf_template_variables_array[] = $value;
403
+ }
404
405
+ foreach ($matches['1'] as $key => $value) {
406
+ $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
407
+ }
408
}
409
410
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_title);
411
412
+ if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
413
+ $seopress_titles_title_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_title_template);
414
+ }
415
+ }
416
+ else { //DEFAULT GLOBAL
417
418
+ $seopress_titles_single_titles_option = esc_attr(seopress_titles_single_titles_option());
419
420
+ preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_single_titles_option, $matches);
421
422
+ if (!empty($matches)) {
423
+ $seopress_titles_cf_template_variables_array = array();
424
+ $seopress_titles_cf_template_replace_array = array();
425
426
+ foreach ($matches['0'] as $key => $value) {
427
+ $seopress_titles_cf_template_variables_array[] = $value;
428
}
429
430
+ foreach ($matches['1'] as $key => $value) {
431
+ $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
432
+ }
433
}
434
435
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_single_titles_option);
436
+
437
+ if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
438
+ $seopress_titles_title_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_title_template);
439
+ }
440
+ }
441
+ } elseif (is_post_type_archive() && seopress_titles_archive_titles_option()) { //IS POST TYPE ARCHIVE
442
+ $seopress_titles_archive_titles_option = esc_attr(seopress_titles_archive_titles_option());
443
444
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archive_titles_option);
445
+ } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_titles_option()) { //IS TAX
446
+ if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_title',true)) {
447
+ $seopress_titles_title_template = esc_attr(get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_title',true));
448
+ } else {
449
+ $seopress_titles_tax_titles_option = esc_attr(seopress_titles_tax_titles_option());
450
451
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_tax_titles_option);
452
+ }
453
+ } elseif (is_author() && seopress_titles_archives_author_title_option()) { //IS AUTHOR
454
+ $seopress_titles_archives_author_title_option = esc_attr(seopress_titles_archives_author_title_option());
455
456
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_author_title_option);
457
+ } elseif (is_date() && seopress_titles_archives_date_title_option()) { //IS DATE
458
+ $seopress_titles_archives_date_title_option = esc_attr(seopress_titles_archives_date_title_option());
459
460
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_date_title_option);
461
+ } elseif (is_search() && seopress_titles_archives_search_title_option()) { //IS SEARCH
462
+ $seopress_titles_archives_search_title_option = esc_attr(seopress_titles_archives_search_title_option());
463
+
464
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_search_title_option);
465
+ } elseif (is_404() && seopress_titles_archives_404_title_option()) { //IS 404
466
+ $seopress_titles_archives_404_title_option = esc_attr(seopress_titles_archives_404_title_option());
467
+
468
+ $seopress_titles_title_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_archives_404_title_option);
469
+ }
470
471
+ //Hook on Title tag - 'seopress_titles_title'
472
+ if (has_filter('seopress_titles_title')) {
473
+ $seopress_titles_title_template = apply_filters('seopress_titles_title', $seopress_titles_title_template);
474
+ }
475
+ //Return Title tag
476
+ return $seopress_titles_title_template;
477
+ }
478
+ add_filter( 'pre_get_document_title', 'seopress_titles_the_title', 10 );
479
480
+ //THE Meta Description
481
+ function seopress_titles_the_description_content() {
482
+ global $post;
483
484
+ //Template variables
485
+ $seopress_paged ='';
486
+ $seopress_get_author ='';
487
488
+ if (get_query_var('paged') >='1') {
489
+ $seopress_paged = get_query_var('paged');
490
+ }
491
492
+ $seopress_excerpt ='';
493
+ if (!is_404() && $post !='') {
494
+ if (has_excerpt($post->ID)) {
495
+ $seopress_excerpt = get_the_excerpt();
496
}
497
+ }
498
499
+ if (get_query_var('paged') >='1') {
500
+ $seopress_paged = get_query_var('paged');
501
+ $seopress_paged = apply_filters('seopress_paged', $seopress_paged);
502
+ }
503
504
+ if (get_the_author_meta() !='') {
505
+ $seopress_get_author = get_the_author_meta( 'display_name', $post->post_author );
506
+ }
507
508
+ $post_category ='';
509
+ if (is_single() && has_category()) {
510
+ $post_category_array = get_the_terms(get_the_id(), 'category');
511
+ $post_category = $post_category_array[0]->name;
512
+ }
513
514
+ $post_tag ='';
515
+ if (is_single() && has_tag()) {
516
+ $post_tag_array = get_the_terms(get_the_id(), 'post_tag');
517
+ $post_tag = $post_tag_array[0]->name;
518
+ }
519
520
+ $get_search_query ='';
521
+ if (get_search_query() !='') {
522
+ $get_search_query = '"'.get_search_query().'"';
523
+ } else {
524
+ $get_search_query = esc_attr('" "');
525
+ }
526
+ $get_search_query = apply_filters('seopress_get_search_query', $get_search_query);
527
528
+ if ($seopress_excerpt !='') {
529
+ $seopress_get_the_excerpt = wp_trim_words(esc_attr(stripslashes_deep(wp_filter_nohtml_kses($seopress_excerpt))), 30);
530
+ } elseif ($post !='') {
531
+ if (get_post_field('post_content', $post->ID) !='') {
532
+ $seopress_get_the_excerpt = wp_trim_words(esc_attr(stripslashes_deep(wp_filter_nohtml_kses(get_post_field('post_content', $post->ID)))), 30);
533
} else {
534
$seopress_get_the_excerpt = null;
535
}
536
+ } else {
537
+ $seopress_get_the_excerpt = null;
538
+ }
539
540
+ $woo_single_cat_html ='';
541
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
542
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
543
+ if (is_product()) {
544
+ $woo_single_cats = get_the_terms( $post->ID, 'product_cat' );
545
+
546
+ if ( $woo_single_cats && ! is_wp_error( $woo_single_cats ) ) {
547
+
548
+ $woo_single_cat = array();
549
+
550
+ foreach ( $woo_single_cats as $term ) {
551
+ $woo_single_cat[] = $term->name;
552
+ }
553
+
554
+ $woo_single_cat_html = stripslashes_deep(wp_filter_nohtml_kses(join( ", ", $woo_single_cat )));
555
}
556
}
557
+ }
558
559
+ $woo_single_tag_html ='';
560
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
561
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' )) {
562
+ if (is_product()) {
563
+ $woo_single_tags = get_the_terms( $post->ID, 'product_tag' );
564
+
565
+ if ( $woo_single_tags && ! is_wp_error( $woo_single_tags ) ) {
566
+
567
+ $woo_single_tag = array();
568
+
569
+ foreach ( $woo_single_tags as $term ) {
570
+ $woo_single_tag[] = $term->name;
571
+ }
572
+
573
+ $woo_single_tag_html = stripslashes_deep(wp_filter_nohtml_kses(join( ", ", $woo_single_tag )));
574
}
575
}
576
+ }
577
578
+ $seopress_titles_template_variables_array = array(
579
+ '%%sitetitle%%',
580
+ '%%tagline%%',
581
+ '%%post_title%%',
582
+ '%%post_excerpt%%',
583
+ '%%post_date%%',
584
+ '%%post_author%%',
585
+ '%%post_category%%',
586
+ '%%post_tag%%',
587
+ '%%_category_title%%',
588
+ '%%_category_description%%',
589
+ '%%tag_title%%',
590
+ '%%tag_description%%',
591
+ '%%term_title%%',
592
+ '%%term_description%%',
593
+ '%%search_keywords%%',
594
+ '%%current_pagination%%',
595
+ '%%cpt_plural%%',
596
+ '%%archive_date%%',
597
+ '%%wc_single_cat%%',
598
+ '%%wc_single_tag%%',
599
+ '%%wc_single_short_desc%%',
600
+ );
601
+ $seopress_titles_template_replace_array = array(
602
+ get_bloginfo('name'),
603
+ get_bloginfo('description'),
604
+ the_title_attribute('echo=0'),
605
+ $seopress_get_the_excerpt,
606
+ get_the_date(),
607
+ $seopress_get_author,
608
+ $post_category,
609
+ $post_tag,
610
+ single_cat_title('', false),
611
+ stripslashes_deep(wp_filter_nohtml_kses(category_description())),
612
+ single_tag_title('', false),
613
+ stripslashes_deep(wp_filter_nohtml_kses(tag_description())),
614
+ single_term_title('', false),
615
+ stripslashes_deep(wp_filter_nohtml_kses(term_description())),
616
+ $get_search_query,
617
+ $seopress_paged,
618
+ post_type_archive_title('', false),
619
+ get_the_archive_title(),
620
+ $woo_single_cat_html,
621
+ $woo_single_tag_html,
622
+ $seopress_excerpt,
623
+ );
624
+
625
+ if ( is_front_page() && is_home() && get_post_meta($post->ID,'_seopress_titles_desc',true) =='' ) { //HOMEPAGE
626
+ if (seopress_titles_home_site_desc_option() !='') { //IS GLOBAL
627
+ $seopress_titles_the_description = esc_attr(seopress_titles_home_site_desc_option());
628
629
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
630
+ }
631
+ } elseif ( is_front_page() && get_post_meta($post->ID,'_seopress_titles_desc',true) ==''){ //STATIC HOMEPAGE
632
+ if (seopress_titles_home_site_desc_option() !='' && get_post_meta($post->ID,'_seopress_titles_desc',true) =='') { //IS GLOBAL
633
+ $seopress_titles_the_description = esc_attr(seopress_titles_home_site_desc_option());
634
635
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
636
+ }
637
+ } elseif ( is_home() && get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_desc',true) !=''){ //BLOG PAGE
638
+ if (get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_desc',true)) { //IS METABOXE
639
+ $seopress_titles_the_description_meta = get_post_meta(get_option( 'page_for_posts' ),'_seopress_titles_desc',true);
640
+ $seopress_titles_the_description = esc_attr($seopress_titles_the_description_meta);
641
+
642
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
643
+ }
644
+ } elseif ( is_home() && (get_option( 'show_on_front' ) =='posts')) { //YOUR LATEST POSTS
645
+ if (seopress_titles_home_site_desc_option() !='') { //IS GLOBAL
646
+ $seopress_titles_the_description = esc_attr(seopress_titles_home_site_desc_option());
647
648
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
649
+ }
650
+ } elseif (is_singular()) { //IS SINGLE
651
+ if (get_post_meta($post->ID,'_seopress_titles_desc',true)) { //IS METABOXE
652
+ $seopress_titles_the_description = esc_attr(get_post_meta($post->ID,'_seopress_titles_desc',true));
653
654
+ preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_the_description, $matches);
655
656
+ if (!empty($matches)) {
657
+ $seopress_titles_cf_template_variables_array = array();
658
+ $seopress_titles_cf_template_replace_array = array();
659
660
+ foreach ($matches['0'] as $key => $value) {
661
+ $seopress_titles_cf_template_variables_array[] = $value;
662
}
663
664
+ foreach ($matches['1'] as $key => $value) {
665
+ $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
666
}
667
+ }
668
669
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
670
671
+ if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
672
+ $seopress_titles_description_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_description_template);
673
+ }
674
+ } elseif (seopress_titles_single_desc_option() !='') { //IS GLOBAL
675
+ $seopress_titles_the_description = esc_attr(seopress_titles_single_desc_option());
676
+
677
+ preg_match_all('/%%_cf_(.*?)%%/', $seopress_titles_the_description, $matches);
678
679
+ if (!empty($matches)) {
680
+ $seopress_titles_cf_template_variables_array = array();
681
+ $seopress_titles_cf_template_replace_array = array();
682
683
+ foreach ($matches['0'] as $key => $value) {
684
+ $seopress_titles_cf_template_variables_array[] = $value;
685
}
686
687
+ foreach ($matches['1'] as $key => $value) {
688
+ $seopress_titles_cf_template_replace_array[] = get_post_meta($post->ID,$value,true);
689
}
690
}
691
+
692
$seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
693
+
694
+ if (!empty($matches) && !empty($seopress_titles_cf_template_variables_array) && !empty($seopress_titles_cf_template_replace_array)) {
695
+ $seopress_titles_description_template = str_replace($seopress_titles_cf_template_variables_array, $seopress_titles_cf_template_replace_array, $seopress_titles_description_template);
696
+ }
697
+ } else {
698
+ setup_postdata( $post );
699
+ if ($seopress_excerpt !='' || get_the_content() !='') { //DEFAULT EXCERPT OR THE CONTENT
700
+ $seopress_titles_the_description = wp_trim_words(stripslashes_deep(wp_filter_nohtml_kses($seopress_excerpt)), 30);
701
702
$seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
703
}
704
+ }
705
+ } elseif (is_post_type_archive() && seopress_titles_archive_desc_option()) { //IS POST TYPE ARCHIVE
706
+ $seopress_titles_the_description = esc_attr(seopress_titles_archive_desc_option());
707
+
708
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
709
+ } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_desc_option()) { //IS TAX
710
+ if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_desc',true)) {
711
+ $seopress_titles_the_description = esc_attr(get_term_meta(get_queried_object()->{'term_id'},'_seopress_titles_desc',true));
712
+ } else {
713
+ $seopress_titles_the_description = esc_attr(seopress_titles_tax_desc_option());
714
715
$seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
716
+ }
717
+ } elseif (is_author() && seopress_titles_archives_author_desc_option()) { //IS AUTHOR
718
+ $seopress_titles_the_description = esc_attr(seopress_titles_archives_author_desc_option());
719
+
720
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
721
+ } elseif (is_date() && seopress_titles_archives_date_desc_option()) { //IS DATE
722
+ $seopress_titles_the_description = esc_attr(seopress_titles_archives_date_desc_option());
723
724
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
725
+ } elseif (is_search() && seopress_titles_archives_search_desc_option()) { //IS SEARCH
726
+ $seopress_titles_the_description = esc_attr(seopress_titles_archives_search_desc_option());
727
728
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
729
+ } elseif (is_404() && seopress_titles_archives_404_desc_option()) { //IS 404
730
+ $seopress_titles_the_description = esc_attr(seopress_titles_archives_404_desc_option());
731
+
732
+ $seopress_titles_description_template = str_replace($seopress_titles_template_variables_array, $seopress_titles_template_replace_array, $seopress_titles_the_description);
733
}
734
+ //Hook on meta description - 'seopress_titles_desc'
735
+ if (has_filter('seopress_titles_desc')) {
736
+ $seopress_titles_description_template = apply_filters('seopress_titles_desc', $seopress_titles_description_template);
737
+ }
738
+ //Return Title tag
739
+ return $seopress_titles_description_template;
740
+ }
741
+ function seopress_titles_the_description() {
742
+ $html = '<meta name="description" content="'.seopress_titles_the_description_content().'" />';
743
+ $html .= "\n";
744
+ echo $html;
745
+ }
746
+ add_action( 'wp_head', 'seopress_titles_the_description', 1 );
747
+
748
+ //Advanced
749
+ //noindex
750
+ //Single CPT noindex
751
+ function seopress_titles_single_cpt_noindex_option() {
752
+ global $post;
753
+ $seopress_get_current_cpt = get_post_type($post);
754
+
755
+ $seopress_titles_single_cpt_noindex_option = get_option("seopress_titles_option_name");
756
+ if ( ! empty ( $seopress_titles_single_cpt_noindex_option ) ) {
757
+ foreach ($seopress_titles_single_cpt_noindex_option as $key => $seopress_titles_single_cpt_noindex_value)
758
+ $options[$key] = $seopress_titles_single_cpt_noindex_value;
759
+ if (isset($seopress_titles_single_cpt_noindex_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['noindex'])) {
760
+ return $seopress_titles_single_cpt_noindex_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['noindex'];
761
+ }
762
+ }
763
+ };
764
+
765
+ //Archive CPT noindex
766
+ function seopress_titles_archive_cpt_noindex_option() {
767
+ global $post;
768
+ $seopress_get_current_cpt = get_post_type($post);
769
+
770
+ $seopress_titles_archive_cpt_noindex_option = get_option("seopress_titles_option_name");
771
+ if ( ! empty ( $seopress_titles_archive_cpt_noindex_option ) ) {
772
+ foreach ($seopress_titles_archive_cpt_noindex_option as $key => $seopress_titles_archive_cpt_noindex_value)
773
+ $options[$key] = $seopress_titles_archive_cpt_noindex_value;
774
+ if (isset($seopress_titles_archive_cpt_noindex_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['noindex'])) {
775
+ return $seopress_titles_archive_cpt_noindex_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['noindex'];
776
+ }
777
+ }
778
+ };
779
+
780
+ //Tax archive noindex
781
+ function seopress_titles_tax_noindex_option() {
782
+ $queried_object = get_queried_object();
783
+ $seopress_get_current_tax = $queried_object->taxonomy;
784
+
785
+ if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_index',true) == 'yes') {
786
+ return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_index',true);
787
+ } else {
788
+ $seopress_titles_tax_noindex_option = get_option("seopress_titles_option_name");
789
+ if ( ! empty ( $seopress_titles_tax_noindex_option ) ) {
790
+ foreach ($seopress_titles_tax_noindex_option as $key => $seopress_titles_tax_noindex_value)
791
+ $options[$key] = $seopress_titles_tax_noindex_value;
792
+ if (isset($seopress_titles_tax_noindex_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['noindex'])) {
793
+ return $seopress_titles_tax_noindex_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['noindex'];
794
}
795
}
796
+ }
797
+ };
798
+
799
+ //noindex Author archives
800
+ function seopress_titles_archives_author_noindex_option() {
801
+ $seopress_titles_archives_author_noindex_option = get_option("seopress_titles_option_name");
802
+ if ( ! empty ( $seopress_titles_archives_author_noindex_option ) ) {
803
+ foreach ($seopress_titles_archives_author_noindex_option as $key => $seopress_titles_archives_author_noindex_value)
804
+ $options[$key] = $seopress_titles_archives_author_noindex_value;
805
+ if (isset($seopress_titles_archives_author_noindex_option['seopress_titles_archives_author_noindex'])) {
806
+ return $seopress_titles_archives_author_noindex_option['seopress_titles_archives_author_noindex'];
807
+ }
808
+ }
809
+ };
810
+
811
+ //noindex Date archives
812
+ function seopress_titles_archives_date_noindex_option() {
813
+ $seopress_titles_archives_date_noindex_option = get_option("seopress_titles_option_name");
814
+ if ( ! empty ( $seopress_titles_archives_date_noindex_option ) ) {
815
+ foreach ($seopress_titles_archives_date_noindex_option as $key => $seopress_titles_archives_date_noindex_value)
816
+ $options[$key] = $seopress_titles_archives_date_noindex_value;
817
+ if (isset($seopress_titles_archives_date_noindex_option['seopress_titles_archives_date_noindex'])) {
818
+ return $seopress_titles_archives_date_noindex_option['seopress_titles_archives_date_noindex'];
819
+ }
820
+ }
821
+ };
822
+
823
+ //noindex Search
824
+ function seopress_titles_archives_search_title_noindex_option() {
825
+ $seopress_titles_archives_search_title_noindex_option = get_option("seopress_titles_option_name");
826
+ if ( ! empty ( $seopress_titles_archives_search_title_noindex_option ) ) {
827
+ foreach ($seopress_titles_archives_search_title_noindex_option as $key => $seopress_titles_archives_search_title_noindex_value)
828
+ $options[$key] = $seopress_titles_archives_search_title_noindex_value;
829
+ if (isset($seopress_titles_archives_search_title_noindex_option['seopress_titles_archives_search_title_noindex'])) {
830
+ return $seopress_titles_archives_search_title_noindex_option['seopress_titles_archives_search_title_noindex'];
831
+ }
832
+ }
833
+ };
834
+
835
+ //noindex Global Advanced tab
836
+ function seopress_titles_noindex_option() {
837
+ $seopress_titles_noindex_option = get_option("seopress_titles_option_name");
838
+ if ( ! empty ( $seopress_titles_noindex_option ) ) {
839
+ foreach ($seopress_titles_noindex_option as $key => $seopress_titles_noindex_value)
840
+ $options[$key] = $seopress_titles_noindex_value;
841
+ if (isset($seopress_titles_noindex_option['seopress_titles_noindex'])) {
842
+ return $seopress_titles_noindex_option['seopress_titles_noindex'];
843
+ }
844
+ }
845
+ };
846
847
+ //noindex single CPT
848
+ function seopress_titles_noindex_post_option() {
849
+ $_seopress_robots_index = get_post_meta(get_the_ID(),'_seopress_robots_index',true);
850
+ if ($_seopress_robots_index == 'yes') {
851
+ return $_seopress_robots_index;
852
+ }
853
+ };
854
+
855
+ //noindex WooCommerce page
856
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
857
+ if (is_plugin_active('wp-seopress-pro/seopress-pro.php')) {
858
+ //Cart page
859
+ function seopress_woocommerce_cart_page_no_index_option() {
860
+ $seopress_woocommerce_cart_page_no_index_option = get_option("seopress_pro_option_name");
861
+ if ( ! empty ( $seopress_woocommerce_cart_page_no_index_option ) ) {
862
+ foreach ($seopress_woocommerce_cart_page_no_index_option as $key => $seopress_woocommerce_cart_page_no_index_value)
863
+ $options[$key] = $seopress_woocommerce_cart_page_no_index_value;
864
+ if (isset($seopress_woocommerce_cart_page_no_index_option['seopress_woocommerce_cart_page_no_index'])) {
865
+ return $seopress_woocommerce_cart_page_no_index_option['seopress_woocommerce_cart_page_no_index'];
866
}
867
}
868
+ }
869
+ //Checkout page
870
+ function seopress_woocommerce_checkout_page_no_index_option() {
871
+ $seopress_woocommerce_checkout_page_no_index_option = get_option("seopress_pro_option_name");
872
+ if ( ! empty ( $seopress_woocommerce_checkout_page_no_index_option ) ) {
873
+ foreach ($seopress_woocommerce_checkout_page_no_index_option as $key => $seopress_woocommerce_checkout_page_no_index_value)
874
+ $options[$key] = $seopress_woocommerce_checkout_page_no_index_value;
875
+ if (isset($seopress_woocommerce_checkout_page_no_index_option['seopress_woocommerce_checkout_page_no_index'])) {
876
+ return $seopress_woocommerce_checkout_page_no_index_option['seopress_woocommerce_checkout_page_no_index'];
877
}
878
}
879
+ }
880
+ //Customer Account
881
+ function seopress_woocommerce_customer_account_page_no_index_option() {
882
+ $seopress_woocommerce_customer_account_page_no_index_option = get_option("seopress_pro_option_name");
883
+ if ( ! empty ( $seopress_woocommerce_customer_account_page_no_index_option ) ) {
884
+ foreach ($seopress_woocommerce_customer_account_page_no_index_option as $key => $seopress_woocommerce_customer_account_page_no_index_value)
885
+ $options[$key] = $seopress_woocommerce_customer_account_page_no_index_value;
886
+ if (isset($seopress_woocommerce_customer_account_page_no_index_option['seopress_woocommerce_customer_account_page_no_index'])) {
887
+ return $seopress_woocommerce_customer_account_page_no_index_option['seopress_woocommerce_customer_account_page_no_index'];
888
}
889
}
890
}
891
+ }
892
893
+ function seopress_titles_noindex_bypass() {
894
+ //init
895
+ $seopress_titles_noindex ='';
896
+
897
+ if (seopress_titles_noindex_option()) { //Single CPT Global Advanced tab
898
+ $seopress_titles_noindex = seopress_titles_noindex_option();
899
+ } elseif (is_singular() && seopress_titles_single_cpt_noindex_option()) { //Single CPT Global
900
+ $seopress_titles_noindex = seopress_titles_single_cpt_noindex_option();
901
+ } elseif (is_singular() && seopress_titles_noindex_post_option() ) { //Single CPT Metaboxe
902
+ $seopress_titles_noindex = seopress_titles_noindex_post_option();
903
+ } elseif (is_post_type_archive() && seopress_titles_archive_cpt_noindex_option() ) { //IS POST TYPE ARCHIVE
904
+ $seopress_titles_noindex = seopress_titles_archive_cpt_noindex_option();
905
+ } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_noindex_option()) { //IS TAX
906
+ $seopress_titles_noindex = seopress_titles_tax_noindex_option();
907
+ } elseif (is_author() && seopress_titles_archives_author_noindex_option()) { //IS Author archive
908
+ $seopress_titles_noindex = seopress_titles_archives_author_noindex_option();
909
+ } elseif (is_date() && seopress_titles_archives_date_noindex_option()) { //IS Date archive
910
+ $seopress_titles_noindex = seopress_titles_archives_date_noindex_option();
911
+ } elseif (is_search() && seopress_titles_archives_search_title_noindex_option()) {
912
+ $seopress_titles_noindex = seopress_titles_archives_search_title_noindex_option();
913
+ } elseif (function_exists('is_cart') && function_exists('seopress_woocommerce_cart_page_no_index_option') && (is_cart() && seopress_woocommerce_cart_page_no_index_option())) { //IS WooCommerce Cart page
914
+ $seopress_titles_noindex = seopress_woocommerce_cart_page_no_index_option();
915
+ } elseif (function_exists('is_checkout') && function_exists('seopress_woocommerce_checkout_page_no_index_option') && (is_checkout() && seopress_woocommerce_checkout_page_no_index_option())) { //IS WooCommerce Checkout page
916
+ $seopress_titles_noindex = seopress_woocommerce_checkout_page_no_index_option();
917
+ } elseif (function_exists('is_account_page') && function_exists('seopress_woocommerce_customer_account_page_no_index_option') && (is_account_page() && seopress_woocommerce_customer_account_page_no_index_option())) { //IS WooCommerce Customer account pages
918
+ $seopress_titles_noindex = seopress_woocommerce_customer_account_page_no_index_option();
919
+ } elseif (function_exists('is_wc_endpoint_url') && function_exists('seopress_woocommerce_customer_account_page_no_index_option') && (is_wc_endpoint_url() && seopress_woocommerce_customer_account_page_no_index_option())) { //IS WooCommerce Customer account pages
920
+ $seopress_titles_noindex = seopress_woocommerce_customer_account_page_no_index_option();
921
+ } elseif(is_404()) { //Is 404 page
922
+ $seopress_titles_noindex = "noindex";
923
}
924
+ //Return noindex tag
925
+ return $seopress_titles_noindex;
926
+ }
927
928
+ //nofollow
929
+ //Single CPT nofollow
930
+ function seopress_titles_single_cpt_nofollow_option() {
931
+ global $post;
932
+ $seopress_get_current_cpt = get_post_type($post);
933
+
934
+ $seopress_titles_single_cpt_nofollow_option = get_option("seopress_titles_option_name");
935
+ if ( ! empty ( $seopress_titles_single_cpt_nofollow_option ) ) {
936
+ foreach ($seopress_titles_single_cpt_nofollow_option as $key => $seopress_titles_single_cpt_nofollow_value)
937
+ $options[$key] = $seopress_titles_single_cpt_nofollow_value;
938
+ if (isset($seopress_titles_single_cpt_nofollow_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['nofollow'])) {
939
+ return $seopress_titles_single_cpt_nofollow_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['nofollow'];
940
+ }
941
+ }
942
+ };
943
+
944
+ //Archive CPT nofollow
945
+ function seopress_titles_archive_cpt_nofollow_option() {
946
+ global $post;
947
+ $seopress_get_current_cpt = get_post_type($post);
948
+
949
+ $seopress_titles_archive_cpt_nofollow_option = get_option("seopress_titles_option_name");
950
+ if ( ! empty ( $seopress_titles_archive_cpt_nofollow_option ) ) {
951
+ foreach ($seopress_titles_archive_cpt_nofollow_option as $key => $seopress_titles_archive_cpt_nofollow_value)
952
+ $options[$key] = $seopress_titles_archive_cpt_nofollow_value;
953
+ if (isset($seopress_titles_archive_cpt_nofollow_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['nofollow'])) {
954
+ return $seopress_titles_archive_cpt_nofollow_option['seopress_titles_archive_titles'][$seopress_get_current_cpt]['nofollow'];
955
+ }
956
+ }
957
+ };
958
+
959
+ //Tax archive nofollow
960
+ function seopress_titles_tax_nofollow_option() {
961
+ $queried_object = get_queried_object();
962
+ $seopress_get_current_tax = $queried_object->taxonomy;
963
+
964
+ if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_follow',true) == 'yes') {
965
+ return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_follow',true);
966
+ } else {
967
+ $seopress_titles_tax_nofollow_option = get_option("seopress_titles_option_name");
968
+ if ( ! empty ( $seopress_titles_tax_nofollow_option ) ) {
969
+ foreach ($seopress_titles_tax_nofollow_option as $key => $seopress_titles_tax_nofollow_value)
970
+ $options[$key] = $seopress_titles_tax_nofollow_value;
971
+ if (isset($seopress_titles_tax_nofollow_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['nofollow'])) {
972
+ return $seopress_titles_tax_nofollow_option['seopress_titles_tax_titles'][$seopress_get_current_tax]['nofollow'];
973
}
974
}
975
}
976
+ };
977
+
978
+ //nofollow Global Avanced tab
979
+ function seopress_titles_nofollow_option() {
980
+ $seopress_titles_nofollow_option = get_option("seopress_titles_option_name");
981
+ if ( ! empty ( $seopress_titles_nofollow_option ) ) {
982
+ foreach ($seopress_titles_nofollow_option as $key => $seopress_titles_nofollow_value)
983
+ $options[$key] = $seopress_titles_nofollow_value;
984
+ if (isset($seopress_titles_nofollow_option['seopress_titles_nofollow'])) {
985
+ return $seopress_titles_nofollow_option['seopress_titles_nofollow'];
986
+ }
987
+ }
988
+ };
989
990
+ function seopress_titles_nofollow_post_option() {
991
+ $_seopress_robots_follow = get_post_meta(get_the_ID(),'_seopress_robots_follow',true);
992
+ if ($_seopress_robots_follow == 'yes') {
993
+ return $_seopress_robots_follow;
994
+ }
995
+ };
996
+
997
+ function seopress_titles_nofollow_bypass() {
998
+ //init
999
+ $seopress_titles_nofollow ='';
1000
+
1001
+ if (seopress_titles_nofollow_option()) { //Single CPT Global Advanced tab
1002
+ $seopress_titles_nofollow = seopress_titles_nofollow_option();
1003
+ } elseif (is_singular() && seopress_titles_single_cpt_nofollow_option()) { //Single CPT Global
1004
+ $seopress_titles_nofollow = seopress_titles_single_cpt_nofollow_option();
1005
+ } elseif (is_singular() && seopress_titles_nofollow_post_option() ) { //Single CPT Metaboxe
1006
+ $seopress_titles_nofollow = seopress_titles_nofollow_post_option();
1007
+ } elseif (is_post_type_archive() && seopress_titles_archive_cpt_nofollow_option() ) { //IS POST TYPE ARCHIVE
1008
+ $seopress_titles_nofollow = seopress_titles_archive_cpt_nofollow_option();
1009
+ } elseif ((is_tax() || is_category() || is_tag()) && seopress_titles_tax_nofollow_option()) { //IS TAX
1010
+ $seopress_titles_nofollow = seopress_titles_tax_nofollow_option();
1011
+ }
1012
+ return $seopress_titles_nofollow;
1013
+ };
1014
+
1015
+ //date in SERPs
1016
+ function seopress_titles_single_cpt_date_option() {
1017
+ global $post;
1018
+ $seopress_get_current_cpt = get_post_type($post);
1019
+
1020
+ $seopress_titles_single_cpt_date_option = get_option("seopress_titles_option_name");
1021
+ if ( ! empty ( $seopress_titles_single_cpt_date_option ) ) {
1022
+ foreach ($seopress_titles_single_cpt_date_option as $key => $seopress_titles_single_cpt_date_value)
1023
+ $options[$key] = $seopress_titles_single_cpt_date_value;
1024
+ if (isset($seopress_titles_single_cpt_date_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['date'])) {
1025
+ return $seopress_titles_single_cpt_date_option['seopress_titles_single_titles'][$seopress_get_current_cpt]['date'];
1026
+ }
1027
+ }
1028
+ };
1029
+
1030
+ function seopress_titles_single_cpt_date_hook() {
1031
+ if (!is_front_page() && !is_home()) {
1032
+ if (is_singular() && seopress_titles_single_cpt_date_option() =='1') {
1033
+ $seopress_get_current_pub_post_date = get_the_date('c');
1034
+ $seopress_get_current_up_post_date = get_the_modified_date('c');
1035
+ echo '<meta property="article:published_time" content="'.$seopress_get_current_pub_post_date.'" />';
1036
+ echo "\n";
1037
+ echo '<meta property="article:modified_time" content="'.$seopress_get_current_up_post_date.'" />';
1038
+ echo "\n";
1039
+ echo '<meta property="og:updated_time" content="'.$seopress_get_current_up_post_date.'" />';
1040
+ echo "\n";
1041
}
1042
+ }
1043
+ }
1044
+ add_action( 'wp_head', 'seopress_titles_single_cpt_date_hook', 1 );
1045
+
1046
+ //noodp
1047
+ function seopress_titles_noodp_option() {
1048
+ $seopress_titles_noodp_option = get_option("seopress_titles_option_name");
1049
+ if ( ! empty ( $seopress_titles_noodp_option ) ) {
1050
+ foreach ($seopress_titles_noodp_option as $key => $seopress_titles_noodp_value)
1051
+ $options[$key] = $seopress_titles_noodp_value;
1052
+ if (isset($seopress_titles_noodp_option['seopress_titles_noodp'])) {
1053
+ return $seopress_titles_noodp_option['seopress_titles_noodp'];
1054
+ }
1055
+ }
1056
+ };
1057
1058
+ function seopress_titles_noodp_post_option() {
1059
+ $_seopress_robots_odp = get_post_meta(get_the_ID(),'_seopress_robots_odp',true);
1060
+ if ($_seopress_robots_odp == 'yes') {
1061
+ return $_seopress_robots_odp;
1062
+ }
1063
+ };
1064
1065
+ function seopress_titles_noodp_bypass() {
1066
+ if (seopress_titles_noodp_option()) {
1067
+ return seopress_titles_noodp_option();
1068
+ }
1069
+ elseif (is_singular() && seopress_titles_noodp_post_option()) {
1070
+ return seopress_titles_noodp_post_option();
1071
+ } elseif (is_tax() || is_category() || is_tag()) {
1072
+ if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_odp',true) == 'yes') {
1073
+ return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_odp',true);
1074
}
1075
+ }
1076
+ };
1077
+
1078
+ //noarchive
1079
+ function seopress_titles_noarchive_option() {
1080
+ $seopress_titles_noarchive_option = get_option("seopress_titles_option_name");
1081
+ if ( ! empty ( $seopress_titles_noarchive_option ) ) {
1082
+ foreach ($seopress_titles_noarchive_option as $key => $seopress_titles_noarchive_value)
1083
+ $options[$key] = $seopress_titles_noarchive_value;
1084
+ if (isset($seopress_titles_noarchive_option['seopress_titles_noarchive'])) {
1085
+ return $seopress_titles_noarchive_option['seopress_titles_noarchive'];
1086
+ }
1087
+ }
1088
+ };
1089
1090
+ function seopress_titles_noarchive_post_option() {
1091
+ $_seopress_robots_archive = get_post_meta(get_the_ID(),'_seopress_robots_archive',true);
1092
+ if ($_seopress_robots_archive == 'yes') {
1093
+ return $_seopress_robots_archive;
1094
+ }
1095
+ };
1096
1097
+ function seopress_titles_noarchive_bypass() {
1098
+ if (seopress_titles_noarchive_option()) {
1099
+ return seopress_titles_noarchive_option();
1100
+ }
1101
+ elseif (is_singular() && seopress_titles_noarchive_post_option()) {
1102
+ return seopress_titles_noarchive_post_option();
1103
+ } elseif (is_tax() || is_category() || is_tag()) {
1104
+ if (get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_archive',true) == 'yes') {
1105
+ return get_term_meta(get_queried_object()->{'term_id'},'_seopress_robots_archive',true);