langs = new class_fma_adv_lang(); add_action('fma__settings_tab_notifications_content', array($this, 'notification_callback')); // Free: Show AI Integration (Code Pilot) tab content as a PRO teaser add_action('fma__settings_tab_ai_content', array($this, 'ai_integration_callback')); // Hide Freemius Add-Ons menu using Freemius filter hook add_filter('fs_is_submenu_visible_file-manager-advanced', array($this, 'hide_freemius_addons_menu'), 10, 2); // Fallback: Remove Freemius Add-Ons menu if it still exists add_action('admin_menu', array($this, 'remove_freemius_addons_menu'), 999); } /** * Hide Freemius Add-Ons menu using Freemius filter hook * This is the proper way to hide menu items in Freemius */ public function hide_freemius_addons_menu($is_visible, $menu_id) { // Hide Add-Ons menu if ($menu_id === 'addons') { return false; } return $is_visible; } /** * Remove Freemius Add-Ons menu (fallback method) */ public function remove_freemius_addons_menu() { global $fma_fs, $submenu; // Remove Add-Ons submenu if it exists (check various possible slugs) $parent_slug = 'file_manager_advanced_ui'; $possible_slugs = array( 'file-manager-advanced-addons', 'file-manager-advanced-addons-network', 'file_manager_advanced-addons', 'file_manager_advanced-addons-network', ); foreach ($possible_slugs as $slug) { remove_submenu_page($parent_slug, $slug); } // Also remove by menu title if slug-based removal didn't work if (isset($submenu[$parent_slug])) { foreach ($submenu[$parent_slug] as $key => $item) { if (isset($item[0]) && (stripos($item[0], 'Add-On') !== false || stripos($item[0], 'Addon') !== false)) { unset($submenu[$parent_slug][$key]); } } } } /** * Notification Callback * @since 6.7.3 */ public function notification_callback() { if (!class_exists('AFMP\\Modules\\EmailNotification\\EmailNotification')) { echo '
'; echo '

Email Notification Settings PRO

'; echo ''; echo '
'; } if (!class_exists('AFMP\\Modules\\SlackNotification\\SlackNotification')) { echo '
'; echo '

Slack Notification Settings PRO

'; echo ''; echo '
'; } } /** * AI Integration (Code Pilot) Callback * Mirrors notification_callback pattern for the free version * @since 5.4.1 */ public function ai_integration_callback() { if (!class_exists('AFMP\\Modules\\AFMP_AI_Integration')) { // Defaults to avoid undefined variable notices in free view $enabled = '0'; $api_key = ''; ?>

/>

