ring $output Optional. The required return type. One of OBJECT, ARRAY_A, or ARRAY_N, which * correspond to a WP_Post object, an associative array, or a numeric array, * respectively. Default OBJECT. * @param string $filter Optional sanitization filter. See sanitize_post(). Default 'raw'. * @return WP_Post|array|null WP_Post (or array) on success, or null on failure. */ function wp_get_post_revision( &$post, $output = OBJECT, $filter = 'raw' ) { $revision = get_post( $post, OBJECT, $filter ); if ( ! $revision ) { return $revision; } if ( 'revision' !== $revision->post_type ) { return null; } if ( OBJECT === $output ) { return $revision; } elseif ( ARRAY_A === $output ) { $_revision = get_object_vars( $revision ); return $_revision; } elseif ( ARRAY_N === $output ) { $_revision = array_values( get_object_vars( $revision ) ); return $_revision; } return $revision; } /** * Restores a post to the specified revision. * * Can restore a past revision using all fields of the post revision, or only selected fields. * * @since 2.6.0 * * @param int|WP_Post $revision Revision ID or revision object. * @param array $fields Optional. What fields to restore from. Defaults to all. * @return int|false|null Null if error, false if no fields to restore, (int) post ID if success. */ function wp_restore_post_revision( $revision, $fields = null ) { $revision = wp_get_post_revision( $revision, ARRAY_A ); if ( ! $revision ) { return $revision; } if ( ! is_array( $fields ) ) { $fields = array_keys( _wp_post_revision_fields( $revision ) ); } $update = array(); foreach ( array_intersect( array_keys( $revision ), $fields ) as $field ) { $update[ $field ] = $revision[ $field ]; } if ( ! $update ) { return false; } $update['ID'] = $revision['post_parent']; $update = wp_slash( $update ); // Since data is from DB. $post_id = wp_update_post( $update ); if ( ! $post_id || is_wp_error( $post_id ) ) { return $post_id; } // Update last edit user. update_post_meta( $post_id, '_edit_last', get_current_user_id() ); /** * Fires after a post revision has been restored. * * @since 2.6.0 * * @param int $post_id Post ID. * @param int $revision_id Post revision ID. */ do_action( 'wp_restore_post_revision', $post_id, $revision['ID'] ); return $post_id; } /** * Restore the revisioned meta values for a post. * * @since 6.4.0 * * @param int $post_id The ID of the post to restore the meta to. * @param int $revision_id The ID of the revision to restore the meta from. */ function wp_restore_post_revision_meta( $post_id, $revision_id ) { $post_type = get_post_type( $post_id ); if ( ! $post_type ) { return; } // Restore revisioned meta fields. foreach ( wp_post_revision_meta_keys( $post_type ) as $meta_key ) { // Clear any existing meta. delete_post_meta( $post_id, $meta_key ); _wp_copy_post_meta( $revision_id, $post_id, $meta_key ); } } /** * Copy post meta for the given key from one post to another. * * @since 6.4.0 * * @param int $source_post_id Post ID to copy meta value(s) from. * @param int $target_post_id Post ID to copy meta value(s) to. * @param string $meta_key Meta key to copy. */ function _wp_copy_post_meta( $source_post_id, $target_post_id, $meta_key ) { foreach ( get_post_meta( $source_post_id, $meta_key ) as $meta_value ) { /** * We use add_metadata() function vs add_post_meta() here * to allow for a revision post target OR regular post. */ add_metadata( 'post', $target_post_id, $meta_key, wp_slash( $meta_value ) ); } } /** * Determine which post meta fields should be revisioned. * * @since 6.4.0 * * @param string $post_type The post type being revisioned. * @return array An array of meta keys to be revisioned. */ function wp_post_revision_meta_keys( $post_type ) { $registered_meta = array_merge( get_registered_meta_keys( 'post' ), get_registered_meta_keys( 'post', $post_type ) ); $wp_revisioned_meta_keys = array(); foreach ( $registered_meta as $name => $args ) { if ( $args['revisions_enabled'] ) { $wp_revisioned_meta_keys[ $name ] = true; } } $wp_revisioned_meta_keys = array_keys( $wp_revisioned_meta_keys ); /** * Filter the list of post meta keys to be revisioned. * * @since 6.4.0 * * @param array $keys An array of meta fields to be revisioned. * @param string $post_type The post type being revisioned. */ return apply_filters( 'wp_post_revision_meta_keys', $wp_revisioned_meta_keys, $post_type ); } /** * Check whether revisioned post meta fields have changed. * * @since 6.4.0 * * @param bool $post_has_changed Whether the post has changed. * @param WP_Post $last_revision The last revision post object. * @param WP_Post $post The post object. * @return bool Whether the post has changed. */ function wp_check_revisioned_meta_fields_have_changed( $post_has_changed, WP_Post $last_revision, WP_Post $post ) { foreach ( wp_post_revision_meta_keys( $post->post_type ) as $meta_key ) { if ( get_post_meta( $post->ID, $meta_key ) !== get_post_meta( $last_revision->ID, $meta_key ) ) { $post_has_changed = true; break; } } return $post_has_changed; } /** * Deletes a revision. * * Deletes the row from the posts table corresponding to the specified revision. * * @since 2.6.0 * * @param int|WP_Post $revision Revision ID or revision object. * @return WP_Post|false|null Null or false if error, deleted post object if success. */ function wp_delete_post_revision( $revision ) { $revision = wp_get_post_revision( $revision ); if ( ! $revision ) { return $revision; } $delete = wp_delete_post( $revision->ID ); if ( $delete ) { /** * Fires once a post revision has been deleted. * * @since 2.6.0 * * @param int $revision_id Post revision ID. * @param WP_Post $revision Post revision object. */ do_action( 'wp_delete_post_revision', $revision->ID, $revision ); } return $delete; } /** * Returns all revisions of specified post. * * @since 2.6.0 * * @see get_children() * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. * @param array|null $args Optional. Arguments for retrieving post revisions. Default null. * @return WP_Post[]|int[] Array of revision objects or IDs, or an empty array if none. */ function wp_get_post_revisions( $post = 0, $args = null ) { $post = get_post( $post ); if ( ! $post || empty( $post->ID ) ) { return array(); } $defaults = array( 'order' => 'DESC', 'orderby' => 'date ID', 'check_enabled' => true, ); $args = wp_parse_args( $args, $defaults ); if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) ) { return array(); } $args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit', ) ); $revisions = get_children( $args ); if ( ! $revisions ) { return array(); } return $revisions; } /** * Returns the latest revision ID and count of revisions for a post. * * @since 6.1.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. * @return array|WP_Error { * Returns associative array with latest revision ID and total count, * or a WP_Error if the post does not exist or revisions are not enabled. * * @type int $latest_id The latest revision post ID or 0 if no revisions exist. * @type int $count The total count of revisions for the given post. * } */ function wp_get_latest_revision_id_and_total_count( $post = 0 ) { $post = get_post( $post ); if ( ! $post ) { return new WP_Error( 'invalid_post', __( 'Invalid post.' ) ); } if ( ! wp_revisions_enabled( $post ) ) { return new WP_Error( 'revisions_not_enabled', __( 'Revisions not enabled.' ) ); } $args = array( 'post_parent' => $post->ID, 'fields' => 'ids', 'post_type' => 'revision', 'post_status' => 'inherit', 'order' => 'DESC', 'orderby' => 'date ID', 'posts_per_page' => 1, 'ignore_sticky_posts' => true, ); $revision_query = new WP_Query(); $revisions = $revision_query->query( $args ); if ( ! $revisions ) { return array( 'latest_id' => 0, 'count' => 0, ); } return array( 'latest_id' => $revisions[0], 'count' => $revision_query->found_posts, ); } /** * Returns the url for viewing and potentially restoring revisions of a given post. * * @since 5.9.0 * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. * @return string|null The URL for editing revisions on the given post, otherwise null. */ function wp_get_post_revisions_url( $post = 0 ) { $post = get_post( $post ); if ( ! $post instanceof WP_Post ) { return null; } // If the post is a revision, return early. if ( 'revision' === $post->post_type ) { return get_edit_post_link( $post ); } if ( ! wp_revisions_enabled( $post ) ) { return null; } $revisions = wp_get_latest_revision_id_and_total_count( $post->ID ); if ( is_wp_error( $revisions ) || 0 === $revisions['count'] ) { return null; } return get_edit_post_link( $revisions['latest_id'] ); } /** * Determines whether revisions are enabled for a given post. * * @since 3.6.0 * * @param WP_Post $post The post object. * @return bool True if number of revisions to keep isn't zero, false otherwise. */ function wp_revisions_enabled( $post ) { return wp_revisions_to_keep( $post ) !== 0; } /** * Determines how many revisions to retain for a given post. * * By default, an infinite number of revisions are kept. * * The constant WP_POST_REVISIONS can be set in wp-config to specify the limit * of revisions to keep. * * @since 3.6.0 * * @param WP_Post $post The post object. * @return int The number of revisions to keep. */ function wp_revisions_to_keep( $post ) { $num = WP_POST_REVISIONS; if ( true === $num ) { $num = -1; } else { $num = (int) $num; } if ( ! post_type_supports( $post->post_type, 'revisions' ) ) { $num = 0; } /** * Filters the number of revisions to save for the given post. * * Overrides the value of WP_POST_REVISIONS. * * @since 3.6.0 * * @param int $num Number of revisions to store. * @param WP_Post $post Post object. */ $num = apply_filters( 'wp_revisions_to_keep', $num, $post ); /** * Filters the number of revisions to save for the given post by its post type. * * Overrides both the value of WP_POST_REVISIONS and the {@see 'wp_revisions_to_keep'} filter. * * The dynamic portion of the hook name, `$post->post_type`, refers to * the post type slug. * * Possible hook names include: * * - `wp_post_revisions_to_keep` * - `wp_page_revisions_to_keep` * * @since 5.8.0 * * @param int $num Number of revisions to store. * @param WP_Post $post Post object. */ $num = apply_filters( "wp_{$post->post_type}_revisions_to_keep", $num, $post ); return (int) $num; } /** * Sets up the post object for preview based on the post autosave. * * @since 2.7.0 * @access private * * @param WP_Post $post * @return WP_Post|false */ function _set_preview( $post ) { if ( ! is_object( $post ) ) { return $post; } $preview = wp_get_post_autosave( $post->ID ); if ( is_object( $preview ) ) { $preview = sanitize_post( $preview ); $post->post_content = $preview->post_content; $post->post_title = $preview->post_title; $post->post_excerpt = $preview->post_excerpt; } add_filter( 'get_the_terms', '_wp_preview_terms_filter', 10, 3 ); add_filter( 'get_post_metadata', '_wp_preview_post_thumbnail_filter', 10, 3 ); add_filter( 'get_post_metadata', '_wp_preview_meta_filter', 10, 4 ); return $post; } /** * Filters the latest content for preview from the post autosave. * * @since 2.7.0 * @access private */ function _show_post_preview() { if ( isset( $_GET['preview_id'] ) && isset( $_GET['preview_nonce'] ) ) { $id = (int) $_GET['preview_id']; if ( false === wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $id ) ) { wp_die( __( 'Sorry, you are not allowed to preview drafts.' ), 403 ); } add_filter( 'the_preview', '_set_preview' ); } } /** * Filters terms lookup to set the post format. * * @since 3.6.0 * @access private * * @param array $terms * @param int $post_id * @param string $taxonomy * @return array */ function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) { $post = get_post(); if ( ! $post ) { return $terms; } if ( empty( $_REQUEST['post_format'] ) || $post->ID !== $post_id || 'post_format' !== $taxonomy || 'revision' === $post->post_type ) { return $terms; } if ( 'standard' === $_REQUEST['post_format'] ) { $terms = array(); } else { $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ); if ( $term ) { $terms = array( $term ); // Can only have one post format. } } return $terms; } /** * Filters post thumbnail lookup to set the post thumbnail. * * @since 4.6.0 * @access private * * @param null|array|string $value The value to return - a single metadata value, or an array of values. * @param int $post_id Post ID. * @param string $meta_key Meta key. * @return null|array The default return value or the post thumbnail meta array. */ function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) { $post = get_post(); if ( ! $post ) { return $value; } if ( empty( $_REQUEST['_thumbnail_id'] ) || empty( $_REQUEST['preview_id'] ) || $post->ID !== $post_id || $post_id !== (int) $_REQUEST['preview_id'] || '_thumbnail_id' !== $meta_key || 'revision' === $post->post_type ) { return $value; } $thumbnail_id = (int) $_REQUEST['_thumbnail_id']; if ( $thumbnail_id <= 0 ) { return ''; } return (string) $thumbnail_id; } /** * Gets the post revision version. * * @since 3.6.0 * @access private * * @param WP_Post $revision * @return int|false */ function _wp_get_post_revision_version( $revision ) { if ( is_object( $revision ) ) { $revision = get_object_vars( $revision ); } elseif ( ! is_array( $revision ) ) { return false; } if ( preg_match( '/^\d+-(?:autosave|revision)-v(\d+)$/', $revision['post_name'], $matches ) ) { return (int) $matches[1]; } return 0; } /** * Upgrades the revisions author, adds the current post as a revision and sets the revisions version to 1. * * @since 3.6.0 * @access private * * @global wpdb $wpdb WordPress database abstraction object. * * @param WP_Post $post Post object. * @param array $revisions Current revisions of the post. * @return bool true if the revisions were upgraded, false if problems. */ function _wp_upgrade_revisions_of_post( $post, $revisions ) { global $wpdb; // Add post option exclusively. $lock = "revision-upgrade-{$post->ID}"; $now = time(); $result = $wpdb->query( $wpdb->prepare( "INSERT IGNORE INTO `$wpdb->options` (`option_name`, `option_value`, `autoload`) VALUES (%s, %s, 'no') /* LOCK */", $lock, $now ) ); if ( ! $result ) { // If we couldn't get a lock, see how old the previous lock is. $locked = get_option( $lock ); if ( ! $locked ) { /* * Can't write to the lock, and can't read the lock. * Something broken has happened. */ return false; } if ( $locked > $now - HOUR_IN_SECONDS ) { // Lock is not too old: some other process may be upgrading this post. Bail. return false; } // Lock is too old - update it (below) and continue. } // If we could get a lock, re-"add" the option to fire all the correct filters. update_option( $lock, $now ); reset( $revisions ); $add_last = true; do { $this_revision = current( $revisions ); $prev_revision = next( $revisions ); $this_revision_version = _wp_get_post_revision_version( $this_revision ); // Something terrible happened. if ( false === $this_revision_version ) { continue; } /* * 1 is the latest revision version, so we're already up to date. * No need to add a copy of the post as latest revision. */ if ( 0 < $this_revision_version ) { $add_last = false; continue; } // Always update the revision version. $update = array( 'post_name' => preg_replace( '/^(\d+-(?:autosave|revision))[\d-]*$/', '$1-v1', $this_revision->post_name ), ); /* * If this revision is the oldest revision of the post, i.e. no $prev_revision, * the correct post_author is probably $post->post_author, but that's only a good guess. * Update the revision version only and Leave the author as-is. */ if ( $prev_revision ) { $prev_revision_version = _wp_get_post_revision_version( $prev_revision ); // If the previous revision is already up to date, it no longer has the information we need :( if ( $prev_revision_version < 1 ) { $update['post_author'] = $prev_revision->post_author; } } // Upgrade this revision. $result = $wpdb->update( $wpdb->posts, $update, array( 'ID' => $this_revision->ID ) ); if ( $result ) { wp_cache_delete( $this_revision->ID, 'posts' ); } } while ( $prev_revision ); delete_option( $lock ); // Add a copy of the post as latest revision. if ( $add_last ) { wp_save_post_revision( $post->ID ); } return true; } /** * Filters preview post meta retrieval to get values from the autosave. * * Filters revisioned meta keys only. * * @since 6.4.0 * * @param mixed $value Meta value to filter. * @param int $object_id Object ID. * @param string $meta_key Meta key to filter a value for. * @param bool $single Whether to return a single value. Default false. * @return mixed Original meta value if the meta key isn't revisioned, the object doesn't exist, * the post type is a revision or the post ID doesn't match the object ID. * Otherwise, the revisioned meta value is returned for the preview. */ function _wp_preview_meta_filter( $value, $object_id, $meta_key, $single ) { $post = get_post(); if ( empty( $post ) || $post->ID !== $object_id || ! in_array( $meta_key, wp_post_revision_meta_keys( $post->post_type ), true ) || 'revision' === $post->post_type ) { return $value; } $preview = wp_get_post_autosave( $post->ID ); if ( false === $preview ) { return $value; } return get_post_meta( $preview->ID, $meta_key, $single ); } $group Optional. Group level: level (int), no group (false). * Default false. * @return bool True on success, false on failure. */ public function all_deps( $handles, $recursion = false, $group = false ) { $handles = (array) $handles; if ( ! $handles ) { return false; } foreach ( $handles as $handle ) { $handle_parts = explode( '?', $handle ); $handle = $handle_parts[0]; $queued = in_array( $handle, $this->to_do, true ); if ( in_array( $handle, $this->done, true ) ) { // Already done. continue; } $moved = $this->set_group( $handle, $recursion, $group ); $new_group = $this->groups[ $handle ]; if ( $queued && ! $moved ) { // Already queued and in the right group. continue; } $keep_going = true; if ( ! isset( $this->registered[ $handle ] ) ) { $keep_going = false; // Item doesn't exist. } elseif ( $this->registered[ $handle ]->deps && array_diff( $this->registered[ $handle ]->deps, array_keys( $this->registered ) ) ) { $keep_going = false; // Item requires dependencies that don't exist. } elseif ( $this->registered[ $handle ]->deps && ! $this->all_deps( $this->registered[ $handle ]->deps, true, $new_group ) ) { $keep_going = false; // Item requires dependencies that don't exist. } if ( ! $keep_going ) { // Either item or its dependencies don't exist. if ( $recursion ) { return false; // Abort this branch. } else { continue; // We're at the top level. Move on to the next one. } } if ( $queued ) { // Already grabbed it and its dependencies. continue; } if ( isset( $handle_parts[1] ) ) { $this->args[ $handle ] = $handle_parts[1]; } $this->to_do[] = $handle; } return true; } /** * Register an item. * * Registers the item if no item of that name already exists. * * @since 2.1.0 * @since 2.6.0 Moved from `WP_Scripts`. * * @param string $handle Name of the item. Should be unique. * @param string|false $src Full URL of the item, or path of the item relative * to the WordPress root directory. If source is set to false, * the item is an alias of other items it depends on. * @param string[] $deps Optional. An array of registered item handles this item depends on. * Default empty array. * @param string|bool|null $ver Optional. String specifying item version number, if it has one, * which is added to the URL as a query string for cache busting purposes. * If version is set to false, a version number is automatically added * equal to current installed WordPress version. * If set to null, no version is added. * @param mixed $args Optional. Custom property of the item. NOT the class property $args. * Examples: $media, $in_footer. * @return bool Whether the item has been registered. True on success, false on failure. */ public function add( $handle, $src, $deps = array(), $ver = false, $args = null ) { if ( isset( $this->registered[ $handle ] ) ) { return false; } $this->registered[ $handle ] = new _WP_Dependency( $handle, $src, $deps, $ver, $args ); // If the item was enqueued before the details were registered, enqueue it now. if ( array_key_exists( $handle, $this->queued_before_register ) ) { if ( ! is_null( $this->queued_before_register[ $handle ] ) ) { $this->enqueue( $handle . '?' . $this->queued_before_register[ $handle ] ); } else { $this->enqueue( $handle ); } unset( $this->queued_before_register[ $handle ] ); } return true; } /** * Add extra item data. * * Adds data to a registered item. * * @since 2.6.0 * * @param string $handle Name of the item. Should be unique. * @param string $key The data key. * @param mixed $value The data value. * @return bool True on success, false on failure. */ public function add_data( $handle, $key, $value ) { if ( ! isset( $this->registered[ $handle ] ) ) { return false; } return $this->registered[ $handle ]->add_data( $key, $value ); } /** * Get extra item data. * * Gets data associated with a registered item. * * @since 3.3.0 * * @param string $handle Name of the item. Should be unique. * @param string $key The data key. * @return mixed Extra item data (string), false otherwise. */ public function get_data( $handle, $key ) { if ( ! isset( $this->registered[ $handle ] ) ) { return false; } if ( ! isset( $this->registered[ $handle ]->extra[ $key ] ) ) { return false; } return $this->registered[ $handle ]->extra[ $key ]; } /** * Un-register an item or items. * * @since 2.1.0 * @since 2.6.0 Moved from `WP_Scripts`. * * @param string|string[] $handles Item handle (string) or item handles (array of strings). */ public function remove( $handles ) { foreach ( (array) $handles as $handle ) { unset( $this->registered[ $handle ] ); } } /** * Queue an item or items. * * Decodes handles and arguments, then queues handles and stores * arguments in the class property $args. For example in extending * classes, $args is appended to the item url as a query string. * Note $args is NOT the $args property of items in the $registered array. * * @since 2.1.0 * @since 2.6.0 Moved from `WP_Scripts`. * * @param string|string[] $handles Item handle (string) or item handles (array of strings). */ public function enqueue( $handles ) { foreach ( (array) $handles as $handle ) { $handle = explode( '?', $handle ); if ( ! in_array( $handle[0], $this->queue, true ) && isset( $this->registered[ $handle[0] ] ) ) { $this->queue[] = $handle[0]; // Reset all dependencies so they must be recalculated in recurse_deps(). $this->all_queued_deps = null; if ( isset( $handle[1] ) ) { $this->args[ $handle[0] ] = $handle[1]; } } elseif ( ! isset( $this->registered[ $handle[0] ] ) ) { $this->queued_before_register[ $handle[0] ] = null; // $args if ( isset( $handle[1] ) ) { $this->queued_before_register[ $handle[0] ] = $handle[1]; } } } } /** * Dequeue an item or items. * * Decodes handles and arguments, then dequeues handles * and removes arguments from the class property $args. * * @since 2.1.0 * @since 2.6.0 Moved from `WP_Scripts`. * * @param string|string[] $handles Item handle (string) or item handles (array of strings). */ public function dequeue( $handles ) { foreach ( (array) $handles as $handle ) { $handle = explode( '?', $handle ); $key = array_search( $handle[0], $this->queue, true ); if ( false !== $key ) { // Reset all dependencies so they must be recalculated in recurse_deps(). $this->all_queued_deps = null; unset( $this->queue[ $key ] ); unset( $this->args[ $handle[0] ] ); } elseif ( array_key_exists( $handle[0], $this->queued_before_register ) ) { unset( $this->queued_before_register[ $handle[0] ] ); } } } /** * Recursively search the passed dependency tree for a handle. * * @since 4.0.0 * * @param string[] $queue An array of queued _WP_Dependency handles. * @param string $handle Name of the item. Should be unique. * @return bool Whether the handle is found after recursively searching the dependency tree. */ protected function recurse_deps( $queue, $handle ) { if ( isset( $this->all_queued_deps ) ) { return isset( $this->all_queued_deps[ $handle ] ); } $all_deps = array_fill_keys( $queue, true ); $queues = array(); $done = array(); while ( $queue ) { foreach ( $queue as $queued ) { if ( ! isset( $done[ $queued ] ) && isset( $this->registered[ $queued ] ) ) { $deps = $this->registered[ $queued ]->deps; if ( $deps ) { $all_deps += array_fill_keys( $deps, true ); array_push( $queues, $deps ); } $done[ $queued ] = true; } } $queue = array_pop( $queues ); } $this->all_queued_deps = $all_deps; return isset( $this->all_queued_deps[ $handle ] ); } /** * Query the list for an item. * * @since 2.1.0 * @since 2.6.0 Moved from `WP_Scripts`. * * @param string $handle Name of the item. Should be unique. * @param string $status Optional. Status of the item to query. Default 'registered'. * @return bool|_WP_Dependency Found, or object Item data. */ public function query( $handle, $status = 'registered' ) { switch ( $status ) { case 'registered': case 'scripts': // Back compat. if ( isset( $this->registered[ $handle ] ) ) { return $this->registered[ $handle ]; } return false; case 'enqueued': case 'queue': // Back compat. if ( in_array( $handle, $this->queue, true ) ) { return true; } return $this->recurse_deps( $this->queue, $handle ); case 'to_do': case 'to_print': // Back compat. return in_array( $handle, $this->to_do, true ); case 'done': case 'printed': // Back compat. return in_array( $handle, $this->done, true ); } return false; } /** * Set item group, unless already in a lower group. * * @since 2.8.0 * * @param string $handle Name of the item. Should be unique. * @param bool $recursion Internal flag that calling function was called recursively. * @param int|false $group Group level: level (int), no group (false). * @return bool Not already in the group or a lower group. */ public function set_group( $handle, $recursion, $group ) { $group = (int) $group; if ( isset( $this->groups[ $handle ] ) && $this->groups[ $handle ] <= $group ) { return false; } $this->groups[ $handle ] = $group; return true; } }