Make WordPress Core

Ticket #51513: 51513.diff

File 51513.diff, 5.8 KB (added by SergeyBiryukov, 5 years ago)
  • src/wp-admin/authorize-application.php

     
    7070        );
    7171}
    7272
    73 if ( ! wp_is_application_passwords_available_for_user( $user ) ) {
    74         if ( wp_is_application_passwords_available() ) {
     73if ( ! wp_application_passwords_enabled_for_user( $user ) ) {
     74        if ( wp_application_passwords_enabled() ) {
    7575                $message = __( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' );
    7676        } else {
    7777                $message = __( 'Application passwords are not enabled.' );
  • src/wp-admin/user-edit.php

     
    2727
    2828wp_enqueue_script( 'user-profile' );
    2929
    30 if ( wp_is_application_passwords_available_for_user( $user_id ) ) {
     30if ( wp_application_passwords_enabled_for_user( $user_id ) ) {
    3131        wp_enqueue_script( 'application-passwords' );
    3232}
    3333
     
    707707        </table>
    708708
    709709
    710                 <?php if ( wp_is_application_passwords_available_for_user( $user_id ) ) : ?>
     710                <?php if ( wp_application_passwords_enabled_for_user( $user_id ) ) : ?>
    711711        <div class="application-passwords hide-if-no-js" id="application-passwords-section">
    712712                <h2><?php _e( 'Application Passwords' ); ?></h2>
    713713                <p><?php _e( 'Application passwords allow authentication via non-interactive systems, such as XML-RPC or the REST API, without providing your actual password. Application passwords can be easily revoked. They cannot be used for traditional logins to your website.' ); ?></p>
  • src/wp-includes/rest-api.php

     
    11001100 * @return WP_REST_Response
    11011101 */
    11021102function rest_add_application_passwords_to_index( $response ) {
    1103         if ( ! wp_is_application_passwords_available() ) {
     1103        if ( ! wp_application_passwords_enabled() ) {
    11041104                return $response;
    11051105        }
    11061106
  • src/wp-includes/rest-api/endpoints/class-wp-rest-application-passwords-controller.php

     
    495495         * @return WP_User|WP_Error The WordPress user associated with the request, or a WP_Error if none found.
    496496         */
    497497        protected function get_user( $request ) {
    498                 if ( ! wp_is_application_passwords_available() ) {
     498                if ( ! wp_application_passwords_enabled() ) {
    499499                        return new WP_Error(
    500500                                'application_passwords_disabled',
    501501                                __( 'Application passwords are not enabled.' ),
     
    539539                        return $error;
    540540                }
    541541
    542                 if ( ! wp_is_application_passwords_available_for_user( $user ) ) {
     542                if ( ! wp_application_passwords_enabled_for_user( $user ) ) {
    543543                        return new WP_Error(
    544544                                'application_passwords_disabled_for_user',
    545545                                __( 'Application passwords are not enabled for your account. Please contact the site administrator for assistance.' ),
  • src/wp-includes/user.php

     
    350350                                __( 'Unknown username. Check again or try your email address.' )
    351351                        );
    352352                }
    353         } elseif ( ! wp_is_application_passwords_available_for_user( $user ) ) {
     353        } elseif ( ! wp_application_passwords_enabled_for_user( $user ) ) {
    354354                $error = new WP_Error(
    355355                        'application_passwords_disabled',
    356356                        __( 'Application passwords are disabled for the requested user.' )
     
    448448                return $input_user;
    449449        }
    450450
    451         if ( ! wp_is_application_passwords_available() ) {
     451        if ( ! wp_application_passwords_enabled() ) {
    452452                return $input_user;
    453453        }
    454454
     
    40984098 * Checks if Application Passwords is globally available.
    40994099 *
    41004100 * By default, Application Passwords is available to all sites using SSL or to local environments.
    4101  * Use {@see 'wp_is_application_passwords_available'} to adjust its availability.
     4101 * Use {@see 'wp_application_passwords_enabled'} to adjust its availability.
    41024102 *
    41034103 * @since 5.6.0
    41044104 *
    41054105 * @return bool
    41064106 */
    4107 function wp_is_application_passwords_available() {
     4107function wp_application_passwords_enabled() {
    41084108        $available = is_ssl() || 'local' === wp_get_environment_type();
    41094109
    41104110        /**
     
    41144114         *
    41154115         * @param bool $available True if available, false otherwise.
    41164116         */
    4117         return apply_filters( 'wp_is_application_passwords_available', $available );
     4117        return apply_filters( 'wp_application_passwords_enabled', $available );
    41184118}
    41194119
    41204120/**
    41214121 * Checks if Application Passwords is enabled for a specific user.
    41224122 *
    4123  * By default all users can use Application Passwords. Use {@see 'wp_is_application_passwords_available_for_user'}
     4123 * By default all users can use Application Passwords. Use {@see 'wp_application_passwords_enabled_for_user'}
    41244124 * to restrict availability to certain users.
    41254125 *
    41264126 * @since 5.6.0
     
    41284128 * @param int|WP_User $user The user to check.
    41294129 * @return bool
    41304130 */
    4131 function wp_is_application_passwords_available_for_user( $user ) {
    4132         if ( ! wp_is_application_passwords_available() ) {
     4131function wp_application_passwords_enabled_for_user( $user ) {
     4132        if ( ! wp_application_passwords_enabled() ) {
    41334133                return false;
    41344134        }
    41354135
     
    41494149         * @param bool    $available True if available, false otherwise.
    41504150         * @param WP_User $user      The user to check.
    41514151         */
    4152         return apply_filters( 'wp_is_application_passwords_available_for_user', true, $user );
     4152        return apply_filters( 'wp_application_passwords_enabled_for_user', true, $user );
    41534153}