WP Add Mime Types - Version 1.3.6

Version Description

  • Fixed load_plugin_textdomain setting.
Download this release

Release Info

Developer kimipooh
Plugin Icon wp plugin WP Add Mime Types
Version 1.3.6
Comparing to
See all releases

Code changes from version 1.3.5 to 1.3.6

Files changed (2) hide show
  1. readme.txt +4 -1
  2. wp-add-mime-types.php +140 -140
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Kimiya Kitani
3
  Tags: mime,file extention
4
  Requires at least: 3.0
5
  Tested up to: 4.2.2
6
- Stable tag: 1.3.5
7
 
8
  The plugin additionally allows the mime types and file extensions to WordPress.
9
 
@@ -38,6 +38,9 @@ You can see the list of allowed mime types and file extensions by WordPress.
38
 
39
  == Changelog ==
40
 
 
 
 
41
  = 1.3.5 =
42
  * Fixed load_plugin_textdomain setting.
43
 
3
  Tags: mime,file extention
4
  Requires at least: 3.0
5
  Tested up to: 4.2.2
6
+ Stable tag: 1.3.6
7
 
8
  The plugin additionally allows the mime types and file extensions to WordPress.
9
 
38
 
39
  == Changelog ==
40
 
41
+ = 1.3.6 =
42
+ * Fixed load_plugin_textdomain setting.
43
+
44
  = 1.3.5 =
45
  * Fixed load_plugin_textdomain setting.
46
 
