| @@ -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.4 | |
| 7 | +Version: 3.2 | |
| 8 | 8 | Author URI: http://marcomilesi.ml |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | function wpa_action_init() |
| @@ -10,10 +10,9 @@ | ||
| 10 | 10 | |
| 11 | 11 | function wpa_action_init() |
| 12 | 12 | { |
| 13 | 13 | load_plugin_textdomain( 'wp-attachments', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); |
| 14 | - update_option( 'wpa_version_number', '3.4' ); | |
| 15 | - wp_enqueue_style('wpa-css', plugin_dir_url(__FILE__) . 'styles/frontend.css'); | |
| 14 | + update_option( 'wpa_version_number', '3.2' ); | |
| 16 | 15 | } |
| 17 | 16 | |
| 18 | 17 | // Add actions |
| 19 | 18 | add_action('init', 'wpa_action_init'); |
| @@ -18,9 +17,8 @@ | ||
| 18 | 17 | // Add actions |
| 19 | 18 | add_action('init', 'wpa_action_init'); |
| 20 | 19 | require_once(plugin_dir_path(__FILE__) . 'settings.php'); |
| 21 | 20 | require_once(plugin_dir_path(__FILE__) . 'ij-post-attachments.php'); |
| 22 | -require_once(plugin_dir_path(__FILE__) . 'attach_unattach_reattach.php'); | |
| 23 | 21 | |
| 24 | 22 | function wpatt_format_bytes($a_bytes) |
| 25 | 23 | { |
| 26 | 24 | |
| @@ -26,9 +24,9 @@ | ||
| 26 | 24 | |
| 27 | 25 | if ($a_bytes < 1024) |
| 28 | 26 | { |
| 29 | 27 | |
| 30 | - return '< 1KB'; | |
| 28 | + return $a_bytes . ' B'; | |
| 31 | 29 | |
| 32 | 30 | } |
| 33 | 31 | elseif ($a_bytes < 1048576) |
| 34 | 32 | { |
| @@ -64,10 +62,8 @@ | ||
| 64 | 62 | { |
| 65 | 63 | global $post; |
| 66 | 64 | $somethingtoshow = 0; |
| 67 | 65 | |
| 68 | - if ($post->ID == '0' || $post->ID == NULL) { return $content; } //Skip the attachments list if POST ID is null | |
| 69 | - | |
| 70 | 66 | $attachments = get_posts(array( |
| 71 | 67 | 'post_type' => 'attachment', |
| 72 | 68 | 'orderby' => 'menu_order', |
| 73 | 69 | 'order' => 'ASC', |
| @@ -77,9 +73,18 @@ | ||
| 77 | 73 | |
| 78 | 74 | if ($attachments) |
| 79 | 75 | { |
| 80 | 76 | $content_l .= '<div style="width:100%;float:left;margin:10px 0 10px 0;"><h3>' . get_option('wpatt_option_localization') . '</h3> |
| 81 | - <ul class="post-attachments">'; | |
| 77 | + <style> | |
| 78 | + ul.post-attachments{list-style:none;margin:0;} | |
| 79 | + 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)} | |
| 80 | + .post-attachment.mime-applicationzip{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-zipper.png)} | |
| 81 | + .post-attachment.mime-applicationpdf{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-pdf.png)} | |
| 82 | + .post-attachment.mime-applicationvnd-ms-excel{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-excel.png)} | |
| 83 | + .post-attachment.mime-applicationvnd-openxmlformats-officedocument-spreadsheetml-sheet{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-excel.png)} | |
| 84 | + .post-attachment.mime-applicationmsword{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-word.png)} | |
| 85 | + .post-attachment.mime-applicationvnd-openxmlformats-officedocument-wordprocessingml-document{background-image:url(' . plugin_dir_url(__FILE__) . 'icons/document-word.png)} | |
| 86 | + </style><ul class="post-attachments">'; | |
| 82 | 87 | |
| 83 | 88 | foreach ($attachments as $attachment) |
| 84 | 89 | { |
| 85 | 90 | |
| @@ -91,15 +96,9 @@ | ||
| 91 | 96 | $somethingtoshow = 1; |
| 92 | 97 | |
| 93 | 98 | $class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type); |
| 94 | 99 | |
| 95 | - $wpatt_option_targetblank_get = get_option('wpatt_option_targetblank'); | |
| 96 | - | |
| 97 | - $content_l .= '<li class="' . $class . '"><a '; | |
| 98 | - | |
| 99 | - if ($wpatt_option_targetblank_get == '1') { $content_l .= 'target="_blank" '; } | |
| 100 | - | |
| 101 | - $content_l .= 'href="' . wp_get_attachment_url($attachment->ID) . '">' . $attachment->post_title . '</a> (' . wpatt_format_bytes(filesize(get_attached_file($attachment->ID))); | |
| 100 | + $content_l .= '<li class="' . $class . '"><a href="' . wp_get_attachment_url($attachment->ID) . '">' . $attachment->post_title . '</a> (' . wpatt_format_bytes(filesize(get_attached_file($attachment->ID))); | |
| 102 | 101 | |
| 103 | 102 | |
| 104 | 103 | $wpatt_option_showdate_get = get_option('wpatt_option_showdate'); |
| 105 | 104 | |
| @@ -138,10 +137,8 @@ | ||
| 138 | 137 | |
| 139 | 138 | register_setting('wpatt_options_group', 'wpatt_option_localization'); |
| 140 | 139 | |
| 141 | 140 | register_setting('wpatt_options_group', 'wpatt_disable_backend'); |
| 142 | - | |
| 143 | - register_setting('wpatt_options_group', 'wpatt_option_targetblank', 'intval'); | |
| 144 | 141 | |
| 145 | 142 | /* Preopulate 'Attachments' */ |
| 146 | 143 | |
| 147 | 144 | $wpatt_option_showdate_get = get_option('wpatt_option_showdate'); |
| @@ -157,6 +154,7 @@ | ||
| 157 | 154 | |
| 158 | 155 | function wpatt_plugin_menu(){ |
| 159 | 156 | add_options_page('WP Attachments - Settings', 'WP Attachments', 'manage_options', 'wpatt-option-page', 'wpatt_plugin_options'); |
| 160 | 157 | } |
| 158 | + | |
| 161 | 159 | |
| 162 | 160 | ?> |