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