Edit File by line
/home/barbar84/public_h.../wp-admin/includes
File: credits.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Credits Administration API.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
* @since 4.4.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Retrieve the contributor credits.
[10] Fix | Delete
*
[11] Fix | Delete
* @since 3.2.0
[12] Fix | Delete
* @since 5.6.0 Added the `$version` and `$locale` parameters.
[13] Fix | Delete
*
[14] Fix | Delete
* @param string $version WordPress version. Defaults to the current version.
[15] Fix | Delete
* @param string $locale WordPress locale. Defaults to the current user's locale.
[16] Fix | Delete
* @return array|false A list of all of the contributors, or false on error.
[17] Fix | Delete
*/
[18] Fix | Delete
function wp_credits( $version = '', $locale = '' ) {
[19] Fix | Delete
if ( ! $version ) {
[20] Fix | Delete
// Include an unmodified $wp_version.
[21] Fix | Delete
require ABSPATH . WPINC . '/version.php';
[22] Fix | Delete
[23] Fix | Delete
$version = $wp_version;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
if ( ! $locale ) {
[27] Fix | Delete
$locale = get_user_locale();
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
$results = get_site_transient( 'wordpress_credits_' . $locale );
[31] Fix | Delete
[32] Fix | Delete
if ( ! is_array( $results )
[33] Fix | Delete
|| false !== strpos( $version, '-' )
[34] Fix | Delete
|| ( isset( $results['data']['version'] ) && strpos( $version, $results['data']['version'] ) !== 0 )
[35] Fix | Delete
) {
[36] Fix | Delete
$url = "http://api.wordpress.org/core/credits/1.1/?version={$version}&locale={$locale}";
[37] Fix | Delete
$options = array( 'user-agent' => 'WordPress/' . $version . '; ' . home_url( '/' ) );
[38] Fix | Delete
[39] Fix | Delete
if ( wp_http_supports( array( 'ssl' ) ) ) {
[40] Fix | Delete
$url = set_url_scheme( $url, 'https' );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
$response = wp_remote_get( $url, $options );
[44] Fix | Delete
[45] Fix | Delete
if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
[46] Fix | Delete
return false;
[47] Fix | Delete
}
[48] Fix | Delete
[49] Fix | Delete
$results = json_decode( wp_remote_retrieve_body( $response ), true );
[50] Fix | Delete
[51] Fix | Delete
if ( ! is_array( $results ) ) {
[52] Fix | Delete
return false;
[53] Fix | Delete
}
[54] Fix | Delete
[55] Fix | Delete
set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
return $results;
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Retrieve the link to a contributor's WordPress.org profile page.
[63] Fix | Delete
*
[64] Fix | Delete
* @access private
[65] Fix | Delete
* @since 3.2.0
[66] Fix | Delete
*
[67] Fix | Delete
* @param string $display_name The contributor's display name (passed by reference).
[68] Fix | Delete
* @param string $username The contributor's username.
[69] Fix | Delete
* @param string $profiles URL to the contributor's WordPress.org profile page.
[70] Fix | Delete
*/
[71] Fix | Delete
function _wp_credits_add_profile_link( &$display_name, $username, $profiles ) {
[72] Fix | Delete
$display_name = '<a href="' . esc_url( sprintf( $profiles, $username ) ) . '">' . esc_html( $display_name ) . '</a>';
[73] Fix | Delete
}
[74] Fix | Delete
[75] Fix | Delete
/**
[76] Fix | Delete
* Retrieve the link to an external library used in WordPress.
[77] Fix | Delete
*
[78] Fix | Delete
* @access private
[79] Fix | Delete
* @since 3.2.0
[80] Fix | Delete
*
[81] Fix | Delete
* @param string $data External library data (passed by reference).
[82] Fix | Delete
*/
[83] Fix | Delete
function _wp_credits_build_object_link( &$data ) {
[84] Fix | Delete
$data = '<a href="' . esc_url( $data[1] ) . '">' . esc_html( $data[0] ) . '</a>';
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Displays the title for a given group of contributors.
[89] Fix | Delete
*
[90] Fix | Delete
* @since 5.3.0
[91] Fix | Delete
*
[92] Fix | Delete
* @param array $group_data The current contributor group.
[93] Fix | Delete
*/
[94] Fix | Delete
function wp_credits_section_title( $group_data = array() ) {
[95] Fix | Delete
if ( ! count( $group_data ) ) {
[96] Fix | Delete
return;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
if ( $group_data['name'] ) {
[100] Fix | Delete
if ( 'Translators' === $group_data['name'] ) {
[101] Fix | Delete
// Considered a special slug in the API response. (Also, will never be returned for en_US.)
[102] Fix | Delete
$title = _x( 'Translators', 'Translate this to be the equivalent of English Translators in your language for the credits page Translators section' );
[103] Fix | Delete
} elseif ( isset( $group_data['placeholders'] ) ) {
[104] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
[105] Fix | Delete
$title = vsprintf( translate( $group_data['name'] ), $group_data['placeholders'] );
[106] Fix | Delete
} else {
[107] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
[108] Fix | Delete
$title = translate( $group_data['name'] );
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
echo '<h2 class="wp-people-group-title">' . esc_html( $title ) . "</h2>\n";
[112] Fix | Delete
}
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
/**
[116] Fix | Delete
* Displays a list of contributors for a given group.
[117] Fix | Delete
*
[118] Fix | Delete
* @since 5.3.0
[119] Fix | Delete
*
[120] Fix | Delete
* @param array $credits The credits groups returned from the API.
[121] Fix | Delete
* @param string $slug The current group to display.
[122] Fix | Delete
*/
[123] Fix | Delete
function wp_credits_section_list( $credits = array(), $slug = '' ) {
[124] Fix | Delete
$group_data = isset( $credits['groups'][ $slug ] ) ? $credits['groups'][ $slug ] : array();
[125] Fix | Delete
$credits_data = $credits['data'];
[126] Fix | Delete
if ( ! count( $group_data ) ) {
[127] Fix | Delete
return;
[128] Fix | Delete
}
[129] Fix | Delete
[130] Fix | Delete
if ( ! empty( $group_data['shuffle'] ) ) {
[131] Fix | Delete
shuffle( $group_data['data'] ); // We were going to sort by ability to pronounce "hierarchical," but that wouldn't be fair to Matt.
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
switch ( $group_data['type'] ) {
[135] Fix | Delete
case 'list':
[136] Fix | Delete
array_walk( $group_data['data'], '_wp_credits_add_profile_link', $credits_data['profiles'] );
[137] Fix | Delete
echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
[138] Fix | Delete
break;
[139] Fix | Delete
case 'libraries':
[140] Fix | Delete
array_walk( $group_data['data'], '_wp_credits_build_object_link' );
[141] Fix | Delete
echo '<p class="wp-credits-list">' . wp_sprintf( '%l.', $group_data['data'] ) . "</p>\n\n";
[142] Fix | Delete
break;
[143] Fix | Delete
default:
[144] Fix | Delete
$compact = 'compact' === $group_data['type'];
[145] Fix | Delete
$classes = 'wp-people-group ' . ( $compact ? 'compact' : '' );
[146] Fix | Delete
echo '<ul class="' . $classes . '" id="wp-people-group-' . $slug . '">' . "\n";
[147] Fix | Delete
foreach ( $group_data['data'] as $person_data ) {
[148] Fix | Delete
echo '<li class="wp-person" id="wp-person-' . esc_attr( $person_data[2] ) . '">' . "\n\t";
[149] Fix | Delete
echo '<a href="' . esc_url( sprintf( $credits_data['profiles'], $person_data[2] ) ) . '" class="web">';
[150] Fix | Delete
$size = $compact ? 40 : 80;
[151] Fix | Delete
$data = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size ) );
[152] Fix | Delete
$data2x = get_avatar_data( $person_data[1] . '@md5.gravatar.com', array( 'size' => $size * 2 ) );
[153] Fix | Delete
echo '<img src="' . esc_url( $data['url'] ) . '" srcset="' . esc_url( $data2x['url'] ) . ' 2x" class="gravatar" alt="" />' . "\n";
[154] Fix | Delete
echo esc_html( $person_data[0] ) . "</a>\n\t";
[155] Fix | Delete
if ( ! $compact ) {
[156] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText
[157] Fix | Delete
echo '<span class="title">' . translate( $person_data[3] ) . "</span>\n";
[158] Fix | Delete
}
[159] Fix | Delete
echo "</li>\n";
[160] Fix | Delete
}
[161] Fix | Delete
echo "</ul>\n";
[162] Fix | Delete
break;
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function