Make WordPress Core


Ignore:
Timestamp:
12/14/2021 04:12:57 PM (4 years ago)
Author:
hellofromTonya
Message:

Themes: Rename public static functions in WP_Theme_JSON_Resolver to remove custom_post_type references.

WordPress Core is not really custom and does not reference "custom post type" in its function naming. This commit renames 2 public static methods:

  • WP_Theme_JSON_Resolver::get_user_custom_post_type_id() renamed to WP_Theme_JSON_Resolver::get_user_global_styles_post_id().
  • WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type() renamed to WP_Theme_JSON_Resolver:: get_user_data_from_wp_global_styles().

Follow-up to [52049], [52051], [52069], [52232], [52275], [52364].

Props antonvlasenko, bernhard-reiter, costdev, desrosj, hellofromTonya, noisysocks, oandregal, SergeyBiryukov.
Fixes #54517.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json-resolver.php

    r52323 r52372  
    226226     * @param WP_Theme $theme              The theme object. If empty, it
    227227     *                                     defaults to the current theme.
    228      * @param bool     $should_create_cpt  Optional. Whether a new custom post
     228     * @param bool     $create_post        Optional. Whether a new custom post
    229229     *                                     type should be created if none are
    230230     *                                     found. Default false.
     
    234234     * @return array Custom Post Type for the user's origin config.
    235235     */
    236     public static function get_user_data_from_custom_post_type( $theme, $should_create_cpt = false, $post_status_filter = array( 'publish' ) ) {
     236    public static function get_user_data_from_wp_global_styles( $theme, $create_post = false, $post_status_filter = array( 'publish' ) ) {
    237237        if ( ! $theme instanceof WP_Theme ) {
    238238            $theme = wp_get_theme();
     
    263263
    264264        // Special case: '-1' is a results not found.
    265         if ( -1 === $post_id && ! $should_create_cpt ) {
     265        if ( -1 === $post_id && ! $create_post ) {
    266266            return $user_cpt;
    267267        }
     
    270270        if ( is_array( $recent_posts ) && ( count( $recent_posts ) === 1 ) ) {
    271271            $user_cpt = $recent_posts[0];
    272         } elseif ( $should_create_cpt ) {
     272        } elseif ( $create_post ) {
    273273            $cpt_post_id = wp_insert_post(
    274274                array(
     
    297297     * @since 5.9.0
    298298     *
    299      * @return WP_Theme_JSON Entity that holds user data.
     299     * @return WP_Theme_JSON Entity that holds styles for user data.
    300300     */
    301301    public static function get_user_data() {
     
    305305
    306306        $config   = array();
    307         $user_cpt = self::get_user_data_from_custom_post_type( wp_get_theme() );
     307        $user_cpt = self::get_user_data_from_wp_global_styles( wp_get_theme() );
    308308
    309309        if ( array_key_exists( 'post_content', $user_cpt ) ) {
     
    382382     * @return integer|null
    383383     */
    384     public static function get_user_custom_post_type_id() {
     384    public static function get_user_global_styles_post_id() {
    385385        if ( null !== self::$user_custom_post_type_id ) {
    386386            return self::$user_custom_post_type_id;
    387387        }
    388388
    389         $user_cpt = self::get_user_data_from_custom_post_type( wp_get_theme(), true );
     389        $user_cpt = self::get_user_data_from_wp_global_styles( wp_get_theme(), true );
    390390
    391391        if ( array_key_exists( 'ID', $user_cpt ) ) {
Note: See TracChangeset for help on using the changeset viewer.