fmaPer(); /** Authorizing only super admin to manage settings */ $subPer = 'manage_options'; if (is_multisite() && !is_network_admin()) { $subPer = 'manage_network'; $fmaPer = $this->networkPer(); } add_menu_page( __('File Manager', 'file-manager-advanced'), __('File Manager', 'file-manager-advanced'), $fmaPer, 'file_manager_advanced_ui', array($this, 'file_manager_advanced_ui'), plugins_url('assets/icon/fma-new.png', __FILE__), 4 ); add_submenu_page( 'file_manager_advanced_ui', __('Settings', 'file-manager-advanced'), __('Settings', 'file-manager-advanced'), $subPer, 'file_manager_advanced_controls', array(&$this, 'file_manager_advanced_controls') ); if (!class_exists('AFMP\Modules\Integrations')) { add_submenu_page('file_manager_advanced_ui', __('Integrations', 'file-manager-advanced'), __('Integrations', 'file-manager-advanced'), 'manage_options', 'afm-integrations-pro', array($this, 'integrations_pro_menu'), 2); } if (!class_exists('AFMP\Modules\AFMP_AI_Integration')) { add_submenu_page( '', __('AI - Code Pilot', 'file-manager-advanced'), sprintf( '%1$s %2$s', __('AI - Code Pilot', 'file-manager-advanced'), __('NEW', 'file-manager-advanced') ), 'manage_options', 'ai-code-pilot', array($this, 'ai_code_pilot_callback'), 2 ); } // Blocks submenu is now handled by class_fma_blocks // Old submenu removed - blocks post type is used instead // if(!class_exists('file_manager_advanced_shortcode')) { // add_submenu_page( 'file_manager_advanced_ui', 'Blocks', 'Blocks', $subPer, 'file_manager_advanced_shortcodes', array(&$this, 'file_manager_advanced_shortcodes')); // } if (!class_exists('AFMP\\Modules\\Adminer')) { add_submenu_page('file_manager_advanced_ui', __('DB Access', 'file-manager-advanced'), __('DB Access', 'file-manager-advanced'), 'manage_options', 'afmp-adminer', array($this, 'adminer_menu')); } if (!class_exists('AFMP\\Modules\\Dropbox')) { add_submenu_page('', __('Dropbox Settings', 'file-manager-advanced'), __('Dropbox', 'file-manager-advanced'), 'manage_options', 'afmp-dropbox', array($this, 'dropbox_menu')); } if (!class_exists('AFMP\\Modules\\FileLogs')) { add_submenu_page('file_manager_advanced_ui', __('File Logs', 'file-manager-advanced'), __('File Logs', 'file-manager-advanced'), 'manage_options', 'afmp-file-logs', array($this, 'afmp__file_logs'), 3); } if (!class_exists('AFMP\\Modules\\GoogleDrive')) { add_submenu_page('', __('Google Drive Settings', 'file-manager-advanced'), __('Google Drive', 'file-manager-advanced'), 'manage_options', 'afmp-googledrive', array($this, 'googledrive_menu')); } if (!class_exists('AFMP\Modules\Onedrive')) { add_submenu_page('', __('OneDrive Settings', 'file-manager-advanced'), __('OneDrive', 'file-manager-advanced'), 'manage_options', 'afmp-onedrive', array($this, 'onedrive_menu')); } if (!class_exists('AFMP\\Modules\\AmazonS3')) { add_submenu_page('', __('Amazon S3 (AWS) Settings', 'file-manager-advanced'), __('Amazon S3 (AWS)', 'file-manager-advanced'), 'manage_options', 'afmp-aws', array($this, 'aws_menu')); } if (!class_exists('AFMP\\Modules\\GitHub')) { add_submenu_page('', __('GitHub Settings', 'file-manager-advanced'), __('GitHub', 'file-manager-advanced'), 'manage_options', 'afmp-github', array($this, 'github_menu')); } if (!class_exists('AFMP\\Modules\\GoogleCloud')) { add_submenu_page('', __('Google Cloud Settings', 'file-manager-advanced'), __('Google Cloud', 'file-manager-advanced'), 'manage_options', 'afmp-googlecloud', array($this, 'googlecloud_menu')); } // Add GET PRO menu item at the bottom (only if pro plugin is not active) if (!class_exists('file_manager_advanced_shortcode')) { add_submenu_page( 'file_manager_advanced_ui', __('GET PRO', 'file-manager-advanced'), __('GET PRO', 'file-manager-advanced'), 'manage_options', 'fma-get-pro', '__return_null' ); if (isset($_GET['page']) && 'fma-get-pro' === sanitize_text_field(wp_unslash($_GET['page']))) { wp_redirect( add_query_arg( array( 'utm_source' => 'wordpress_admin_menu', 'utm_medium' => 'website', 'utm_campaign' => 'free_plugin', ), 'https://advancedfilemanager.com/pricing/' ) ); exit; } } // Add CSS styling for GET PRO menu add_action('admin_head', array($this, 'get_pro_menu_styles')); // Add JavaScript to redirect GET PRO menu directly // add_action('admin_footer', array($this, 'get_pro_menu_redirect_script')); } /** * GET PRO menu styles */ public function get_pro_menu_styles() { ?>

Dropbox Settings PRO
Enable

Enter a title which will be displayed on File Manager

Enter your Dropbox App key, you will get your app key from Dropbox App Console

Enter your Dropbox App secret, you will get your app secret from Dropbox App Console

