PageRenderTime 28ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/html/blog/wp-content/plugins/wordpress-seo/admin/pages/dashboard.php

https://github.com/jimmytidey/jimmytidey.co.uk
PHP | 170 lines | 132 code | 27 blank | 11 comment | 39 complexity | 6da9a972d5232c26037680815005834d MD5 | raw file
  1. <?php
  2. /**
  3. *
  4. *
  5. * @package Admin
  6. */
  7. if ( ! defined( 'WPSEO_VERSION' ) ) {
  8. header( 'Status: 403 Forbidden' );
  9. header( 'HTTP/1.1 403 Forbidden' );
  10. exit();
  11. }
  12. global $wpseo_admin_pages;
  13. $options = get_option( 'wpseo' );
  14. if ( isset( $_GET['allow_tracking'] ) && check_admin_referer( 'wpseo_activate_tracking', 'nonce' ) ) {
  15. $options['tracking_popup_done'] = true;
  16. if ( $_GET['allow_tracking'] == 'yes' ) {
  17. $options['yoast_tracking'] = true;
  18. }
  19. else {
  20. $options['yoast_tracking'] = false;
  21. }
  22. update_option( 'wpseo', $options );
  23. if ( isset( $_SERVER['HTTP_REFERER'] ) ) {
  24. wp_safe_redirect( $_SERVER['HTTP_REFERER'], 307 );
  25. exit;
  26. }
  27. }
  28. // Fix metadescription if so requested
  29. if ( isset( $_GET['fixmetadesc'] ) && check_admin_referer( 'wpseo-fix-metadesc', 'nonce' ) && $options['theme_description_found'] !== '' ) {
  30. $path = false;
  31. if ( file_exists( get_stylesheet_directory() . '/header.php' ) ) {
  32. // theme or child theme
  33. $path = get_stylesheet_directory();
  34. }
  35. elseif ( file_exists( get_template_directory() . '/header.php' ) ) {
  36. // parent theme in case of a child theme
  37. $path = get_template_directory();
  38. }
  39. if ( is_string( $path ) && $path !== '' ) {
  40. $fcontent = file_get_contents( $path . '/header.php' );
  41. $msg = '';
  42. $backup_file = date( 'Ymd-H.i.s-' ) . 'header.php.wpseobak';
  43. if ( ! file_exists( $path . '/' . $backup_file ) ) {
  44. $backupfile = fopen( $path . '/' . $backup_file, 'w+' );
  45. if ( $backupfile ) {
  46. fwrite( $backupfile, $fcontent );
  47. fclose( $backupfile );
  48. $msg = __( 'Backed up the original file header.php to <strong><em>' . esc_html( $backup_file ) . '</em></strong>, ', 'wordpress-seo' );
  49. $count = 0;
  50. $fcontent = str_replace( $options['theme_description_found'], '', $fcontent, $count );
  51. if ( $count > 0 ) {
  52. $header_file = fopen( $path . '/header.php', 'w+' );
  53. if ( $header_file ) {
  54. if ( fwrite( $header_file, $fcontent ) !== false ) {
  55. $msg .= __( 'Removed hardcoded meta description.', 'wordpress-seo' );
  56. $options['theme_has_description'] = false;
  57. $options['theme_description_found'] = '';
  58. update_option( 'wpseo', $options );
  59. }
  60. else {
  61. $msg .= '<span class="error">' . __( 'Failed to remove hardcoded meta description.', 'wordpress-seo' ) . '</span>';
  62. }
  63. fclose( $header_file );
  64. }
  65. }
  66. else {
  67. wpseo_description_test();
  68. $msg .= '<span class="warning">' . __( 'Earlier found meta description was not found in file. Renewed the description test data.', 'wordpress-seo' ) . '</span>';
  69. }
  70. add_settings_error( 'yoast_wpseo_dashboard_options', 'error', $msg, 'updated' );
  71. }
  72. }
  73. }
  74. // Clean up the referrer url for later use
  75. if( isset( $_SERVER['REQUEST_URI'] ) ) {
  76. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'nonce', 'fixmetadesc' ), $_SERVER['REQUEST_URI'] );
  77. }
  78. }
  79. if ( ( ! isset( $options['theme_has_description'] ) || ( ( isset( $options['theme_has_description'] ) && $options['theme_has_description'] === true ) || $options['theme_description_found'] !== '' ) ) || ( isset( $_GET['checkmetadesc'] ) && check_admin_referer( 'wpseo-check-metadesc', 'nonce' ) ) ) {
  80. wpseo_description_test();
  81. // Renew the options after the test
  82. $options = get_option( 'wpseo' );
  83. }
  84. if( isset( $_GET['checkmetadesc'] ) ) {
  85. // Clean up the referrer url for later use
  86. if( isset( $_SERVER['REQUEST_URI'] ) ) {
  87. $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'nonce', 'checkmetadesc' ), $_SERVER['REQUEST_URI'] );
  88. }
  89. }
  90. $wpseo_admin_pages->admin_header( true, WPSEO_Options::get_group_name( 'wpseo' ), 'wpseo' );
  91. do_action( 'wpseo_all_admin_notices' );
  92. if ( is_array( $options['blocking_files'] ) && count( $options['blocking_files'] ) > 0 ) {
  93. echo '<p id="blocking_files" class="wrong">'
  94. . '<a href="javascript:wpseo_killBlockingFiles(\'' . esc_js( wp_create_nonce( 'wpseo-blocking-files' ) ) . '\')" class="button fixit">' . __( 'Fix it.', 'wordpress-seo' ) . '</a>'
  95. . __( 'The following file(s) is/are blocking your XML sitemaps from working properly:', 'wordpress-seo' ) . '<br />';
  96. foreach ( $options['blocking_files'] as $file ) {
  97. echo esc_html( $file ) . '<br/>';
  98. }
  99. echo __( 'Either delete them (this can be done with the "Fix it" button) or disable WP SEO XML sitemaps.', 'wordpress-seo' );
  100. echo '</p>';
  101. }
  102. if ( $options['theme_description_found'] !== '' ) {
  103. echo '<p id="metadesc_found notice" class="wrong settings_error">'
  104. . '<a href="' . esc_url( add_query_arg( array( 'nonce' => wp_create_nonce( 'wpseo-fix-metadesc' ) ), admin_url( 'admin.php?page=wpseo_dashboard&fixmetadesc' ) ) ) . '" class="button fixit">' . __( 'Fix it.', 'wordpress-seo' ) . '</a>'
  105. . ' <a href="' . esc_url( add_query_arg( array( 'nonce' => wp_create_nonce( 'wpseo-check-metadesc' ) ), admin_url( 'admin.php?page=wpseo_dashboard&checkmetadesc' ) ) ) . '" class="button checkit">' . __( 'Re-check theme.', 'wordpress-seo' ) . '</a>'
  106. . __( 'Your theme contains a meta description, which blocks WordPress SEO from working properly, please delete the following line, or press fix it:', 'wordpress-seo' ) . '<br />';
  107. echo '<code>' . esc_html( $options['theme_description_found'] ) . '</code>';
  108. echo '</p>';
  109. }
  110. if ( strpos( get_option( 'permalink_structure' ), '%postname%' ) === false && $options['ignore_permalink'] === false )
  111. echo '<p id="wrong_permalink" class="wrong">'
  112. . '<a href="' . esc_url( admin_url( 'options-permalink.php' ) ) . '" class="button fixit">' . __( 'Fix it.', 'wordpress-seo' ) . '</a>'
  113. . '<a href="javascript:wpseo_setIgnore(\'permalink\',\'wrong_permalink\',\'' . esc_js( wp_create_nonce( 'wpseo-ignore' ) ) . '\');" class="button fixit">' . __( 'Ignore.', 'wordpress-seo' ) . '</a>'
  114. . __( 'You do not have your postname in the URL of your posts and pages, it is highly recommended that you do. Consider setting your permalink structure to <strong>/%postname%/</strong>.', 'wordpress-seo' ) . '</p>';
  115. if ( get_option( 'page_comments' ) && $options['ignore_page_comments'] === false )
  116. echo '<p id="wrong_page_comments" class="wrong">'
  117. . '<a href="javascript:setWPOption(\'page_comments\',\'0\',\'wrong_page_comments\',\'' . esc_js( wp_create_nonce( 'wpseo-setoption' ) ) . '\');" class="button fixit">' . __( 'Fix it.', 'wordpress-seo' ) . '</a>'
  118. . '<a href="javascript:wpseo_setIgnore(\'page_comments\',\'wrong_page_comments\',\'' . esc_js( wp_create_nonce( 'wpseo-ignore' ) ) . '\');" class="button fixit">' . __( 'Ignore.', 'wordpress-seo' ) . '</a>'
  119. . __( 'Paging comments is enabled, this is not needed in 999 out of 1000 cases, so the suggestion is to disable it, to do that, simply uncheck the box before "Break comments into pages..."', 'wordpress-seo' ) . '</p>';
  120. echo '<h2>' . __( 'General', 'wordpress-seo' ) . '</h2>';
  121. if ( $options['ignore_tour'] === true ) {
  122. echo '<label class="select">' . __( 'Introduction Tour:', 'wordpress-seo' ) . '</label><a class="button-secondary" href="' . esc_url( admin_url( 'admin.php?page=wpseo_dashboard&wpseo_restart_tour' ) ) . '">' . __( 'Start Tour', 'wordpress-seo' ) . '</a>';
  123. echo '<p class="desc label">' . __( 'Take this tour to quickly learn about the use of this plugin.', 'wordpress-seo' ) . '</p>';
  124. }
  125. echo '<label class="select">' . __( 'Default Settings:', 'wordpress-seo' ) . '</label><a class="button-secondary" href="' . esc_url( add_query_arg( array( 'nonce' => wp_create_nonce( 'wpseo_reset_defaults' ) ), admin_url( 'admin.php?page=wpseo_dashboard&wpseo_reset_defaults' ) ) ) . '">' . __( 'Reset Default Settings', 'wordpress-seo' ) . '</a>';
  126. echo '<p class="desc label">' . __( 'If you want to restore a site to the default WordPress SEO settings, press this button.', 'wordpress-seo' ) . '</p>';
  127. echo '<h2>' . __( 'Tracking', 'wordpress-seo' ) . '</h2>';
  128. echo $wpseo_admin_pages->checkbox( 'yoast_tracking', __( 'Allow tracking of this WordPress install\'s anonymous data.', 'wordpress-seo' ) );
  129. echo '<p class="desc">' . __( "To maintain a plugin as big as WordPress SEO, we need to know what we're dealing with: what kinds of other plugins our users are using, what themes, etc. Please allow us to track that data from your install. It will not track <em>any</em> user details, so your security and privacy are safe with us.", 'wordpress-seo' ) . '</p>';
  130. echo '<h2>' . __( 'Security', 'wordpress-seo' ) . '</h2>';
  131. echo $wpseo_admin_pages->checkbox( 'disableadvanced_meta', __( 'Disable the Advanced part of the WordPress SEO meta box', 'wordpress-seo' ) );
  132. echo '<p class="desc">' . __( 'Unchecking this box allows authors and editors to redirect posts, noindex them and do other things you might not want if you don\'t trust your authors.', 'wordpress-seo' ) . '</p>';
  133. echo '<h2>' . __( 'Webmaster Tools', 'wordpress-seo' ) . '</h2>';
  134. echo '<p>' . __( 'You can use the boxes below to verify with the different Webmaster Tools, if your site is already verified, you can just forget about these. Enter the verify meta values for:', 'wordpress-seo' ) . '</p>';
  135. echo $wpseo_admin_pages->textinput( 'alexaverify', '<a target="_blank" href="http://www.alexa.com/siteowners/claim">' . __( 'Alexa Verification ID', 'wordpress-seo' ) . '</a>' );
  136. echo $wpseo_admin_pages->textinput( 'msverify', '<a target="_blank" href="' . esc_url( 'http://www.bing.com/webmaster/?rfp=1#/Dashboard/?url=' . urlencode( str_replace( 'http://', '', get_bloginfo( 'url' ) ) ) ) . '">' . __( 'Bing Webmaster Tools', 'wordpress-seo' ) . '</a>' );
  137. echo $wpseo_admin_pages->textinput( 'googleverify', '<a target="_blank" href="' . esc_url( 'https://www.google.com/webmasters/verification/verification?hl=en&siteUrl=' . urlencode( get_bloginfo( 'url' ) ) . '/' ) . '">' . __( 'Google Webmaster Tools', 'wordpress-seo' ) . '</a>' );
  138. echo $wpseo_admin_pages->textinput( 'pinterestverify', '<a target="_blank" href="https://help.pinterest.com/entries/22488487-Verify-with-HTML-meta-tags">' . __( 'Pinterest', 'wordpress-seo' ) . '</a>' );
  139. echo $wpseo_admin_pages->textinput( 'yandexverify', '<a target="_blank" href="http://help.yandex.com/webmaster/service/rights.xml#how-to">' . __( 'Yandex Webmaster Tools', 'wordpress-seo' ) . '</a>' );
  140. do_action( 'wpseo_dashboard' );
  141. $wpseo_admin_pages->admin_footer();