settings = $settings; } /** * Every registered module, annotated with its enabled state. * * @return array */ public function modules() { $modules = Module_Registry::all(); foreach ( $modules as $id => $module ) { $modules[ $id ]['enabled'] = $this->is_module_enabled( $module ); } return $modules; } /** * Whether a module is enabled. * * @param array $module Normalised module definition. * @return bool */ public function is_module_enabled( $module ) { $id = isset( $module['id'] ) ? (string) $module['id'] : ''; $default = isset( $module['default_enabled'] ) ? (bool) $module['default_enabled'] : true; return (bool) $this->settings->is_enabled( Settings::GROUP_MODULES, $id, $default ); } /** * Total / active / inactive module counts. * * @return array */ public function module_counts() { $total = 0; $active = 0; foreach ( Module_Registry::all() as $module ) { $total++; if ( $this->is_module_enabled( $module ) ) { $active++; } } return array( 'total' => $total, 'active' => $active, 'inactive' => $total - $active, ); } /** * Whether the Pro plugin is present. * * @return bool */ public function is_pro_active() { /** * Filter whether the Pro edition is considered active. * * @param bool $active Default guess based on a classic marker class. */ return (bool) apply_filters( 'bulkora_pro_active', class_exists( 'Bulkora_Pro' ) ); } /** * Human label for the current edition. * * @return string */ public function edition_label() { return $this->is_pro_active() ? __( 'Pro', 'bulkora-multiple-variation-order' ) : __( 'Free', 'bulkora-multiple-variation-order' ); } }