{$value_to_check}; $types = [ 'visible' => $plugin->visibility === 'visible', 'hidden' => $plugin->visibility === 'hidden', 'default' => $plugin->behavior === 'default', 'force_active' => $plugin->behavior === 'force_active', 'force_inactive' => $plugin->behavior === 'force_inactive', 'force_active_locked' => $plugin->behavior === 'force_active_locked', 'force_inactive_locked' => $plugin->behavior === 'force_inactive_locked', ]; return wu_get_isset($types, $type, false); } /** * Adds a magic getter for plugins. * * @since 2.0.0 * * @param string $plugin_name The plugin name. * @return object */ public function __get($plugin_name) { $plugin = (object) wu_get_isset($this->get_limit(), $plugin_name, $this->get_default_permissions($plugin_name)); return (object) wp_parse_args($plugin, $this->get_default_permissions($plugin_name)); } /** * Returns a list of plugins by behavior and visibility. * * @since 2.0.0 * * @param null|string $behavior The behaviour to search for. * @param null|string $visibility The visibility to search for. * @return array */ public function get_by_type($behavior = null, $visibility = null) { $search_params = []; if ($behavior) { $search_params[] = ['behavior', $behavior]; } if ($visibility) { $search_params[] = ['visibility', $visibility]; } $results = \Arrch\Arrch::find( (array) $this->get_limit(), [ 'where' => $search_params, ] ); return $results; } /** * Returns default permissions. * * @since 2.0.0 * * @param string $type Type for sub-checking. * @return array */ public function get_default_permissions($type) { return [ 'visibility' => 'visible', 'behavior' => 'default', ]; } /** * Checks if a theme exists on the current module. * * @since 2.0.0 * * @param string $plugin_name The theme name. * @return bool */ public function exists($plugin_name) { $results = wu_get_isset($this->get_limit(), $plugin_name, []); return wu_get_isset($results, 'visibility', 'not-set') !== 'not-set' || wu_get_isset($results, 'behavior', 'not-set') !== 'not-set'; } /** * Checks if the module is enabled. * * @since 2.0.0 * * @param string $type Type for sub-checking. * @return boolean */ public function is_enabled($type = '') { return true; } }