diff --git a/admin/qtx_admin_settings.php b/admin/qtx_admin_settings.php
index 2769f6cb..78303803 100644
--- a/admin/qtx_admin_settings.php
+++ b/admin/qtx_admin_settings.php
@@ -244,33 +244,22 @@ private function add_configuration_inspector() {
}
private function add_sections( $nonce_action ) {
- global $q_config;
-
$admin_sections = array();
$admin_sections['general'] = __( 'General', 'qtranslate' );
$admin_sections['advanced'] = __( 'Advanced', 'qtranslate' );
-
- $custom_sections = apply_filters( 'qtranslate_admin_sections', array() );
+ $custom_sections = apply_filters( 'qtranslate_admin_sections', array() );
foreach ( $custom_sections as $key => $value ) {
$admin_sections[ $key ] = $value;
}
-
$admin_sections['integration'] = __( 'Integration', 'qtranslate' );
- $admin_sections['import'] = __( 'Import', 'qtranslate' ) . '/' . __( 'Export', 'qtranslate' );
- $admin_sections['languages'] = __( 'Languages', 'qtranslate' );
-
- //TODO: this actually assumes every manual activation module has settings, dedicated key to be added if that is not the case...
- if ( isset( $q_config['ma_module_enabled'] ) ) {
- foreach ( $q_config['ma_module_enabled'] as $module_id => $module_enabled ) {
- if ( ! $module_enabled ) {
- continue;
- }
- $ma_module = QTX_Modules_Handler::get_module_def_by_id( $module_id );
- $admin_sections[ $module_id ] = $ma_module['name'];
+ foreach ( QTX_Modules_Handler::get_active_modules() as $module ) {
+ if ( isset( $module ['has_settings'] ) && $module ['has_settings'] ) {
+ $admin_sections[ $module['id'] ] = $module['name'];
}
}
+ $admin_sections['import'] = __( 'Import', 'qtranslate' ) . '/' . __( 'Export', 'qtranslate' );
+ $admin_sections['languages'] = __( 'Languages', 'qtranslate' );
$admin_sections['troubleshooting'] = __( 'Troubleshooting', 'qtranslate' );
-
?>
$name ) : ?>
diff --git a/modules/qtx_modules_handler.php b/modules/qtx_modules_handler.php
index 25ec6368..76e21547 100644
--- a/modules/qtx_modules_handler.php
+++ b/modules/qtx_modules_handler.php
@@ -7,27 +7,44 @@
class QTX_Modules_Handler {
/**
- * Loads modules previously enabled in the options after validation for plugin integration on admin-side.
+ * Get the modules previously activated in the options after validation for plugin integration on admin-side.
* Note these should be loaded before "qtranslate_init_language" is triggered.
*
* @see QTX_Admin_Modules::update_modules_status()
+ * @array Module defs.
*/
- public static function load_modules_enabled() {
- $def_modules = self::get_modules_defs();
+ public static function get_active_modules() {
$options_modules = get_option( 'qtranslate_modules', array() );
if ( ! is_array( $options_modules ) ) {
- return null;
+ return array();
}
+ $active_modules = array();
+ $def_modules = self::get_modules_defs();
foreach ( $def_modules as $def_module ) {
if ( ! array_key_exists( $def_module['id'], $options_modules ) ) {
continue;
}
$module_status = $options_modules[ $def_module['id'] ];
if ( $module_status === QTX_MODULE_STATUS_ACTIVE ) {
- include_once( QTRANSLATE_DIR . '/modules/' . $def_module['id'] . '/' . $def_module['id'] . '.php' );
+ array_push( $active_modules, $def_module );
}
}
+
+ return $active_modules;
+ }
+
+ /**
+ * Loads modules previously activated in the options after validation for plugin integration on admin-side.
+ * Note these should be loaded before "qtranslate_init_language" is triggered.
+ *
+ * @see QTX_Admin_Modules::update_modules_status()
+ */
+ public static function load_active_modules() {
+ $def_modules = self::get_active_modules();
+ foreach ( $def_modules as $def_module ) {
+ include_once( QTRANSLATE_DIR . '/modules/' . $def_module['id'] . '/' . $def_module['id'] . '.php' );
+ }
}
public static function update_manual_enabled_modules() {
@@ -46,7 +63,7 @@ public static function update_manual_enabled_modules() {
if ( $changed ) {
update_option( 'qtranslate_modules', $options_modules );
- self::load_modules_enabled();
+ self::load_active_modules();
do_action( 'qtx_ma_modules_updated' );
}
}
@@ -118,6 +135,7 @@ public static function get_modules_defs() {
'plugin' => true,
'incompatible' => 'qtranslate-slug/qtranslate-slug.php',
'manual_activation' => true,
+ 'has_settings' => true,
)
);
}
diff --git a/qtranslate_core.php b/qtranslate_core.php
index 834b5992..0ea0a6bd 100644
--- a/qtranslate_core.php
+++ b/qtranslate_core.php
@@ -124,7 +124,7 @@ function qtranxf_init_language() {
qtranxf_load_option_qtrans_compatibility();
- QTX_Modules_Handler::load_modules_enabled();
+ QTX_Modules_Handler::load_active_modules();
/**
* allow other plugins and modules to initialize whatever they need for language