PluginProbe ʕ •ᴥ•ʔ
reSmush.it : The original free image compressor and optimizer plugin / 0.4.12
reSmush.it : The original free image compressor and optimizer plugin v0.4.12
1.0.6 trunk 0.1.1 0.1.10 0.1.11 0.1.12 0.1.13 0.1.14 0.1.15 0.1.16 0.1.17 0.1.18 0.1.19 0.1.2 0.1.20 0.1.21 0.1.22 0.1.23 0.1.3 0.1.4 0.1.5 0.1.6 0.1.7 0.1.8 0.1.9 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 0.3.0 0.3.1 0.3.10 0.3.11 0.3.12 0.3.2 0.3.3 0.3.4 0.3.5 0.3.6 0.3.7 0.3.8 0.3.9 0.4.0 0.4.1 0.4.10 0.4.11 0.4.12 0.4.13 0.4.14 0.4.2 0.4.3 0.4.4 0.4.5 0.4.6 0.4.7 0.4.8 0.4.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5
resmushit-image-optimizer / resmushit.admin.php
resmushit-image-optimizer Last commit date
classes 3 years ago css 3 years ago images 2 years ago js 3 years ago languages 3 years ago readme.txt 2 years ago resmushit.admin.php 2 years ago resmushit.inc.php 3 years ago resmushit.php 2 years ago resmushit.settings.php 2 years ago
resmushit.admin.php
192 lines
1 <?php
2 /**
3 *
4 * Create menu entries and routing
5 *
6 * @param none
7 * @return none
8 */
9 function resmushit_create_menu() {
10 if ( is_super_admin() )
11 add_media_page( 'reSmush.it', 'reSmush.it', 'manage_options', 'resmushit_options', 'resmushit_settings_page');
12 }
13 add_action( 'admin_menu','resmushit_create_menu');
14
15
16
17 /**
18 *
19 * Declares settings entries
20 *
21 * @param none
22 * @return none
23 */
24 function resmushit_settings_declare() {
25 register_setting( 'resmushit-settings', 'resmushit_on_upload' );
26 register_setting( 'resmushit-settings', 'resmushit_qlty' );
27 register_setting( 'resmushit-settings', 'resmushit_statistics' );
28 register_setting( 'resmushit-settings', 'resmushit_logs' );
29 register_setting( 'resmushit-settings', 'resmushit_cron' );
30 register_setting( 'resmushit-settings', 'resmushit_preserve_exif' );
31 register_setting( 'resmushit-settings', 'resmushit_remove_unsmushed' );
32 register_setting( 'resmushit-settings', 'resmushit_notice_close' );
33 }
34 add_action( 'admin_init', 'resmushit_settings_declare' );
35
36
37
38 /**
39 *
40 * Add Columns to the media panel
41 *
42 * @param array $columns
43 * @return $columns
44 */
45 function resmushit_media_list_add_column( $columns ) {
46 $columns["resmushit_disable"] = __('Disable of reSmush.it', 'resmushit-image-optimizer');
47 $columns["resmushit_status"] = __('reSmush.it status', 'resmushit-image-optimizer');
48 return $columns;
49 }
50 add_filter( 'manage_media_columns', 'resmushit_media_list_add_column' );
51
52
53
54 /**
55 *
56 * Sort Columns to the media panel
57 *
58 * @param array $columns
59 * @return $columns
60 */
61 function resmushit_media_list_sort_column( $columns ) {
62 $columns["resmushit_disable"] = "resmushit_disable";
63 $columns["resmushit_status"] = "resmushit_status";
64 return $columns;
65 }
66 add_filter( 'manage_upload_sortable_columns', 'resmushit_media_list_sort_column' );
67
68
69
70 /**
71 *
72 * Add Value to Columns of the media panel
73 *
74 * @param string $column_name
75 * @param string $identifier of the column
76 * @return none
77 */
78 function resmushit_media_list_add_column_value( $column_name, $id ) {
79 if ( $column_name == "resmushit_disable" )
80 reSmushitUI::mediaListCustomValuesDisable($id);
81 else if ( $column_name == "resmushit_status" )
82 reSmushitUI::mediaListCustomValuesStatus($id);
83 }
84 add_action( 'manage_media_custom_column', 'resmushit_media_list_add_column_value', 10, 2 );
85
86
87
88 /**
89 *
90 * Add custom field to attachment
91 *
92 * @param array $form_fields
93 * @param object $post
94 * @return array
95 */
96 function resmushit_image_attachment_add_status_button($form_fields, $post) {
97 if ( !preg_match("/image.*/", $post->post_mime_type) )
98 return $form_fields;
99
100 $form_fields["rsmt-disabled-checkbox"] = array(
101 "label" => __("Disable of reSmush.it", "resmushit-image-optimizer"),
102 "input" => "html",
103 "value" => '',
104 "html" => reSmushitUI::mediaListCustomValuesDisable($post->ID, true)
105 );
106
107 $form_fields["rsmt-status-button"] = array(
108 "label" => __("reSmush.it status", "resmushit-image-optimizer"),
109 "input" => "html",
110 "value" => '',
111 "html" => reSmushitUI::mediaListCustomValuesStatus($post->ID, true)
112 );
113 return $form_fields;
114 }
115 add_filter("attachment_fields_to_edit", "resmushit_image_attachment_add_status_button", null, 2);
116
117
118
119 /**
120 *
121 * Settings page builder
122 *
123 * @param none
124 * @return none
125 */
126 function resmushit_settings_page() {
127 ?>
128 <div class='rsmt-panels'>
129 <div class="rsmt-cols w66 iln-block">
130 <?php reSmushitUI::headerPanel();?>
131 <?php reSmushitUI::alertPanel();?>
132 <?php reSmushitUI::bulkPanel();?>
133 <?php reSmushitUI::bigFilesPanel();?>
134 <?php reSmushitUI::statisticsPanel();?>
135 <?php reSmushitUI::restorePanel();?>
136 </div>
137 <div class="rsmt-cols w33 iln-block">
138 <?php reSmushitUI::settingsPanel();?>
139 <?php reSmushitUI::newsPanel();?>
140 </div>
141 </div>
142 <?php
143 }
144
145
146
147 /**
148 *
149 * Assets declaration
150 *
151 * @param none
152 * @return none
153 */
154 function resmushit_register_plugin_assets(){
155 $allowed_pages = array( 'media_page_resmushit_options',
156 'upload',
157 'dashboard',
158 'post',
159 'plugins',
160 'edit-post',
161 'media',
162 'attachment');
163
164 if ( function_exists( 'get_current_screen' ) ) {
165 $current_page = get_current_screen();
166 }
167
168 if ( isset( $current_page->id ) && in_array( $current_page->id, $allowed_pages ) ) {
169 wp_register_style( 'resmushit-css', plugins_url( 'css/resmushit.css', __FILE__ ) );
170 wp_enqueue_style( 'resmushit-css' );
171 wp_enqueue_style( 'prefix-style', esc_url_raw( 'https://fonts.googleapis.com/css?family=Roboto+Slab:700' ), array(), null );
172
173 wp_register_script( 'resmushit-js', plugins_url( 'js/script.js?' . hash_file('crc32', dirname(__FILE__) . '/js/script.js'), __FILE__ ) );
174 wp_enqueue_script( 'resmushit-js' );
175 }
176 }
177 add_action( 'admin_head', 'resmushit_register_plugin_assets' );
178
179
180
181 /**
182 *
183 * Detect unsmushed files by browsing the library directory
184 *
185 * @param none
186 * @return none
187 */
188 function detect_unsmushed_files() {
189 $wp_upload_dir=wp_upload_dir();
190 return glob_recursive($wp_upload_dir['basedir'] . '/*-unsmushed.*');
191 }
192