Skip to Content

is_engine()

Compare the rendering engine of the user’s browser.

PHP May 3, 2017

Usage

PHP
nebula()->is_engine($engine)

Parameters

$engine
(Required) (String) The rendering engine to compare
Default: None

Request or provide clarification »

Additional Notes

Note: This function requires the Device Detection Nebula option to be enabled or only basic detection happens with WordPress core.

Source File

Located in /libs/Utilities/Device.php on line 350.

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_nebula_is_engine"
Need a new filter hook? Request one here.

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

PHP
        public function is_engine($engine=null){
            $override = apply_filters('pre_nebula_is_engine', null, $engine);
            if ( isset($override) ){return $override;}

            if ( $this->get_option('device_detection') ){
                if ( empty($engine) ){
                    trigger_error('is_engine requires a parameter of requested engine.');
                    return false;
                }

                switch ( strtolower($engine) ){
                    case 'ie':
                    case 'internet explorer':
                        $engine = 'trident';
                        break;
                    case 'web kit':
                        $engine = 'webkit';
                        break;
                    default:
                        break;
                }

                $actual_engine = $this->get_browser('engine');
                if ( strpos(strtolower($actual_engine), strtolower($engine)) !== false ){
                    return true;
                }
            }

            return false;
        }

Override

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

PHP
add_filter('pre_nebula_is_engine', 'my_custom_is_engine', 10, 2); //The last integer must be 1 more than the actual parameters
function my_custom_is_engine($null, $engine){ //$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_nebula_is_engine', '__return_false');