PageRenderTime 66ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-content/plugins/all-in-one-seo-pack/aioseop.class.php

https://bitbucket.org/openfarmtech/weblog-content
PHP | 2273 lines | 1966 code | 170 blank | 137 comment | 192 complexity | 241d83c577a6736d3bbb13a95e8b4ac7 MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.0, LGPL-3.0, BSD-3-Clause, GPL-3.0, LGPL-2.1, AGPL-3.0, CC-BY-SA-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. class All_in_One_SEO_Pack {
  3. var $version = "1.6.12.1";
  4. /** Max numbers of chars in auto-generated description */
  5. var $maximum_description_length = 160;
  6. /** Minimum number of chars an excerpt should be so that it can be used
  7. * as description. Touch only if you know what you're doing
  8. */
  9. var $minimum_description_length = 1;
  10. var $ob_start_detected = false;
  11. var $title_start = -1;
  12. var $title_end = -1;
  13. /** The title before rewriting */
  14. var $orig_title = '';
  15. /** Temp filename for the latest version. */
  16. // var $upgrade_filename = 'temp.zip';
  17. /** Where to extract the downloaded newest version. */
  18. // var $upgrade_folder;
  19. /** Any error in upgrading. */
  20. // var $upgrade_error;
  21. /** Which zip to download in order to upgrade .*/
  22. // var $upgrade_url = 'http://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip';
  23. /** Filename of log file. */
  24. var $log_file;
  25. /** Flag whether there should be logging. */
  26. var $do_log;
  27. var $wp_version;
  28. var $aioseop_op;
  29. //var $aioseop_options = get_option('aioseop_options');
  30. function All_in_One_SEO_Pack() {
  31. global $wp_version;
  32. global $aioseop_options;
  33. $this->wp_version = $wp_version;
  34. $this->log_file = dirname(__FILE__) . '/all_in_one_seo_pack.log';
  35. if ($aioseop_options['aiosp_do_log']) {
  36. $this->do_log = true;
  37. } else {
  38. $this->do_log = false;
  39. }
  40. // $this->upgrade_filename = dirname(__FILE__) . '/' . $this->upgrade_filename;
  41. // $this->upgrade_folder = dirname(__FILE__);
  42. }
  43. /**
  44. * Convert a string to lower case
  45. * Compatible with mb_strtolower(), an UTF-8 friendly replacement for strtolower()
  46. */
  47. function strtolower($str) {
  48. global $UTF8_TABLES;
  49. return strtr($str, $UTF8_TABLES['strtolower']);
  50. }
  51. /**
  52. * Convert a string to upper case
  53. * Compatible with mb_strtoupper(), an UTF-8 friendly replacement for strtoupper()
  54. */
  55. function strtoupper($str) {
  56. global $UTF8_TABLES;
  57. return strtr($str, $UTF8_TABLES['strtoupper']);
  58. }
  59. function template_redirect() {
  60. global $wp_query;
  61. global $aioseop_options;
  62. $post = $wp_query->get_queried_object();
  63. if( $this->aioseop_mrt_exclude_this_page()){
  64. return;
  65. }
  66. if (is_feed()) {
  67. return;
  68. }
  69. if (is_single() || is_page()) {
  70. $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_disable', true)));
  71. if ($aiosp_disable) {
  72. return;
  73. }
  74. }
  75. if ($aioseop_options['aiosp_rewrite_titles']) {
  76. ob_start(array($this, 'output_callback_for_title'));
  77. }
  78. }
  79. function aioseop_mrt_exclude_this_page(){
  80. global $aioseop_options;
  81. $currenturl = trim($_SERVER['REQUEST_URI'],'/');
  82. /* echo "<br /><br />";
  83. echo $aioseop_options['aiosp_ex_pages'];
  84. echo "<br /><br />";
  85. */
  86. $excludedstuff = explode(',',$aioseop_options['aiosp_ex_pages']);
  87. foreach($excludedstuff as $exedd){
  88. //echo $exedd;
  89. $exedd = trim($exedd);
  90. if($exedd){
  91. if(stristr($currenturl, $exedd)){
  92. return true;
  93. }
  94. }
  95. }
  96. return false;
  97. }
  98. function output_callback_for_title($content) {
  99. return $this->rewrite_title($content);
  100. }
  101. //
  102. //CHECK IF ARRAY EXISTS IN DB, IF SO, GET ARRAY, ADD EVERYTHING, CHECK FOR ISSET?
  103. //
  104. function init() {
  105. if (function_exists('load_plugin_textdomain')) {
  106. if ( !defined('WP_PLUGIN_DIR') ) {
  107. load_plugin_textdomain('all_in_one_seo_pack', str_replace( ABSPATH, '', dirname(__FILE__)));
  108. } else {
  109. load_plugin_textdomain('all_in_one_seo_pack', false, dirname(plugin_basename(__FILE__)));
  110. }
  111. }
  112. /*
  113. if (function_exists('load_plugin_textdomain')) {
  114. load_plugin_textdomain('all_in_one_seo_pack', WP_PLUGIN_DIR . '/all-in-one-seo-pack');
  115. }
  116. */
  117. }
  118. function is_static_front_page() {
  119. global $wp_query;
  120. global $aioseop_options;
  121. $post = $wp_query->get_queried_object();
  122. return get_option('show_on_front') == 'page' && is_page() && $post->ID == get_option('page_on_front');
  123. }
  124. function is_static_posts_page() {
  125. global $wp_query;
  126. $post = $wp_query->get_queried_object();
  127. return get_option('show_on_front') == 'page' && is_home() && $post->ID == get_option('page_for_posts');
  128. }
  129. function get_base() {
  130. return '/'.end(explode('/', str_replace(array('\\','/all_in_one_seo_pack.php'),array('/',''),__FILE__)));
  131. }
  132. function seo_mrt_admin_head() {
  133. $home = get_settings('siteurl');
  134. $stylesheet = WP_PLUGIN_URL . '/all-in-one-seo-pack/style.css';
  135. echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
  136. }
  137. function wp_head() {
  138. if (is_feed()) {
  139. return;
  140. }
  141. global $wp_query;
  142. global $aioseop_options;
  143. $post = $wp_query->get_queried_object();
  144. $meta_string = null;
  145. if($this->is_static_posts_page()){
  146. $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
  147. }
  148. //echo("wp_head() " . wp_title('', false) . " is_home() => " . is_home() . ", is_page() => " . is_page() . ", is_single() => " . is_single() . ", is_static_front_page() => " . $this->is_static_front_page() . ", is_static_posts_page() => " . $this->is_static_posts_page());
  149. if (is_single() || is_page()) {
  150. $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_disable', true)));
  151. if ($aiosp_disable) {
  152. return;
  153. }
  154. }
  155. if( $this->aioseop_mrt_exclude_this_page()==TRUE ){
  156. return;
  157. }
  158. if ($aioseop_options['aiosp_rewrite_titles']) {
  159. // make the title rewrite as short as possible
  160. if (function_exists('ob_list_handlers')) {
  161. $active_handlers = ob_list_handlers();
  162. } else {
  163. $active_handlers = array();
  164. }
  165. if (sizeof($active_handlers) > 0 &&
  166. strtolower($active_handlers[sizeof($active_handlers) - 1]) ==
  167. strtolower('All_in_One_SEO_Pack::output_callback_for_title')) {
  168. ob_end_flush();
  169. } else {
  170. $this->log("another plugin interfering?");
  171. // if we get here there *could* be trouble with another plugin :(
  172. $this->ob_start_detected = true;
  173. if (function_exists('ob_list_handlers')) {
  174. foreach (ob_list_handlers() as $handler) {
  175. $this->log("detected output handler $handler");
  176. }
  177. }
  178. }
  179. }
  180. /*
  181. echo trim($_SERVER['REQUEST_URI'],'/');
  182. $currenturl = trim($_SERVER['REQUEST_URI'],'/');
  183. echo "<br /><br />";
  184. echo $aioseop_options['aiosp_ex_pages'];
  185. echo "<br /><br />";
  186. $excludedstuff = explode(',',$aioseop_options['aiosp_ex_pages']);
  187. foreach($excludedstuff as $exedd){
  188. echo $exedd;
  189. //echo "<br /><br />substring: ". stristr($currenturl,trim($exedd)) . "<br />";
  190. if(stristr($currenturl, trim($exedd))){
  191. echo "<br />match, should not display<br /><br />";
  192. }else{
  193. echo "<br />( " . $exedd . " was not found in " . $currenturl . " ) - no match<br /><br />";
  194. }
  195. }
  196. //print_r($excludedstuff);
  197. */
  198. echo "\n<!-- All in One SEO Pack $this->version by Michael Torbert of Semper Fi Web Design";
  199. if ($this->ob_start_detected) {
  200. echo "ob_start_detected ";
  201. }
  202. echo "[$this->title_start,$this->title_end] ";
  203. echo "-->\n";
  204. if ((is_home() && $aioseop_options['aiosp_home_keywords'] && !$this->is_static_posts_page()) || $this->is_static_front_page()) {
  205. $keywords = trim($this->internationalize($aioseop_options['aiosp_home_keywords']));
  206. } elseif($this->is_static_posts_page() && !$aioseop_options['aiosp_dynamic_postspage_keywords']){ // and if option = use page set keywords instead of keywords from recent posts
  207. //$keywords = "posts keyyysss" . stripcslashes(get_post_meta($post->ID,'keywords',true));
  208. $keywords = stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true)));
  209. // $keywords = $this->get_unique_keywords($keywords);
  210. } else {
  211. $keywords = $this->get_all_keywords();
  212. }
  213. if (is_single() || is_page() || $this->is_static_posts_page()) {
  214. if ($this->is_static_front_page()) {
  215. $description = trim(stripcslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
  216. } else {
  217. $description = $this->get_post_description($post);
  218. $description = apply_filters('aioseop_description',$description);
  219. }
  220. } else if (is_home()) {
  221. $description = trim(stripcslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
  222. } else if (is_category()) {
  223. $description = $this->internationalize(category_description());
  224. }
  225. if (isset($description) && (strlen($description) > $this->minimum_description_length) && !(is_home() && is_paged())) {
  226. $description = trim(strip_tags($description));
  227. $description = str_replace('"', '', $description);
  228. // replace newlines on mac / windows?
  229. $description = str_replace("\r\n", ' ', $description);
  230. // maybe linux uses this alone
  231. $description = str_replace("\n", ' ', $description);
  232. if (isset($meta_string)) {
  233. //$meta_string .= "\n";
  234. } else {
  235. $meta_string = '';
  236. }
  237. // description format
  238. $description_format = $aioseop_options['aiosp_description_format'];
  239. if (!isset($description_format) || empty($description_format)) {
  240. $description_format = "%description%";
  241. }
  242. $description = str_replace('%description%', $description, $description_format);
  243. $description = str_replace('%blog_title%', get_bloginfo('name'), $description);
  244. $description = str_replace('%blog_description%', get_bloginfo('description'), $description);
  245. $description = str_replace('%wp_title%', $this->get_original_title(), $description);
  246. //$description = html_entity_decode($description, ENT_COMPAT, get_bloginfo('charset'));
  247. if($aioseop_options['aiosp_can'] && is_attachment()){
  248. $url = $this->aiosp_mrt_get_url($wp_query);
  249. if ($url) {
  250. preg_match_all('/(\d+)/', $url, $matches);
  251. if (is_array($matches)){
  252. $uniqueDesc = join('',$matches[0]);
  253. }
  254. }
  255. $description .= ' ' . $uniqueDesc;
  256. }
  257. $meta_string .= sprintf("<meta name=\"description\" content=\"%s\" />", $description);
  258. }
  259. $keywords = apply_filters('aioseop_keywords',$keywords);
  260. if (isset ($keywords) && !empty($keywords) && !(is_home() && is_paged())) {
  261. if (isset($meta_string)) {
  262. $meta_string .= "\n";
  263. }
  264. $keywords = str_replace('"','',$keywords);
  265. $meta_string .= sprintf("<meta name=\"keywords\" content=\"%s\" />", $keywords);
  266. }
  267. if (function_exists('is_tag')) {
  268. $is_tag = is_tag();
  269. }
  270. if ((is_category() && $aioseop_options['aiosp_category_noindex']) || (!is_category() && is_archive() &&!$is_tag && $aioseop_options['aiosp_archive_noindex']) || ($aioseop_options['aiosp_tags_noindex'] && $is_tag)) {
  271. if (isset($meta_string)) {
  272. $meta_string .= "\n";
  273. }
  274. $meta_string .= '<meta name="robots" content="noindex,follow" />';
  275. }
  276. $page_meta = stripcslashes($aioseop_options['aiosp_page_meta_tags']);
  277. $post_meta = stripcslashes($aioseop_options['aiosp_post_meta_tags']);
  278. $home_meta = stripcslashes($aioseop_options['aiosp_home_meta_tags']);
  279. if (is_page() && isset($page_meta) && !empty($page_meta) || $this->is_static_posts_page()) {
  280. if (isset($meta_string)) {
  281. $meta_string .= "\n";
  282. }
  283. echo "\n$page_meta";
  284. }
  285. if (is_single() && isset($post_meta) && !empty($post_meta)) {
  286. if (isset($meta_string)) {
  287. $meta_string .= "\n";
  288. }
  289. $meta_string .= "$post_meta";
  290. }
  291. if (is_home() && !empty($home_meta)) {
  292. if (isset($meta_string)) {
  293. $meta_string .= "\n";
  294. }
  295. $meta_string .= "$home_meta";
  296. }
  297. if ($meta_string != null) {
  298. echo "$meta_string\n";
  299. }
  300. if($aioseop_options['aiosp_can']){
  301. $url = $this->aiosp_mrt_get_url($wp_query);
  302. if ($url) {
  303. $url = apply_filters('aioseop_canonical_url',$url);
  304. echo "".'<link rel="canonical" href="'.$url.'" />'."\n";
  305. }
  306. }
  307. echo "<!-- /all in one seo pack -->\n";
  308. }
  309. // Thank you, Yoast de Valk, for much of this code.
  310. function aiosp_mrt_get_url($query) {
  311. global $aioseop_options;
  312. if ($query->is_404 || $query->is_search) {
  313. return false;
  314. }
  315. $haspost = count($query->posts) > 0;
  316. $has_ut = function_exists('user_trailingslashit');
  317. if (get_query_var('m')) {
  318. $m = preg_replace('/[^0-9]/', '', get_query_var('m'));
  319. switch (strlen($m)) {
  320. case 4:
  321. $link = get_year_link($m);
  322. break;
  323. case 6:
  324. $link = get_month_link(substr($m, 0, 4), substr($m, 4, 2));
  325. break;
  326. case 8:
  327. $link = get_day_link(substr($m, 0, 4), substr($m, 4, 2), substr($m, 6, 2));
  328. break;
  329. default:
  330. return false;
  331. }
  332. } elseif (($query->is_single || $query->is_page) && $haspost) {
  333. $post = $query->posts[0];
  334. $link = get_permalink($post->ID);
  335. $link = $this->yoast_get_paged($link);
  336. /* if ($page && $page > 1) {
  337. $link = trailingslashit($link) . "page/". "$page";
  338. if ($has_ut) {
  339. $link = user_trailingslashit($link, 'paged');
  340. } else {
  341. $link .= '/';
  342. }
  343. }
  344. if ($query->is_page && ('page' == get_option('show_on_front')) &&
  345. $post->ID == get_option('page_on_front'))
  346. {
  347. $link = trailingslashit($link);
  348. }*/
  349. } elseif ($query->is_author && $haspost) {
  350. global $wp_version;
  351. if ($wp_version >= '2') {
  352. $author = get_userdata(get_query_var('author'));
  353. if ($author === false)
  354. return false;
  355. $link = get_author_link(false, $author->ID, $author->user_nicename);
  356. } else {
  357. global $cache_userdata;
  358. $userid = get_query_var('author');
  359. $link = get_author_link(false, $userid, $cache_userdata[$userid]->user_nicename);
  360. }
  361. } elseif ($query->is_category && $haspost) {
  362. $link = get_category_link(get_query_var('cat'));
  363. $link = $this->yoast_get_paged($link);
  364. } else if ($query->is_tag && $haspost) {
  365. $tag = get_term_by('slug',get_query_var('tag'),'post_tag');
  366. if (!empty($tag->term_id)) {
  367. $link = get_tag_link($tag->term_id);
  368. }
  369. $link = $this->yoast_get_paged($link);
  370. } elseif ($query->is_day && $haspost) {
  371. $link = get_day_link(get_query_var('year'),
  372. get_query_var('monthnum'),
  373. get_query_var('day'));
  374. } elseif ($query->is_month && $haspost) {
  375. $link = get_month_link(get_query_var('year'),
  376. get_query_var('monthnum'));
  377. } elseif ($query->is_year && $haspost) {
  378. $link = get_year_link(get_query_var('year'));
  379. } elseif ($query->is_home) {
  380. if ((get_option('show_on_front') == 'page') &&
  381. ($pageid = get_option('page_for_posts')))
  382. {
  383. $link = get_permalink($pageid);
  384. $link = $this->yoast_get_paged($link);
  385. $link = trailingslashit($link);
  386. } else {
  387. $link = get_option('home');
  388. $link = $this->yoast_get_paged($link);
  389. $link = trailingslashit($link); }
  390. } else {
  391. return false;
  392. }
  393. return $link;
  394. }
  395. function yoast_get_paged($link) {
  396. $page = get_query_var('paged');
  397. if ($page && $page > 1) {
  398. $link = trailingslashit($link) ."page/". "$page";
  399. if ($has_ut) {
  400. $link = user_trailingslashit($link, 'paged');
  401. } else {
  402. $link .= '/';
  403. }
  404. }
  405. return $link;
  406. }
  407. function get_post_description($post) {
  408. global $aioseop_options;
  409. $description = trim(stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_description", true))));
  410. if (!$description) {
  411. $description = $this->trim_excerpt_without_filters_full_length($this->internationalize($post->post_excerpt));
  412. if (!$description && $aioseop_options["aiosp_generate_descriptions"]) {
  413. $description = $this->trim_excerpt_without_filters($this->internationalize($post->post_content));
  414. }
  415. }
  416. // "internal whitespace trim"
  417. $description = preg_replace("/\s\s+/", " ", $description);
  418. return $description;
  419. }
  420. function replace_title($content, $title) {
  421. $title = trim(strip_tags($title));
  422. $title_tag_start = "<title>";
  423. $title_tag_end = "</title>";
  424. $len_start = strlen($title_tag_start);
  425. $len_end = strlen($title_tag_end);
  426. $title = stripcslashes(trim($title));
  427. $start = strpos($content, $title_tag_start);
  428. $end = strpos($content, $title_tag_end);
  429. $this->title_start = $start;
  430. $this->title_end = $end;
  431. $this->orig_title = $title;
  432. if ($start && $end) {
  433. $header = substr($content, 0, $start + $len_start) . $title . substr($content, $end);
  434. } else {
  435. // this breaks some sitemap plugins (like wpg2)
  436. //$header = $content . "<title>$title</title>";
  437. $header = $content;
  438. }
  439. return $header;
  440. }
  441. function internationalize($in) {
  442. if (function_exists('langswitch_filter_langs_with_message')) {
  443. $in = langswitch_filter_langs_with_message($in);
  444. }
  445. if (function_exists('polyglot_filter')) {
  446. $in = polyglot_filter($in);
  447. }
  448. if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
  449. $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in);
  450. }
  451. $in = apply_filters('localization', $in);
  452. return $in;
  453. }
  454. /** @return The original title as delivered by WP (well, in most cases) */
  455. function get_original_title() {
  456. global $wp_query;
  457. global $aioseop_options;
  458. if (!$wp_query) {
  459. return null;
  460. }
  461. $post = $wp_query->get_queried_object();
  462. // the_search_query() is not suitable, it cannot just return
  463. global $s;
  464. $title = null;
  465. if (is_home()) {
  466. $title = get_option('blogname');
  467. } else if (is_single()) {
  468. $title = $this->internationalize(wp_title('', false));
  469. } else if (is_search() && isset($s) && !empty($s)) {
  470. if (function_exists('attribute_escape')) {
  471. $search = attribute_escape(stripcslashes($s));
  472. } else {
  473. $search = wp_specialchars(stripcslashes($s), true);
  474. }
  475. $search = $this->capitalize($search);
  476. $title = $search;
  477. } else if (is_category() && !is_feed()) {
  478. $category_description = $this->internationalize(category_description());
  479. $category_name = ucwords($this->internationalize(single_cat_title('', false)));
  480. $title = $category_name;
  481. } else if (is_page()) {
  482. $title = $this->internationalize(wp_title('', false));
  483. } else if (function_exists('is_tag') && is_tag()) {
  484. global $utw;
  485. if ($utw) {
  486. $tags = $utw->GetCurrentTagSet();
  487. $tag = $tags[0]->tag;
  488. $tag = str_replace('-', ' ', $tag);
  489. } else {
  490. // wordpress > 2.3
  491. $tag = $this->internationalize(wp_title('', false));
  492. }
  493. if ($tag) {
  494. $title = $tag;
  495. }
  496. } else if (is_archive()) {
  497. $title = $this->internationalize(wp_title('', false));
  498. } else if (is_404()) {
  499. $title_format = $aioseop_options['aiosp_404_title_format'];
  500. $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  501. $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
  502. $new_title = str_replace('%request_url%', $_SERVER['REQUEST_URI'], $new_title);
  503. $new_title = str_replace('%request_words%', $this->request_as_words($_SERVER['REQUEST_URI']), $new_title);
  504. $title = $new_title;
  505. }
  506. return trim($title);
  507. }
  508. function paged_title($title) {
  509. // the page number if paged
  510. global $paged;
  511. global $aioseop_options;
  512. // simple tagging support
  513. global $STagging;
  514. if (is_paged() || (isset($STagging) && $STagging->is_tag_view() && $paged)) {
  515. $part = $this->internationalize($aioseop_options['aiosp_paged_format']);
  516. if (isset($part) || !empty($part)) {
  517. $part = " " . trim($part);
  518. $part = str_replace('%page%', $paged, $part);
  519. $this->log("paged_title() [$title] [$part]");
  520. $title .= $part;
  521. }
  522. }
  523. return $title;
  524. }
  525. function rewrite_title($header) {
  526. global $aioseop_options;
  527. global $wp_query;
  528. if (!$wp_query) {
  529. $header .= "<!-- no wp_query found! -->\n";
  530. return $header;
  531. }
  532. $post = $wp_query->get_queried_object();
  533. // the_search_query() is not suitable, it cannot just return
  534. global $s;
  535. global $STagging;
  536. if (is_home() && !$this->is_static_posts_page()) {
  537. $title = $this->internationalize($aioseop_options['aiosp_home_title']);
  538. if (empty($title)) {
  539. $title = $this->internationalize(get_option('blogname'));
  540. }
  541. $title = $this->paged_title($title);
  542. $header = $this->replace_title($header, $title);
  543. } else if (is_attachment()) {
  544. $title = get_the_title($post->post_parent).' '.$post->post_title.' – '.get_option('blogname');
  545. $header = $this->replace_title($header,$title);
  546. } else if (is_single()) {
  547. // we're not in the loop :(
  548. $authordata = get_userdata($post->post_author);
  549. $categories = get_the_category();
  550. $category = '';
  551. if (count($categories) > 0) {
  552. $category = $categories[0]->cat_name;
  553. }
  554. $title = $this->internationalize(get_post_meta($post->ID, "_aioseop_title", true));
  555. if (!$title) {
  556. $title = $this->internationalize(get_post_meta($post->ID, "title_tag", true));
  557. if (!$title) {
  558. $title = $this->internationalize(wp_title('', false));
  559. }
  560. }
  561. $title_format = $aioseop_options['aiosp_post_title_format'];
  562. /*
  563. $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  564. $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
  565. $new_title = str_replace('%post_title%', $title, $new_title);
  566. $new_title = str_replace('%category%', $category, $new_title);
  567. $new_title = str_replace('%category_title%', $category, $new_title);
  568. $new_title = str_replace('%post_author_login%', $authordata->user_login, $new_title);
  569. $new_title = str_replace('%post_author_nicename%', $authordata->user_nicename, $new_title);
  570. $new_title = str_replace('%post_author_firstname%', ucwords($authordata->first_name), $new_title);
  571. $new_title = str_replace('%post_author_lastname%', ucwords($authordata->last_name), $new_title);
  572. */
  573. $r_title = array('%blog_title%','%blog_description%','%post_title%','%category%','%category_title%','%post_author_login%','%post_author_nicename%','%post_author_firstname%','%post_author_lastname%');
  574. $d_title = array($this->internationalize(get_bloginfo('name')),$this->internationalize(get_bloginfo('description')),$title, $category, $category, $authordata->user_login, $authordata->user_nicename, ucwords($authordata->first_name), ucwords($authordata->last_name));
  575. $title = trim(str_replace($r_title, $d_title, $title_format));
  576. // $title = $new_title;
  577. // $title = trim($title);
  578. $title = apply_filters('aioseop_title_single',$title);
  579. $header = $this->replace_title($header, $title);
  580. } else if (is_search() && isset($s) && !empty($s)) {
  581. if (function_exists('attribute_escape')) {
  582. $search = attribute_escape(stripcslashes($s));
  583. } else {
  584. $search = wp_specialchars(stripcslashes($s), true);
  585. }
  586. $search = $this->capitalize($search);
  587. $title_format = $aioseop_options['aiosp_search_title_format'];
  588. $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  589. $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
  590. $title = str_replace('%search%', $search, $title);
  591. $header = $this->replace_title($header, $title);
  592. } else if (is_category() && !is_feed()) {
  593. $category_description = $this->internationalize(category_description());
  594. if($aioseop_options['aiosp_cap_cats']){
  595. $category_name = ucwords($this->internationalize(single_cat_title('', false)));
  596. }else{
  597. $category_name = $this->internationalize(single_cat_title('', false));
  598. }
  599. //$category_name = ucwords($this->internationalize(single_cat_title('', false)));
  600. $title_format = $aioseop_options['aiosp_category_title_format'];
  601. $title = str_replace('%category_title%', $category_name, $title_format);
  602. $title = str_replace('%category_description%', $category_description, $title);
  603. $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title);
  604. $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
  605. $title = $this->paged_title($title);
  606. $header = $this->replace_title($header, $title);
  607. } else if (is_page() || $this->is_static_posts_page()) {
  608. // we're not in the loop :(
  609. $authordata = get_userdata($post->post_author);
  610. if ($this->is_static_front_page()) {
  611. if ($this->internationalize($aioseop_options['aiosp_home_title'])) {
  612. //home title filter
  613. $home_title = $this->internationalize($aioseop_options['aiosp_home_title']);
  614. $home_title = apply_filters('aioseop_home_page_title',$home_title);
  615. $header = $this->replace_title($header, $home_title);
  616. }
  617. } else {
  618. $title = $this->internationalize(get_post_meta($post->ID, "_aioseop_title", true));
  619. if (!$title) {
  620. $title = $this->internationalize(wp_title('', false));
  621. }
  622. $title_format = $aioseop_options['aiosp_page_title_format'];
  623. $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  624. $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
  625. $new_title = str_replace('%page_title%', $title, $new_title);
  626. $new_title = str_replace('%page_author_login%', $authordata->user_login, $new_title);
  627. $new_title = str_replace('%page_author_nicename%', $authordata->user_nicename, $new_title);
  628. $new_title = str_replace('%page_author_firstname%', ucwords($authordata->first_name), $new_title);
  629. $new_title = str_replace('%page_author_lastname%', ucwords($authordata->last_name), $new_title);
  630. $title = trim($new_title);
  631. $title = $this->paged_title($title);
  632. $title = apply_filters('aioseop_title_page',$title);
  633. $header = $this->replace_title($header, $title);
  634. }
  635. } else if (function_exists('is_tag') && is_tag()) {
  636. global $utw;
  637. if ($utw) {
  638. $tags = $utw->GetCurrentTagSet();
  639. $tag = $tags[0]->tag;
  640. $tag = str_replace('-', ' ', $tag);
  641. } else {
  642. // wordpress > 2.3
  643. $tag = $this->internationalize(wp_title('', false));
  644. }
  645. if ($tag) {
  646. $tag = $this->capitalize($tag);
  647. $title_format = $aioseop_options['aiosp_tag_title_format'];
  648. $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  649. $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
  650. $title = str_replace('%tag%', $tag, $title);
  651. $title = $this->paged_title($title);
  652. $header = $this->replace_title($header, $title);
  653. }
  654. } else if (isset($STagging) && $STagging->is_tag_view()) { // simple tagging support
  655. $tag = $STagging->search_tag;
  656. if ($tag) {
  657. $tag = $this->capitalize($tag);
  658. $title_format = $aioseop_options['aiosp_tag_title_format'];
  659. $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  660. $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
  661. $title = str_replace('%tag%', $tag, $title);
  662. $title = $this->paged_title($title);
  663. $header = $this->replace_title($header, $title);
  664. }
  665. } else if (is_archive()) {
  666. $date = $this->internationalize(wp_title('', false));
  667. $title_format = $aioseop_options['aiosp_archive_title_format'];
  668. $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  669. $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
  670. $new_title = str_replace('%date%', $date, $new_title);
  671. $title = trim($new_title);
  672. $title = $this->paged_title($title);
  673. $header = $this->replace_title($header, $title);
  674. } else if (is_404()) {
  675. $title_format = $aioseop_options['aiosp_404_title_format'];
  676. $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
  677. $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
  678. $new_title = str_replace('%request_url%', $_SERVER['REQUEST_URI'], $new_title);
  679. $new_title = str_replace('%request_words%', $this->request_as_words($_SERVER['REQUEST_URI']), $new_title);
  680. $new_title = str_replace('%404_title%', $this->internationalize(wp_title('', false)), $new_title);
  681. $header = $this->replace_title($header, $new_title);
  682. }
  683. return $header;
  684. }
  685. /**
  686. * @return User-readable nice words for a given request.
  687. */
  688. function request_as_words($request) {
  689. $request = htmlspecialchars($request);
  690. $request = str_replace('.html', ' ', $request);
  691. $request = str_replace('.htm', ' ', $request);
  692. $request = str_replace('.', ' ', $request);
  693. $request = str_replace('/', ' ', $request);
  694. $request_a = explode(' ', $request);
  695. $request_new = array();
  696. foreach ($request_a as $token) {
  697. $request_new[] = ucwords(trim($token));
  698. }
  699. $request = implode(' ', $request_new);
  700. return $request;
  701. }
  702. function capitalize($s) {
  703. $s = trim($s);
  704. $tokens = explode(' ', $s);
  705. while (list($key, $val) = each($tokens)) {
  706. $tokens[$key] = trim($tokens[$key]);
  707. $tokens[$key] = strtoupper(substr($tokens[$key], 0, 1)) . substr($tokens[$key], 1);
  708. }
  709. $s = implode(' ', $tokens);
  710. return $s;
  711. }
  712. function trim_excerpt_without_filters($text) {
  713. $text = str_replace(']]>', ']]&gt;', $text);
  714. $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
  715. $text = strip_tags($text);
  716. $max = $this->maximum_description_length;
  717. if ($max < strlen($text)) {
  718. while($text[$max] != ' ' && $max > $this->minimum_description_length) {
  719. $max--;
  720. }
  721. }
  722. $text = substr($text, 0, $max);
  723. return trim(stripcslashes($text));
  724. }
  725. function trim_excerpt_without_filters_full_length($text) {
  726. $text = str_replace(']]>', ']]&gt;', $text);
  727. $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
  728. $text = strip_tags($text);
  729. return trim(stripcslashes($text));
  730. }
  731. /**
  732. * @return comma-separated list of unique keywords
  733. */
  734. function get_all_keywords() {
  735. global $posts;
  736. global $aioseop_options;
  737. if (is_404()) {
  738. return null;
  739. }
  740. // if we are on synthetic pages
  741. if (!is_home() && !is_page() && !is_single() &&!$this->is_static_front_page() && !$this->is_static_posts_page()) {
  742. return null;
  743. }
  744. $keywords = array();
  745. if (is_array($posts)) {
  746. foreach ($posts as $post) {
  747. if ($post) {
  748. // custom field keywords
  749. $keywords_a = $keywords_i = null;
  750. $description_a = $description_i = null;
  751. $id = (is_attachment())?($post->post_parent):($post->ID); // if attachment then use parent post id
  752. $keywords_i = stripcslashes($this->internationalize(get_post_meta($id, "_aioseop_keywords", true)));
  753. //$id = $post->ID;
  754. //$keywords_i = stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true)));
  755. $keywords_i = str_replace('"', '', $keywords_i);
  756. if (isset($keywords_i) && !empty($keywords_i)) {
  757. $traverse = explode(',', $keywords_i);
  758. foreach ($traverse as $keyword) {
  759. $keywords[] = $keyword;
  760. }
  761. }
  762. // WP 2.3 tags
  763. if ($aioseop_options['aiosp_use_tags_as_keywords']){
  764. if (function_exists('get_the_tags')) {
  765. //$tags = get_the_tags($post->ID);
  766. $tags = get_the_tags($id);
  767. if ($tags && is_array($tags)) {
  768. foreach ($tags as $tag) {
  769. $keywords[] = $this->internationalize($tag->name);
  770. }
  771. }
  772. }
  773. }
  774. // Ultimate Tag Warrior integration
  775. global $utw;
  776. if ($utw) {
  777. $tags = $utw->GetTagsForPost($post);
  778. if (is_array($tags)) {
  779. foreach ($tags as $tag) {
  780. $tag = $tag->tag;
  781. $tag = str_replace('_',' ', $tag);
  782. $tag = str_replace('-',' ',$tag);
  783. $tag = stripcslashes($tag);
  784. $keywords[] = $tag;
  785. }
  786. }
  787. }
  788. // autometa
  789. $autometa = stripcslashes(get_post_meta($id, 'autometa', true));
  790. //$autometa = stripcslashes(get_post_meta($post->ID, "autometa", true));
  791. if (isset($autometa) && !empty($autometa)) {
  792. $autometa_array = explode(' ', $autometa);
  793. foreach ($autometa_array as $e) {
  794. $keywords[] = $e;
  795. }
  796. }
  797. if ($aioseop_options['aiosp_use_categories'] && !is_page()) {
  798. $categories = get_the_category($id);
  799. //$categories = get_the_category($post->ID);
  800. foreach ($categories as $category) {
  801. $keywords[] = $this->internationalize($category->cat_name);
  802. }
  803. }
  804. }
  805. }
  806. }
  807. return $this->get_unique_keywords($keywords);
  808. }
  809. function get_meta_keywords() {
  810. global $posts;
  811. $keywords = array();
  812. if (is_array($posts)) {
  813. foreach ($posts as $post) {
  814. if ($post) {
  815. // custom field keywords
  816. $keywords_a = $keywords_i = null;
  817. $description_a = $description_i = null;
  818. $id = $post->ID;
  819. $keywords_i = stripcslashes(get_post_meta($post->ID, "_aioseop_keywords", true));
  820. $keywords_i = str_replace('"', '', $keywords_i);
  821. if (isset($keywords_i) && !empty($keywords_i)) {
  822. $keywords[] = $keywords_i;
  823. }
  824. }
  825. }
  826. }
  827. return $this->get_unique_keywords($keywords);
  828. }
  829. function get_unique_keywords($keywords) {
  830. $small_keywords = array();
  831. foreach ($keywords as $word) {
  832. if (function_exists('mb_strtolower'))
  833. $small_keywords[] = mb_strtolower($word, get_bloginfo('charset'));
  834. else
  835. $small_keywords[] = $this->strtolower($word);
  836. }
  837. $keywords_ar = array_unique($small_keywords);
  838. return implode(',', $keywords_ar);
  839. }
  840. function get_url($url) {
  841. if (function_exists('file_get_contents')) {
  842. $file = file_get_contents($url);
  843. } else {
  844. $curl = curl_init($url);
  845. curl_setopt($curl, CURLOPT_HEADER, 0);
  846. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  847. $file = curl_exec($curl);
  848. curl_close($curl);
  849. }
  850. return $file;
  851. }
  852. function log($message) {
  853. if ($this->do_log) {
  854. error_log(date('Y-m-d H:i:s') . " " . $message . "\n", 3, $this->log_file);
  855. }
  856. }
  857. function download_newest_version() {
  858. $success = true;
  859. $file_content = $this->get_url($this->upgrade_url);
  860. if ($file_content === false) {
  861. $this->upgrade_error = sprintf(__("Could not download distribution (%s)"), $this->upgrade_url);
  862. $success = false;
  863. } else if (strlen($file_content) < 100) {
  864. $this->upgrade_error = sprintf(__("Could not download distribution (%s): %s"), $this->upgrade_url, $file_content);
  865. $success = false;
  866. } else {
  867. $this->log(sprintf("filesize of download ZIP: %d", strlen($file_content)));
  868. $fh = @fopen($this->upgrade_filename, 'w');
  869. $this->log("fh is $fh");
  870. if (!$fh) {
  871. $this->upgrade_error = sprintf(__("Could not open %s for writing"), $this->upgrade_filename);
  872. $this->upgrade_error .= "<br />";
  873. $this->upgrade_error .= sprintf(__("Please make sure %s is writable"), $this->upgrade_folder);
  874. $success = false;
  875. } else {
  876. $bytes_written = @fwrite($fh, $file_content);
  877. $this->log("wrote $bytes_written bytes");
  878. if (!$bytes_written) {
  879. $this->upgrade_error = sprintf(__("Could not write to %s"), $this->upgrade_filename);
  880. $success = false;
  881. }
  882. }
  883. if ($success) {
  884. fclose($fh);
  885. }
  886. }
  887. return $success;
  888. }
  889. function install_newest_version() {
  890. $success = $this->download_newest_version();
  891. if ($success) {
  892. $success = $this->extract_plugin();
  893. unlink($this->upgrade_filename);
  894. }
  895. return $success;
  896. }
  897. function extract_plugin() {
  898. if (!class_exists('PclZip')) {
  899. require_once ('pclzip.lib.php');
  900. }
  901. $archive = new PclZip($this->upgrade_filename);
  902. $files = $archive->extract(PCLZIP_OPT_STOP_ON_ERROR, PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_PATH, $this->upgrade_folder);
  903. $this->log("files is $files");
  904. if (is_array($files)) {
  905. $num_extracted = sizeof($files);
  906. $this->log("extracted $num_extracted files to $this->upgrade_folder");
  907. $this->log(print_r($files, true));
  908. return true;
  909. } else {
  910. $this->upgrade_error = $archive->errorInfo();
  911. return false;
  912. }
  913. }
  914. /** crude approximization of whether current user is an admin */
  915. function is_admin() {
  916. return current_user_can('level_8');
  917. }
  918. function is_directory_writable($directory) {
  919. $filename = $directory . '/' . 'tmp_file_' . time();
  920. $fh = @fopen($filename, 'w');
  921. if (!$fh) {
  922. return false;
  923. }
  924. $written = fwrite($fh, "test");
  925. fclose($fh);
  926. unlink($filename);
  927. if ($written) {
  928. return true;
  929. } else {
  930. return false;
  931. }
  932. }
  933. function is_upgrade_directory_writable() {
  934. //return $this->is_directory_writable($this->upgrade_folder);
  935. // let's assume it is
  936. return true;
  937. }
  938. function post_meta_tags($id) {
  939. $awmp_edit = $_POST["aiosp_edit"];
  940. $nonce = $_POST['nonce-aioseop-edit'];
  941. // if (!wp_verify_nonce($nonce, 'edit-aioseop-nonce')) die ( 'Security Check - If you receive this in error, log out and back in to WordPress');
  942. if (isset($awmp_edit) && !empty($awmp_edit) && wp_verify_nonce($nonce, 'edit-aioseop-nonce')) {
  943. $keywords = $_POST["aiosp_keywords"];
  944. $description = $_POST["aiosp_description"];
  945. $title = $_POST["aiosp_title"];
  946. $aiosp_meta = $_POST["aiosp_meta"];
  947. $aiosp_disable = $_POST["aiosp_disable"];
  948. $aiosp_titleatr = $_POST["aiosp_titleatr"];
  949. $aiosp_menulabel = $_POST["aiosp_menulabel"];
  950. delete_post_meta($id, '_aioseop_keywords');
  951. delete_post_meta($id, '_aioseop_description');
  952. delete_post_meta($id, '_aioseop_title');
  953. delete_post_meta($id, '_aioseop_titleatr');
  954. delete_post_meta($id, '_aioseop_menulabel');
  955. if ($this->is_admin()) {
  956. delete_post_meta($id, '_aioseop_disable');
  957. }
  958. //delete_post_meta($id, 'aiosp_meta');
  959. if (isset($keywords) && !empty($keywords)) {
  960. add_post_meta($id, '_aioseop_keywords', $keywords);
  961. }
  962. if (isset($description) && !empty($description)) {
  963. add_post_meta($id, '_aioseop_description', $description);
  964. }
  965. if (isset($title) && !empty($title)) {
  966. add_post_meta($id, '_aioseop_title', $title);
  967. }
  968. if (isset($aiosp_titleatr) && !empty($aiosp_titleatr)) {
  969. add_post_meta($id, '_aioseop_titleatr', $aiosp_titleatr);
  970. }
  971. if (isset($aiosp_menulabel) && !empty($aiosp_menulabel)) {
  972. add_post_meta($id, '_aioseop_menulabel', $aiosp_menulabel);
  973. }
  974. if (isset($aiosp_disable) && !empty($aiosp_disable) && $this->is_admin()) {
  975. add_post_meta($id, '_aioseop_disable', $aiosp_disable);
  976. }
  977. /*
  978. if (isset($aiosp_meta) && !empty($aiosp_meta)) {
  979. add_post_meta($id, 'aiosp_meta', $aiosp_meta);
  980. }
  981. */
  982. }
  983. }
  984. function edit_category($id) {
  985. global $wpdb;
  986. $id = $wpdb->escape($id);
  987. $awmp_edit = $_POST["aiosp_edit"];
  988. if (isset($awmp_edit) && !empty($awmp_edit)) {
  989. $keywords = $wpdb->escape($_POST["aiosp_keywords"]);
  990. $title = $wpdb->escape($_POST["aiosp_title"]);
  991. $old_category = $wpdb->get_row("select * from $this->table_categories where category_id=$id", OBJECT);
  992. if ($old_category) {
  993. $wpdb->query($wpdb->prepare("update $this->table_categories
  994. set meta_title='$title', meta_keywords='$keywords'
  995. where category_id=$id"));
  996. } else {
  997. $wpdb->query($wpdb->prepare("insert into $this->table_categories(meta_title, meta_keywords, category_id)
  998. values ('$title', '$keywords', $id"));
  999. }
  1000. //$wpdb->query($wpdb->prepare("insert into $this->table_categories"))
  1001. /*
  1002. delete_post_meta($id, 'keywords');
  1003. delete_post_meta($id, 'description');
  1004. delete_post_meta($id, 'title');
  1005. if (isset($keywords) && !empty($keywords)) {
  1006. add_post_meta($id, 'keywords', $keywords);
  1007. }
  1008. if (isset($description) && !empty($description)) {
  1009. add_post_meta($id, 'description', $description);
  1010. }
  1011. if (isset($title) && !empty($title)) {
  1012. add_post_meta($id, 'title', $title);
  1013. }
  1014. */
  1015. }
  1016. }
  1017. /**
  1018. * @deprecated This was for the feature of dedicated meta tags for categories which never went mainstream.
  1019. */
  1020. function edit_category_form() {
  1021. global $post;
  1022. $keywords = stripcslashes(get_post_meta($post->ID, '_aioseop_keywords', true));
  1023. $title = stripcslashes(get_post_meta($post->ID, '_aioseop_title', true));
  1024. $description = stripcslashes(get_post_meta($post->ID, '_aioseop_description', true));
  1025. ?>
  1026. <input value="aiosp_edit" type="hidden" name="aiosp_edit" />
  1027. <table class="editform" width="100%" cellspacing="2" cellpadding="5">
  1028. <tr>
  1029. <th width="33%" scope="row" valign="top">
  1030. <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>
  1031. </th>
  1032. </tr>
  1033. <tr>
  1034. <th width="33%" scope="row" valign="top"><label for="aiosp_title"><?php _e('Title:', 'all_in_one_seo_pack') ?></label></th>
  1035. <td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="70"/></td>
  1036. </tr>
  1037. <tr>
  1038. <th width="33%" scope="row" valign="top"><label for="aiosp_keywords"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></label></th>
  1039. <td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="70"/></td>
  1040. </tr>
  1041. </table>
  1042. <?php
  1043. }
  1044. function add_meta_tags_textinput() {
  1045. global $post;
  1046. $post_id = $post;
  1047. if (is_object($post_id)) {
  1048. $post_id = $post_id->ID;
  1049. }
  1050. $keywords = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_keywords', true)));
  1051. $title = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_title', true)));
  1052. $description = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_description', true)));
  1053. $aiosp_meta = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_meta', true)));
  1054. $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_disable', true)));
  1055. $aiosp_titleatr = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_titleatr', true)));
  1056. $aiosp_menulabel = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_menulabel', true)));
  1057. ?>
  1058. <SCRIPT LANGUAGE="JavaScript">
  1059. <!-- Begin
  1060. function countChars(field,cntfield) {
  1061. cntfield.value = field.value.length;
  1062. }
  1063. // End -->
  1064. </script>
  1065. <?php if (substr($this->wp_version, 0, 3) >= '2.5') { ?>
  1066. <div id="postaiosp" class="postbox closed">
  1067. <h3><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></h3>
  1068. <div class="inside">
  1069. <div id="postaiosp">
  1070. <?php } else { ?>
  1071. <div class="dbx-b-ox-wrapper">
  1072. <fieldset id="seodiv" class="dbx-box">
  1073. <div class="dbx-h-andle-wrapper">
  1074. <h3 class="dbx-handle"><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></h3>
  1075. </div>
  1076. <div class="dbx-c-ontent-wrapper">
  1077. <div class="dbx-content">
  1078. <?php } ?>
  1079. <a target="__blank" href="http://semperfiwebdesign.com/portfolio/wordpress/wordpress-plugins/all-in-one-seo-pack/"><?php _e('Click here for Support', 'all_in_one_seo_pack') ?></a>
  1080. <input value="aiosp_edit" type="hidden" name="aiosp_edit" />
  1081. <table style="margin-bottom:40px">
  1082. <tr>
  1083. <th style="text-align:left;" colspan="2">
  1084. </th>
  1085. </tr>
  1086. <tr>
  1087. <th scope="row" style="text-align:right;"><?php _e('Title:', 'all_in_one_seo_pack') ?></th>
  1088. <td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="62"/></td>
  1089. </tr>
  1090. <tr>
  1091. <th scope="row" style="text-align:right;"><?php _e('Description:', 'all_in_one_seo_pack') ?></th>
  1092. <td><textarea name="aiosp_description" rows="1" cols="60" onKeyDown="countChars(document.post.aiosp_description,document.post.length1)" onKeyUp="countChars(document.post.aiosp_description,document.post.length1)"><?php echo $description ?>
  1093. </textarea><br />
  1094. <input readonly type="text" name="length1" size="3" maxlength="3" value="<?php echo strlen($description);?>" />
  1095. <?php _e(' characters. Most search engines use a maximum of 160 chars for the description.', 'all_in_one_seo_pack') ?>
  1096. </td>
  1097. </tr>
  1098. <tr>
  1099. <th scope="row" style="text-align:right;"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></th>
  1100. <td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="62"/></td>
  1101. </tr>
  1102. <input type="hidden" name="nonce-aioseop-edit" value="<?php echo wp_create_nonce('edit-aioseop-nonce'); ?>" />
  1103. <?php if ($this->is_admin()) { ?>
  1104. <tr>
  1105. <th scope="row" style="text-align:right; vertical-align:top;">
  1106. <?php _e('Disable on this page/post:', 'all_in_one_seo_pack')?>
  1107. </th>
  1108. <td>
  1109. <input type="checkbox" name="aiosp_disable" <?php if ($aiosp_disable) echo "checked=\"1\""; ?>/>
  1110. </td>
  1111. </tr>
  1112. <tr>
  1113. <th scope="row" style="text-align:right;"><?php _e('Title Attribute:', 'all_in_one_seo_pack') ?></th>
  1114. <td><input value="<?php echo $aiosp_titleatr ?>" type="text" name="aiosp_titleatr" size="62"/></td>
  1115. </tr>
  1116. <tr>
  1117. <th scope="row" style="text-align:right;"><?php _e('Menu Label:', 'all_in_one_seo_pack') ?></th>
  1118. <td><input value="<?php echo $aiosp_menulabel ?>" type="text" name="aiosp_menulabel" size="62"/></td>
  1119. </tr>
  1120. <?php } ?>
  1121. </table>
  1122. <?php if (substr($this->wp_version, 0, 3) >= '2.5') { ?>
  1123. </div>
  1124. </div>
  1125. </div>
  1126. <?php } else { ?>
  1127. </div>
  1128. </fieldset>
  1129. </div>
  1130. <?php } ?>
  1131. <?php
  1132. }
  1133. function admin_menu() {
  1134. $file = __FILE__;
  1135. // hack for 1.5
  1136. if (substr($this->wp_version, 0, 3) == '1.5') {
  1137. $file = 'all-in-one-seo-pack/all_in_one_seo_pack.php';
  1138. }
  1139. //add_management_page(__('All in One SEO Title', 'all_in_one_seo_pack'), __('All in One SEO', 'all_in_one_seo_pack'), 10, $file, array($this, 'management_panel'));
  1140. add_submenu_page('options-general.php', __('All in One SEO', 'all_in_one_seo_pack'), __('All in One SEO', 'all_in_one_seo_pack'), 'manage_options', $file, array($this, 'options_panel'));
  1141. }
  1142. function management_panel() {
  1143. $message = null;
  1144. $base_url = "edit.php?page=" . __FILE__;
  1145. //echo($base_url);
  1146. $type = $_REQUEST['type'];
  1147. if (!isset($type)) {
  1148. $type = "posts";
  1149. }
  1150. ?>
  1151. <ul class="aiosp_menu">
  1152. <li><a href="<?php echo $base_url ?>&type=posts">Posts</a>
  1153. </li>
  1154. <li><a href="<?php echo $base_url ?>&type=pages">Pages</a>
  1155. </li>
  1156. </ul>
  1157. <?php
  1158. if ($type == "posts") {
  1159. echo("posts");
  1160. } elseif ($type == "pages") {
  1161. echo("pages");
  1162. }
  1163. }
  1164. function options_panel() {
  1165. $message = null;
  1166. //$message_updated = __("All in One SEO Options Updated.", 'all_in_one_seo_pack');
  1167. global $aioseop_options;
  1168. if(!$aioseop_options['aiosp_cap_cats…

Large files files are truncated, but you can click here to view the full file