Skip to content
  • Log In
  • Register
WordPress.org
  • News
  • Download & Extend
    • Get WordPress
    • Themes
    • Patterns
    • Plugins
    • Openverse
    • Mobile
    • Hosting
  • Learn
    • Learn WordPress
    • Documentation
    • Forums
    • WordPress.tv
    • Developers
  • Community
    • Make WordPress
    • WordCamp
    • Meetups
    • Photo Directory
    • Job Board
    • Five for the Future
  • About
    • About WordPress
    • Showcase
    • Gutenberg
    • Enterprise
    • WordPress Swag Store
  • Get WordPress
Get WordPress

Developer Resources

Browse: Home / Reference / Classes / WP_Metadata_Lazyloader / WP_Metadata_Lazyloader::queue_objects()

WP_Metadata_Lazyloader::queue_objects( string $object_type, array $object_ids ): void|WP_Error

Adds objects to the metadata lazy-load queue.

Contents

  • Parameters
  • Return
  • Source
  • Hooks
  • Related
    • Uses
  • Changelog
  • User Contributed Notes

Parameters

$object_type string Required
Type of object whose meta is to be lazy-loaded. Accepts 'term' or 'comment'.
$object_ids array Required
Array of object IDs.

Top ↑

Return

void|WP_Error WP_Error on failure.


Top ↑

Source

File: wp-includes/class-wp-metadata-lazyloader.php. View all references

public function queue_objects( $object_type, $object_ids ) {
	if ( ! isset( $this->settings[ $object_type ] ) ) {
		return new WP_Error( 'invalid_object_type', __( 'Invalid object type.' ) );
	}

	$type_settings = $this->settings[ $object_type ];

	if ( ! isset( $this->pending_objects[ $object_type ] ) ) {
		$this->pending_objects[ $object_type ] = array();
	}

	foreach ( $object_ids as $object_id ) {
		// Keyed by ID for faster lookup.
		if ( ! isset( $this->pending_objects[ $object_type ][ $object_id ] ) ) {
			$this->pending_objects[ $object_type ][ $object_id ] = 1;
		}
	}

	add_filter( $type_settings['filter'], $type_settings['callback'] );

	/**
	 * Fires after objects are added to the metadata lazy-load queue.
	 *
	 * @since 4.5.0
	 *
	 * @param array                  $object_ids  Array of object IDs.
	 * @param string                 $object_type Type of object being queued.
	 * @param WP_Metadata_Lazyloader $lazyloader  The lazy-loader object.
	 */
	do_action( 'metadata_lazyloader_queued_objects', $object_ids, $object_type, $this );
}

View on Trac View on GitHub


Top ↑

Hooks

do_action( 'metadata_lazyloader_queued_objects', array $object_ids, string $object_type, WP_Metadata_Lazyloader $lazyloader )

Fires after objects are added to the metadata lazy-load queue.


Top ↑

Related

Top ↑

Uses

Uses
Uses Description
__() wp-includes/l10n.php

Retrieves the translation of $text.

add_filter() wp-includes/plugin.php

Adds a callback function to a filter hook.

do_action() wp-includes/plugin.php

Calls the callback functions that have been added to an action hook.

WP_Error::__construct() wp-includes/class-wp-error.php

Initializes the error.

Show 2 more uses Hide more uses

Top ↑

Changelog

Changelog
Version Description
4.5.0 Introduced.

Top ↑

User Contributed Notes

You must log in before being able to contribute a note or feedback.

  • About
  • News
  • Hosting
  • Donate
  • Swag
  • Documentation
  • Developers
  • Get Involved
  • Learn
  • Showcase
  • Plugins
  • Themes
  • Patterns
  • WordCamp
  • WordPress.TV
  • BuddyPress
  • bbPress
  • WordPress.com
  • Matt
  • Privacy
  • Public Code
WordPress.org
WordPress.org
  • Visit our Facebook page
  • Visit our Twitter account
  • Visit our Instagram account
  • Visit our LinkedIn account
Code is Poetry

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.