';
public function __construct() {
$this->active = get_option($this->active_option_name, false);
if ($this->active == 'true') {
$this->init();
}
// AJAX handlers
add_action('wp_ajax_update_active_option_canonical_' . $this->active_option_name, array($this, 'update_active_option_callback'));
}
public function init() {
// Initialize Install Plugin functionality
add_action('admin_menu', array($this, 'add_admin_menu'));
}
public function add_admin_menu() {
add_submenu_page(
'ai_auto_tool',
'Install Plugin',
'Install Plugin',
'manage_options',
'install-plugin',
array($this, 'render_admin_page')
);
}
public function render_admin_page() {
echo '
';
echo '
Install Plugin
';
echo '
Install and manage plugins
';
echo '
';
}
public function update_active_option_callback() {
check_ajax_referer('aiautotool_nonce', 'security');
if (!current_user_can('manage_options')) {
wp_die(__('Permission denied', 'ai-auto-tool'), '', array('response' => 403));
}
if (isset($_POST['active'])) {
$active = sanitize_text_field($_POST['active']);
update_option($this->active_option_name, $active, null, 'no');
wp_send_json_success(array('active' => $active));
}
wp_send_json_error('Invalid request');
}
public function render_feature() {
$box = new AutoToolBox(
$this->icon . ' Install Plugin',
'Install and manage plugins',
admin_url('admin.php?page=aiautotool_integrations'),
$this->active_option_name,
$this->active,
'',
false
);
echo $box->generateHTML();
}
}
}