-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_in_one_seo_pack.php
893 lines (806 loc) · 34.5 KB
/
all_in_one_seo_pack.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
<?php
/*
Plugin Name: All in One SEO Pack
Plugin URI: http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/
Description: Out-of-the-box SEO for your Wordpress blog.
Version: 1.2.8.6
Author: uberdose
Author URI: http://wp.uberdose.com/
*/
/*
Copyright (C) 2007 uberdose (seopack AT uberdose DOT com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class All_in_One_SEO_Pack {
var $version = "1.2.8.6";
/**
* Max numbers of chars in auto-generated description.
*/
var $maximum_description_length = 160;
/**
* Minimum number of chars an excerpt should be so that it can be used
* as description. Touch only if you know what you're doing.
*/
var $minimum_description_length = 1;
var $table_prefix = "aiosp_";
var $table_categries;
var $db_version = '0.1';
var $ob_start_detected = false;
var $title_start = -1;
var $title_end = -1;
var $orig_title = '';
function template_redirect() {
if (is_feed()) {
return;
}
if (get_option('aiosp_rewrite_titles')) {
ob_start(array($this, 'output_callback_for_title'));
}
}
function output_callback_for_title($content) {
return $this->rewrite_title($content);
}
function init() {
if(function_exists('load_plugin_textdomain')) {
load_plugin_textdomain('all_in_one_seo_pack', 'wp-content/plugins/all-in-one-seo-pack');
}
//$this->db_install();
}
function is_static_front_page() {
global $wp_query;
$post = $wp_query->get_queried_object();
return get_option('show_on_front') == 'page' && is_page() && $post->ID == get_option('page_on_front');
}
function is_static_posts_page() {
global $wp_query;
$post = $wp_query->get_queried_object();
return get_option('show_on_front') == 'page' && is_home() && $post->ID == get_option('page_for_posts');
}
function wp_head() {
if (is_feed()) {
return;
}
if (get_option('aiosp_rewrite_titles')) {
// make the title rewrite as short as possible
$active_handlers = ob_list_handlers();
if (sizeof($active_handlers) > 0 &&
strtolower($active_handlers[sizeof($active_handlers) - 1]) ==
strtolower('All_in_One_SEO_Pack::output_callback_for_title')) {
ob_end_flush();
} else {
// if we get here there *could* be trouble with another plugin :(
$this->ob_start_detected = true;
echo "\n";
foreach (ob_list_handlers() as $handler) {
echo "<!-- all in one seo pack output handler $handler -->\n";
}
}
}
global $wp_query;
$post = $wp_query->get_queried_object();
$meta_string = null;
echo "<!-- all in one seo pack $this->version ";
if ($this->ob_start_detected) {
echo "ob_start_detected ";
}
echo "[$this->title_start,$this->title_end,$this->orig_title] ";
echo "-->\n";
if ((is_home() && !$this->is_static_posts_page() && get_option('aiosp_home_keywords')) || $this->is_static_front_page()) {
$keywords = trim(get_option('aiosp_home_keywords'));
} else {
$keywords = $this->get_all_keywords();
}
if (is_single() || is_page()) {
if ($this->is_static_front_page()) {
$description = trim(stripslashes(get_option('aiosp_home_description')));
} else {
$description = $this->get_post_description($post);
}
} else if (is_home()) {
if ($this->is_static_posts_page()) {
$description = $this->get_post_description(get_post(get_option('page_for_posts')));
} else {
$description = trim(stripslashes(get_option('aiosp_home_description')));
}
} else if (is_category()) {
$description = category_description();
}
if (isset($description) && strlen($description) > $this->minimum_description_length) {
$description = str_replace('"', '', $description);
// replace newlines on mac / windows?
$description = str_replace("\r\n", ' ', $description);
// maybe linux uses this alone
$description = str_replace("\n", ' ', $description);
if (isset($meta_string)) {
$meta_string .= "\n";
}
$meta_string .= sprintf("<meta name=\"description\" content=\"%s\"/>", $description);
}
if (isset ($keywords) && !empty($keywords)) {
if (isset($meta_string)) {
$meta_string .= "\n";
}
$meta_string .= sprintf("<meta name=\"keywords\" content=\"%s\"/>", $keywords);
}
if (function_exists('is_tag')) {
$is_tag = is_tag();
}
if ((is_category() && get_option('aiosp_category_noindex')) ||
(!is_category() && is_archive() &&!$is_tag && get_option('aiosp_archive_noindex')) ||
(get_option('aiosp_tags_noindex') && $is_tag)) {
if (isset($meta_string)) {
$meta_string .= "\n";
}
$meta_string = '<meta name="robots" content="noindex,follow" />';
}
if ($meta_string != null) {
echo "$meta_string\n";
}
}
function get_post_description($post) {
$description = trim(stripslashes(get_post_meta($post->ID, "description", true)));
if (!$description) {
$description = $this->trim_excerpt_without_filters_full_length($post->post_excerpt);
if (!$description && get_option("aiosp_generate_descriptions")) {
$description = $this->trim_excerpt_without_filters($post->post_content);
}
}
return $description;
}
function replace_title($content, $title) {
$title_tag_start = "<title>";
$title_tag_end = "</title>";
$len_start = strlen($title_tag_start);
$len_end = strlen($title_tag_end);
$title = stripslashes(trim($title));
$start = strpos($content, "<title>");
$end = strpos($content, "</title>");
$this->title_start = $start;
$this->title_end = $end;
$this->orig_title = $title;
if ($start && $end) {
$header = substr($content, 0, $start + $len_start) . $title . substr($content, $end);
} else {
$header = $content . "<title>$title</title>";
}
return $header;
}
function rewrite_title($header) {
global $wp_query;
if (!$wp_query) {
$header .= "<!-- no wp_query found! -->\n";
return $header;
}
$post = $wp_query->get_queried_object();
// the_search_query() is not suitable, it cannot just return
global $s;
if (is_home()) {
if ($this->is_static_posts_page()) {
$title = get_post_meta(get_option('page_for_posts'), "title", true);
if (!$title) {
$title = wp_title('', false);
}
$title_format = get_option('aiosp_page_title_format');
$new_title = str_replace('%blog_title%', get_bloginfo('name'), $title_format);
$new_title = str_replace('%page_title%', $title, $new_title);
$new_title = str_replace('%blog_description%', get_bloginfo('description'), $new_title);
$title = trim($new_title);
$header = $this->replace_title($header, $title);
} else {
if (get_option('aiosp_home_title')) {
$header = $this->replace_title($header, get_option('aiosp_home_title'));
}
}
} else if (is_single()) {
$categories = get_the_category();
$category = '';
if (count($categories) > 0) {
$category = $categories[0]->cat_name;
}
$title = get_post_meta($post->ID, "title", true);
if (!$title) {
$title = get_post_meta($post->ID, "title_tag", true);
if (!$title) {
$title = wp_title('', false);
}
}
$title_format = get_option('aiosp_post_title_format');
$new_title = str_replace('%blog_title%', get_bloginfo('name'), $title_format);
$new_title = str_replace('%blog_description%', get_bloginfo('description'), $new_title);
$new_title = str_replace('%post_title%', $title, $new_title);
$new_title = str_replace('%category%', $category, $new_title);
$title = $new_title;
$title = trim($title);
$header = $this->replace_title($header, $title);
} else if (is_search() && isset($s) && !empty($s)) {
if (function_exists('attribute_escape')) {
$search = attribute_escape(stripslashes($s));
} else {
$search = wp_specialchars(stripslashes($s), true);
}
$search = $this->capitalize($search);
$title_format = get_option('aiosp_search_title_format');
$title = str_replace('%blog_title%', get_bloginfo('name'), $title_format);
$title = str_replace('%blog_description%', get_bloginfo('description'), $title);
$title = str_replace('%search%', $search, $title);
$header = $this->replace_title($header, $title);
} else if (is_category() && !is_feed()) {
$category_description = category_description();
$category_name = ucwords(single_cat_title('', false));
$title_format = get_option('aiosp_category_title_format');
$title = str_replace('%category_title%', $category_name, $title_format);
$title = str_replace('%category_description%', $category_description, $title);
$title = str_replace('%blog_title%', get_bloginfo('name'), $title);
$title = str_replace('%blog_description%', get_bloginfo('description'), $title);
$header = $this->replace_title($header, $title);
} else if (is_page()) {
if ($this->is_static_front_page()) {
if (get_option('aiosp_home_title')) {
$header = $this->replace_title($header, get_option('aiosp_home_title'));
}
} else {
$title = get_post_meta($post->ID, "title", true);
if (!$title) {
$title = wp_title('', false);
}
$title_format = get_option('aiosp_page_title_format');
$new_title = str_replace('%blog_title%', get_bloginfo('name'), $title_format);
$new_title = str_replace('%blog_description%', get_bloginfo('description'), $new_title);
$new_title = str_replace('%page_title%', $title, $new_title);
$title = trim($new_title);
$header = $this->replace_title($header, $title);
}
} else if (function_exists('is_tag') && is_tag()) {
global $utw;
if ($utw) {
$tags = $utw->GetCurrentTagSet();
$tag = $tags[0]->tag;
$tag = str_replace('-', ' ', $tag);
} else {
// wordpress > 2.3
$tag = wp_title('', false);
}
if ($tag) {
$tag = $this->capitalize($tag);
$title_format = get_option('aiosp_tag_title_format');
$title = str_replace('%blog_title%', get_bloginfo('name'), $title_format);
$title = str_replace('%blog_description%', get_bloginfo('description'), $title);
$title = str_replace('%tag%', $tag, $title);
$header = $this->replace_title($header, $title);
}
} else if (is_archive()) {
$date = wp_title('', false);
$title_format = get_option('aiosp_archive_title_format');
$new_title = str_replace('%blog_title%', get_bloginfo('name'), $title_format);
$new_title = str_replace('%blog_description%', get_bloginfo('description'), $new_title);
$new_title = str_replace('%date%', $date, $new_title);
$title = trim($new_title);
$header = $this->replace_title($header, $title);
}
return $header;
}
function capitalize($s) {
$s = trim($s);
$tokens = explode(' ', $s);
while (list($key, $val) = each($tokens)) {
$tokens[$key] = trim($tokens[$key]);
$tokens[$key] = strtoupper(substr($tokens[$key], 0, 1)) . substr($tokens[$key], 1);
}
$s = implode(' ', $tokens);
return $s;
}
function trim_excerpt_without_filters($text) {
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$max = $this->maximum_description_length;
if ($max < strlen($text)) {
while($text[$max] != ' ' && $max > $this->minimum_description_length) {
$max--;
}
}
$text = substr($text, 0, $max);
return trim(stripslashes($text));
}
function trim_excerpt_without_filters_full_length($text) {
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
return trim(stripslashes($text));
}
/**
* @return comma-separated list of unique keywords
*/
function get_all_keywords() {
global $posts;
$keywords = array();
if (is_array($posts)) {
foreach ($posts as $post) {
if ($post) {
if (get_option('aiosp_use_categories') && !is_page()) {
$categories = get_the_category($post->ID);
foreach ($categories as $category) {
$keywords[] = $category->cat_name;
}
}
// Ultimate Tag Warrior integration
global $utw;
if ($utw) {
$tags = $utw->GetTagsForPost($post);
foreach ($tags as $tag) {
$tag = $tag->tag;
$tag = str_replace('_',' ', $tag);
$tag = str_replace('-',' ',$tag);
$tag = stripslashes($tag);
$keywords[] = $tag;
}
}
// WP 2.3 tags
if (function_exists('get_the_tags')) {
$tags = get_the_tags($post->ID);
if ($tags && is_array($tags)) {
foreach ($tags as $tag) {
$keywords[] = $tag->name;
}
}
}
// custom field keywords
$keywords_a = $keywords_i = null;
$description_a = $description_i = null;
$id = $post->ID;
$keywords_i = stripslashes(get_post_meta($post->ID, "keywords", true));
$keywords_i = str_replace('"', '', $keywords_i);
if (isset($keywords_i) && !empty($keywords_i)) {
$keywords[] = $keywords_i;
}
// autometa
$autometa = stripslashes(get_post_meta($post->ID, "autometa", true));
if (isset($autometa)) {
$autometa_array = explode(' ', $autometa);
foreach ($autometa_array as $e) {
$keywords[] = $e;
}
}
}
}
}
return $this->get_unique_keywords($keywords);
}
function get_meta_keywords() {
global $posts;
$keywords = array();
if (is_array($posts)) {
foreach ($posts as $post) {
if ($post) {
// custom field keywords
$keywords_a = $keywords_i = null;
$description_a = $description_i = null;
$id = $post->ID;
$keywords_i = stripslashes(get_post_meta($post->ID, "keywords", true));
$keywords_i = str_replace('"', '', $keywords_i);
if (isset($keywords_i) && !empty($keywords_i)) {
$keywords[] = $keywords_i;
}
}
}
}
return $this->get_unique_keywords($keywords);
}
function db_install() {
global $wpdb;
$this->table_categories = $wpdb->prefix . $this->table_prefix . "categories";
if(get_option('aiosp_db_version') != $this->db_version) {
$sql = "CREATE TABLE $this->table_categories (
ID bigint(20) NOT NULL auto_increment,
category_id bigint(20) NOT NULL default '0',
meta_title text NOT NULL,
meta_description text NOT NULL,
meta_keywords text NOT NULL,
PRIMARY KEY (ID),
KEY category_id (category_id));";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);
update_option('aiosp_db_version', $this->db_version);
}
}
function get_unique_keywords($keywords) {
$keywords_ar = array_unique($keywords);
return implode(',', $keywords_ar);
}
function post_meta_tags($id) {
$awmp_edit = $_POST["aiosp_edit"];
if (isset($awmp_edit) && !empty($awmp_edit)) {
$keywords = $_POST["aiosp_keywords"];
$description = $_POST["aiosp_description"];
$title = $_POST["aiosp_title"];
delete_post_meta($id, 'keywords');
delete_post_meta($id, 'description');
delete_post_meta($id, 'title');
if (isset($keywords) && !empty($keywords)) {
add_post_meta($id, 'keywords', $keywords);
}
if (isset($description) && !empty($description)) {
add_post_meta($id, 'description', $description);
}
if (isset($title) && !empty($title)) {
add_post_meta($id, 'title', $title);
}
}
}
function edit_category($id) {
global $wpdb;
$id = $wpdb->escape($id);
$awmp_edit = $_POST["aiosp_edit"];
if (isset($awmp_edit) && !empty($awmp_edit)) {
$keywords = $wpdb->escape($_POST["aiosp_keywords"]);
$title = $wpdb->escape($_POST["aiosp_title"]);
$old_category = $wpdb->get_row("select * from $this->table_categories where category_id=$id", OBJECT);
if ($old_category) {
$wpdb->query("update $this->table_categories
set meta_title='$title', meta_keywords='$keywords'
where category_id=$id");
} else {
$wpdb->query("insert into $this->table_categories(meta_title, meta_keywords, category_id)
values ('$title', '$keywords', $id");
}
//$wpdb->query("insert into $this->table_categories")
/*
delete_post_meta($id, 'keywords');
delete_post_meta($id, 'description');
delete_post_meta($id, 'title');
if (isset($keywords) && !empty($keywords)) {
add_post_meta($id, 'keywords', $keywords);
}
if (isset($description) && !empty($description)) {
add_post_meta($id, 'description', $description);
}
if (isset($title) && !empty($title)) {
add_post_meta($id, 'title', $title);
}
*/
}
}
function edit_category_form() {
global $post;
$keywords = stripslashes(get_post_meta($post->ID, 'keywords', true));
$title = stripslashes(get_post_meta($post->ID, 'title', true));
$description = stripslashes(get_post_meta($post->ID, 'description', true));
?>
<input value="aiosp_edit" type="hidden" name="aiosp_edit" />
<table class="editform" width="100%" cellspacing="2" cellpadding="5">
<tr>
<th width="33%" scope="row" valign="top">
<a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/"><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></a>
</th>
</tr>
<tr>
<th width="33%" scope="row" valign="top"><label for="aiosp_title"><?php _e('Title:', 'all_in_one_seo_pack') ?></label></th>
<td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="70"/></td>
</tr>
<tr>
<th width="33%" scope="row" valign="top"><label for="aiosp_keywords"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></label></th>
<td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="70"/></td>
</tr>
</table>
<?php
}
function add_meta_tags_textinput() {
global $post;
$post_id = $post;
if (is_object($post_id)) {
$post_id = $post_id->ID;
}
$keywords = htmlspecialchars(stripslashes(get_post_meta($post_id, 'keywords', true)));
$title = htmlspecialchars(stripslashes(get_post_meta($post_id, 'title', true)));
$description = htmlspecialchars(stripslashes(get_post_meta($post_id, 'description', true)));
?>
<input value="aiosp_edit" type="hidden" name="aiosp_edit" />
<table style="margin-bottom:40px; margin-top:30px;">
<tr>
<th style="text-align:left;" colspan="2">
<a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/"><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></a>
</th>
</tr>
<tr>
<th scope="row" style="text-align:right;"><?php _e('Title:', 'all_in_one_seo_pack') ?></th>
<td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="80"/></td>
</tr>
<tr>
<th scope="row" style="text-align:right;"><?php _e('Description:', 'all_in_one_seo_pack') ?></th>
<td><textarea name="aiosp_description" rows="1" cols="78"><?php echo $description ?></textarea><br/>
<?php _e('Most search engines use a maximum of 160 chars for the description.', 'all_in_one_seo_pack') ?>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right;"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></th>
<td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="80"/></td>
</tr>
</table>
<?php
}
function add_meta_tags_page_textinput() {
global $post;
$keywords = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'keywords', true)));
$description = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'description', true)));
$title = htmlspecialchars(stripslashes(get_post_meta($post->ID, 'title', true)));
?>
<input value="aiosp_edit" type="hidden" name="aiosp_edit"/>
<table style="margin-bottom:40px; margin-top:30px;">
<tr>
<th style="text-align:left;" colspan="2">
<a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/"><?php _e('All in One SEO Pack', 'all_in_one_seo_pack')?></a>
</th>
</tr>
<tr>
<th scope="row" style="text-align:right;"><?php _e('Title:', 'all_in_one_seo_pack') ?></th>
<td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="80" tabindex="1000"/></td>
</tr>
<tr>
<th scope="row" style="text-align:right;"><?php _e('Description:', 'all_in_one_seo_pack') ?></th>
<td><textarea name="aiosp_description" rows="1" cols="78" tabindex="1001"><?php echo $description ?></textarea><br/>
<?php _e('Most search engines use a maximum of 160 chars for the description.', 'all_in_one_seo_pack')?></td>
</tr>
<tr>
<th scope="row" style="text-align:right;"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></th>
<td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="80" tabindex="1002"/></td>
</tr>
</table>
<?php
}
function admin_menu() {
$file = __FILE__;
// hack for 1.5
global $wp_version;
if (substr($wp_version, 0, 3) == '1.5') {
$file = 'all-in-one-seo-pack/all_in_one_seo_pack.php';
}
add_submenu_page('options-general.php', __('All in One SEO', 'all_in_one_seo_pack'), __('All in One SEO', 'all_in_one_seo_pack'), 5, $file, array($this, 'plugin_menu'));
}
function plugin_menu() {
$message = null;
$message_updated = __("All in One SEO Options Updated.");
// update options
if ($_POST['action'] && $_POST['action'] == 'aiosp_update') {
$message = $message_updated;
update_option('aiosp_home_title', $_POST['aiosp_home_title']);
update_option('aiosp_home_description', $_POST['aiosp_home_description']);
update_option('aiosp_home_keywords', $_POST['aiosp_home_keywords']);
update_option('aiosp_max_words_excerpt', $_POST['aiosp_max_words_excerpt']);
update_option('aiosp_rewrite_titles', $_POST['aiosp_rewrite_titles']);
update_option('aiosp_post_title_format', $_POST['aiosp_post_title_format']);
update_option('aiosp_page_title_format', $_POST['aiosp_page_title_format']);
update_option('aiosp_category_title_format', $_POST['aiosp_category_title_format']);
update_option('aiosp_archive_title_format', $_POST['aiosp_archive_title_format']);
update_option('aiosp_tag_title_format', $_POST['aiosp_tag_title_format']);
update_option('aiosp_search_title_format', $_POST['aiosp_search_title_format']);
update_option('aiosp_use_categories', $_POST['aiosp_use_categories']);
update_option('aiosp_category_noindex', $_POST['aiosp_category_noindex']);
update_option('aiosp_archive_noindex', $_POST['aiosp_archive_noindex']);
update_option('aiosp_tags_noindex', $_POST['aiosp_tags_noindex']);
update_option('aiosp_generate_descriptions', $_POST['aiosp_generate_descriptions']);
update_option('aiosp_debug_info', $_POST['aiosp_debug_info']);
if (function_exists('wp_cache_flush')) {
wp_cache_flush();
}
}
?>
<?php if ($message) : ?>
<div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
<?php endif; ?>
<div id="dropmessage" class="updated" style="display:none;"></div>
<div class="wrap">
<h2><?php _e('All in One SEO Plugin Options', 'all_in_one_seo_pack'); ?></h2>
<p>
<?php _e("This is version ", 'all_in_one_seo_pack') ?><?php _e("$this->version. ", 'all_in_one_seo_pack') ?>
<a target="_blank" title="<?php _e('All in One SEO Plugin Release History', 'all_in_one_seo_pack')?>"
href="http://wp.uberdose.com/2007/07/27/all-in-one-seo-pack-release-history/"><php _e("Should I upgrade?", 'all_in_one_seo_pack')?>
</a>
</p>
<p>
<a target="_blank" title="<?php _e('All in One SEO Plugin Help', 'all_in_one_seo_pack') ?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/">
<?php _e('Help', 'all_in_one_seo_pack') ?></a>
| <a target="_blank" title="<?php _e('FAQ', 'all_in_one_seo_pack') ?>"
href="http://wp.uberdose.com/2007/07/11/all-in-one-seo-pack-faq/"><?php _e('FAQ', 'all_in_one_seo_pack') ?></a>
| <a target="_blank" title="<?php _e('All in One SEO Plugin Feedback', 'all_in_one_seo_pack') ?>"
href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/#respond"><?php _e('Feedback', 'all_in_one_seo_pack') ?></a>
| <a target="_blank" title="<?php _e('All in One SEO Plugin Translations', 'all_in_one_seo_pack') ?>"
href="http://wp.uberdose.com/2007/10/02/translations-for-all-in-one-seo-pack/"><?php _e('Translations', 'all_in_one_seo_pack') ?></a>
</p>
<form name="dofollow" action="" method="post">
<table>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option Home Title', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#hometitle">
<?php _e('Home Title:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<textarea cols="60" rows="2" name="aiosp_home_title"><?php echo stripcslashes(get_option('aiosp_home_title')); ?></textarea>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option Home Description', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#homedescription">
<?php _e('Home Description:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<textarea cols="60" rows="2" name="aiosp_home_description"><?php echo stripcslashes(get_option('aiosp_home_description')); ?></textarea>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option Home Keywords', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#homekeywords">
<?php _e('Home Keywords (comma separated):', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<textarea cols="60" rows="2" name="aiosp_home_keywords"><?php echo stripcslashes(get_option('aiosp_home_keywords')); ?></textarea>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option Rewrite Titles', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#rewritetitles">
<?php _e('Rewrite Titles:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input type="checkbox" name="aiosp_rewrite_titles" <?php if (get_option('aiosp_rewrite_titles')) echo "checked=\"1\""; ?>/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Post Title Format', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#posttitleformat">
<?php _e('Post Title Format:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input size="59" name="aiosp_post_title_format" value="<?php echo stripcslashes(get_option('aiosp_post_title_format')); ?>"/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Page Title Format', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#pagetitleformat">
<?php _e('Page Title Format:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input size="59" name="aiosp_page_title_format" value="<?php echo stripcslashes(get_option('aiosp_page_title_format')); ?>"/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Category Title Format', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#categorytitleformat">
<?php _e('Category Title Format:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input size="59" name="aiosp_category_title_format" value="<?php echo stripcslashes(get_option('aiosp_category_title_format')); ?>"/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Archive Title Format', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#archivetitleformat">
<?php _e('Archive Title Format:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input size="59" name="aiosp_archive_title_format" value="<?php echo stripcslashes(get_option('aiosp_archive_title_format')); ?>"/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Tag Title Format', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#tagtitleformat">
<?php _e('Tag Title Format:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input size="59" name="aiosp_tag_title_format" value="<?php echo stripcslashes(get_option('aiosp_tag_title_format')); ?>"/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Search Title Format', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#searchtitleformat">
<?php _e('Search Title Format:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input size="59" name="aiosp_search_title_format" value="<?php echo stripcslashes(get_option('aiosp_search_title_format')); ?>"/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option Categories for META keywords', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#categorymetakeywords">
<?php _e('Use Categories for META keywords:', 'all_in_one_seo_pack')?>
</td>
<td>
<input type="checkbox" name="aiosp_use_categories" <?php if (get_option('aiosp_use_categories')) echo "checked=\"1\""; ?>/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option noindex for Categories', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#usenoindexforcategories">
<?php _e('Use noindex for Categories:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input type="checkbox" name="aiosp_category_noindex" <?php if (get_option('aiosp_category_noindex')) echo "checked=\"1\""; ?>/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option noindex for Archives', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#usenoindexforarchives">
<?php _e('Use noindex for Archives:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input type="checkbox" name="aiosp_archive_noindex" <?php if (get_option('aiosp_archive_noindex')) echo "checked=\"1\""; ?>/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Option noindex for Tag Archives', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#usenoindexfortagarchives">
<?php _e('Use noindex for Tag Archives:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input type="checkbox" name="aiosp_tags_noindex" <?php if (get_option('aiosp_tags_noindex')) echo "checked=\"1\""; ?>/>
</td>
</tr>
<tr>
<th scope="row" style="text-align:right; vertical-align:top;">
<a target="_blank" title="<?php _e('Help for Autogenerate Descriptions', 'all_in_one_seo_pack')?>" href="http://wp.uberdose.com/2007/05/11/all-in-one-seo-pack-help/#autogeneratedescriptions">
<?php _e('Autogenerate Descriptions:', 'all_in_one_seo_pack')?>
</a>
</td>
<td>
<input type="checkbox" name="aiosp_generate_descriptions" <?php if (get_option('aiosp_generate_descriptions')) echo "checked=\"1\""; ?>/>
</td>
</tr>
</table>
<p class="submit">
<input type="hidden" name="action" value="aiosp_update" />
<input type="hidden" name="page_options" value="aiosp_home_description" />
<input type="submit" name="Submit" value="<?php _e('Update Options', 'all_in_one_seo_pack')?> »" />
</p>
</form>
</div>
<?php
} // plugin_menu
}
add_option("aiosp_home_description", null, 'All in One SEO Plugin Home Description', 'yes');
add_option("aiosp_home_title", null, 'All in One SEO Plugin Home Title', 'yes');
add_option("aiosp_rewrite_titles", 1, 'All in One SEO Plugin Rewrite Titles', 'yes');
add_option("aiosp_use_categories", 1, 'All in One SEO Plugin Use Categories', 'yes');
add_option("aiosp_category_noindex", 1, 'All in One SEO Plugin Noindex for Categories', 'yes');
add_option("aiosp_archive_noindex", 1, 'All in One SEO Plugin Noindex for Archives', 'yes');
add_option("aiosp_tags_noindex", 1, 'All in One SEO Plugin Noindex for Tag Archives', 'yes');
add_option("aiosp_generate_descriptions", 0, 'All in One SEO Plugin Autogenerate Descriptions', 'yes');
add_option("aiosp_post_title_format", '%post_title% | %blog_title%', 'All in One SEO Plugin Post Title Format', 'yes');
add_option("aiosp_page_title_format", '%page_title% | %blog_title%', 'All in One SEO Plugin Page Title Format', 'yes');
add_option("aiosp_category_title_format", '%category_title% | %blog_title%', 'All in One SEO Plugin Category Title Format', 'yes');
add_option("aiosp_archive_title_format", '%date% | %blog_title%', 'All in One SEO Plugin Archive Title Format', 'yes');
add_option("aiosp_tag_title_format", '%tag% | %blog_title%', 'All in One SEO Plugin Tag Title Format', 'yes');
add_option("aiosp_search_title_format", '%search% | %blog_title%', 'All in One SEO Plugin Search Title Format', 'yes');
$aiosp = new All_in_One_SEO_Pack();
add_action('wp_head', array($aiosp, 'wp_head'));
add_action('template_redirect', array($aiosp, 'template_redirect'));
add_action('init', array($aiosp, 'init'));
add_action('simple_edit_form', array($aiosp, 'add_meta_tags_textinput'));
add_action('edit_form_advanced', array($aiosp, 'add_meta_tags_textinput'));
add_action('edit_page_form', array($aiosp, 'add_meta_tags_page_textinput'));
//add_action('edit_category_form', array($aiosp, 'edit_category_form'));
add_action('edit_post', array($aiosp, 'post_meta_tags'));
add_action('publish_post', array($aiosp, 'post_meta_tags'));
add_action('save_post', array($aiosp, 'post_meta_tags'));
add_action('edit_page_form', array($aiosp, 'post_meta_tags'));
//add_action('edit_category', array($aiosp, 'edit_category'));
add_action('admin_menu', array($aiosp, 'admin_menu'));
?>