Increase Max Upload Filesize - Version 1.35

Version Description

Download this release

Release Info

Developer WebFactory
Plugin Icon 128x128 Increase Max Upload Filesize
Version 1.35
Comparing to
See all releases

Code changes from version 1.3 to 1.35

Files changed (2) hide show
  1. readme.txt +10 -2
  2. upload_max_file_size.php +248 -125
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: max upload file size, increase upload limit, increase file size limit, upl
4
  Requires at least: 3.0
5
  Requires PHP: 5.0
6
  Tested up to: 5.2
7
- Stable tag: 1.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -19,7 +19,9 @@ Plugin automatically detects upload limits set by WordPress and by the server /
19
 
20
  Access plugin's settings from the main WP admin menu.
21
 
22
- If you need help, please use the <a href="https://wordpress.org/support/plugin/upload-max-file-size/">official plugin support forum</a>.
 
 
23
 
24
 
25
  == Installation ==
@@ -53,6 +55,12 @@ Yes, it works with all servers. But, please know that server adjusted limits can
53
 
54
  == Changelog ==
55
 
 
 
 
 
 
 
56
  = v1.3 =
57
  * 2019/05/23
58
  * almost complete plugin rewrite
4
  Requires at least: 3.0
5
  Requires PHP: 5.0
6
  Tested up to: 5.2
7
+ Stable tag: 1.35
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
19
 
20
  Access plugin's settings from the main WP admin menu.
21
 
22
+ > Please read the maximum possible values displayed in the plugin and if needed contact your hosting provider.
23
+
24
+ If you need help, please use the <a href="https://wordpress.org/support/plugin/upload-max-file-size/">official plugin support forum</a>. We reply to all messages ASAP!
25
 
26
 
27
  == Installation ==
55
 
56
  == Changelog ==
57
 
58
+ = v1.35 =
59
+ * 2019/08/12
60
+ * better messages to clearly communicate max upload file size limits
61
+ * minor changes
62
+ * 309,800 downloads
63
+
64
  = v1.3 =
65
  * 2019/05/23
66
  * almost complete plugin rewrite
upload_max_file_size.php CHANGED
@@ -5,9 +5,9 @@
5
  Author: WebFactory Ltd
6
  Author URI: https://www.webfactoryltd.com/
7
  Plugin URI: https://wordpress.org/plugins/upload-max-file-size/
8
- Version: 1.3
9
  License: GPL2
10
- Text Domain:upload-max-filesize
11
 
12
  Copyright 2013 - 2019 WebFactory Ltd (email: support@webfactoryltd.com)
13
 
@@ -29,144 +29,267 @@
29
  // main plugin class
30
  class WF_Upload_Max_File_Size
31
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- static function init()
34
- {
35
- // Hook for adding admin menus
36
- add_action('admin_menu', array(__CLASS__, 'upload_max_file_size_add_pages'));
37
- add_filter('upload_size_limit', array(__CLASS__, 'upload_max_increase_upload'));
 
 
38
 
39
- if (isset($_POST['upload_max_file_size_field']) && wp_verify_nonce($_POST['upload_max_file_size_nonce'], 'upload_max_file_size_action')) {
40
- $number = (int)$_POST['upload_max_file_size_field'] * 1024 * 1024;
41
- update_option('max_file_size', $number);
42
- wp_safe_redirect(admin_url('?page=upload_max_file_size&max-size-updated=true'));
43
- }
44
- } // init
45
-
46
- /**
47
- * Add menu pages
48
- *
49
- * @since 1.4
50
- *
51
- * @return null
52
- *
53
- */
54
- static function upload_max_file_size_add_pages()
55
- {
56
- // Add a new menu under Settings
57
- add_menu_page('Increase Max Upload File Size', 'Increase Maximum Upload File Size', 'manage_options', 'upload_max_file_size', array(__CLASS__, 'upload_max_file_size_dash'), 'dashicons-admin-tools');
58
- } // upload_max_file_size_add_pages
59
-
60
- /**
61
- * Get closest value from array
62
- *
63
- * @since 1.4
64
- *
65
- * @param int search value
66
- * @param array to find closest value in
67
- *
68
- * @return int in MB, closest value
69
- *
70
- */
71
- static function get_closest($search, $arr)
72
- {
73
- $closest = null;
74
- foreach ($arr as $item) {
75
- if ($closest === null || abs($search - $closest) > abs($item - $search)) {
76
- $closest = $item;
77
- }
78
- }
79
- return $closest;
80
  }
 
 
 
 
 
 
