Skip to Content
Menu

glob_r()

Recursive glob.

PHP April 27, 2017

Usage

PHP
nebula()->glob_r($pattern, $flags)

Parameters

$pattern
(Optional) (String) The glob pattern
Default: None

$flags
(Optional) (String) The glob flags
Default: false

Parameter Notes

Refer to standard PHP glob flags.

Request or provide clarification »

Was this page helpful? Yes No


    A feedback message is required to submit this form.


    Please check that you have entered a valid email address.

    Enter your email address if you would like a response.

    Thank you for your feedback!

    Source File

    Located in /libs/Utilities/Utilities.php on line 890.

    1 Hook

    Find these filters and actions in the source code below to hook into them. Use do_action() and add_filter() in your functions file or plugin.

    Filters
    "pre_glob_r"
    Need a new filter hook? Request one here.

    Actions
    This function has no action hooks available. Request one?

    PHP
            public function glob_r($pattern, $flags=0){
                $override = apply_filters('pre_glob_r', null, $pattern, $flags);
                if ( isset($override) ){return $override;}
    
                $files = glob($pattern, $flags);
                foreach ( glob(dirname($pattern) . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir ){
                    $files = array_merge($files, $this->glob_r($dir . '/' . basename($pattern), $flags));
                }
    
                return $files;
            }
    

    Override

    To override this PHP function, use this hook in your child theme or plugin ("my_custom" can be changed):

    PHP
    add_filter('pre_glob_r', 'my_custom_glob_r', 10, 3); //The last integer must be 1 more than the actual parameters
    function my_custom_glob_r($null, $pattern, $flags){ //$null is required, but can be ignored
        //Write your own code here
    
        return true; //Return true to prevent the original function from running afterwords
    }

    You can completely disable this PHP function with a single line actions:

    PHP
     add_filter('pre_glob_r', '__return_false');