Copy this URL and paste it in your Dropbox App Console under Redirect URIs

'; submit_button(); echo '
'; } /** * OneDrive menu * @since 6.7.3 */ public function onedrive_menu() { echo ''; echo '

One Drive Settings PRO

'; echo '
'; echo '

'; echo ''; submit_button(); echo '
'; } /** * Google Drive menu * @since 6.7.2 */ public function googledrive_menu() { echo '

Google Drive Settings PRO

Enable

Enter a title which will be displayed on File Manager

Enter your Google Drive App key, you will get your app key from Google Drive App Console

Enter your Google Drive App secret, you will get your app secret from Google Drive App Console

Copy this URL and paste it in your Google Drive App Console under JavaScripts Origins

Copy this URL and paste it in your Google Drive App Console under Redirect URIs

'; submit_button(); echo '
'; } /** * GitHub menu * @since 6.7.2 */ public function github_menu() { echo '

GitHub Settings PRO

Enter your email which you use for your GitHub account

Enter your GitHub username

Enter GitHub Personal Access Token (PAT) for your account Click here to get Github PAT

This field is not a required as a default directory is set, but this can be changed

This field is not a required, and if left empty all configuration will apply to the whole repository

'; submit_button(); echo '
'; } /** * Amazon S3 (AWS) menu * @since 5.3.8 */ public function aws_menu() { echo '

Amazon S3 (AWS) Settings PRO

Enable

Enter a title which will be displayed on File Manager

Enter your Amazon S3 (AWS) App key. Learn how to get your credentials

Enter your Amazon S3 (AWS) App secret. Learn how to get your credentials

Enter the AWS region where your bucket is located (e.g. us-east-1)

Enter the name of your Amazon S3 bucket





Select the user roles allowed to access the AWS-connected file manager

Enter a folder name to restrict access to that folder only. Leave blank to use the root directory (e.g. awsfolder)

'; submit_button(); echo '
'; } /** * Google Cloud menu * @since 5.3.8 */ public function googlecloud_menu() { echo '

Google Cloud Settings PRO

Enable

Enter a title which will be displayed on File Manager

Upload your Google Cloud service account key file (.json format)

Enter the name of your Google Cloud Storage bucket





Select the user roles allowed to access the Google Cloud file manager

Enter a subfolder path within your bucket. Leave blank to use the root directory

Note: Folder paths and user role values are case-sensitive

'; submit_button(); echo '
'; } /** * Adminer menu * @since 6.7.2 */ public function adminer_menu() { require_once FMAFILEPATH . 'templates/adminer.php'; } public function afmp__file_logs() { echo <<

File Logs PRO

Delete All
ID Sort descending.User Sort ascending.Date & Time Sort descending.Event Sort descending.File Path Sort descending.Type Sort descending.IP Address Sort descending.Actions
6admin
john@flywheel.local
May 02, 2025 12:40 pmuploadedD:\Local Sites\file-manager-advanced\app\public\wp-content\HeidiSQL.lnkapplication/x-ms-shortcut127.0.0.1
5admin
john@flywheel.local
May 02, 2025 12:39 pmpastedD:\Local Sites\file-manager-advanced\app\public\wp-content\index.phptext/x-php127.0.0.1
4admin
john@flywheel.local
May 02, 2025 12:39 pmdeletedD:\Local Sites\file-manager-advanced\app\public\wp-content\themes\deletedme.phptext/x-php127.0.0.1
3admin
john@flywheel.local
May 02, 2025 12:39 pmupdatedD:\Local Sites\file-manager-advanced\app\public\wp-content\themes\deletedme.phptext/x-php127.0.0.1
2admin
john@flywheel.local
May 02, 2025 12:39 pmrenamedD:\Local Sites\file-manager-advanced\app\public\wp-content\themes\index copy 1.phptext/x-php127.0.0.1
1admin
john@flywheel.local
May 02, 2025 12:38 pmduplicatedD:\Local Sites\file-manager-advanced\app\public\wp-content\themes\index copy 1.phptext/x-php127.0.0.1
ID Sort descending.User Sort ascending.Date & Time Sort descending.Event Sort descending.File Path Sort descending.Type Sort descending.IP Address Sort descending.Actions
6 items Current Page1 of 1

