options = $options;
$this->init();
}
/**
* Start the engine running
*
* @return void
*/
private function init() {
add_filter( 'adminoptimizer_settings_navtab', [ $this, 'add_settings_navtab' ] );
add_filter( 'adminoptimizer_settings_sections', [ $this, 'settings_fields' ] );
if ( ! empty( $this->options['enable_smtp_mail'] ) ) {
$this->modules['smtp'] = new SMTP_Email();
}
if ( ! empty( $this->options['enable_form_builder'] ) ) {
$this->modules['form'] = new Form_Builder();
}
if ( ! empty( $this->options['enable_custom_code'] ) ) {
$this->modules['custom_code'] = new Custom_Code();
}
}
/**
* Add settings navtab
*
* @param array $nav_tab List of nav tabs.
*
* @return array
*/
public function add_settings_navtab( $nav_tab ) {
if ( empty( $nav_tab['tools'] ) ) {
$nav_tab['tools'] = [
'title' => __( 'System Tools', 'admin-optimizer' ),
'slug' => 'adminoptim-tools-settings',
];
}
return $nav_tab;
}
/**
* List of Settings fields
*
* @param array $fields Settings fields.
*
* @return array
*/
public function settings_fields( $fields ) {
if ( empty( $fields['tools-module'] ) ) {
$fields['tools-module'] = [
'id' => 'adminoptimizer-tools-module-settings',
'title' => __( 'Modules', 'admin-optimizer' ),
'description' => '',
'menu_slug' => 'adminoptim-tools-settings',
'option_name' => MODULES_OPTION,
'args' => [
'before_section' => '
',
'after_section' => '
',
'section_class' => 'module',
],
'fields' => [
[
'type' => 'slider-checkbox',
'title' => __( 'AI Connectors (Pro only)', 'admin-optimizer' ),
'id' => 'enable-ai-connectors',
'name' => 'enable_ai_connectors',
'disabled' => 'disabled',
// translators: %1$s is the line break tag. %2$s is the anchor tag. %3$s is the anchor closure tag.
'label' => sprintf( __( 'Improve the native AI Connectors settings in WordPress 7+ and bring AI provider key management to older WordPress versions. Connect to more AI providers, and view usage cost and request logs.%1$s%2$sLearn more%3$s', 'admin-optimizer' ), '
', '', '' ),
],
[
'type' => 'slider-checkbox',
'title' => __( 'Email & SMTP', 'admin-optimizer' ),
'id' => 'enable-smtp-mail',
'name' => 'enable_smtp_mail',
// translators: %1$s is the line break tag. %2$s is the anchor tag. %3$s is the anchor closure tag.
'label' => sprintf( __( 'Set up SMTP email delivery in WordPress, create routing rules, and send emails directly from the admin.%1$s%2$sLearn more%3$s', 'admin-optimizer' ), '
', '', '' ),
],
[
'type' => 'slider-checkbox',
'title' => __( 'Form Builder (Pro options)', 'admin-optimizer' ),
'id' => 'enable-form-builder',
'name' => 'enable_form_builder',
// translators: %1$s is the line break tag. %2$s is the anchor tag. %3$s is the anchor closure tag.
'label' => sprintf( __( 'Create forms to display on your website (comes with Pro options).%1$s%2$sLearn more%3$s', 'admin-optimizer' ), '
', '', '' ),
],
[
'type' => 'slider-checkbox',
'title' => __( 'Custom Code (Pro options)', 'admin-optimizer' ),
'id' => 'enable-custom-code',
'name' => 'enable_custom_code',
'label' => __( 'Add custom CSS, HTML, JavaScript and PHP code snippets to your website (comes with Pro options).', 'admin-optimizer' ),
],
],
];
}
return $fields;
}
}