get_key_from_asm( $class ); $all_child_pages = (array) wp_cache_get( self::CHILD_PAGES_KEY, $this->get_cache_group() ); if ( isset( $all_child_pages[ $key ] ) ) { return $all_child_pages[ $key ]; } return 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 $class - Full menu class with all properties set. * @param array $child_pages - List of child pages to store. * * @return void */ public function add_child_pages( $class, $child_pages ) { $key = $this->get_key_from_asm( $class ); $all_child_pages = (array) wp_cache_get( self::CHILD_PAGES_KEY, $this->get_cache_group() ); $all_child_pages[ $key ] = $child_pages; wp_cache_set( self::CHILD_PAGES_KEY, $all_child_pages, $this->get_cache_group() ); } /** * There are many possibilities for properties * set to the object used for generations. * To guarantee we have a unique id for the cache * we serialize the whole object and hash it * * @param List_Pages $class - Full menu class with all properties set. * * @return string */ private function get_key_from_asm( $class ) { $string = serialize( $class ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize return md5( $string ); } }