PageRenderTime 102ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 1ms

/htdocs/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php

https://bitbucket.org/dkrzos/phc
PHP | 2115 lines | 1860 code | 182 blank | 73 comment | 496 complexity | 499e571c6f65a4485d834691b356f2e7 MD5 | raw file
Possible License(s): GPL-2.0

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

  1. <?php
  2. /**
  3. * @package All-in-One-SEO-Pack
  4. */
  5. /**
  6. * Include the module base class.
  7. */
  8. require_once( 'aioseop_module_class.php' );
  9. /**
  10. * The main class.
  11. */
  12. class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module {
  13. /** The current version of the plugin. **/
  14. var $version = AIOSEOP_VERSION;
  15. /** Max numbers of chars in auto-generated description */
  16. var $maximum_description_length = 160;
  17. /** Minimum number of chars an excerpt should be so that it can be used
  18. * as description. Touch only if you know what you're doing
  19. */
  20. var $minimum_description_length = 1;
  21. /** Whether output buffering is already being used during forced title rewrites. **/
  22. var $ob_start_detected = false;
  23. /** The start of the title text in the head section for forced title rewrites. **/
  24. var $title_start = -1;
  25. /** The end of the title text in the head section for forced title rewrites. **/
  26. var $title_end = -1;
  27. /** The title before rewriting */
  28. var $orig_title = '';
  29. /** Filename of log file. */
  30. var $log_file;
  31. /** Flag whether there should be logging. */
  32. var $do_log;
  33. function All_in_One_SEO_Pack() {
  34. global $aioseop_options;
  35. $this->log_file = dirname( __FILE__ ) . '/all_in_one_seo_pack.log';
  36. if ( $aioseop_options['aiosp_do_log'] )
  37. $this->do_log = true;
  38. else
  39. $this->do_log = false;
  40. $this->init();
  41. global $aioseop_plugin_name;
  42. $aioseop_plugin_name = __( 'All in One SEO Pack', 'all_in_one_seo_pack' );
  43. if ( ! defined( 'AIOSEOP_PLUGIN_NAME' ) )
  44. define( 'AIOSEOP_PLUGIN_NAME', $aioseop_plugin_name );
  45. $this->name = sprintf( __( '%s Plugin Options', 'all_in_one_seo_pack' ), AIOSEOP_PLUGIN_NAME );
  46. $this->menu_name = __( 'General Settings', 'all_in_one_seo_pack' );
  47. $this->prefix = 'aiosp_'; // option prefix
  48. $this->option_name = 'aioseop_options';
  49. $this->store_option = true;
  50. $this->file = __FILE__; // the current file
  51. parent::__construct();
  52. $this->default_options = array(
  53. "donate"=> Array(
  54. 'name' => __( 'I enjoy this plugin and have made a donation:', 'all_in_one_seo_pack' ),
  55. 'help_text' => __( 'All donations support continued development of this free software.', 'all_in_one_seo_pack' ),
  56. 'default' => 0),
  57. "home_title"=> Array(
  58. 'name' => __( 'Home Title:', 'all_in_one_seo_pack' ),
  59. 'help_text' => __( 'As the name implies, this will be the title of your homepage. This is independent of any other option. If not set, the default blog title will get used.', 'all_in_one_seo_pack' ),
  60. 'default' => null, 'type' => 'textarea', 'sanitize' => 'text' ),
  61. "home_description"=> Array(
  62. 'name' => __( 'Home Description:', 'all_in_one_seo_pack' ),
  63. 'help_text' => __( 'The META description for your homepage. Independent of any other options, the default is no META description at all if this is not set.', 'all_in_one_seo_pack' ),
  64. 'default' => '', 'type' => 'textarea', 'sanitize' => 'text' ),
  65. "togglekeywords" => Array(
  66. 'name' => __( 'Use Keywords:', 'all_in_one_seo_pack' ),
  67. 'help_text' => __( 'This option allows you to toggle the use of meta keywords throughout the whole of the site.', 'all_in_one_seo_pack' ),
  68. 'default' => 0,
  69. 'type' => 'radio',
  70. 'initial_options' => Array( 0 => __( 'Enabled', 'all_in_one_seo_pack' ),
  71. 1 => __( 'Disabled', 'all_in_one_seo_pack' ) )
  72. ),
  73. "home_keywords"=> Array(
  74. 'name' => __( 'Home Keywords (comma separated):', 'all_in_one_seo_pack' ),
  75. 'help_text' => __( 'A comma separated list of your most important keywords for your site that will be written as META keywords on your homepage. Don\'t stuff everything in here.', 'all_in_one_seo_pack' ),
  76. 'default' => null, 'type' => 'textarea', 'sanitize' => 'text',
  77. 'condshow' => Array( "aiosp_togglekeywords" => 0 ) ),
  78. "can"=> Array(
  79. 'name' => __( 'Canonical URLs:', 'all_in_one_seo_pack' ),
  80. 'help_text' => __( "This option will automatically generate Canonical URLS for your entire WordPress installation. This will help to prevent duplicate content penalties by <a href='http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html' target='_blank'>Google</a>.", 'all_in_one_seo_pack' ),
  81. 'default' => 1),
  82. "rewrite_titles"=> Array(
  83. 'name' => __( 'Rewrite Titles:', 'all_in_one_seo_pack' ),
  84. 'help_text' => __( "Note that this is all about the title tag. This is what you see in your browser's window title bar. This is NOT visible on a page, only in the window title bar and of course in the source. If set, all page, post, category, search and archive page titles get rewritten. You can specify the format for most of them. For example: The default templates puts the title tag of posts like this: “Blog Archive >> Blog Name >> Post Title” (maybe I've overdone slightly). This is far from optimal. With the default post title format, Rewrite Title rewrites this to “Post Title | Blog Name”. If you have manually defined a title (in one of the text fields for All in One SEO Plugin input) this will become the title of your post in the format string.", 'all_in_one_seo_pack' ),
  85. 'default' => 1,
  86. 'type' => 'radio',
  87. 'initial_options' => Array( 1 => __( 'Enabled', 'all_in_one_seo_pack' ),
  88. 0 => __( 'Disabled', 'all_in_one_seo_pack' ) )
  89. ),
  90. "force_rewrites"=> Array(
  91. 'name' => __( 'Force Rewrites:', 'all_in_one_seo_pack' ),
  92. 'help_text' => __( "Use output buffering to ensure that the title gets rewritten.", 'all_in_one_seo_pack' ),
  93. 'default' => 1,
  94. 'type' => 'hidden',
  95. 'prefix' => $this->prefix,
  96. 'initial_options' => Array( 1 => __( 'Enabled', 'all_in_one_seo_pack' ),
  97. 0 => __( 'Disabled', 'all_in_one_seo_pack' ) )
  98. ),
  99. "use_original_title"=> Array(
  100. 'name' => __( 'Use Original Title:', 'all_in_one_seo_pack' ),
  101. 'help_text' => __( "Use wp_title to set the title; disable this option if you run into conflicts with the title being set by your theme or another plugin.", 'all_in_one_seo_pack' ),
  102. 'type' => 'radio',
  103. 'default' => 0,
  104. 'initial_options' => Array( 1 => __( 'Enabled', 'all_in_one_seo_pack' ),
  105. 0 => __( 'Disabled', 'all_in_one_seo_pack' ) )
  106. ),
  107. "cap_titles"=> Array(
  108. 'name' => __( 'Capitalize Titles:', 'all_in_one_seo_pack' ),
  109. 'help_text' => __( "Check this and Search Page Titles and Tag Page Titles will have the first letter of each word capitalized.", 'all_in_one_seo_pack' ),
  110. 'default' => 1),
  111. "cap_cats"=> Array(
  112. 'name' => __( 'Capitalize Category Titles:', 'all_in_one_seo_pack' ),
  113. 'help_text' => __( "Check this and Category Titles will have the first letter of each word capitalized.", 'all_in_one_seo_pack' ),
  114. 'default' => 1),
  115. "page_title_format"=> Array(
  116. 'name' => __( 'Page Title Format:', 'all_in_one_seo_pack' ),
  117. 'help_text' =>
  118. __( 'The following macros are supported:', 'all_in_one_seo_pack' )
  119. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  120. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  121. __( '%page_title% - The original title of the page', 'all_in_one_seo_pack' ) . '</li><li>' .
  122. __( '%category_title% - The (main) category of the page', 'all_in_one_seo_pack' ) . '</li><li>' .
  123. __( '%category% - Alias for %category_title%', 'all_in_one_seo_pack' ) . '</li><li>' .
  124. __( "%page_author_login% - This page's author' login", 'all_in_one_seo_pack' ) . '</li><li>' .
  125. __( "%page_author_nicename% - This page's author' nicename", 'all_in_one_seo_pack' ) . '</li><li>' .
  126. __( "%page_author_firstname% - This page's author' first name (capitalized)", 'all_in_one_seo_pack' ) . '</li><li>' .
  127. __( "%page_author_lastname% - This page's author' last name (capitalized)", 'all_in_one_seo_pack' ) . '</li>' .
  128. '</ul>',
  129. 'type' => 'text',
  130. 'default' => '%page_title% | %blog_title%',
  131. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  132. "post_title_format"=> Array(
  133. 'name' => __( 'Post Title Format:', 'all_in_one_seo_pack' ),
  134. 'help_text' =>
  135. __( 'The following macros are supported:', 'all_in_one_seo_pack' )
  136. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  137. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  138. __( '%post_title% - The original title of the post', 'all_in_one_seo_pack' ) . '</li><li>' .
  139. __( '%category_title% - The (main) category of the post', 'all_in_one_seo_pack' ) . '</li><li>' .
  140. __( '%category% - Alias for %category_title%', 'all_in_one_seo_pack' ) . '</li><li>' .
  141. __( "%post_author_login% - This post's author' login", 'all_in_one_seo_pack' ) . '</li><li>' .
  142. __( "%post_author_nicename% - This post's author' nicename", 'all_in_one_seo_pack' ) . '</li><li>' .
  143. __( "%post_author_firstname% - This post's author' first name (capitalized)", 'all_in_one_seo_pack' ) . '</li><li>' .
  144. __( "%post_author_lastname% - This post's author' last name (capitalized)", 'all_in_one_seo_pack' ) . '</li>' .
  145. '</ul>',
  146. 'type' => 'text',
  147. 'default' => '%post_title% | %blog_title%',
  148. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  149. "category_title_format"=> Array(
  150. 'name' => __( 'Category Title Format:', 'all_in_one_seo_pack' ),
  151. 'help_text' =>
  152. __( 'The following macros are supported:', 'all_in_one_seo_pack' ) .
  153. '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  154. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  155. __( '%category_title% - The original title of the category', 'all_in_one_seo_pack' ) . '</li><li>' .
  156. __( '%category_description% - The description of the category', 'all_in_one_seo_pack' ) . '</li></ul>',
  157. 'type' => 'text',
  158. 'default' => '%category_title% | %blog_title%',
  159. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  160. "archive_title_format"=> Array(
  161. 'name' => __( 'Archive Title Format:', 'all_in_one_seo_pack' ),
  162. 'help_text' =>
  163. __( 'The following macros are supported:', 'all_in_one_seo_pack' ) .
  164. '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  165. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  166. __( '%date% - The original archive title given by wordpress, e.g. "2007" or "2007 August"', 'all_in_one_seo_pack' ) . '</li></ul>',
  167. 'type' => 'text',
  168. 'default' => '%date% | %blog_title%',
  169. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  170. "tag_title_format"=> Array(
  171. 'name' => __( 'Tag Title Format:', 'all_in_one_seo_pack' ),
  172. 'help_text' =>
  173. __( 'The following macros are supported:', 'all_in_one_seo_pack' ) .
  174. '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  175. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  176. __( '%tag% - The name of the tag', 'all_in_one_seo_pack' ) . '</li></ul>',
  177. 'type' => 'text',
  178. 'default' => '%tag% | %blog_title%',
  179. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  180. "search_title_format"=> Array(
  181. 'name' => __( 'Search Title Format:', 'all_in_one_seo_pack' ),
  182. 'help_text' =>
  183. __( 'The following macros are supported:', 'all_in_one_seo_pack' ) .
  184. '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  185. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  186. __( '%search% - What was searched for', 'all_in_one_seo_pack' ) . '</li></ul>',
  187. 'type' => 'text',
  188. 'default' => '%search% | %blog_title%',
  189. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  190. "description_format"=> Array(
  191. 'name' => __( 'Description Format', 'all_in_one_seo_pack' ),
  192. 'help_text' => __( 'The following macros are supported:', 'all_in_one_seo_pack' ) .
  193. '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  194. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  195. __( '%description% - The original description as determined by the plugin, e.g. the excerpt if one is set or an auto-generated one if that option is set', 'all_in_one_seo_pack' ) . '</li><li>' .
  196. __( '%wp_title% - The original wordpress title, e.g. post_title for posts', 'all_in_one_seo_pack' ) . '</li></ul>',
  197. 'type' => 'text',
  198. 'default' => '%description%',
  199. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  200. "404_title_format"=> Array(
  201. 'name' => __( '404 Title Format:', 'all_in_one_seo_pack' ),
  202. 'help_text' => __( 'The following macros are supported:', 'all_in_one_seo_pack' ) .
  203. '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  204. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  205. __( '%request_url% - The original URL path, like "/url-that-does-not-exist/"', 'all_in_one_seo_pack' ) . '</li><li>' .
  206. __( '%request_words% - The URL path in human readable form, like "Url That Does Not Exist"', 'all_in_one_seo_pack' ) . '</li><li>' .
  207. __( '%404_title% - Additional 404 title input"', 'all_in_one_seo_pack' ) . '</li></ul>',
  208. 'type' => 'text',
  209. 'default' => 'Nothing found for %request_words%',
  210. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  211. "paged_format"=> Array(
  212. 'name' => __( 'Paged Format:', 'all_in_one_seo_pack' ),
  213. 'help_text' => __( 'This string gets appended/prepended to titles when they are for paged index pages (like home or archive pages).', 'all_in_one_seo_pack' )
  214. . __( 'The following macros are supported:', 'all_in_one_seo_pack' )
  215. . '<ul><li>' . __( '%page% - The page number', 'all_in_one_seo_pack' ) . '</li></ul>',
  216. 'type' => 'text',
  217. 'default' => ' - Part %page%',
  218. 'condshow' => Array( "aiosp_rewrite_titles" => 1 ) ),
  219. "enablecpost"=> Array(
  220. 'name' => __( 'SEO for Custom Post Types:', 'all_in_one_seo_pack' ),
  221. 'help_text' => __( 'Check this if you want your enable AIOSEOP support for Custom Post Types on this site.', 'all_in_one_seo_pack' ),
  222. 'default' => 'on',
  223. 'type' => 'radio',
  224. 'initial_options' => Array( 'on' => __( 'Enabled', 'all_in_one_seo_pack' ),
  225. 0 => __( 'Disabled', 'all_in_one_seo_pack' ) )
  226. ),
  227. "cpostadvanced" => Array(
  228. 'name' => __( 'Enable Advanced Options:', 'all_in_one_seo_pack' ),
  229. 'help_text' => __( 'This allows you to do more with your custom post types.', 'all_in_one_seo_pack' ),
  230. 'default' => 0,
  231. 'type' => 'radio',
  232. 'initial_options' => Array( 'on' => __( 'Enabled', 'all_in_one_seo_pack' ),
  233. 0 => __( 'Disabled', 'all_in_one_seo_pack' ) ),
  234. 'label' => null,
  235. 'condshow' => Array( "aiosp_enablecpost" => 'on' )
  236. ),
  237. "cpostactive" => Array(
  238. 'name' => __( 'SEO on only these post types:', 'all_in_one_seo_pack' ),
  239. 'help_text' => __( 'Select specific custom post types for AIOSEOP support.', 'all_in_one_seo_pack' ),
  240. 'type' => 'multicheckbox',
  241. 'default' => array('post', 'page'),
  242. 'condshow' => Array( 'aiosp_enablecpost' => 'on', 'aiosp_cpostadvanced' => 'on' )
  243. ),
  244. "cposttitles" => Array(
  245. 'name' => __( 'Custom titles:', 'all_in_one_seo_pack' ),
  246. 'help_text' => __( 'Allows setting specific custom titles for all post types.', 'all_in_one_seo_pack' ),
  247. 'type' => 'checkbox',
  248. 'default' => 0,
  249. 'condshow' => Array( 'aiosp_enablecpost' => 'on', 'aiosp_cpostadvanced' => 'on' )
  250. ),
  251. "posttypecolumns" => Array(
  252. 'name' => __( 'Show Column Labels for Custom Post Types:', 'all_in_one_seo_pack' ),
  253. 'help_text' => __( 'Choose which post types you want to have SEO columns on the edit.php screen. You can select as many as you like.', 'all_in_one_seo_pack' ),
  254. 'type' => 'multicheckbox',
  255. 'default' => array('post', 'page') ),
  256. "admin_bar" => Array(
  257. 'name' => __( 'Display Menu In Admin Bar:', 'all_in_one_seo_pack' ),
  258. 'help_text' => __( 'Check this for easy access to settings from the admin menu bar.', 'all_in_one_seo_pack' ),
  259. 'default' => 'on',
  260. ),
  261. "custom_menu_order" => Array(
  262. 'name' => __( 'Display Menu At The Top:', 'all_in_one_seo_pack' ),
  263. 'help_text' => __( 'Check this for easy access to settings from the top of your WordPress Dashboard.', 'all_in_one_seo_pack' ),
  264. 'default' => 'on',
  265. ),
  266. "google_verify" => Array(
  267. 'name' => __( 'Google Webmaster Tools:', 'all_in_one_seo_pack' ),
  268. 'help_text' => __( 'Enter your verification code here to add a meta tag to your homepage to verify your site.', 'all_in_one_seo_pack' ),
  269. 'default' => '', 'type' => 'text' ),
  270. "bing_verify" => Array(
  271. 'name' => __( 'Bing Webmaster Center:', 'all_in_one_seo_pack' ),
  272. 'help_text' => __( 'Enter your verification code here to add a meta tag to your homepage to verify your site.', 'all_in_one_seo_pack' ),
  273. 'default' => '', 'type' => 'text' ),
  274. "pinterest_verify" => Array(
  275. 'name' => __( 'Pinterest Site Verification:', 'all_in_one_seo_pack' ),
  276. 'help_text' => __( 'Enter your verification code here to add a meta tag to your homepage to verify your site.', 'all_in_one_seo_pack' ),
  277. 'default' => '', 'type' => 'text' ),
  278. "google_publisher"=> Array(
  279. 'name' => __( 'Google Plus Default Profile:', 'all_in_one_seo_pack' ),
  280. 'help_text' => __( 'Enter your Google Plus Profile URL here to link your site\'s pages to Google Plus.', 'all_in_one_seo_pack' ),
  281. 'default' => '', 'type' => 'text' ),
  282. "google_disable_profile"=> Array(
  283. 'name' => __( 'Disable Google Plus Profile:', 'all_in_one_seo_pack' ),
  284. 'help_text' => __( 'Check this option to remove the Google Plus Profile field on user profile pages.', 'all_in_one_seo_pack' ),
  285. 'default' => 0, 'type' => 'checkbox' ),
  286. "google_analytics_id"=> Array(
  287. 'name' => __( 'Google Analytics ID:', 'all_in_one_seo_pack' ),
  288. 'help_text' => __( 'Enter your Google Analytics ID here to track your site with Google Analytics.', 'all_in_one_seo_pack' ),
  289. 'default' => null, 'type' => 'text' ),
  290. "ga_domain"=> Array(
  291. 'name' => __( 'Tracking Domain:', 'all_in_one_seo_pack' ),
  292. 'type' => 'text',
  293. 'help_text' => __( 'Enter domain name for tracking with Google Analytics.', 'all_in_one_seo_pack' ),
  294. 'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
  295. "ga_multi_domain"=> Array(
  296. 'name' => __( 'Track Multiple Domains:', 'all_in_one_seo_pack' ),
  297. 'help_text' => __( 'Enable multi-domain tracking for Google Analytics.', 'all_in_one_seo_pack' ),
  298. 'default' => 0,
  299. 'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
  300. "ga_track_outbound_links"=> Array(
  301. 'name' => __( 'Track Outbound Links:', 'all_in_one_seo_pack' ),
  302. 'help_text' => __( 'Add functionality to track outbound links with Google Analytics.', 'all_in_one_seo_pack' ),
  303. 'default' => 0,
  304. 'condshow' => Array( 'aiosp_google_analytics_id' => Array( 'lhs' => 'aiosp_google_analytics_id', 'op' => '!=', 'rhs' => '' ) ) ),
  305. "use_categories"=> Array(
  306. 'name' => __( 'Use Categories for META keywords:', 'all_in_one_seo_pack' ),
  307. 'help_text' => __( 'Check this if you want your categories for a given post used as the META keywords for this post (in addition to any keywords and tags you specify on the post edit page).', 'all_in_one_seo_pack' ),
  308. 'default' => 0,
  309. 'condshow' => Array( "aiosp_togglekeywords" => 0 ) ),
  310. "use_tags_as_keywords" => Array(
  311. 'name' => __( 'Use Tags for META keywords:', 'all_in_one_seo_pack' ),
  312. 'help_text' => __( 'Check this if you want your tags for a given post used as the META keywords for this post (in addition to any keywords you specify on the post edit page).', 'all_in_one_seo_pack' ),
  313. 'default' => 1,
  314. 'condshow' => Array( "aiosp_togglekeywords" => 0 ) ),
  315. "dynamic_postspage_keywords"=> Array(
  316. 'name' => __( 'Dynamically Generate Keywords for Posts Page:', 'all_in_one_seo_pack' ),
  317. 'help_text' => __( 'Check this if you want your keywords on a custom posts page (set it in options->reading) to be dynamically generated from the keywords of the posts showing on that page. If unchecked, it will use the keywords set in the edit page screen for the posts page.', 'all_in_one_seo_pack' ),
  318. 'default' => 1,
  319. 'condshow' => Array( "aiosp_togglekeywords" => 0 ) ),
  320. "category_noindex"=> Array(
  321. 'name' => __( 'Use noindex for Categories:', 'all_in_one_seo_pack' ),
  322. 'help_text' => __( 'Check this for excluding category pages from being crawled. Useful for avoiding duplicate content.', 'all_in_one_seo_pack' ),
  323. 'default' => 1),
  324. "archive_noindex"=> Array(
  325. 'name' => __( 'Use noindex for Archives:', 'all_in_one_seo_pack' ),
  326. 'help_text' => __( 'Check this for excluding archive pages from being crawled. Useful for avoiding duplicate content.', 'all_in_one_seo_pack' ),
  327. 'default' => 1),
  328. "tags_noindex"=> Array(
  329. 'name' => __( 'Use noindex for Tag Archives:', 'all_in_one_seo_pack' ),
  330. 'help_text' => __( 'Check this for excluding tag pages from being crawled. Useful for avoiding duplicate content.', 'all_in_one_seo_pack' ),
  331. 'default' => 0),
  332. "generate_descriptions"=> Array(
  333. 'name' => __( 'Autogenerate Descriptions:', 'all_in_one_seo_pack' ),
  334. 'help_text' => __( "Check this and your META descriptions will get autogenerated if there's no excerpt.", 'all_in_one_seo_pack' ),
  335. 'default' => 1),
  336. "hide_paginated_descriptions"=> Array(
  337. 'name' => __( 'Remove Descriptions For Paginated Pages:', 'all_in_one_seo_pack' ),
  338. 'help_text' => __( "Check this and your META descriptions will get hidden if on Page 2 or later of paginated content.", 'all_in_one_seo_pack' ),
  339. 'default' => 0),
  340. "unprotect_meta"=> Array(
  341. 'name' => __( 'Unprotect Post Meta Fields:', 'all_in_one_seo_pack' ),
  342. 'help_text' => __( "Unprotect internal postmeta fields for use with XMLRPC -- if you don't know what that is, leave it unchecked.", 'all_in_one_seo_pack' ),
  343. 'default' => 0),
  344. "ex_pages" => Array(
  345. 'name' => __( 'Exclude Pages:', 'all_in_one_seo_pack' ),
  346. 'help_text' => __( "Enter any comma separated pages here to be excluded by All in One SEO Pack. This is helpful when using plugins which generate their own non-WordPress dynamic pages. Ex: <em>/forum/,/contact/</em> For instance, if you want to exclude the virtual pages generated by a forum plugin, all you have to do is give forum or /forum or /forum/ or and any URL with the word \"forum\" in it, such as http://mysite.com/forum or http://mysite.com/forum/someforumpage will be excluded from All in One SEO Pack.", 'all_in_one_seo_pack' ),
  347. 'type' => 'textarea', 'default' => '' ),
  348. "post_meta_tags"=> Array(
  349. 'name' => __( 'Additional Post Headers:', 'all_in_one_seo_pack' ),
  350. 'help_text' => __( 'What you enter here will be copied verbatim to your header on posts.', 'all_in_one_seo_pack' ) . ' ' . __( 'You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack' ),
  351. 'type' => 'textarea', 'default' => '', 'sanitize' => 'default' ),
  352. "page_meta_tags"=> Array(
  353. 'name' => __( 'Additional Page Headers:', 'all_in_one_seo_pack' ),
  354. 'help_text' => __( 'What you enter here will be copied verbatim to your header on pages.', 'all_in_one_seo_pack' ) . ' ' . __( 'You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack' ),
  355. 'type' => 'textarea', 'default' => '', 'sanitize' => 'default' ),
  356. "front_meta_tags"=> Array(
  357. 'name' => __( 'Additional Front Page Headers:', 'all_in_one_seo_pack' ),
  358. 'help_text' => __( 'What you enter here will be copied verbatim to your header on the front page if you have a static page set in Settings, Reading.', 'all_in_one_seo_pack' ) . ' ' . __( 'You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack' ) . ' ' . __( 'This will fall back to using Additional Page Headers if you have them set and nothing is entered here.', 'all_in_one_seo_pack' ),
  359. 'type' => 'textarea', 'default' => '', 'sanitize' => 'default' ),
  360. "home_meta_tags"=> Array(
  361. 'name' => __( 'Additional Blog Page Headers:', 'all_in_one_seo_pack' ),
  362. 'help_text' => __( 'What you enter here will be copied verbatim to your header on the home page if you have Front page displays your latest posts selected in Settings, Reading.  It will also be copied verbatim to your header on the Posts page if you have one set in Settings, Reading.', 'all_in_one_seo_pack' ) . ' ' . __( 'You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack' ),
  363. 'type' => 'textarea', 'default' => '', 'sanitize' => 'default' ),
  364. "do_log"=> Array(
  365. 'name' => __( 'Log important events:', 'all_in_one_seo_pack' ),
  366. 'help_text' => __( 'Check this and SEO pack will create a log of important events (all_in_one_seo_pack.log) in its plugin directory which might help debugging it. Make sure this directory is writable.', 'all_in_one_seo_pack' ),
  367. 'default' => null ),
  368. );
  369. $this->locations = Array(
  370. 'default' => Array( 'name' => $this->name, 'prefix' => 'aiosp_', 'type' => 'settings', 'options' => null ),
  371. 'aiosp' => Array( 'name' => $this->plugin_name, 'type' => 'metabox', 'prefix' => '',
  372. 'options' => Array( 'edit', 'nonce-aioseop-edit', 'upgrade', 'snippet', 'title', 'description', 'keywords', 'noindex', 'nofollow', 'titleatr', 'menulabel', 'disable', 'disable_analytics' ),
  373. 'default_options' => Array(
  374. 'edit' => Array( 'type' => 'hidden', 'default' => 'aiosp_edit', 'prefix' => true, 'nowrap' => 1 ),
  375. 'nonce-aioseop-edit' => Array( 'type' => 'hidden', 'default' => null, 'prefix' => false, 'nowrap' => 1 ),
  376. 'upgrade' => Array( 'type' => 'html', 'label' => 'none',
  377. 'default' => '<a target="__blank" href="http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/">'
  378. . __( 'Upgrade to All in One SEO Pack Pro Version', 'all_in_one_seo_pack' ) . '</a>'
  379. ),
  380. 'snippet' => Array( 'name' => __( 'Preview Snippet', 'all_in_one_seo_pack' ), 'type' => 'custom', 'help_text' => __( 'A preview of what this page might look like in search engine results.', 'all_in_one_seo_pack' ), 'label' => 'top', 'default' => '<div class="preview_snippet"><div id="aioseop_snippet"><h3><a>%s</a></h3><div><div><cite>%s</cite></div><span>%s</span></div></div></div>' ),
  381. 'title' => Array( 'name' => __( 'Title', 'all_in_one_seo_pack' ), 'type' => 'text', 'help_text' => __( 'A custom title that shows up in the title tag for this page.', 'all_in_one_seo_pack' ), 'count' => true, 'size' => 60 ),
  382. 'description' => Array( 'name' => __( 'Description', 'all_in_one_seo_pack' ), 'type' => 'textarea', 'help_text' => __( 'The META description for this page. This will override any autogenerated descriptions.', 'all_in_one_seo_pack' ), 'count' => true, 'cols' => 80, 'rows' => 2 ),
  383. 'keywords' => Array( 'name' => __( 'Keywords (comma separated)', 'all_in_one_seo_pack' ), 'type' => 'text', 'help_text' => __( 'A comma separated list of your most important keywords for this page that will be written as META keywords.', 'all_in_one_seo_pack' ) ),
  384. 'noindex' => Array( 'name' => __( "Robots Meta NOINDEX", 'all_in_one_seo_pack' ), 'help_text' => __( 'Check this box to ask search engines not to index this page.', 'all_in_one_seo_pack' ) ),
  385. 'nofollow' => Array( 'name' => __( "Robots Meta NOFOLLOW", 'all_in_one_seo_pack' ), 'help_text' => __( 'Check this box to ask search engines not to follow links from this page.', 'all_in_one_seo_pack' ) ),
  386. 'titleatr' => Array( 'name' => __( 'Title Attribute', 'all_in_one_seo_pack' ), 'type' => 'text', 'help_text' => __( 'Set the title attribute for menu links.', 'all_in_one_seo_pack' ), 'size' => 60 ),
  387. 'menulabel' => Array( 'name' => __( 'Menu Label', 'all_in_one_seo_pack' ), 'type' => 'text', 'help_text' => __( 'Set the label for this page menu item.', 'all_in_one_seo_pack' ), 'size' => 60 ),
  388. 'disable' => Array( 'name' => __( 'Disable on this page/post', 'all_in_one_seo_pack' ), 'help_text' => __( 'Disable SEO on this page.', 'all_in_one_seo_pack' ) ),
  389. 'disable_analytics' => Array( 'name' => __( 'Disable Google Analytics', 'all_in_one_seo_pack' ), 'help_text' => __( 'Disable Google Analytics on this page.', 'all_in_one_seo_pack' ), 'condshow' => Array( 'aiosp_disable' => 'on' ) ) ),
  390. 'display' => null )
  391. );
  392. $this->layout = Array(
  393. 'default' => Array(
  394. 'name' => __( 'General Settings', 'all_in_one_seo_pack' ),
  395. 'options' => Array() // this is set below, to the remaining options -- pdb
  396. ),
  397. 'home' => Array(
  398. 'name' => __( 'Home Page Settings', 'all_in_one_seo_pack' ),
  399. 'options' => Array( 'home_title', 'home_description', 'home_keywords' )
  400. ),
  401. 'keywords' => Array(
  402. 'name' => __( 'Keyword Settings', 'all_in_one_seo_pack' ),
  403. 'options' => Array( "togglekeywords", "use_categories", "use_tags_as_keywords", "dynamic_postspage_keywords" )
  404. ),
  405. 'title' => Array(
  406. 'name' => __( 'Title Settings', 'all_in_one_seo_pack' ),
  407. 'options' => Array( "rewrite_titles", "force_rewrites", "cap_titles", "cap_cats", "page_title_format", "post_title_format", "category_title_format", "archive_title_format",
  408. "tag_title_format", "search_title_format", "description_format", "404_title_format", "paged_format" )
  409. ),
  410. 'cpt' => Array(
  411. 'name' => __( 'Custom Post Type Settings', 'all_in_one_seo_pack' ),
  412. 'options' => Array( "enablecpost", "cpostadvanced", "cpostactive", "cposttitles" )
  413. ),
  414. 'display' => Array(
  415. 'name' => __( 'Display Settings', 'all_in_one_seo_pack' ),
  416. 'options' => Array( "posttypecolumns", "admin_bar", "custom_menu_order" )
  417. ),
  418. 'webmaster' => Array(
  419. 'name' => __( 'Webmaster Verification', 'all_in_one_seo_pack' ),
  420. 'options' => Array( "google_verify", "bing_verify", "pinterest_verify" )
  421. ),
  422. 'google' => Array(
  423. 'name' => __( 'Google Settings', 'all_in_one_seo_pack' ),
  424. 'options' => Array( "google_publisher", "google_disable_profile", "google_analytics_id", "ga_domain", "ga_multi_domain", "ga_track_outbound_links" )
  425. ),
  426. 'noindex' => Array(
  427. 'name' => __( 'Noindex Settings', 'all_in_one_seo_pack' ),
  428. 'options' => Array( 'category_noindex', 'archive_noindex', 'tags_noindex' )
  429. ),
  430. 'advanced' => Array(
  431. 'name' => __( 'Advanced Settings', 'all_in_one_seo_pack' ),
  432. 'options' => Array( 'generate_descriptions', 'hide_paginated_descriptions', 'unprotect_meta', 'ex_pages', 'post_meta_tags', 'page_meta_tags', 'front_meta_tags', 'home_meta_tags' )
  433. )
  434. );
  435. $other_options = Array();
  436. foreach( $this->layout as $k => $v )
  437. $other_options = array_merge( $other_options, $v['options'] );
  438. $this->layout['default']['options'] = array_diff( array_keys( $this->default_options ), $other_options );
  439. if ( is_admin() ) {
  440. add_action( "aioseop_global_settings_header", Array( $this, 'display_right_sidebar' ) );
  441. add_action( "aioseop_global_settings_footer", Array( $this, 'display_settings_footer' ) );
  442. add_action( "output_option", Array( $this, 'custom_output_option' ), 10, 2 );
  443. }
  444. }
  445. /*** Use custom callback for outputting snippet ***/
  446. function custom_output_option( $buf, $args ) {
  447. if ( $args['name'] == 'aiosp_snippet' ) {
  448. global $post, $aioseop_options, $wp_query;
  449. if ( is_object( $post ) ) {
  450. $post_id = $post->ID;
  451. $p = $post; $w = $wp_query;
  452. if (! $post->post_modified_gmt != '' )
  453. $wp_query = new WP_Query( array( 'p' => $post_id, 'post_type' => $post->post_type ) );
  454. if ( $post->post_type == 'page' )
  455. $wp_query->is_page = true;
  456. elseif ( $post->post_type == 'attachment' )
  457. $wp_query->is_attachment = true;
  458. else
  459. $wp_query->is_single = true;
  460. if ( get_option( 'show_on_front' ) == 'page' ) {
  461. if ( is_page() && $post->ID == get_option( 'page_on_front' ) )
  462. $wp_query->is_front_page = true;
  463. elseif ( $post->ID == get_option( 'page_for_posts' ) )
  464. $wp_query->is_home = true;
  465. }
  466. $args['options']['type'] = 'html';
  467. $args['options']['nowrap'] = false;
  468. $args['options']['save'] = false;
  469. $title = $this->wp_title();
  470. if ( empty( $title ) ) $title = $post->post_title;
  471. if ( ( $aioseop_options['aiosp_can'] ) && ( $url = $this->aiosp_mrt_get_url( $wp_query ) ) )
  472. $url = apply_filters( 'aioseop_canonical_url', $url );
  473. if ( !$url ) $url = get_permalink();
  474. $description = $this->get_post_description( $post );
  475. if ( strlen( $title ) > 70 ) $title = $this->trim_excerpt_without_filters( $title, 70 ) . '...';
  476. if ( strlen( $description ) > 156 ) $description = $this->trim_excerpt_without_filters( $description, 156 ) . '...';
  477. $args['value'] = sprintf( $args['value'], esc_attr( strip_tags( $title ) ), esc_url( $url ), esc_attr( strip_tags( $description ) ) );
  478. $buf = $this->get_option_row( $args['name'], $args['options'], $args );
  479. wp_reset_postdata();
  480. $wp_query = $w; $post = $p;
  481. }
  482. }
  483. return $buf;
  484. }
  485. function add_page_icon() {
  486. wp_enqueue_script( 'wp-pointer', false, array( 'jquery' ) );
  487. wp_enqueue_style( 'wp-pointer' );
  488. $this->add_admin_pointers();
  489. ?>
  490. <style>
  491. #toplevel_page_all-in-one-seo-pack-aioseop_class .wp-menu-image {
  492. background: url(<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>shield-sprite-16.png) no-repeat 6px 6px !important;
  493. }
  494. #toplevel_page_all-in-one-seo-pack-aioseop_class .wp-menu-image img {
  495. display: none;
  496. }
  497. #toplevel_page_all-in-one-seo-pack-aioseop_class:hover .wp-menu-image, #toplevel_page_all-in-one-seo-pack-aioseop_class.wp-has-current-submenu .wp-menu-image {
  498. background-position: 6px -26px !important;
  499. }
  500. #icon-aioseop.icon32 {
  501. background: url(<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>shield32.png) no-repeat left top !important;
  502. }
  503. #aioseop_settings_header #message {
  504. padding: 5px 0px 5px 50px;
  505. background-image: url(<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>update32.png);
  506. background-repeat: no-repeat;
  507. background-position: 10px;
  508. font-size: 14px;
  509. min-height: 32px;
  510. }
  511. @media
  512. only screen and (-webkit-min-device-pixel-ratio: 1.5),
  513. only screen and ( min--moz-device-pixel-ratio: 1.5),
  514. only screen and ( -o-min-device-pixel-ratio: 3/2),
  515. only screen and ( min-device-pixel-ratio: 1.5),
  516. only screen and ( min-resolution: 1.5dppx) {
  517. #toplevel_page_all-in-one-seo-pack-aioseop_class .wp-menu-image {
  518. background-image: url('<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>shield-sprite-32.png') !important;
  519. -webkit-background-size: 16px 48px !important;
  520. -moz-background-size: 16px 48px !important;
  521. background-size: 16px 48px !important;
  522. }
  523. #icon-aioseop.icon32 {
  524. background-image: url('<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>shield64.png') !important;
  525. -webkit-background-size: 32px 32px !important;
  526. -moz-background-size: 32px 32px !important;
  527. background-size: 32px 32px !important;
  528. }
  529. #aioseop_settings_header #message {
  530. background-image: url(<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>update64.png) !important;
  531. -webkit-background-size: 32px 32px !important;
  532. -moz-background-size: 32px 32px !important;
  533. background-size: 32px 32px !important;
  534. }
  535. }
  536. </style>
  537. <script>
  538. function aioseop_show_pointer( handle, value ) {
  539. if ( typeof( jQuery ) != 'undefined' ) {
  540. var p_edge = 'bottom';
  541. var p_align = 'center';
  542. if ( typeof( jQuery( value.pointer_target ).pointer) != 'undefined' ) {
  543. if ( typeof( value.pointer_edge ) != 'undefined' ) p_edge = value.pointer_edge;
  544. if ( typeof( value.pointer_align ) != 'undefined' ) p_align = value.pointer_align;
  545. jQuery(value.pointer_target).pointer({
  546. content : value.pointer_text,
  547. position: {
  548. edge: p_edge,
  549. align: p_align
  550. },
  551. close : function() {
  552. jQuery.post( ajaxurl, {
  553. pointer: handle,
  554. action: 'dismiss-wp-pointer'
  555. });
  556. }
  557. }).pointer('open');
  558. }
  559. }
  560. }
  561. <?php
  562. if ( !empty( $this->pointers ) ) {
  563. ?>
  564. if ( typeof( jQuery ) != 'undefined' ) {
  565. jQuery(document).ready(function() {
  566. var admin_pointer;
  567. var admin_index;
  568. <?php
  569. foreach( $this->pointers as $k => $p )
  570. if ( !empty( $p["pointer_scope"] ) && ( $p["pointer_scope"] == 'global' ) ) {
  571. ?>admin_index = "<?php echo esc_attr($k); ?>";
  572. admin_pointer = <?php echo json_encode( $p ); ?>;
  573. aioseop_show_pointer( admin_index, admin_pointer );
  574. <?php
  575. }
  576. ?>
  577. });
  578. }
  579. <?php
  580. }
  581. ?>
  582. </script>
  583. <?php
  584. }
  585. function add_page_hooks() {
  586. $post_objs = get_post_types( '', 'objects' );
  587. $pt = array_keys( $post_objs );
  588. $rempost = array( 'revision', 'nav_menu_item' );
  589. $pt = array_diff( $pt, $rempost );
  590. $post_types = Array();
  591. foreach ( $pt as $p ) {
  592. if ( !empty( $post_objs[$p]->label ) )
  593. $post_types[$p] = $post_objs[$p]->label;
  594. else
  595. $post_types[$p] = $p;
  596. }
  597. $this->default_options["posttypecolumns"]['initial_options'] = $post_types;
  598. $this->default_options["cpostactive"]['initial_options'] = $post_types;
  599. foreach ( $post_types as $p => $pt ) {
  600. $field = $p . "_title_format";
  601. $name = $post_objs[$p]->labels->singular_name;
  602. if ( !isset( $this->default_options[$field] ) ) {
  603. $this->default_options[$field] = Array (
  604. 'name' => "$name " . __( 'Title Format:', 'all_in_one_seo_pack' ) . "<br />($p)",
  605. 'help_text' =>
  606. __( 'The following macros are supported:', 'all_in_one_seo_pack' )
  607. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all_in_one_seo_pack' ) . '</li><li>' .
  608. __( '%blog_description% - Your blog description', 'all_in_one_seo_pack' ) . '</li><li>' .
  609. __( '%post_title% - The original title of the post', 'all_in_one_seo_pack' ) . '</li><li>' .
  610. __( '%category_title% - The (main) category of the post', 'all_in_one_seo_pack' ) . '</li><li>' .
  611. __( '%category% - Alias for %category_title%', 'all_in_one_seo_pack' ) . '</li><li>' .
  612. __( "%post_author_login% - This post's author' login", 'all_in_one_seo_pack' ) . '</li><li>' .
  613. __( "%post_author_nicename% - This post's author' nicename", 'all_in_one_seo_pack' ) . '</li><li>' .
  614. __( "%post_author_firstname% - This post's author' first name (capitalized)", 'all_in_one_seo_pack' ) . '</li><li>' .
  615. __( "%post_author_lastname% - This post's author' last name (capitalized)", 'all_in_one_seo_pack' ) . '</li>' .
  616. '</ul>',
  617. 'type' => 'text',
  618. 'default' => '%post_title% | %blog_title%',
  619. 'condshow' => Array( 'aiosp_enablecpost' => 'on', 'aiosp_cpostadvanced' => 'on', 'aiosp_cposttitles' => 'on' )
  620. );
  621. $this->layout['cpt']['options'][] = $field;
  622. }
  623. }
  624. $this->setting_options();
  625. add_filter( "{$this->prefix}display_options", Array( $this, 'filter_options' ), 10, 3 );
  626. parent::add_page_hooks();
  627. }
  628. function add_admin_pointers() {
  629. $this->pointers['aioseop_menu_202'] = Array( 'pointer_target' => '#toplevel_page_all-in-one-seo-pack-aioseop_class',
  630. 'pointer_text' => '<h3>' . sprintf( __( 'Welcome to Version %s!', 'all_in_one_seo_pack' ), AIOSEOP_VERSION )
  631. . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! Please review your settings, as we\'re always adding new features for you!', 'all_in_one_seo_pack' ) . '</p>',
  632. 'pointer_edge' => 'top',
  633. 'pointer_align' => 'left',
  634. 'pointer_scope' => 'global'
  635. );
  636. $this->pointers['aioseop_welcome_202'] = Array( 'pointer_target' => '#aioseop_top_button',
  637. 'pointer_text' => '<h3>' . sprintf( __( 'Review Your Settings', 'all_in_one_seo_pack' ), AIOSEOP_VERSION )
  638. . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! New in 2.0: manage your performance with our Performance module; enable it from our new feature manager! And please review your settings, we have added some new ones!', 'all_in_one_seo_pack' ) . '</p>',
  639. 'pointer_edge' => 'bottom',
  640. 'pointer_align' => 'left',
  641. 'pointer_scope' => 'local'
  642. );
  643. $this->filter_pointers();
  644. }
  645. function settings_page_init() {
  646. add_filter( "{$this->prefix}submit_options", Array( $this, 'filter_submit' ) );
  647. }
  648. function enqueue_scripts() {
  649. add_filter( "{$this->prefix}display_settings", Array( $this, 'filter_settings' ), 10, 3 );
  650. parent::enqueue_scripts();
  651. }
  652. function filter_submit( $submit ) {
  653. $submit['Submit_Default']['value'] = __( 'Reset General Settings to Defaults', 'all_in_one_seo_pack' ) . ' &raquo;';
  654. $submit['Submit_All_Default'] = Array( 'type' => 'submit', 'class' => 'button-primary', 'value' => __( 'Reset ALL Settings to Defaults', 'all_in_one_seo_pack' ) . ' &raquo;' );
  655. return $submit;
  656. }
  657. /**
  658. * Handle resetting options to defaults.
  659. */
  660. function reset_options( $location = null, $delete = false ) {
  661. if ( $delete === true ) {
  662. $this->delete_class_option( $delete );
  663. $this->options = Array();
  664. }
  665. $default_options = $this->default_options( $location );
  666. foreach ( $default_options as $k => $v )
  667. $this->options[$k] = $v;
  668. $this->update_class_option( $this->options );
  669. }
  670. function get_current_options( $opts = Array(), $location = null, $defaults = null ) {
  671. if ( ( $location === 'aiosp' ) && ( $this->locations[$location]['type'] == 'metabox' ) ) {
  672. global $post;
  673. $post_id = $post;
  674. if ( is_object( $post_id ) )
  675. $post_id = $post_id->ID;
  676. $get_opts = $this->default_options( $location );
  677. foreach ( Array( 'keywords', 'description', 'title', 'disable', 'disable_analytics', 'noindex', 'nofollow', 'titleatr', 'menulabel' ) as $f ) {
  678. $field = "aiosp_$f";
  679. $get_opts[$field] = htmlspecialchars( stripcslashes( get_post_meta( $post_id, '_aioseop_' . $f, true ) ) );
  680. }
  681. $opts = wp_parse_args( $opts, $get_opts );
  682. return $opts;
  683. } else {
  684. $options = parent::get_current_options( $opts, $location, $defaults );
  685. return $options;
  686. }
  687. }
  688. function filter_settings( $settings, $location, $current ) {
  689. if ( $location == null ) {
  690. $prefix = $this->prefix;
  691. foreach ( Array( 'seopostcol', 'seocustptcol', 'debug_info', 'max_words_excerpt' ) as $opt )
  692. unset( $settings["{$prefix}$opt"] );
  693. } elseif ( $location == 'aiosp' ) {
  694. global $post;
  695. $prefix = $this->get_prefix( $location ) . $location . '_';
  696. if ( is_object( $post ) ) {
  697. if ( $post->post_type != 'page' ) {
  698. unset( $settings["{$prefix}titleatr"] );
  699. unset( $settings["{$prefix}menulabel"] );
  700. }
  701. }
  702. if ( !empty( $this->options[$this->prefix . 'togglekeywords'] ) ) {
  703. unset( $settings["{$prefix}keywords"] );
  704. unset( $settings["{$prefix}togglekeywords"] );
  705. } elseif ( !empty( $current["{$prefix}togglekeywords"] ) ) {
  706. unset( $settings["{$prefix}keywords"] );
  707. }
  708. }
  709. return $settings;
  710. }
  711. function filter_options( $options, $location ) {
  712. if ( $location == null ) {
  713. $prefix = $this->prefix;
  714. if ( isset( $options["{$prefix}rewrite_titles"] ) && ( !empty( $options["{$prefix}rewrite_titles"] ) ) )
  715. $options["{$prefix}rewrite_titles"] = 1;
  716. if ( ( isset( $options["{$prefix}enablecpost"] ) ) && ( $options["{$prefix}enablecpost"] === '' ) )
  717. $options["{$prefix}enablecpost"] = 0;
  718. if ( ( isset( $options["{$prefix}use_original_title"] ) ) && ( $options["{$prefix}use_original_title"] === '' ) )
  719. $options["{$prefix}use_original_title"] = 0;
  720. }
  721. return $options;
  722. }
  723. function display_extra_metaboxes( $add, $meta ) {
  724. echo "<div class='aioseop_metabox_wrapper' >";
  725. switch ( $meta['id'] ) {
  726. case "aioseop-about":
  727. ?><div class="aioseop_metabox_text">
  728. <p><h2 style="display:inline;"><?php echo AIOSEOP_PLUGIN_NAME; ?></h2> by Michael Torbert of <a target="_blank" title="Semper Fi Web Design"
  729. href="http://semperfiwebdesign.com/">Semper Fi Web Design</a>.</p>
  730. <p>
  731. <a target="_blank" title="<?php _e('All in One SEO Plugin Support Forum', 'all_in_one_seo_pack' ); ?>"
  732. href="http://semperplugins.com/support/"><?php _e('Support Forum', 'all_in_one_seo_pack' ); ?></a>
  733. | <strong><a target="_blank" title="<?php _e('Pro Version', 'all_in_one_seo_pack' ); ?>"
  734. href="http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/">
  735. <?php _e('UPGRADE TO PRO VERSION', 'all_in_one_seo_pack' ); ?></a></strong></p>
  736. </div>
  737. <?php
  738. case "aioseop-donate":
  739. ?>
  740. <div>
  741. <div class="aioseop_metabox_text">
  742. <p>If you like this plugin and find it useful, help keep this plugin free and actively developed by clicking the <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8"
  743. target="_blank"><strong>donate</strong></a> button or send me a gift from my <a
  744. href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank">
  745. <strong>Amazon wishlist</strong></a>. Also, don't forget to follow me on <a
  746. href="http://twitter.com/michaeltorbert/" target="_blank"><strong>Twitter</strong></a>.</p>
  747. </div>
  748. <div class="aioseop_metabox_feature">
  749. <a target="_blank" title="<?php _e( 'Donate', 'all_in_one_seo_pack' ); ?>"
  750. href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">
  751. <img src="<?php echo AIOSEOP_PLUGIN_URL; ?>images/donate.jpg" alt="<?php _e('Donate with Paypal', 'all_in_one_seo_pack' ); ?>" /> </a>
  752. <a target="_blank" title="Amazon Wish List" href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web">
  753. <img src="<?php echo AIOSEOP_PLUGIN_URL; ?>images/amazon.jpg" alt="<?php _e('My Amazon Wish List', 'all_in_one_seo_pack' ); ?>" /> </a>
  754. <a target="_blank" title="<?php _e( 'Follow us on Facebook', 'all_in_one_seo_pack' ); ?>" href="http://www.facebook.com/pages/Semper-Fi-Web-Design/121878784498475"><span class="aioseop_follow_button aioseop_facebook_follow"></span></a>
  755. <a target="_blank" title="<?php _e( 'Follow us on Twitter', 'all_in_one_seo_pack' ); ?>" href="http://twitter.com/semperfidev/"><span class="aioseop_follow_button aioseop_twitter_follow"></span></a>
  756. </div>
  757. </div>
  758. <?php
  759. break;
  760. case "aioseop-list":
  761. ?>
  762. <div class="aioseop_metabox_text">
  763. <form action="http://semperfiwebdesign.us1.list-manage.com/subscribe/post?u=794674d3d54fdd912f961ef14&amp;id=af0a96d3d9"
  764. method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank">
  765. <h2><?php _e( 'Join our mailing list for tips, tricks, and WordPress secrets.', 'all_in_one_seo_pack' ); ?></h2>
  766. <p><i><?php _e( 'Sign up today and receive a free copy of the e-book 5 SEO Tips for WordPress ($39 value).', 'all_in_one_seo_pack' ); ?></i></p>
  767. <p><input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL" placeholder="Email Address">
  768. <input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn"></p>
  769. </form>
  770. </div>
  771. <?php
  772. break;
  773. case "aioseop-support":
  774. ?><div class="aioseop_metabox_text">
  775. <p><?php _e( 'For support please visit the Semper Plugins Support Forum at http://semperplugins.com/support/', 'all_in_one_seo_pack' ); ?></p>
  776. </div>
  777. <?php
  778. break;
  779. }
  780. echo "</div>";
  781. }
  782. function get_queried_object() {
  783. static $p = null;
  784. global $wp_query, $post;
  785. if ( $p !== null ) return $p;
  786. if ( is_object( $post ) )
  787. $p = $post;
  788. else {
  789. if ( !$wp_query ) return null;
  790. $p = $wp_query->get_queried_object();
  791. }
  792. return $p;
  793. }
  794. function template_redirect() {
  795. global $aioseop_options;
  796. $post = $this->get_queried_object();
  797. if( aioseop_mrt_exclude_this_page() ) return;
  798. if ( is_feed() ) return;
  799. if ( is_single() || is_page() ) {
  800. $aiosp_disable = htmlspecialchars(stripcslashes( get_post_meta( $post->ID, '_aioseop_disable', true ) ) );
  801. if ( $aiosp_disable ) {
  802. $aiosp_disable_analytics = htmlspecialchars(stripcslashes( get_post_meta( $post->ID, '_aioseop_disable_analytics', true ) ) );
  803. if ( !$aiosp_disable_analytics ) {
  804. if ( aioseop_option_isset( 'aiosp_google_analytics_id' ) ) {
  805. remove_action( 'aioseop_modules_wp_head', array( $this, 'aiosp_google_analytics' ) );
  806. add_action( 'wp_head', array( $this, 'aiosp_google_a…

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