get_key_from_asm( $list_pages ); $all_child_pages = (array) wp_cache_get( static::CHILD_PAGES_KEY, $this->get_cache_group() ); return $all_child_pages[ $key ] ?? false; } /** * Add a post and its children to the cache * Uses a global key for all posts so this appends to an array * * @param List_Pages $list_pages - Full menu class with all properties set. * @param array $child_pages - List of child pages to store. * * @return void */ public function add_child_pages( List_Pages $list_pages, $child_pages ) { $key = $this->get_key_from_asm( $list_pages ); $all_child_pages = (array) wp_cache_get( static::CHILD_PAGES_KEY, $this->get_cache_group() ); $all_child_pages[ $key ] = $child_pages; wp_cache_set( static::CHILD_PAGES_KEY, $all_child_pages, $this->get_cache_group() ); } /** * Too many possibilities for properties set to the object * used for generations. * To guarantee we have a unique id for the cache we serialize * the entire object and hash it. * * @param List_Pages $list_pages - Full menu class with all properties set. * * @return string */ protected function get_key_from_asm( List_Pages $list_pages ) { $string = \serialize( $list_pages ); //phpcs:ignore -- Serialize is required. return \md5( $string ); } }