81
 
82
- /**
83
- * Dashboard Page
84
- *
85
- * @since 1.4
86
- *
87
- * @return null
88
- *
89
- */
90
- static function upload_max_file_size_dash()
91
- {
92
- echo '<style>';
93
- echo '.wrap, .wrap p { font-size: 15px; } .form-table th { width: 230px; }';
94
- echo '</style>';
95
-
96
- if (isset($_GET['max-size-updated'])) {
97
- echo '<div class="notice-success notice is-dismissible"><p>Maximum Upload File Size Saved!</p></div>';
98
- }
99
 
100
- $ini_size = ini_get('upload_max_filesize');
101
- if (!$ini_size) {
102
- $ini_size = 'unknown';
103
- } elseif (is_numeric($ini_size)) {
104
- $ini_size .= ' bytes';
105
- } else {
106
- $ini_size .= 'B';
107
- }
108
 
109
- $wp_size = wp_max_upload_size();
110
- if (!$wp_size) {
111
- $wp_size = 'unknown';
112
- } else {
113
- $wp_size = round(($wp_size / 1024 / 1024));
114
- $wp_size = $wp_size == 1024 ? '1GB' : $wp_size . 'MB';
115
- }
116
 
117
- $max_size = get_option('max_file_size');
118
- if (!$max_size) {
119
- $max_size = 64 * 1024 * 1024;
120
- }
121
- $max_size = $max_size / 1024 / 1024;
122
 
 
 
 
123
 
124
- $upload_sizes = array(16, 32, 64, 128, 256, 512, 1024);
 
 
 
 
 
 
 
 
125
 
126
- $current_max_size = self::get_closest($max_size, $upload_sizes);
127
 
128
- echo '<div class="wrap">';
129
- echo '<h1>Increase Maximum Upload File Size</h1><br><br>';
130
 
131
- echo 'Maximum upload file size, set by your hosting provider: ' . $ini_size . '.<br>';
132
- echo 'Maximum upload file size, set by WordPress: ' . $wp_size . '.<br>';
133
- echo '<br><b>Important</b>: if you want to upload files larger than the limit set by your hosting provider, you have to contact your hosting provider.<br>It\'s NOT possible to increase the hosting defined limit from a plugin.';
134
- echo '<form method="post">';
135
- settings_fields("header_section");
136
- echo '<table class="form-table"><tbody><tr><th scope="row"><label for="upload_max_file_size_field">Choose Maximum Upload File Size</label></th><td>';
137
- echo '<select id="upload_max_file_size_field" name="upload_max_file_size_field">';
138
- foreach ($upload_sizes as $size) {
139
- echo '<option value="' . $size . '" ' . ($size == $current_max_size ? 'selected' : '') . '>' . ($size == 1024 ? '1GB' : $size . 'MB') . '</option>';
140
- }
141
- echo '</select>';
142
- echo '</td></tr></tbody></table>';
143
- echo wp_nonce_field('upload_max_file_size_action', 'upload_max_file_size_nonce');
144
- submit_button();
145
- echo '</form>';
146
-
147
- echo '<p style="display: inline-block; padding: 15px; background-color: #ddd;">Did the plugin help you? Please <a href="https://wordpress.org/support/plugin/upload-max-file-size/reviews/?filter=5" target="_blank">rate it with ★★★★★</a>. It\'s what keeps it free!</p>';
148
-
149
- echo '</div>';
150
- } // upload_max_file_size_dash
151
-
152
- /**
153
- * Filter to increase max_file_size
154
- *
155
- * @since 1.4
156
- *
157
- * @return int max_size in bytes
158
- *
159
- */
160
- static function upload_max_increase_upload()
161
- {
162
- $max_size = get_option('max_file_size');
163
- if (!$max_size) {
164
- $max_size = 64 * 1024 * 1024;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
 
 
166
 
167
- return $max_size;
168
- } // upload_max_increase_upload
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
 
 
 
170
  } // class WF_Upload_Max_File_Size
