Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: Improve inline comments
Increase consistency, focus on explaining the reason for the referenced
code.
  • Loading branch information
dcalhoun committed Aug 14, 2024
commit 4d6eaccbe8d5d1ffd2450c8ff781d2188abc7c87
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,9 @@ public function register_routes() {
public function get_items($request) {
global $wp_styles, $wp_scripts;

// Keep track of the styles and scripts instance to restore later.
$current_wp_styles = $wp_styles;
$current_wp_scripts = $wp_scripts;

// Create new instances to collect the assets.
$wp_styles = new WP_Styles();
$wp_scripts = new WP_Scripts();

Expand All @@ -63,10 +61,10 @@ public function get_items($request) {
$wp_styles->registered = isset($current_wp_styles->registered) ? $current_wp_styles->registered : array();
$wp_scripts->registered = isset($current_wp_scripts->registered) ? $current_wp_scripts->registered : array();

// We generally do not need reset styles for the iframed editor.
// However, if it's a classic theme, margins will be added to every block,
// which is reset specifically for list items, so classic themes rely on
// these reset styles.
// We generally do not need reset styles for the block editor. However, if
// it's a classic theme, margins will be added to every block, which is
// reset specifically for list items, so classic themes rely on these
// reset styles.
$wp_styles->done =
wp_theme_has_theme_json() ? array( 'wp-reset-editor-styles' ) : array();

Expand All @@ -78,14 +76,13 @@ public function get_items($request) {
wp_enqueue_style( 'wp-block-library-theme' );
}

// Enqueue frequent dependent, admin-only `dashicon` asset
// Enqueue frequent dependent, admin-only `dashicon` asset.
wp_enqueue_style( 'dashicons' );

// Enqueue frequent dependent, admin-only `postbox` asset
// Enqueue frequent dependent, admin-only `postbox` asset.
$suffix = wp_scripts_get_suffix();
wp_enqueue_script( 'postbox', "/wp-admin/js/postbox$suffix.js", array( 'jquery-ui-sortable', 'wp-a11y' ), false, 1 );

// Enqueue both block and block editor assets.
add_filter( 'should_load_block_editor_scripts_and_styles', '__return_true' );
do_action( 'enqueue_block_assets' );
do_action( 'enqueue_block_editor_assets' );
Expand All @@ -108,10 +105,8 @@ public function get_items($request) {
}
}

/**
* Remove the deprecated `print_emoji_styles` handler.
* It avoids breaking style generation with a deprecation message.
*/
// Remove the deprecated `print_emoji_styles` handler. It avoids breaking
// style generation with a deprecation message.
$has_emoji_styles = has_action( 'wp_print_styles', 'print_emoji_styles' );
if ( $has_emoji_styles ) {
remove_action( 'wp_print_styles', 'print_emoji_styles' );
Expand All @@ -130,7 +125,6 @@ public function get_items($request) {
wp_print_footer_scripts();
$scripts = ob_get_clean();

// Restore the original instances.
$wp_styles = $current_wp_styles;
$wp_scripts = $current_wp_scripts;

Expand Down