wp-add-mime-types.php CHANGED
@@ -1,140 +1,140 @@
1
- <?php
2
- /*
3
- Plugin Name: WP Add Mime Types
4
- Plugin URI:
5
- Description: The plugin additionally allows the mime types and file extensions to WordPress.
6
- Version: 1.3.5
7
- Author: Kimiya Kitani
8
- Author URI: http://kitaney.jp/~kitani
9
- */
10
-
11
- // Multi-language support.
12
- load_plugin_textdomain('wp-add-mime-types', false, 'wp-add-mime-types/lang/');
13
-
14
-
15
- $default_var = array(
16
- 'wp_add_mime_types' => '1.3.5',
17
- );
18
-
19
- // Add Setting to WordPress 'Settings' menu.
20
- add_action('admin_menu', 'add_to_settings_menu');
21
-
22
- function add_to_settings_menu(){
23
-
24
- // add_options_page (Title, Setting Title, Permission, Special Definition, function name);
25
- add_options_page(__('WP Add Mime Types Admin Settings', 'wp-add-mime-types'), __('Mime Type Settings','wp-add-mime-types'), 'manage_options', __FILE__,'admin_settings_page');
26
-
27
- }
28
-
29
- // Processing Setting menu for the plugin.
30
- function admin_settings_page(){
31
- // Loading the stored setting data (wp_add_mime_types_array) from WordPress database.
32
- $settings = get_option('wp_add_mime_types_array');
33
-
34
- $permission = false;
35
- // The user who can manage the WordPress option can only access the Setting menu of this plugin.
36
- if(current_user_can('manage_options')) $permission = true;
37
- // If the adding data is not set, the value "mime_type_values" sets "empty".
38
- if(!isset($settings['mime_type_values'])) $settings['mime_type_values'] = '';
39
- // When the adding data is saved (posted) at the setting menu, the data will update to the WordPress database after the security check
40
- if(isset($_POST['mime_type_values'])){
41
- $p_set = esc_attr(strip_tags(html_entity_decode($_POST['mime_type_values']),ENT_QUOTES));
42
- $mime_type_values = explode("\n", $p_set);
43
- foreach($mime_type_values as $m_type=>$m_value)
44
- // " " is the Japanese multi-byte space. If the character is found out, it automatically change the space.
45
- $mime_type_values[$m_type] = trim(str_replace(" ", " ", $m_value));
46
- $settings['mime_type_values'] = serialize($mime_type_values);
47
- }else
48
- $mime_type_values = unserialize($settings['mime_type_values']);
49
-
50
-
51
- // Update to WordPress Data.
52
- update_option('wp_add_mime_types_array', $settings);
53
-
54
- ?>
55
- <div class="add_mime_media_admin_setting_page_updated"><p><strong><?php _e('Updated', 'wp-add-mime-types'); ?></strong></p></div>
56
-
57
- <div id="add_mime_media_admin_menu">
58
- <h2><?php _e('WP Add Mime Types Admin Settings', 'wp-add-mime-types'); ?></h2>
59
-
60
- <form method="post" action="">
61
- <fieldset style="border:1px solid #777777; width: 750px; padding-left: 6px;">
62
- <legend><h3><?php _e('List of allowed mime types and file extensions by WordPress','wp-add-mime-types'); ?></h3></legend>
63
- <div style="overflow:scroll; height: 500px;">
64
- <table>
65
- <?php
66
- // Get the list of the file extensions which WordPress allows the upload.
67
- $allowed_mime_values = get_allowed_mime_types();
68
-
69
- // Getting the extension name in the saved data
70
- foreach ($mime_type_values as $line){
71
- $line_value = explode("=", $line);
72
- if(count($line_value) != 2) continue;
73
- $mimes[trim($line_value[0])] = trim($line_value[1]);
74
- }
75
-
76
- // List view of the allowed mime types including the addition (red color) in the admin settings.
77
- foreach($allowed_mime_values as $type=>$value){
78
- if(isset($mimes)){
79
- $add_mime_type_check = "";
80
- foreach($mimes as $a_type=>$a_value){
81
- if(!strcmp($type, $a_type)){
82
- $add_mime_type_check = " style='color:red;'";
83
- break;
84
- }
85
- }
86
-
87
- echo "<tr><td$add_mime_type_check>$type</td><td$add_mime_type_check>=</td><td$add_mime_type_check>$value</td></tr>\n";
88
- }else
89
- echo "<tr><td>$type</td><td>=</td><td>$value</td></tr>\n";
90
- }
91
- ?>
92
- </table>
93
- </div>
94
- </fieldset>
95
- <br/>
96
-
97
- <fieldset style="border:1px solid #777777; width: 750px; padding-left: 6px;">
98
- <legend><h3><?php _e('Add Values','wp-add-mime-types'); ?></h3></legend>
99
- <p><?php _e('* About the mime type value for the file extension, please search "mime type [file extension name] using a search engine.<br/> Ex. "epub = application/epub+zip in http://ja.wikipedia.org/wiki/EPUB."','wp-add-mime-types'); ?></p>
100
-
101
- <?php // If the permission is not allowed, the user can only read the setting. ?>
102
- <textarea name="mime_type_values" cols="100" rows="10" <?php if(!$permission) echo "disabled"; ?>><?php if(isset($mimes) && is_array($mimes)) foreach ($mimes as $m_type=>$m_value) echo $m_type . "\t= " .$m_value . "\n"; ?></textarea>
103
- </fieldset>
104
-
105
- <br/>
106
-
107
- <input type="submit" value="<?php _e('Save', 'wp-add-mime-types'); ?>" />
108
- </form>
109
-
110
- </div>
111
-
112
- <?php
113
- }
114
- // Procedure for adding the mime types and file extensions to WordPress.
115
- function add_allow_upload_extension( $mimes ) {
116
- $settings = get_option('wp_add_mime_types_array');
117
-
118
- if(!isset($settings['mime_type_values']) || empty($settings['mime_type_values'])) return $mimes;
119
- else
120
- $mime_type_values = unserialize($settings['mime_type_values']);
121
-
122
- foreach ($mime_type_values as $line){
123
- // If 2 or more "=" character in the line data, it will be ignored.
124
- $line_value = explode("=", $line);
125
- if(count($line_value) != 2) continue;
126
-
127
- // " " is the Japanese multi-byte space. If the character is found out, it automatically change the space.
128
- $mimes[trim($line_value[0])] = trim(str_replace(" ", " ", $line_value[1]));
129
- }
130
-
131
- //$mimes['dot'] = 'application/word';
132
-
133
- return $mimes;
134
- }
135
-
136
- // Register the Procedure process to WordPress.
137
- add_filter( 'upload_mimes', 'add_allow_upload_extension' );
138
-
139
-
140
- ?>
1
+ <?php
2
+ /*
3
+ Plugin Name: WP Add Mime Types
4
+ Plugin URI:
5
+ Description: The plugin additionally allows the mime types and file extensions to WordPress.
6
+ Version: 1.3.6
7
+ Author: Kimiya Kitani
8
+ Author URI: http://kitaney.jp/~kitani
9
+ */
10
+
11
+ // Multi-language support.
12
+ load_plugin_textdomain('wp-add-mime-types', false, plugin_dir_path(__FILE__) . '/wp-add-mime-types/lang/');
13
+
14
+
15
+ $default_var = array(
16
+ 'wp_add_mime_types' => '1.3.6',
17
+ );
18
+
19
+ // Add Setting to WordPress 'Settings' menu.
20
+ add_action('admin_menu', 'add_to_settings_menu');
21
+
22
+ function add_to_settings_menu(){
23
+
24
+ // add_options_page (Title, Setting Title, Permission, Special Definition, function name);
25
+ add_options_page(__('WP Add Mime Types Admin Settings', 'wp-add-mime-types'), __('Mime Type Settings','wp-add-mime-types'), 'manage_options', __FILE__,'admin_settings_page');
26
+
27
+ }
28
+
29
+ // Processing Setting menu for the plugin.
30
+ function admin_settings_page(){
31
+ // Loading the stored setting data (wp_add_mime_types_array) from WordPress database.
32
+ $settings = get_option('wp_add_mime_types_array');
33
+
34
+ $permission = false;
35
+ // The user who can manage the WordPress option can only access the Setting menu of this plugin.
36
+ if(current_user_can('manage_options')) $permission = true;
37
+ // If the adding data is not set, the value "mime_type_values" sets "empty".
38
+ if(!isset($settings['mime_type_values'])) $settings['mime_type_values'] = '';
39
+ // When the adding data is saved (posted) at the setting menu, the data will update to the WordPress database after the security check
40
+ if(isset($_POST['mime_type_values'])){
41
+ $p_set = esc_attr(strip_tags(html_entity_decode($_POST['mime_type_values']),ENT_QUOTES));
42
+ $mime_type_values = explode("\n", $p_set);
43
+ foreach($mime_type_values as $m_type=>$m_value)
44
+ // " " is the Japanese multi-byte space. If the character is found out, it automatically change the space.
45
+ $mime_type_values[$m_type] = trim(str_replace(" ", " ", $m_value));
46
+ $settings['mime_type_values'] = serialize($mime_type_values);
47
+ }else
48
+ $mime_type_values = unserialize($settings['mime_type_values']);
49
+
50
+
51
+ // Update to WordPress Data.
52
+ update_option('wp_add_mime_types_array', $settings);
53
+
54
+ ?>
55
+ <div class="add_mime_media_admin_setting_page_updated"><p><strong><?php _e('Updated', 'wp-add-mime-types'); ?></strong></p></div>
56
+
57
+ <div id="add_mime_media_admin_menu">
58
+ <h2><?php _e('WP Add Mime Types Admin Settings', 'wp-add-mime-types'); ?></h2>
59
+
60
+ <form method="post" action="">
61
+ <fieldset style="border:1px solid #777777; width: 750px; padding-left: 6px;">
62
+ <legend><h3><?php _e('List of allowed mime types and file extensions by WordPress','wp-add-mime-types'); ?></h3></legend>
63
+ <div style="overflow:scroll; height: 500px;">
64
+ <table>
65
+ <?php
66
+ // Get the list of the file extensions which WordPress allows the upload.
67
+ $allowed_mime_values = get_allowed_mime_types();
68
+
69
+ // Getting the extension name in the saved data
70
+ foreach ($mime_type_values as $line){
71
+ $line_value = explode("=", $line);
72
+ if(count($line_value) != 2) continue;
73
+ $mimes[trim($line_value[0])] = trim($line_value[1]);
74
+ }
75
+
76
+ // List view of the allowed mime types including the addition (red color) in the admin settings.
77
+ foreach($allowed_mime_values as $type=>$value){
78
+ if(isset($mimes)){
79
+ $add_mime_type_check = "";
80
+ foreach($mimes as $a_type=>$a_value){
81
+ if(!strcmp($type, $a_type)){
82
+ $add_mime_type_check = " style='color:red;'";
83
+ break;
84
+ }
85
+ }
86
+
87
+ echo "<tr><td$add_mime_type_check>$type</td><td$add_mime_type_check>=</td><td$add_mime_type_check>$value</td></tr>\n";
88
+ }else
89
+ echo "<tr><td>$type</td><td>=</td><td>$value</td></tr>\n";
90
+ }
91
+ ?>
92
+ </table>
93
+ </div>
94
+ </fieldset>
95
+ <br/>
96
+
97
+ <fieldset style="border:1px solid #777777; width: 750px; padding-left: 6px;">
98
+ <legend><h3><?php _e('Add Values','wp-add-mime-types'); ?></h3></legend>
99
+ <p><?php _e('* About the mime type value for the file extension, please search "mime type [file extension name] using a search engine.<br/> Ex. "epub = application/epub+zip in http://ja.wikipedia.org/wiki/EPUB."','wp-add-mime-types'); ?></p>
100
+
101
+ <?php // If the permission is not allowed, the user can only read the setting. ?>
102
+ <textarea name="mime_type_values" cols="100" rows="10" <?php if(!$permission) echo "disabled"; ?>><?php if(isset($mimes) && is_array($mimes)) foreach ($mimes as $m_type=>$m_value) echo $m_type . "\t= " .$m_value . "\n"; ?></textarea>
103
+ </fieldset>
104
+
105
+ <br/>
106
+
107
+ <input type="submit" value="<?php _e('Save', 'wp-add-mime-types'); ?>" />
108
+ </form>
109
+
110
+ </div>
111
+
112
+ <?php
113
+ }
114
+ // Procedure for adding the mime types and file extensions to WordPress.
115
+ function add_allow_upload_extension( $mimes ) {
116
+ $settings = get_option('wp_add_mime_types_array');
117
+
118
+ if(!isset($settings['mime_type_values']) || empty($settings['mime_type_values'])) return $mimes;
119
+ else
120
+ $mime_type_values = unserialize($settings['mime_type_values']);
121
+
122
+ foreach ($mime_type_values as $line){
123
+ // If 2 or more "=" character in the line data, it will be ignored.
124
+ $line_value = explode("=", $line);
125
+ if(count($line_value) != 2) continue;
126
+
127
+ // " " is the Japanese multi-byte space. If the character is found out, it automatically change the space.
128
+ $mimes[trim($line_value[0])] = trim(str_replace(" ", " ", $line_value[1]));
129
+ }
130
+
131
+ //$mimes['dot'] = 'application/word';
132
+
133
+ return $mimes;
134
+ }
135
+
136
+ // Register the Procedure process to WordPress.
137
+ add_filter( 'upload_mimes', 'add_allow_upload_extension' );
138
+
139
+
140
+ ?>