HTML; } /** * Fma permissions */ public function fmaPer() { $settings = $this->get(); $user = wp_get_current_user(); $allowed_fma_user_roles = isset($settings['fma_user_roles']) ? $settings['fma_user_roles'] : array('administrator'); if (!in_array('administrator', $allowed_fma_user_roles)) { $fma_user_roles = array_merge(array('administrator'), $allowed_fma_user_roles); } else { $fma_user_roles = $allowed_fma_user_roles; } $checkUserRoleExistance = array_intersect($fma_user_roles, $user->roles); if (count($checkUserRoleExistance) > 0 && !in_array('administrator', $checkUserRoleExistance)) { $fmaPer = 'read'; } else { $fmaPer = 'manage_options'; } return $fmaPer; } /** * Fma - Network Permissions */ public function networkPer() { $settings = $this->get(); $user = wp_get_current_user(); $allowed_fma_user_roles = isset($settings['fma_user_roles']) ? $settings['fma_user_roles'] : array(); $fma_user_roles = $allowed_fma_user_roles; $checkUserRoleExistance = array_intersect($fma_user_roles, $user->roles); if (count($checkUserRoleExistance) > 0) { if (!in_array('administrator', $checkUserRoleExistance)) { $fmaPer = 'read'; } else { $fmaPer = 'manage_options'; } } else { $fmaPer = 'manage_network'; } return $fmaPer; } /** * Diaplying AFM */ public function file_manager_advanced_ui() { $fmaPer = $this->fmaPer(); if (current_user_can($fmaPer)) { include('pages/main.php'); } } /** * Settings */ public function file_manager_advanced_controls() { if (current_user_can('manage_options')) { include('pages/controls.php'); } } /** * Shortcode */ public function file_manager_advanced_shortcodes() { if (current_user_can('manage_options')) { include('pages/buy_shortcode.php'); } } /** * Saving Options */ public function save() { if (isset($_POST['submit']) && wp_verify_nonce($_POST['_fmaform'], 'fmaform')) { $save = array(); $defaultRole = array('administrator'); if (is_multisite()) { $defaultRole = array(); } $public_dir = isset($_POST['public_path']) ? sanitize_text_field($_POST['public_path']) : ''; $save['fma_user_roles'] = isset($_POST['fma_user_role']) ? array_map('sanitize_text_field', $_POST['fma_user_role']) : $defaultRole; $save['fma_theme'] = isset($_POST['fma_theme']) ? sanitize_text_field($_POST['fma_theme']) : 'light'; $save['fma_locale'] = isset($_POST['fma_locale']) ? sanitize_text_field($_POST['fma_locale']) : 'en'; /* Directory Traversal fix @220723 */ $save['public_path'] = $this->afm_sanitize_directory($public_dir); $save['public_url'] = isset($_POST['public_url']) ? sanitize_text_field($_POST['public_url']) : ''; //25122022 $save['upload_max_size'] = isset($_POST['upload_max_size']) ? sanitize_text_field($_POST['upload_max_size']) : '0'; $save['display_ui_options'] = isset($_POST['display_ui_options']) ? array_map('sanitize_text_field', $_POST['display_ui_options']) : array(); $save['hide_path'] = isset($_POST['hide_path']) ? sanitize_text_field($_POST['hide_path']) : 0; $save['enable_trash'] = isset($_POST['enable_trash']) ? sanitize_text_field($_POST['enable_trash']) : 0; $save['enable_htaccess'] = isset($_POST['enable_htaccess']) ? sanitize_text_field($_POST['enable_htaccess']) : 0; $save['fma_upload_allow'] = isset($_POST['fma_upload_allow']) ? sanitize_text_field($_POST['fma_upload_allow']) : 'all'; $save['fma_cm_theme'] = isset($_POST['fma_cm_theme']) ? sanitize_text_field($_POST['fma_cm_theme']) : 'default'; $save['fma_debug_enabled'] = isset($_POST['fma_debug_enabled']) ? sanitize_text_field($_POST['fma_debug_enabled']) : 0; $save['fma_delete_data_on_uninstall'] = isset($_POST['fma_delete_data_on_uninstall']) ? sanitize_text_field($_POST['fma_delete_data_on_uninstall']) : 0; update_option('fmaoptions', $save); $this->f('?page=file_manager_advanced_controls&status=1'); } } /** * Sanitize directory path */ public function afm_sanitize_directory($path = '') { if (!empty($path)) { $path = str_replace('..', '', htmlentities(trim($path))); } return $path; } /** * Getting Options */ public function get() { return get_option('fmaoptions'); } /** * Diplay Notices */ public function notice($type, $message) { if (isset($type) && !empty($type)) { $class = ($type == '1') ? 'updated' : 'error'; return '

' . $message . '

'; } } /** * Redirection */ public function f($u) { $url = esc_url_raw($u); wp_register_script('fma-redirect-script', ''); wp_enqueue_script('fma-redirect-script'); wp_add_inline_script( 'fma-redirect-script', ' window.location.href="' . $url . '" ;' ); } public static function shortcodeUpdateNotice() { if (class_exists('file_manager_advanced_shortcode')): if (defined('fmas_ver')) { if (fmas_ver < '2.4.1') { return '

Advanced File manager shortcode addon update: You are using version ' . fmas_ver . ' we recommend you to update to latest version. If you did not receive update please download from my account page.

'; } } else { return '

Advanced File manager shortcode addon update: You are using old version, we recommend you to update to latest version. If you did not receive update please download from my account page.

'; } endif; } /** * Get User Roles */ public function wpUserRoles() { global $wp_roles; return $wp_roles->roles; } /** * Integrations Pro Menu */ public function integrations_pro_menu() { wp_enqueue_script('fma-admin-scripts'); $pro_images_url = plugins_url('assets/images/', __FILE__); ?>

PRO

array( 'name' => 'OneDrive', 'desc' => 'Connect and manage your Microsoft OneDrive files directly from the Advanced File Manager.', 'icon' => 'onedrive.svg' ), 'googledrive' => array( 'name' => 'Google Drive', 'desc' => 'Sync and manage your Google Drive files and folders seamlessly with your WordPress setup.', 'icon' => 'googledrive.svg' ), 'amazons3' => array( 'name' => 'Amazon S3', 'desc' => 'Securely connect and manage your AWS S3 buckets for flexible and scalable cloud storage.', 'icon' => 'amazons3.svg' ), 'googlecloud' => array( 'name' => 'Google Cloud Storage', 'desc' => 'Access and organize your Google Cloud Storage buckets right from your WordPress dashboard.', 'icon' => 'googlecloud.svg' ), 'github' => array( 'name' => 'GitHub', 'desc' => 'Connect your GitHub repositories to browse and manage your project files directly.', 'icon' => 'github.svg' ), 'dropbox' => array( 'name' => 'Dropbox', 'desc' => 'Easily integrate and manage your Dropbox cloud storage files within the file manager.', 'icon' => 'dropbox.svg' ), 'pcloud' => array( 'name' => 'pCloud', 'desc' => 'Connect and manage your pCloud files directly from the Advanced File Manager.', 'icon' => 'pcloud.svg' ), 'cloudflarer2' => array( 'name' => 'Cloudflare R2', 'desc' => 'Connect and manage your Cloudflare R2 buckets/files directly from the Advanced File Manager.', 'icon' => 'cloudflarer2.svg' ), 'digitalocean' => array( 'name' => 'DigitalOcean Spaces', 'desc' => 'Connect and manage your DigitalOcean Spaces buckets/files directly from the Advanced File Manager.', 'icon' => 'digitalocean.svg', 'coming_soon' => true ) ); foreach ($integrations as $item): ?>
<?php echo $item['name']; ?>

Coming Soon