Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: robots-template.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Robots template functions.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Robots
[5] Fix | Delete
* @since 5.7.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Displays the robots meta tag as necessary.
[10] Fix | Delete
*
[11] Fix | Delete
* Gathers robots directives to include for the current context, using the
[12] Fix | Delete
* {@see 'wp_robots'} filter. The directives are then sanitized, and the
[13] Fix | Delete
* robots meta tag is output if there is at least one relevant directive.
[14] Fix | Delete
*
[15] Fix | Delete
* @since 5.7.0
[16] Fix | Delete
* @since 5.7.1 No longer prevents specific directives to occur together.
[17] Fix | Delete
*/
[18] Fix | Delete
function wp_robots() {
[19] Fix | Delete
/**
[20] Fix | Delete
* Filters the directives to be included in the 'robots' meta tag.
[21] Fix | Delete
*
[22] Fix | Delete
* The meta tag will only be included as necessary.
[23] Fix | Delete
*
[24] Fix | Delete
* @since 5.7.0
[25] Fix | Delete
*
[26] Fix | Delete
* @param array $robots Associative array of directives. Every key must be the name of the directive, and the
[27] Fix | Delete
* corresponding value must either be a string to provide as value for the directive or a
[28] Fix | Delete
* boolean `true` if it is a boolean directive, i.e. without a value.
[29] Fix | Delete
*/
[30] Fix | Delete
$robots = apply_filters( 'wp_robots', array() );
[31] Fix | Delete
[32] Fix | Delete
$robots_strings = array();
[33] Fix | Delete
foreach ( $robots as $directive => $value ) {
[34] Fix | Delete
if ( is_string( $value ) ) {
[35] Fix | Delete
// If a string value, include it as value for the directive.
[36] Fix | Delete
$robots_strings[] = "{$directive}:{$value}";
[37] Fix | Delete
} elseif ( $value ) {
[38] Fix | Delete
// Otherwise, include the directive if it is truthy.
[39] Fix | Delete
$robots_strings[] = $directive;
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
if ( empty( $robots_strings ) ) {
[44] Fix | Delete
return;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
echo "<meta name='robots' content='" . esc_attr( implode( ', ', $robots_strings ) ) . "' />\n";
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/**
[51] Fix | Delete
* Adds noindex to the robots meta tag if required by the site configuration.
[52] Fix | Delete
*
[53] Fix | Delete
* If a blog is marked as not being public then noindex will be output to
[54] Fix | Delete
* tell web robots not to index the page content. Add this to the
[55] Fix | Delete
* {@see 'wp_robots'} filter.
[56] Fix | Delete
*
[57] Fix | Delete
* Typical usage is as a {@see 'wp_robots'} callback:
[58] Fix | Delete
*
[59] Fix | Delete
* add_filter( 'wp_robots', 'wp_robots_noindex' );
[60] Fix | Delete
*
[61] Fix | Delete
* @since 5.7.0
[62] Fix | Delete
*
[63] Fix | Delete
* @see wp_robots_no_robots()
[64] Fix | Delete
*
[65] Fix | Delete
* @param array $robots Associative array of robots directives.
[66] Fix | Delete
* @return array Filtered robots directives.
[67] Fix | Delete
*/
[68] Fix | Delete
function wp_robots_noindex( array $robots ) {
[69] Fix | Delete
if ( ! get_option( 'blog_public' ) ) {
[70] Fix | Delete
return wp_robots_no_robots( $robots );
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
return $robots;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
/**
[77] Fix | Delete
* Adds noindex to the robots meta tag for embeds.
[78] Fix | Delete
*
[79] Fix | Delete
* Typical usage is as a {@see 'wp_robots'} callback:
[80] Fix | Delete
*
[81] Fix | Delete
* add_filter( 'wp_robots', 'wp_robots_noindex_embeds' );
[82] Fix | Delete
*
[83] Fix | Delete
* @since 5.7.0
[84] Fix | Delete
*
[85] Fix | Delete
* @see wp_robots_no_robots()
[86] Fix | Delete
*
[87] Fix | Delete
* @param array $robots Associative array of robots directives.
[88] Fix | Delete
* @return array Filtered robots directives.
[89] Fix | Delete
*/
[90] Fix | Delete
function wp_robots_noindex_embeds( array $robots ) {
[91] Fix | Delete
if ( is_embed() ) {
[92] Fix | Delete
return wp_robots_no_robots( $robots );
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
return $robots;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
/**
[99] Fix | Delete
* Adds noindex to the robots meta tag if a search is being performed.
[100] Fix | Delete
*
[101] Fix | Delete
* If a search is being performed then noindex will be output to
[102] Fix | Delete
* tell web robots not to index the page content. Add this to the
[103] Fix | Delete
* {@see 'wp_robots'} filter.
[104] Fix | Delete
*
[105] Fix | Delete
* Typical usage is as a {@see 'wp_robots'} callback:
[106] Fix | Delete
*
[107] Fix | Delete
* add_filter( 'wp_robots', 'wp_robots_noindex_search' );
[108] Fix | Delete
*
[109] Fix | Delete
* @since 5.7.0
[110] Fix | Delete
*
[111] Fix | Delete
* @see wp_robots_no_robots()
[112] Fix | Delete
*
[113] Fix | Delete
* @param array $robots Associative array of robots directives.
[114] Fix | Delete
* @return array Filtered robots directives.
[115] Fix | Delete
*/
[116] Fix | Delete
function wp_robots_noindex_search( array $robots ) {
[117] Fix | Delete
if ( is_search() ) {
[118] Fix | Delete
return wp_robots_no_robots( $robots );
[119] Fix | Delete
}
[120] Fix | Delete
[121] Fix | Delete
return $robots;
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* Adds noindex to the robots meta tag.
[126] Fix | Delete
*
[127] Fix | Delete
* This directive tells web robots not to index the page content.
[128] Fix | Delete
*
[129] Fix | Delete
* Typical usage is as a {@see 'wp_robots'} callback:
[130] Fix | Delete
*
[131] Fix | Delete
* add_filter( 'wp_robots', 'wp_robots_no_robots' );
[132] Fix | Delete
*
[133] Fix | Delete
* @since 5.7.0
[134] Fix | Delete
*
[135] Fix | Delete
* @param array $robots Associative array of robots directives.
[136] Fix | Delete
* @return array Filtered robots directives.
[137] Fix | Delete
*/
[138] Fix | Delete
function wp_robots_no_robots( array $robots ) {
[139] Fix | Delete
$robots['noindex'] = true;
[140] Fix | Delete
[141] Fix | Delete
if ( get_option( 'blog_public' ) ) {
[142] Fix | Delete
$robots['follow'] = true;
[143] Fix | Delete
} else {
[144] Fix | Delete
$robots['nofollow'] = true;
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
return $robots;
[148] Fix | Delete
}
[149] Fix | Delete
[150] Fix | Delete
/**
[151] Fix | Delete
* Adds noindex and noarchive to the robots meta tag.
[152] Fix | Delete
*
[153] Fix | Delete
* This directive tells web robots not to index or archive the page content and
[154] Fix | Delete
* is recommended to be used for sensitive pages.
[155] Fix | Delete
*
[156] Fix | Delete
* Typical usage is as a {@see 'wp_robots'} callback:
[157] Fix | Delete
*
[158] Fix | Delete
* add_filter( 'wp_robots', 'wp_robots_sensitive_page' );
[159] Fix | Delete
*
[160] Fix | Delete
* @since 5.7.0
[161] Fix | Delete
*
[162] Fix | Delete
* @param array $robots Associative array of robots directives.
[163] Fix | Delete
* @return array Filtered robots directives.
[164] Fix | Delete
*/
[165] Fix | Delete
function wp_robots_sensitive_page( array $robots ) {
[166] Fix | Delete
$robots['noindex'] = true;
[167] Fix | Delete
$robots['noarchive'] = true;
[168] Fix | Delete
return $robots;
[169] Fix | Delete
}
[170] Fix | Delete
[171] Fix | Delete
/**
[172] Fix | Delete
* Adds 'max-image-preview:large' to the robots meta tag.
[173] Fix | Delete
*
[174] Fix | Delete
* This directive tells web robots that large image previews are allowed to be
[175] Fix | Delete
* displayed, e.g. in search engines, unless the blog is marked as not being public.
[176] Fix | Delete
*
[177] Fix | Delete
* Typical usage is as a {@see 'wp_robots'} callback:
[178] Fix | Delete
*
[179] Fix | Delete
* add_filter( 'wp_robots', 'wp_robots_max_image_preview_large' );
[180] Fix | Delete
*
[181] Fix | Delete
* @since 5.7.0
[182] Fix | Delete
*
[183] Fix | Delete
* @param array $robots Associative array of robots directives.
[184] Fix | Delete
* @return array Filtered robots directives.
[185] Fix | Delete
*/
[186] Fix | Delete
function wp_robots_max_image_preview_large( array $robots ) {
[187] Fix | Delete
if ( get_option( 'blog_public' ) ) {
[188] Fix | Delete
$robots['max-image-preview'] = 'large';
[189] Fix | Delete
}
[190] Fix | Delete
return $robots;
[191] Fix | Delete
}
[192] Fix | Delete
[193] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function