| @@ -3,9 +3,9 @@ | ||
| 3 | 3 | Plugin Name: WP Attachments |
| 4 | 4 | Plugin URI: http://marcomilesi.ml |
| 5 | 5 | Description: Automatically shows your attachments under every post and page content. Simple. Automatic. Easy. As it has to be! |
| 6 | 6 | Author: Marco Milesi |
| 7 | -Version: 3.0.1 | |
| 7 | +Version: 3.1 | |
| 8 | 8 | Author URI: http://marcomilesi.ml |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | |
| @@ -61,13 +61,12 @@ | ||
| 61 | 61 | )); |
| 62 | 62 | |
| 63 | 63 | if ($attachments) |
| 64 | 64 | { |
| 65 | - | |
| 66 | - $content .= '<div style="width:100%;margin:10px 0 10px 0;"><h3>' . get_option('wpatt_option_localization') . '</h3></div> | |
| 65 | + $content .= '<div style="width:100%;float:left;margin:10px 0 10px 0;"><h3>' . get_option('wpatt_option_localization') . '</h3> | |
| 67 | 66 | <style> |
| 68 | 67 | ul.post-attachments{list-style:none;margin:0;} |
| 69 | - li.post-attachment{background:url(' . plugin_dir_url(__FILE__) . 'icons/document.png) 0 4px no-repeat;padding-left:24px} .post-attachment.mime-imagejpeg,.post-attachment.mime-imagepng{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-image.png)} | |
| 68 | + li.post-attachment{background:url(' . plugin_dir_url(__FILE__) . 'icons/document.png) 0 4px no-repeat;padding-left:24px} .post-attachment.mime-imagejpeg,.post-attachment.mime-imagepng,.post-attachment.mime-imagejpeg,.post-attachment.mime-imagegif{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-image.png)} | |
| 70 | 69 | .post-attachment.mime-applicationzip{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-zipper.png)} |
| 71 | 70 | .post-attachment.mime-applicationpdf{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-pdf.png)} |
| 72 | 71 | .post-attachment.mime-applicationvnd-ms-excel{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-excel.png)} |
| 73 | 72 | .post-attachment.mime-applicationvnd-openxmlformats-officedocument-spreadsheetml-sheet{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-excel.png)} |
| @@ -77,13 +76,19 @@ | ||
| 77 | 76 | |
| 78 | 77 | foreach ($attachments as $attachment) |
| 79 | 78 | { |
| 80 | 79 | |
| 80 | + $wpatt_option_includeimages_get = get_option('wpatt_option_includeimages'); | |
| 81 | + if ($wpatt_option_includeimages_get == '1') { | |
| 82 | + } else if ( wp_attachment_is_image( $attachment->ID ) ) { | |
| 83 | + continue; | |
| 84 | + } | |
| 81 | 85 | |
| 82 | 86 | $class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type); |
| 83 | 87 | |
| 84 | 88 | $content .= '<li class="' . $class . '"><a href="' . wp_get_attachment_url($attachment->ID) . '">' . $attachment->post_title . '</a> (' . wpatt_format_bytes(filesize(get_attached_file($attachment->ID))); |
| 85 | - | |
| 89 | + | |
| 90 | + | |
| 86 | 91 | $wpatt_option_showdate_get = get_option('wpatt_option_showdate'); |
| 87 | 92 | |
| 88 | 93 | if ($wpatt_option_showdate_get == '1') |
| 89 | 94 | { |
| @@ -96,9 +101,9 @@ | ||
| 96 | 101 | |
| 97 | 102 | $content .= ')</li>'; |
| 98 | 103 | |
| 99 | 104 | } |
| 100 | - $content .= '</ul>'; | |
| 105 | + $content .= '</ul></div>'; | |
| 101 | 106 | |
| 102 | 107 | } |
| 103 | 108 | return $content; |
| 104 | 109 | |
| @@ -113,8 +118,10 @@ | ||
| 113 | 118 | function wpatt_reg_settings() |
| 114 | 119 | { |
| 115 | 120 | |
| 116 | 121 | register_setting('wpatt_options_group', 'wpatt_option_showdate', 'intval'); |
| 122 | + | |
| 123 | + register_setting('wpatt_options_group', 'wpatt_option_includeimages', 'intval'); | |
| 117 | 124 | |
| 118 | 125 | register_setting('wpatt_options_group', 'wpatt_option_localization'); |
| 119 | 126 | |
| 120 | 127 | /* Preopulate 'Attachments' */ |
| @@ -160,33 +167,26 @@ | ||
| 160 | 167 | } |
| 161 | 168 | |
| 162 | 169 | |
| 163 | 170 | |
| 164 | - if (isset($_POST['Submit'])) | |
| 165 | - { | |
| 171 | + if (isset($_POST['Submit'])) { | |
| 166 | 172 | |
| 167 | 173 | $wpatt_option_localization_get = $_POST["wpatt_option_localization_n"]; |
| 168 | 174 | |
| 169 | 175 | update_option('wpatt_option_localization', $wpatt_option_localization_get); |
| 170 | 176 | |
| 171 | - | |
| 172 | - | |
| 173 | - if (isset($_POST['wpatt_option_showdate_n'])) | |
| 174 | - { | |
| 175 | - | |
| 176 | - update_option('wpatt_option_showdate', '1'); | |
| 177 | - | |
| 178 | - } | |
| 179 | - else | |
| 180 | - { | |
| 181 | - | |
| 182 | - update_option('wpatt_option_showdate', '0'); | |
| 183 | - | |
| 184 | - } | |
| 185 | - | |
| 186 | - | |
| 187 | - | |
| 188 | - } | |
| 177 | + if (isset($_POST['wpatt_option_showdate_n'])) { | |
| 178 | + update_option('wpatt_option_showdate', '1'); | |
| 179 | + } else { | |
| 180 | + update_option('wpatt_option_showdate', '0'); | |
| 181 | + } | |
| 182 | + | |
| 183 | + if (isset($_POST['wpatt_option_includeimages_n'])) { | |
| 184 | + update_option('wpatt_option_includeimages', '1'); | |
| 185 | + } else { | |
| 186 | + update_option('wpatt_option_includeimages', '0'); | |
| 187 | + } | |
| 188 | + } | |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | |
| 192 | 192 | echo '<div class="wrap">'; |
| @@ -192,9 +192,10 @@ | ||
| 192 | 192 | echo '<div class="wrap">'; |
| 193 | 193 | |
| 194 | 194 | screen_icon(); |
| 195 | 195 | |
| 196 | - echo '<h2>Settings</h2>'; | |
| 196 | + echo '<h2>WP Attachments</h2>'; | |
| 197 | + echo '<h3>OPTIONS</h3>'; | |
| 197 | 198 | |
| 198 | 199 | echo '<div id="welcome-panel" class="welcome-panel">'; |
| 199 | 200 | |
| 200 | 201 | echo '<form method="post" name="options" target="_self">'; |
| @@ -216,32 +217,36 @@ | ||
| 216 | 217 | echo get_option('wpatt_option_localization'); |
| 217 | 218 | |
| 218 | 219 | echo '" /> Insert here the label you want to use for the title of the attachments list. Default "<b>Attachments</b>"</td></tr>'; |
| 219 | 220 | |
| 220 | - | |
| 221 | - | |
| 221 | + echo '<tr><th scope="row">Include Images?</th> | |
| 222 | + <td><input type="checkbox" name="wpatt_option_includeimages_n" '; | |
| 223 | + $wpatt_option_includeimages_get = get_option('wpatt_option_includeimages'); | |
| 224 | + if ($wpatt_option_includeimages_get == '1') { | |
| 225 | + echo 'checked=\'checked\''; | |
| 226 | + } | |
| 227 | + echo '/> Check this if you want to include images (.jpg, .jpeg, .gif, .png) from being listed.</td>'; | |
| 228 | + echo '</tr>'; | |
| 229 | + | |
| 230 | + | |
| 222 | 231 | echo '<tr><th scope="row">Show date?</th> |
| 223 | - | |
| 224 | 232 | <td><input type="checkbox" name="wpatt_option_showdate_n" '; |
| 225 | - | |
| 226 | 233 | $wpatt_option_showdate_get = get_option('wpatt_option_showdate'); |
| 227 | - | |
| 228 | - if ($wpatt_option_showdate_get == '1') | |
| 229 | - { | |
| 230 | - | |
| 231 | - echo 'checked=\'checked\''; | |
| 232 | - | |
| 233 | - } | |
| 234 | - | |
| 234 | + if ($wpatt_option_showdate_get == '1') { | |
| 235 | + echo 'checked=\'checked\''; | |
| 236 | + } | |
| 235 | 237 | echo '/> Check this if you want to show when the file has been uploaded.</td>'; |
| 236 | - | |
| 237 | 238 | echo '</tr></table>'; |
| 238 | 239 | |
| 239 | 240 | |
| 240 | 241 | |
| 241 | - echo '</table><p class="submit"><input type="submit" name="Submit" value="Update" /></p>'; | |
| 242 | + echo '</table><p class="submit"><input type="submit" class="button-primary" name="Submit" value="Update" /></p>'; | |
| 242 | 243 | |
| 243 | - echo '</form></div></div>'; | |
| 244 | + echo '</form></div> | |
| 245 | + <h3>HELP, SUPPORT & FEEDBACK</h3> | |
| 246 | + <a href="http://wordpress.org/plugins/wp-attachments/" title "WP Attachments Wordpress Plugin>http://wordpress.org/plugins/wp-attachments/</a><br/> | |
| 247 | + This plugin is continuously developed by Marco Milesi focusing on semplicity, intuitiveness and cleanness. Keep updated :)<br/> | |
| 248 | + Thank You for using this plugin.</div>'; | |
| 244 | 249 | |
| 245 | 250 | } |
| 246 | 251 | |
| 247 | -?> | |
| 252 | +?> | |