PluginProbe
WP Attachments / 3.2
WP Attachments v3.2
6.0.2 6.0.3 trunk 2.0 3 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.2 3.1.3 3.1.4 3.2 3.2.1 3.2.2 3.2.3 3.2.4 3.3 3.4 3.5 3.5.1 3.5.2 3.5.3 3.5.4 All 52 releases
← All changes | wp-attachments.php +15 -24 3.53.2 View file →
@@ -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.5
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 {
@@ -63,12 +61,9 @@
63 61 function wpatt_job_cpt_template_filter($content)
64 62 {
65 63 global $post;
66 64 $somethingtoshow = 0;
67 - $content_l = null;
68 65
69 - if ($post->ID == '0' || $post->ID == NULL) { return $content; } //Skip the attachments list if POST ID is null
70 -
71 66 $attachments = get_posts(array(
72 67 'post_type' => 'attachment',
73 68 'orderby' => 'menu_order',
74 69 'order' => 'ASC',
@@ -78,9 +73,18 @@
78 73
79 74 if ($attachments)
80 75 {
81 76 $content_l .= '<div style="width:100%;float:left;margin:10px 0 10px 0;"><h3>' . get_option('wpatt_option_localization') . '</h3>
82 - <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">';
83 87
84 88 foreach ($attachments as $attachment)
85 89 {
86 90
@@ -92,21 +96,9 @@
92 96 $somethingtoshow = 1;
93 97
94 98 $class = "post-attachment mime-" . sanitize_title($attachment->post_mime_type);
95 99
96 - $wpatt_option_targetblank_get = get_option('wpatt_option_targetblank');
97 -
98 - $content_l .= '<li class="' . $class . '"><a ';
99 -
100 - if ($wpatt_option_targetblank_get == '1') { $content_l .= 'target="_blank" '; }
101 -
102 - if ((file_exists(get_attached_file($attachment->ID)))) {
103 - $wpatt_fs = wpatt_format_bytes(filesize(get_attached_file($attachment->ID)));
104 - } else {
105 - $wpatt_fs = 'not found';
106 - }
107 -
108 - $content_l .= 'href="' . wp_get_attachment_url($attachment->ID) . '">' . $attachment->post_title . '</a> (' . $wpatt_fs;
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)));
109 101
110 102
111 103 $wpatt_option_showdate_get = get_option('wpatt_option_showdate');
112 104
@@ -145,10 +137,8 @@
145 137
146 138 register_setting('wpatt_options_group', 'wpatt_option_localization');
147 139
148 140 register_setting('wpatt_options_group', 'wpatt_disable_backend');
149 -
150 - register_setting('wpatt_options_group', 'wpatt_option_targetblank', 'intval');
151 141
152 142 /* Preopulate 'Attachments' */
153 143
154 144 $wpatt_option_showdate_get = get_option('wpatt_option_showdate');
@@ -164,6 +154,7 @@
164 154
165 155 function wpatt_plugin_menu(){
166 156 add_options_page('WP Attachments - Settings', 'WP Attachments', 'manage_options', 'wpatt-option-page', 'wpatt_plugin_options');
167 157 }
158 +
168 159
169 160 ?>