PluginProbe
Simple File List / trunk
Simple File List vtrunk
6.3.10 6.3.9 6.3.8 6.3.7 4.1.3 4.2.15 4.3.6 4.4.14 6.0.10 6.0.11 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.1.1 6.1.10 6.1.11 6.1.13 6.1.14 6.1.15 6.1.16 6.1.17 All 41 releases
simple-file-list / simple-file-list.php

simple-file-list.php in Simple File List trunk, at simple-file-list.php

288 lines 11.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package Simple File List
5 */
6 /*
7 Plugin Name: Simple File List
8 Plugin URI: https://simplefilelist.com
9 Description: Easy file list and upload manager for WordPress.
10 Author: Mitchell Bennis
11 Version: 6.3.11
12 Author URI: https://simplefilelist.com
13 License: GPLv2 or later
14 License URI: https://www.gnu.org/licenses/gpl-2.0.html
15 Text Domain: simple-file-list
16 Domain Path: /languages
17 */
18
19 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
20
21 // CONSTANTS
22 if(!defined('eeSFL_Version')) { define('eeSFL_Version', '6.3.11'); }
23 define('eeSFL_PluginName', 'Simple File List');
24 define('eeSFL_PluginSlug', 'simple-file-list');
25 define('eeSFL_Product', 'Free');
26 define('eeSFL_PluginMenuTitle', 'File List');
27
28 // Common
29 define('eeSFL_Prefix', 'eeSFL');
30 define('eeSFL_FileListDefaultDir', 'simple-file-list/'); // Default Upload Directory
31 define('eeSFL_PluginWebPage', 'https://simplefilelist.com');
32 define('eeSFL_AddOnsURL', 'https://get.simplefilelist.com/index.php');
33 define('eeSFL_RegCheckURL', 'https://reg.simplefilelist.com/index.php');
34 define('eeSFL_AdminEmail', 'admin@simplefilelist.com');
35 define('eeSFL_Go', wp_date('Y-m-d h:m:s') ); // Log Entry Key
36
37
38 // GLOBAL VARIABLES
39 $eeSFL = new stdClass(); // Our Main Object
40 $eeSFLU = new stdClass(); // Our Upload Class
41 $eeSFLM = TRUE; // Media Player
42 $eeSFL_Upload = FALSE; // File Uploading
43 $eeSFL_Thumbs = FALSE; // Thumbnail Creation and Management Object
44 $eeSFL_HideName = FALSE;
45 $eeSFL_HideType = FALSE;
46 $eeSFL_VarsForJS = array(); // Translated strings we pass to JavaScript
47 $eeSFL_StartTime = 0;
48 $eeSFL_MemoryUsedStart = 0;
49 $eeSFLF = FALSE; // Folder Support Object — initialised by pro/ee-ini.php when Pro is active
50 $eeSFLS = FALSE; // Search Object — initialised by ee-simple-file-list-search when active
51 $eeSFLA = FALSE; // Access Object — initialised by ee-simple-file-list-access when active
52 $eeSFL_Extensions = array();
53
54
55
56 // =============================================================================
57 // Plugin Setup
58 // =============================================================================
59 function eeSFL_Setup() {
60
61 global $eeSFL, $eeSFL_VarsForJS, $eeSFLU;
62
63 // Admin-only startup tasks: plugin state checks, conflicting plugin deactivation, debug tools.
64 // Guarded here to avoid loading wp-admin/includes/plugin.php on every frontend page load.
65 if(is_admin()) {
66
67 if(!function_exists('is_plugin_active')) {
68 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
69 }
70
71 // Purge stale registration options for extensions that are no longer installed/active.
72 // This prevents leftover NAG/NO options from showing bogus alerts after an extension is removed.
73 $eeSFL_ExtensionPlugins = array(
74 'eeSFLS' => 'ee-simple-file-list-search/ee-simple-file-list-search.php',
75 'eeSFLA' => 'ee-simple-file-list-access/ee-simple-file-list-access.php',
76 );
77 foreach ($eeSFL_ExtensionPlugins as $eeExtPrefix => $eeExtPlugin) {
78 if (!is_plugin_active($eeExtPlugin)) {
79 delete_option($eeExtPrefix . '_Registration');
80 delete_transient($eeExtPrefix . '_RegCheck');
81 }
82 }
83 unset($eeSFL_ExtensionPlugins, $eeExtPrefix, $eeExtPlugin);
84
85 // Load debug logging functions from Tools plugin (debug console output is in Tools plugin)
86 // Only load if the Tools plugin is actually active
87 if (is_plugin_active('ee-simple-file-list-tools/ee-simple-file-list-tools.php')) {
88 $tools_debug_file = WP_PLUGIN_DIR . '/ee-simple-file-list-tools/includes/ee-tools-debug.php';
89 if (file_exists($tools_debug_file)) {
90 include_once($tools_debug_file);
91 }
92 }
93
94 // Deactivate the Pro version if needed
95 $eePlugin = 'ee-simple-file-list-pro/ee-simple-file-list-pro.php';
96 if( is_plugin_active($eePlugin) ) {
97 deactivate_plugins($eePlugin);
98 }
99
100 // Deactivate the old Email extension if needed (email file sending is now Pro-only)
101 $eePlugin = 'ee-simple-file-list-email/ee-simple-file-list-email.php';
102 if( is_plugin_active($eePlugin) ) {
103 deactivate_plugins($eePlugin);
104 add_action( 'admin_notices', function() {
105 echo '<div class="notice notice-warning is-dismissible"><p><strong>' .
106 esc_html__('Simple File List:', 'simple-file-list') . '</strong> ' .
107 esc_html__('The Email extension has been automatically deactivated. Email file sending is now a Pro-only feature.', 'simple-file-list') .
108 '</p></div>';
109 });
110 }
111
112 // Deactivate the old Media extension if needed (functionality now integrated into core)
113 $eePlugin = 'ee-simple-file-list-media/ee-simple-file-list-media.php';
114 if( is_plugin_active($eePlugin) ) {
115 deactivate_plugins($eePlugin);
116 add_action( 'admin_notices', function() {
117 echo '<div class="notice notice-warning is-dismissible"><p><strong>' .
118 esc_html__('Simple File List:', 'simple-file-list') . '</strong> ' .
119 esc_html__('The Media extension has been automatically deactivated because media functionality is now integrated into core.', 'simple-file-list') .
120 '</p></div>';
121 });
122 }
123
124 } // end is_admin()
125
126 // Define debug logging stub (no-op on frontend; real implementation provided by Tools plugin above)
127 if(!function_exists('eeSFL_Debug_Log')) { function eeSFL_Debug_Log($eeString) { return FALSE; } }
128 eeSFL_Debug_Log("Simple File List v" . eeSFL_Version . " initializing", 'Loading');
129
130 // Translation strings to pass to javascript as eesfl_vars
131 $eeProtocol = isset( $_SERVER['HTTPS'] ) ? 'https://' : 'http://';
132 $eeSFL_VarsForJS = array(
133 'ajaxurl' => admin_url( 'admin-ajax.php', $eeProtocol ),
134 'eeEditText' => __('Edit', 'simple-file-list'), // Edit link text
135 'eeConfirmDeleteText' => __('Are you sure you want to delete this?', 'simple-file-list'), // Delete confirmation
136 'eeCancelText' => __('Cancel', 'simple-file-list'),
137 'eeCopyLinkText' => __('The Link Has Been Copied', 'simple-file-list'),
138 'eeUploadLimitText' => __('Upload Limit', 'simple-file-list'),
139 'eeFileTooLargeText' => __('This file is too large', 'simple-file-list'),
140 'eeFileNoSizeText' => __('This file is empty', 'simple-file-list'),
141 'eeFileNotAllowedText' => __('This file type is not allowed', 'simple-file-list'),
142 'eeUploadErrorText' => __('Upload Failed', 'simple-file-list'),
143 'eePleaseWaitText' => __('Please Wait', 'simple-file-list'),
144 'eeFilesSelected' => __('Files Selected', 'simple-file-list'),
145
146 // Back-End Only
147 'eeShowText' => __('Show', 'simple-file-list'), // Shortcode Builder
148 'eeHideText' => __('Hide', 'simple-file-list'),
149
150 // Extensions
151 'eeChooseListText' => __('Choose List', 'simple-file-list'),
152 );
153
154
155 // Get Class
156 if(!class_exists('eeSFL')) {
157
158 // Get Functions File
159 include_once(plugin_dir_path(__FILE__) . 'includes/ee-functions.php');
160
161 if(!is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) {
162 include_once(plugin_dir_path(__FILE__) . 'includes/ee-front-end.php');
163 }
164
165 // Main Class
166 require_once(plugin_dir_path(__FILE__) . 'includes/ee-class.php');
167 $eeSFL = new eeSFL_MainClass();
168
169 // Load Upload Class (needed by GetEnv)
170 require_once(plugin_dir_path(__FILE__) . 'includes/ee-class-uploads.php');
171 $eeSFLU = new eeSFL_UploadClass();
172
173 // Initialize environment (requires $eeSFLU)
174 $eeSFL->eeSFL_GetEnv();
175
176 // Can we go on?
177 $eeResult = $eeSFL->eeSFL_GetRootPath();
178 if($eeResult === FALSE) {
179
180 eeSFL_Debug_Log("CRITICAL: Root path determination failed - hosting incompatibility", 'ERROR');
181
182 add_action('admin_notices', function() {
183 echo '<div class="notice notice-error is-dismissible">';
184 echo '<p><strong>' . esc_html__('Simple File List Error:', 'simple-file-list') . '</strong> ' . esc_html__('This plugin cannot determine the correct file system paths on your hosting environment.', 'simple-file-list') . '</p>';
185 echo '<p>' . esc_html__('This typically occurs on managed WordPress hosting platforms. Please contact support with your hosting provider details.', 'simple-file-list') . '</p>';
186 echo '<p>' . esc_html__('This plugin will not work under this configuration.', 'simple-file-list') . '</p>';
187 echo '</div>';
188 });
189
190 return; // Stop plugin execution
191 }
192
193 // Initialize performance tracking
194 $eeSFL_StartTime = round( microtime(true) - (isset($_SERVER["REQUEST_TIME_FLOAT"]) ? sanitize_text_field(wp_unslash($_SERVER["REQUEST_TIME_FLOAT"])) : microtime(true)), 3);
195 $eeSFL_MemoryUsedStart = memory_get_usage();
196
197 // Set List ID
198 $eeSFL->eeListID = 1;
199
200 // Load Settings
201 $eeSFL->eeSFL_GetSettings($eeSFL->eeListID);
202
203 // Install or Update if Needed
204 if( is_admin() ) {
205 eeSFL_VersionCheck();
206 eeSFL_Debug_Log("Version check completed.", 'Loading');
207 }
208
209 eeSFL_Debug_Log('- List ID = ' . $eeSFL->eeListID . ' --> Setup Loaded.', 'General', $eeSFL->eeListID);
210 eeSFL_Debug_Log("Setup Complete for List ID: " . $eeSFL->eeListID, 'Loading');
211 eeSFL_Debug_Log("Final memory usage: " . round(memory_get_usage()/1024/1024, 2) . "MB", 'Loading');
212
213 } else {
214 eeSFL_Debug_Log("eeSFL class already exists, skipping initialization", 'Loading');
215 }
216
217 return TRUE;
218 }
219
220
221 // =============================================================================
222 // WORDPRESS HOOKS REGISTRATION
223 // =============================================================================
224 // Note: These hooks must be registered after eeSFL_Setup() runs and loads all includes
225
226 // Core Initialization
227 add_action('init', 'eeSFL_Setup'); // Main setup - loads all classes and functions
228 add_action('init', 'eeSFL_Textdomain'); // Load textdomain at init to comply with WordPress 6.7+ requirements
229
230 // Asset Management
231 add_action('init', 'eeSFL_RegisterAssets'); // Register scripts and styles
232 add_action('wp_enqueue_scripts', 'eeSFL_Enqueue'); // Frontend assets
233 add_action('admin_enqueue_scripts', 'eeSFL_AdminHead'); // Admin assets
234
235 // SFL Dashboard detection meta tag
236 add_action('wp_head', function() { echo '<meta name="simple-file-list" content="' . esc_attr(eeSFL_Version) . '">' . "\n"; });
237
238 // Admin Interface
239 add_action('admin_menu', 'eeSFL_AdminMenu'); // Add admin menu
240 add_action('current_screen', 'eeSFL_SetAdminTitle'); // Set admin page title
241 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'eeSFL_ActionPluginLinks'); // Plugin page links
242
243 // AJAX Handlers
244 add_action('wp_ajax_simplefilelist_upload_job', 'simplefilelist_upload_job');
245 add_action('wp_ajax_nopriv_simplefilelist_upload_job', 'simplefilelist_upload_job');
246 add_action('wp_ajax_simplefilelist_edit_job', 'simplefilelist_edit_job');
247 add_action('wp_ajax_nopriv_simplefilelist_edit_job', 'simplefilelist_edit_job');
248 add_action('wp_ajax_simplefilelist_confirm', 'simplefilelist_confirm');
249 add_action('wp_ajax_simplefilelist_dismiss', 'simplefilelist_dismiss'); // Acknowledge new features
250
251 // Shortcode
252 add_shortcode('eeSFL', 'eeSFL_FrontEnd'); // [eeSFL] shortcode
253
254 // Language Enabler
255 function eeSFL_Textdomain() {
256 // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound -- Required for private plugins
257 load_plugin_textdomain( 'simple-file-list', false, basename( dirname( __FILE__ ) ) . '/languages/' );
258 }
259
260
261 // Plugin Activation
262 function eeSFL_Activate() {
263
264 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
265
266 // Clear cached root path so it is re-verified after activation or update
267 delete_transient('eeSFL_root_path');
268
269 // Deactivate the Pro version if needed
270 $eePlugin = 'ee-simple-file-list-pro/ee-simple-file-list-pro.php';
271 if( is_plugin_active($eePlugin) ) {
272 deactivate_plugins($eePlugin);
273 }
274
275 return TRUE;
276 }
277 register_activation_hook( __FILE__, 'eeSFL_Activate' );
278
279
280
281 // Upon Deactivation...
282 function eeSFL_Deactivate() {
283 // Nothing needed for Free version
284 }
285 register_deactivation_hook( __FILE__, 'eeSFL_Deactivate' );
286
287
288 ?>