Making WordPress.org


Ignore:
Timestamp:
03/04/2021 11:22:21 PM (5 years ago)
Author:
coffee2code
Message:

Handbooks, Init: Add reset() to reset handbooks to uninitialized state, optionally deleting existing handbook objects.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/init.php

    r10753 r10759  
    3434                 */
    3535                return (array) apply_filters( 'handbook_post_types', array( 'handbook' ) );
     36        }
     37
     38        /**
     39         * Resets memoized and cached variables.
     40         *
     41         * @param bool $delete_handbook_objects Optional. Delete associated handbook
     42         *                                      objects? Default false.
     43         */
     44        public static function reset( $delete_handbook_objects = false ) {
     45                if ( $delete_handbook_objects ) {
     46                        foreach ( self::get_handbook_objects() as $obj ) {
     47                                unset( $obj );
     48                        }
     49                }
     50
     51                self::$handbooks  = [];
    3652        }
    3753
Note: See TracChangeset for help on using the changeset viewer.