Making WordPress.org


Ignore:
Timestamp:
09/24/2021 06:47:29 PM (3 years ago)
Author:
coreymckrill
Message:

WordPress.org Learn: Sync with GitHub

Props ronalfy

https://github.com/WordPress/learn/compare/7b3890692153b1036440ed363fde3f3763d96b91...b604cfdd398923f62e8fa857c1a8b359a2dd1028

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-learn-2020/functions.php

    r10926 r11256  
    627627
    628628/**
    629  * Get the bio of a user, either from profiles.wordpress.org or usermeta.
    630  *
    631  * This relies on the availability of the `bpmain_bp_xprofile_data` table, so for local environments
    632  * it falls back on values in `usermeta`.
    633  *
    634  * @param WP_User $user
     629 * Get the bio of a user, first trying usermeta and then profiles.wordpress.org.
     630 *
     631 * The `usermeta` bio (description) field will be pulled. If there is no bio, profiles.wordpress.org is tried.
     632 * The bio at profiles.wordpress.org relies on the availability of the `bpmain_bp_xprofile_data` table.
     633 * For local environments the bio will only pull from `usermeta`.
     634 *
     635 * @param WP_User $user The user to retrieve a bio for.
    635636 *
    636637 * @return string
     
    639640    global $wpdb;
    640641
    641     $bio = '';
    642 
    643     if ( 'local' !== wp_get_environment_type() ) {
     642    // Retrieve bio from user data.
     643    $bio = $user->description;
     644
     645    // If bio is empty, retrieve from .org.
     646    if ( ! $bio && 'local' !== wp_get_environment_type() ) {
    644647        $xprofile_field_id = 3;
    645648
     
    656659
    657660        $bio = $wpdb->get_var( $sql ) ?: ''; // phpcs:ignore WordPress.DB.PreparedSQL -- prepare called above.
    658     }
    659 
    660     if ( ! $bio ) {
    661         $bio = $user->description;
    662661    }
    663662
     
    854853}
    855854add_filter( 'syntaxhighlighter_htmlresult', 'wporg_learn_fix_code_entity_encoding', 20 );
     855
     856/**
     857 * Add fallback image to Jetpack when no featured image exists.
     858 *
     859 * @param string $default_image The default image URL.
     860 *
     861 * @return string Image URL.
     862 */
     863function wporg_learn_return_default_image( $default_image ) {
     864    return 'https://s.w.org/images/learn-thumbnail-fallback.jpg';
     865}
     866add_action( 'jetpack_open_graph_image_default', 'wporg_learn_return_default_image', 15, 1 );
Note: See TracChangeset for help on using the changeset viewer.