Making WordPress.org

Changeset 12776


Ignore:
Timestamp:
08/01/2023 10:18:53 PM (16 months ago)
Author:
coffee2code
Message:

Photo Directory, Admin: Output admin body class of 'post-type-photo' when applicable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/admin.php

    r12772 r12776  
    7070        add_action( 'edit_form_top',                           [ __CLASS__, 'show_moderation_message' ] );
    7171        add_filter( 'redirect_post_location',                  [ __CLASS__, 'redirect_to_next_post_after_moderation' ], 5, 2 );
     72
     73        // Add class(es) to body tag.
     74        add_filter( 'admin_body_class',                        [ __CLASS__, 'add_body_class' ] );
    7275    }
    7376
     
    12491252    }
    12501253
     1254    /**
     1255     * Amends body tag with additional classes.
     1256     *
     1257     * @param string $classes Body classes.
     1258     * @return string
     1259     */
     1260    public static function add_body_class( $classes ) {
     1261        $post_type = Registrations::get_post_type();
     1262        if (
     1263            // Post listing of photos.
     1264            filter_input(INPUT_GET, 'post_type') === $post_type
     1265        ||
     1266            // Editing a photo post.
     1267            ( ( $post_id = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT) ) && get_post_type( $post_id ) === $post_type )
     1268        ) {
     1269            $classes .= ' post-type-photo';
     1270        }
     1271
     1272        return $classes;
     1273    }
     1274
    12511275}
    12521276
Note: See TracChangeset for help on using the changeset viewer.