171
 
172
  add_action('init', array('WF_Upload_Max_File_Size', 'init'));
5
  Author: WebFactory Ltd
6
  Author URI: https://www.webfactoryltd.com/
7
  Plugin URI: https://wordpress.org/plugins/upload-max-file-size/
8
+ Version: 1.35
9
  License: GPL2
10
+ Text Domain: upload-max-file-size
11
 
12
  Copyright 2013 - 2019 WebFactory Ltd (email: support@webfactoryltd.com)
13
 
29
  // main plugin class
30
  class WF_Upload_Max_File_Size
31
  {
32
+ static function init()
33
+ {
34
+ if (is_admin()) {
35
+ add_action('admin_menu', array(__CLASS__, 'upload_max_file_size_add_pages'));
36
+ add_filter('install_plugins_table_api_args_featured', array(__CLASS__, 'featured_plugins_tab'));
37
+ add_filter('plugin_action_links_' . plugin_basename(__FILE__), array(__CLASS__, 'plugin_action_links'));
38
+ add_filter('plugin_row_meta', array(__CLASS__, 'plugin_meta_links'), 10, 2);
39
+ add_filter('admin_footer_text', array(__CLASS__, 'admin_footer_text'));
40
+
41
+ if (isset($_POST['upload_max_file_size_field'])
42
+ && wp_verify_nonce($_POST['upload_max_file_size_nonce'], 'upload_max_file_size_action')
43
+ && is_numeric($_POST['upload_max_file_size_field'])) {
44
+ $max_size = (int) $_POST['upload_max_file_size_field'] * 1024 * 1024;
45
+ update_option('max_file_size', $max_size);
46
+ wp_safe_redirect(admin_url('?page=upload_max_file_size&max-size-updated=true'));
47
+ }
48
+ }
49
+
50
+ add_filter('upload_size_limit', array(__CLASS__, 'upload_max_increase_upload'));
51
+ } // init
52
+
53
+
54
+ // get plugin version from header
55
+ static function get_plugin_version() {
56
+ $plugin_data = get_file_data(__FILE__, array('version' => 'Version'), 'plugin');
57
 
58
+ return $plugin_data['version'];
59
+ } // get_plugin_version
60
+
61
+
62
+ // test if we're on plugin's page
63
+ static function is_plugin_page() {
64
+ $current_screen = get_current_screen();
65
 
66
+ if ($current_screen->id == 'toplevel_page_upload_max_file_size') {
67
+ return true;
68
+ } else {
69
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
+ } // is_plugin_page
72
+
73
+
74
+ // add settings link to plugins page
75
+ static function plugin_action_links($links) {
76
+ $settings_link = '<a href="' . admin_url('admin.php?page=upload_max_file_size') . '" title="Adjust Max File Upload Size Settings">Settings</a>';
77
 
78
+ array_unshift($links, $settings_link);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
+ return $links;
81
+ } // plugin_action_links
 
 
 
 
 
 
82
 
 
 
 
 
 
 
 
83
 
84
+ // add links to plugin's description in plugins table
85
+ static function plugin_meta_links($links, $file) {
86
+ $support_link = '<a target="_blank" href="https://wordpress.org/support/plugin/upload-max-file-size" title="Get help">Support</a>';
87
+
 
88
 
89
+ if ($file == plugin_basename(__FILE__)) {
90
+ $links[] = $support_link;
91
+ }
92
 
93
+ return $links;
94
+ } // plugin_meta_links
95
+
96
+
97
+ // additional powered by text in admin footer; only on plugin's page
98
+ static function admin_footer_text($text) {
99
+ if (!self::is_plugin_page()) {
100
+ return $text;
101
+ }
102
 
103
+ $text = '<i>Increase Maximum Upload File Size v' . self::get_plugin_version() . ' by <a href="https://www.webfactoryltd.com/" title="Visit our site to get more great plugins" target="_blank">WebFactory Ltd</a>.</i> ' . $text;
104
 
105
+ return $text;
106
+ } // admin_footer_text
107
 
108
+
109
+ /**
110
+ * Add menu pages
111
+ *
112
+ * @since 1.4
113
+ *
114
+ * @return null
115
+ *
116
+ */
117
+ static function upload_max_file_size_add_pages()
118
+ {
119
+ // Add a new menu on main menu
120
+ add_menu_page('Increase Max Upload File Size', 'Increase Maximum Upload File Size', 'manage_options', 'upload_max_file_size', array(__CLASS__, 'upload_max_file_size_dash'), 'dashicons-upload');
121
+ } // upload_max_file_size_add_pages
122
+
123
+
124
+ /**
125
+ * Get closest value from array
126
+ *
127
+ * @since 1.4
128
+ *
129
+ * @param int search value
130
+ * @param array to find closest value in
131
+ *
132
+ * @return int in MB, closest value
133
+ *
134
+ */
135
+ static function get_closest($search, $arr)
136
+ {
137
+ $closest = null;
138
+ foreach ($arr as $item) {
139
+ if ($closest === null || abs($search - $closest) > abs($item - $search)) {
140
+ $closest = $item;
141
+ }
142
+ }
143
+ return $closest;
144
+ } // get_closest
145
+
146
+
147
+ /**
148
+ * Dashboard Page
149
+ *
150
+ * @since 1.4
151
+ *
152
+ * @return null
153
+ *
154
+ */
155
+ static function upload_max_file_size_dash()
156
+ {
157
+ echo '<style>';
158
+ echo '.wrap, .wrap p { font-size: 15px; } .form-table th { width: 230px; }';
159
+ echo '.gray-box { display: inline-block; padding: 15px; background-color: #e6e6e6; }';
160
+ echo '</style>';
161
+
162
+ if (isset($_GET['max-size-updated'])) {
163
+ echo '<div class="notice-success notice is-dismissible"><p>Maximum Upload File Size Saved &amp; Changed!</p></div>';
164
+ }
165
+
166
+ $ini_size = ini_get('upload_max_filesize');
167
+ if (!$ini_size) {
168
+ $ini_size = 'unknown';
169
+ } elseif (is_numeric($ini_size)) {
170
+ $ini_size .= ' bytes';
171
+ } else {
172
+ $ini_size .= 'B';
173
+ }
174
+
175
+ $wp_size = wp_max_upload_size();
176
+ if (!$wp_size) {
177
+ $wp_size = 'unknown';
178
+ } else {
179
+ $wp_size = round(($wp_size / 1024 / 1024));
180
+ $wp_size = $wp_size == 1024 ? '1GB' : $wp_size . 'MB';
181
+ }
182
+
183
+ $max_size = get_option('max_file_size');
184
+ if (!$max_size) {
185
+ $max_size = 64 * 1024 * 1024;
186
+ }
187
+ $max_size = $max_size / 1024 / 1024;
188
+
189
+
190
+ $upload_sizes = array(16, 32, 64, 128, 256, 512, 1024);
191
+
192
+ $current_max_size = self::get_closest($max_size, $upload_sizes);
193
+
194
+ echo '<div class="wrap">';
195
+ echo '<h1><span class="dashicons dashicons-upload" style="font-size: inherit; line-height: unset;"></span> Increase Maximum Upload File Size</h1><br>';
196
+
197
+ echo '<p class="gray-box"><b>Important</b>: if you want to upload files larger than ' . $ini_size . ' (which is the limit set by your hosting provider) you have to contact your hosting provider.<br>It\'s <b>NOT POSSIBLE</b> to increase that hosting defined upload limit from a plugin.</p>';
198
+
199
+ echo '<p>Maximum upload file size, set by your hosting provider: ' . $ini_size . '.<br>';
200
+ echo 'Maximum upload file size, set by WordPress: ' . $wp_size . '.</p>';
201
+
202
+ echo '<form method="post">';
203
+ settings_fields("header_section");
204
+ echo '<table class="form-table"><tbody><tr><th scope="row"><label for="upload_max_file_size_field">Choose Maximum Upload File Size</label></th><td>';
205
+ echo '<select id="upload_max_file_size_field" name="upload_max_file_size_field">';
206
+ foreach ($upload_sizes as $size) {
207
+ echo '<option value="' . $size . '" ' . ($size == $current_max_size ? 'selected' : '') . '>' . ($size == 1024 ? '1GB' : $size . 'MB') . '</option>';
208
+ }
209
+ echo '</select>';
210
+ echo '</td></tr></tbody></table>';
211
+ echo wp_nonce_field('upload_max_file_size_action', 'upload_max_file_size_nonce');
212
+ submit_button();
213
+ echo '</form>';
214
+
215
+ echo '<p class="gray-box">Did the plugin help you? Please <a href="https://wordpress.org/support/plugin/upload-max-file-size/reviews/?filter=5" target="_blank">rate it with ★★★★★</a>. It\'s what keeps it free!</p>';
216
+
217
+ echo '</div>';
218
+ } // upload_max_file_size_dash
219
+
220
+
221
+ /**
222
+ * Filter to increase max_file_size
223
+ *
224
+ * @since 1.4
225
+ *
226
+ * @return int max_size in bytes
227
+ *
228
+ */
229
+ static function upload_max_increase_upload()
230
+ {
231
+ $max_size = (int) get_option('max_file_size');
232
+ if (!$max_size) {
233
+ $max_size = 64 * 1024 * 1024;
234
+ }
235
+
236
+ return $max_size;
237
+ } // upload_max_increase_upload
238
+
239
+
240
+ // add our plugins to recommended list
241
+ static function plugins_api_result($res, $action, $args) {
242
+ remove_filter('plugins_api_result', array(__CLASS__, 'plugins_api_result'), 10, 3);
243
+
244
+ $res = self::add_plugin_favs('under-construction-page', $res);
245
+ $res = self::add_plugin_favs('wp-reset', $res);
246
+ $res = self::add_plugin_favs('eps-301-redirects', $res);
247
+
248
+ return $res;
249
+ } // plugins_api_result
250
+
251
+
252
+ // helper function for adding plugins to fav list
253
+ static function featured_plugins_tab($args) {
254
+ add_filter('plugins_api_result', array(__CLASS__, 'plugins_api_result'), 10, 3);
255
+
256
+ return $args;
257
+ } // featured_plugins_tab
258
+
259
+
260
+ // add single plugin to list of favs
261
+ static function add_plugin_favs($plugin_slug, $res) {
262
+ if (!empty($res->plugins) && is_array($res->plugins)) {
263
+ foreach ($res->plugins as $plugin) {
264
+ if (is_object($plugin) && !empty($plugin->slug) && $plugin->slug == $plugin_slug) {
265
+ return $res;
266
  }
267
+ } // foreach
268
+ }
269
 
270
+ if ($plugin_info = get_transient('wf-plugin-info-' . $plugin_slug)) {
271
+ array_unshift($res->plugins, $plugin_info);
272
+ } else {
273
+ $plugin_info = plugins_api('plugin_information', array(
274
+ 'slug' => $plugin_slug,
275
+ 'is_ssl' => is_ssl(),
276
+ 'fields' => array(
277
+ 'banners' => true,
278
+ 'reviews' => true,
279
+ 'downloaded' => true,
280
+ 'active_installs' => true,
281
+ 'icons' => true,
282
+ 'short_description' => true,
283
+ )
284
+ ));
285
+ if (!is_wp_error($plugin_info)) {
286
+ $res->plugins[] = $plugin_info;
287
+ set_transient('wf-plugin-info-' . $plugin_slug, $plugin_info, DAY_IN_SECONDS * 7);
288
+ }
289
+ }
290
 
291
+ return $res;
292
+ } // add_plugin_favs
293
  } // class WF_Upload_Max_File_Size
294
 
295
  add_action('init', array('WF_Upload_Max_File_Size', 'init'));