All_in_One_SEO_Pack

Class All_in_One_SEO_Pack.

Defined (1)

The class is defined in the following location(s).

/aioseop_class.php  
  1. class All_in_One_SEO_Pack extends All_in_One_SEO_Pack_Module { 
  2.  
  3. // Current version of the plugin. 
  4. var $version = AIOSEOP_VERSION; 
  5.  
  6. // Max numbers of chars in auto-generated description. 
  7. var $maximum_description_length = 160; 
  8.  
  9. // Minimum number of chars an excerpt should be so that it can be used as description. 
  10. var $minimum_description_length = 1; 
  11.  
  12. // Whether output buffering is already being used during forced title rewrites. 
  13. var $ob_start_detected = false; 
  14.  
  15. // The start of the title text in the head section for forced title rewrites. 
  16. var $title_start = - 1; 
  17.  
  18. // The end of the title text in the head section for forced title rewrites. 
  19. var $title_end = - 1; 
  20.  
  21. // The title before rewriting. 
  22. var $orig_title = ''; 
  23.  
  24. // Filename of log file. 
  25. var $log_file; 
  26.  
  27. // Flag whether there should be logging. 
  28. var $do_log; 
  29.  
  30. var $token; 
  31. var $secret; 
  32. var $access_token; 
  33. var $ga_token; 
  34. var $account_cache; 
  35. var $profile_id; 
  36. var $meta_opts = false; 
  37. var $is_front_page = null; 
  38.  
  39. /** 
  40. * All_in_One_SEO_Pack constructor. 
  41. */ 
  42. function __construct() { 
  43. global $aioseop_options; 
  44. $this->log_file = dirname( __FILE__ ) . '/all-in-one-seo-pack.log'; // PHP <5.3 compatibility, once we drop support we can use __DIR___. 
  45.  
  46. if ( ! empty( $aioseop_options ) && isset( $aioseop_options['aiosp_do_log'] ) && $aioseop_options['aiosp_do_log'] ) { 
  47. $this->do_log = true; 
  48. } else { 
  49. $this->do_log = false; 
  50.  
  51. $this->name = sprintf( __( '%s Plugin Options', 'all-in-one-seo-pack' ), AIOSEOP_PLUGIN_NAME ); 
  52. $this->menu_name = __( 'General Settings', 'all-in-one-seo-pack' ); 
  53.  
  54. $this->prefix = 'aiosp_'; // Option prefix. 
  55. $this->option_name = 'aioseop_options'; 
  56. $this->store_option = true; 
  57. $this->file = __FILE__; // The current file. 
  58. $blog_name = esc_attr( get_bloginfo( 'name' ) ); 
  59. parent::__construct(); 
  60.  
  61. $this->help_text = array( 
  62. 'donate' => __( 'All donations support continued development of this free software.', 'all-in-one-seo-pack' ),  
  63. 'license_key' => __( 'This will be the license key received when the product was purchased. This is used for automatic upgrades.', 'all-in-one-seo-pack' ),  
  64. 'can' => __( "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' ),  
  65. 'no_paged_canonical_links' => __( 'Checking this option will set the Canonical URL for all paginated content to the first page.', 'all-in-one-seo-pack' ),  
  66. 'customize_canonical_links' => __( 'Checking this option will allow you to customize Canonical URLs for specific posts.', 'all-in-one-seo-pack' ),  
  67. 'can_set_protocol' => __( 'Set protocol for canonical URLs.', 'all-in-one-seo-pack' ),  
  68. 'use_original_title' => __( 'Use wp_title to get the title used by the theme; this is disabled by default. If you use this option, set your title formats appropriately, as your theme might try to do its own title SEO as well.', 'all-in-one-seo-pack' ),  
  69. 'do_log' => __( 'Check this and All in One SEO Pack will create a log of important events (all-in-one-seo-pack.log) in its plugin directory which might help debugging. Make sure this directory is writable.', 'all-in-one-seo-pack' ),  
  70. 'home_title' => __( 'As the name implies, this will be the Meta Title of your homepage. This is independent of any other option. If not set, the default Site Title (found in WordPress under Settings, General, Site Title) will be used.', 'all-in-one-seo-pack' ),  
  71. 'home_description' => __( 'This will be the Meta Description for your homepage. This is independent of any other option. The default is no Meta Description at all if this is not set.', 'all-in-one-seo-pack' ),  
  72. 'home_keywords' => __( 'Enter a comma separated list of your most important keywords for your site that will be written as Meta Keywords on your homepage. Do not stuff everything in here.', 'all-in-one-seo-pack' ),  
  73. 'use_static_home_info' => __( 'Checking this option uses the title, description, and keywords set on your static Front Page.', 'all-in-one-seo-pack' ),  
  74. 'togglekeywords' => __( 'This option allows you to toggle the use of Meta Keywords throughout the whole of the site.', 'all-in-one-seo-pack' ),  
  75. 'use_categories' => __( 'Check this if you want your categories for a given post used as the Meta Keywords for this post (in addition to any keywords you specify on the Edit Post screen).', 'all-in-one-seo-pack' ),  
  76. 'use_tags_as_keywords' => __( '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 Edit Post screen).', 'all-in-one-seo-pack' ),  
  77. 'dynamic_postspage_keywords' => __( 'Check this if you want your keywords on your Posts page (set in WordPress under Settings, Reading, Front Page Displays) and your archive pages 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' ),  
  78. 'rewrite_titles' => __( "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 title bar and in the source code. If enabled, all page, post, category, search and archive page titles get rewritten. You can specify the format for most of them. For example: Using the default post title format below, Rewrite Titles will write all post titles as 'Post Title | Blog Name'. If you have manually defined a title using All in One SEO Pack, this will become the title of your post in the format string.", 'all-in-one-seo-pack' ),  
  79. 'cap_titles' => __( 'Check this and Search Page Titles and Tag Page Titles will have the first letter of each word capitalized.', 'all-in-one-seo-pack' ),  
  80. 'cap_cats' => __( 'Check this and Category Titles will have the first letter of each word capitalized.', 'all-in-one-seo-pack' ),  
  81. 'home_page_title_format' => 
  82. __( 'This controls the format of the title tag for your Home Page.<br />The following macros are supported:', 'all-in-one-seo-pack' ) 
  83. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  84. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  85. __( '%page_title% - The original title of the page', 'all-in-one-seo-pack' ) . '</li><li>' . 
  86. __( "%page_author_login% - This page's author' login", 'all-in-one-seo-pack' ) . '</li><li>' . 
  87. __( "%page_author_nicename% - This page's author' nicename", 'all-in-one-seo-pack' ) . '</li><li>' . 
  88. __( "%page_author_firstname% - This page's author' first name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' . 
  89. __( "%page_author_lastname% - This page's author' last name (capitalized)", 'all-in-one-seo-pack' ) . '</li></ul>',  
  90. 'page_title_format' => 
  91. __( 'This controls the format of the title tag for Pages.<br />The following macros are supported:', 'all-in-one-seo-pack' ) 
  92. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  93. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  94. __( '%page_title% - The original title of the page', 'all-in-one-seo-pack' ) . '</li><li>' . 
  95. __( "%page_author_login% - This page's author' login", 'all-in-one-seo-pack' ) . '</li><li>' . 
  96. __( "%page_author_nicename% - This page's author' nicename", 'all-in-one-seo-pack' ) . '</li><li>' . 
  97. __( "%page_author_firstname% - This page's author' first name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' . 
  98. __( "%page_author_lastname% - This page's author' last name (capitalized)", 'all-in-one-seo-pack' ) . '</li></ul>',  
  99. 'post_title_format' => 
  100. __( 'This controls the format of the title tag for Posts.<br />The following macros are supported:', 'all-in-one-seo-pack' ) 
  101. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  102. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  103. __( '%post_title% - The original title of the post', 'all-in-one-seo-pack' ) . '</li><li>' . 
  104. __( '%category_title% - The (main) category of the post', 'all-in-one-seo-pack' ) . '</li><li>' . 
  105. __( '%category% - Alias for %category_title%', 'all-in-one-seo-pack' ) . '</li><li>' . 
  106. __( "%post_author_login% - This post's author' login", 'all-in-one-seo-pack' ) . '</li><li>' . 
  107. __( "%post_author_nicename% - This post's author' nicename", 'all-in-one-seo-pack' ) . '</li><li>' . 
  108. __( "%post_author_firstname% - This post's author' first name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' . 
  109. __( "%post_author_lastname% - This post's author' last name (capitalized)", 'all-in-one-seo-pack' ) . '</li></ul>',  
  110. 'category_title_format' => 
  111. __( 'This controls the format of the title tag for Category Archives.<br />The following macros are supported:', 'all-in-one-seo-pack' ) . 
  112. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  113. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  114. __( '%category_title% - The original title of the category', 'all-in-one-seo-pack' ) . '</li><li>' . 
  115. __( '%category_description% - The description of the category', 'all-in-one-seo-pack' ) . '</li></ul>',  
  116. 'archive_title_format' => 
  117. __( 'This controls the format of the title tag for Custom Post Archives.<br />The following macros are supported:', 'all-in-one-seo-pack' ) . 
  118. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  119. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  120. __( '%archive_title - The original archive title given by wordpress', 'all-in-one-seo-pack' ) . '</li></ul>',  
  121. 'date_title_format' => 
  122. __( 'This controls the format of the title tag for Date Archives.<br />The following macros are supported:', 'all-in-one-seo-pack' ) . 
  123. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  124. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  125. __( '%date% - The original archive title given by wordpress, e.g. "2007" or "2007 August"', 'all-in-one-seo-pack' ) . '</li><li>' . 
  126. __( '%day% - The original archive day given by wordpress, e.g. "17"', 'all-in-one-seo-pack' ) . '</li><li>' . 
  127. __( '%month% - The original archive month given by wordpress, e.g. "August"', 'all-in-one-seo-pack' ) . '</li><li>' . 
  128. __( '%year% - The original archive year given by wordpress, e.g. "2007"', 'all-in-one-seo-pack' ) . '</li></ul>',  
  129. 'author_title_format' => 
  130. __( 'This controls the format of the title tag for Author Archives.<br />The following macros are supported:', 'all-in-one-seo-pack' ) . 
  131. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  132. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  133. __( '%author% - The original archive title given by wordpress, e.g. "Steve" or "John Smith"', 'all-in-one-seo-pack' ) . '</li></ul>',  
  134. 'tag_title_format' => 
  135. __( 'This controls the format of the title tag for Tag Archives.<br />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. __( '%tag% - The name of the tag', 'all-in-one-seo-pack' ) . '</li></ul>',  
  139. 'search_title_format' => 
  140. __( 'This controls the format of the title tag for the Search page.<br />The following macros are supported:', 'all-in-one-seo-pack' ) . 
  141. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  142. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  143. __( '%search% - What was searched for', 'all-in-one-seo-pack' ) . '</li></ul>',  
  144. 'description_format' => __( 'This controls the format of Meta Descriptions.The following macros are supported:', 'all-in-one-seo-pack' ) . 
  145. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  146. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  147. __( '%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>' . 
  148. __( '%post_title% - The original title of the post', 'all-in-one-seo-pack' ) . '</li><li>' . 
  149. __( '%wp_title% - The original wordpress title, e.g. post_title for posts', 'all-in-one-seo-pack' ) . '</li></ul>',  
  150. '404_title_format' => __( 'This controls the format of the title tag for the 404 page.<br />The following macros are supported:', 'all-in-one-seo-pack' ) . 
  151. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  152. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  153. __( '%request_url% - The original URL path, like "/url-that-does-not-exist/"', 'all-in-one-seo-pack' ) . '</li><li>' . 
  154. __( '%request_words% - The URL path in human readable form, like "Url That Does Not Exist"', 'all-in-one-seo-pack' ) . '</li><li>' . 
  155. __( '%404_title% - Additional 404 title input"', 'all-in-one-seo-pack' ) . '</li></ul>',  
  156. 'paged_format' => __( 'This string gets appended/prepended to titles of paged index pages (like home or archive pages).', 'all-in-one-seo-pack' ) 
  157. . __( 'The following macros are supported:', 'all-in-one-seo-pack' ) 
  158. . '<ul><li>' . __( '%page% - The page number', 'all-in-one-seo-pack' ) . '</li></ul>',  
  159. 'enablecpost' => __( 'Check this if you want to use All in One SEO Pack with any Custom Post Types on this site.', 'all-in-one-seo-pack' ),  
  160. 'cpostadvanced' => __( 'This will show or hide the advanced options for SEO for Custom Post Types.', 'all-in-one-seo-pack' ),  
  161. 'cpostactive' => __( 'Use these checkboxes to select which Post Types you want to use All in One SEO Pack with.', 'all-in-one-seo-pack' ),  
  162. 'taxactive' => __( 'Use these checkboxes to select which Taxonomies you want to use All in One SEO Pack with.', 'all-in-one-seo-pack' ),  
  163. 'cposttitles' => __( 'This allows you to set the title tags for each Custom Post Type.', 'all-in-one-seo-pack' ),  
  164. 'posttypecolumns' => __( 'This lets you select which screens display the SEO Title, SEO Keywords and SEO Description columns.', 'all-in-one-seo-pack' ),  
  165. 'admin_bar' => __( 'Check this to add All in One SEO Pack to the Admin Bar for easy access to your SEO settings.', 'all-in-one-seo-pack' ),  
  166. 'custom_menu_order' => __( 'Check this to move the All in One SEO Pack menu item to the top of your WordPress Dashboard menu.', 'all-in-one-seo-pack' ),  
  167. 'google_verify' => __( "Enter your verification code here to verify your site with Google Webmaster Tools.<br /><a href='http://semperplugins.com/documentation/google-webmaster-tools-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),  
  168. 'bing_verify' => __( "Enter your verification code here to verify your site with Bing Webmaster Tools.<br /><a href='http://semperplugins.com/documentation/bing-webmaster-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),  
  169. 'pinterest_verify' => __( "Enter your verification code here to verify your site with Pinterest.<br /><a href='http://semperplugins.com/documentation/pinterest-site-verification/' target='_blank'>Click here for documentation on this setting</a>", 'all-in-one-seo-pack' ),  
  170. 'google_publisher' => __( 'Enter your Google+ Profile URL here to add the rel=*author* tag to your site for Google authorship. It is recommended that the URL you enter here should be your personal Google+ profile. Use the Advanced Authorship Options below if you want greater control over the use of authorship.', 'all-in-one-seo-pack' ),  
  171. 'google_disable_profile' => __( 'Check this to remove the Google Plus field from the user profile screen.', 'all-in-one-seo-pack' ),  
  172. 'google_author_advanced' => __( 'Enable this to display advanced options for controlling Google Plus authorship information on your website.', 'all-in-one-seo-pack' ),  
  173. 'google_author_location' => __( 'This option allows you to control which types of pages you want to display rel=\"author\" on for Google authorship. The options include the Front Page (the homepage of your site), Posts, Pages, and any Custom Post Types. The Everywhere Else option includes 404, search, categories, tags, custom taxonomies, date archives, author archives and any other page template.', 'all-in-one-seo-pack' ),  
  174. 'google_enable_publisher' => __( 'This option allows you to control whether rel=\"publisher\" is displayed on the homepage of your site. Google recommends using this if the site is a business website.', 'all-in-one-seo-pack' ),  
  175. 'google_specify_publisher' => __( 'The Google+ profile you enter here will appear on your homepage only as the rel=\"publisher\" tag. It is recommended that the URL you enter here should be the Google+ profile for your business.', 'all-in-one-seo-pack' ),  
  176. 'google_sitelinks_search' => __( 'Add markup to display the Google Sitelinks Search Box next to your search results in Google.', 'all-in-one-seo-pack' ),  
  177. 'google_set_site_name' => __( 'Add markup to tell Google the preferred name for your website.', 'all-in-one-seo-pack' ),  
  178. 'google_connect' => __( 'Press the connect button to connect with Google Analytics; or if already connected, press the disconnect button to disable and remove any stored analytics credentials.', 'all-in-one-seo-pack' ),  
  179. 'google_analytics_id' => __( 'Enter your Google Analytics ID here to track visitor behavior on your site using Google Analytics.', 'all-in-one-seo-pack' ),  
  180. 'ga_advanced_options' => __( 'Check to use advanced Google Analytics options.', 'all-in-one-seo-pack' ),  
  181. 'ga_domain' => __( 'Enter your domain name without the http:// to set your cookie domain.', 'all-in-one-seo-pack' ),  
  182. 'ga_multi_domain' => __( 'Use this option to enable tracking of multiple or additional domains.', 'all-in-one-seo-pack' ),  
  183. 'ga_addl_domains' => __( 'Add a list of additional domains to track here. Enter one domain name per line without the http://.', 'all-in-one-seo-pack' ),  
  184. 'ga_anonymize_ip' => __( 'This enables support for IP Anonymization in Google Analytics.', 'all-in-one-seo-pack' ),  
  185. 'ga_display_advertising' => __( 'This enables support for the Display Advertiser Features in Google Analytics.', 'all-in-one-seo-pack' ),  
  186. 'ga_exclude_users' => __( 'Exclude logged-in users from Google Analytics tracking by role.', 'all-in-one-seo-pack' ),  
  187. 'ga_track_outbound_links' => __( 'Check this if you want to track outbound links with Google Analytics.', 'all-in-one-seo-pack' ),  
  188. 'ga_link_attribution' => __( 'This enables support for the Enhanced Link Attribution in Google Analytics.', 'all-in-one-seo-pack' ),  
  189. 'ga_enhanced_ecommerce' => __( 'This enables support for the Enhanced Ecommerce in Google Analytics.', 'all-in-one-seo-pack' ),  
  190. 'cpostnoindex' => __( 'Set the default NOINDEX setting for each Post Type.', 'all-in-one-seo-pack' ),  
  191. 'cpostnofollow' => __( 'Set the default NOFOLLOW setting for each Post Type.', 'all-in-one-seo-pack' ),  
  192.  
  193. 'category_noindex' => __( 'Check this to ask search engines not to index Category Archives. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  194. 'archive_date_noindex' => __( 'Check this to ask search engines not to index Date Archives. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  195. 'archive_author_noindex' => __( 'Check this to ask search engines not to index Author Archives. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  196. 'tags_noindex' => __( 'Check this to ask search engines not to index Tag Archives. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  197. 'search_noindex' => __( 'Check this to ask search engines not to index the Search page. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  198. '404_noindex' => __( 'Check this to ask search engines not to index the 404 page.', 'all-in-one-seo-pack' ),  
  199. 'tax_noindex' => __( 'Check this to ask search engines not to index custom Taxonomy archive pages. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  200. 'paginated_noindex' => __( 'Check this to ask search engines not to index paginated pages/posts. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  201. 'paginated_nofollow' => __( 'Check this to ask search engines not to follow links from paginated pages/posts. Useful for avoiding duplicate content.', 'all-in-one-seo-pack' ),  
  202. 'noodp' => __( 'Check this box to ask search engines not to use descriptions from the Open Directory Project for your entire site.', 'all-in-one-seo-pack' ),  
  203. 'cpostnoodp' => __( 'Set the default noodp setting for each Post Type.', 'all-in-one-seo-pack' ),  
  204. 'noydir' => __( 'Check this box to ask Yahoo! not to use descriptions from the Yahoo! directory for your entire site.', 'all-in-one-seo-pack' ),  
  205. 'cpostnoydir' => __( 'Set the default noydir setting for each Post Type.', 'all-in-one-seo-pack' ),  
  206. 'skip_excerpt' => __( "Check this and your Meta Descriptions won't be generated from the excerpt.", 'all-in-one-seo-pack' ),  
  207. 'generate_descriptions' => __( 'Check this and your Meta Descriptions will be auto-generated from your excerpt or content.', 'all-in-one-seo-pack' ),  
  208. 'run_shortcodes' => __( 'Check this and shortcodes will get executed for descriptions auto-generated from content.', 'all-in-one-seo-pack' ),  
  209. 'hide_paginated_descriptions' => __( 'Check this and your Meta Descriptions will be removed from page 2 or later of paginated content.', 'all-in-one-seo-pack' ),  
  210. 'dont_truncate_descriptions' => __( 'Check this to prevent your Description from being truncated regardless of its length.', 'all-in-one-seo-pack' ),  
  211. 'schema_markup' => __( 'Check this to support Schema.org markup, i.e., itemprop on supported metadata.', 'all-in-one-seo-pack' ),  
  212. 'unprotect_meta' => __( "Check this to unprotect internal postmeta fields for use with XMLRPC. If you don't know what that is, leave it unchecked.", 'all-in-one-seo-pack' ),  
  213. 'redirect_attachement_parent' => __( 'Redirect attachment pages to post parent.', 'all-in-one-seo-pack' ),  
  214. 'ex_pages' => __( 'Enter a comma separated list of 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 add 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 here and it will be excluded from All in One SEO Pack.', 'all-in-one-seo-pack' ),  
  215. 'post_meta_tags' => __( 'What you enter here will be copied verbatim to the header of all Posts. You can enter whatever additional headers you want here, even references to stylesheets.', 'all-in-one-seo-pack' ),  
  216. 'page_meta_tags' => __( 'What you enter here will be copied verbatim to the header of all Pages. You can enter whatever additional headers you want here, even references to stylesheets.', 'all-in-one-seo-pack' ),  
  217. 'front_meta_tags' => __( 'What you enter here will be copied verbatim to the header of the front page if you have set a static page in Settings, Reading, Front Page Displays. You can enter whatever additional headers you want here, even references to stylesheets. This will fall back to using Additional Page Headers if you have them set and nothing is entered here.', 'all-in-one-seo-pack' ),  
  218. 'home_meta_tags' => __( 'What you enter here will be copied verbatim to the header of the home page if you have Front page displays your latest posts selected in Settings, Reading. It will also be copied verbatim to the header on the Posts page if you have one set in Settings, Reading. You can enter whatever additional headers you want here, even references to stylesheets.', 'all-in-one-seo-pack' ),  
  219. ); 
  220.  
  221. $this->help_anchors = array( 
  222. 'license_key' => '#license-key',  
  223. 'can' => '#canonical-urls',  
  224. 'no_paged_canonical_links' => '#no-pagination-for-canonical-urls',  
  225. 'customize_canonical_links' => '#enable-custom-canonical-urls',  
  226. 'can_set_protocol' => '#set-protocol-for-canonical-urls',  
  227. 'use_original_title' => '#use-original-title',  
  228. 'schema_markup' => '#use-schema-markup',  
  229. 'do_log' => '#log-important-events',  
  230. 'home_title' => '#home-title',  
  231. 'home_description' => '#home-description',  
  232. 'home_keywords' => '#home-keywords',  
  233. 'use_static_home_info' => '#use-static-front-page-instead',  
  234. 'togglekeywords' => '#use-keywords',  
  235. 'use_categories' => '#use-categories-for-meta-keywords',  
  236. 'use_tags_as_keywords' => '#use-tags-for-meta-keywords',  
  237. 'dynamic_postspage_keywords' => '#dynamically-generate-keywords-for-posts-page',  
  238. 'rewrite_titles' => '#rewrite-titles',  
  239. 'cap_titles' => '#capitalize-titles',  
  240. 'cap_cats' => '#capitalize-titles',  
  241. 'home_page_title_format' => '#title-format-fields',  
  242. 'page_title_format' => '#title-format-fields',  
  243. 'post_title_format' => '#title-format-fields',  
  244. 'category_title_format' => '#title-format-fields',  
  245. 'archive_title_format' => '#title-format-fields',  
  246. 'date_title_format' => '#title-format-fields',  
  247. 'author_title_format' => '#title-format-fields',  
  248. 'tag_title_format' => '#title-format-fields',  
  249. 'search_title_format' => '#title-format-fields',  
  250. 'description_format' => '#title-format-fields',  
  251. '404_title_format' => '#title-format-fields',  
  252. 'paged_format' => '#title-format-fields',  
  253. 'enablecpost' => '#seo-for-custom-post-types',  
  254. 'cpostadvanced' => '#enable-advanced-options',  
  255. 'cpostactive' => '#seo-on-only-these-post-types',  
  256. 'taxactive' => '#seo-on-only-these-taxonomies',  
  257. 'cposttitles' => '#custom-titles',  
  258. 'posttypecolumns' => '#show-column-labels-for-custom-post-types',  
  259. 'admin_bar' => '#display-menu-in-admin-bar',  
  260. 'custom_menu_order' => '#display-menu-at-the-top',  
  261. 'google_verify' => '',  
  262. 'bing_verify' => '',  
  263. 'pinterest_verify' => '',  
  264. 'google_publisher' => '#google-plus-default-profile',  
  265. 'google_disable_profile' => '#disable-google-plus-profile',  
  266. 'google_sitelinks_search' => '#display-sitelinks-search-box',  
  267. 'google_set_site_name' => '#set-preferred-site-name',  
  268. 'google_author_advanced' => '#advanced-authorship-options',  
  269. 'google_author_location' => '#display-google-authorship',  
  270. 'google_enable_publisher' => '#display-publisher-meta-on-front-page',  
  271. 'google_specify_publisher' => '#specify-publisher-url',  
  272. 'google_analytics_id' => 'http://semperplugins.com/documentation/setting-up-google-analytics/',  
  273. 'ga_domain' => '#tracking-domain',  
  274. 'ga_multi_domain' => '#track-multiple-domains-additional-domains',  
  275. 'ga_addl_domains' => '#track-multiple-domains-additional-domains',  
  276. 'ga_anonymize_ip' => '#anonymize-ip-addresses',  
  277. 'ga_display_advertising' => '#display-advertiser-tracking',  
  278. 'ga_exclude_users' => '#exclude-users-from-tracking',  
  279. 'ga_track_outbound_links' => '#track-outbound-links',  
  280. 'ga_link_attribution' => '#enhanced-link-attribution',  
  281. 'ga_enhanced_ecommerce' => '#enhanced-ecommerce',  
  282. 'cpostnoindex' => '#noindex',  
  283. 'cpostnofollow' => '#nofollow',  
  284. 'cpostnoodp' => '#noodp',  
  285. 'cpostnoydir' => '#noydir',  
  286. 'category_noindex' => '#noindex-settings',  
  287. 'archive_date_noindex' => '#noindex-settings',  
  288. 'archive_author_noindex' => '#noindex-settings',  
  289. 'tags_noindex' => '#noindex-settings',  
  290. 'search_noindex' => '#use-noindex-for-the-search-page',  
  291. '404_noindex' => '#use-noindex-for-the-404-page',  
  292. 'tax_noindex' => '#use-noindex-for-the-taxonomy-archives',  
  293. 'paginated_noindex' => '#use-noindex-for-paginated-pages-posts',  
  294. 'paginated_nofollow' => '#use-nofollow-for-paginated-pages-posts',  
  295. 'noodp' => '#exclude-site-from-the-open-directory-project',  
  296. 'noydir' => '#exclude-site-from-yahoo-directory',  
  297. 'skip_excerpt' => '#avoid-using-the-excerpt-in-descriptions',  
  298. 'generate_descriptions' => '#autogenerate-descriptions',  
  299. 'run_shortcodes' => '#run-shortcodes-in-autogenerated-descriptions',  
  300. 'hide_paginated_descriptions' => '#remove-descriptions-for-paginated-pages',  
  301. 'dont_truncate_descriptions' => '#never-shorten-long-descriptions',  
  302. 'unprotect_meta' => '#unprotect-post-meta-fields',  
  303. 'redirect_attachement_parent' => '#redirect-attachments-to-post-parent',  
  304. 'ex_pages' => '#exclude-pages',  
  305. 'post_meta_tags' => '#additional-post-headers',  
  306. 'page_meta_tags' => '#additional-page-headers',  
  307. 'front_meta_tags' => '#additional-front-page-headers',  
  308. 'home_meta_tags' => '#additional-blog-page-headers',  
  309. ); 
  310.  
  311. $meta_help_text = array( 
  312. 'snippet' => __( 'A preview of what this page might look like in search engine results.', 'all-in-one-seo-pack' ),  
  313. 'title' => __( 'A custom title that shows up in the title tag for this page.', 'all-in-one-seo-pack' ),  
  314. 'description' => __( 'The META description for this page. This will override any autogenerated descriptions.', 'all-in-one-seo-pack' ),  
  315. 'keywords' => __( 'A comma separated list of your most important keywords for this page that will be written as META keywords.', 'all-in-one-seo-pack' ),  
  316. 'custom_link' => __( 'Override the canonical URLs for this post.', 'all-in-one-seo-pack' ),  
  317. 'noindex' => __( 'Check this box to ask search engines not to index this page.', 'all-in-one-seo-pack' ),  
  318. 'nofollow' => __( 'Check this box to ask search engines not to follow links from this page.', 'all-in-one-seo-pack' ),  
  319. 'noodp' => __( 'Check this box to ask search engines not to use descriptions from the Open Directory Project for this page.', 'all-in-one-seo-pack' ),  
  320. 'noydir' => __( 'Check this box to ask Yahoo! not to use descriptions from the Yahoo! directory for this page.', 'all-in-one-seo-pack' ),  
  321. 'titleatr' => __( 'Set the title attribute for menu links.', 'all-in-one-seo-pack' ),  
  322. 'menulabel' => __( 'Set the label for this page menu item.', 'all-in-one-seo-pack' ),  
  323. 'sitemap_exclude' => __( "Don't display this page in the sitemap.", 'all-in-one-seo-pack' ),  
  324. 'disable' => __( 'Disable SEO on this page.', 'all-in-one-seo-pack' ),  
  325. 'disable_analytics' => __( 'Disable Google Analytics on this page.', 'all-in-one-seo-pack' ),  
  326. ); 
  327.  
  328. $this->default_options = array( 
  329. 'license_key' => array( 
  330. 'name' => __( 'License Key:', 'all-in-one-seo-pack' ),  
  331. 'type' => 'text',  
  332. ),  
  333. 'donate' => array( 
  334. 'name' => __( 'I enjoy this plugin and have made a donation:', 'all-in-one-seo-pack' ),  
  335. ),  
  336. 'home_title' => array( 
  337. 'name' => __( 'Home Title:', 'all-in-one-seo-pack' ),  
  338. 'default' => null,  
  339. 'type' => 'textarea',  
  340. 'sanitize' => 'text',  
  341. 'count' => true,  
  342. 'rows' => 1,  
  343. 'cols' => 60,  
  344. 'condshow' => array( 'aiosp_use_static_home_info' => 0 ),  
  345. ),  
  346. 'home_description' => array( 
  347. 'name' => __( 'Home Description:', 'all-in-one-seo-pack' ),  
  348. 'default' => '',  
  349. 'type' => 'textarea',  
  350. 'sanitize' => 'text',  
  351. 'count' => true,  
  352. 'cols' => 80,  
  353. 'rows' => 2,  
  354. 'condshow' => array( 'aiosp_use_static_home_info' => 0 ),  
  355. ),  
  356. 'togglekeywords' => array( 
  357. 'name' => __( 'Use Keywords:', 'all-in-one-seo-pack' ),  
  358. 'default' => 1,  
  359. 'type' => 'radio',  
  360. 'initial_options' => array( 
  361. 0 => __( 'Enabled', 'all-in-one-seo-pack' ),  
  362. 1 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  363. ),  
  364. ),  
  365. 'home_keywords' => array( 
  366. 'name' => __( 'Home Keywords (comma separated):', 'all-in-one-seo-pack' ),  
  367. 'default' => null,  
  368. 'type' => 'textarea',  
  369. 'sanitize' => 'text',  
  370. 'condshow' => array( 'aiosp_togglekeywords' => 0, 'aiosp_use_static_home_info' => 0 ),  
  371. ),  
  372. 'use_static_home_info' => array( 
  373. 'name' => __( 'Use Static Front Page Instead', 'all-in-one-seo-pack' ),  
  374. 'default' => 0,  
  375. 'type' => 'radio',  
  376. 'initial_options' => array( 
  377. 1 => __( 'Enabled', 'all-in-one-seo-pack' ),  
  378. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  379. ),  
  380. ),  
  381. 'can' => array( 
  382. 'name' => __( 'Canonical URLs:', 'all-in-one-seo-pack' ),  
  383. 'default' => 1,  
  384. ),  
  385. 'no_paged_canonical_links' => array( 
  386. 'name' => __( 'No Pagination for Canonical URLs:', 'all-in-one-seo-pack' ),  
  387. 'default' => 0,  
  388. 'condshow' => array( 'aiosp_can' => 'on' ),  
  389. ),  
  390. 'customize_canonical_links' => array( 
  391. 'name' => __( 'Enable Custom Canonical URLs:', 'all-in-one-seo-pack' ),  
  392. 'default' => 0,  
  393. 'condshow' => array( 'aiosp_can' => 'on' ),  
  394. ),  
  395. 'can_set_protocol' => array( 
  396. 'name' => __( 'Set Protocol For Canonical URLs:', 'all-in-one-seo-pack' ),  
  397. 'type' => 'radio',  
  398. 'default' => 'auto',  
  399. 'initial_options' => array( 
  400. 'auto' => __( 'Auto', 'all-in-one-seo-pack' ),  
  401. 'http' => __( 'HTTP', 'all-in-one-seo-pack' ),  
  402. 'https' => __( 'HTTPS', 'all-in-one-seo-pack' ),  
  403. ),  
  404. 'condshow' => array( 'aiosp_can' => 'on' ),  
  405. ),  
  406. 'rewrite_titles' => array( 
  407. 'name' => __( 'Rewrite Titles:', 'all-in-one-seo-pack' ),  
  408. 'default' => 1,  
  409. 'type' => 'radio',  
  410. 'initial_options' => array( 
  411. 1 => __( 'Enabled', 'all-in-one-seo-pack' ),  
  412. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  413. ),  
  414. ),  
  415. 'force_rewrites' => array( 
  416. 'name' => __( 'Force Rewrites:', 'all-in-one-seo-pack' ),  
  417. 'default' => 1,  
  418. 'type' => 'hidden',  
  419. 'prefix' => $this->prefix,  
  420. 'initial_options' => array( 
  421. 1 => __( 'Enabled', 'all-in-one-seo-pack' ),  
  422. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  423. ),  
  424. ),  
  425. 'use_original_title' => array( 
  426. 'name' => __( 'Use Original Title:', 'all-in-one-seo-pack' ),  
  427. 'type' => 'radio',  
  428. 'default' => 0,  
  429. 'initial_options' => array( 
  430. 1 => __( 'Enabled', 'all-in-one-seo-pack' ),  
  431. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  432. ),  
  433. ),  
  434. 'cap_titles' => array( 
  435. 'name' => __( 'Capitalize Tag and Search Titles:', 'all-in-one-seo-pack' ),  
  436. 'default' => 1,  
  437. ),  
  438. 'cap_cats' => array( 
  439. 'name' => __( 'Capitalize Category Titles:', 'all-in-one-seo-pack' ),  
  440. 'default' => 1,  
  441. ),  
  442. 'home_page_title_format' => array( 
  443. 'name' => __( 'Home Page Title Format:', 'all-in-one-seo-pack' ),  
  444. 'type' => 'text',  
  445. 'default' => '%page_title%',  
  446. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  447. ),  
  448. 'page_title_format' => array( 
  449. 'name' => __( 'Page Title Format:', 'all-in-one-seo-pack' ),  
  450. 'type' => 'text',  
  451. 'default' => '%page_title% | %blog_title%',  
  452. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  453. ),  
  454. 'post_title_format' => array( 
  455. 'name' => __( 'Post Title Format:', 'all-in-one-seo-pack' ),  
  456. 'type' => 'text',  
  457. 'default' => '%post_title% | %blog_title%',  
  458. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  459. ),  
  460. 'category_title_format' => array( 
  461. 'name' => __( 'Category Title Format:', 'all-in-one-seo-pack' ),  
  462. 'type' => 'text',  
  463. 'default' => '%category_title% | %blog_title%',  
  464. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  465. ),  
  466. 'archive_title_format' => array( 
  467. 'name' => __( 'Archive Title Format:', 'all-in-one-seo-pack' ),  
  468. 'type' => 'text',  
  469. 'default' => '%archive_title% | %blog_title%',  
  470. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  471. ),  
  472. 'date_title_format' => array( 
  473. 'name' => __( 'Date Archive Title Format:', 'all-in-one-seo-pack' ),  
  474. 'type' => 'text',  
  475. 'default' => '%date% | %blog_title%',  
  476. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  477. ),  
  478. 'author_title_format' => array( 
  479. 'name' => __( 'Author Archive Title Format:', 'all-in-one-seo-pack' ),  
  480. 'type' => 'text',  
  481. 'default' => '%author% | %blog_title%',  
  482. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  483. ),  
  484. 'tag_title_format' => array( 
  485. 'name' => __( 'Tag Title Format:', 'all-in-one-seo-pack' ),  
  486. 'type' => 'text',  
  487. 'default' => '%tag% | %blog_title%',  
  488. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  489. ),  
  490. 'search_title_format' => array( 
  491. 'name' => __( 'Search Title Format:', 'all-in-one-seo-pack' ),  
  492. 'type' => 'text',  
  493. 'default' => '%search% | %blog_title%',  
  494. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  495. ),  
  496. 'description_format' => array( 
  497. 'name' => __( 'Description Format', 'all-in-one-seo-pack' ),  
  498. 'type' => 'text',  
  499. 'default' => '%description%',  
  500. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  501. ),  
  502. '404_title_format' => array( 
  503. 'name' => __( '404 Title Format:', 'all-in-one-seo-pack' ),  
  504. 'type' => 'text',  
  505. 'default' => 'Nothing found for %request_words%',  
  506. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  507. ),  
  508. 'paged_format' => array( 
  509. 'name' => __( 'Paged Format:', 'all-in-one-seo-pack' ),  
  510. 'type' => 'text',  
  511. 'default' => ' - Part %page%',  
  512. 'condshow' => array( 'aiosp_rewrite_titles' => 1 ),  
  513. ),  
  514. 'enablecpost' => array( 
  515. 'name' => __( 'SEO for Custom Post Types:', 'all-in-one-seo-pack' ),  
  516. 'default' => 'on',  
  517. 'type' => 'radio',  
  518. 'initial_options' => array( 
  519. 'on' => __( 'Enabled', 'all-in-one-seo-pack' ),  
  520. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  521. ),  
  522. ),  
  523. 'cpostactive' => array( 
  524. 'name' => __( 'SEO on only these post types:', 'all-in-one-seo-pack' ),  
  525. 'type' => 'multicheckbox',  
  526. 'default' => array( 'post', 'page' ),  
  527. 'condshow' => array( 'aiosp_enablecpost' => 'on' ),  
  528. ),  
  529. 'taxactive' => array( 
  530. 'name' => __( 'SEO on only these taxonomies:', 'all-in-one-seo-pack' ),  
  531. 'type' => 'multicheckbox',  
  532. 'default' => array( 'category', 'post_tag' ),  
  533. 'condshow' => array( 'aiosp_enablecpost' => 'on' ),  
  534. ),  
  535. 'cpostadvanced' => array( 
  536. 'name' => __( 'Enable Advanced Options:', 'all-in-one-seo-pack' ),  
  537. 'default' => 0,  
  538. 'type' => 'radio',  
  539. 'initial_options' => array( 
  540. 'on' => __( 'Enabled', 'all-in-one-seo-pack' ),  
  541. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  542. ),  
  543. 'label' => null,  
  544. 'condshow' => array( 'aiosp_enablecpost' => 'on' ),  
  545. ),  
  546. 'cpostnoindex' => array( 
  547. 'name' => __( 'Default to NOINDEX:', 'all-in-one-seo-pack' ),  
  548. 'type' => 'multicheckbox',  
  549. 'default' => array(),  
  550. ),  
  551. 'cpostnofollow' => array( 
  552. 'name' => __( 'Default to NOFOLLOW:', 'all-in-one-seo-pack' ),  
  553. 'type' => 'multicheckbox',  
  554. 'default' => array(),  
  555. ),  
  556. 'cpostnoodp' => array( 
  557. 'name' => __( 'Default to NOODP:', 'all-in-one-seo-pack' ),  
  558. 'type' => 'multicheckbox',  
  559. 'default' => array(),  
  560. ),  
  561. 'cpostnoydir' => array( 
  562. 'name' => __( 'Default to NOYDIR:', 'all-in-one-seo-pack' ),  
  563. 'type' => 'multicheckbox',  
  564. 'default' => array(),  
  565. ),  
  566. 'cposttitles' => array( 
  567. 'name' => __( 'Custom titles:', 'all-in-one-seo-pack' ),  
  568. 'type' => 'checkbox',  
  569. 'default' => 0,  
  570. 'condshow' => array( 
  571. 'aiosp_rewrite_titles' => 1,  
  572. 'aiosp_enablecpost' => 'on',  
  573. 'aiosp_cpostadvanced' => 'on',  
  574. ),  
  575. ),  
  576. 'posttypecolumns' => array( 
  577. 'name' => __( 'Show Column Labels for Custom Post Types:', 'all-in-one-seo-pack' ),  
  578. 'type' => 'multicheckbox',  
  579. 'default' => array( 'post', 'page' ),  
  580. 'condshow' => array( 'aiosp_enablecpost' => 'on' ),  
  581. ),  
  582. 'admin_bar' => array( 
  583. 'name' => __( 'Display Menu In Admin Bar:', 'all-in-one-seo-pack' ),  
  584. 'default' => 'on',  
  585. ),  
  586. 'custom_menu_order' => array( 
  587. 'name' => __( 'Display Menu At The Top:', 'all-in-one-seo-pack' ),  
  588. 'default' => 'on',  
  589. ),  
  590. 'google_verify' => array( 
  591. 'name' => __( 'Google Webmaster Tools:', 'all-in-one-seo-pack' ),  
  592. 'default' => '',  
  593. 'type' => 'text',  
  594. ),  
  595. 'bing_verify' => array( 
  596. 'name' => __( 'Bing Webmaster Center:', 'all-in-one-seo-pack' ),  
  597. 'default' => '',  
  598. 'type' => 'text',  
  599. ),  
  600. 'pinterest_verify' => array( 
  601. 'name' => __( 'Pinterest Site Verification:', 'all-in-one-seo-pack' ),  
  602. 'default' => '',  
  603. 'type' => 'text',  
  604. ),  
  605. 'google_publisher' => array( 
  606. 'name' => __( 'Google Plus Default Profile:', 'all-in-one-seo-pack' ),  
  607. 'default' => '',  
  608. 'type' => 'text',  
  609. ),  
  610. 'google_disable_profile' => array( 
  611. 'name' => __( 'Disable Google Plus Profile:', 'all-in-one-seo-pack' ),  
  612. 'default' => 0,  
  613. 'type' => 'checkbox',  
  614. ),  
  615. 'google_sitelinks_search' => array( 
  616. 'name' => __( 'Display Sitelinks Search Box:', 'all-in-one-seo-pack' ),  
  617. ),  
  618. 'google_set_site_name' => array( 
  619. 'name' => __( 'Set Preferred Site Name:', 'all-in-one-seo-pack' ),  
  620. ),  
  621. 'google_specify_site_name' => array( 
  622. 'name' => __( 'Specify A Preferred Name:', 'all-in-one-seo-pack' ),  
  623. 'type' => 'text',  
  624. 'placeholder' => $blog_name,  
  625. 'condshow' => array( 'aiosp_google_set_site_name' => 'on' ),  
  626. ),  
  627. 'google_author_advanced' => array( 
  628. 'name' => __( 'Advanced Authorship Options:', 'all-in-one-seo-pack' ),  
  629. 'default' => 0,  
  630. 'type' => 'radio',  
  631. 'initial_options' => array( 
  632. 'on' => __( 'Enabled', 'all-in-one-seo-pack' ),  
  633. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  634. ),  
  635. 'label' => null,  
  636. ),  
  637. 'google_author_location' => array( 
  638. 'name' => __( 'Display Google Authorship:', 'all-in-one-seo-pack' ),  
  639. 'default' => array( 'all' ),  
  640. 'type' => 'multicheckbox',  
  641. 'condshow' => array( 'aiosp_google_author_advanced' => 'on' ),  
  642. ),  
  643. 'google_enable_publisher' => array( 
  644. 'name' => __( 'Display Publisher Meta on Front Page:', 'all-in-one-seo-pack' ),  
  645. 'default' => 'on',  
  646. 'type' => 'radio',  
  647. 'initial_options' => array( 
  648. 'on' => __( 'Enabled', 'all-in-one-seo-pack' ),  
  649. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  650. ),  
  651. 'condshow' => array( 'aiosp_google_author_advanced' => 'on' ),  
  652. ),  
  653. 'google_specify_publisher' => array( 
  654. 'name' => __( 'Specify Publisher URL:', 'all-in-one-seo-pack' ),  
  655. 'type' => 'text',  
  656. 'condshow' => array( 'aiosp_google_author_advanced' => 'on', 'aiosp_google_enable_publisher' => 'on' ),  
  657. ),  
  658. // "google_connect"=>array( 'name' => __( 'Connect With Google Analytics', 'all-in-one-seo-pack' ), ),  
  659. 'google_analytics_id' => array( 
  660. 'name' => __( 'Google Analytics ID:', 'all-in-one-seo-pack' ),  
  661. 'default' => null,  
  662. 'type' => 'text',  
  663. 'placeholder' => 'UA-########-#',  
  664. ),  
  665. 'ga_advanced_options' => array( 
  666. 'name' => __( 'Advanced Analytics Options:', 'all-in-one-seo-pack' ),  
  667. 'default' => 'on',  
  668. 'type' => 'radio',  
  669. 'initial_options' => array( 
  670. 'on' => __( 'Enabled', 'all-in-one-seo-pack' ),  
  671. 0 => __( 'Disabled', 'all-in-one-seo-pack' ),  
  672. ),  
  673. 'condshow' => array( 
  674. 'aiosp_google_analytics_id' => array( 
  675. 'lhs' => 'aiosp_google_analytics_id',  
  676. 'op' => '!=',  
  677. 'rhs' => '',  
  678. ),  
  679. ),  
  680. ),  
  681. 'ga_domain' => array( 
  682. 'name' => __( 'Tracking Domain:', 'all-in-one-seo-pack' ),  
  683. 'type' => 'text',  
  684. 'condshow' => array( 
  685. 'aiosp_google_analytics_id' => array( 
  686. 'lhs' => 'aiosp_google_analytics_id',  
  687. 'op' => '!=',  
  688. 'rhs' => '',  
  689. ),  
  690. 'aiosp_ga_advanced_options' => 'on',  
  691. ),  
  692. ),  
  693. 'ga_multi_domain' => array( 
  694. 'name' => __( 'Track Multiple Domains:', 'all-in-one-seo-pack' ),  
  695. 'default' => 0,  
  696. 'condshow' => array( 
  697. 'aiosp_google_analytics_id' => array( 
  698. 'lhs' => 'aiosp_google_analytics_id',  
  699. 'op' => '!=',  
  700. 'rhs' => '',  
  701. ),  
  702. 'aiosp_ga_advanced_options' => 'on',  
  703. ),  
  704. ),  
  705. 'ga_addl_domains' => array( 
  706. 'name' => __( 'Additional Domains:', 'all-in-one-seo-pack' ),  
  707. 'type' => 'textarea',  
  708. 'condshow' => array( 
  709. 'aiosp_google_analytics_id' => array( 
  710. 'lhs' => 'aiosp_google_analytics_id',  
  711. 'op' => '!=',  
  712. 'rhs' => '',  
  713. ),  
  714. 'aiosp_ga_advanced_options' => 'on',  
  715. 'aiosp_ga_multi_domain' => 'on',  
  716. ),  
  717. ),  
  718. 'ga_anonymize_ip' => array( 
  719. 'name' => __( 'Anonymize IP Addresses:', 'all-in-one-seo-pack' ),  
  720. 'type' => 'checkbox',  
  721. 'condshow' => array( 
  722. 'aiosp_google_analytics_id' => array( 
  723. 'lhs' => 'aiosp_google_analytics_id',  
  724. 'op' => '!=',  
  725. 'rhs' => '',  
  726. ),  
  727. 'aiosp_ga_advanced_options' => 'on',  
  728. ),  
  729. ),  
  730. 'ga_display_advertising' => array( 
  731. 'name' => __( 'Display Advertiser Tracking:', 'all-in-one-seo-pack' ),  
  732. 'type' => 'checkbox',  
  733. 'condshow' => array( 
  734. 'aiosp_google_analytics_id' => array( 
  735. 'lhs' => 'aiosp_google_analytics_id',  
  736. 'op' => '!=',  
  737. 'rhs' => '',  
  738. ),  
  739. 'aiosp_ga_advanced_options' => 'on',  
  740. ),  
  741. ),  
  742. 'ga_exclude_users' => array( 
  743. 'name' => __( 'Exclude Users From Tracking:', 'all-in-one-seo-pack' ),  
  744. 'type' => 'multicheckbox',  
  745. 'condshow' => array( 
  746. 'aiosp_google_analytics_id' => array( 
  747. 'lhs' => 'aiosp_google_analytics_id',  
  748. 'op' => '!=',  
  749. 'rhs' => '',  
  750. ),  
  751. 'aiosp_ga_advanced_options' => 'on',  
  752. ),  
  753. ),  
  754. 'ga_track_outbound_links' => array( 
  755. 'name' => __( 'Track Outbound Links:', 'all-in-one-seo-pack' ),  
  756. 'default' => 0,  
  757. 'condshow' => array( 
  758. 'aiosp_google_analytics_id' => array( 
  759. 'lhs' => 'aiosp_google_analytics_id',  
  760. 'op' => '!=',  
  761. 'rhs' => '',  
  762. ),  
  763. 'aiosp_ga_advanced_options' => 'on',  
  764. ),  
  765. ),  
  766. 'ga_link_attribution' => array( 
  767. 'name' => __( 'Enhanced Link Attribution:', 'all-in-one-seo-pack' ),  
  768. 'default' => 0,  
  769. 'condshow' => array( 
  770. 'aiosp_google_analytics_id' => array( 
  771. 'lhs' => 'aiosp_google_analytics_id',  
  772. 'op' => '!=',  
  773. 'rhs' => '',  
  774. ),  
  775. 'aiosp_ga_advanced_options' => 'on',  
  776. ),  
  777. ),  
  778. 'ga_enhanced_ecommerce' => array( 
  779. 'name' => __( 'Enhanced Ecommerce:', 'all-in-one-seo-pack' ),  
  780. 'default' => 0,  
  781. 'condshow' => array( 
  782. 'aiosp_google_analytics_id' => array( 
  783. 'lhs' => 'aiosp_google_analytics_id',  
  784. 'op' => '!=',  
  785. 'rhs' => '',  
  786. ),  
  787. 'aiosp_ga_advanced_options' => 'on',  
  788. ),  
  789. ),  
  790. 'use_categories' => array( 
  791. 'name' => __( 'Use Categories for META keywords:', 'all-in-one-seo-pack' ),  
  792. 'default' => 0,  
  793. 'condshow' => array( 'aiosp_togglekeywords' => 0 ),  
  794. ),  
  795. 'use_tags_as_keywords' => array( 
  796. 'name' => __( 'Use Tags for META keywords:', 'all-in-one-seo-pack' ),  
  797. 'default' => 1,  
  798. 'condshow' => array( 'aiosp_togglekeywords' => 0 ),  
  799. ),  
  800. 'dynamic_postspage_keywords' => array( 
  801. 'name' => __( 'Dynamically Generate Keywords for Posts Page/Archives:', 'all-in-one-seo-pack' ),  
  802. 'default' => 1,  
  803. 'condshow' => array( 'aiosp_togglekeywords' => 0 ),  
  804. ),  
  805. 'category_noindex' => array( 
  806. 'name' => __( 'Use noindex for Categories:', 'all-in-one-seo-pack' ),  
  807. 'default' => 1,  
  808. ),  
  809. 'archive_date_noindex' => array( 
  810. 'name' => __( 'Use noindex for Date Archives:', 'all-in-one-seo-pack' ),  
  811. 'default' => 1,  
  812. ),  
  813. 'archive_author_noindex' => array( 
  814. 'name' => __( 'Use noindex for Author Archives:', 'all-in-one-seo-pack' ),  
  815. 'default' => 1,  
  816. ),  
  817. 'tags_noindex' => array( 
  818. 'name' => __( 'Use noindex for Tag Archives:', 'all-in-one-seo-pack' ),  
  819. 'default' => 0,  
  820. ),  
  821. 'search_noindex' => array( 
  822. 'name' => __( 'Use noindex for the Search page:', 'all-in-one-seo-pack' ),  
  823. 'default' => 0,  
  824. ),  
  825. '404_noindex' => array( 
  826. 'name' => __( 'Use noindex for the 404 page:', 'all-in-one-seo-pack' ),  
  827. 'default' => 0,  
  828. ),  
  829. 'tax_noindex' => array( 
  830. 'name' => __( 'Use noindex for Taxonomy Archives:', 'all-in-one-seo-pack' ),  
  831. 'type' => 'multicheckbox',  
  832. 'default' => array(),  
  833. 'condshow' => array( 'aiosp_enablecpost' => 'on', 'aiosp_cpostadvanced' => 'on' ),  
  834. ),  
  835. 'paginated_noindex' => array( 
  836. 'name' => __( 'Use noindex for paginated pages/posts:', 'all-in-one-seo-pack' ),  
  837. 'default' => 0,  
  838. ),  
  839. 'paginated_nofollow' => array( 
  840. 'name' => __( 'Use nofollow for paginated pages/posts:', 'all-in-one-seo-pack' ),  
  841. 'default' => 0,  
  842. ),  
  843. 'noodp' => array( 
  844. 'name' => __( 'Exclude site from the Open Directory Project:', 'all-in-one-seo-pack' ),  
  845. 'default' => 0,  
  846. ),  
  847. 'noydir' => array( 
  848. 'name' => __( 'Exclude site from Yahoo! Directory:', 'all-in-one-seo-pack' ),  
  849. 'default' => 0,  
  850. ),  
  851. 'skip_excerpt' => array( 
  852. 'name' => __( 'Avoid Using The Excerpt In Descriptions:', 'all-in-one-seo-pack' ),  
  853. 'default' => 0,  
  854. ),  
  855. 'generate_descriptions' => array( 
  856. 'name' => __( 'Autogenerate Descriptions:', 'all-in-one-seo-pack' ),  
  857. 'default' => 1,  
  858. ),  
  859. 'run_shortcodes' => array( 
  860. 'name' => __( 'Run Shortcodes In Autogenerated Descriptions:', 'all-in-one-seo-pack' ),  
  861. 'default' => 0,  
  862. 'condshow' => array( 'aiosp_generate_descriptions' => 'on' ),  
  863. ),  
  864. 'hide_paginated_descriptions' => array( 
  865. 'name' => __( 'Remove Descriptions For Paginated Pages:', 'all-in-one-seo-pack' ),  
  866. 'default' => 0,  
  867. ),  
  868. 'dont_truncate_descriptions' => array( 
  869. 'name' => __( 'Never Shorten Long Descriptions:', 'all-in-one-seo-pack' ),  
  870. 'default' => 0,  
  871. ),  
  872. 'schema_markup' => array( 
  873. 'name' => __( 'Use Schema.org Markup', 'all-in-one-seo-pack' ),  
  874. 'default' => 1,  
  875. ),  
  876. 'unprotect_meta' => array( 
  877. 'name' => __( 'Unprotect Post Meta Fields:', 'all-in-one-seo-pack' ),  
  878. 'default' => 0,  
  879. ),  
  880. 'redirect_attachement_parent' => array( 
  881. 'name' => __( 'Redirect Attachments to Post Parent:', 'all-in-one-seo-pack'),  
  882. 'default' => 0,  
  883. ),  
  884. 'ex_pages' => array( 
  885. 'name' => __( 'Exclude Pages:', 'all-in-one-seo-pack' ),  
  886. 'type' => 'textarea',  
  887. 'default' => '',  
  888. ),  
  889. 'post_meta_tags' => array( 
  890. 'name' => __( 'Additional Post Headers:', 'all-in-one-seo-pack' ),  
  891. 'type' => 'textarea',  
  892. 'default' => '',  
  893. 'sanitize' => 'default',  
  894. ),  
  895. 'page_meta_tags' => array( 
  896. 'name' => __( 'Additional Page Headers:', 'all-in-one-seo-pack' ),  
  897. 'type' => 'textarea',  
  898. 'default' => '',  
  899. 'sanitize' => 'default',  
  900. ),  
  901. 'front_meta_tags' => array( 
  902. 'name' => __( 'Additional Front Page Headers:', 'all-in-one-seo-pack' ),  
  903. 'type' => 'textarea',  
  904. 'default' => '',  
  905. 'sanitize' => 'default',  
  906. ),  
  907. 'home_meta_tags' => array( 
  908. 'name' => __( 'Additional Blog Page Headers:', 'all-in-one-seo-pack' ),  
  909. 'type' => 'textarea',  
  910. 'default' => '',  
  911. 'sanitize' => 'default',  
  912. ),  
  913. 'do_log' => array( 
  914. 'name' => __( 'Log important events:', 'all-in-one-seo-pack' ),  
  915. 'default' => null,  
  916. ),  
  917. ); 
  918.  
  919. if ( AIOSEOPPRO ) { 
  920. unset( $this->default_options['donate'] ); 
  921. } else { 
  922. unset( $this->default_options['license_key'] ); 
  923. unset( $this->default_options['taxactive'] ); 
  924.  
  925. $this->locations = array( 
  926. 'default' => array( 'name' => $this->name, 'prefix' => 'aiosp_', 'type' => 'settings', 'options' => null ),  
  927. 'aiosp' => array( 
  928. 'name' => $this->plugin_name,  
  929. 'type' => 'metabox',  
  930. 'prefix' => '',  
  931. 'help_link' => 'http://semperplugins.com/sections/postpage-settings/',  
  932. 'options' => array( 
  933. 'edit',  
  934. 'nonce-aioseop-edit',  
  935. AIOSEOPPRO ? 'support' : 'upgrade',  
  936. 'snippet',  
  937. 'title',  
  938. 'description',  
  939. 'keywords',  
  940. 'custom_link',  
  941. 'noindex',  
  942. 'nofollow',  
  943. 'noodp',  
  944. 'noydir',  
  945. 'titleatr',  
  946. 'menulabel',  
  947. 'sitemap_exclude',  
  948. 'disable',  
  949. 'disable_analytics',  
  950. ),  
  951. 'default_options' => array( 
  952. 'edit' => array( 
  953. 'type' => 'hidden',  
  954. 'default' => 'aiosp_edit',  
  955. 'prefix' => true,  
  956. 'nowrap' => 1,  
  957. ),  
  958. 'nonce-aioseop-edit' => array( 
  959. 'type' => 'hidden',  
  960. 'default' => null,  
  961. 'prefix' => false,  
  962. 'nowrap' => 1,  
  963. ),  
  964. 'upgrade' => array( 
  965. 'type' => 'html',  
  966. 'label' => 'none',  
  967. 'default' => aiosp_common::get_upgrade_hyperlink( 'meta', __( 'Upgrade to All in One SEO Pack Pro Version', 'all-in-one-seo-pack' ), __( 'UPGRADE TO PRO VERSION', 'all-in-one-seo-pack' ), '_blank' ),  
  968. ),  
  969. 'support' => array( 
  970. 'type' => 'html',  
  971. 'label' => 'none',  
  972. 'default' => '<a target="_blank" href="https://semperplugins.com/support/">' 
  973. . __( 'Support Forum', 'all-in-one-seo-pack' ) . '</a>',  
  974. ),  
  975. 'snippet' => array( 
  976. 'name' => __( 'Preview Snippet', 'all-in-one-seo-pack' ),  
  977. 'type' => 'custom',  
  978. 'label' => 'top',  
  979. 'default' => ' 
  980. <script> 
  981. jQuery(document).ready(function() { 
  982. jQuery("#aiosp_title_wrapper").bind("input", function() { 
  983. jQuery("#aiosp_snippet_title").text(jQuery("#aiosp_title_wrapper input").val().replace(/<(?:.|\n)*?>/gm, "")); 
  984. }); 
  985. jQuery("#aiosp_description_wrapper").bind("input", function() { 
  986. jQuery("#aioseop_snippet_description").text(jQuery("#aiosp_description_wrapper textarea").val().replace(/<(?:.|\n)*?>/gm, "")); 
  987. }); 
  988. }); 
  989. </script> 
  990. <div class="preview_snippet"><div id="aioseop_snippet"><h3><a>%s</a></h3><div><div><cite id="aioseop_snippet_link">%s</cite></div><span id="aioseop_snippet_description">%s</span></div></div></div>',  
  991. ),  
  992. 'title' => array( 
  993. 'name' => __( 'Title', 'all-in-one-seo-pack' ),  
  994. 'type' => 'text',  
  995. 'count' => true,  
  996. 'size' => 60,  
  997. ),  
  998. 'description' => array( 
  999. 'name' => __( 'Description', 'all-in-one-seo-pack' ),  
  1000. 'type' => 'textarea',  
  1001. 'count' => true,  
  1002. 'cols' => 80,  
  1003. 'rows' => 2,  
  1004. ),  
  1005.  
  1006. 'keywords' => array( 
  1007. 'name' => __( 'Keywords (comma separated)', 'all-in-one-seo-pack' ),  
  1008. 'type' => 'text',  
  1009. ),  
  1010. 'custom_link' => array( 
  1011. 'name' => __( 'Custom Canonical URL', 'all-in-one-seo-pack' ),  
  1012. 'type' => 'text',  
  1013. 'size' => 60,  
  1014. ),  
  1015. 'noindex' => array( 
  1016. 'name' => __( 'Robots Meta NOINDEX', 'all-in-one-seo-pack' ),  
  1017. 'default' => '',  
  1018. ),  
  1019. 'nofollow' => array( 
  1020. 'name' => __( 'Robots Meta NOFOLLOW', 'all-in-one-seo-pack' ),  
  1021. 'default' => '',  
  1022. ),  
  1023. 'noodp' => array( 'name' => __( 'Robots Meta NOODP', 'all-in-one-seo-pack' ) ),  
  1024. 'noydir' => array( 'name' => __( 'Robots Meta NOYDIR', 'all-in-one-seo-pack' ) ),  
  1025. 'titleatr' => array( 
  1026. 'name' => __( 'Title Attribute', 'all-in-one-seo-pack' ),  
  1027. 'type' => 'text',  
  1028. 'size' => 60,  
  1029. ),  
  1030. 'menulabel' => array( 
  1031. 'name' => __( 'Menu Label', 'all-in-one-seo-pack' ),  
  1032. 'type' => 'text',  
  1033. 'size' => 60,  
  1034. ),  
  1035. 'sitemap_exclude' => array( 'name' => __( 'Exclude From Sitemap', 'all-in-one-seo-pack' ) ),  
  1036. 'disable' => array( 'name' => __( 'Disable on this page/post', 'all-in-one-seo-pack' ) ),  
  1037. 'disable_analytics' => array( 
  1038. 'name' => __( 'Disable Google Analytics', 'all-in-one-seo-pack' ),  
  1039. 'condshow' => array( 'aiosp_disable' => 'on' ),  
  1040. ),  
  1041. ),  
  1042. 'display' => null,  
  1043. ),  
  1044. ); 
  1045.  
  1046. if ( ! empty( $meta_help_text ) ) { 
  1047. foreach ( $meta_help_text as $k => $v ) { 
  1048. $this->locations['aiosp']['default_options'][ $k ]['help_text'] = $v; 
  1049.  
  1050. $this->layout = array( 
  1051. 'default' => array( 
  1052. 'name' => __( 'General Settings', 'all-in-one-seo-pack' ),  
  1053. 'help_link' => 'https://semperplugins.com/documentation/general-settings/',  
  1054. 'options' => array(), // This is set below, to the remaining options -- pdb. 
  1055. ),  
  1056. 'home' => array( 
  1057. 'name' => __( 'Home Page Settings', 'all-in-one-seo-pack' ),  
  1058. 'help_link' => 'https://semperplugins.com/documentation/home-page-settings/',  
  1059. 'options' => array( 'home_title', 'home_description', 'home_keywords', 'use_static_home_info' ),  
  1060. ),  
  1061. 'title' => array( 
  1062. 'name' => __( 'Title Settings', 'all-in-one-seo-pack' ),  
  1063. 'help_link' => 'https://semperplugins.com/documentation/title-settings/',  
  1064. 'options' => array( 
  1065. 'rewrite_titles',  
  1066. 'force_rewrites',  
  1067. 'cap_titles',  
  1068. 'cap_cats',  
  1069. 'home_page_title_format',  
  1070. 'page_title_format',  
  1071. 'post_title_format',  
  1072. 'category_title_format',  
  1073. 'archive_title_format',  
  1074. 'date_title_format',  
  1075. 'author_title_format',  
  1076. 'tag_title_format',  
  1077. 'search_title_format',  
  1078. 'description_format',  
  1079. '404_title_format',  
  1080. 'paged_format',  
  1081. ),  
  1082. ),  
  1083. 'cpt' => array( 
  1084. 'name' => __( 'Custom Post Type Settings', 'all-in-one-seo-pack' ),  
  1085. 'help_link' => 'http://semperplugins.com/documentation/custom-post-type-settings/',  
  1086. 'options' => array( 'enablecpost', 'cpostadvanced', 'taxactive', 'cpostactive', 'cposttitles' ),  
  1087. ),  
  1088. 'display' => array( 
  1089. 'name' => __( 'Display Settings', 'all-in-one-seo-pack' ),  
  1090. 'help_link' => 'http://semperplugins.com/documentation/display-settings/',  
  1091. 'options' => array( 'posttypecolumns', 'admin_bar', 'custom_menu_order' ),  
  1092. ),  
  1093. 'webmaster' => array( 
  1094. 'name' => __( 'Webmaster Verification', 'all-in-one-seo-pack' ),  
  1095. 'help_link' => 'http://semperplugins.com/sections/webmaster-verification/',  
  1096. 'options' => array( 'google_verify', 'bing_verify', 'pinterest_verify' ),  
  1097. ),  
  1098. 'google' => array( 
  1099. 'name' => __( 'Google Settings', 'all-in-one-seo-pack' ),  
  1100. 'help_link' => 'http://semperplugins.com/documentation/google-settings/',  
  1101. 'options' => array( 
  1102. 'google_publisher',  
  1103. 'google_disable_profile',  
  1104. 'google_sitelinks_search',  
  1105. 'google_set_site_name',  
  1106. 'google_specify_site_name',  
  1107. 'google_author_advanced',  
  1108. 'google_author_location',  
  1109. 'google_enable_publisher',  
  1110. 'google_specify_publisher',  
  1111. // "google_connect",  
  1112. 'google_analytics_id',  
  1113. 'ga_advanced_options',  
  1114. 'ga_domain',  
  1115. 'ga_multi_domain',  
  1116. 'ga_addl_domains',  
  1117. 'ga_anonymize_ip',  
  1118. 'ga_display_advertising',  
  1119. 'ga_exclude_users',  
  1120. 'ga_track_outbound_links',  
  1121. 'ga_link_attribution',  
  1122. 'ga_enhanced_ecommerce',  
  1123. ),  
  1124. ),  
  1125. 'noindex' => array( 
  1126. 'name' => __( 'Noindex Settings', 'all-in-one-seo-pack' ),  
  1127. 'help_link' => 'http://semperplugins.com/documentation/noindex-settings/',  
  1128. 'options' => array( 
  1129. 'cpostnoindex',  
  1130. 'cpostnofollow',  
  1131. 'cpostnoodp',  
  1132. 'cpostnoydir',  
  1133. 'category_noindex',  
  1134. 'archive_date_noindex',  
  1135. 'archive_author_noindex',  
  1136. 'tags_noindex',  
  1137. 'search_noindex',  
  1138. '404_noindex',  
  1139. 'tax_noindex',  
  1140. 'paginated_noindex',  
  1141. 'paginated_nofollow',  
  1142. 'noodp',  
  1143. 'noydir',  
  1144. ),  
  1145. ),  
  1146. 'advanced' => array( 
  1147. 'name' => __( 'Advanced Settings', 'all-in-one-seo-pack' ),  
  1148. 'help_link' => 'http://semperplugins.com/documentation/advanced-settings/',  
  1149. 'options' => array( 
  1150. 'generate_descriptions',  
  1151. 'skip_excerpt',  
  1152. 'run_shortcodes',  
  1153. 'hide_paginated_descriptions',  
  1154. 'dont_truncate_descriptions',  
  1155. 'unprotect_meta',  
  1156. 'redirect_attachement_parent',  
  1157. 'ex_pages',  
  1158. 'post_meta_tags',  
  1159. 'page_meta_tags',  
  1160. 'front_meta_tags',  
  1161. 'home_meta_tags',  
  1162. ),  
  1163. ),  
  1164. 'keywords' => array( 
  1165. 'name' => __( 'Keyword Settings', 'all-in-one-seo-pack' ),  
  1166. 'help_link' => 'http://semperplugins.com/documentation/keyword-settings/',  
  1167. 'options' => array( 
  1168. 'togglekeywords',  
  1169. 'use_categories',  
  1170. 'use_tags_as_keywords',  
  1171. 'dynamic_postspage_keywords',  
  1172. ),  
  1173. ),  
  1174. ); 
  1175.  
  1176. if ( ! AIOSEOPPRO ) { 
  1177. unset( $this->layout['cpt']['options']['2'] ); 
  1178.  
  1179. $other_options = array(); 
  1180. foreach ( $this->layout as $k => $v ) { 
  1181. $other_options = array_merge( $other_options, $v['options'] ); 
  1182.  
  1183. $this->layout['default']['options'] = array_diff( array_keys( $this->default_options ), $other_options ); 
  1184.  
  1185. if ( is_admin() ) { 
  1186. $this->add_help_text_links(); 
  1187. add_action( 'aioseop_global_settings_header', array( $this, 'display_right_sidebar' ) ); 
  1188. add_action( 'aioseop_global_settings_footer', array( $this, 'display_settings_footer' ) ); 
  1189. add_action( 'output_option', array( $this, 'custom_output_option' ), 10, 2 ); 
  1190. add_action( 'all_admin_notices', array( $this, 'visibility_warning' ) ); 
  1191.  
  1192. if ( ! AIOSEOPPRO ) { 
  1193. // add_action('all_admin_notices', array( $this, 'woo_upgrade_notice')); 
  1194. if ( AIOSEOPPRO ) { 
  1195. add_action( 'split_shared_term', array( $this, 'split_shared_term' ), 10, 4 ); 
  1196.  
  1197. //good candidate for pro dir 
  1198.  
  1199. /** 
  1200. * Use custom callback for outputting snippet 
  1201. * @param $buf 
  1202. * @param $args 
  1203. * @return string 
  1204. */ 
  1205. function custom_output_option( $buf, $args ) { 
  1206. if ( 'aiosp_snippet' === $args['name'] ) { 
  1207. $args['options']['type'] = 'html'; 
  1208. $args['options']['nowrap'] = false; 
  1209. $args['options']['save'] = false; 
  1210. $info = $this->get_page_snippet_info(); 
  1211. extract( $info ); 
  1212. } else { 
  1213. return ''; 
  1214.  
  1215. if ( $this->strlen( $title ) > 70 ) { 
  1216. $title = $this->trim_excerpt_without_filters( $title, 70 ) . '...'; 
  1217. if ( $this->strlen( $description ) > 156 ) { 
  1218. $description = $this->trim_excerpt_without_filters( $description, 156 ) . '...'; 
  1219. $extra_title_len = 0; 
  1220. if ( empty( $title_format ) ) { 
  1221. $title = '<span id="' . $args['name'] . '_title">' . esc_attr( wp_strip_all_tags( html_entity_decode( $title ) ) ) . '</span>'; 
  1222. } else { 
  1223. if ( strpos( $title_format, '%blog_title%' ) !== false ) { 
  1224. $title_format = str_replace( '%blog_title%', get_bloginfo( 'name' ), $title_format ); 
  1225. $title_format = $this->apply_cf_fields( $title_format ); 
  1226. $replace_title = '<span id="' . $args['name'] . '_title">' . esc_attr( wp_strip_all_tags( html_entity_decode( $title ) ) ) . '</span>'; 
  1227. if ( strpos( $title_format, '%post_title%' ) !== false ) { 
  1228. $title_format = str_replace( '%post_title%', $replace_title, $title_format ); 
  1229. if ( strpos( $title_format, '%page_title%' ) !== false ) { 
  1230. $title_format = str_replace( '%page_title%', $replace_title, $title_format ); 
  1231. if ( $w->is_category || $w->is_tag || $w->is_tax ) { 
  1232. if ( AIOSEOPPRO && ! empty( $_GET ) && ! empty( $_GET['taxonomy'] ) && ! empty( $_GET['tag_ID'] ) && function_exists( 'wp_get_split_terms' ) ) { 
  1233. $term_id = intval( $_GET['tag_ID'] ); 
  1234. $was_split = get_term_meta( $term_id, '_aioseop_term_was_split', true ); 
  1235. if ( ! $was_split ) { 
  1236. $split_terms = wp_get_split_terms( $term_id, $_GET['taxonomy'] ); 
  1237. if ( ! empty( $split_terms ) ) { 
  1238. foreach ( $split_terms as $new_tax => $new_term ) { 
  1239. $this->split_shared_term( $term_id, $new_term ); 
  1240. if ( strpos( $title_format, '%category_title%' ) !== false ) { 
  1241. $title_format = str_replace( '%category_title%', $replace_title, $title_format ); 
  1242. if ( strpos( $title_format, '%taxonomy_title%' ) !== false ) { 
  1243. $title_format = str_replace( '%taxonomy_title%', $replace_title, $title_format ); 
  1244. } else { 
  1245. if ( strpos( $title_format, '%category%' ) !== false ) { 
  1246. $title_format = str_replace( '%category%', $category, $title_format ); 
  1247. if ( strpos( $title_format, '%category_title%' ) !== false ) { 
  1248. $title_format = str_replace( '%category_title%', $category, $title_format ); 
  1249. if ( strpos( $title_format, '%taxonomy_title%' ) !== false ) { 
  1250. $title_format = str_replace( '%taxonomy_title%', $category, $title_format ); 
  1251. if ( AIOSEOPPRO ) { 
  1252. if ( strpos( $title_format, '%tax_' ) && ! empty( $p ) ) { 
  1253. $taxes = get_object_taxonomies( $p, 'objects' ); 
  1254. if ( ! empty( $taxes ) ) { 
  1255. foreach ( $taxes as $t ) { 
  1256. if ( strpos( $title_format, "%tax_{$t->name}%" ) ) { 
  1257. $terms = $this->get_all_terms( $p->ID, $t->name ); 
  1258. $term = ''; 
  1259. if ( count( $terms ) > 0 ) { 
  1260. $term = $terms[0]; 
  1261. $title_format = str_replace( "%tax_{$t->name}%", $term, $title_format ); 
  1262. if ( strpos( $title_format, '%taxonomy_description%' ) !== false ) { 
  1263. $title_format = str_replace( '%taxonomy_description%', $description, $title_format ); 
  1264.  
  1265. $title_format = preg_replace( '/%([^%]*?)%/', '', $title_format ); 
  1266. $title = $title_format; 
  1267. $extra_title_len = strlen( str_replace( $replace_title, '', $title_format ) ); 
  1268.  
  1269. $args['value'] = sprintf( $args['value'], $title, esc_url( $url ), esc_attr( wp_strip_all_tags( $description ) ) ); 
  1270. $extra_title_len = (int) $extra_title_len; 
  1271. $args['value'] .= "<script>var aiosp_title_extra = {$extra_title_len};</script>"; 
  1272. $buf = $this->get_option_row( $args['name'], $args['options'], $args ); 
  1273.  
  1274. return $buf; 
  1275.  
  1276. //good candidate for pro dir 
  1277.  
  1278. /** 
  1279. * @return array 
  1280. */ 
  1281. function get_page_snippet_info() { 
  1282. static $info = array(); 
  1283. if ( ! empty( $info ) ) { 
  1284. return $info; 
  1285. global $post, $aioseop_options, $wp_query; 
  1286. $title = $url = $description = $term = $category = ''; 
  1287. $p = $post; 
  1288. $w = $wp_query; 
  1289. if ( ! is_object( $post ) ) { 
  1290. $post = $this->get_queried_object(); 
  1291. if ( empty( $this->meta_opts ) ) { 
  1292. $this->meta_opts = $this->get_current_options( array(), 'aiosp' ); 
  1293. if ( ! is_object( $post ) && is_admin() && ! empty( $_GET ) && ! empty( $_GET['post_type'] ) && ! empty( $_GET['taxonomy'] ) && ! empty( $_GET['tag_ID'] ) ) { 
  1294. $term = get_term_by( 'id', $_GET['tag_ID'], $_GET['taxonomy'] ); 
  1295. if ( is_object( $post ) ) { 
  1296. $opts = $this->meta_opts; 
  1297. $post_id = $p->ID; 
  1298. if ( empty( $post->post_modified_gmt ) ) { 
  1299. $wp_query = new WP_Query( array( 'p' => $post_id, 'post_type' => $post->post_type ) ); 
  1300. if ( 'page' === $post->post_type ) { 
  1301. $wp_query->is_page = true; 
  1302. } elseif ( 'attachment' === $post->post_type ) { 
  1303. $wp_query->is_attachment = true; 
  1304. } else { 
  1305. $wp_query->is_single = true; 
  1306. if ( empty( $this->is_front_page ) ) { 
  1307. $this->is_front_page = false; 
  1308. if ( 'page' === get_option( 'show_on_front' ) ) { 
  1309. if ( is_page() && $post->ID == get_option( 'page_on_front' ) ) { 
  1310. $this->is_front_page = true; 
  1311. } elseif ( $post->ID == get_option( 'page_for_posts' ) ) { 
  1312. $wp_query->is_home = true; 
  1313. $wp_query->queried_object = $post; 
  1314. if ( ! empty( $post ) && ! $wp_query->is_home && ! $this->is_front_page ) { 
  1315. $title = $this->internationalize( get_post_meta( $post->ID, '_aioseop_title', true ) ); 
  1316. if ( empty( $title ) ) { 
  1317. $title = $post->post_title; 
  1318. $title_format = ''; 
  1319. if ( empty( $title ) ) { 
  1320. $title = $this->wp_title(); 
  1321. $description = $this->get_main_description( $post ); 
  1322. if ( empty( $title_format ) ) { 
  1323. if ( is_page() ) { 
  1324. $title_format = $aioseop_options['aiosp_page_title_format']; 
  1325. } elseif ( is_single() || is_attachment() ) { 
  1326. $title_format = $this->get_post_title_format( 'post', $post ); 
  1327. if ( empty( $title_format ) ) { 
  1328. $title_format = '%post_title%'; 
  1329. $categories = $this->get_all_categories( $post_id ); 
  1330. $category = ''; 
  1331. if ( count( $categories ) > 0 ) { 
  1332. $category = $categories[0]; 
  1333. } else if ( is_object( $term ) ) { 
  1334. if ( 'category' === $_GET['taxonomy'] ) { 
  1335. query_posts( array( 'cat' => $_GET['tag_ID'] ) ); 
  1336. } else if ( 'post_tag' === $_GET['taxonomy'] ) { 
  1337. query_posts( array( 'tag' => $term->slug ) ); 
  1338. } else { 
  1339. query_posts( array( 
  1340. 'page' => '',  
  1341. $_GET['taxonomy'] => $term->slug,  
  1342. 'post_type' => $_GET['post_type'],  
  1343. ) ); 
  1344. if ( empty( $this->meta_opts ) ) { 
  1345. $this->meta_opts = $this->get_current_options( array(), 'aiosp' ); 
  1346. $title = $this->get_tax_name( $_GET['taxonomy'] ); 
  1347. $title_format = $this->get_tax_title_format(); 
  1348. $opts = $this->meta_opts; 
  1349. if ( ! empty( $opts ) ) { 
  1350. $description = $opts['aiosp_description']; 
  1351. if ( empty( $description ) ) { 
  1352. $description = term_description(); 
  1353. $description = $this->internationalize( $description ); 
  1354.  
  1355. $show_page = true; 
  1356. if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) { 
  1357. $show_page = false; 
  1358. if ( $aioseop_options['aiosp_can'] ) { 
  1359. if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) { 
  1360. $url = $opts['aiosp_custom_link']; 
  1361. if ( empty( $url ) ) { 
  1362. $url = $this->aiosp_mrt_get_url( $wp_query, $show_page ); 
  1363. $url = apply_filters( 'aioseop_canonical_url', $url ); 
  1364. if ( ! $url ) { 
  1365. $url = get_permalink(); 
  1366.  
  1367. $title = $this->apply_cf_fields( $title ); 
  1368. $description = $this->apply_cf_fields( $description ); 
  1369. $description = apply_filters( 'aioseop_description', $description ); 
  1370.  
  1371. $keywords = $this->get_main_keywords(); 
  1372. $keywords = $this->apply_cf_fields( $keywords ); 
  1373. $keywords = apply_filters( 'aioseop_keywords', $keywords ); 
  1374.  
  1375. $info = array( 
  1376. 'title' => $title,  
  1377. 'description' => $description,  
  1378. 'keywords' => $keywords,  
  1379. 'url' => $url,  
  1380. 'title_format' => $title_format,  
  1381. 'category' => $category,  
  1382. 'w' => $wp_query,  
  1383. 'p' => $post,  
  1384. ); 
  1385. wp_reset_postdata(); 
  1386. $wp_query = $w; 
  1387. $post = $p; 
  1388.  
  1389. return $info; 
  1390.  
  1391. /** 
  1392. * @return null|object|WP_Post 
  1393. */ 
  1394. function get_queried_object() { 
  1395. static $p = null; 
  1396. global $wp_query, $post; 
  1397. if ( null !== $p ) { 
  1398. return $p; 
  1399. if ( is_object( $post ) ) { 
  1400. $p = $post; 
  1401. } else { 
  1402. if ( ! $wp_query ) { 
  1403. return null; 
  1404. $p = $wp_query->get_queried_object(); 
  1405.  
  1406. return $p; 
  1407.  
  1408. /** 
  1409. * @param array $opts 
  1410. * @param null $location 
  1411. * @param null $defaults 
  1412. * @param null $post 
  1413. * @return array 
  1414. */ 
  1415. function get_current_options( $opts = array(), $location = null, $defaults = null, $post = null ) { 
  1416. if ( ( 'aiosp' === $location) && ( 'metabox' == $this->locations[ $location ]['type'] ) ) { 
  1417. if ( null === $post ) { 
  1418. global $post; 
  1419. $post_id = $post; 
  1420. if ( is_object( $post_id ) ) { 
  1421. $post_id = $post_id->ID; 
  1422. $get_opts = $this->default_options( $location ); 
  1423. $optlist = array( 
  1424. 'keywords',  
  1425. 'description',  
  1426. 'title',  
  1427. 'custom_link',  
  1428. 'sitemap_exclude',  
  1429. 'disable',  
  1430. 'disable_analytics',  
  1431. 'noindex',  
  1432. 'nofollow',  
  1433. 'noodp',  
  1434. 'noydir',  
  1435. 'titleatr',  
  1436. 'menulabel',  
  1437. ); 
  1438. if ( ! ( ! empty( $this->options['aiosp_can'] ) ) && ( ! empty( $this->options['aiosp_customize_canonical_links'] ) ) ) { 
  1439. unset( $optlist['custom_link'] ); 
  1440. foreach ( $optlist as $f ) { 
  1441. $meta = ''; 
  1442. $field = "aiosp_$f"; 
  1443.  
  1444. if ( AIOSEOPPRO ) { 
  1445. if ( ( isset( $_GET['taxonomy'] ) && isset( $_GET['tag_ID'] ) ) || is_category() || is_tag() || is_tax() ) { 
  1446. if ( is_admin() && isset( $_GET['tag_ID'] ) ) { 
  1447. $meta = get_term_meta( $_GET['tag_ID'], '_aioseop_' . $f, true ); 
  1448. } else { 
  1449. $queried_object = get_queried_object(); 
  1450. if ( ! empty( $queried_object ) && ! empty( $queried_object->term_id ) ) { 
  1451. $meta = get_term_meta( $queried_object->term_id, '_aioseop_' . $f, true ); 
  1452. } else { 
  1453. $meta = get_post_meta( $post_id, '_aioseop_' . $f, true ); 
  1454. if ( 'title' === $f || 'description' === $f ) { 
  1455. $get_opts[ $field ] = htmlspecialchars( $meta ); 
  1456. } else { 
  1457. $get_opts[ $field ] = htmlspecialchars( stripslashes( $meta ) ); 
  1458. } else { 
  1459. $field = "aiosp_$f"; 
  1460. $meta = get_post_meta( $post_id, '_aioseop_' . $f, true ); 
  1461. if ( 'title' === $f || 'description' === $f ) { 
  1462. $get_opts[ $field ] = htmlspecialchars( $meta ); 
  1463. } else { 
  1464. $get_opts[ $field ] = htmlspecialchars( stripslashes( $meta ) ); 
  1465.  
  1466. $opts = wp_parse_args( $opts, $get_opts ); 
  1467.  
  1468. return $opts; 
  1469. } else { 
  1470. $options = parent::get_current_options( $opts, $location, $defaults ); 
  1471.  
  1472. return $options; 
  1473.  
  1474. /** 
  1475. * @param $in 
  1476. * @return mixed|void 
  1477. */ 
  1478. function internationalize( $in ) { 
  1479. if ( function_exists( 'langswitch_filter_langs_with_message' ) ) { 
  1480. $in = langswitch_filter_langs_with_message( $in ); 
  1481.  
  1482. if ( function_exists( 'polyglot_filter' ) ) { 
  1483. $in = polyglot_filter( $in ); 
  1484.  
  1485. if ( function_exists( 'qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) { 
  1486. $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $in ); 
  1487. } elseif ( function_exists( 'ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) { 
  1488. $in = ppqtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $in ); 
  1489. } elseif ( function_exists( 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage' ) ) { 
  1490. $in = qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage( $in ); 
  1491.  
  1492. return apply_filters( 'localization', $in ); 
  1493.  
  1494. /*** Used to filter wp_title(), get our title. ***/ 
  1495. function wp_title() { 
  1496. global $aioseop_options; 
  1497. $title = false; 
  1498. $post = $this->get_queried_object(); 
  1499. if ( ! empty( $aioseop_options['aiosp_rewrite_titles'] ) ) { 
  1500. $title = $this->get_aioseop_title( $post ); 
  1501. $title = $this->apply_cf_fields( $title ); 
  1502.  
  1503. if ( false === $title ) { 
  1504. $title = $this->get_original_title(); 
  1505.  
  1506. // If we're going to have this here, which seems logical, we should probably take it out of other places... do all titles pass through here? 
  1507. // The following lines have been commented out to fix an error with Capitalize Titles as reported in the WP forums 
  1508. // if ( !empty( $aioseop_options['aiosp_cap_titles'] ) ) 
  1509. // $title = $this->capitalize( $title ); 
  1510.  
  1511. return apply_filters( 'aioseop_title', $title ); 
  1512.  
  1513. /** 
  1514. * Gets the title that will be used by AIOSEOP for title rewrites or returns false. 
  1515. * @param $post 
  1516. * @return bool|string 
  1517. */ 
  1518. function get_aioseop_title( $post ) { 
  1519. global $aioseop_options; 
  1520. // the_search_query() is not suitable, it cannot just return. 
  1521. global $s, $STagging; 
  1522. $opts = $this->meta_opts; 
  1523. if ( is_front_page() ) { 
  1524. if ( ! empty( $aioseop_options['aiosp_use_static_home_info'] ) ) { 
  1525. global $post; 
  1526. if ( get_option( 'show_on_front' ) == 'page' && is_page() && $post->ID == get_option( 'page_on_front' ) ) { 
  1527. $title = $this->internationalize( get_post_meta( $post->ID, '_aioseop_title', true ) ); 
  1528. if ( ! $title ) { 
  1529. $title = $this->internationalize( $post->post_title ); 
  1530. if ( ! $title ) { 
  1531. $title = $this->internationalize( $this->get_original_title( '', false ) ); 
  1532. if ( ! empty( $aioseop_options['aiosp_home_page_title_format'] ) ) { 
  1533. $title = $this->apply_page_title_format( $title, $post, $aioseop_options['aiosp_home_page_title_format'] ); 
  1534. $title = $this->paged_title( $title ); 
  1535. $title = apply_filters( 'aioseop_home_page_title', $title ); 
  1536. } else { 
  1537. $title = $this->internationalize( $aioseop_options['aiosp_home_title'] ); 
  1538. if ( ! empty( $aioseop_options['aiosp_home_page_title_format'] ) ) { 
  1539. $title = $this->apply_page_title_format( $title, null, $aioseop_options['aiosp_home_page_title_format'] ); 
  1540. if ( empty( $title ) ) { 
  1541. $title = $this->internationalize( get_option( 'blogname' ) ) . ' | ' . $this->internationalize( get_bloginfo( 'description' ) ); 
  1542.  
  1543. global $post; 
  1544. $post_id = $post->ID; 
  1545.  
  1546. if ( is_post_type_archive() && is_post_type_archive( 'product' ) && $post_id = woocommerce_get_page_id( 'shop' ) && $post = get_post( $post_id ) ) { 
  1547. $frontpage_id = get_option( 'page_on_front' ); 
  1548.  
  1549. if ( woocommerce_get_page_id( 'shop' ) == get_option( 'page_on_front' ) && ! empty( $aioseop_options['aiosp_use_static_home_info'] ) ) { 
  1550. $title = $this->internationalize( get_post_meta( $post->ID, '_aioseop_title', true ) ); 
  1551. // $title = $this->internationalize( $aioseop_options['aiosp_home_title'] ); 
  1552. if ( ! $title ) { 
  1553. $title = $this->internationalize( get_post_meta( $frontpage_id, '_aioseop_title', true ) ); 
  1554. } // This is/was causing the first product to come through. 
  1555. if ( ! $title ) { 
  1556. $title = $this->internationalize( $post->post_title ); 
  1557. if ( ! $title ) { 
  1558. $title = $this->internationalize( $this->get_original_title( '', false ) ); 
  1559.  
  1560. $title = $this->apply_page_title_format( $title, $post ); 
  1561. $title = $this->paged_title( $title ); 
  1562. $title = apply_filters( 'aioseop_title_page', $title ); 
  1563.  
  1564. return $title; 
  1565.  
  1566.  
  1567. return $this->paged_title( $title ); //this is returned for woo 
  1568. } else if ( is_attachment() ) { 
  1569. if ( null === $post ) { 
  1570. return false; 
  1571. $title = get_post_meta( $post->ID, '_aioseop_title', true ); 
  1572. if ( empty( $title ) ) { 
  1573. $title = $post->post_title; 
  1574. if ( empty( $title ) ) { 
  1575. $title = $this->get_original_title( '', false ); 
  1576. if ( empty( $title ) ) { 
  1577. $title = get_the_title( $post->post_parent ); 
  1578. $title = apply_filters( 'aioseop_attachment_title', $this->internationalize( $this->apply_post_title_format( $title, '', $post ) ) ); 
  1579.  
  1580. return $title; 
  1581. } else if ( is_page() || $this->is_static_posts_page() || ( is_home() && ! $this->is_static_posts_page() ) ) { 
  1582. if ( null === $post ) { 
  1583. return false; 
  1584. if ( $this->is_static_front_page() && ( $home_title = $this->internationalize( $aioseop_options['aiosp_home_title'] ) ) ) { 
  1585. if ( ! empty( $aioseop_options['aiosp_home_page_title_format'] ) ) { 
  1586. $home_title = $this->apply_page_title_format( $home_title, $post, $aioseop_options['aiosp_home_page_title_format'] ); 
  1587.  
  1588. // Home title filter. 
  1589. return apply_filters( 'aioseop_home_page_title', $home_title ); 
  1590. } else { 
  1591. $page_for_posts = ''; 
  1592. if ( is_home() ) { 
  1593. $page_for_posts = get_option( 'page_for_posts' ); 
  1594. if ( $page_for_posts ) { 
  1595. $title = $this->internationalize( get_post_meta( $page_for_posts, '_aioseop_title', true ) ); 
  1596. if ( ! $title ) { 
  1597. $post_page = get_post( $page_for_posts ); 
  1598. $title = $this->internationalize( $post_page->post_title ); 
  1599. } else { 
  1600. $title = $this->internationalize( get_post_meta( $post->ID, '_aioseop_title', true ) ); 
  1601. if ( ! $title ) { 
  1602. $title = $this->internationalize( $post->post_title ); 
  1603. if ( ! $title ) { 
  1604. $title = $this->internationalize( $this->get_original_title( '', false ) ); 
  1605.  
  1606. $title = $this->apply_page_title_format( $title, $post ); 
  1607. $title = $this->paged_title( $title ); 
  1608. $title = apply_filters( 'aioseop_title_page', $title ); 
  1609. if ( $this->is_static_posts_page() ) { 
  1610. $title = apply_filters( 'single_post_title', $title ); 
  1611.  
  1612. return $title; 
  1613. } else if ( function_exists( 'woocommerce_get_page_id' ) && is_post_type_archive( 'product' ) && ( $post_id = woocommerce_get_page_id( 'shop' ) ) && ( $post = get_post( $post_id ) ) ) { 
  1614. // Too far down? -mrt. 
  1615. $title = $this->internationalize( get_post_meta( $post->ID, '_aioseop_title', true ) ); 
  1616. if ( ! $title ) { 
  1617. $title = $this->internationalize( $post->post_title ); 
  1618. if ( ! $title ) { 
  1619. $title = $this->internationalize( $this->get_original_title( '', false ) ); 
  1620. $title = $this->apply_page_title_format( $title, $post ); 
  1621. $title = $this->paged_title( $title ); 
  1622. $title = apply_filters( 'aioseop_title_page', $title ); 
  1623.  
  1624. return $title; 
  1625. } else if ( is_single() ) { 
  1626. // We're not in the loop :(. 
  1627. if ( null === $post ) { 
  1628. return false; 
  1629. $categories = $this->get_all_categories(); 
  1630. $category = ''; 
  1631. if ( count( $categories ) > 0 ) { 
  1632. $category = $categories[0]; 
  1633. $title = $this->internationalize( get_post_meta( $post->ID, '_aioseop_title', true ) ); 
  1634. if ( ! $title ) { 
  1635. $title = $this->internationalize( get_post_meta( $post->ID, 'title_tag', true ) ); 
  1636. if ( ! $title ) { 
  1637. $title = $this->internationalize( $this->get_original_title( '', false ) ); 
  1638. if ( empty( $title ) ) { 
  1639. $title = $post->post_title; 
  1640. if ( ! empty( $title ) ) { 
  1641. $title = $this->apply_post_title_format( $title, $category, $post ); 
  1642. $title = $this->paged_title( $title ); 
  1643.  
  1644. return apply_filters( 'aioseop_title_single', $title ); 
  1645. } else if ( is_search() && isset( $s ) && ! empty( $s ) ) { 
  1646. $search = esc_attr( stripslashes( $s ) ); 
  1647. if ( ! empty( $aioseop_options['aiosp_cap_titles'] ) ) { 
  1648. $search = $this->capitalize( $search ); 
  1649. $title_format = $aioseop_options['aiosp_search_title_format']; 
  1650. $title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title_format ); 
  1651. if ( strpos( $title, '%blog_description%' ) !== false ) { 
  1652. $title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $title ); 
  1653. if ( strpos( $title, '%search%' ) !== false ) { 
  1654. $title = str_replace( '%search%', $search, $title ); 
  1655. $title = $this->paged_title( $title ); 
  1656.  
  1657. return $title; 
  1658. } else if ( is_tag() ) { 
  1659. global $utw; 
  1660. $tag = $tag_description = ''; 
  1661. if ( $utw ) { 
  1662. $tags = $utw->GetCurrentTagSet(); 
  1663. $tag = $tags[0]->tag; 
  1664. $tag = str_replace( '-', ' ', $tag ); 
  1665. } else { 
  1666. if ( AIOSEOPPRO ) { 
  1667. if ( ! empty( $opts ) && ! empty( $opts['aiosp_title'] ) ) { 
  1668. $tag = $opts['aiosp_title']; 
  1669. if ( ! empty( $opts ) ) { 
  1670. if ( ! empty( $opts['aiosp_title'] ) ) { 
  1671. $tag = $opts['aiosp_title']; 
  1672. if ( ! empty( $opts['aiosp_description'] ) ) { 
  1673. $tag_description = $opts['aiosp_description']; 
  1674. if ( empty( $tag ) ) { 
  1675. $tag = $this->get_original_title( '', false ); 
  1676. if ( empty( $tag_description ) ) { 
  1677. $tag_description = tag_description(); 
  1678. $tag = $this->internationalize( $tag ); 
  1679. $tag_description = $this->internationalize( $tag_description ); 
  1680. if ( $tag ) { 
  1681. if ( ! empty( $aioseop_options['aiosp_cap_titles'] ) ) { 
  1682. $tag = $this->capitalize( $tag ); 
  1683. $title_format = $aioseop_options['aiosp_tag_title_format']; 
  1684. $title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title_format ); 
  1685. if ( strpos( $title, '%blog_description%' ) !== false ) { 
  1686. $title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $title ); 
  1687. if ( strpos( $title, '%tag%' ) !== false ) { 
  1688. $title = str_replace( '%tag%', $tag, $title ); 
  1689. if ( strpos( $title, '%tag_description%' ) !== false ) { 
  1690. $title = str_replace( '%tag_description%', $tag_description, $title ); 
  1691. if ( strpos( $title, '%taxonomy_description%' ) !== false ) { 
  1692. $title = str_replace( '%taxonomy_description%', $tag_description, $title ); 
  1693. $title = trim( wp_strip_all_tags( $title ) ); 
  1694. $title = str_replace( array( '"', "\r\n", "\n" ), array( '"', ' ', ' ' ), $title ); 
  1695. $title = $this->paged_title( $title ); 
  1696.  
  1697. return $title; 
  1698. } else if ( ( is_tax() || is_category() ) && ! is_feed() ) { 
  1699. return $this->get_tax_title(); 
  1700. } else if ( isset( $STagging ) && $STagging->is_tag_view() ) { // Simple tagging support. 
  1701. $tag = $STagging->search_tag; 
  1702. if ( $tag ) { 
  1703. if ( ! empty( $aioseop_options['aiosp_cap_titles'] ) ) { 
  1704. $tag = $this->capitalize( $tag ); 
  1705. $title_format = $aioseop_options['aiosp_tag_title_format']; 
  1706. $title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title_format ); 
  1707. if ( strpos( $title, '%blog_description%' ) !== false ) { 
  1708. $title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $title ); 
  1709. if ( strpos( $title, '%tag%' ) !== false ) { 
  1710. $title = str_replace( '%tag%', $tag, $title ); 
  1711. $title = $this->paged_title( $title ); 
  1712.  
  1713. return $title; 
  1714. } else if ( is_archive() || is_post_type_archive() ) { 
  1715. if ( is_author() ) { 
  1716. $author = $this->internationalize( $this->get_original_title( '', false ) ); 
  1717. $title_format = $aioseop_options['aiosp_author_title_format']; 
  1718. $new_title = str_replace( '%author%', $author, $title_format ); 
  1719. } else if ( is_date() ) { 
  1720. global $wp_query; 
  1721. $date = $this->internationalize( $this->get_original_title( '', false ) ); 
  1722. $title_format = $aioseop_options['aiosp_date_title_format']; 
  1723. $new_title = str_replace( '%date%', $date, $title_format ); 
  1724. $day = get_query_var( 'day' ); 
  1725. if ( empty( $day ) ) { 
  1726. $day = ''; 
  1727. $new_title = str_replace( '%day%', $day, $new_title ); 
  1728. $monthnum = get_query_var( 'monthnum' ); 
  1729. $year = get_query_var( 'year' ); 
  1730. if ( empty( $monthnum ) || is_year() ) { 
  1731. $month = ''; 
  1732. $monthnum = 0; 
  1733. $month = date( 'F', mktime( 0, 0, 0, (int) $monthnum, 1, (int) $year ) ); 
  1734. $new_title = str_replace( '%monthnum%', $monthnum, $new_title ); 
  1735. if ( strpos( $new_title, '%month%' ) !== false ) { 
  1736. $new_title = str_replace( '%month%', $month, $new_title ); 
  1737. if ( strpos( $new_title, '%year%' ) !== false ) { 
  1738. $new_title = str_replace( '%year%', get_query_var( 'year' ), $new_title ); 
  1739. } else if ( is_post_type_archive() ) { 
  1740. if ( empty( $title ) ) { 
  1741. $title = $this->get_original_title( '', false ); 
  1742. $new_title = apply_filters( 'aioseop_archive_title', $this->apply_archive_title_format( $title ) ); 
  1743. } else { 
  1744. return false; 
  1745. $new_title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $new_title ); 
  1746. if ( strpos( $new_title, '%blog_description%' ) !== false ) { 
  1747. $new_title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $new_title ); 
  1748. $title = trim( $new_title ); 
  1749. $title = $this->paged_title( $title ); 
  1750.  
  1751. return $title; 
  1752. } else if ( is_404() ) { 
  1753. $title_format = $aioseop_options['aiosp_404_title_format']; 
  1754. $new_title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title_format ); 
  1755. if ( strpos( $new_title, '%blog_description%' ) !== false ) { 
  1756. $new_title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $new_title ); 
  1757. if ( strpos( $new_title, '%request_url%' ) !== false ) { 
  1758. $new_title = str_replace( '%request_url%', $_SERVER['REQUEST_URI'], $new_title ); 
  1759. if ( strpos( $new_title, '%request_words%' ) !== false ) { 
  1760. $new_title = str_replace( '%request_words%', $this->request_as_words( $_SERVER['REQUEST_URI'] ), $new_title ); 
  1761. if ( strpos( $new_title, '%404_title%' ) !== false ) { 
  1762. $new_title = str_replace( '%404_title%', $this->internationalize( $this->get_original_title( '', false ) ), $new_title ); 
  1763.  
  1764. return $new_title; 
  1765.  
  1766. return false; 
  1767.  
  1768. /** 
  1769. * @param string $sep 
  1770. * @param bool $echo 
  1771. * @param string $seplocation 
  1772. * @return The original title as delivered by WP (well, in most cases). 
  1773. */ 
  1774. function get_original_title( $sep = '|', $echo = false, $seplocation = '' ) { 
  1775. global $aioseop_options; 
  1776. if ( ! empty( $aioseop_options['aiosp_use_original_title'] ) ) { 
  1777. $has_filter = has_filter( 'wp_title', array( $this, 'wp_title' ) ); 
  1778. if ( false !== $has_filter ) { 
  1779. remove_filter( 'wp_title', array( $this, 'wp_title' ), $has_filter ); 
  1780. if ( current_theme_supports( 'title-tag' ) ) { 
  1781. $sep = '|'; 
  1782. $echo = false; 
  1783. $seplocation = 'right'; 
  1784. $title = wp_title( $sep, $echo, $seplocation ); 
  1785. if ( false !== $has_filter ) { 
  1786. add_filter( 'wp_title', array( $this, 'wp_title' ), $has_filter ); 
  1787. if ( $title && ( $title = trim( $title ) ) ) { 
  1788. return trim( $title ); 
  1789.  
  1790. // the_search_query() is not suitable, it cannot just return. 
  1791. global $s; 
  1792.  
  1793. $title = null; 
  1794.  
  1795. if ( is_home() ) { 
  1796. $title = get_option( 'blogname' ); 
  1797. } else if ( is_single() ) { 
  1798. $title = $this->internationalize( single_post_title( '', false ) ); 
  1799. } else if ( is_search() && isset( $s ) && ! empty( $s ) ) { 
  1800. $search = esc_attr( stripslashes( $s ) ); 
  1801. if ( ! empty( $aioseop_options['aiosp_cap_titles'] ) ) { 
  1802. $search = $this->capitalize( $search ); 
  1803. $title = $search; 
  1804. } else if ( ( is_tax() || is_category() ) && ! is_feed() ) { 
  1805. $category_name = $this->ucwords( $this->internationalize( single_cat_title( '', false ) ) ); 
  1806. $title = $category_name; 
  1807. } else if ( is_page() ) { 
  1808. $title = $this->internationalize( single_post_title( '', false ) ); 
  1809. } else if ( is_tag() ) { 
  1810. global $utw; 
  1811. if ( $utw ) { 
  1812. $tags = $utw->GetCurrentTagSet(); 
  1813. $tag = $tags[0]->tag; 
  1814. $tag = str_replace( '-', ' ', $tag ); 
  1815. } else { 
  1816. // For WordPress > 2.3. 
  1817. $tag = $this->internationalize( single_term_title( '', false ) ); 
  1818. if ( $tag ) { 
  1819. $title = $tag; 
  1820. } else if ( is_author() ) { 
  1821. $author = get_userdata( get_query_var( 'author' ) ); 
  1822. if ( $author === false ) { 
  1823. global $wp_query; 
  1824. $author = $wp_query->get_queried_object(); 
  1825. if ( $author !== false ) { 
  1826. $title = $author->display_name; 
  1827. } else if ( is_day() ) { 
  1828. $title = get_the_date(); 
  1829. } else if ( is_month() ) { 
  1830. $title = get_the_date( 'F, Y' ); 
  1831. } else if ( is_year() ) { 
  1832. $title = get_the_date( 'Y' ); 
  1833. } else if ( is_archive() ) { 
  1834. $title = $this->internationalize( post_type_archive_title( '', false ) ); 
  1835. } else if ( is_404() ) { 
  1836. $title_format = $aioseop_options['aiosp_404_title_format']; 
  1837. $new_title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title_format ); 
  1838. if ( strpos( $new_title, '%blog_description%' ) !== false ) { 
  1839. $new_title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $new_title ); 
  1840. if ( strpos( $new_title, '%request_url%' ) !== false ) { 
  1841. $new_title = str_replace( '%request_url%', $_SERVER['REQUEST_URI'], $new_title ); 
  1842. if ( strpos( $new_title, '%request_words%' ) !== false ) { 
  1843. $new_title = str_replace( '%request_words%', $this->request_as_words( $_SERVER['REQUEST_URI'] ), $new_title ); 
  1844. $title = $new_title; 
  1845.  
  1846. return trim( $title ); 
  1847.  
  1848. /** 
  1849. * @param $s 
  1850. * @return string 
  1851. */ 
  1852. function capitalize( $s ) { 
  1853. $s = trim( $s ); 
  1854. $tokens = explode( ' ', $s ); 
  1855. while ( list( $key, $val ) = each( $tokens ) ) { 
  1856. $tokens[ $key ] = trim( $tokens[ $key ] ); 
  1857. $tokens[ $key ] = $this->strtoupper( $this->substr( $tokens[ $key ], 0, 1 ) ) . $this->substr( $tokens[ $key ], 1 ); 
  1858. $s = implode( ' ', $tokens ); 
  1859.  
  1860. return $s; 
  1861.  
  1862. /** 
  1863. * @param $request 
  1864. * @return User -readable nice words for a given request. 
  1865. */ 
  1866. function request_as_words( $request ) { 
  1867. $request = htmlspecialchars( $request ); 
  1868. $request = str_replace( '.html', ' ', $request ); 
  1869. $request = str_replace( '.htm', ' ', $request ); 
  1870. $request = str_replace( '.', ' ', $request ); 
  1871. $request = str_replace( '/', ' ', $request ); 
  1872. $request = str_replace( '-', ' ', $request ); 
  1873. $request_a = explode( ' ', $request ); 
  1874. $request_new = array(); 
  1875. foreach ( $request_a as $token ) { 
  1876. $request_new[] = $this->ucwords( trim( $token ) ); 
  1877. $request = implode( ' ', $request_new ); 
  1878.  
  1879. return $request; 
  1880.  
  1881. /** 
  1882. * @param $title 
  1883. * @param null $p 
  1884. * @param string $title_format 
  1885. * @return string 
  1886. */ 
  1887. function apply_page_title_format( $title, $p = null, $title_format = '' ) { 
  1888. global $aioseop_options; 
  1889. if ( $p === null ) { 
  1890. global $post; 
  1891. } else { 
  1892. $post = $p; 
  1893. if ( empty( $title_format ) ) { 
  1894. $title_format = $aioseop_options['aiosp_page_title_format']; 
  1895.  
  1896. return $this->title_placeholder_helper( $title, $post, 'page', $title_format ); 
  1897.  
  1898. /** 
  1899. * @param $title 
  1900. * @param $post 
  1901. * @param string $type 
  1902. * @param string $title_format 
  1903. * @param string $category 
  1904. * @return string 
  1905. */ 
  1906. function title_placeholder_helper( $title, $post, $type = 'post', $title_format = '', $category = '' ) { 
  1907. if ( ! empty( $post ) ) { 
  1908. $authordata = get_userdata( $post->post_author ); 
  1909. } else { 
  1910. $authordata = new WP_User(); 
  1911. $new_title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title_format ); 
  1912. if ( strpos( $new_title, '%blog_description%' ) !== false ) { 
  1913. $new_title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $new_title ); 
  1914. if ( strpos( $new_title, "%{$type}_title%" ) !== false ) { 
  1915. $new_title = str_replace( "%{$type}_title%", $title, $new_title ); 
  1916. if ( $type == 'post' ) { 
  1917. if ( strpos( $new_title, '%category%' ) !== false ) { 
  1918. $new_title = str_replace( '%category%', $category, $new_title ); 
  1919. if ( strpos( $new_title, '%category_title%' ) !== false ) { 
  1920. $new_title = str_replace( '%category_title%', $category, $new_title ); 
  1921. if ( strpos( $new_title, '%tax_' ) && ! empty( $post ) ) { 
  1922. $taxes = get_object_taxonomies( $post, 'objects' ); 
  1923. if ( ! empty( $taxes ) ) { 
  1924. foreach ( $taxes as $t ) { 
  1925. if ( strpos( $new_title, "%tax_{$t->name}%" ) ) { 
  1926. $terms = $this->get_all_terms( $post->ID, $t->name ); 
  1927. $term = ''; 
  1928. if ( count( $terms ) > 0 ) { 
  1929. $term = $terms[0]; 
  1930. $new_title = str_replace( "%tax_{$t->name}%", $term, $new_title ); 
  1931. if ( strpos( $new_title, "%{$type}_author_login%" ) !== false ) { 
  1932. $new_title = str_replace( "%{$type}_author_login%", $authordata->user_login, $new_title ); 
  1933. if ( strpos( $new_title, "%{$type}_author_nicename%" ) !== false ) { 
  1934. $new_title = str_replace( "%{$type}_author_nicename%", $authordata->user_nicename, $new_title ); 
  1935. if ( strpos( $new_title, "%{$type}_author_firstname%" ) !== false ) { 
  1936. $new_title = str_replace( "%{$type}_author_firstname%", $this->ucwords( $authordata->first_name ), $new_title ); 
  1937. if ( strpos( $new_title, "%{$type}_author_lastname%" ) !== false ) { 
  1938. $new_title = str_replace( "%{$type}_author_lastname%", $this->ucwords( $authordata->last_name ), $new_title ); 
  1939. $title = trim( $new_title ); 
  1940.  
  1941. return $title; 
  1942.  
  1943. /** 
  1944. * @param $id 
  1945. * @param $taxonomy 
  1946. * @return array 
  1947. */ 
  1948. function get_all_terms( $id, $taxonomy ) { 
  1949. $keywords = array(); 
  1950. $terms = get_the_terms( $id, $taxonomy ); 
  1951. if ( ! empty( $terms ) ) { 
  1952. foreach ( $terms as $term ) { 
  1953. $keywords[] = $this->internationalize( $term->name ); 
  1954.  
  1955. return $keywords; 
  1956.  
  1957. /** 
  1958. * @param $title 
  1959. * @return string 
  1960. */ 
  1961. function paged_title( $title ) { 
  1962. // The page number if paged. 
  1963. global $paged; 
  1964. global $aioseop_options; 
  1965. // Simple tagging support. 
  1966. global $STagging; 
  1967. $page = get_query_var( 'page' ); 
  1968. if ( $paged > $page ) { 
  1969. $page = $paged; 
  1970. if ( is_paged() || ( isset( $STagging ) && $STagging->is_tag_view() && $paged ) || ( $page > 1 ) ) { 
  1971. $part = $this->internationalize( $aioseop_options['aiosp_paged_format'] ); 
  1972. if ( isset( $part ) || ! empty( $part ) ) { 
  1973. $part = ' ' . trim( $part ); 
  1974. $part = str_replace( '%page%', $page, $part ); 
  1975. $this->log( "paged_title() [$title] [$part]" ); 
  1976. $title .= $part; 
  1977.  
  1978. return $title; 
  1979.  
  1980. /** 
  1981. * @param $message 
  1982. */ 
  1983. function log( $message ) { 
  1984. if ( $this->do_log ) { 
  1985. @error_log( date( 'Y-m-d H:i:s' ) . ' ' . $message . "\n", 3, $this->log_file ); 
  1986.  
  1987. /** 
  1988. * @param $title 
  1989. * @param string $category 
  1990. * @param null $p 
  1991. * @return string 
  1992. */ 
  1993. function apply_post_title_format( $title, $category = '', $p = null ) { 
  1994. if ( $p === null ) { 
  1995. global $post; 
  1996. } else { 
  1997. $post = $p; 
  1998. $title_format = $this->get_post_title_format( 'post', $post ); 
  1999.  
  2000. return $this->title_placeholder_helper( $title, $post, 'post', $title_format, $category ); 
  2001.  
  2002. /** 
  2003. * @param string $title_type 
  2004. * @param null $p 
  2005. * @return bool|string 
  2006. */ 
  2007. function get_post_title_format( $title_type = 'post', $p = null ) { 
  2008. global $aioseop_options; 
  2009. if ( ( $title_type != 'post' ) && ( $title_type != 'archive' ) ) { 
  2010. return false; 
  2011. $title_format = "%{$title_type}_title% | %blog_title%"; 
  2012. if ( isset( $aioseop_options["aiosp_{$title_type}_title_format"] ) ) { 
  2013. $title_format = $aioseop_options["aiosp_{$title_type}_title_format"]; 
  2014. if ( ! empty( $aioseop_options['aiosp_enablecpost'] ) && ! empty( $aioseop_options['aiosp_cpostactive'] ) ) { 
  2015. $wp_post_types = $aioseop_options['aiosp_cpostactive']; 
  2016. if ( ! empty( $aioseop_options['aiosp_cposttitles'] ) ) { 
  2017. if ( ( ( $title_type == 'archive' ) && is_post_type_archive( $wp_post_types ) && $prefix = "aiosp_{$title_type}_" ) || 
  2018. ( ( $title_type == 'post' ) && $this->is_singular( $wp_post_types, $p ) && $prefix = 'aiosp_' ) 
  2019. ) { 
  2020. $post_type = get_post_type( $p ); 
  2021. if ( ! empty( $aioseop_options["{$prefix}{$post_type}_title_format"] ) ) { 
  2022. $title_format = $aioseop_options["{$prefix}{$post_type}_title_format"]; 
  2023.  
  2024. return $title_format; 
  2025.  
  2026. /** 
  2027. * @param array $post_types 
  2028. * @param null $post 
  2029. * @return bool 
  2030. */ 
  2031. function is_singular( $post_types = array(), $post = null ) { 
  2032. if ( ! empty( $post_types ) && is_object( $post ) ) { 
  2033. return in_array( $post->post_type, (array) $post_types ); 
  2034. } else { 
  2035. return is_singular( $post_types ); 
  2036.  
  2037. /** 
  2038. * @return bool|null 
  2039. */ 
  2040. function is_static_posts_page() { 
  2041. static $is_posts_page = null; 
  2042. if ( $is_posts_page !== null ) { 
  2043. return $is_posts_page; 
  2044. $post = $this->get_queried_object(); 
  2045. $is_posts_page = ( get_option( 'show_on_front' ) == 'page' && is_home() && ! empty( $post ) && $post->ID == get_option( 'page_for_posts' ) ); 
  2046.  
  2047. return $is_posts_page; 
  2048.  
  2049. /** 
  2050. * @return bool|null 
  2051. */ 
  2052. function is_static_front_page() { 
  2053. if ( isset( $this->is_front_page ) && $this->is_front_page !== null ) { 
  2054. return $this->is_front_page; 
  2055. $post = $this->get_queried_object(); 
  2056. $this->is_front_page = ( get_option( 'show_on_front' ) == 'page' && is_page() && ! empty( $post ) && $post->ID == get_option( 'page_on_front' ) ); 
  2057.  
  2058. return $this->is_front_page; 
  2059.  
  2060. /** 
  2061. * @param int $id 
  2062. * @return array 
  2063. */ 
  2064. function get_all_categories( $id = 0 ) { 
  2065. $keywords = array(); 
  2066. $categories = get_the_category( $id ); 
  2067. if ( ! empty( $categories ) ) { 
  2068. foreach ( $categories as $category ) { 
  2069. $keywords[] = $this->internationalize( $category->cat_name ); 
  2070.  
  2071. return $keywords; 
  2072.  
  2073. /** 
  2074. * @param string $tax 
  2075. * @return string 
  2076. */ 
  2077. function get_tax_title( $tax = '' ) { 
  2078. if ( AIOSEOPPRO ) { 
  2079. if ( empty( $this->meta_opts ) ) { 
  2080. $this->meta_opts = $this->get_current_options( array(), 'aiosp' ); 
  2081. if ( empty( $tax ) ) { 
  2082. if ( is_category() ) { 
  2083. $tax = 'category'; 
  2084. } else { 
  2085. $tax = get_query_var( 'taxonomy' ); 
  2086. $name = $this->get_tax_name( $tax ); 
  2087. $desc = $this->get_tax_desc( $tax ); 
  2088.  
  2089. return $this->apply_tax_title_format( $name, $desc, $tax ); 
  2090.  
  2091. // Handle prev / next links. 
  2092.  
  2093. /** 
  2094. * @param $tax 
  2095. * @return mixed|void 
  2096. */ 
  2097. function get_tax_name( $tax ) { 
  2098. global $aioseop_options; 
  2099. if ( AIOSEOPPRO ) { 
  2100. $opts = $this->meta_opts; 
  2101. if ( ! empty( $opts ) ) { 
  2102. $name = $opts['aiosp_title']; 
  2103. } else { 
  2104. $name = ''; 
  2105. if ( empty( $name ) ) { 
  2106. $name = single_term_title( '', false ); 
  2107. // Apparently we're already ucwordsing this elsewhere, and doing it a second time messes it up... why aren't we just doing this at the end? 
  2108. if ( ( $tax == 'category' ) && ( !empty( $aioseop_options['aiosp_cap_cats'] ) ) ) { 
  2109. $name = $this->ucwords( $name ); 
  2110.  
  2111. return $this->internationalize( $name ); 
  2112.  
  2113. /** 
  2114. * @param $tax 
  2115. * @return mixed|void 
  2116. */ 
  2117. function get_tax_desc( $tax ) { 
  2118. if ( AIOSEOPPRO ) { 
  2119. $opts = $this->meta_opts; 
  2120. if ( ! empty( $opts ) ) { 
  2121. $desc = $opts['aiosp_description']; 
  2122. } else { 
  2123. $desc = ''; 
  2124. if ( empty( $desc ) ) { 
  2125. $desc = term_description( '', $tax ); 
  2126.  
  2127. return $this->internationalize( $desc ); 
  2128.  
  2129. /** 
  2130. * @param $category_name 
  2131. * @param $category_description 
  2132. * @param string $tax 
  2133. * @return string 
  2134. */ 
  2135. function apply_tax_title_format( $category_name, $category_description, $tax = '' ) { 
  2136. if ( empty( $tax ) ) { 
  2137. $tax = get_query_var( 'taxonomy' ); 
  2138. $title_format = $this->get_tax_title_format( $tax ); 
  2139. $title = str_replace( '%taxonomy_title%', $category_name, $title_format ); 
  2140. if ( strpos( $title, '%taxonomy_description%' ) !== false ) { 
  2141. $title = str_replace( '%taxonomy_description%', $category_description, $title ); 
  2142. if ( strpos( $title, '%category_title%' ) !== false ) { 
  2143. $title = str_replace( '%category_title%', $category_name, $title ); 
  2144. if ( strpos( $title, '%category_description%' ) !== false ) { 
  2145. $title = str_replace( '%category_description%', $category_description, $title ); 
  2146. if ( strpos( $title, '%blog_title%' ) !== false ) { 
  2147. $title = str_replace( '%blog_title%', $this->internationalize( get_bloginfo( 'name' ) ), $title ); 
  2148. if ( strpos( $title, '%blog_description%' ) !== false ) { 
  2149. $title = str_replace( '%blog_description%', $this->internationalize( get_bloginfo( 'description' ) ), $title ); 
  2150. $title = wp_strip_all_tags( $title ); 
  2151.  
  2152. return $this->paged_title( $title ); 
  2153.  
  2154. /** 
  2155. * @param string $tax 
  2156. * @return string 
  2157. */ 
  2158. function get_tax_title_format( $tax = '' ) { 
  2159. global $aioseop_options; 
  2160. if ( AIOSEOPPRO ) { 
  2161. $title_format = '%taxonomy_title% | %blog_title%'; 
  2162. if ( is_category() ) { 
  2163. $title_format = $aioseop_options['aiosp_category_title_format']; 
  2164. } else { 
  2165. $taxes = $aioseop_options['aiosp_taxactive']; 
  2166. if ( empty( $tax ) ) { 
  2167. $tax = get_query_var( 'taxonomy' ); 
  2168. if ( ! empty( $aioseop_options["aiosp_{$tax}_tax_title_format"] ) ) { 
  2169. $title_format = $aioseop_options["aiosp_{$tax}_tax_title_format"]; 
  2170. if ( empty( $title_format ) ) { 
  2171. $title_format = '%category_title% | %blog_title%'; 
  2172. } else { 
  2173. $title_format = '%category_title% | %blog_title%'; 
  2174. if ( ! empty( $aioseop_options['aiosp_category_title_format'] ) ) { 
  2175. $title_format = $aioseop_options['aiosp_category_title_format']; 
  2176.  
  2177. return $title_format; 
  2178.  
  2179. return $title_format; 
  2180.  
  2181. /** 
  2182. * @param $title 
  2183. * @param string $category 
  2184. * @return string 
  2185. */ 
  2186. function apply_archive_title_format( $title, $category = '' ) { 
  2187. $title_format = $this->get_archive_title_format(); 
  2188. $r_title = array( '%blog_title%', '%blog_description%', '%archive_title%' ); 
  2189. $d_title = array( 
  2190. $this->internationalize( get_bloginfo( 'name' ) ),  
  2191. $this->internationalize( get_bloginfo( 'description' ) ),  
  2192. post_type_archive_title( '', false ),  
  2193. ); 
  2194. $title = trim( str_replace( $r_title, $d_title, $title_format ) ); 
  2195.  
  2196. return $title; 
  2197.  
  2198. /** 
  2199. * @return bool|string 
  2200. */ 
  2201. function get_archive_title_format() { 
  2202. return $this->get_post_title_format( 'archive' ); 
  2203.  
  2204. /** 
  2205. * @param null $post 
  2206. * @return mixed|string|void 
  2207. */ 
  2208. function get_main_description( $post = null ) { 
  2209. global $aioseop_options; 
  2210. $opts = $this->meta_opts; 
  2211. $description = ''; 
  2212. if ( is_author() && $this->show_page_description() ) { 
  2213. $description = $this->internationalize( get_the_author_meta( 'description' ) ); 
  2214. } else if ( function_exists( 'woocommerce_get_page_id' ) && is_post_type_archive( 'product' ) && ( $post_id = woocommerce_get_page_id( 'shop' ) ) && ( $post = get_post( $post_id ) ) ) { 
  2215. // $description = $this->get_post_description( $post ); 
  2216. // $description = $this->apply_cf_fields( $description ); 
  2217. if ( ! ( woocommerce_get_page_id( 'shop' ) == get_option( 'page_on_front' ) ) ) { 
  2218. $description = trim( $this->internationalize( get_post_meta( $post->ID, '_aioseop_description', true ) ) ); 
  2219. } else if ( woocommerce_get_page_id( 'shop' ) == get_option( 'page_on_front' ) && ! empty( $aioseop_options['aiosp_use_static_home_info'] ) ) { 
  2220. // $description = $this->get_aioseop_description( $post ); 
  2221. $description = trim( $this->internationalize( get_post_meta( $post->ID, '_aioseop_description', true ) ) ); 
  2222. } else if ( woocommerce_get_page_id( 'shop' ) == get_option( 'page_on_front' ) && empty( $aioseop_options['aiosp_use_static_home_info'] ) ) { 
  2223. $description = $this->get_aioseop_description( $post ); 
  2224. } else if ( is_front_page() ) { 
  2225. $description = $this->get_aioseop_description( $post ); 
  2226. } else if ( is_single() || is_page() || is_attachment() || is_home() || $this->is_static_posts_page() ) { 
  2227. $description = $this->get_aioseop_description( $post ); 
  2228. } else if ( ( is_category() || is_tag() || is_tax() ) && $this->show_page_description() ) { 
  2229. if ( ! empty( $opts ) && AIOSEOPPRO ) { 
  2230. $description = $opts['aiosp_description']; 
  2231. if ( empty( $description ) ) { 
  2232. $description = term_description(); 
  2233. $description = $this->internationalize( $description ); 
  2234. if ( empty( $aioseop_options['aiosp_dont_truncate_descriptions'] ) ) { 
  2235. $description = $this->trim_excerpt_without_filters( $description ); 
  2236.  
  2237. return $description; 
  2238.  
  2239. /** 
  2240. * @return bool 
  2241. */ 
  2242. function show_page_description() { 
  2243. global $aioseop_options; 
  2244. if ( ! empty( $aioseop_options['aiosp_hide_paginated_descriptions'] ) ) { 
  2245. $page = $this->get_page_number(); 
  2246. if ( ! empty( $page ) && ( $page > 1 ) ) { 
  2247. return false; 
  2248.  
  2249. return true; 
  2250.  
  2251. /** 
  2252. * @return mixed 
  2253. */ 
  2254. function get_page_number() { 
  2255. $page = get_query_var( 'page' ); 
  2256. if ( empty( $page ) ) { 
  2257. $page = get_query_var( 'paged' ); 
  2258.  
  2259. return $page; 
  2260.  
  2261. /** 
  2262. * @param null $post 
  2263. * @return mixed|string 
  2264. */ 
  2265. function get_aioseop_description( $post = null ) { 
  2266. global $aioseop_options; 
  2267. if ( null === $post ) { 
  2268. $post = $GLOBALS['post']; 
  2269. $blog_page = aiosp_common::get_blog_page(); 
  2270. $description = ''; 
  2271. if ( is_front_page() && empty( $aioseop_options['aiosp_use_static_home_info'] ) ) { 
  2272. $description = trim( $this->internationalize( $aioseop_options['aiosp_home_description'] ) ); 
  2273. } elseif ( ! empty( $blog_page ) ) { 
  2274. $description = $this->get_post_description( $blog_page ); 
  2275. if ( empty( $description ) && is_object( $post ) && ! is_archive() && empty( $blog_page ) ) { 
  2276. $description = $this->get_post_description( $post ); 
  2277. $description = $this->apply_cf_fields( $description ); 
  2278.  
  2279. return $description; 
  2280.  
  2281. /** 
  2282. * @param $post 
  2283. * @return mixed|string 
  2284. */ 
  2285. function get_post_description( $post ) { 
  2286. global $aioseop_options; 
  2287. $description = ''; 
  2288. if ( ! $this->show_page_description() ) { 
  2289. return ''; 
  2290. $description = trim( $this->internationalize( get_post_meta( $post->ID, '_aioseop_description', true ) ) ); 
  2291. if ( ! empty( $post ) && post_password_required( $post ) ) { 
  2292. return $description; 
  2293. if ( ! $description ) { 
  2294. if ( empty( $aioseop_options['aiosp_skip_excerpt'] ) ) { 
  2295. $description = $this->trim_excerpt_without_filters_full_length( $this->internationalize( $post->post_excerpt ) ); 
  2296. if ( ! $description && isset( $aioseop_options['aiosp_generate_descriptions'] ) && $aioseop_options['aiosp_generate_descriptions'] ) { 
  2297. $content = $post->post_content; 
  2298. if ( ! empty( $aioseop_options['aiosp_run_shortcodes'] ) ) { 
  2299. $content = do_shortcode( $content ); 
  2300. $content = wp_strip_all_tags( $content ); 
  2301. $description = $this->trim_excerpt_without_filters( $this->internationalize( $content ) ); 
  2302.  
  2303. // Internal whitespace trim. 
  2304. $description = preg_replace( '/\s\s+/u', ' ', $description ); 
  2305.  
  2306. return $description; 
  2307.  
  2308. /** 
  2309. * @param $text 
  2310. * @return string 
  2311. */ 
  2312. function trim_excerpt_without_filters_full_length( $text ) { 
  2313. $text = str_replace( ']]>', ']]>', $text ); 
  2314. $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text ); 
  2315. $text = wp_strip_all_tags( $text ); 
  2316.  
  2317. return trim( $text ); 
  2318.  
  2319. /** 
  2320. * @param $text 
  2321. * @param int $max 
  2322. * @return string 
  2323. */ 
  2324. function trim_excerpt_without_filters( $text, $max = 0 ) { 
  2325. $text = str_replace( ']]>', ']]>', $text ); 
  2326. $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text ); 
  2327. $text = wp_strip_all_tags( $text ); 
  2328. // Treat other common word-break characters like a space. 
  2329. $text2 = preg_replace( '/[, ._\-=+&!\?;:*]/s', ' ', $text ); 
  2330. if ( ! $max ) { 
  2331. $max = $this->maximum_description_length; 
  2332. $max_orig = $max; 
  2333. $len = $this->strlen( $text2 ); 
  2334. if ( $max < $len ) { 
  2335. if ( function_exists( 'mb_strrpos' ) ) { 
  2336. $pos = mb_strrpos( $text2, ' ', - ( $len - $max ) ); 
  2337. if ( false === $pos ) { 
  2338. $pos = $max; 
  2339. if ( $pos > $this->minimum_description_length ) { 
  2340. $max = $pos; 
  2341. } else { 
  2342. $max = $this->minimum_description_length; 
  2343. } else { 
  2344. while ( ' ' != $text2[ $max ] && $max > $this->minimum_description_length ) { 
  2345. $max --; 
  2346.  
  2347. // Probably no valid chars to break on? 
  2348. if ( $len > $max_orig && $max < intval( $max_orig / 2 ) ) { 
  2349. $max = $max_orig; 
  2350. $text = $this->substr( $text, 0, $max ); 
  2351.  
  2352. return trim( $text ); 
  2353.  
  2354. /** 
  2355. * @param $query 
  2356. * @param bool $show_page 
  2357. * @return bool|false|string 
  2358. */ 
  2359. function aiosp_mrt_get_url( $query, $show_page = true ) { 
  2360. if ( $query->is_404 || $query->is_search ) { 
  2361. return false; 
  2362. $link = ''; 
  2363. $haspost = count( $query->posts ) > 0; 
  2364. if ( get_query_var( 'm' ) ) { 
  2365. $m = preg_replace( '/[^0-9]/', '', get_query_var( 'm' ) ); 
  2366. switch ( $this->strlen( $m ) ) { 
  2367. case 4: 
  2368. $link = get_year_link( $m ); 
  2369. break; 
  2370. case 6: 
  2371. $link = get_month_link( $this->substr( $m, 0, 4 ), $this->substr( $m, 4, 2 ) ); 
  2372. break; 
  2373. case 8: 
  2374. $link = get_day_link( $this->substr( $m, 0, 4 ), $this->substr( $m, 4, 2 ), $this->substr( $m, 6, 2 ) ); 
  2375. break; 
  2376. default: 
  2377. return false; 
  2378. } elseif ( $query->is_home && ( get_option( 'show_on_front' ) == 'page' ) && ( $pageid = get_option( 'page_for_posts' ) ) ) { 
  2379. $link = get_permalink( $pageid ); 
  2380. } elseif ( is_front_page() || ( $query->is_home && ( get_option( 'show_on_front' ) != 'page' || ! get_option( 'page_for_posts' ) ) ) ) { 
  2381. if ( function_exists( 'icl_get_home_url' ) ) { 
  2382. $link = icl_get_home_url(); 
  2383. } else { 
  2384. $link = trailingslashit( home_url() ); 
  2385. } elseif ( ( $query->is_single || $query->is_page ) && $haspost ) { 
  2386. $post = $query->posts[0]; 
  2387. $link = get_permalink( $post->ID ); 
  2388. } elseif ( $query->is_author && $haspost ) { 
  2389. $author = get_userdata( get_query_var( 'author' ) ); 
  2390. if ( false === $author ) { 
  2391. return false; 
  2392. $link = get_author_posts_url( $author->ID, $author->user_nicename ); 
  2393. } elseif ( $query->is_category && $haspost ) { 
  2394. $link = get_category_link( get_query_var( 'cat' ) ); 
  2395. } elseif ( $query->is_tag && $haspost ) { 
  2396. $tag = get_term_by( 'slug', get_query_var( 'tag' ), 'post_tag' ); 
  2397. if ( ! empty( $tag->term_id ) ) { 
  2398. $link = get_tag_link( $tag->term_id ); 
  2399. } elseif ( $query->is_day && $haspost ) { 
  2400. $link = get_day_link( get_query_var( 'year' ),  
  2401. get_query_var( 'monthnum' ),  
  2402. get_query_var( 'day' ) ); 
  2403. } elseif ( $query->is_month && $haspost ) { 
  2404. $link = get_month_link( get_query_var( 'year' ),  
  2405. get_query_var( 'monthnum' ) ); 
  2406. } elseif ( $query->is_year && $haspost ) { 
  2407. $link = get_year_link( get_query_var( 'year' ) ); 
  2408. } elseif ( $query->is_tax && $haspost ) { 
  2409. $taxonomy = get_query_var( 'taxonomy' ); 
  2410. $term = get_query_var( 'term' ); 
  2411. if ( ! empty( $term ) ) { 
  2412. $link = get_term_link( $term, $taxonomy ); 
  2413. } elseif ( $query->is_archive && function_exists( 'get_post_type_archive_link' ) && ( $post_type = get_query_var( 'post_type' ) ) ) { 
  2414. if ( is_array( $post_type ) ) { 
  2415. $post_type = reset( $post_type ); 
  2416. $link = get_post_type_archive_link( $post_type ); 
  2417. } else { 
  2418. return false; 
  2419. if ( empty( $link ) || ! is_string( $link ) ) { 
  2420. return false; 
  2421. if ( apply_filters( 'aioseop_canonical_url_pagination', $show_page ) ) { 
  2422. $link = $this->get_paged( $link ); 
  2423. if ( ! empty( $link ) ) { 
  2424. global $aioseop_options; 
  2425. if ( isset( $aioseop_options['aiosp_can_set_protocol'] ) && ( 'auto' !== $aioseop_options['aiosp_can_set_protocol'] ) ) { 
  2426. if ( 'http' === $aioseop_options['aiosp_can_set_protocol'] ) { 
  2427. $link = preg_replace( '/^https:/i', 'http:', $link ); 
  2428. } elseif ( 'https' === $aioseop_options['aiosp_can_set_protocol'] ) { 
  2429. $link = preg_replace( '/^http:/i', 'https:', $link ); 
  2430.  
  2431. return $link; 
  2432.  
  2433. /** 
  2434. * @param $link 
  2435. * @return string 
  2436. */ 
  2437. function get_paged( $link ) { 
  2438. global $wp_rewrite; 
  2439. $page = $this->get_page_number(); 
  2440. $page_name = 'page'; 
  2441. if ( ! empty( $wp_rewrite ) && ! empty( $wp_rewrite->pagination_base ) ) { 
  2442. $page_name = $wp_rewrite->pagination_base; 
  2443. if ( ! empty( $page ) && $page > 1 ) { 
  2444. if ( $page == get_query_var( 'page' ) ) { 
  2445. $link = trailingslashit( $link ) . "$page"; 
  2446. } else { 
  2447. $link = trailingslashit( $link ) . trailingslashit( $page_name ) . $page; 
  2448. $link = user_trailingslashit( $link, 'paged' ); 
  2449.  
  2450. return $link; 
  2451.  
  2452. /** 
  2453. * @return comma|string 
  2454. */ 
  2455. function get_main_keywords() { 
  2456. global $aioseop_options; 
  2457. global $aioseop_keywords; 
  2458. global $post; 
  2459. $opts = $this->meta_opts; 
  2460. if ( ( is_front_page() && $aioseop_options['aiosp_home_keywords'] && ! $this->is_static_posts_page() ) || $this->is_static_front_page() ) { 
  2461. if ( ! empty( $aioseop_options['aiosp_use_static_home_info'] ) ) { 
  2462. $keywords = $this->get_all_keywords(); 
  2463. } else { 
  2464. $keywords = trim( $this->internationalize( $aioseop_options['aiosp_home_keywords'] ) ); 
  2465. } elseif ( empty( $aioseop_options['aiosp_dynamic_postspage_keywords'] ) && $this->is_static_posts_page() ) { 
  2466. $keywords = stripslashes( $this->internationalize( $opts['aiosp_keywords'] ) ); // And if option = use page set keywords instead of keywords from recent posts. 
  2467. } elseif ( ( $blog_page = aiosp_common::get_blog_page( $post ) ) && empty( $aioseop_options['aiosp_dynamic_postspage_keywords'] ) ) { 
  2468. $keywords = stripslashes( $this->internationalize( get_post_meta( $blog_page->ID, '_aioseop_keywords', true ) ) ); 
  2469. } elseif ( empty( $aioseop_options['aiosp_dynamic_postspage_keywords'] ) && ( is_archive() || is_post_type_archive() ) ) { 
  2470. $keywords = ''; 
  2471. } else { 
  2472. $keywords = $this->get_all_keywords(); 
  2473.  
  2474. return $keywords; 
  2475.  
  2476. /** 
  2477. * @return comma-separated list of unique keywords 
  2478. */ 
  2479. function get_all_keywords() { 
  2480. global $posts; 
  2481. global $aioseop_options; 
  2482. if ( is_404() ) { 
  2483. return null; 
  2484. // If we are on synthetic pages. 
  2485. if ( ! is_home() && ! is_page() && ! is_single() && ! $this->is_static_front_page() && ! $this->is_static_posts_page() && ! is_archive() && ! is_post_type_archive() && ! is_category() && ! is_tag() && ! is_tax() ) { 
  2486. return null; 
  2487. $keywords = array(); 
  2488. $opts = $this->meta_opts; 
  2489. if ( ! empty( $opts['aiosp_keywords'] ) ) { 
  2490. $traverse = $this->keyword_string_to_list( $this->internationalize( $opts['aiosp_keywords'] ) ); 
  2491. if ( ! empty( $traverse ) ) { 
  2492. foreach ( $traverse as $keyword ) { 
  2493. $keywords[] = $keyword; 
  2494. if ( empty( $posts ) ) { 
  2495. global $post; 
  2496. $post_arr = array( $post ); 
  2497. } else { 
  2498. $post_arr = $posts; 
  2499. if ( is_array( $post_arr ) ) { 
  2500. $postcount = count( $post_arr ); 
  2501. foreach ( $post_arr as $p ) { 
  2502. if ( $p ) { 
  2503. $id = $p->ID; 
  2504. if ( 1 == $postcount || ! empty( $aioseop_options['aiosp_dynamic_postspage_keywords'] ) ) { 
  2505. // Custom field keywords. 
  2506. $keywords_i = null; 
  2507. $keywords_i = stripslashes( $this->internationalize( get_post_meta( $id, '_aioseop_keywords', true ) ) ); 
  2508. if ( is_attachment() ) { 
  2509. $id = $p->post_parent; 
  2510. if ( empty( $keywords_i ) ) { 
  2511. $keywords_i = stripslashes( $this->internationalize( get_post_meta( $id, '_aioseop_keywords', true ) ) ); 
  2512. $traverse = $this->keyword_string_to_list( $keywords_i ); 
  2513. if ( ! empty( $traverse ) ) { 
  2514. foreach ( $traverse as $keyword ) { 
  2515. $keywords[] = $keyword; 
  2516.  
  2517. if ( ! empty( $aioseop_options['aiosp_use_tags_as_keywords'] ) ) { 
  2518. $keywords = array_merge( $keywords, $this->get_all_tags( $id ) ); 
  2519. // Autometa. 
  2520. $autometa = stripslashes( get_post_meta( $id, 'autometa', true ) ); 
  2521. if ( isset( $autometa ) && ! empty( $autometa ) ) { 
  2522. $autometa_array = explode( ' ', $autometa ); 
  2523. foreach ( $autometa_array as $e ) { 
  2524. $keywords[] = $e; 
  2525.  
  2526. if ( isset( $aioseop_options['aiosp_use_categories'] ) && $aioseop_options['aiosp_use_categories'] && ! is_page() ) { 
  2527. $keywords = array_merge( $keywords, $this->get_all_categories( $id ) ); 
  2528.  
  2529. return $this->get_unique_keywords( $keywords ); 
  2530.  
  2531. /** 
  2532. * @param $keywords 
  2533. * @return array 
  2534. */ 
  2535. function keyword_string_to_list( $keywords ) { 
  2536. $traverse = array(); 
  2537. $keywords_i = str_replace( '"', '', $keywords ); 
  2538. if ( isset( $keywords_i ) && ! empty( $keywords_i ) ) { 
  2539. $traverse = explode( ', ', $keywords_i ); 
  2540.  
  2541. return $traverse; 
  2542.  
  2543. /** 
  2544. * @param int $id 
  2545. * @return array 
  2546. */ 
  2547. function get_all_tags( $id = 0 ) { 
  2548. $keywords = array(); 
  2549. $tags = get_the_tags( $id ); 
  2550. if ( ! empty( $tags ) && is_array( $tags ) ) { 
  2551. foreach ( $tags as $tag ) { 
  2552. $keywords[] = $this->internationalize( $tag->name ); 
  2553. // Ultimate Tag Warrior integration. 
  2554. global $utw; 
  2555. if ( $utw ) { 
  2556. $tags = $utw->GetTagsForPost( $p ); 
  2557. if ( is_array( $tags ) ) { 
  2558. foreach ( $tags as $tag ) { 
  2559. $tag = $tag->tag; 
  2560. $tag = str_replace( '_', ' ', $tag ); 
  2561. $tag = str_replace( '-', ' ', $tag ); 
  2562. $tag = stripslashes( $tag ); 
  2563. $keywords[] = $tag; 
  2564.  
  2565. return $keywords; 
  2566.  
  2567. /** 
  2568. * @param $keywords 
  2569. * @return string 
  2570. */ 
  2571. function get_unique_keywords( $keywords ) { 
  2572. return implode( ', ', $this->clean_keyword_list( $keywords ) ); 
  2573.  
  2574. /** 
  2575. * @param $keywords 
  2576. * @return array 
  2577. */ 
  2578. function clean_keyword_list( $keywords ) { 
  2579. $small_keywords = array(); 
  2580. if ( ! is_array( $keywords ) ) { 
  2581. $keywords = $this->keyword_string_to_list( $keywords ); 
  2582. if ( ! empty( $keywords ) ) { 
  2583. foreach ( $keywords as $word ) { 
  2584. $small_keywords[] = trim( $this->strtolower( $word ) ); 
  2585.  
  2586. return array_unique( $small_keywords ); 
  2587.  
  2588. /** 
  2589. * @param $term_id 
  2590. * @param $new_term_id 
  2591. * @param string $term_taxonomy_id 
  2592. * @param string $taxonomy 
  2593. */ 
  2594. function split_shared_term( $term_id, $new_term_id, $term_taxonomy_id = '', $taxonomy = '' ) { 
  2595. $terms = $this->get_all_term_data( $term_id ); 
  2596. if ( ! empty( $terms ) ) { 
  2597. $new_terms = $this->get_all_term_data( $new_term_id ); 
  2598. if ( empty( $new_terms ) ) { 
  2599. foreach ( $terms as $k => $v ) { 
  2600. add_term_meta( $new_term_id, $k, $v, true ); 
  2601. add_term_meta( $term_id, '_aioseop_term_was_split', true, true ); 
  2602.  
  2603. /** 
  2604. * @param $term_id 
  2605. * @return array 
  2606. */ 
  2607. function get_all_term_data( $term_id ) { 
  2608. $terms = array(); 
  2609. $optlist = array( 
  2610. 'keywords',  
  2611. 'description',  
  2612. 'title',  
  2613. 'custom_link',  
  2614. 'sitemap_exclude',  
  2615. 'disable',  
  2616. 'disable_analytics',  
  2617. 'noindex',  
  2618. 'nofollow',  
  2619. 'noodp',  
  2620. 'noydir',  
  2621. 'titleatr',  
  2622. 'menulabel',  
  2623. ); 
  2624. foreach ( $optlist as $f ) { 
  2625. $meta = get_term_meta( $term_id, '_aioseop_' . $f, true ); 
  2626. if ( ! empty( $meta ) ) { 
  2627. $terms[ '_aioseop_' . $f ] = $meta; 
  2628.  
  2629. return $terms; 
  2630.  
  2631. function add_page_icon() { 
  2632. wp_enqueue_script( 'wp-pointer', false, array( 'jquery' ) ); 
  2633. wp_enqueue_style( 'wp-pointer' ); 
  2634. $this->add_admin_pointers(); 
  2635.  
  2636. wp_enqueue_style( 'aiosp_admin_style', AIOSEOP_PLUGIN_URL . 'css/aiosp_admin.css' ); 
  2637. ?> 
  2638. <script> 
  2639. function aioseop_show_pointer(handle, value) { 
  2640. if (typeof( jQuery ) != 'undefined') { 
  2641. var p_edge = 'bottom'; 
  2642. var p_align = 'center'; 
  2643. if (typeof( jQuery(value.pointer_target).pointer) != 'undefined') { 
  2644. if (typeof( value.pointer_edge ) != 'undefined') p_edge = value.pointer_edge; 
  2645. if (typeof( value.pointer_align ) != 'undefined') p_align = value.pointer_align; 
  2646. jQuery(value.pointer_target).pointer({ 
  2647. content: value.pointer_text,  
  2648. position: { 
  2649. edge: p_edge,  
  2650. align: p_align 
  2651. },  
  2652. close: function () { 
  2653. jQuery.post(ajaxurl, { 
  2654. pointer: handle,  
  2655. action: 'dismiss-wp-pointer' 
  2656. }); 
  2657. }).pointer('open'); 
  2658. <?php 
  2659. if ( ! empty( $this->pointers ) ) { 
  2660. ?> 
  2661. if (typeof( jQuery ) != 'undefined') { 
  2662. jQuery(document).ready(function () { 
  2663. var admin_pointer; 
  2664. var admin_index; 
  2665. <?php 
  2666. foreach ( $this->pointers as $k => $p ) 
  2667. {if ( ! empty( $p['pointer_scope'] ) && ( 'global' === $p['pointer_scope'] ) ) { 
  2668. ?>admin_index = "<?php echo esc_attr( $k ); ?>"; 
  2669. admin_pointer = <?php echo json_encode( $p ); ?>; 
  2670. aioseop_show_pointer(admin_index, admin_pointer); 
  2671. <?php 
  2672. } ?> 
  2673. }); 
  2674. <?php } ?> 
  2675. </script> 
  2676. <?php 
  2677.  
  2678. function add_admin_pointers() { 
  2679. if ( AIOSEOPPRO ) { 
  2680. $this->pointers['aioseop_menu_236'] = array( 
  2681. 'pointer_target' => '#toplevel_page_all-in-one-seo-pack-pro-aioseop_class',  
  2682. 'pointer_text' => '<h3>' . sprintf( __( 'Welcome to Version %s!', 'all-in-one-seo-pack' ), AIOSEOP_VERSION ) 
  2683. . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack Pro ever! Please review your settings, as we\'re always adding new features for you!', 'all-in-one-seo-pack' ) . '</p>',  
  2684. 'pointer_edge' => 'top',  
  2685. 'pointer_align' => 'left',  
  2686. 'pointer_scope' => 'global',  
  2687. ); 
  2688. $this->pointers['aioseop_welcome_230'] = array( 
  2689. 'pointer_target' => '#aioseop_top_button',  
  2690. 'pointer_text' => '<h3>' . sprintf( __( 'Review Your Settings', 'all-in-one-seo-pack' ), AIOSEOP_VERSION ) 
  2691. . '</h3><p>' . __( 'New in 2.4: Improved support for taxonomies, Woocommerce and massive performance improvements under the hood! Please review your settings on each options page!', 'all-in-one-seo-pack' ) . '</p>',  
  2692. 'pointer_edge' => 'bottom',  
  2693. 'pointer_align' => 'left',  
  2694. 'pointer_scope' => 'local',  
  2695. ); 
  2696. $this->filter_pointers(); 
  2697. } else { 
  2698. $this->pointers['aioseop_menu_220'] = array( 
  2699. 'pointer_target' => '#toplevel_page_all-in-one-seo-pack-aioseop_class',  
  2700. 'pointer_text' => '<h3>' . sprintf( __( 'Welcome to Version %s!', 'all-in-one-seo-pack' ), AIOSEOP_VERSION ) 
  2701. . '</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>',  
  2702. 'pointer_edge' => 'top',  
  2703. 'pointer_align' => 'left',  
  2704. 'pointer_scope' => 'global',  
  2705. ); 
  2706. $this->pointers['aioseop_welcome_220'] = array( 
  2707. 'pointer_target' => '#aioseop_top_button',  
  2708. 'pointer_text' => '<h3>' . sprintf( __( 'Review Your Settings', 'all-in-one-seo-pack' ), AIOSEOP_VERSION ) 
  2709. . '</h3><p>' . __( 'Thank you for running the latest and greatest All in One SEO Pack ever! New since 2.2: Control who accesses your site with the new Robots.txt Editor and File Editor modules! Enable them from the Feature Manager. Remember to review your settings, we have added some new ones!', 'all-in-one-seo-pack' ) . '</p>',  
  2710. 'pointer_edge' => 'bottom',  
  2711. 'pointer_align' => 'left',  
  2712. 'pointer_scope' => 'local',  
  2713. ); 
  2714. $this->filter_pointers(); 
  2715.  
  2716. function add_page_hooks() { 
  2717.  
  2718. global $aioseop_options; 
  2719.  
  2720. $post_objs = get_post_types( '', 'objects' ); 
  2721. $pt = array_keys( $post_objs ); 
  2722. $rempost = array( 'revision', 'nav_menu_item' ); 
  2723. $pt = array_diff( $pt, $rempost ); 
  2724. $post_types = array(); 
  2725.  
  2726. $aiosp_enablecpost = ''; 
  2727. if ( isset( $_REQUEST['aiosp_enablecpost'] ) ) { 
  2728. $aiosp_enablecpost = $_REQUEST['aiosp_enablecpost']; 
  2729.  
  2730. foreach ( $pt as $p ) { 
  2731. if ( ! empty( $post_objs[ $p ]->label ) ) { 
  2732. if ( $post_objs[ $p ]->_builtin && empty( $aioseop_options['aiosp_enablecpost'] ) ) { 
  2733. $post_types[ $p ] = $post_objs[ $p ]->label; 
  2734. } elseif ( ! empty( $aioseop_options['aiosp_enablecpost'] ) || $aiosp_enablecpost == 'on' ) { 
  2735. $post_types[ $p ] = $post_objs[ $p ]->label; 
  2736. } else { 
  2737. $post_types[ $p ] = $p; 
  2738.  
  2739. foreach ( $pt as $p ) { 
  2740. if ( ! empty( $post_objs[ $p ]->label ) ) { 
  2741. $all_post_types[ $p ] = $post_objs[ $p ]->label; 
  2742.  
  2743. $taxes = get_taxonomies( '', 'objects' ); 
  2744. $tx = array_keys( $taxes ); 
  2745. $remtax = array( 'nav_menu', 'link_category', 'post_format' ); 
  2746. $tx = array_diff( $tx, $remtax ); 
  2747. $tax_types = array(); 
  2748. foreach ( $tx as $t ) { 
  2749. if ( ! empty( $taxes[ $t ]->label ) ) { 
  2750. $tax_types[ $t ] = $taxes[ $t ]->label; 
  2751. } else { 
  2752. $taxes[ $t ] = $t; 
  2753. $this->default_options['posttypecolumns']['initial_options'] = $post_types; 
  2754. $this->default_options['cpostactive']['initial_options'] = $all_post_types; 
  2755. $this->default_options['cpostnoindex']['initial_options'] = $post_types; 
  2756. $this->default_options['cpostnofollow']['initial_options'] = $post_types; 
  2757. $this->default_options['cpostnoodp']['initial_options'] = $post_types; 
  2758. $this->default_options['cpostnoydir']['initial_options'] = $post_types; 
  2759. if ( AIOSEOPPRO ) { 
  2760. $this->default_options['taxactive']['initial_options'] = $tax_types; 
  2761. $this->default_options['google_author_location']['initial_options'] = $post_types; 
  2762. $this->default_options['google_author_location']['initial_options'] = array_merge( array( 'front' => __( 'Front Page', 'all-in-one-seo-pack' ) ), $post_types, array( 'all' => __( 'Everywhere Else', 'all-in-one-seo-pack' ) ) ); 
  2763. $this->default_options['google_author_location']['default'] = array_keys( $this->default_options['google_author_location']['initial_options'] ); 
  2764.  
  2765. foreach ( $post_types as $p => $pt ) { 
  2766. $field = $p . '_title_format'; 
  2767. $name = $post_objs[ $p ]->labels->singular_name; 
  2768. if ( ! isset( $this->default_options[ $field ] ) ) { 
  2769. $this->default_options[ $field ] = array( 
  2770. 'name' => "$name " . __( 'Title Format:', 'all-in-one-seo-pack' ) . "<br />($p)",  
  2771. 'type' => 'text',  
  2772. 'default' => '%post_title% | %blog_title%',  
  2773. 'condshow' => array( 
  2774. 'aiosp_rewrite_titles' => 1,  
  2775. 'aiosp_enablecpost' => 'on',  
  2776. 'aiosp_cpostadvanced' => 'on',  
  2777. 'aiosp_cposttitles' => 'on',  
  2778. 'aiosp_cpostactive\[\]' => $p,  
  2779. ),  
  2780. ); 
  2781. $this->help_text[ $field ] = __( 'The following macros are supported:', 'all-in-one-seo-pack' ) 
  2782. . '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  2783. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  2784. __( '%post_title% - The original title of the post.', 'all-in-one-seo-pack' ) . '</li><li>'; 
  2785. $taxes = get_object_taxonomies( $p, 'objects' ); 
  2786. if ( ! empty( $taxes ) ) { 
  2787. foreach ( $taxes as $n => $t ) { 
  2788. $this->help_text[ $field ] .= sprintf( __( "%%tax_%s%% - This post's associated %s taxonomy title", 'all-in-one-seo-pack' ), $n, $t->label ) . '</li><li>'; 
  2789. $this->help_text[ $field ] .= 
  2790. __( "%post_author_login% - This post's author' login", 'all-in-one-seo-pack' ) . '</li><li>' . 
  2791. __( "%post_author_nicename% - This post's author' nicename", 'all-in-one-seo-pack' ) . '</li><li>' . 
  2792. __( "%post_author_firstname% - This post's author' first name (capitalized)", 'all-in-one-seo-pack' ) . '</li><li>' . 
  2793. __( "%post_author_lastname% - This post's author' last name (capitalized)", 'all-in-one-seo-pack' ) . '</li>' . 
  2794. '</ul>'; 
  2795. $this->help_anchors[ $field ] = '#custom-titles'; 
  2796. $this->layout['cpt']['options'][] = $field; 
  2797. global $wp_roles; 
  2798. if ( ! isset( $wp_roles ) ) { 
  2799. $wp_roles = new WP_Roles(); 
  2800. $role_names = $wp_roles->get_names(); 
  2801. ksort( $role_names ); 
  2802. $this->default_options['ga_exclude_users']['initial_options'] = $role_names; 
  2803.  
  2804. unset( $tax_types['category'] ); 
  2805. unset( $tax_types['post_tag'] ); 
  2806. $this->default_options['tax_noindex']['initial_options'] = $tax_types; 
  2807. if ( empty( $tax_types ) ) { 
  2808. unset( $this->default_options['tax_noindex'] ); 
  2809.  
  2810. if ( AIOSEOPPRO ) { 
  2811. foreach ( $tax_types as $p => $pt ) { 
  2812. $field = $p . '_tax_title_format'; 
  2813. $name = $pt; 
  2814. if ( ! isset( $this->default_options[ $field ] ) ) { 
  2815. $this->default_options[ $field ] = array( 
  2816. 'name' => "$name " . __( 'Taxonomy Title Format:', 'all-in-one-seo-pack' ),  
  2817. 'type' => 'text',  
  2818. 'default' => '%taxonomy_title% | %blog_title%',  
  2819. 'condshow' => array( 
  2820. 'aiosp_rewrite_titles' => 1,  
  2821. 'aiosp_enablecpost' => 'on',  
  2822. 'aiosp_cpostadvanced' => 'on',  
  2823. 'aiosp_cposttitles' => 'on',  
  2824. 'aiosp_taxactive\[\]' => $p,  
  2825. ),  
  2826. ); 
  2827. $this->help_text[ $field ] = __( 'The following macros are supported:', 'all-in-one-seo-pack' ) . 
  2828. '<ul><li>' . __( '%blog_title% - Your blog title', 'all-in-one-seo-pack' ) . '</li><li>' . 
  2829. __( '%blog_description% - Your blog description', 'all-in-one-seo-pack' ) . '</li><li>' . 
  2830. __( '%taxonomy_title% - The original title of the taxonomy', 'all-in-one-seo-pack' ) . '</li><li>' . 
  2831. __( '%taxonomy_description% - The description of the taxonomy', 'all-in-one-seo-pack' ) . '</li></ul>'; 
  2832. $this->help_anchors[ $field ] = '#custom-titles'; 
  2833. $this->layout['cpt']['options'][] = $field; 
  2834. $this->setting_options(); 
  2835. $this->add_help_text_links(); 
  2836.  
  2837. if ( AIOSEOPPRO ) { 
  2838. global $aioseop_update_checker; 
  2839. add_action( "{$this->prefix}update_options", array( 
  2840. $aioseop_update_checker,  
  2841. 'license_change_check',  
  2842. ), 10, 2 ); 
  2843. add_action( "{$this->prefix}settings_update", array( $aioseop_update_checker, 'update_check' ), 10, 2 ); 
  2844.  
  2845. add_filter( "{$this->prefix}display_options", array( $this, 'filter_options' ), 10, 2 ); 
  2846. parent::add_page_hooks(); 
  2847.  
  2848. function settings_page_init() { 
  2849. add_filter( "{$this->prefix}submit_options", array( $this, 'filter_submit' ) ); 
  2850.  
  2851. function enqueue_scripts() { 
  2852. add_filter( "{$this->prefix}display_settings", array( $this, 'filter_settings' ), 10, 3 ); 
  2853. add_filter( "{$this->prefix}display_options", array( $this, 'filter_options' ), 10, 2 ); 
  2854. parent::enqueue_scripts(); 
  2855.  
  2856. /** 
  2857. * @param $submit 
  2858. * @return mixed 
  2859. */ 
  2860. function filter_submit( $submit ) { 
  2861. $submit['Submit_Default']['value'] = __( 'Reset General Settings to Defaults', 'all-in-one-seo-pack' ) . ' »'; 
  2862. $submit['Submit_All_Default'] = array( 
  2863. 'type' => 'submit',  
  2864. 'class' => 'button-secondary',  
  2865. 'value' => __( 'Reset ALL Settings to Defaults', 'all-in-one-seo-pack' ) . ' »',  
  2866. ); 
  2867.  
  2868. return $submit; 
  2869.  
  2870. /** 
  2871. * Handle resetting options to defaults, but preserve the license key if pro. 
  2872. * @param null $location 
  2873. * @param bool $delete 
  2874. */ 
  2875. function reset_options( $location = null, $delete = false ) { 
  2876. if ( AIOSEOPPRO ) { 
  2877. global $aioseop_update_checker; 
  2878. if ( $delete === true ) { 
  2879.  
  2880. if ( AIOSEOPPRO ) { 
  2881. $license_key = ''; 
  2882. if ( isset( $this->options ) && isset( $this->options['aiosp_license_key'] ) ) { 
  2883. $license_key = $this->options['aiosp_license_key']; 
  2884.  
  2885. $this->delete_class_option( $delete ); 
  2886.  
  2887. if ( AIOSEOPPRO ) { 
  2888. $this->options = array( 'aiosp_license_key' => $license_key ); 
  2889. } else { 
  2890. $this->options = array(); 
  2891. $default_options = $this->default_options( $location ); 
  2892.  
  2893. if ( AIOSEOPPRO ) { 
  2894. foreach ( $default_options as $k => $v ) { 
  2895. if ( $k != 'aiosp_license_key' ) { 
  2896. $this->options[ $k ] = $v; 
  2897. $aioseop_update_checker->license_key = $this->options['aiosp_license_key']; 
  2898. } else { 
  2899. foreach ( $default_options as $k => $v ) { 
  2900. $this->options[ $k ] = $v; 
  2901. $this->update_class_option( $this->options ); 
  2902.  
  2903. /** 
  2904. * @param $settings 
  2905. * @param $location 
  2906. * @param $current 
  2907. * @return mixed 
  2908. */ 
  2909. function filter_settings( $settings, $location, $current ) { 
  2910. if ( $location == null ) { 
  2911. $prefix = $this->prefix; 
  2912.  
  2913. foreach ( array( 'seopostcol', 'seocustptcol', 'debug_info', 'max_words_excerpt' ) as $opt ) { 
  2914. unset( $settings["{$prefix}$opt"] ); 
  2915.  
  2916. if ( ! class_exists( 'DOMDocument' ) ) { 
  2917. unset( $settings['{prefix}google_connect'] ); 
  2918. if ( AIOSEOPPRO ) { 
  2919. if ( ! empty( $this->options['aiosp_license_key'] ) ) { 
  2920. $settings['aiosp_license_key']['type'] = 'password'; 
  2921. $settings['aiosp_license_key']['size'] = 38; 
  2922. } elseif ( $location == 'aiosp' ) { 
  2923. global $post, $aioseop_sitemap; 
  2924. $prefix = $this->get_prefix( $location ) . $location . '_'; 
  2925. if ( ! empty( $post ) ) { 
  2926. $post_type = get_post_type( $post ); 
  2927. if ( ! empty( $this->options['aiosp_cpostnoindex'] ) && in_array( $post_type, $this->options['aiosp_cpostnoindex'] ) ) { 
  2928. $settings["{$prefix}noindex"]['type'] = 'select'; 
  2929. $settings["{$prefix}noindex"]['initial_options'] = array( 
  2930. '' => __( 'Default - noindex', 'all-in-one-seo-pack' ),  
  2931. 'off' => __( 'index', 'all-in-one-seo-pack' ),  
  2932. 'on' => __( 'noindex', 'all-in-one-seo-pack' ),  
  2933. ); 
  2934. if ( ! empty( $this->options['aiosp_cpostnofollow'] ) && in_array( $post_type, $this->options['aiosp_cpostnofollow'] ) ) { 
  2935. $settings["{$prefix}nofollow"]['type'] = 'select'; 
  2936. $settings["{$prefix}nofollow"]['initial_options'] = array( 
  2937. '' => __( 'Default - nofollow', 'all-in-one-seo-pack' ),  
  2938. 'off' => __( 'follow', 'all-in-one-seo-pack' ),  
  2939. 'on' => __( 'nofollow', 'all-in-one-seo-pack' ),  
  2940. ); 
  2941. if ( ! empty( $this->options['aiosp_cpostnoodp'] ) && in_array( $post_type, $this->options['aiosp_cpostnoodp'] ) ) { 
  2942. $settings["{$prefix}noodp"]['type'] = 'select'; 
  2943. $settings["{$prefix}noodp"]['initial_options'] = array( 
  2944. '' => __( 'Default - noodp', 'all-in-one-seo-pack' ),  
  2945. 'off' => __( 'odp', 'all-in-one-seo-pack' ),  
  2946. 'on' => __( 'noodp', 'all-in-one-seo-pack' ),  
  2947. ); 
  2948. if ( ! empty( $this->options['aiosp_cpostnoydir'] ) && in_array( $post_type, $this->options['aiosp_cpostnoydir'] ) ) { 
  2949. $settings["{$prefix}noydir"]['type'] = 'select'; 
  2950. $settings["{$prefix}noydir"]['initial_options'] = array( 
  2951. '' => __( 'Default - noydir', 'all-in-one-seo-pack' ),  
  2952. 'off' => __( 'ydir', 'all-in-one-seo-pack' ),  
  2953. 'on' => __( 'noydir', 'all-in-one-seo-pack' ),  
  2954. ); 
  2955. global $post; 
  2956. $info = $this->get_page_snippet_info(); 
  2957. extract( $info ); 
  2958. $settings["{$prefix}title"]['placeholder'] = $title; 
  2959. $settings["{$prefix}description"]['placeholder'] = $description; 
  2960. $settings["{$prefix}keywords"]['placeholder'] = $keywords; 
  2961.  
  2962. if ( ! AIOSEOPPRO ) { 
  2963. if ( ! current_user_can( 'update_plugins' ) ) { 
  2964. unset( $settings["{$prefix}upgrade"] ); 
  2965.  
  2966. if ( ! is_object( $aioseop_sitemap ) ) { 
  2967. unset( $settings['aiosp_sitemap_exclude'] ); 
  2968. if ( is_object( $post ) ) { 
  2969. if ( $post->post_type != 'page' ) { 
  2970. unset( $settings["{$prefix}titleatr"] ); 
  2971. unset( $settings["{$prefix}menulabel"] ); 
  2972. if ( ! empty( $this->options[ $this->prefix . 'togglekeywords' ] ) ) { 
  2973. unset( $settings["{$prefix}keywords"] ); 
  2974. unset( $settings["{$prefix}togglekeywords"] ); 
  2975. } elseif ( ! empty( $current["{$prefix}togglekeywords"] ) ) { 
  2976. unset( $settings["{$prefix}keywords"] ); 
  2977. if ( empty( $this->options['aiosp_can'] ) || empty( $this->options['aiosp_customize_canonical_links'] ) ) { 
  2978. unset( $settings["{$prefix}custom_link"] ); 
  2979.  
  2980. return $settings; 
  2981.  
  2982. /** 
  2983. * @param $options 
  2984. * @param $location 
  2985. * @return mixed 
  2986. */ 
  2987. function filter_options( $options, $location ) { 
  2988. if ( $location == 'aiosp' ) { 
  2989. global $post; 
  2990. if ( ! empty( $post ) ) { 
  2991. $prefix = $this->prefix; 
  2992. $post_type = get_post_type( $post ); 
  2993. foreach ( array( 'noindex', 'nofollow', 'noodp', 'noydir' ) as $no ) { 
  2994. if ( empty( $this->options[ 'aiosp_cpost' . $no ] ) || ( ! in_array( $post_type, $this->options[ 'aiosp_cpost' . $no ] ) ) ) { 
  2995. if ( isset( $options["{$prefix}{$no}"] ) && ( $options["{$prefix}{$no}"] != 'on' ) ) { 
  2996. unset( $options["{$prefix}{$no}"] ); 
  2997. if ( $location == null ) { 
  2998. $prefix = $this->prefix; 
  2999. if ( isset( $options["{$prefix}rewrite_titles"] ) && ( ! empty( $options["{$prefix}rewrite_titles"] ) ) ) { 
  3000. $options["{$prefix}rewrite_titles"] = 1; 
  3001. if ( isset( $options["{$prefix}enablecpost"] ) && ( $options["{$prefix}enablecpost"] === '' ) ) { 
  3002. $options["{$prefix}enablecpost"] = 0; 
  3003. if ( isset( $options["{$prefix}use_original_title"] ) && ( $options["{$prefix}use_original_title"] === '' ) ) { 
  3004. $options["{$prefix}use_original_title"] = 0; 
  3005.  
  3006. return $options; 
  3007.  
  3008. function template_redirect() { 
  3009. global $aioseop_options; 
  3010.  
  3011. $post = $this->get_queried_object(); 
  3012.  
  3013. if ( ! $this->is_page_included() ) { 
  3014. return; 
  3015.  
  3016. if ( ! empty( $aioseop_options['aiosp_rewrite_titles'] ) ) { 
  3017. $force_rewrites = 1; 
  3018. if ( isset( $aioseop_options['aiosp_force_rewrites'] ) ) { 
  3019. $force_rewrites = $aioseop_options['aiosp_force_rewrites']; 
  3020. if ( $force_rewrites ) { 
  3021. ob_start( array( $this, 'output_callback_for_title' ) ); 
  3022. } else { 
  3023. add_filter( 'wp_title', array( $this, 'wp_title' ), 20 ); 
  3024.  
  3025. /** 
  3026. * @return bool 
  3027. */ 
  3028. function is_page_included() { 
  3029. global $aioseop_options; 
  3030. if ( is_feed() ) { 
  3031. return false; 
  3032. if ( aioseop_mrt_exclude_this_page() ) { 
  3033. return false; 
  3034. $post = $this->get_queried_object(); 
  3035. $post_type = ''; 
  3036. if ( ! empty( $post ) && ! empty( $post->post_type ) ) { 
  3037. $post_type = $post->post_type; 
  3038. if ( empty( $aioseop_options['aiosp_enablecpost'] ) ) { 
  3039. $wp_post_types = get_post_types( array( '_builtin' => true ) ); // Don't display meta if SEO isn't enabled on custom post types -- pdb. 
  3040. if ( is_singular() && ! in_array( $post_type, $wp_post_types ) && ! is_front_page() ) { 
  3041. return false; 
  3042. } else { 
  3043. $wp_post_types = $aioseop_options['aiosp_cpostactive']; 
  3044. if ( empty( $wp_post_types ) ) { 
  3045. $wp_post_types = array(); 
  3046. if ( AIOSEOPPRO ) { 
  3047. if ( is_tax() ) { 
  3048. if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! is_tax( $aioseop_options['aiosp_taxactive'] ) ) { 
  3049. return false; 
  3050. } elseif ( is_category() ) { 
  3051. if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! in_array( 'category', $aioseop_options['aiosp_taxactive'] ) ) { 
  3052. return false; 
  3053. } elseif ( is_tag() ) { 
  3054. if ( empty( $aioseop_options['aiosp_taxactive'] ) || ! in_array( 'post_tag', $aioseop_options['aiosp_taxactive'] ) ) { 
  3055. return false; 
  3056. } else if ( ! in_array( $post_type, $wp_post_types ) && ! is_front_page() && ! is_post_type_archive( $wp_post_types ) && ! is_404() ) { 
  3057. return false; 
  3058. } else { 
  3059. if ( is_singular() && ! in_array( $post_type, $wp_post_types ) && ! is_front_page() ) { 
  3060. return false; 
  3061. if ( is_post_type_archive() && ! is_post_type_archive( $wp_post_types ) ) { 
  3062. return false; 
  3063.  
  3064. $this->meta_opts = $this->get_current_options( array(), 'aiosp' ); 
  3065.  
  3066. $aiosp_disable = $aiosp_disable_analytics = false; 
  3067.  
  3068. if ( ! empty( $this->meta_opts ) ) { 
  3069. if ( isset( $this->meta_opts['aiosp_disable'] ) ) { 
  3070. $aiosp_disable = $this->meta_opts['aiosp_disable']; 
  3071. if ( isset( $this->meta_opts['aiosp_disable_analytics'] ) ) { 
  3072. $aiosp_disable_analytics = $this->meta_opts['aiosp_disable_analytics']; 
  3073.  
  3074. if ( $aiosp_disable ) { 
  3075. if ( ! $aiosp_disable_analytics ) { 
  3076. if ( aioseop_option_isset( 'aiosp_google_analytics_id' ) ) { 
  3077. remove_action( 'aioseop_modules_wp_head', array( $this, 'aiosp_google_analytics' ) ); 
  3078. add_action( 'wp_head', array( $this, 'aiosp_google_analytics' ) ); 
  3079.  
  3080. return false; 
  3081.  
  3082. if ( ! empty( $this->meta_opts ) && $this->meta_opts['aiosp_disable'] == true ) { 
  3083. return false; 
  3084.  
  3085. return true; 
  3086.  
  3087. /** 
  3088. * @param $content 
  3089. * @return mixed|string 
  3090. */ 
  3091. function output_callback_for_title( $content ) { 
  3092. return $this->rewrite_title( $content ); 
  3093.  
  3094. /** 
  3095. * Used for forcing title rewrites. 
  3096. * @param $header 
  3097. * @return mixed|string 
  3098. */ 
  3099. function rewrite_title( $header ) { 
  3100. global $wp_query; 
  3101. if ( ! $wp_query ) { 
  3102. $header .= "<!-- no wp_query found! -->\n"; 
  3103.  
  3104. return $header; 
  3105. $title = $this->wp_title(); 
  3106. if ( ! empty( $title ) ) { 
  3107. $header = $this->replace_title( $header, $title ); 
  3108.  
  3109. return $header; 
  3110.  
  3111. /** 
  3112. * @param $content 
  3113. * @param $title 
  3114. * @return mixed 
  3115. */ 
  3116. function replace_title( $content, $title ) { 
  3117. // We can probably improve this... I'm not sure half of this is even being used. 
  3118. $title = trim( strip_tags( $title ) ); 
  3119. $title_tag_start = '<title'; 
  3120. $title_tag_end = '</title'; 
  3121. $start = $this->strpos( $content, $title_tag_start ); 
  3122. $end = $this->strpos( $content, $title_tag_end ); 
  3123. $this->title_start = $start; 
  3124. $this->title_end = $end; 
  3125. $this->orig_title = $title; 
  3126.  
  3127. return preg_replace( '/<title([^>]*?)\s*>([^<]*?)<\/title\s*>/is', '<title\\1>' . preg_replace( '/(\$|\\\\)(?=\d)/', '\\\\\1', strip_tags( $title ) ) . '</title>', $content, 1 ); 
  3128.  
  3129. function add_hooks() { 
  3130. global $aioseop_options, $aioseop_update_checker; 
  3131.  
  3132. // MOVED TO MAIN PLUGIN FILE IN ORDER TO FIRE SOONS 
  3133. //$role = get_role( 'administrator' ); 
  3134. //if ( is_object( $role ) ) { 
  3135. // $role->add_cap( 'aiosp_manage_seo' ); 
  3136. //} 
  3137.  
  3138. aioseop_update_settings_check(); 
  3139. add_filter( 'user_contactmethods', 'aioseop_add_contactmethods' ); 
  3140. if ( is_user_logged_in() && function_exists( 'is_admin_bar_showing' ) && is_admin_bar_showing() && current_user_can( 'aiosp_manage_seo' ) ) { 
  3141. add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 1000 ); 
  3142.  
  3143. if ( is_admin() ) { 
  3144. add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 
  3145. add_action( 'admin_head', array( $this, 'add_page_icon' ) ); 
  3146. add_action( 'admin_init', 'aioseop_addmycolumns', 1 ); 
  3147. add_action( 'admin_init', 'aioseop_handle_ignore_notice' ); 
  3148. if ( AIOSEOPPRO ) { 
  3149. if ( current_user_can( 'update_plugins' ) ) { 
  3150. add_action( 'admin_notices', array( $aioseop_update_checker, 'key_warning' ) ); 
  3151. add_action( 'after_plugin_row_' . AIOSEOP_PLUGIN_BASENAME, array( 
  3152. $aioseop_update_checker,  
  3153. 'add_plugin_row',  
  3154. ) ); 
  3155. } else { 
  3156. if ( $aioseop_options['aiosp_can'] == '1' || $aioseop_options['aiosp_can'] == 'on' ) { 
  3157. remove_action( 'wp_head', 'rel_canonical' ); 
  3158. // Analytics. 
  3159. if ( aioseop_option_isset( 'aiosp_google_analytics_id' ) ) { 
  3160. add_action( 'aioseop_modules_wp_head', array( $this, 'aiosp_google_analytics' ) ); 
  3161. add_filter( 'wp_list_pages', 'aioseop_list_pages' ); 
  3162. add_action( 'wp_head', array( $this, 'wp_head' ), apply_filters( 'aioseop_wp_head_priority', 1 ) ); 
  3163. add_action( 'template_redirect', array( $this, 'template_redirect' ), 0 ); 
  3164. add_filter( 'wp_list_pages_excludes', 'aioseop_get_pages_start' ); 
  3165. add_filter( 'get_pages', 'aioseop_get_pages' ); 
  3166.  
  3167. function visibility_warning() { 
  3168.  
  3169. $aioseop_visibility_notice_dismissed = get_user_meta( get_current_user_id(), 'aioseop_visibility_notice_dismissed', true ); 
  3170.  
  3171. if ( '0' == get_option( 'blog_public' ) && empty( $aioseop_visibility_notice_dismissed ) ) { 
  3172.  
  3173. printf( ' 
  3174. <div id="message" class="error notice is-dismissible aioseop-notice visibility-notice"> 
  3175. <p> 
  3176. <strong>%1$s</strong> 
  3177. %2$s 
  3178.  
  3179. </p> 
  3180. </div>',  
  3181. __( 'Warning: You\'re blocking access to search engines.', 'all-in-one-seo-pack' ),  
  3182. sprintf( __( 'You can %s click here%s to go to your reading settings and toggle your blog visibility.', 'all-in-one-seo-pack' ), sprintf( '<a href="%s">', esc_url( admin_url( 'options-reading.php' ) ) ), '</a>' ) ); 
  3183.  
  3184. } elseif ( '1' == get_option( 'blog_public' ) && ! empty( $aioseop_visibility_notice_dismissed ) ) { 
  3185. delete_user_meta( get_current_user_id(), 'aioseop_visibility_notice_dismissed' ); 
  3186.  
  3187. function woo_upgrade_notice() { 
  3188.  
  3189. $aioseop_woo_upgrade_notice_dismissed = get_user_meta( get_current_user_id(), 'aioseop_woo_upgrade_notice_dismissed', true ); 
  3190.  
  3191. if ( class_exists( 'WooCommerce' ) && empty( $aioseop_woo_upgrade_notice_dismissed ) && current_user_can( 'manage_options' ) ) { 
  3192.  
  3193. printf( ' 
  3194. <div id="message" class="notice-info notice is-dismissible aioseop-notice woo-upgrade-notice"> 
  3195. <p> 
  3196. <strong>%1$s</strong> 
  3197. %2$s 
  3198.  
  3199. </p> 
  3200. </div>',  
  3201. __( 'We\'ve detected you\'re running WooCommerce.', 'all-in-one-seo-pack' ),  
  3202. sprintf( __( '%s Upgrade%s to All in One SEO Pack Pro for increased SEO compatibility for your products.', 'all-in-one-seo-pack' ), sprintf( '<a target="_blank" href="%s">', esc_url( 'http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=woo' ) ), '</a>' ) ); 
  3203.  
  3204. } elseif ( ! class_exists( 'WooCommerce' ) && ! empty( $aioseop_woo_upgrade_notice_dismissed ) ) { 
  3205. delete_user_meta( get_current_user_id(), 'aioseop_woo_upgrade_notice_dismissed' ); 
  3206.  
  3207. /** 
  3208. * @param $description 
  3209. * @return string 
  3210. */ 
  3211. function make_unique_att_desc( $description ) { 
  3212. global $wp_query; 
  3213. if ( is_attachment() ) { 
  3214.  
  3215. $url = $this->aiosp_mrt_get_url( $wp_query ); 
  3216. if ( $url ) { 
  3217. $matches = array(); 
  3218. preg_match_all( '/(\d+)/', $url, $matches ); 
  3219. if ( is_array( $matches ) ) { 
  3220. $uniqueDesc = join( '', $matches[0] ); 
  3221. $description .= ' ' . $uniqueDesc; 
  3222.  
  3223. return $description; 
  3224.  
  3225. function wp_head() { 
  3226. if ( ! $this->is_page_included() ) { 
  3227. return; 
  3228. $opts = $this->meta_opts; 
  3229. global $aioseop_update_checker, $wp_query, $aioseop_options, $posts; 
  3230. static $aioseop_dup_counter = 0; 
  3231. $aioseop_dup_counter ++; 
  3232. if ( $aioseop_dup_counter > 1 ) { 
  3233. echo "\n<!-- " . sprintf( __( 'Debug Warning: All in One SEO Pack meta data was included again from %s filter. Called %s times!', 'all-in-one-seo-pack' ), current_filter(), $aioseop_dup_counter ) . " -->\n"; 
  3234.  
  3235. return; 
  3236. if ( is_home() && ! is_front_page() ) { 
  3237. $post = aiosp_common::get_blog_page(); 
  3238. } else { 
  3239. $post = $this->get_queried_object(); 
  3240. $meta_string = null; 
  3241. $description = ''; 
  3242. // Logging - rewrite handler check for output buffering. 
  3243. $this->check_rewrite_handler(); 
  3244. if ( AIOSEOPPRO ) { 
  3245. echo "\n<!-- All in One SEO Pack Pro $this->version by Michael Torbert of Semper Fi Web Design"; 
  3246. } else { 
  3247. echo "\n<!-- All in One SEO Pack $this->version by Michael Torbert of Semper Fi Web Design"; 
  3248. if ( $this->ob_start_detected ) { 
  3249. echo 'ob_start_detected '; 
  3250. echo "[$this->title_start, $this->title_end] "; 
  3251. echo "-->\n"; 
  3252. if ( AIOSEOPPRO ) { 
  3253. echo '<!-- ' . __( 'Debug String', 'all-in-one-seo-pack' ) . ': ' . $aioseop_update_checker->get_verification_code() . " -->\n"; 
  3254. $blog_page = aiosp_common::get_blog_page( $post ); 
  3255. $save_posts = $posts; 
  3256. if ( function_exists( 'woocommerce_get_page_id' ) && is_post_type_archive( 'product' ) && ( $post_id = woocommerce_get_page_id( 'shop' ) ) && ( $post = get_post( $post_id ) ) ) { 
  3257. global $posts; 
  3258. $opts = $this->meta_opts = $this->get_current_options( array(), 'aiosp', null, $post ); 
  3259. $posts = array(); 
  3260. $posts[] = $post; 
  3261. $posts = $save_posts; 
  3262. $description = apply_filters( 'aioseop_description', $this->get_main_description( $post ) ); // Get the description. 
  3263. // Handle the description format. 
  3264. if ( isset( $description ) && ( $this->strlen( $description ) > $this->minimum_description_length ) && ! ( is_front_page() && is_paged() ) ) { 
  3265. $description = $this->trim_description( $description ); 
  3266. if ( ! isset( $meta_string ) ) { 
  3267. $meta_string = ''; 
  3268. // Description format. 
  3269. $description = apply_filters( 'aioseop_description_full', $this->apply_description_format( $description, $post ) ); 
  3270. $desc_attr = ''; 
  3271. if ( ! empty( $aioseop_options['aiosp_schema_markup'] ) ) { 
  3272. $desc_attr = ''; 
  3273. $desc_attr = apply_filters( 'aioseop_description_attributes', $desc_attr ); 
  3274. $meta_string .= sprintf( "<meta name=\"description\" %s content=\"%s\" />\n", $desc_attr, $description ); 
  3275. // Get the keywords. 
  3276. $togglekeywords = 0; 
  3277. if ( isset( $aioseop_options['aiosp_togglekeywords'] ) ) { 
  3278. $togglekeywords = $aioseop_options['aiosp_togglekeywords']; 
  3279. if ( $togglekeywords == 0 && ! ( is_front_page() && is_paged() ) ) { 
  3280. $keywords = $this->get_main_keywords(); 
  3281. $keywords = $this->apply_cf_fields( $keywords ); 
  3282. $keywords = apply_filters( 'aioseop_keywords', $keywords ); 
  3283.  
  3284. if ( isset( $keywords ) && ! empty( $keywords ) ) { 
  3285. if ( isset( $meta_string ) ) { 
  3286. $meta_string .= "\n"; 
  3287. $keywords = wp_filter_nohtml_kses( str_replace( '"', '', $keywords ) ); 
  3288. $key_attr = ''; 
  3289. if ( ! empty( $aioseop_options['aiosp_schema_markup'] ) ) { 
  3290. $key_attr = 'itemprop="keywords"'; 
  3291. $key_attr = apply_filters( 'aioseop_keywords_attributes', $key_attr ); 
  3292. $meta_string .= sprintf( "<meta name=\"keywords\" %s content=\"%s\" />\n", $key_attr, $keywords ); 
  3293. // Handle noindex, nofollow - robots meta. 
  3294. $robots_meta = apply_filters( 'aioseop_robots_meta', $this->get_robots_meta() ); 
  3295. if ( ! empty( $robots_meta ) ) { 
  3296. $meta_string .= '<meta name="robots" content="' . esc_attr( $robots_meta ) . '" />' . "\n"; 
  3297. // Handle site verification. 
  3298. if ( is_front_page() ) { 
  3299. foreach ( 
  3300. array( 
  3301. 'google' => 'google-site-verification',  
  3302. 'bing' => 'msvalidate.01',  
  3303. 'pinterest' => 'p:domain_verify',  
  3304. ) as $k => $v 
  3305. ) { 
  3306. if ( ! empty( $aioseop_options["aiosp_{$k}_verify"] ) ) { 
  3307. $meta_string .= '<meta name="' . $v . '" content="' . trim( strip_tags( $aioseop_options["aiosp_{$k}_verify"] ) ) . '" />' . "\n"; 
  3308.  
  3309. // Sitelinks search. 
  3310. if ( ! empty( $aioseop_options['aiosp_google_sitelinks_search'] ) || ! empty( $aioseop_options['aiosp_google_set_site_name'] ) ) { 
  3311. $meta_string .= $this->sitelinks_search_box() . "\n"; 
  3312. // Handle extra meta fields. 
  3313. foreach ( array( 'page_meta', 'post_meta', 'home_meta', 'front_meta' ) as $meta ) { 
  3314. if ( ! empty( $aioseop_options["aiosp_{$meta}_tags"] ) ) { 
  3315. $$meta = html_entity_decode( stripslashes( $aioseop_options["aiosp_{$meta}_tags"] ), ENT_QUOTES ); 
  3316. } else { 
  3317. $$meta = ''; 
  3318. if ( is_page() && isset( $page_meta ) && ! empty( $page_meta ) && ( ! is_front_page() || empty( $front_meta ) ) ) { 
  3319. if ( isset( $meta_string ) ) { 
  3320. $meta_string .= "\n"; 
  3321. $meta_string .= $page_meta; 
  3322. if ( is_single() && isset( $post_meta ) && ! empty( $post_meta ) ) { 
  3323. if ( isset( $meta_string ) ) { 
  3324. $meta_string .= "\n"; 
  3325. $meta_string .= $post_meta; 
  3326. // Handle authorship. 
  3327. $authorship = $this->get_google_authorship( $post ); 
  3328. $publisher = apply_filters( 'aioseop_google_publisher', $authorship['publisher'] ); 
  3329. if ( ! empty( $publisher ) ) { 
  3330. $meta_string = '<link rel="publisher" href="' . esc_url( $publisher ) . '" />' . "\n" . $meta_string; 
  3331. $author = apply_filters( 'aioseop_google_author', $authorship['author'] ); 
  3332. if ( ! empty( $author ) ) { 
  3333. $meta_string = '<link rel="author" href="' . esc_url( $author ) . '" />' . "\n" . $meta_string; 
  3334.  
  3335. if ( is_front_page() && ! empty( $front_meta ) ) { 
  3336. if ( isset( $meta_string ) ) { 
  3337. $meta_string .= "\n"; 
  3338. $meta_string .= $front_meta; 
  3339. } else { 
  3340. if ( is_home() && ! empty( $home_meta ) ) { 
  3341. if ( isset( $meta_string ) ) { 
  3342. $meta_string .= "\n"; 
  3343. $meta_string .= $home_meta; 
  3344. $prev_next = $this->get_prev_next_links( $post ); 
  3345. $prev = apply_filters( 'aioseop_prev_link', $prev_next['prev'] ); 
  3346. $next = apply_filters( 'aioseop_next_link', $prev_next['next'] ); 
  3347. if ( ! empty( $prev ) ) { 
  3348. $meta_string .= "<link rel='prev' href='" . esc_url( $prev ) . "' />\n"; 
  3349. if ( ! empty( $next ) ) { 
  3350. $meta_string .= "<link rel='next' href='" . esc_url( $next ) . "' />\n"; 
  3351. if ( $meta_string != null ) { 
  3352. echo "$meta_string\n"; 
  3353.  
  3354. // Handle canonical links. 
  3355. $show_page = true; 
  3356. if ( ! empty( $aioseop_options['aiosp_no_paged_canonical_links'] ) ) { 
  3357. $show_page = false; 
  3358.  
  3359. if ( $aioseop_options['aiosp_can'] ) { 
  3360. $url = ''; 
  3361. if ( ! empty( $aioseop_options['aiosp_customize_canonical_links'] ) && ! empty( $opts['aiosp_custom_link'] ) ) { 
  3362. $url = $opts['aiosp_custom_link']; 
  3363. if ( empty( $url ) ) { 
  3364. $url = $this->aiosp_mrt_get_url( $wp_query, $show_page ); 
  3365.  
  3366. $url = $this->validate_url_scheme( $url ); 
  3367.  
  3368. $url = apply_filters( 'aioseop_canonical_url', $url ); 
  3369. if ( ! empty( $url ) ) { 
  3370. echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n"; 
  3371. do_action( 'aioseop_modules_wp_head' ); 
  3372. if ( AIOSEOPPRO ) { 
  3373. echo "<!-- /all in one seo pack pro -->\n"; 
  3374. } else { 
  3375. echo "<!-- /all in one seo pack -->\n"; 
  3376.  
  3377. /** 
  3378. * Check rewrite handler. 
  3379. */ 
  3380. function check_rewrite_handler() { 
  3381. global $aioseop_options; 
  3382.  
  3383. $force_rewrites = 1; 
  3384. if ( isset( $aioseop_options['aiosp_force_rewrites'] ) ) { 
  3385. $force_rewrites = $aioseop_options['aiosp_force_rewrites']; 
  3386.  
  3387. if ( ! empty( $aioseop_options['aiosp_rewrite_titles'] ) && $force_rewrites ) { 
  3388. // Make the title rewrite as short as possible. 
  3389. if ( function_exists( 'ob_list_handlers' ) ) { 
  3390. $active_handlers = ob_list_handlers(); 
  3391. } else { 
  3392. $active_handlers = array(); 
  3393. if ( sizeof( $active_handlers ) > 0 && 
  3394. $this->strtolower( $active_handlers[ sizeof( $active_handlers ) - 1 ] ) == 
  3395. $this->strtolower( 'All_in_One_SEO_Pack::output_callback_for_title' ) 
  3396. ) { 
  3397. ob_end_flush(); 
  3398. } else { 
  3399. $this->log( 'another plugin interfering?' ); 
  3400. // If we get here there *could* be trouble with another plugin :(. 
  3401. $this->ob_start_detected = true; 
  3402. if ( $this->option_isset( 'rewrite_titles' ) ) { // Try alternate method -- pdb. 
  3403. $aioseop_options['aiosp_rewrite_titles'] = 0; 
  3404. $force_rewrites = 0; 
  3405. add_filter( 'wp_title', array( $this, 'wp_title' ), 20 ); 
  3406. if ( function_exists( 'ob_list_handlers' ) ) { 
  3407. foreach ( ob_list_handlers() as $handler ) { 
  3408. $this->log( "detected output handler $handler" ); 
  3409.  
  3410. /** 
  3411. * @param $description 
  3412. * @return mixed|string 
  3413. */ 
  3414. function trim_description( $description ) { 
  3415. $description = trim( wp_strip_all_tags( $description ) ); 
  3416. $description = str_replace( '"', '"', $description ); 
  3417. $description = str_replace( "\r\n", ' ', $description ); 
  3418. $description = str_replace( "\n", ' ', $description ); 
  3419.  
  3420. return $description; 
  3421.  
  3422. /** 
  3423. * @param $description 
  3424. * @param null $post 
  3425. * @return mixed 
  3426. */ 
  3427. function apply_description_format( $description, $post = null ) { 
  3428. global $aioseop_options; 
  3429. $description_format = $aioseop_options['aiosp_description_format']; 
  3430. if ( ! isset( $description_format ) || empty( $description_format ) ) { 
  3431. $description_format = '%description%'; 
  3432. $description = str_replace( '%description%', apply_filters( 'aioseop_description_override', $description ), $description_format ); 
  3433. if ( strpos( $description, '%blog_title%' ) !== false ) { 
  3434. $description = str_replace( '%blog_title%', get_bloginfo( 'name' ), $description ); 
  3435. if ( strpos( $description, '%blog_description%' ) !== false ) { 
  3436. $description = str_replace( '%blog_description%', get_bloginfo( 'description' ), $description ); 
  3437. if ( strpos( $description, '%wp_title%' ) !== false ) { 
  3438. $description = str_replace( '%wp_title%', $this->get_original_title(), $description ); 
  3439. if ( strpos( $description, '%post_title%' ) !== false ) { 
  3440. $description = str_replace( '%post_title%', $this->get_aioseop_title( $post ), $description ); 
  3441.  
  3442.  
  3443. /**this was intended to make attachment descriptions unique if pulling from the parent... let's remove it and see if there are any problems 
  3444. *on the roadmap is to have a better hierarchy for attachment description pulling 
  3445. * if ($aioseop_options['aiosp_can']) $description = $this->make_unique_att_desc($description); 
  3446. */ 
  3447.  
  3448. return $description; 
  3449.  
  3450. /** 
  3451. * @return string 
  3452. */ 
  3453. function get_robots_meta() { 
  3454. global $aioseop_options; 
  3455. $opts = $this->meta_opts; 
  3456. $page = $this->get_page_number(); 
  3457. $robots_meta = $tax_noindex = ''; 
  3458. if ( isset( $aioseop_options['aiosp_tax_noindex'] ) ) { 
  3459. $tax_noindex = $aioseop_options['aiosp_tax_noindex']; 
  3460.  
  3461. if ( empty( $tax_noindex ) || ! is_array( $tax_noindex ) ) { 
  3462. $tax_noindex = array(); 
  3463.  
  3464. $aiosp_noindex = $aiosp_nofollow = $aiosp_noodp = $aiosp_noydir = ''; 
  3465. $noindex = 'index'; 
  3466. $nofollow = 'follow'; 
  3467. if ( ( is_category() && ! empty( $aioseop_options['aiosp_category_noindex'] ) ) || ( ! is_category() && is_archive() && ! is_tag() && ! is_tax() 
  3468. && ( ( is_date() && ! empty( $aioseop_options['aiosp_archive_date_noindex'] ) ) || ( is_author() && ! empty( $aioseop_options['aiosp_archive_author_noindex'] ) ) ) ) 
  3469. || ( is_tag() && ! empty( $aioseop_options['aiosp_tags_noindex'] ) ) 
  3470. || ( is_search() && ! empty( $aioseop_options['aiosp_search_noindex'] ) ) 
  3471. || ( is_404() && ! empty( $aioseop_options['aiosp_404_noindex'] ) ) 
  3472. || ( is_tax() && in_array( get_query_var( 'taxonomy' ), $tax_noindex ) ) 
  3473. ) { 
  3474. $noindex = 'noindex'; 
  3475. } elseif ( is_single() || is_page() || $this->is_static_posts_page() || is_attachment() || is_category() || is_tag() || is_tax() || ( $page > 1 ) ) { 
  3476. $post_type = get_post_type(); 
  3477. if ( ! empty( $opts ) ) { 
  3478. $aiosp_noindex = htmlspecialchars( stripslashes( $opts['aiosp_noindex'] ) ); 
  3479. $aiosp_nofollow = htmlspecialchars( stripslashes( $opts['aiosp_nofollow'] ) ); 
  3480. $aiosp_noodp = htmlspecialchars( stripslashes( $opts['aiosp_noodp'] ) ); 
  3481. $aiosp_noydir = htmlspecialchars( stripslashes( $opts['aiosp_noydir'] ) ); 
  3482. if ( $aiosp_noindex || $aiosp_nofollow || $aiosp_noodp || $aiosp_noydir || ! empty( $aioseop_options['aiosp_cpostnoindex'] ) 
  3483. || ! empty( $aioseop_options['aiosp_cpostnofollow'] ) || ! empty( $aioseop_options['aiosp_cpostnoodp'] ) || ! empty( $aioseop_options['aiosp_cpostnoydir'] ) 
  3484. || ! empty( $aioseop_options['aiosp_paginated_noindex'] ) || ! empty( $aioseop_options['aiosp_paginated_nofollow'] ) 
  3485. ) { 
  3486. if ( ( $aiosp_noindex == 'on' ) || ( ( ! empty( $aioseop_options['aiosp_paginated_noindex'] ) ) && $page > 1 ) || 
  3487. ( ( $aiosp_noindex == '' ) && ( ! empty( $aioseop_options['aiosp_cpostnoindex'] ) ) && in_array( $post_type, $aioseop_options['aiosp_cpostnoindex'] ) ) 
  3488. ) { 
  3489. $noindex = 'noindex'; 
  3490. if ( ( $aiosp_nofollow == 'on' ) || ( ( ! empty( $aioseop_options['aiosp_paginated_nofollow'] ) ) && $page > 1 ) || 
  3491. ( ( $aiosp_nofollow == '' ) && ( ! empty( $aioseop_options['aiosp_cpostnofollow'] ) ) && in_array( $post_type, $aioseop_options['aiosp_cpostnofollow'] ) ) 
  3492. ) { 
  3493. $nofollow = 'nofollow'; 
  3494. if ( ( $aiosp_noodp == 'on' ) || ( empty( $aiosp_noodp ) && ( ! empty( $aioseop_options['aiosp_cpostnoodp'] ) && in_array( $post_type, $aioseop_options['aiosp_cpostnoodp'] ) ) ) ) { 
  3495. $aiosp_noodp = true; 
  3496. } else { 
  3497. $aiosp_noodp = false; 
  3498. if ( ( $aiosp_noydir == 'on' ) || ( empty( $aiosp_noydir ) && ( ! empty( $aioseop_options['aiosp_cpostnoydir'] ) && in_array( $post_type, $aioseop_options['aiosp_cpostnoydir'] ) ) ) ) { 
  3499. $aiosp_noydir = true; 
  3500. } else { 
  3501. $aiosp_noydir = false; 
  3502. if ( ! empty( $aioseop_options['aiosp_noodp'] ) && $aioseop_options['aiosp_noodp'] ) { 
  3503. $aiosp_noodp = true; 
  3504. if ( ! empty( $aioseop_options['aiosp_noydir'] ) && $aioseop_options['aiosp_noydir'] ) { 
  3505. $aiosp_noydir = true; 
  3506. if ( $aiosp_noodp ) { 
  3507. $nofollow .= ', noodp'; 
  3508. if ( $aiosp_noydir ) { 
  3509. $nofollow .= ', noydir'; 
  3510. $robots_meta = $noindex . ', ' . $nofollow; 
  3511. if ( $robots_meta == 'index, follow' ) { 
  3512. $robots_meta = ''; 
  3513.  
  3514. return $robots_meta; 
  3515.  
  3516. /** 
  3517. * @return mixed|void 
  3518. */ 
  3519. function sitelinks_search_box() { 
  3520. global $aioseop_options; 
  3521. $home_url = esc_url( get_home_url() ); 
  3522. $name_block = $search_block = ''; 
  3523. if ( ! empty( $aioseop_options['aiosp_google_set_site_name'] ) ) { 
  3524. if ( ! empty( $aioseop_options['aiosp_google_specify_site_name'] ) ) { 
  3525. $blog_name = $aioseop_options['aiosp_google_specify_site_name']; 
  3526. } else { 
  3527. $blog_name = get_bloginfo( 'name' ); 
  3528. $blog_name = esc_attr( $blog_name ); 
  3529. $name_block = <<<EOF 
  3530. "name": "{$blog_name}",  
  3531. EOF; 
  3532.  
  3533. if ( ! empty( $aioseop_options['aiosp_google_sitelinks_search'] ) ) { 
  3534. $search_block = <<<EOF 
  3535. "potentialAction": { 
  3536. "@type": "SearchAction",  
  3537. "target": "{$home_url}/?s={search_term}",  
  3538. "query-input": "required name=search_term" 
  3539. },  
  3540. EOF; 
  3541.  
  3542. $search_box = <<<EOF 
  3543. <script type="application/ld+json"> 
  3544. "@context": "http://schema.org",  
  3545. "@type": "WebSite",  
  3546. EOF; 
  3547. if ( ! empty( $name_block ) ) { 
  3548. $search_box .= $name_block; 
  3549. if ( ! empty( $search_block ) ) { 
  3550. $search_box .= $search_block; 
  3551. $search_box .= <<<EOF 
  3552. "url": "{$home_url}/" 
  3553. </script> 
  3554. EOF; 
  3555.  
  3556. return apply_filters( 'aiosp_sitelinks_search_box', $search_box ); 
  3557.  
  3558. /** 
  3559. * @param $post 
  3560. * @return array 
  3561. */ 
  3562. function get_google_authorship( $post ) { 
  3563. global $aioseop_options; 
  3564. $page = $this->get_page_number(); 
  3565. // Handle authorship. 
  3566. $googleplus = $publisher = $author = ''; 
  3567.  
  3568. if ( ! empty( $post ) && isset( $post->post_author ) && empty( $aioseop_options['aiosp_google_disable_profile'] ) ) { 
  3569. $googleplus = get_the_author_meta( 'googleplus', $post->post_author ); 
  3570.  
  3571. if ( empty( $googleplus ) && ! empty( $aioseop_options['aiosp_google_publisher'] ) ) { 
  3572. $googleplus = $aioseop_options['aiosp_google_publisher']; 
  3573.  
  3574. if ( is_front_page() && ( $page < 2 ) ) { 
  3575. if ( ! empty( $aioseop_options['aiosp_google_publisher'] ) ) { 
  3576. $publisher = $aioseop_options['aiosp_google_publisher']; 
  3577.  
  3578. if ( ! empty( $aioseop_options['aiosp_google_author_advanced'] ) ) { 
  3579. if ( empty( $aioseop_options['aiosp_google_enable_publisher'] ) ) { 
  3580. $publisher = ''; 
  3581. } elseif ( ! empty( $aioseop_options['aiosp_google_specify_publisher'] ) ) { 
  3582. $publisher = $aioseop_options['aiosp_google_specify_publisher']; 
  3583. if ( is_singular() && ( ! empty( $googleplus ) ) ) { 
  3584. $author = $googleplus; 
  3585. } else if ( ! empty( $aioseop_options['aiosp_google_publisher'] ) ) { 
  3586. $author = $aioseop_options['aiosp_google_publisher']; 
  3587.  
  3588. if ( ! empty( $aioseop_options['aiosp_google_author_advanced'] ) && isset( $aioseop_options['aiosp_google_author_location'] ) ) { 
  3589. if ( empty( $aioseop_options['aiosp_google_author_location'] ) ) { 
  3590. $aioseop_options['aiosp_google_author_location'] = array(); 
  3591. if ( is_front_page() && ! in_array( 'front', $aioseop_options['aiosp_google_author_location'] ) ) { 
  3592. $author = ''; 
  3593. } else { 
  3594. if ( in_array( 'all', $aioseop_options['aiosp_google_author_location'] ) ) { 
  3595. if ( is_singular() && ! is_singular( $aioseop_options['aiosp_google_author_location'] ) ) { 
  3596. $author = ''; 
  3597. } else { 
  3598. if ( ! is_singular( $aioseop_options['aiosp_google_author_location'] ) ) { 
  3599. $author = ''; 
  3600.  
  3601. return array( 'publisher' => $publisher, 'author' => $author ); 
  3602.  
  3603. /** 
  3604. * @param null $post 
  3605. * @return array 
  3606. */ 
  3607. function get_prev_next_links( $post = null ) { 
  3608. $prev = $next = ''; 
  3609. $page = $this->get_page_number(); 
  3610. if ( is_home() || is_archive() || is_paged() ) { 
  3611. global $wp_query; 
  3612. $max_page = $wp_query->max_num_pages; 
  3613. if ( $page > 1 ) { 
  3614. $prev = get_previous_posts_page_link(); 
  3615. if ( $page < $max_page ) { 
  3616. $paged = $GLOBALS['paged']; 
  3617. if ( ! is_single() ) { 
  3618. if ( ! $paged ) { 
  3619. $paged = 1; 
  3620. $nextpage = intval( $paged ) + 1; 
  3621. if ( ! $max_page || $max_page >= $nextpage ) { 
  3622. $next = get_pagenum_link( $nextpage ); 
  3623. } else if ( is_page() || is_single() ) { 
  3624. $numpages = 1; 
  3625. $multipage = 0; 
  3626. $page = get_query_var( 'page' ); 
  3627. if ( ! $page ) { 
  3628. $page = 1; 
  3629. if ( is_single() || is_page() || is_feed() ) { 
  3630. $more = 1; 
  3631. $content = $post->post_content; 
  3632. if ( false !== strpos( $content, '<!--nextpage-->' ) ) { 
  3633. if ( $page > 1 ) { 
  3634. $more = 1; 
  3635. $content = str_replace( "\n<!--nextpage-->\n", '<!--nextpage-->', $content ); 
  3636. $content = str_replace( "\n<!--nextpage-->", '<!--nextpage-->', $content ); 
  3637. $content = str_replace( "<!--nextpage-->\n", '<!--nextpage-->', $content ); 
  3638. // Ignore nextpage at the beginning of the content. 
  3639. if ( 0 === strpos( $content, '<!--nextpage-->' ) ) { 
  3640. $content = substr( $content, 15 ); 
  3641. $pages = explode( '<!--nextpage-->', $content ); 
  3642. $numpages = count( $pages ); 
  3643. if ( $numpages > 1 ) { 
  3644. $multipage = 1; 
  3645. if ( ! empty( $page ) ) { 
  3646. if ( $page > 1 ) { 
  3647. $prev = _wp_link_page( $page - 1 ); 
  3648. if ( $page + 1 <= $numpages ) { 
  3649. $next = _wp_link_page( $page + 1 ); 
  3650. if ( ! empty( $prev ) ) { 
  3651. $prev = $this->substr( $prev, 9, - 2 ); 
  3652. if ( ! empty( $next ) ) { 
  3653. $next = $this->substr( $next, 9, - 2 ); 
  3654.  
  3655. return array( 'prev' => $prev, 'next' => $next ); 
  3656.  
  3657. /** 
  3658. * Validates whether the url should be https or http. 
  3659. * Mainly we're just using this for canonical URLS, but eventually it may be useful for other things 
  3660. * @param $url 
  3661. * @return string $url 
  3662. * @since 2.3.5 
  3663. */ 
  3664. function validate_url_scheme( $url ) { 
  3665.  
  3666. // TODO we should check for the site setting in the case of auto. 
  3667.  
  3668. global $aioseop_options; 
  3669.  
  3670. if( ! isset( $aioseop_options['aiosp_can_set_protocol'] ) ) { 
  3671. return $url; // Just send the url back if there's nothing there. 
  3672.  
  3673. if ( $aioseop_options['aiosp_can_set_protocol'] == 'http' ) { 
  3674. $url = preg_replace( '/^https:/i', 'http:', $url ); 
  3675. if ( $aioseop_options['aiosp_can_set_protocol'] == 'https' ) { 
  3676. $url = preg_replace( '/^http:/i', 'https:', $url ); 
  3677.  
  3678. return $url; 
  3679.  
  3680. /** 
  3681. * @param $options 
  3682. * @param $location 
  3683. * @param $settings 
  3684. * @return mixed 
  3685. */ 
  3686. function override_options( $options, $location, $settings ) { 
  3687. if ( class_exists( 'DOMDocument' ) ) { 
  3688. $options['aiosp_google_connect'] = $settings['aiosp_google_connect']['default']; 
  3689.  
  3690. return $options; 
  3691.  
  3692. function aiosp_google_analytics() { 
  3693. new aioseop_google_analytics; 
  3694.  
  3695. /** 
  3696. * @param $id 
  3697. * @return bool 
  3698. */ 
  3699. function save_post_data( $id ) { 
  3700. $awmp_edit = $nonce = null; 
  3701. if ( empty( $_POST ) ) { 
  3702. return false; 
  3703. if ( isset( $_POST['aiosp_edit'] ) ) { 
  3704. $awmp_edit = $_POST['aiosp_edit']; 
  3705. if ( isset( $_POST['nonce-aioseop-edit'] ) ) { 
  3706. $nonce = $_POST['nonce-aioseop-edit']; 
  3707.  
  3708. if ( isset( $awmp_edit ) && ! empty( $awmp_edit ) && wp_verify_nonce( $nonce, 'edit-aioseop-nonce' ) ) { 
  3709.  
  3710. $optlist = array( 
  3711. 'keywords',  
  3712. 'description',  
  3713. 'title',  
  3714. 'custom_link',  
  3715. 'sitemap_exclude',  
  3716. 'disable',  
  3717. 'disable_analytics',  
  3718. 'noindex',  
  3719. 'nofollow',  
  3720. 'noodp',  
  3721. 'noydir',  
  3722. 'titleatr',  
  3723. 'menulabel',  
  3724. ); 
  3725. if ( ! ( ! empty( $this->options['aiosp_can'] ) ) && ( ! empty( $this->options['aiosp_customize_canonical_links'] ) ) ) { 
  3726. unset( $optlist['custom_link'] ); 
  3727. foreach ( $optlist as $f ) { 
  3728. $field = "aiosp_$f"; 
  3729. if ( isset( $_POST[ $field ] ) ) { 
  3730. $$field = $_POST[ $field ]; 
  3731.  
  3732. $optlist = array( 
  3733. 'keywords',  
  3734. 'description',  
  3735. 'title',  
  3736. 'custom_link',  
  3737. 'noindex',  
  3738. 'nofollow',  
  3739. 'noodp',  
  3740. 'noydir',  
  3741. 'titleatr',  
  3742. 'menulabel',  
  3743. ); 
  3744. if ( ! ( ! empty( $this->options['aiosp_can'] ) ) && ( ! empty( $this->options['aiosp_customize_canonical_links'] ) ) ) { 
  3745. unset( $optlist['custom_link'] ); 
  3746. foreach ( $optlist as $f ) { 
  3747. delete_post_meta( $id, "_aioseop_{$f}" ); 
  3748.  
  3749. if ( $this->is_admin() ) { 
  3750. delete_post_meta( $id, '_aioseop_sitemap_exclude' ); 
  3751. delete_post_meta( $id, '_aioseop_disable' ); 
  3752. delete_post_meta( $id, '_aioseop_disable_analytics' ); 
  3753.  
  3754. foreach ( $optlist as $f ) { 
  3755. $var = "aiosp_$f"; 
  3756. $field = "_aioseop_$f"; 
  3757. if ( isset( $$var ) && ! empty( $$var ) ) { 
  3758. add_post_meta( $id, $field, $$var ); 
  3759. if ( isset( $aiosp_sitemap_exclude ) && ! empty( $aiosp_sitemap_exclude ) && $this->is_admin() ) { 
  3760. add_post_meta( $id, '_aioseop_sitemap_exclude', $aiosp_sitemap_exclude ); 
  3761. if ( isset( $aiosp_disable ) && ! empty( $aiosp_disable ) && $this->is_admin() ) { 
  3762. add_post_meta( $id, '_aioseop_disable', $aiosp_disable ); 
  3763. if ( isset( $aiosp_disable_analytics ) && ! empty( $aiosp_disable_analytics ) ) { 
  3764. add_post_meta( $id, '_aioseop_disable_analytics', $aiosp_disable_analytics ); 
  3765.  
  3766. /** 
  3767. * @param $post 
  3768. * @param $metabox 
  3769. */ 
  3770. function display_tabbed_metabox( $post, $metabox ) { 
  3771. $tabs = $metabox['args']; 
  3772. echo '<div class="aioseop_tabs">'; 
  3773. $header = $this->get_metabox_header( $tabs ); 
  3774. echo $header; 
  3775. $active = ''; 
  3776. foreach ( $tabs as $m ) { 
  3777. echo '<div id="' . $m['id'] . '" class="aioseop_tab"' . $active . '>'; 
  3778. if ( ! $active ) { 
  3779. $active = ' style="display:none;"'; 
  3780. $m['args'] = $m['callback_args']; 
  3781. $m['callback'][0]->{$m['callback'][1]}( $post, $m ); 
  3782. echo '</div>'; 
  3783. echo '</div>'; 
  3784.  
  3785. /** 
  3786. * @param $tabs 
  3787. * @return string 
  3788. */ 
  3789. function get_metabox_header( $tabs ) { 
  3790. $header = '<ul class="aioseop_header_tabs hide">'; 
  3791. $active = ' active'; 
  3792. foreach ( $tabs as $t ) { 
  3793. if ( $active ) { 
  3794. $title = __( 'Main Settings', 'all-in-one-seo-pack' ); 
  3795. } else { 
  3796. $title = $t['title']; 
  3797. $header .= '<li><label class="aioseop_header_nav"><a class="aioseop_header_tab' . $active . '" href="#' . $t['id'] . '">' . $title . '</a></label></li>'; 
  3798. $active = ''; 
  3799. $header .= '</ul>'; 
  3800.  
  3801. return $header; 
  3802.  
  3803. function admin_bar_menu() { 
  3804. global $wp_admin_bar, $aioseop_admin_menu, $aioseop_options, $post; 
  3805.  
  3806. $toggle = ''; 
  3807. if ( isset( $_POST['aiosp_use_original_title'] ) && isset( $_POST['aiosp_admin_bar'] ) ) { 
  3808. $toggle = 'on'; 
  3809. if ( isset( $_POST['aiosp_use_original_title'] ) && ! isset( $_POST['aiosp_admin_bar'] ) ) { 
  3810. $toggle = 'off'; 
  3811.  
  3812. if ( ! empty( $aioseop_options['aiosp_admin_bar'] ) && $toggle != 'off' || isset( $_POST['aiosp_admin_bar'] ) ) { 
  3813. $menu_slug = plugin_basename( __FILE__ ); 
  3814.  
  3815. $url = ''; 
  3816. if ( function_exists( 'menu_page_url' ) ) { 
  3817. $url = menu_page_url( $menu_slug, 0 ); 
  3818. if ( empty( $url ) ) { 
  3819. $url = esc_url( admin_url( 'admin.php?page=' . $menu_slug ) ); 
  3820.  
  3821. $wp_admin_bar->add_menu( array( 
  3822. 'id' => AIOSEOP_PLUGIN_DIRNAME,  
  3823. 'title' => __( 'SEO', 'all-in-one-seo-pack' ),  
  3824. 'href' => $url,  
  3825. ) ); 
  3826.  
  3827. if ( current_user_can( 'update_plugins' ) && ! AIOSEOPPRO ) { 
  3828. $wp_admin_bar->add_menu( array( 
  3829. 'parent' => AIOSEOP_PLUGIN_DIRNAME,  
  3830. 'title' => __( 'Upgrade To Pro', 'all-in-one-seo-pack' ),  
  3831. 'id' => 'aioseop-pro-upgrade',  
  3832. 'href' => 'http://semperplugins.com/plugins/all-in-one-seo-pack-pro-version/?loc=menu',  
  3833. 'meta' => array( 'target' => '_blank' ),  
  3834. ) ); 
  3835. // add_action( 'admin_bar_menu', array( $this, 'admin_bar_upgrade_menu' ), 1101 ); 
  3836.  
  3837. $aioseop_admin_menu = 1; 
  3838. if ( ! is_admin() && ! empty( $post ) ) { 
  3839.  
  3840. $blog_page = aiosp_common::get_blog_page( $post ); 
  3841. if ( ! empty( $blog_page ) ) { 
  3842. $post = $blog_page; 
  3843. if( ! is_home() || ( ! is_front_page() && ! is_home() ) ) { 
  3844. // Don't show if we're on the home page and the home page is the latest posts. 
  3845. $wp_admin_bar->add_menu( array( 
  3846. 'id' => 'aiosp_edit_' . $post->ID,  
  3847. 'parent' => AIOSEOP_PLUGIN_DIRNAME,  
  3848. 'title' => __( 'Edit SEO', 'all-in-one-seo-pack' ),  
  3849. 'href' => get_edit_post_link( $post->ID ) . '#aiosp',  
  3850. ) ); 
  3851.  
  3852. /** 
  3853. * Order for adding the menus for the aioseop_modules_add_menus hook. 
  3854. */ 
  3855. function menu_order() { 
  3856. return 5; 
  3857.  
  3858. /** 
  3859. * @param $tax 
  3860. */ 
  3861. function display_category_metaboxes( $tax ) { 
  3862. $screen = 'edit-' . $tax->taxonomy; 
  3863. ?> 
  3864. <div id="poststuff"> 
  3865. <?php do_meta_boxes( '', 'advanced', $tax ); ?> 
  3866. </div> 
  3867. <?php 
  3868.  
  3869. /** 
  3870. * @param $id 
  3871. */ 
  3872. function save_category_metaboxes( $id ) { 
  3873. $awmp_edit = $nonce = null; 
  3874. if ( isset( $_POST['aiosp_edit'] ) ) { 
  3875. $awmp_edit = $_POST['aiosp_edit']; 
  3876. if ( isset( $_POST['nonce-aioseop-edit'] ) ) { 
  3877. $nonce = $_POST['nonce-aioseop-edit']; 
  3878.  
  3879. if ( isset( $awmp_edit ) && ! empty( $awmp_edit ) && wp_verify_nonce( $nonce, 'edit-aioseop-nonce' ) ) { 
  3880. $optlist = array( 
  3881. 'keywords',  
  3882. 'description',  
  3883. 'title',  
  3884. 'custom_link',  
  3885. 'sitemap_exclude',  
  3886. 'disable',  
  3887. 'disable_analytics',  
  3888. 'noindex',  
  3889. 'nofollow',  
  3890. 'noodp',  
  3891. 'noydir',  
  3892. 'titleatr',  
  3893. 'menulabel',  
  3894. ); 
  3895. foreach ( $optlist as $f ) { 
  3896. $field = "aiosp_$f"; 
  3897. if ( isset( $_POST[ $field ] ) ) { 
  3898. $$field = $_POST[ $field ]; 
  3899.  
  3900. $optlist = array( 
  3901. 'keywords',  
  3902. 'description',  
  3903. 'title',  
  3904. 'custom_link',  
  3905. 'noindex',  
  3906. 'nofollow',  
  3907. 'noodp',  
  3908. 'noydir',  
  3909. 'titleatr',  
  3910. 'menulabel',  
  3911. ); 
  3912. if ( ! ( ! empty( $this->options['aiosp_can'] ) ) && ( ! empty( $this->options['aiosp_customize_canonical_links'] ) ) ) { 
  3913. unset( $optlist['custom_link'] ); 
  3914. foreach ( $optlist as $f ) { 
  3915. delete_term_meta( $id, "_aioseop_{$f}" ); 
  3916.  
  3917. if ( $this->is_admin() ) { 
  3918. delete_term_meta( $id, '_aioseop_sitemap_exclude' ); 
  3919. delete_term_meta( $id, '_aioseop_disable' ); 
  3920. delete_term_meta( $id, '_aioseop_disable_analytics' ); 
  3921.  
  3922. foreach ( $optlist as $f ) { 
  3923. $var = "aiosp_$f"; 
  3924. $field = "_aioseop_$f"; 
  3925. if ( isset( $$var ) && ! empty( $$var ) ) { 
  3926. add_term_meta( $id, $field, $$var ); 
  3927. if ( isset( $aiosp_sitemap_exclude ) && ! empty( $aiosp_sitemap_exclude ) && $this->is_admin() ) { 
  3928. add_term_meta( $id, '_aioseop_sitemap_exclude', $aiosp_sitemap_exclude ); 
  3929. if ( isset( $aiosp_disable ) && ! empty( $aiosp_disable ) && $this->is_admin() ) { 
  3930. add_term_meta( $id, '_aioseop_disable', $aiosp_disable ); 
  3931. if ( isset( $aiosp_disable_analytics ) && ! empty( $aiosp_disable_analytics ) ) { 
  3932. add_term_meta( $id, '_aioseop_disable_analytics', $aiosp_disable_analytics ); 
  3933.  
  3934. function admin_menu() { 
  3935. $file = plugin_basename( __FILE__ ); 
  3936. $menu_name = __( 'All in One SEO', 'all-in-one-seo-pack' ); 
  3937.  
  3938. $this->locations['aiosp']['default_options']['nonce-aioseop-edit']['default'] = wp_create_nonce( 'edit-aioseop-nonce' ); 
  3939.  
  3940. $custom_menu_order = false; 
  3941. global $aioseop_options; 
  3942. if ( ! isset( $aioseop_options['custom_menu_order'] ) ) { 
  3943. $custom_menu_order = true; 
  3944.  
  3945. $this->update_options(); 
  3946.  
  3947. $this->add_admin_pointers(); 
  3948. if ( ! empty( $this->pointers ) ) { 
  3949. foreach ( $this->pointers as $k => $p ) { 
  3950. if ( ! empty( $p['pointer_scope'] ) && ( $p['pointer_scope'] == 'global' ) ) { 
  3951. unset( $this->pointers[ $k ] ); 
  3952.  
  3953. $donated = false; 
  3954. if ( isset( $_POST ) && isset( $_POST['module'] ) && isset( $_POST['nonce-aioseop'] ) && ( $_POST['module'] == 'All_in_One_SEO_Pack' ) && wp_verify_nonce( $_POST['nonce-aioseop'], 'aioseop-nonce' ) ) { 
  3955. if ( isset( $_POST['aiosp_donate'] ) ) { 
  3956. $donated = $_POST['aiosp_donate']; 
  3957. if ( isset( $_POST['Submit'] ) ) { 
  3958. if ( isset( $_POST['aiosp_custom_menu_order'] ) ) { 
  3959. $custom_menu_order = $_POST['aiosp_custom_menu_order']; 
  3960. } else { 
  3961. $custom_menu_order = false; 
  3962. } else if ( isset( $_POST['Submit_Default'] ) || isset( $_POST['Submit_All_Default'] ) ) { 
  3963. $custom_menu_order = true; 
  3964. } else { 
  3965. if ( isset( $this->options['aiosp_donate'] ) ) { 
  3966. $donated = $this->options['aiosp_donate']; 
  3967. if ( isset( $this->options['aiosp_custom_menu_order'] ) ) { 
  3968. $custom_menu_order = $this->options['aiosp_custom_menu_order']; 
  3969.  
  3970. if ( $custom_menu_order ) { 
  3971. add_filter( 'custom_menu_order', '__return_true' ); 
  3972. add_filter( 'menu_order', array( $this, 'set_menu_order' ), 11 ); 
  3973.  
  3974. if ( $donated ) { 
  3975. // Thank you for your donation. 
  3976. $this->pointers['aioseop_donate'] = array( 
  3977. 'pointer_target' => '#aiosp_donate_wrapper',  
  3978. 'pointer_text' => '<h3>' . __( 'Thank you!', 'all-in-one-seo-pack' ) 
  3979. . '</h3><p>' . __( 'Thank you for your donation, it helps keep this plugin free and actively developed!', 'all-in-one-seo-pack' ) . '</p>',  
  3980. ); 
  3981.  
  3982. if ( ! AIOSEOPPRO ) { 
  3983. if ( ! empty( $this->pointers ) ) { 
  3984. foreach ( $this->pointers as $k => $p ) { 
  3985. if ( ! empty( $p['pointer_scope'] ) && ( $p['pointer_scope'] == 'global' ) ) { 
  3986. unset( $this->pointers[ $k ] ); 
  3987.  
  3988. $this->filter_pointers(); 
  3989.  
  3990. if ( ! empty( $this->options['aiosp_enablecpost'] ) && $this->options['aiosp_enablecpost'] ) { 
  3991. if ( AIOSEOPPRO ) { 
  3992. $this->locations['aiosp']['display'] = $this->options['aiosp_cpostactive']; 
  3993. if ( ! empty( $this->options['aiosp_taxactive'] ) ) { 
  3994. foreach ( $this->options['aiosp_taxactive'] as $tax ) { 
  3995. $this->locations['aiosp']['display'][] = 'edit-' . $tax; 
  3996. add_action( "{$tax}_edit_form", array( $this, 'display_category_metaboxes' ) ); 
  3997. add_action( "edited_{$tax}", array( $this, 'save_category_metaboxes' ) ); 
  3998. } else { 
  3999. if ( ! empty( $this->options['aiosp_cpostactive'] ) ) { 
  4000. $this->locations['aiosp']['display'] = $this->options['aiosp_cpostactive']; 
  4001. } else { 
  4002. $this->locations['aiosp']['display'] = array(); 
  4003. } else { 
  4004. $this->locations['aiosp']['display'] = array( 'post', 'page' ); 
  4005.  
  4006.  
  4007. add_menu_page( $menu_name, $menu_name, apply_filters( 'manage_aiosp', 'aiosp_manage_seo' ), $file, array( 
  4008. $this,  
  4009. 'display_settings_page',  
  4010. ) ); 
  4011.  
  4012. add_meta_box( 'aioseop-list', __( 'Join Our Mailing List', 'all-in-one-seo-pack' ), array( 
  4013. 'aiosp_metaboxes',  
  4014. 'display_extra_metaboxes',  
  4015. ), 'aioseop_metaboxes', 'normal', 'core' ); 
  4016. if ( AIOSEOPPRO ) { 
  4017. add_meta_box( 'aioseop-about', __( 'About', 'all-in-one-seo-pack' ), array( 
  4018. 'aiosp_metaboxes',  
  4019. 'display_extra_metaboxes',  
  4020. ), 'aioseop_metaboxes', 'side', 'core' ); 
  4021. } else { 
  4022. add_meta_box( 'aioseop-about', "About <span class='Taha' style='float:right;'>Version <b>" . AIOSEOP_VERSION . '</b></span>', array( 
  4023. 'aiosp_metaboxes',  
  4024. 'display_extra_metaboxes',  
  4025. ), 'aioseop_metaboxes', 'side', 'core' ); 
  4026. add_meta_box( 'aioseop-support', __( 'Support', 'all-in-one-seo-pack' ) . " <span class='Taha' style='float:right;'>" . __( 'Version', 'all-in-one-seo-pack' ) . ' <b>' . AIOSEOP_VERSION . '</b></span>', array( 
  4027. 'aiosp_metaboxes',  
  4028. 'display_extra_metaboxes',  
  4029. ), 'aioseop_metaboxes', 'side', 'core' ); 
  4030.  
  4031. add_action( 'aioseop_modules_add_menus', array( $this, 'add_menu' ), 5 ); 
  4032. do_action( 'aioseop_modules_add_menus', $file ); 
  4033.  
  4034. $metaboxes = apply_filters( 'aioseop_add_post_metabox', array() ); 
  4035.  
  4036. if ( ! empty( $metaboxes ) ) { 
  4037. if ( $this->tabbed_metaboxes ) { 
  4038. $tabs = array(); 
  4039. $tab_num = 0; 
  4040. foreach ( $metaboxes as $m ) { 
  4041. if ( ! isset( $tabs[ $m['post_type'] ] ) ) { 
  4042. $tabs[ $m['post_type'] ] = array(); 
  4043. $tabs[ $m['post_type'] ][] = $m; 
  4044.  
  4045. if ( ! empty( $tabs ) ) { 
  4046. foreach ( $tabs as $p => $m ) { 
  4047. $tab_num = count( $m ); 
  4048. $title = $m[0]['title']; 
  4049. if ( $title != $this->plugin_name ) { 
  4050. $title = $this->plugin_name . ' - ' . $title; 
  4051. if ( $tab_num <= 1 ) { 
  4052. if ( ! empty( $m[0]['callback_args']['help_link'] ) ) { 
  4053. $title .= "<a class='aioseop_help_text_link aioseop_meta_box_help' target='_blank' href='" . $m[0]['callback_args']['help_link'] . "'><span>" . __( 'Help', 'all-in-one-seo-pack' ) . '</span></a>'; 
  4054. add_meta_box( $m[0]['id'], $title, $m[0]['callback'], $m[0]['post_type'], $m[0]['context'], $m[0]['priority'], $m[0]['callback_args'] ); 
  4055. } elseif ( $tab_num > 1 ) { 
  4056. add_meta_box( $m[0]['id'] . '_tabbed', $title, array( 
  4057. $this,  
  4058. 'display_tabbed_metabox',  
  4059. ), $m[0]['post_type'], $m[0]['context'], $m[0]['priority'], $m ); 
  4060. } else { 
  4061. foreach ( $metaboxes as $m ) { 
  4062. $title = $m['title']; 
  4063. if ( $title != $this->plugin_name ) { 
  4064. $title = $this->plugin_name . ' - ' . $title; 
  4065. if ( ! empty( $m['help_link'] ) ) { 
  4066. $title .= "<a class='aioseop_help_text_link aioseop_meta_box_help' target='_blank' href='" . $m['help_link'] . "'><span>" . __( 'Help', 'all-in-one-seo-pack' ) . '</span></a>'; 
  4067. add_meta_box( $m['id'], $title, $m['callback'], $m['post_type'], $m['context'], $m['priority'], $m['callback_args'] ); 
  4068.  
  4069. /** 
  4070. * @param $menu_order 
  4071. * @return array 
  4072. */ 
  4073. function set_menu_order( $menu_order ) { 
  4074. $order = array(); 
  4075. $file = plugin_basename( __FILE__ ); 
  4076. foreach ( $menu_order as $index => $item ) { 
  4077. if ( $item != $file ) { 
  4078. $order[] = $item; 
  4079. if ( $index == 0 ) { 
  4080. $order[] = $file; 
  4081.  
  4082. return $order; 
  4083.  
  4084. function display_settings_header() { 
  4085.  
  4086. function display_settings_footer() { 
  4087.  
  4088. function display_right_sidebar() { 
  4089. global $wpdb; 
  4090.  
  4091. if ( ! get_option( 'aioseop_options' ) ) { 
  4092. $msg = "<div style='text-align:center;'><p><strong>Your database options need to be updated.</strong><em>(Back up your database before updating.)</em> 
  4093. <FORM action='' method='post' name='aioseop-migrate-options'> 
  4094. <input type='hidden' name='nonce-aioseop-migrate-options' value='" . wp_create_nonce( 'aioseop-migrate-nonce-options' ) . "' /> 
  4095. <input type='submit' name='aioseop_migrate_options' class='button-primary' value='Update Database Options'> 
  4096. </FORM> 
  4097. </p></div>"; 
  4098. aioseop_output_dismissable_notice( $msg, '', 'error' ); 
  4099. ?> 
  4100. <div class="aioseop_top"> 
  4101. <div class="aioseop_top_sidebar aioseop_options_wrapper"> 
  4102. <?php do_meta_boxes( 'aioseop_metaboxes', 'normal', array( 'test' ) ); ?> 
  4103. </div> 
  4104. </div> 
  4105. <style> 
  4106. #wpbody-content { 
  4107. min-width: 900px; 
  4108. </style> 
  4109. <div class="aioseop_right_sidebar aioseop_options_wrapper"> 
  4110.  
  4111. <div class="aioseop_sidebar"> 
  4112. <?php 
  4113. do_meta_boxes( 'aioseop_metaboxes', 'side', array( 'test' ) ); 
  4114. ?> 
  4115. <script type="text/javascript"> 
  4116. //<![CDATA[ 
  4117. jQuery(document).ready(function ($) { 
  4118. // Close postboxes that should be closed. 
  4119. $('.if-js-closed').removeClass('if-js-closed').addClass('closed'); 
  4120. // Postboxes setup. 
  4121. if (typeof postboxes !== 'undefined') 
  4122. postboxes.add_postbox_toggles('<?php echo $this->pagehook; ?>'); 
  4123. }); 
  4124. //]]> 
  4125. </script> 
  4126. <?php if ( ! AIOSEOPPRO ) { ?> 
  4127. <div class="aioseop_advert aioseop_nopad_all"> 
  4128. <?php $adid = mt_rand( 21, 22 ); ?> 
  4129. <a href="https://www.wincher.com/?referer=all-in-one-seo-pack&adreferer=banner<?php echo $adid; ?>" 
  4130. target="_blank"> 
  4131. <div class=wincherad id=wincher<?php echo $adid; ?>> 
  4132. </div> 
  4133. </a> 
  4134. </div> 
  4135. <div class="aioseop_advert headwaythemes"> 
  4136. <div> 
  4137. <h3>Drag and Drop WordPress Design</h3> 
  4138. <p><a href="http://semperfiwebdesign.com/headwayaio/" target="_blank">Headway Themes</a> 
  4139. allows you to easily create your own stunning website designs! Stop using premade themes 
  4140. start making your own design with Headway's easy to use Drag and Drop interface. All in 
  4141. One SEO Pack users have an exclusive discount by using coupon code 
  4142. <strong>SEMPERFI30</strong> at checkout.</p> 
  4143. </div> 
  4144. <a href="http://semperfiwebdesign.com/headwayaio/" target="_blank"><img 
  4145. src="<?php echo AIOSEOP_PLUGIN_IMAGES_URL; ?>headwaybanner.png"></a> 
  4146. </div> 
  4147. <?php } ?> 
  4148. </div> 
  4149. </div> 
  4150. <?php 
  4151.