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