author | Anthony Ly <anthonyly.com@gmail.com> |
Tue, 12 Mar 2013 18:21:39 +0100 | |
changeset 206 | 919b4ddb13fa |
parent 204 | 09a1c134465b |
permissions | -rw-r--r-- |
136 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Administration Media API. |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7 |
*/ |
|
8 |
||
9 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
10 |
* Defines the default media upload tabs |
136 | 11 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
12 |
* @since 2.5.0 |
136 | 13 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
14 |
* @return array default tabs |
136 | 15 |
*/ |
16 |
function media_upload_tabs() { |
|
17 |
$_default_tabs = array( |
|
18 |
'type' => __('From Computer'), // handler action suffix => tab text |
|
19 |
'type_url' => __('From URL'), |
|
20 |
'gallery' => __('Gallery'), |
|
21 |
'library' => __('Media Library') |
|
22 |
); |
|
23 |
||
24 |
return apply_filters('media_upload_tabs', $_default_tabs); |
|
25 |
} |
|
26 |
||
27 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
28 |
* Adds the gallery tab back to the tabs array if post has image attachments |
136 | 29 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
30 |
* @since 2.5.0 |
136 | 31 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
32 |
* @param array $tabs |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
33 |
* @return array $tabs with gallery if post has image attachment |
136 | 34 |
*/ |
35 |
function update_gallery_tab($tabs) { |
|
36 |
global $wpdb; |
|
37 |
||
38 |
if ( !isset($_REQUEST['post_id']) ) { |
|
39 |
unset($tabs['gallery']); |
|
40 |
return $tabs; |
|
41 |
} |
|
42 |
||
43 |
$post_id = intval($_REQUEST['post_id']); |
|
44 |
||
45 |
if ( $post_id ) |
|
46 |
$attachments = intval( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent = %d", $post_id ) ) ); |
|
47 |
||
48 |
if ( empty($attachments) ) { |
|
49 |
unset($tabs['gallery']); |
|
50 |
return $tabs; |
|
51 |
} |
|
52 |
||
53 |
$tabs['gallery'] = sprintf(__('Gallery (%s)'), "<span id='attachments-count'>$attachments</span>"); |
|
54 |
||
55 |
return $tabs; |
|
56 |
} |
|
57 |
add_filter('media_upload_tabs', 'update_gallery_tab'); |
|
58 |
||
59 |
/** |
|
60 |
* {@internal Missing Short Description}} |
|
61 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
62 |
* @since 2.5.0 |
136 | 63 |
*/ |
64 |
function the_media_upload_tabs() { |
|
65 |
global $redir_tab; |
|
66 |
$tabs = media_upload_tabs(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
67 |
$default = 'type'; |
136 | 68 |
|
69 |
if ( !empty($tabs) ) { |
|
70 |
echo "<ul id='sidemenu'>\n"; |
|
71 |
if ( isset($redir_tab) && array_key_exists($redir_tab, $tabs) ) |
|
72 |
$current = $redir_tab; |
|
73 |
elseif ( isset($_GET['tab']) && array_key_exists($_GET['tab'], $tabs) ) |
|
74 |
$current = $_GET['tab']; |
|
75 |
else |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
76 |
$current = apply_filters('media_upload_default_tab', $default); |
136 | 77 |
|
78 |
foreach ( $tabs as $callback => $text ) { |
|
79 |
$class = ''; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
80 |
|
136 | 81 |
if ( $current == $callback ) |
82 |
$class = " class='current'"; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
83 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
84 |
$href = add_query_arg(array('tab' => $callback, 's' => false, 'paged' => false, 'post_mime_type' => false, 'm' => false)); |
136 | 85 |
$link = "<a href='" . esc_url($href) . "'$class>$text</a>"; |
86 |
echo "\t<li id='" . esc_attr("tab-$callback") . "'>$link</li>\n"; |
|
87 |
} |
|
88 |
echo "</ul>\n"; |
|
89 |
} |
|
90 |
} |
|
91 |
||
92 |
/** |
|
93 |
* {@internal Missing Short Description}} |
|
94 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
95 |
* @since 2.5.0 |
136 | 96 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
97 |
* @param integer $id image attachment id |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
98 |
* @param string $caption image caption |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
99 |
* @param string $alt image alt attribute |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
100 |
* @param string $title image title attribute |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
101 |
* @param string $align image css alignment property |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
102 |
* @param string $url image src url |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
103 |
* @param string|bool $rel image rel attribute |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
104 |
* @param string $size image size (thumbnail, medium, large, full or added with add_image_size() ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
105 |
* @return string the html to insert into editor |
136 | 106 |
*/ |
107 |
function get_image_send_to_editor($id, $caption, $title, $align, $url='', $rel = false, $size='medium', $alt = '') { |
|
108 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
109 |
$html = get_image_tag($id, $alt, '', $align, $size); |
136 | 110 |
|
111 |
$rel = $rel ? ' rel="attachment wp-att-' . esc_attr($id).'"' : ''; |
|
112 |
||
113 |
if ( $url ) |
|
114 |
$html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>"; |
|
115 |
||
116 |
$html = apply_filters( 'image_send_to_editor', $html, $id, $caption, $title, $align, $url, $size, $alt ); |
|
117 |
||
118 |
return $html; |
|
119 |
} |
|
120 |
||
121 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
122 |
* Adds image shortcode with caption to editor |
136 | 123 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
124 |
* @since 2.6.0 |
136 | 125 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
126 |
* @param string $html |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
127 |
* @param integer $id |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
128 |
* @param string $caption image caption |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
129 |
* @param string $alt image alt attribute |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
130 |
* @param string $title image title attribute |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
131 |
* @param string $align image css alignment property |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
132 |
* @param string $url image src url |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
133 |
* @param string $size image size (thumbnail, medium, large, full or added with add_image_size() ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
134 |
* @return string |
136 | 135 |
*/ |
136 |
function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $alt = '' ) { |
|
137 |
||
138 |
if ( empty($caption) || apply_filters( 'disable_captions', '' ) ) |
|
139 |
return $html; |
|
140 |
||
141 |
$id = ( 0 < (int) $id ) ? 'attachment_' . $id : ''; |
|
142 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
143 |
if ( ! preg_match( '/width=["\']([0-9]+)/', $html, $matches ) ) |
136 | 144 |
return $html; |
145 |
||
146 |
$width = $matches[1]; |
|
147 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
148 |
$caption = str_replace( array("\r\n", "\r"), "\n", $caption); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
149 |
$caption = preg_replace_callback( '/<[a-zA-Z0-9]+(?: [^<>]+>)*/', '_cleanup_image_add_caption', $caption ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
150 |
// convert any remaining line breaks to <br> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
151 |
$caption = preg_replace( '/[ \n\t]*\n[ \t]*/', '<br />', $caption ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
152 |
|
136 | 153 |
$html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); |
154 |
if ( empty($align) ) |
|
155 |
$align = 'none'; |
|
156 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
157 |
$shcode = '[caption id="' . $id . '" align="align' . $align . '" width="' . $width . '"]' . $html . ' ' . $caption . '[/caption]'; |
136 | 158 |
|
159 |
return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); |
|
160 |
} |
|
161 |
add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); |
|
162 |
||
163 |
/** |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
164 |
* Private preg_replace callback used in image_add_caption() |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
165 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
166 |
* @access private |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
167 |
* @since 3.4.0 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
168 |
*/ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
169 |
function _cleanup_image_add_caption( $matches ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
170 |
// remove any line breaks from inside the tags |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
171 |
return preg_replace( '/[\r\n\t]+/', ' ', $matches[0] ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
172 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
173 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
174 |
/** |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
175 |
* Adds image html to editor |
136 | 176 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
177 |
* @since 2.5.0 |
136 | 178 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
179 |
* @param string $html |
136 | 180 |
*/ |
181 |
function media_send_to_editor($html) { |
|
182 |
?> |
|
183 |
<script type="text/javascript"> |
|
184 |
/* <![CDATA[ */ |
|
185 |
var win = window.dialogArguments || opener || parent || top; |
|
186 |
win.send_to_editor('<?php echo addslashes($html); ?>'); |
|
187 |
/* ]]> */ |
|
188 |
</script> |
|
189 |
<?php |
|
190 |
exit; |
|
191 |
} |
|
192 |
||
193 |
/** |
|
194 |
* This handles the file upload POST itself, creating the attachment post. |
|
195 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
196 |
* @since 2.5.0 |
136 | 197 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
198 |
* @param string $file_id Index into the {@link $_FILES} array of the upload |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
199 |
* @param int $post_id The post ID the media is associated with |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
200 |
* @param array $post_data allows you to overwrite some of the attachment |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
201 |
* @param array $overrides allows you to override the {@link wp_handle_upload()} behavior |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
202 |
* @return int the ID of the attachment |
136 | 203 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
204 |
function media_handle_upload($file_id, $post_id, $post_data = array(), $overrides = array( 'test_form' => false )) { |
136 | 205 |
|
206 |
$time = current_time('mysql'); |
|
207 |
if ( $post = get_post($post_id) ) { |
|
208 |
if ( substr( $post->post_date, 0, 4 ) > 0 ) |
|
209 |
$time = $post->post_date; |
|
210 |
} |
|
211 |
||
212 |
$name = $_FILES[$file_id]['name']; |
|
213 |
$file = wp_handle_upload($_FILES[$file_id], $overrides, $time); |
|
214 |
||
215 |
if ( isset($file['error']) ) |
|
216 |
return new WP_Error( 'upload_error', $file['error'] ); |
|
217 |
||
218 |
$name_parts = pathinfo($name); |
|
219 |
$name = trim( substr( $name, 0, -(1 + strlen($name_parts['extension'])) ) ); |
|
220 |
||
221 |
$url = $file['url']; |
|
222 |
$type = $file['type']; |
|
223 |
$file = $file['file']; |
|
224 |
$title = $name; |
|
225 |
$content = ''; |
|
226 |
||
227 |
// use image exif/iptc data for title and caption defaults if possible |
|
228 |
if ( $image_meta = @wp_read_image_metadata($file) ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
229 |
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) |
136 | 230 |
$title = $image_meta['title']; |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
231 |
if ( trim( $image_meta['caption'] ) ) |
136 | 232 |
$content = $image_meta['caption']; |
233 |
} |
|
234 |
||
235 |
// Construct the attachment array |
|
236 |
$attachment = array_merge( array( |
|
237 |
'post_mime_type' => $type, |
|
238 |
'guid' => $url, |
|
239 |
'post_parent' => $post_id, |
|
240 |
'post_title' => $title, |
|
241 |
'post_content' => $content, |
|
242 |
), $post_data ); |
|
243 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
244 |
// This should never be set as it would then overwrite an existing attachment. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
245 |
if ( isset( $attachment['ID'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
246 |
unset( $attachment['ID'] ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
247 |
|
136 | 248 |
// Save the data |
249 |
$id = wp_insert_attachment($attachment, $file, $post_id); |
|
250 |
if ( !is_wp_error($id) ) { |
|
251 |
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
|
252 |
} |
|
253 |
||
254 |
return $id; |
|
255 |
||
256 |
} |
|
257 |
||
258 |
/** |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
259 |
* This handles a sideloaded file in the same way as an uploaded file is handled by {@link media_handle_upload()} |
136 | 260 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
261 |
* @since 2.6.0 |
136 | 262 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
263 |
* @param array $file_array Array similar to a {@link $_FILES} upload array |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
264 |
* @param int $post_id The post ID the media is associated with |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
265 |
* @param string $desc Description of the sideloaded file |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
266 |
* @param array $post_data allows you to overwrite some of the attachment |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
267 |
* @return int|object The ID of the attachment or a WP_Error on failure |
136 | 268 |
*/ |
269 |
function media_handle_sideload($file_array, $post_id, $desc = null, $post_data = array()) { |
|
270 |
$overrides = array('test_form'=>false); |
|
271 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
272 |
$time = current_time( 'mysql' ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
273 |
if ( $post = get_post( $post_id ) ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
274 |
if ( substr( $post->post_date, 0, 4 ) > 0 ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
275 |
$time = $post->post_date; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
276 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
277 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
278 |
$file = wp_handle_sideload( $file_array, $overrides, $time ); |
136 | 279 |
if ( isset($file['error']) ) |
280 |
return new WP_Error( 'upload_error', $file['error'] ); |
|
281 |
||
282 |
$url = $file['url']; |
|
283 |
$type = $file['type']; |
|
284 |
$file = $file['file']; |
|
285 |
$title = preg_replace('/\.[^.]+$/', '', basename($file)); |
|
286 |
$content = ''; |
|
287 |
||
288 |
// use image exif/iptc data for title and caption defaults if possible |
|
289 |
if ( $image_meta = @wp_read_image_metadata($file) ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
290 |
if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) |
136 | 291 |
$title = $image_meta['title']; |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
292 |
if ( trim( $image_meta['caption'] ) ) |
136 | 293 |
$content = $image_meta['caption']; |
294 |
} |
|
295 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
296 |
if ( isset( $desc ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
297 |
$title = $desc; |
136 | 298 |
|
299 |
// Construct the attachment array |
|
300 |
$attachment = array_merge( array( |
|
301 |
'post_mime_type' => $type, |
|
302 |
'guid' => $url, |
|
303 |
'post_parent' => $post_id, |
|
304 |
'post_title' => $title, |
|
305 |
'post_content' => $content, |
|
306 |
), $post_data ); |
|
307 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
308 |
// This should never be set as it would then overwrite an existing attachment. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
309 |
if ( isset( $attachment['ID'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
310 |
unset( $attachment['ID'] ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
311 |
|
136 | 312 |
// Save the attachment metadata |
313 |
$id = wp_insert_attachment($attachment, $file, $post_id); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
314 |
if ( !is_wp_error($id) ) |
136 | 315 |
wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
316 |
|
136 | 317 |
return $id; |
318 |
} |
|
319 |
||
320 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
321 |
* Adds the iframe to display content for the media upload page |
136 | 322 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
323 |
* @since 2.5.0 |
136 | 324 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
325 |
* @param array $content_func |
136 | 326 |
*/ |
327 |
function wp_iframe($content_func /* ... */) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
328 |
_wp_admin_html_begin(); |
136 | 329 |
?> |
330 |
<title><?php bloginfo('name') ?> › <?php _e('Uploads'); ?> — <?php _e('WordPress'); ?></title> |
|
331 |
<?php |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
332 |
|
136 | 333 |
wp_enqueue_style( 'colors' ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
334 |
// Check callback name for 'media' |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
335 |
if ( ( is_array( $content_func ) && ! empty( $content_func[1] ) && 0 === strpos( (string) $content_func[1], 'media' ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
336 |
|| ( ! is_array( $content_func ) && 0 === strpos( $content_func, 'media' ) ) ) |
136 | 337 |
wp_enqueue_style( 'media' ); |
338 |
wp_enqueue_style( 'ie' ); |
|
339 |
?> |
|
340 |
<script type="text/javascript"> |
|
341 |
//<![CDATA[ |
|
342 |
addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}; |
|
343 |
var userSettings = {'url':'<?php echo SITECOOKIEPATH; ?>','uid':'<?php if ( ! isset($current_user) ) $current_user = wp_get_current_user(); echo $current_user->ID; ?>','time':'<?php echo time(); ?>'}; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
344 |
var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>', pagenow = 'media-upload-popup', adminpage = 'media-upload-popup', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
345 |
isRtl = <?php echo (int) is_rtl(); ?>; |
136 | 346 |
//]]> |
347 |
</script> |
|
348 |
<?php |
|
349 |
do_action('admin_enqueue_scripts', 'media-upload-popup'); |
|
350 |
do_action('admin_print_styles-media-upload-popup'); |
|
351 |
do_action('admin_print_styles'); |
|
352 |
do_action('admin_print_scripts-media-upload-popup'); |
|
353 |
do_action('admin_print_scripts'); |
|
354 |
do_action('admin_head-media-upload-popup'); |
|
355 |
do_action('admin_head'); |
|
356 |
||
357 |
if ( is_string($content_func) ) |
|
358 |
do_action( "admin_head_{$content_func}" ); |
|
359 |
?> |
|
360 |
</head> |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
361 |
<body<?php if ( isset($GLOBALS['body_id']) ) echo ' id="' . $GLOBALS['body_id'] . '"'; ?> class="wp-core-ui no-js"> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
362 |
<script type="text/javascript"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
363 |
document.body.className = document.body.className.replace('no-js', 'js'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
364 |
</script> |
136 | 365 |
<?php |
366 |
$args = func_get_args(); |
|
367 |
$args = array_slice($args, 1); |
|
368 |
call_user_func_array($content_func, $args); |
|
369 |
||
370 |
do_action('admin_print_footer_scripts'); |
|
371 |
?> |
|
372 |
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> |
|
373 |
</body> |
|
374 |
</html> |
|
375 |
<?php |
|
376 |
} |
|
377 |
||
378 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
379 |
* Adds the media button to the editor |
136 | 380 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
381 |
* @since 2.5.0 |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
382 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
383 |
* @param string $editor_id |
136 | 384 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
385 |
function media_buttons($editor_id = 'content') { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
386 |
$post = get_post(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
387 |
if ( ! $post && ! empty( $GLOBALS['post_ID'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
388 |
$post = $GLOBALS['post_ID']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
389 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
390 |
wp_enqueue_media( array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
391 |
'post' => $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
392 |
) ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
393 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
394 |
$img = '<span class="wp-media-buttons-icon"></span> '; |
136 | 395 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
396 |
echo '<a href="#" class="button insert-media add_media" data-editor="' . esc_attr( $editor_id ) . '" title="' . esc_attr__( 'Add Media' ) . '">' . $img . __( 'Add Media' ) . '</a>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
397 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
398 |
// Don't use this filter. Want to add a button? Use the media_buttons action. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
399 |
$legacy_filter = apply_filters('media_buttons_context', ''); // deprecated |
136 | 400 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
401 |
if ( $legacy_filter ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
402 |
// #WP22559. Close <a> if a plugin started by closing <a> to open their own <a> tag. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
403 |
if ( 0 === stripos( trim( $legacy_filter ), '</a>' ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
404 |
$legacy_filter .= '</a>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
405 |
echo $legacy_filter; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
406 |
} |
136 | 407 |
} |
408 |
add_action( 'media_buttons', 'media_buttons' ); |
|
409 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
410 |
function get_upload_iframe_src( $type = null, $post_id = null, $tab = null ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
411 |
global $post_ID; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
412 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
413 |
if ( empty( $post_id ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
414 |
$post_id = $post_ID; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
415 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
416 |
$upload_iframe_src = add_query_arg( 'post_id', (int) $post_id, admin_url('media-upload.php') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
417 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
418 |
if ( $type && 'media' != $type ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
419 |
$upload_iframe_src = add_query_arg('type', $type, $upload_iframe_src); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
420 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
421 |
if ( ! empty( $tab ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
422 |
$upload_iframe_src = add_query_arg('tab', $tab, $upload_iframe_src); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
423 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
424 |
$upload_iframe_src = apply_filters($type . '_upload_iframe_src', $upload_iframe_src); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
425 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
426 |
return add_query_arg('TB_iframe', true, $upload_iframe_src); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
427 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
428 |
|
136 | 429 |
/** |
430 |
* {@internal Missing Short Description}} |
|
431 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
432 |
* @since 2.5.0 |
136 | 433 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
434 |
* @return mixed void|object WP_Error on failure |
136 | 435 |
*/ |
436 |
function media_upload_form_handler() { |
|
437 |
check_admin_referer('media-form'); |
|
438 |
||
439 |
$errors = null; |
|
440 |
||
441 |
if ( isset($_POST['send']) ) { |
|
442 |
$keys = array_keys($_POST['send']); |
|
443 |
$send_id = (int) array_shift($keys); |
|
444 |
} |
|
445 |
||
446 |
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { |
|
447 |
$post = $_post = get_post($attachment_id, ARRAY_A); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
448 |
$post_type_object = get_post_type_object( $post[ 'post_type' ] ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
449 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
450 |
if ( !current_user_can( $post_type_object->cap->edit_post, $attachment_id ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
451 |
continue; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
452 |
|
136 | 453 |
if ( isset($attachment['post_content']) ) |
454 |
$post['post_content'] = $attachment['post_content']; |
|
455 |
if ( isset($attachment['post_title']) ) |
|
456 |
$post['post_title'] = $attachment['post_title']; |
|
457 |
if ( isset($attachment['post_excerpt']) ) |
|
458 |
$post['post_excerpt'] = $attachment['post_excerpt']; |
|
459 |
if ( isset($attachment['menu_order']) ) |
|
460 |
$post['menu_order'] = $attachment['menu_order']; |
|
461 |
||
462 |
if ( isset($send_id) && $attachment_id == $send_id ) { |
|
463 |
if ( isset($attachment['post_parent']) ) |
|
464 |
$post['post_parent'] = $attachment['post_parent']; |
|
465 |
} |
|
466 |
||
467 |
$post = apply_filters('attachment_fields_to_save', $post, $attachment); |
|
468 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
469 |
if ( isset($attachment['image_alt']) ) { |
136 | 470 |
$image_alt = get_post_meta($attachment_id, '_wp_attachment_image_alt', true); |
471 |
if ( $image_alt != stripslashes($attachment['image_alt']) ) { |
|
472 |
$image_alt = wp_strip_all_tags( stripslashes($attachment['image_alt']), true ); |
|
473 |
// update_meta expects slashed |
|
474 |
update_post_meta( $attachment_id, '_wp_attachment_image_alt', addslashes($image_alt) ); |
|
475 |
} |
|
476 |
} |
|
477 |
||
478 |
if ( isset($post['errors']) ) { |
|
479 |
$errors[$attachment_id] = $post['errors']; |
|
480 |
unset($post['errors']); |
|
481 |
} |
|
482 |
||
483 |
if ( $post != $_post ) |
|
484 |
wp_update_post($post); |
|
485 |
||
486 |
foreach ( get_attachment_taxonomies($post) as $t ) { |
|
487 |
if ( isset($attachment[$t]) ) |
|
488 |
wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); |
|
489 |
} |
|
490 |
} |
|
491 |
||
492 |
if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?> |
|
493 |
<script type="text/javascript"> |
|
494 |
/* <![CDATA[ */ |
|
495 |
var win = window.dialogArguments || opener || parent || top; |
|
496 |
win.tb_remove(); |
|
497 |
/* ]]> */ |
|
498 |
</script> |
|
499 |
<?php |
|
500 |
exit; |
|
501 |
} |
|
502 |
||
503 |
if ( isset($send_id) ) { |
|
504 |
$attachment = stripslashes_deep( $_POST['attachments'][$send_id] ); |
|
505 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
506 |
$html = isset( $attachment['post_title'] ) ? $attachment['post_title'] : ''; |
136 | 507 |
if ( !empty($attachment['url']) ) { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
508 |
$rel = ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
509 |
if ( strpos($attachment['url'], 'attachment_id') || get_attachment_link($send_id) == $attachment['url'] ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
510 |
$rel = " rel='attachment wp-att-" . esc_attr($send_id) . "'"; |
136 | 511 |
$html = "<a href='{$attachment['url']}'$rel>$html</a>"; |
512 |
} |
|
513 |
||
514 |
$html = apply_filters('media_send_to_editor', $html, $send_id, $attachment); |
|
515 |
return media_send_to_editor($html); |
|
516 |
} |
|
517 |
||
518 |
return $errors; |
|
519 |
} |
|
520 |
||
521 |
/** |
|
522 |
* {@internal Missing Short Description}} |
|
523 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
524 |
* @since 2.5.0 |
136 | 525 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
526 |
* @return mixed |
136 | 527 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
528 |
function wp_media_upload_handler() { |
136 | 529 |
$errors = array(); |
530 |
$id = 0; |
|
531 |
||
532 |
if ( isset($_POST['html-upload']) && !empty($_FILES) ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
533 |
check_admin_referer('media-form'); |
136 | 534 |
// Upload File button was clicked |
535 |
$id = media_handle_upload('async-upload', $_REQUEST['post_id']); |
|
536 |
unset($_FILES); |
|
537 |
if ( is_wp_error($id) ) { |
|
538 |
$errors['upload_error'] = $id; |
|
539 |
$id = false; |
|
540 |
} |
|
541 |
} |
|
542 |
||
543 |
if ( !empty($_POST['insertonlybutton']) ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
544 |
$src = $_POST['src']; |
136 | 545 |
if ( !empty($src) && !strpos($src, '://') ) |
546 |
$src = "http://$src"; |
|
547 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
548 |
if ( isset( $_POST['media_type'] ) && 'image' != $_POST['media_type'] ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
549 |
$title = esc_html( stripslashes( $_POST['title'] ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
550 |
if ( empty( $title ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
551 |
$title = esc_html( basename( $src ) ); |
136 | 552 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
553 |
if ( $title && $src ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
554 |
$html = "<a href='" . esc_url($src) . "'>$title</a>"; |
136 | 555 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
556 |
$type = 'file'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
557 |
if ( ( $ext = preg_replace( '/^.+?\.([^.]+)$/', '$1', $src ) ) && ( $ext_type = wp_ext2type( $ext ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
558 |
&& ( 'audio' == $ext_type || 'video' == $ext_type ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
559 |
$type = $ext_type; |
136 | 560 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
561 |
$html = apply_filters( $type . '_send_to_editor_url', $html, esc_url_raw( $src ), $title ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
562 |
} else { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
563 |
$align = ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
564 |
$alt = esc_attr( stripslashes( $_POST['alt'] ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
565 |
if ( isset($_POST['align']) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
566 |
$align = esc_attr( stripslashes( $_POST['align'] ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
567 |
$class = " class='align$align'"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
568 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
569 |
if ( !empty($src) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
570 |
$html = "<img src='" . esc_url($src) . "' alt='$alt'$class />"; |
136 | 571 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
572 |
$html = apply_filters( 'image_send_to_editor_url', $html, esc_url_raw( $src ), $alt, $align ); |
136 | 573 |
} |
574 |
||
575 |
return media_send_to_editor($html); |
|
576 |
} |
|
577 |
||
578 |
if ( !empty($_POST) ) { |
|
579 |
$return = media_upload_form_handler(); |
|
580 |
||
581 |
if ( is_string($return) ) |
|
582 |
return $return; |
|
583 |
if ( is_array($return) ) |
|
584 |
$errors = $return; |
|
585 |
} |
|
586 |
||
587 |
if ( isset($_POST['save']) ) { |
|
588 |
$errors['upload_notice'] = __('Saved.'); |
|
589 |
return media_upload_gallery(); |
|
590 |
} |
|
591 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
592 |
if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
593 |
$type = 'image'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
594 |
if ( isset( $_GET['type'] ) && in_array( $_GET['type'], array( 'video', 'audio', 'file' ) ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
595 |
$type = $_GET['type']; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
596 |
return wp_iframe( 'media_upload_type_url_form', $type, $errors, $id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
597 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
598 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
599 |
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
600 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
601 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
602 |
/** |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
603 |
* Download an image from the specified URL and attach it to a post. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
604 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
605 |
* @since 2.6.0 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
606 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
607 |
* @param string $file The URL of the image to download |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
608 |
* @param int $post_id The post ID the media is to be associated with |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
609 |
* @param string $desc Optional. Description of the image |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
610 |
* @return string|WP_Error Populated HTML img tag on success |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
611 |
*/ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
612 |
function media_sideload_image($file, $post_id, $desc = null) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
613 |
if ( ! empty($file) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
614 |
// Download file to temp location |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
615 |
$tmp = download_url( $file ); |
136 | 616 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
617 |
// Set variables for storage |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
618 |
// fix file filename for query strings |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
619 |
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
620 |
$file_array['name'] = basename($matches[0]); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
621 |
$file_array['tmp_name'] = $tmp; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
622 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
623 |
// If error storing temporarily, unlink |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
624 |
if ( is_wp_error( $tmp ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
625 |
@unlink($file_array['tmp_name']); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
626 |
$file_array['tmp_name'] = ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
627 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
628 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
629 |
// do the validation and storage stuff |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
630 |
$id = media_handle_sideload( $file_array, $post_id, $desc ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
631 |
// If error storing permanently, unlink |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
632 |
if ( is_wp_error($id) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
633 |
@unlink($file_array['tmp_name']); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
634 |
return $id; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
635 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
636 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
637 |
$src = wp_get_attachment_url( $id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
638 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
639 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
640 |
// Finally check to make sure the file has been saved, then return the html |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
641 |
if ( ! empty($src) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
642 |
$alt = isset($desc) ? esc_attr($desc) : ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
643 |
$html = "<img src='$src' alt='$alt' />"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
644 |
return $html; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
645 |
} |
136 | 646 |
} |
647 |
||
648 |
/** |
|
649 |
* {@internal Missing Short Description}} |
|
650 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
651 |
* @since 2.5.0 |
136 | 652 |
* |
653 |
* @return unknown |
|
654 |
*/ |
|
655 |
function media_upload_gallery() { |
|
656 |
$errors = array(); |
|
657 |
||
658 |
if ( !empty($_POST) ) { |
|
659 |
$return = media_upload_form_handler(); |
|
660 |
||
661 |
if ( is_string($return) ) |
|
662 |
return $return; |
|
663 |
if ( is_array($return) ) |
|
664 |
$errors = $return; |
|
665 |
} |
|
666 |
||
667 |
wp_enqueue_script('admin-gallery'); |
|
668 |
return wp_iframe( 'media_upload_gallery_form', $errors ); |
|
669 |
} |
|
670 |
||
671 |
/** |
|
672 |
* {@internal Missing Short Description}} |
|
673 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
674 |
* @since 2.5.0 |
136 | 675 |
* |
676 |
* @return unknown |
|
677 |
*/ |
|
678 |
function media_upload_library() { |
|
679 |
$errors = array(); |
|
680 |
if ( !empty($_POST) ) { |
|
681 |
$return = media_upload_form_handler(); |
|
682 |
||
683 |
if ( is_string($return) ) |
|
684 |
return $return; |
|
685 |
if ( is_array($return) ) |
|
686 |
$errors = $return; |
|
687 |
} |
|
688 |
||
689 |
return wp_iframe( 'media_upload_library_form', $errors ); |
|
690 |
} |
|
691 |
||
692 |
/** |
|
693 |
* Retrieve HTML for the image alignment radio buttons with the specified one checked. |
|
694 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
695 |
* @since 2.7.0 |
136 | 696 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
697 |
* @param object $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
698 |
* @param string $checked |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
699 |
* @return string |
136 | 700 |
*/ |
701 |
function image_align_input_fields( $post, $checked = '' ) { |
|
702 |
||
703 |
if ( empty($checked) ) |
|
704 |
$checked = get_user_setting('align', 'none'); |
|
705 |
||
706 |
$alignments = array('none' => __('None'), 'left' => __('Left'), 'center' => __('Center'), 'right' => __('Right')); |
|
707 |
if ( !array_key_exists( (string) $checked, $alignments ) ) |
|
708 |
$checked = 'none'; |
|
709 |
||
710 |
$out = array(); |
|
711 |
foreach ( $alignments as $name => $label ) { |
|
712 |
$name = esc_attr($name); |
|
713 |
$out[] = "<input type='radio' name='attachments[{$post->ID}][align]' id='image-align-{$name}-{$post->ID}' value='$name'". |
|
714 |
( $checked == $name ? " checked='checked'" : "" ) . |
|
715 |
" /><label for='image-align-{$name}-{$post->ID}' class='align image-align-{$name}-label'>$label</label>"; |
|
716 |
} |
|
717 |
return join("\n", $out); |
|
718 |
} |
|
719 |
||
720 |
/** |
|
721 |
* Retrieve HTML for the size radio buttons with the specified one checked. |
|
722 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
723 |
* @since 2.7.0 |
136 | 724 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
725 |
* @param object $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
726 |
* @param bool|string $check |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
727 |
* @return array |
136 | 728 |
*/ |
729 |
function image_size_input_fields( $post, $check = '' ) { |
|
730 |
||
731 |
// get a list of the actual pixel dimensions of each possible intermediate version of this image |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
732 |
$size_names = apply_filters( 'image_size_names_choose', array('thumbnail' => __('Thumbnail'), 'medium' => __('Medium'), 'large' => __('Large'), 'full' => __('Full Size')) ); |
136 | 733 |
|
734 |
if ( empty($check) ) |
|
735 |
$check = get_user_setting('imgsize', 'medium'); |
|
736 |
||
737 |
foreach ( $size_names as $size => $label ) { |
|
738 |
$downsize = image_downsize($post->ID, $size); |
|
739 |
$checked = ''; |
|
740 |
||
741 |
// is this size selectable? |
|
742 |
$enabled = ( $downsize[3] || 'full' == $size ); |
|
743 |
$css_id = "image-size-{$size}-{$post->ID}"; |
|
744 |
// if this size is the default but that's not available, don't select it |
|
745 |
if ( $size == $check ) { |
|
746 |
if ( $enabled ) |
|
747 |
$checked = " checked='checked'"; |
|
748 |
else |
|
749 |
$check = ''; |
|
750 |
} elseif ( !$check && $enabled && 'thumbnail' != $size ) { |
|
751 |
// if $check is not enabled, default to the first available size that's bigger than a thumbnail |
|
752 |
$check = $size; |
|
753 |
$checked = " checked='checked'"; |
|
754 |
} |
|
755 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
756 |
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />"; |
136 | 757 |
|
758 |
$html .= "<label for='{$css_id}'>$label</label>"; |
|
759 |
// only show the dimensions if that choice is available |
|
760 |
if ( $enabled ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
761 |
$html .= " <label for='{$css_id}' class='help'>" . sprintf( "(%d × %d)", $downsize[1], $downsize[2] ). "</label>"; |
136 | 762 |
|
763 |
$html .= '</div>'; |
|
764 |
||
765 |
$out[] = $html; |
|
766 |
} |
|
767 |
||
768 |
return array( |
|
769 |
'label' => __('Size'), |
|
770 |
'input' => 'html', |
|
771 |
'html' => join("\n", $out), |
|
772 |
); |
|
773 |
} |
|
774 |
||
775 |
/** |
|
776 |
* Retrieve HTML for the Link URL buttons with the default link type as specified. |
|
777 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
778 |
* @since 2.7.0 |
136 | 779 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
780 |
* @param object $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
781 |
* @param string $url_type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
782 |
* @return string |
136 | 783 |
*/ |
784 |
function image_link_input_fields($post, $url_type = '') { |
|
785 |
||
786 |
$file = wp_get_attachment_url($post->ID); |
|
787 |
$link = get_attachment_link($post->ID); |
|
788 |
||
789 |
if ( empty($url_type) ) |
|
790 |
$url_type = get_user_setting('urlbutton', 'post'); |
|
791 |
||
792 |
$url = ''; |
|
793 |
if ( $url_type == 'file' ) |
|
794 |
$url = $file; |
|
795 |
elseif ( $url_type == 'post' ) |
|
796 |
$url = $link; |
|
797 |
||
798 |
return " |
|
799 |
<input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
800 |
<button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
801 |
<button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
802 |
<button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button> |
136 | 803 |
"; |
804 |
} |
|
805 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
806 |
function wp_caption_input_textarea($edit_post) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
807 |
// post data is already escaped |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
808 |
$name = "attachments[{$edit_post->ID}][post_excerpt]"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
809 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
810 |
return '<textarea name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea>'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
811 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
812 |
|
136 | 813 |
/** |
814 |
* {@internal Missing Short Description}} |
|
815 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
816 |
* @since 2.5.0 |
136 | 817 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
818 |
* @param array $form_fields |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
819 |
* @param object $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
820 |
* @return array |
136 | 821 |
*/ |
822 |
function image_attachment_fields_to_edit($form_fields, $post) { |
|
823 |
return $form_fields; |
|
824 |
} |
|
825 |
||
826 |
/** |
|
827 |
* {@internal Missing Short Description}} |
|
828 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
829 |
* @since 2.5.0 |
136 | 830 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
831 |
* @param array $form_fields |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
832 |
* @param object $post {@internal $post not used}} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
833 |
* @return array |
136 | 834 |
*/ |
835 |
function media_single_attachment_fields_to_edit( $form_fields, $post ) { |
|
836 |
unset($form_fields['url'], $form_fields['align'], $form_fields['image-size']); |
|
837 |
return $form_fields; |
|
838 |
} |
|
839 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
840 |
/** |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
841 |
* {@internal Missing Short Description}} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
842 |
* |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
843 |
* @since 2.8.0 |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
844 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
845 |
* @param array $form_fields |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
846 |
* @param object $post {@internal $post not used}} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
847 |
* @return array |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
848 |
*/ |
136 | 849 |
function media_post_single_attachment_fields_to_edit( $form_fields, $post ) { |
850 |
unset($form_fields['image_url']); |
|
851 |
return $form_fields; |
|
852 |
} |
|
853 |
||
854 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
855 |
* Filters input from media_upload_form_handler() and assigns a default |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
856 |
* post_title from the file name if none supplied. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
857 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
858 |
* Illustrates the use of the attachment_fields_to_save filter |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
859 |
* which can be used to add default values to any field before saving to DB. |
136 | 860 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
861 |
* @since 2.5.0 |
136 | 862 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
863 |
* @param object $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
864 |
* @param array $attachment {@internal $attachment not used}} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
865 |
* @return array |
136 | 866 |
*/ |
867 |
function image_attachment_fields_to_save($post, $attachment) { |
|
868 |
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) { |
|
869 |
if ( strlen(trim($post['post_title'])) == 0 ) { |
|
870 |
$post['post_title'] = preg_replace('/\.\w+$/', '', basename($post['guid'])); |
|
871 |
$post['errors']['post_title']['errors'][] = __('Empty Title filled from filename.'); |
|
872 |
} |
|
873 |
} |
|
874 |
||
875 |
return $post; |
|
876 |
} |
|
877 |
||
878 |
add_filter('attachment_fields_to_save', 'image_attachment_fields_to_save', 10, 2); |
|
879 |
||
880 |
/** |
|
881 |
* {@internal Missing Short Description}} |
|
882 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
883 |
* @since 2.5.0 |
136 | 884 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
885 |
* @param string $html |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
886 |
* @param integer $attachment_id |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
887 |
* @param array $attachment |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
888 |
* @return array |
136 | 889 |
*/ |
890 |
function image_media_send_to_editor($html, $attachment_id, $attachment) { |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
891 |
$post = get_post($attachment_id); |
136 | 892 |
if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
893 |
$url = $attachment['url']; |
|
894 |
$align = !empty($attachment['align']) ? $attachment['align'] : 'none'; |
|
895 |
$size = !empty($attachment['image-size']) ? $attachment['image-size'] : 'medium'; |
|
896 |
$alt = !empty($attachment['image_alt']) ? $attachment['image_alt'] : ''; |
|
897 |
$rel = ( $url == get_attachment_link($attachment_id) ); |
|
898 |
||
899 |
return get_image_send_to_editor($attachment_id, $attachment['post_excerpt'], $attachment['post_title'], $align, $url, $rel, $size, $alt); |
|
900 |
} |
|
901 |
||
902 |
return $html; |
|
903 |
} |
|
904 |
||
905 |
add_filter('media_send_to_editor', 'image_media_send_to_editor', 10, 3); |
|
906 |
||
907 |
/** |
|
908 |
* {@internal Missing Short Description}} |
|
909 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
910 |
* @since 2.5.0 |
136 | 911 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
912 |
* @param object $post |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
913 |
* @param array $errors |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
914 |
* @return array |
136 | 915 |
*/ |
916 |
function get_attachment_fields_to_edit($post, $errors = null) { |
|
917 |
if ( is_int($post) ) |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
918 |
$post = get_post($post); |
136 | 919 |
if ( is_array($post) ) |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
920 |
$post = new WP_Post( (object) $post ); |
136 | 921 |
|
922 |
$image_url = wp_get_attachment_url($post->ID); |
|
923 |
||
924 |
$edit_post = sanitize_post($post, 'edit'); |
|
925 |
||
926 |
$form_fields = array( |
|
927 |
'post_title' => array( |
|
928 |
'label' => __('Title'), |
|
929 |
'value' => $edit_post->post_title |
|
930 |
), |
|
931 |
'image_alt' => array(), |
|
932 |
'post_excerpt' => array( |
|
933 |
'label' => __('Caption'), |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
934 |
'input' => 'html', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
935 |
'html' => wp_caption_input_textarea($edit_post) |
136 | 936 |
), |
937 |
'post_content' => array( |
|
938 |
'label' => __('Description'), |
|
939 |
'value' => $edit_post->post_content, |
|
940 |
'input' => 'textarea' |
|
941 |
), |
|
942 |
'url' => array( |
|
943 |
'label' => __('Link URL'), |
|
944 |
'input' => 'html', |
|
945 |
'html' => image_link_input_fields($post, get_option('image_default_link_type')), |
|
946 |
'helps' => __('Enter a link URL or click above for presets.') |
|
947 |
), |
|
948 |
'menu_order' => array( |
|
949 |
'label' => __('Order'), |
|
950 |
'value' => $edit_post->menu_order |
|
951 |
), |
|
952 |
'image_url' => array( |
|
953 |
'label' => __('File URL'), |
|
954 |
'input' => 'html', |
|
955 |
'html' => "<input type='text' class='text urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . esc_attr($image_url) . "' /><br />", |
|
956 |
'value' => wp_get_attachment_url($post->ID), |
|
957 |
'helps' => __('Location of the uploaded file.') |
|
958 |
) |
|
959 |
); |
|
960 |
||
961 |
foreach ( get_attachment_taxonomies($post) as $taxonomy ) { |
|
962 |
$t = (array) get_taxonomy($taxonomy); |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
963 |
if ( ! $t['public'] || ! $t['show_ui'] ) |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
964 |
continue; |
136 | 965 |
if ( empty($t['label']) ) |
966 |
$t['label'] = $taxonomy; |
|
967 |
if ( empty($t['args']) ) |
|
968 |
$t['args'] = array(); |
|
969 |
||
970 |
$terms = get_object_term_cache($post->ID, $taxonomy); |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
971 |
if ( false === $terms ) |
136 | 972 |
$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
973 |
||
974 |
$values = array(); |
|
975 |
||
976 |
foreach ( $terms as $term ) |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
977 |
$values[] = $term->slug; |
136 | 978 |
$t['value'] = join(', ', $values); |
979 |
||
980 |
$form_fields[$taxonomy] = $t; |
|
981 |
} |
|
982 |
||
983 |
// Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default |
|
984 |
// The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) |
|
985 |
$form_fields = array_merge_recursive($form_fields, (array) $errors); |
|
986 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
987 |
// This was formerly in image_attachment_fields_to_edit(). |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
988 |
if ( substr($post->post_mime_type, 0, 5) == 'image' ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
989 |
$alt = get_post_meta($post->ID, '_wp_attachment_image_alt', true); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
990 |
if ( empty($alt) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
991 |
$alt = ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
992 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
993 |
$form_fields['post_title']['required'] = true; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
994 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
995 |
$form_fields['image_alt'] = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
996 |
'value' => $alt, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
997 |
'label' => __('Alternative Text'), |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
998 |
'helps' => __('Alt text for the image, e.g. “The Mona Lisa”') |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
999 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1000 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1001 |
$form_fields['align'] = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1002 |
'label' => __('Alignment'), |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1003 |
'input' => 'html', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1004 |
'html' => image_align_input_fields($post, get_option('image_default_align')), |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1005 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1006 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1007 |
$form_fields['image-size'] = image_size_input_fields( $post, get_option('image_default_size', 'medium') ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1008 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1009 |
} else { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1010 |
unset( $form_fields['image_alt'] ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1011 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1012 |
|
136 | 1013 |
$form_fields = apply_filters('attachment_fields_to_edit', $form_fields, $post); |
1014 |
||
1015 |
return $form_fields; |
|
1016 |
} |
|
1017 |
||
1018 |
/** |
|
1019 |
* Retrieve HTML for media items of post gallery. |
|
1020 |
* |
|
1021 |
* The HTML markup retrieved will be created for the progress of SWF Upload |
|
1022 |
* component. Will also create link for showing and hiding the form to modify |
|
1023 |
* the image attachment. |
|
1024 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1025 |
* @since 2.5.0 |
136 | 1026 |
* |
1027 |
* @param int $post_id Optional. Post ID. |
|
1028 |
* @param array $errors Errors for attachment, if any. |
|
1029 |
* @return string |
|
1030 |
*/ |
|
1031 |
function get_media_items( $post_id, $errors ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1032 |
$attachments = array(); |
136 | 1033 |
if ( $post_id ) { |
1034 |
$post = get_post($post_id); |
|
1035 |
if ( $post && $post->post_type == 'attachment' ) |
|
1036 |
$attachments = array($post->ID => $post); |
|
1037 |
else |
|
1038 |
$attachments = get_children( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'orderby' => 'menu_order ASC, ID', 'order' => 'DESC') ); |
|
1039 |
} else { |
|
1040 |
if ( is_array($GLOBALS['wp_the_query']->posts) ) |
|
1041 |
foreach ( $GLOBALS['wp_the_query']->posts as $attachment ) |
|
1042 |
$attachments[$attachment->ID] = $attachment; |
|
1043 |
} |
|
1044 |
||
1045 |
$output = ''; |
|
1046 |
foreach ( (array) $attachments as $id => $attachment ) { |
|
1047 |
if ( $attachment->post_status == 'trash' ) |
|
1048 |
continue; |
|
1049 |
if ( $item = get_media_item( $id, array( 'errors' => isset($errors[$id]) ? $errors[$id] : null) ) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1050 |
$output .= "\n<div id='media-item-$id' class='media-item child-of-$attachment->post_parent preloaded'><div class='progress hidden'><div class='bar'></div></div><div id='media-upload-error-$id' class='hidden'></div><div class='filename hidden'></div>$item\n</div>"; |
136 | 1051 |
} |
1052 |
||
1053 |
return $output; |
|
1054 |
} |
|
1055 |
||
1056 |
/** |
|
1057 |
* Retrieve HTML form for modifying the image attachment. |
|
1058 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1059 |
* @since 2.5.0 |
136 | 1060 |
* |
1061 |
* @param int $attachment_id Attachment ID for modification. |
|
1062 |
* @param string|array $args Optional. Override defaults. |
|
1063 |
* @return string HTML form for attachment. |
|
1064 |
*/ |
|
1065 |
function get_media_item( $attachment_id, $args = null ) { |
|
1066 |
global $redir_tab; |
|
1067 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1068 |
if ( ( $attachment_id = intval( $attachment_id ) ) && $thumb_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail', true ) ) |
136 | 1069 |
$thumb_url = $thumb_url[0]; |
1070 |
else |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1071 |
$thumb_url = false; |
136 | 1072 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1073 |
$post = get_post( $attachment_id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1074 |
$current_post_id = !empty( $_GET['post_id'] ) ? (int) $_GET['post_id'] : 0; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1075 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1076 |
$default_args = array( 'errors' => null, 'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true ); |
136 | 1077 |
$args = wp_parse_args( $args, $default_args ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1078 |
$args = apply_filters( 'get_media_item_args', $args ); |
136 | 1079 |
extract( $args, EXTR_SKIP ); |
1080 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1081 |
$toggle_on = __( 'Show' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1082 |
$toggle_off = __( 'Hide' ); |
136 | 1083 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1084 |
$filename = esc_html( wp_basename( $post->guid ) ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1085 |
$title = esc_attr( $post->post_title ); |
136 | 1086 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1087 |
if ( $_tags = get_the_tags( $attachment_id ) ) { |
136 | 1088 |
foreach ( $_tags as $tag ) |
1089 |
$tags[] = $tag->name; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1090 |
$tags = esc_attr( join( ', ', $tags ) ); |
136 | 1091 |
} |
1092 |
||
1093 |
$post_mime_types = get_post_mime_types(); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1094 |
$keys = array_keys( wp_match_mime_types( array_keys( $post_mime_types ), $post->post_mime_type ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1095 |
$type = array_shift( $keys ); |
136 | 1096 |
$type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; |
1097 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1098 |
$form_fields = get_attachment_fields_to_edit( $post, $errors ); |
136 | 1099 |
|
1100 |
if ( $toggle ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1101 |
$class = empty( $errors ) ? 'startclosed' : 'startopen'; |
136 | 1102 |
$toggle_links = " |
1103 |
<a class='toggle describe-toggle-on' href='#'>$toggle_on</a> |
|
1104 |
<a class='toggle describe-toggle-off' href='#'>$toggle_off</a>"; |
|
1105 |
} else { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1106 |
$class = ''; |
136 | 1107 |
$toggle_links = ''; |
1108 |
} |
|
1109 |
||
1110 |
$display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1111 |
$display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : ''; |
136 | 1112 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1113 |
$gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ); |
136 | 1114 |
$order = ''; |
1115 |
||
1116 |
foreach ( $form_fields as $key => $val ) { |
|
1117 |
if ( 'menu_order' == $key ) { |
|
1118 |
if ( $gallery ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1119 |
$order = "<div class='menu_order'> <input class='menu_order_input' type='text' id='attachments[$attachment_id][menu_order]' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ). "' /></div>"; |
136 | 1120 |
else |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1121 |
$order = "<input type='hidden' name='attachments[$attachment_id][menu_order]' value='" . esc_attr( $val['value'] ) . "' />"; |
136 | 1122 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1123 |
unset( $form_fields['menu_order'] ); |
136 | 1124 |
break; |
1125 |
} |
|
1126 |
} |
|
1127 |
||
1128 |
$media_dims = ''; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1129 |
$meta = wp_get_attachment_metadata( $post->ID ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1130 |
if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1131 |
$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1132 |
$media_dims = apply_filters( 'media_meta', $media_dims, $post ); |
136 | 1133 |
|
1134 |
$image_edit_button = ''; |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1135 |
if ( wp_attachment_is_image( $post->ID ) && wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1136 |
$nonce = wp_create_nonce( "image_editor-$post->ID" ); |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1137 |
$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>"; |
136 | 1138 |
} |
1139 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1140 |
$attachment_url = get_permalink( $attachment_id ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1141 |
|
136 | 1142 |
$item = " |
1143 |
$type_html |
|
1144 |
$toggle_links |
|
1145 |
$order |
|
1146 |
$display_title |
|
1147 |
<table class='slidetoggle describe $class'> |
|
1148 |
<thead class='media-item-info' id='media-head-$post->ID'> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1149 |
<tr valign='top'> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1150 |
<td class='A1B1' id='thumbnail-head-$post->ID'> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1151 |
<p><a href='$attachment_url' target='_blank'><img class='thumbnail' src='$thumb_url' alt='' /></a></p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1152 |
<p>$image_edit_button</p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1153 |
</td> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1154 |
<td> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1155 |
<p><strong>" . __('File name:') . "</strong> $filename</p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1156 |
<p><strong>" . __('File type:') . "</strong> $post->post_mime_type</p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1157 |
<p><strong>" . __('Upload date:') . "</strong> " . mysql2date( get_option('date_format'), $post->post_date ). '</p>'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1158 |
if ( !empty( $media_dims ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1159 |
$item .= "<p><strong>" . __('Dimensions:') . "</strong> $media_dims</p>\n"; |
136 | 1160 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1161 |
$item .= "</td></tr>\n"; |
136 | 1162 |
|
1163 |
$item .= " |
|
1164 |
</thead> |
|
1165 |
<tbody> |
|
1166 |
<tr><td colspan='2' class='imgedit-response' id='imgedit-response-$post->ID'></td></tr> |
|
1167 |
<tr><td style='display:none' colspan='2' class='image-editor' id='image-editor-$post->ID'></td></tr>\n"; |
|
1168 |
||
1169 |
$defaults = array( |
|
1170 |
'input' => 'text', |
|
1171 |
'required' => false, |
|
1172 |
'value' => '', |
|
1173 |
'extra_rows' => array(), |
|
1174 |
); |
|
1175 |
||
1176 |
if ( $send ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1177 |
$send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1178 |
if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { |
136 | 1179 |
if ( !EMPTY_TRASH_DAYS ) { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1180 |
$delete = "<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>'; |
136 | 1181 |
} elseif ( !MEDIA_TRASH ) { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1182 |
$delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1183 |
<div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p> |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1184 |
<a href='" . wp_nonce_url( "post.php?action=delete&post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1185 |
<a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1186 |
</div>"; |
136 | 1187 |
} else { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1188 |
$delete = "<a href='" . wp_nonce_url( "post.php?action=trash&post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1189 |
<a href='" . wp_nonce_url( "post.php?action=untrash&post=$attachment_id", 'untrash-post_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; |
136 | 1190 |
} |
1191 |
} else { |
|
1192 |
$delete = ''; |
|
1193 |
} |
|
1194 |
||
1195 |
$thumbnail = ''; |
|
1196 |
$calling_post_id = 0; |
|
1197 |
if ( isset( $_GET['post_id'] ) ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1198 |
$calling_post_id = absint( $_GET['post_id'] ); |
136 | 1199 |
elseif ( isset( $_POST ) && count( $_POST ) ) // Like for async-upload where $_GET['post_id'] isn't set |
1200 |
$calling_post_id = $post->post_parent; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1201 |
if ( 'image' == $type && $calling_post_id && current_theme_supports( 'post-thumbnails', get_post_type( $calling_post_id ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1202 |
&& post_type_supports( get_post_type( $calling_post_id ), 'thumbnail' ) && get_post_thumbnail_id( $calling_post_id ) != $attachment_id ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1203 |
$ajax_nonce = wp_create_nonce( "set_post_thumbnail-$calling_post_id" ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1204 |
$thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1205 |
} |
136 | 1206 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1207 |
if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1208 |
$form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n" ); |
136 | 1209 |
|
1210 |
$hidden_fields = array(); |
|
1211 |
||
1212 |
foreach ( $form_fields as $id => $field ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1213 |
if ( $id[0] == '_' ) |
136 | 1214 |
continue; |
1215 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1216 |
if ( !empty( $field['tr'] ) ) { |
136 | 1217 |
$item .= $field['tr']; |
1218 |
continue; |
|
1219 |
} |
|
1220 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1221 |
$field = array_merge( $defaults, $field ); |
136 | 1222 |
$name = "attachments[$attachment_id][$id]"; |
1223 |
||
1224 |
if ( $field['input'] == 'hidden' ) { |
|
1225 |
$hidden_fields[$name] = $field['value']; |
|
1226 |
continue; |
|
1227 |
} |
|
1228 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1229 |
$required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : ''; |
136 | 1230 |
$aria_required = $field['required'] ? " aria-required='true' " : ''; |
1231 |
$class = $id; |
|
1232 |
$class .= $field['required'] ? ' form-required' : ''; |
|
1233 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1234 |
$item .= "\t\t<tr class='$class'>\n\t\t\t<th valign='top' scope='row' class='label'><label for='$name'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label></th>\n\t\t\t<td class='field'>"; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1235 |
if ( !empty( $field[ $field['input'] ] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1236 |
$item .= $field[ $field['input'] ]; |
136 | 1237 |
elseif ( $field['input'] == 'textarea' ) { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1238 |
if ( 'post_content' == $id && user_can_richedit() ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1239 |
// sanitize_post() skips the post_content when user_can_richedit |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1240 |
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1241 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1242 |
// post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit() |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1243 |
$item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>'; |
136 | 1244 |
} else { |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1245 |
$item .= "<input type='text' class='text' id='$name' name='$name' value='" . esc_attr( $field['value'] ) . "' $aria_required />"; |
136 | 1246 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1247 |
if ( !empty( $field['helps'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1248 |
$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; |
136 | 1249 |
$item .= "</td>\n\t\t</tr>\n"; |
1250 |
||
1251 |
$extra_rows = array(); |
|
1252 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1253 |
if ( !empty( $field['errors'] ) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1254 |
foreach ( array_unique( (array) $field['errors'] ) as $error ) |
136 | 1255 |
$extra_rows['error'][] = $error; |
1256 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1257 |
if ( !empty( $field['extra_rows'] ) ) |
136 | 1258 |
foreach ( $field['extra_rows'] as $class => $rows ) |
1259 |
foreach ( (array) $rows as $html ) |
|
1260 |
$extra_rows[$class][] = $html; |
|
1261 |
||
1262 |
foreach ( $extra_rows as $class => $rows ) |
|
1263 |
foreach ( $rows as $html ) |
|
1264 |
$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n"; |
|
1265 |
} |
|
1266 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1267 |
if ( !empty( $form_fields['_final'] ) ) |
136 | 1268 |
$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; |
1269 |
$item .= "\t</tbody>\n"; |
|
1270 |
$item .= "\t</table>\n"; |
|
1271 |
||
1272 |
foreach ( $hidden_fields as $name => $value ) |
|
1273 |
$item .= "\t<input type='hidden' name='$name' id='$name' value='" . esc_attr( $value ) . "' />\n"; |
|
1274 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1275 |
if ( $post->post_parent < 1 && isset( $_REQUEST['post_id'] ) ) { |
136 | 1276 |
$parent = (int) $_REQUEST['post_id']; |
1277 |
$parent_name = "attachments[$attachment_id][post_parent]"; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1278 |
$item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='$parent' />\n"; |
136 | 1279 |
} |
1280 |
||
1281 |
return $item; |
|
1282 |
} |
|
1283 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1284 |
function get_compat_media_markup( $attachment_id, $args = null ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1285 |
$post = get_post( $attachment_id ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1286 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1287 |
$default_args = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1288 |
'errors' => null, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1289 |
'in_modal' => false, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1290 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1291 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1292 |
$user_can_edit = current_user_can( 'edit_post', $attachment_id ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1293 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1294 |
$args = wp_parse_args( $args, $default_args ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1295 |
$args = apply_filters( 'get_media_item_args', $args ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1296 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1297 |
$form_fields = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1298 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1299 |
if ( $args['in_modal'] ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1300 |
foreach ( get_attachment_taxonomies($post) as $taxonomy ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1301 |
$t = (array) get_taxonomy($taxonomy); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1302 |
if ( ! $t['public'] || ! $t['show_ui'] ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1303 |
continue; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1304 |
if ( empty($t['label']) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1305 |
$t['label'] = $taxonomy; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1306 |
if ( empty($t['args']) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1307 |
$t['args'] = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1308 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1309 |
$terms = get_object_term_cache($post->ID, $taxonomy); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1310 |
if ( false === $terms ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1311 |
$terms = wp_get_object_terms($post->ID, $taxonomy, $t['args']); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1312 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1313 |
$values = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1314 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1315 |
foreach ( $terms as $term ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1316 |
$values[] = $term->slug; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1317 |
$t['value'] = join(', ', $values); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1318 |
$t['taxonomy'] = true; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1319 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1320 |
$form_fields[$taxonomy] = $t; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1321 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1322 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1323 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1324 |
// Merge default fields with their errors, so any key passed with the error (e.g. 'error', 'helps', 'value') will replace the default |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1325 |
// The recursive merge is easily traversed with array casting: foreach( (array) $things as $thing ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1326 |
$form_fields = array_merge_recursive($form_fields, (array) $args['errors'] ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1327 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1328 |
$form_fields = apply_filters( 'attachment_fields_to_edit', $form_fields, $post ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1329 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1330 |
unset( $form_fields['image-size'], $form_fields['align'], $form_fields['image_alt'], |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1331 |
$form_fields['post_title'], $form_fields['post_excerpt'], $form_fields['post_content'], |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1332 |
$form_fields['url'], $form_fields['menu_order'], $form_fields['image_url'] ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1333 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1334 |
$media_meta = apply_filters( 'media_meta', '', $post ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1335 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1336 |
$defaults = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1337 |
'input' => 'text', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1338 |
'required' => false, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1339 |
'value' => '', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1340 |
'extra_rows' => array(), |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1341 |
'show_in_edit' => true, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1342 |
'show_in_modal' => true, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1343 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1344 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1345 |
$hidden_fields = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1346 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1347 |
$item = ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1348 |
foreach ( $form_fields as $id => $field ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1349 |
if ( $id[0] == '_' ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1350 |
continue; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1351 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1352 |
$name = "attachments[$attachment_id][$id]"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1353 |
$id_attr = "attachments-$attachment_id-$id"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1354 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1355 |
if ( !empty( $field['tr'] ) ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1356 |
$item .= $field['tr']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1357 |
continue; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1358 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1359 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1360 |
$field = array_merge( $defaults, $field ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1361 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1362 |
if ( ( ! $field['show_in_edit'] && ! $args['in_modal'] ) || ( ! $field['show_in_modal'] && $args['in_modal'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1363 |
continue; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1364 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1365 |
if ( $field['input'] == 'hidden' ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1366 |
$hidden_fields[$name] = $field['value']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1367 |
continue; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1368 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1369 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1370 |
$readonly = ! $user_can_edit && ! empty( $field['taxonomy'] ) ? " readonly='readonly' " : ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1371 |
$required = $field['required'] ? '<span class="alignright"><abbr title="required" class="required">*</abbr></span>' : ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1372 |
$aria_required = $field['required'] ? " aria-required='true' " : ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1373 |
$class = 'compat-field-' . $id; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1374 |
$class .= $field['required'] ? ' form-required' : ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1375 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1376 |
$item .= "\t\t<tr class='$class'>"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1377 |
$item .= "\t\t\t<th valign='top' scope='row' class='label'><label for='$id_attr'><span class='alignleft'>{$field['label']}</span>$required<br class='clear' /></label>"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1378 |
$item .= "</th>\n\t\t\t<td class='field'>"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1379 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1380 |
if ( !empty( $field[ $field['input'] ] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1381 |
$item .= $field[ $field['input'] ]; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1382 |
elseif ( $field['input'] == 'textarea' ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1383 |
if ( 'post_content' == $id && user_can_richedit() ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1384 |
// sanitize_post() skips the post_content when user_can_richedit |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1385 |
$field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1386 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1387 |
$item .= "<textarea id='$id_attr' name='$name' $aria_required>" . $field['value'] . '</textarea>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1388 |
} else { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1389 |
$item .= "<input type='text' class='text' id='$id_attr' name='$name' value='" . esc_attr( $field['value'] ) . "' $readonly $aria_required />"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1390 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1391 |
if ( !empty( $field['helps'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1392 |
$item .= "<p class='help'>" . join( "</p>\n<p class='help'>", array_unique( (array) $field['helps'] ) ) . '</p>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1393 |
$item .= "</td>\n\t\t</tr>\n"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1394 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1395 |
$extra_rows = array(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1396 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1397 |
if ( !empty( $field['errors'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1398 |
foreach ( array_unique( (array) $field['errors'] ) as $error ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1399 |
$extra_rows['error'][] = $error; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1400 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1401 |
if ( !empty( $field['extra_rows'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1402 |
foreach ( $field['extra_rows'] as $class => $rows ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1403 |
foreach ( (array) $rows as $html ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1404 |
$extra_rows[$class][] = $html; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1405 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1406 |
foreach ( $extra_rows as $class => $rows ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1407 |
foreach ( $rows as $html ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1408 |
$item .= "\t\t<tr><td></td><td class='$class'>$html</td></tr>\n"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1409 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1410 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1411 |
if ( !empty( $form_fields['_final'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1412 |
$item .= "\t\t<tr class='final'><td colspan='2'>{$form_fields['_final']}</td></tr>\n"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1413 |
if ( $item ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1414 |
$item = '<table class="compat-attachment-fields">' . $item . '</table>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1415 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1416 |
foreach ( $hidden_fields as $hidden_field => $value ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1417 |
$item .= '<input type="hidden" name="' . esc_attr( $hidden_field ) . '" value="' . esc_attr( $value ) . '" />' . "\n"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1418 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1419 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1420 |
return array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1421 |
'item' => $item, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1422 |
'meta' => $media_meta, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1423 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1424 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1425 |
|
136 | 1426 |
/** |
1427 |
* {@internal Missing Short Description}} |
|
1428 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1429 |
* @since 2.5.0 |
136 | 1430 |
*/ |
1431 |
function media_upload_header() { |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1432 |
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1433 |
echo '<script type="text/javascript">post_id = ' . $post_id . ";</script>\n"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1434 |
if ( empty( $_GET['chromeless'] ) ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1435 |
echo '<div id="media-upload-header">'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1436 |
the_media_upload_tabs(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1437 |
echo '</div>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1438 |
} |
136 | 1439 |
} |
1440 |
||
1441 |
/** |
|
1442 |
* {@internal Missing Short Description}} |
|
1443 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1444 |
* @since 2.5.0 |
136 | 1445 |
* |
1446 |
* @param unknown_type $errors |
|
1447 |
*/ |
|
1448 |
function media_upload_form( $errors = null ) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1449 |
global $type, $tab, $pagenow, $is_IE, $is_opera; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1450 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1451 |
if ( ! _device_can_upload() ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1452 |
echo '<p>' . __('The web browser on your device cannot be used to upload files. You may be able to use the <a href="http://wordpress.org/extend/mobile/">native app for your device</a> instead.') . '</p>'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1453 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1454 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1455 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1456 |
$upload_action_url = admin_url('async-upload.php'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1457 |
$post_id = isset($_REQUEST['post_id']) ? intval($_REQUEST['post_id']) : 0; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1458 |
$_type = isset($type) ? $type : ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1459 |
$_tab = isset($tab) ? $tab : ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1460 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1461 |
$upload_size_unit = $max_upload_size = wp_max_upload_size(); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1462 |
$sizes = array( 'KB', 'MB', 'GB' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1463 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1464 |
for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1465 |
$upload_size_unit /= 1024; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1466 |
} |
136 | 1467 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1468 |
if ( $u < 0 ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1469 |
$upload_size_unit = 0; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1470 |
$u = 0; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1471 |
} else { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1472 |
$upload_size_unit = (int) $upload_size_unit; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1473 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1474 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1475 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1476 |
<div id="media-upload-notice"><?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1477 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1478 |
if (isset($errors['upload_notice']) ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1479 |
echo $errors['upload_notice']; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1480 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1481 |
?></div> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1482 |
<div id="media-upload-error"><?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1483 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1484 |
if (isset($errors['upload_error']) && is_wp_error($errors['upload_error'])) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1485 |
echo $errors['upload_error']->get_error_message(); |
136 | 1486 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1487 |
?></div> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1488 |
<?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1489 |
if ( is_multisite() && !is_upload_space_available() ) { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1490 |
do_action( 'upload_ui_over_quota' ); |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1491 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1492 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1493 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1494 |
do_action('pre-upload-ui'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1495 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1496 |
$post_params = array( |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1497 |
"post_id" => $post_id, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1498 |
"_wpnonce" => wp_create_nonce('media-form'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1499 |
"type" => $_type, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1500 |
"tab" => $_tab, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1501 |
"short" => "1", |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1502 |
); |
136 | 1503 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1504 |
$post_params = apply_filters( 'upload_post_params', $post_params ); // hook change! old name: 'swfupload_post_params' |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1505 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1506 |
$plupload_init = array( |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1507 |
'runtimes' => 'html5,silverlight,flash,html4', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1508 |
'browse_button' => 'plupload-browse-button', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1509 |
'container' => 'plupload-upload-ui', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1510 |
'drop_element' => 'drag-drop-area', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1511 |
'file_data_name' => 'async-upload', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1512 |
'multiple_queues' => true, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1513 |
'max_file_size' => $max_upload_size . 'b', |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1514 |
'url' => $upload_action_url, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1515 |
'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1516 |
'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1517 |
'filters' => array( array('title' => __( 'Allowed Files' ), 'extensions' => '*') ), |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1518 |
'multipart' => true, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1519 |
'urlstream_upload' => true, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1520 |
'multipart_params' => $post_params |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1521 |
); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1522 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1523 |
// Multi-file uploading doesn't currently work in iOS Safari, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1524 |
// single-file allows the built-in camera to be used as source for images |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1525 |
if ( wp_is_mobile() ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1526 |
$plupload_init['multi_selection'] = false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1527 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1528 |
$plupload_init = apply_filters( 'plupload_init', $plupload_init ); |
136 | 1529 |
|
1530 |
?> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1531 |
|
136 | 1532 |
<script type="text/javascript"> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1533 |
<?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1534 |
// Verify size is an int. If not return default value. |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1535 |
$large_size_h = absint( get_option('large_size_h') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1536 |
if( !$large_size_h ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1537 |
$large_size_h = 1024; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1538 |
$large_size_w = absint( get_option('large_size_w') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1539 |
if( !$large_size_w ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1540 |
$large_size_w = 1024; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1541 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1542 |
var resize_height = <?php echo $large_size_h; ?>, resize_width = <?php echo $large_size_w; ?>, |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1543 |
wpUploaderInit = <?php echo json_encode($plupload_init); ?>; |
136 | 1544 |
</script> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1545 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1546 |
<div id="plupload-upload-ui" class="hide-if-no-js"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1547 |
<?php do_action('pre-plupload-upload-ui'); // hook change, old name: 'pre-flash-upload-ui' ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1548 |
<div id="drag-drop-area"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1549 |
<div class="drag-drop-inside"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1550 |
<p class="drag-drop-info"><?php _e('Drop files here'); ?></p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1551 |
<p><?php _ex('or', 'Uploader: Drop files here - or - Select Files'); ?></p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1552 |
<p class="drag-drop-buttons"><input id="plupload-browse-button" type="button" value="<?php esc_attr_e('Select Files'); ?>" class="button" /></p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1553 |
</div> |
136 | 1554 |
</div> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1555 |
<?php do_action('post-plupload-upload-ui'); // hook change, old name: 'post-flash-upload-ui' ?> |
136 | 1556 |
</div> |
1557 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1558 |
<div id="html-upload-ui" class="hide-if-js"> |
136 | 1559 |
<?php do_action('pre-html-upload-ui'); ?> |
1560 |
<p id="async-upload-wrap"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1561 |
<label class="screen-reader-text" for="async-upload"><?php _e('Upload'); ?></label> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1562 |
<input type="file" name="async-upload" id="async-upload" /> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1563 |
<?php submit_button( __( 'Upload' ), 'button', 'html-upload', false ); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1564 |
<a href="#" onclick="try{top.tb_remove();}catch(e){}; return false;"><?php _e('Cancel'); ?></a> |
136 | 1565 |
</p> |
1566 |
<div class="clear"></div> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1567 |
<?php do_action('post-html-upload-ui'); ?> |
136 | 1568 |
</div> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1569 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1570 |
<span class="max-upload-size"><?php printf( __( 'Maximum upload file size: %d%s.' ), esc_html($upload_size_unit), esc_html($sizes[$u]) ); ?></span> |
136 | 1571 |
<?php |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1572 |
if ( ($is_IE || $is_opera) && $max_upload_size > 100 * 1024 * 1024 ) { ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1573 |
<span class="big-file-warning"><?php _e('Your browser has some limitations uploading large files with the multi-file uploader. Please use the browser uploader for files over 100MB.'); ?></span> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1574 |
<?php } |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1575 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1576 |
do_action('post-upload-ui'); |
136 | 1577 |
} |
1578 |
||
1579 |
/** |
|
1580 |
* {@internal Missing Short Description}} |
|
1581 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1582 |
* @since 2.5.0 |
136 | 1583 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1584 |
* @param string $type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1585 |
* @param object $errors |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1586 |
* @param integer $id |
136 | 1587 |
*/ |
1588 |
function media_upload_type_form($type = 'file', $errors = null, $id = null) { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1589 |
|
136 | 1590 |
media_upload_header(); |
1591 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1592 |
$post_id = isset( $_REQUEST['post_id'] )? intval( $_REQUEST['post_id'] ) : 0; |
136 | 1593 |
|
1594 |
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
|
1595 |
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1596 |
$form_class = 'media-upload-form type-form validate'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1597 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1598 |
if ( get_user_setting('uploader') ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1599 |
$form_class .= ' html-uploader'; |
136 | 1600 |
?> |
1601 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1602 |
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1603 |
<?php submit_button( '', 'hidden', 'save', false ); ?> |
136 | 1604 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
1605 |
<?php wp_nonce_field('media-form'); ?> |
|
1606 |
||
1607 |
<h3 class="media-title"><?php _e('Add media files from your computer'); ?></h3> |
|
1608 |
||
1609 |
<?php media_upload_form( $errors ); ?> |
|
1610 |
||
1611 |
<script type="text/javascript"> |
|
1612 |
//<![CDATA[ |
|
1613 |
jQuery(function($){ |
|
1614 |
var preloaded = $(".media-item.preloaded"); |
|
1615 |
if ( preloaded.length > 0 ) { |
|
1616 |
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
|
1617 |
} |
|
1618 |
updateMediaForm(); |
|
1619 |
}); |
|
1620 |
//]]> |
|
1621 |
</script> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1622 |
<div id="media-items"><?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1623 |
|
136 | 1624 |
if ( $id ) { |
1625 |
if ( !is_wp_error($id) ) { |
|
1626 |
add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); |
|
1627 |
echo get_media_items( $id, $errors ); |
|
1628 |
} else { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1629 |
echo '<div id="media-upload-error">'.esc_html($id->get_error_message()).'</div></div>'; |
136 | 1630 |
exit; |
1631 |
} |
|
1632 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1633 |
?></div> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1634 |
|
136 | 1635 |
<p class="savebutton ml-submit"> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1636 |
<?php submit_button( __( 'Save all changes' ), 'button', 'save', false ); ?> |
136 | 1637 |
</p> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1638 |
</form> |
136 | 1639 |
<?php |
1640 |
} |
|
1641 |
||
1642 |
/** |
|
1643 |
* {@internal Missing Short Description}} |
|
1644 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1645 |
* @since 2.7.0 |
136 | 1646 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1647 |
* @param string $type |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1648 |
* @param object $errors |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1649 |
* @param integer $id |
136 | 1650 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1651 |
function media_upload_type_url_form($type = null, $errors = null, $id = null) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1652 |
if ( null === $type ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1653 |
$type = 'image'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1654 |
|
136 | 1655 |
media_upload_header(); |
1656 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1657 |
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; |
136 | 1658 |
|
1659 |
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); |
|
1660 |
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1661 |
$form_class = 'media-upload-form type-form validate'; |
136 | 1662 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1663 |
if ( get_user_setting('uploader') ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1664 |
$form_class .= ' html-uploader'; |
136 | 1665 |
?> |
1666 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1667 |
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="<?php echo $type; ?>-form"> |
136 | 1668 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
1669 |
<?php wp_nonce_field('media-form'); ?> |
|
1670 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1671 |
<h3 class="media-title"><?php _e('Insert media from another website'); ?></h3> |
136 | 1672 |
|
1673 |
<script type="text/javascript"> |
|
1674 |
//<![CDATA[ |
|
1675 |
var addExtImage = { |
|
1676 |
||
1677 |
width : '', |
|
1678 |
height : '', |
|
1679 |
align : 'alignnone', |
|
1680 |
||
1681 |
insert : function() { |
|
1682 |
var t = this, html, f = document.forms[0], cls, title = '', alt = '', caption = ''; |
|
1683 |
||
1684 |
if ( '' == f.src.value || '' == t.width ) |
|
1685 |
return false; |
|
1686 |
||
1687 |
if ( f.alt.value ) |
|
1688 |
alt = f.alt.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
|
1689 |
||
1690 |
<?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1691 |
if ( f.caption.value ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1692 |
caption = f.caption.value.replace(/\r\n|\r/g, '\n'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1693 |
caption = caption.replace(/<[a-zA-Z0-9]+( [^<>]+)?>/g, function(a){ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1694 |
return a.replace(/[\r\n\t]+/, ' '); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1695 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1696 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1697 |
caption = caption.replace(/\s*\n\s*/g, '<br />'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1698 |
} |
136 | 1699 |
<?php } ?> |
1700 |
||
1701 |
cls = caption ? '' : ' class="'+t.align+'"'; |
|
1702 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1703 |
html = '<img alt="'+alt+'" src="'+f.src.value+'"'+cls+' width="'+t.width+'" height="'+t.height+'" />'; |
136 | 1704 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1705 |
if ( f.url.value ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1706 |
url = f.url.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1707 |
html = '<a href="'+url+'">'+html+'</a>'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1708 |
} |
136 | 1709 |
|
1710 |
if ( caption ) |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1711 |
html = '[caption id="" align="'+t.align+'" width="'+t.width+'"]'+html+caption+'[/caption]'; |
136 | 1712 |
|
1713 |
var win = window.dialogArguments || opener || parent || top; |
|
1714 |
win.send_to_editor(html); |
|
1715 |
return false; |
|
1716 |
}, |
|
1717 |
||
1718 |
resetImageData : function() { |
|
1719 |
var t = addExtImage; |
|
1720 |
||
1721 |
t.width = t.height = ''; |
|
1722 |
document.getElementById('go_button').style.color = '#bbb'; |
|
1723 |
if ( ! document.forms[0].src.value ) |
|
1724 |
document.getElementById('status_img').innerHTML = '*'; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1725 |
else document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/no.png' ) ); ?>" alt="" />'; |
136 | 1726 |
}, |
1727 |
||
1728 |
updateImageData : function() { |
|
1729 |
var t = addExtImage; |
|
1730 |
||
1731 |
t.width = t.preloadImg.width; |
|
1732 |
t.height = t.preloadImg.height; |
|
1733 |
document.getElementById('go_button').style.color = '#333'; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1734 |
document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/yes.png' ) ); ?>" alt="" />'; |
136 | 1735 |
}, |
1736 |
||
1737 |
getImageData : function() { |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1738 |
if ( jQuery('table.describe').hasClass('not-image') ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1739 |
return; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1740 |
|
136 | 1741 |
var t = addExtImage, src = document.forms[0].src.value; |
1742 |
||
1743 |
if ( ! src ) { |
|
1744 |
t.resetImageData(); |
|
1745 |
return false; |
|
1746 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1747 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1748 |
document.getElementById('status_img').innerHTML = '<img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" width="16" />'; |
136 | 1749 |
t.preloadImg = new Image(); |
1750 |
t.preloadImg.onload = t.updateImageData; |
|
1751 |
t.preloadImg.onerror = t.resetImageData; |
|
1752 |
t.preloadImg.src = src; |
|
1753 |
} |
|
1754 |
} |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1755 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1756 |
jQuery(document).ready( function($) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1757 |
$('.media-types input').click( function() { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1758 |
$('table.describe').toggleClass('not-image', $('#not-image').prop('checked') ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1759 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1760 |
}); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1761 |
|
136 | 1762 |
//]]> |
1763 |
</script> |
|
1764 |
||
1765 |
<div id="media-items"> |
|
1766 |
<div class="media-item media-blank"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1767 |
<?php echo apply_filters( 'type_url_form_media', wp_media_insert_url_form( $type ) ); ?> |
136 | 1768 |
</div> |
1769 |
</div> |
|
1770 |
</form> |
|
1771 |
<?php |
|
1772 |
} |
|
1773 |
||
1774 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1775 |
* Adds gallery form to upload iframe |
136 | 1776 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1777 |
* @since 2.5.0 |
136 | 1778 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1779 |
* @param array $errors |
136 | 1780 |
*/ |
1781 |
function media_upload_gallery_form($errors) { |
|
1782 |
global $redir_tab, $type; |
|
1783 |
||
1784 |
$redir_tab = 'gallery'; |
|
1785 |
media_upload_header(); |
|
1786 |
||
1787 |
$post_id = intval($_REQUEST['post_id']); |
|
1788 |
$form_action_url = admin_url("media-upload.php?type=$type&tab=gallery&post_id=$post_id"); |
|
1789 |
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1790 |
$form_class = 'media-upload-form validate'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1791 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1792 |
if ( get_user_setting('uploader') ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1793 |
$form_class .= ' html-uploader'; |
136 | 1794 |
?> |
1795 |
||
1796 |
<script type="text/javascript"> |
|
1797 |
<!-- |
|
1798 |
jQuery(function($){ |
|
1799 |
var preloaded = $(".media-item.preloaded"); |
|
1800 |
if ( preloaded.length > 0 ) { |
|
1801 |
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
|
1802 |
updateMediaForm(); |
|
1803 |
} |
|
1804 |
}); |
|
1805 |
--> |
|
1806 |
</script> |
|
1807 |
<div id="sort-buttons" class="hide-if-no-js"> |
|
1808 |
<span> |
|
1809 |
<?php _e('All Tabs:'); ?> |
|
1810 |
<a href="#" id="showall"><?php _e('Show'); ?></a> |
|
1811 |
<a href="#" id="hideall" style="display:none;"><?php _e('Hide'); ?></a> |
|
1812 |
</span> |
|
1813 |
<?php _e('Sort Order:'); ?> |
|
1814 |
<a href="#" id="asc"><?php _e('Ascending'); ?></a> | |
|
1815 |
<a href="#" id="desc"><?php _e('Descending'); ?></a> | |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1816 |
<a href="#" id="clear"><?php _ex('Clear', 'verb'); ?></a> |
136 | 1817 |
</div> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1818 |
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="gallery-form"> |
136 | 1819 |
<?php wp_nonce_field('media-form'); ?> |
1820 |
<?php //media_upload_form( $errors ); ?> |
|
1821 |
<table class="widefat" cellspacing="0"> |
|
1822 |
<thead><tr> |
|
1823 |
<th><?php _e('Media'); ?></th> |
|
1824 |
<th class="order-head"><?php _e('Order'); ?></th> |
|
1825 |
<th class="actions-head"><?php _e('Actions'); ?></th> |
|
1826 |
</tr></thead> |
|
1827 |
</table> |
|
1828 |
<div id="media-items"> |
|
1829 |
<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
|
1830 |
<?php echo get_media_items($post_id, $errors); ?> |
|
1831 |
</div> |
|
1832 |
||
1833 |
<p class="ml-submit"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1834 |
<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false, array( 'id' => 'save-all', 'style' => 'display: none;' ) ); ?> |
136 | 1835 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
1836 |
<input type="hidden" name="type" value="<?php echo esc_attr( $GLOBALS['type'] ); ?>" /> |
|
1837 |
<input type="hidden" name="tab" value="<?php echo esc_attr( $GLOBALS['tab'] ); ?>" /> |
|
1838 |
</p> |
|
1839 |
||
1840 |
<div id="gallery-settings" style="display:none;"> |
|
1841 |
<div class="title"><?php _e('Gallery Settings'); ?></div> |
|
1842 |
<table id="basic" class="describe"><tbody> |
|
1843 |
<tr> |
|
1844 |
<th scope="row" class="label"> |
|
1845 |
<label> |
|
1846 |
<span class="alignleft"><?php _e('Link thumbnails to:'); ?></span> |
|
1847 |
</label> |
|
1848 |
</th> |
|
1849 |
<td class="field"> |
|
1850 |
<input type="radio" name="linkto" id="linkto-file" value="file" /> |
|
1851 |
<label for="linkto-file" class="radio"><?php _e('Image File'); ?></label> |
|
1852 |
||
1853 |
<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" /> |
|
1854 |
<label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label> |
|
1855 |
</td> |
|
1856 |
</tr> |
|
1857 |
||
1858 |
<tr> |
|
1859 |
<th scope="row" class="label"> |
|
1860 |
<label> |
|
1861 |
<span class="alignleft"><?php _e('Order images by:'); ?></span> |
|
1862 |
</label> |
|
1863 |
</th> |
|
1864 |
<td class="field"> |
|
1865 |
<select id="orderby" name="orderby"> |
|
1866 |
<option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option> |
|
1867 |
<option value="title"><?php _e('Title'); ?></option> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1868 |
<option value="post_date"><?php _e('Date/Time'); ?></option> |
136 | 1869 |
<option value="rand"><?php _e('Random'); ?></option> |
1870 |
</select> |
|
1871 |
</td> |
|
1872 |
</tr> |
|
1873 |
||
1874 |
<tr> |
|
1875 |
<th scope="row" class="label"> |
|
1876 |
<label> |
|
1877 |
<span class="alignleft"><?php _e('Order:'); ?></span> |
|
1878 |
</label> |
|
1879 |
</th> |
|
1880 |
<td class="field"> |
|
1881 |
<input type="radio" checked="checked" name="order" id="order-asc" value="asc" /> |
|
1882 |
<label for="order-asc" class="radio"><?php _e('Ascending'); ?></label> |
|
1883 |
||
1884 |
<input type="radio" name="order" id="order-desc" value="desc" /> |
|
1885 |
<label for="order-desc" class="radio"><?php _e('Descending'); ?></label> |
|
1886 |
</td> |
|
1887 |
</tr> |
|
1888 |
||
1889 |
<tr> |
|
1890 |
<th scope="row" class="label"> |
|
1891 |
<label> |
|
1892 |
<span class="alignleft"><?php _e('Gallery columns:'); ?></span> |
|
1893 |
</label> |
|
1894 |
</th> |
|
1895 |
<td class="field"> |
|
1896 |
<select id="columns" name="columns"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1897 |
<option value="1">1</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1898 |
<option value="2">2</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1899 |
<option value="3" selected="selected">3</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1900 |
<option value="4">4</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1901 |
<option value="5">5</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1902 |
<option value="6">6</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1903 |
<option value="7">7</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1904 |
<option value="8">8</option> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1905 |
<option value="9">9</option> |
136 | 1906 |
</select> |
1907 |
</td> |
|
1908 |
</tr> |
|
1909 |
</tbody></table> |
|
1910 |
||
1911 |
<p class="ml-submit"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1912 |
<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php esc_attr_e( 'Insert gallery' ); ?>" /> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1913 |
<input type="button" class="button" style="display:none;" onMouseDown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php esc_attr_e( 'Update gallery settings' ); ?>" /> |
136 | 1914 |
</p> |
1915 |
</div> |
|
1916 |
</form> |
|
1917 |
<?php |
|
1918 |
} |
|
1919 |
||
1920 |
/** |
|
1921 |
* {@internal Missing Short Description}} |
|
1922 |
* |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1923 |
* @since 2.5.0 |
136 | 1924 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1925 |
* @param array $errors |
136 | 1926 |
*/ |
1927 |
function media_upload_library_form($errors) { |
|
1928 |
global $wpdb, $wp_query, $wp_locale, $type, $tab, $post_mime_types; |
|
1929 |
||
1930 |
media_upload_header(); |
|
1931 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
1932 |
$post_id = isset( $_REQUEST['post_id'] ) ? intval( $_REQUEST['post_id'] ) : 0; |
136 | 1933 |
|
1934 |
$form_action_url = admin_url("media-upload.php?type=$type&tab=library&post_id=$post_id"); |
|
1935 |
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1936 |
$form_class = 'media-upload-form validate'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1937 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1938 |
if ( get_user_setting('uploader') ) |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1939 |
$form_class .= ' html-uploader'; |
136 | 1940 |
|
1941 |
$_GET['paged'] = isset( $_GET['paged'] ) ? intval($_GET['paged']) : 0; |
|
1942 |
if ( $_GET['paged'] < 1 ) |
|
1943 |
$_GET['paged'] = 1; |
|
1944 |
$start = ( $_GET['paged'] - 1 ) * 10; |
|
1945 |
if ( $start < 1 ) |
|
1946 |
$start = 0; |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1947 |
add_filter( 'post_limits', create_function( '$a', "return 'LIMIT $start, 10';" ) ); |
136 | 1948 |
|
1949 |
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
|
1950 |
||
1951 |
?> |
|
1952 |
||
1953 |
<form id="filter" action="" method="get"> |
|
1954 |
<input type="hidden" name="type" value="<?php echo esc_attr( $type ); ?>" /> |
|
1955 |
<input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
1956 |
<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" /> |
|
1957 |
<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? esc_attr( $_GET['post_mime_type'] ) : ''; ?>" /> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1958 |
<input type="hidden" name="context" value="<?php echo isset( $_GET['context'] ) ? esc_attr( $_GET['context'] ) : ''; ?>" /> |
136 | 1959 |
|
1960 |
<p id="media-search" class="search-box"> |
|
1961 |
<label class="screen-reader-text" for="media-search-input"><?php _e('Search Media');?>:</label> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1962 |
<input type="search" id="media-search-input" name="s" value="<?php the_search_query(); ?>" /> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1963 |
<?php submit_button( __( 'Search Media' ), 'button', '', false ); ?> |
136 | 1964 |
</p> |
1965 |
||
1966 |
<ul class="subsubsub"> |
|
1967 |
<?php |
|
1968 |
$type_links = array(); |
|
1969 |
$_num_posts = (array) wp_count_attachments(); |
|
1970 |
$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); |
|
1971 |
foreach ( $matches as $_type => $reals ) |
|
1972 |
foreach ( $reals as $real ) |
|
1973 |
if ( isset($num_posts[$_type]) ) |
|
1974 |
$num_posts[$_type] += $_num_posts[$real]; |
|
1975 |
else |
|
1976 |
$num_posts[$_type] = $_num_posts[$real]; |
|
1977 |
// If available type specified by media button clicked, filter by that type |
|
1978 |
if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) { |
|
1979 |
$_GET['post_mime_type'] = $type; |
|
1980 |
list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query(); |
|
1981 |
} |
|
1982 |
if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' ) |
|
1983 |
$class = ' class="current"'; |
|
1984 |
else |
|
1985 |
$class = ''; |
|
1986 |
$type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>"; |
|
1987 |
foreach ( $post_mime_types as $mime_type => $label ) { |
|
1988 |
$class = ''; |
|
1989 |
||
1990 |
if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) ) |
|
1991 |
continue; |
|
1992 |
||
1993 |
if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) ) |
|
1994 |
$class = ' class="current"'; |
|
1995 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1996 |
$type_links[] = "<li><a href='" . esc_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>'; |
136 | 1997 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
1998 |
echo implode(' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>'; |
136 | 1999 |
unset($type_links); |
2000 |
?> |
|
2001 |
</ul> |
|
2002 |
||
2003 |
<div class="tablenav"> |
|
2004 |
||
2005 |
<?php |
|
2006 |
$page_links = paginate_links( array( |
|
2007 |
'base' => add_query_arg( 'paged', '%#%' ), |
|
2008 |
'format' => '', |
|
2009 |
'prev_text' => __('«'), |
|
2010 |
'next_text' => __('»'), |
|
2011 |
'total' => ceil($wp_query->found_posts / 10), |
|
2012 |
'current' => $_GET['paged'] |
|
2013 |
)); |
|
2014 |
||
2015 |
if ( $page_links ) |
|
2016 |
echo "<div class='tablenav-pages'>$page_links</div>"; |
|
2017 |
?> |
|
2018 |
||
2019 |
<div class="alignleft actions"> |
|
2020 |
<?php |
|
2021 |
||
2022 |
$arc_query = "SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'attachment' ORDER BY post_date DESC"; |
|
2023 |
||
2024 |
$arc_result = $wpdb->get_results( $arc_query ); |
|
2025 |
||
2026 |
$month_count = count($arc_result); |
|
2027 |
||
2028 |
if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) { ?> |
|
2029 |
<select name='m'> |
|
2030 |
<option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option> |
|
2031 |
<?php |
|
2032 |
foreach ($arc_result as $arc_row) { |
|
2033 |
if ( $arc_row->yyear == 0 ) |
|
2034 |
continue; |
|
2035 |
$arc_row->mmonth = zeroise( $arc_row->mmonth, 2 ); |
|
2036 |
||
2037 |
if ( isset($_GET['m']) && ( $arc_row->yyear . $arc_row->mmonth == $_GET['m'] ) ) |
|
2038 |
$default = ' selected="selected"'; |
|
2039 |
else |
|
2040 |
$default = ''; |
|
2041 |
||
2042 |
echo "<option$default value='" . esc_attr( $arc_row->yyear . $arc_row->mmonth ) . "'>"; |
|
2043 |
echo esc_html( $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear" ); |
|
2044 |
echo "</option>\n"; |
|
2045 |
} |
|
2046 |
?> |
|
2047 |
</select> |
|
2048 |
<?php } ?> |
|
2049 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2050 |
<?php submit_button( __( 'Filter »' ), 'button', 'post-query-submit', false ); ?> |
136 | 2051 |
|
2052 |
</div> |
|
2053 |
||
2054 |
<br class="clear" /> |
|
2055 |
</div> |
|
2056 |
</form> |
|
2057 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2058 |
<form enctype="multipart/form-data" method="post" action="<?php echo esc_attr($form_action_url); ?>" class="<?php echo $form_class; ?>" id="library-form"> |
136 | 2059 |
|
2060 |
<?php wp_nonce_field('media-form'); ?> |
|
2061 |
<?php //media_upload_form( $errors ); ?> |
|
2062 |
||
2063 |
<script type="text/javascript"> |
|
2064 |
<!-- |
|
2065 |
jQuery(function($){ |
|
2066 |
var preloaded = $(".media-item.preloaded"); |
|
2067 |
if ( preloaded.length > 0 ) { |
|
2068 |
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); |
|
2069 |
updateMediaForm(); |
|
2070 |
} |
|
2071 |
}); |
|
2072 |
--> |
|
2073 |
</script> |
|
2074 |
||
2075 |
<div id="media-items"> |
|
2076 |
<?php add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); ?> |
|
2077 |
<?php echo get_media_items(null, $errors); ?> |
|
2078 |
</div> |
|
2079 |
<p class="ml-submit"> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2080 |
<?php submit_button( __( 'Save all changes' ), 'button savebutton', 'save', false ); ?> |
136 | 2081 |
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> |
2082 |
</p> |
|
2083 |
</form> |
|
2084 |
<?php |
|
2085 |
} |
|
2086 |
||
2087 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2088 |
* Creates the form for external url |
136 | 2089 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2090 |
* @since 2.7.0 |
136 | 2091 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2092 |
* @param string $default_view |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2093 |
* @return string the form html |
136 | 2094 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2095 |
function wp_media_insert_url_form( $default_view = 'image' ) { |
136 | 2096 |
if ( !apply_filters( 'disable_captions', '' ) ) { |
2097 |
$caption = ' |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2098 |
<tr class="image-only"> |
136 | 2099 |
<th valign="top" scope="row" class="label"> |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2100 |
<label for="caption"><span class="alignleft">' . __('Image Caption') . '</span></label> |
136 | 2101 |
</th> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2102 |
<td class="field"><textarea id="caption" name="caption"></textarea></td> |
136 | 2103 |
</tr> |
2104 |
'; |
|
2105 |
} else { |
|
2106 |
$caption = ''; |
|
2107 |
} |
|
2108 |
||
2109 |
$default_align = get_option('image_default_align'); |
|
2110 |
if ( empty($default_align) ) |
|
2111 |
$default_align = 'none'; |
|
2112 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2113 |
if ( 'image' == $default_view ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2114 |
$view = 'image-only'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2115 |
$table_class = ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2116 |
} else { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2117 |
$view = $table_class = 'not-image'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2118 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2119 |
|
136 | 2120 |
return ' |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2121 |
<p class="media-types"><label><input type="radio" name="media_type" value="image" id="image-only"' . checked( 'image-only', $view, false ) . ' /> ' . __( 'Image' ) . '</label> <label><input type="radio" name="media_type" value="generic" id="not-image"' . checked( 'not-image', $view, false ) . ' /> ' . __( 'Audio, Video, or Other File' ) . '</label></p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2122 |
<table class="describe ' . $table_class . '"><tbody> |
136 | 2123 |
<tr> |
2124 |
<th valign="top" scope="row" class="label" style="width:130px;"> |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2125 |
<label for="src"><span class="alignleft">' . __('URL') . '</span></label> |
136 | 2126 |
<span class="alignright"><abbr id="status_img" title="required" class="required">*</abbr></span> |
2127 |
</th> |
|
2128 |
<td class="field"><input id="src" name="src" value="" type="text" aria-required="true" onblur="addExtImage.getImageData()" /></td> |
|
2129 |
</tr> |
|
2130 |
||
2131 |
<tr> |
|
2132 |
<th valign="top" scope="row" class="label"> |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2133 |
<label for="title"><span class="alignleft">' . __('Title') . '</span></label> |
136 | 2134 |
<span class="alignright"><abbr title="required" class="required">*</abbr></span> |
2135 |
</th> |
|
2136 |
<td class="field"><input id="title" name="title" value="" type="text" aria-required="true" /></td> |
|
2137 |
</tr> |
|
2138 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2139 |
<tr class="not-image"><td></td><td><p class="help">' . __('Link text, e.g. “Ransom Demands (PDF)”') . '</p></td></tr> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2140 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2141 |
<tr class="image-only"> |
136 | 2142 |
<th valign="top" scope="row" class="label"> |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2143 |
<label for="alt"><span class="alignleft">' . __('Alternative Text') . '</span></label> |
136 | 2144 |
</th> |
2145 |
<td class="field"><input id="alt" name="alt" value="" type="text" aria-required="true" /> |
|
2146 |
<p class="help">' . __('Alt text for the image, e.g. “The Mona Lisa”') . '</p></td> |
|
2147 |
</tr> |
|
2148 |
' . $caption . ' |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2149 |
<tr class="align image-only"> |
136 | 2150 |
<th valign="top" scope="row" class="label"><p><label for="align">' . __('Alignment') . '</label></p></th> |
2151 |
<td class="field"> |
|
2152 |
<input name="align" id="align-none" value="none" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'none' ? ' checked="checked"' : '').' /> |
|
2153 |
<label for="align-none" class="align image-align-none-label">' . __('None') . '</label> |
|
2154 |
<input name="align" id="align-left" value="left" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'left' ? ' checked="checked"' : '').' /> |
|
2155 |
<label for="align-left" class="align image-align-left-label">' . __('Left') . '</label> |
|
2156 |
<input name="align" id="align-center" value="center" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'center' ? ' checked="checked"' : '').' /> |
|
2157 |
<label for="align-center" class="align image-align-center-label">' . __('Center') . '</label> |
|
2158 |
<input name="align" id="align-right" value="right" onclick="addExtImage.align=\'align\'+this.value" type="radio"' . ($default_align == 'right' ? ' checked="checked"' : '').' /> |
|
2159 |
<label for="align-right" class="align image-align-right-label">' . __('Right') . '</label> |
|
2160 |
</td> |
|
2161 |
</tr> |
|
2162 |
||
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2163 |
<tr class="image-only"> |
136 | 2164 |
<th valign="top" scope="row" class="label"> |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2165 |
<label for="url"><span class="alignleft">' . __('Link Image To:') . '</span></label> |
136 | 2166 |
</th> |
2167 |
<td class="field"><input id="url" name="url" value="" type="text" /><br /> |
|
2168 |
||
2169 |
<button type="button" class="button" value="" onclick="document.forms[0].url.value=null">' . __('None') . '</button> |
|
2170 |
<button type="button" class="button" value="" onclick="document.forms[0].url.value=document.forms[0].src.value">' . __('Link to image') . '</button> |
|
2171 |
<p class="help">' . __('Enter a link URL or click above for presets.') . '</p></td> |
|
2172 |
</tr> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2173 |
<tr class="image-only"> |
136 | 2174 |
<td></td> |
2175 |
<td> |
|
2176 |
<input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" /> |
|
2177 |
</td> |
|
2178 |
</tr> |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2179 |
<tr class="not-image"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2180 |
<td></td> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2181 |
<td> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2182 |
' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . ' |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2183 |
</td> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2184 |
</tr> |
136 | 2185 |
</tbody></table> |
2186 |
'; |
|
2187 |
||
2188 |
} |
|
2189 |
||
2190 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2191 |
* Displays the multi-file uploader message. |
136 | 2192 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2193 |
* @since 2.6.0 |
136 | 2194 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2195 |
function media_upload_flash_bypass() { |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2196 |
$browser_uploader = admin_url( 'media-new.php?browser-uploader' ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2197 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2198 |
if ( $post = get_post() ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2199 |
$browser_uploader .= '&post_id=' . intval( $post->ID ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2200 |
elseif ( ! empty( $GLOBALS['post_ID'] ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2201 |
$browser_uploader .= '&post_id=' . intval( $GLOBALS['post_ID'] ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2202 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2203 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2204 |
<p class="upload-flash-bypass"> |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2205 |
<?php printf( __( 'You are using the multi-file uploader. Problems? Try the <a href="%1$s" target="%2$s">browser uploader</a> instead.' ), $browser_uploader, '_blank' ); ?> |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2206 |
</p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2207 |
<?php |
136 | 2208 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2209 |
add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
136 | 2210 |
|
2211 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2212 |
* Displays the browser's built-in uploader message. |
136 | 2213 |
* |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2214 |
* @since 2.6.0 |
136 | 2215 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2216 |
function media_upload_html_bypass() { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2217 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2218 |
<p class="upload-html-bypass hide-if-no-js"> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2219 |
<?php _e('You are using the browser’s built-in file uploader. The WordPress uploader includes multiple file selection and drag and drop capability. <a href="#">Switch to the multi-file uploader</a>.'); ?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2220 |
</p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2221 |
<?php |
136 | 2222 |
} |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2223 |
add_action('post-html-upload-ui', 'media_upload_html_bypass'); |
136 | 2224 |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2225 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2226 |
* Used to display a "After a file has been uploaded..." help message. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2227 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2228 |
* @since 3.3.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2229 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2230 |
function media_upload_text_after() {} |
136 | 2231 |
|
2232 |
/** |
|
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2233 |
* Displays the checkbox to scale images. |
136 | 2234 |
* |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2235 |
* @since 3.3.0 |
136 | 2236 |
*/ |
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2237 |
function media_upload_max_image_resize() { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2238 |
$checked = get_user_setting('upload_resize') ? ' checked="true"' : ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2239 |
$a = $end = ''; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2240 |
|
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2241 |
if ( current_user_can( 'manage_options' ) ) { |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2242 |
$a = '<a href="' . esc_url( admin_url( 'options-media.php' ) ) . '" target="_blank">'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2243 |
$end = '</a>'; |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2244 |
} |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2245 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2246 |
<p class="hide-if-no-js"><label> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2247 |
<input name="image_resize" type="checkbox" id="image_resize" value="true"<?php echo $checked; ?> /> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2248 |
<?php |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2249 |
/* translators: %1$s is link start tag, %2$s is link end tag, %3$d is width, %4$d is height*/ |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2250 |
printf( __( 'Scale images to match the large size selected in %1$simage options%2$s (%3$d × %4$d).' ), $a, $end, (int) get_option( 'large_size_w', '1024' ), (int) get_option( 'large_size_h', '1024' ) ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2251 |
?> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2252 |
</label></p> |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2253 |
<?php |
136 | 2254 |
} |
2255 |
||
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2256 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2257 |
* Displays the out of storage quota message in Multisite. |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2258 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2259 |
* @since 3.5.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2260 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2261 |
function multisite_over_quota_message() { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2262 |
echo '<p>' . sprintf( __( 'Sorry, you have used all of your storage quota of %s MB.' ), get_space_allowed() ) . '</p>'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2263 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2264 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2265 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2266 |
* Displays the image and editor in the post editor |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2267 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2268 |
* @since 3.5.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2269 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2270 |
function edit_form_image_editor() { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2271 |
$post = get_post(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2272 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2273 |
$open = isset( $_GET['image-editor'] ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2274 |
if ( $open ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2275 |
require_once ABSPATH . 'wp-admin/includes/image-edit.php'; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2276 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2277 |
$thumb_url = false; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2278 |
if ( $attachment_id = intval( $post->ID ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2279 |
$thumb_url = wp_get_attachment_image_src( $attachment_id, array( 900, 450 ), true ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2280 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2281 |
$filename = esc_html( basename( $post->guid ) ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2282 |
$title = esc_attr( $post->post_title ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2283 |
$alt_text = get_post_meta( $post->ID, '_wp_attachment_image_alt', true ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2284 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2285 |
$att_url = wp_get_attachment_url( $post->ID ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2286 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2287 |
if ( wp_attachment_is_image( $post->ID ) ) : |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2288 |
$image_edit_button = ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2289 |
if ( wp_image_editor_supports( array( 'mime_type' => $post->post_mime_type ) ) ) { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2290 |
$nonce = wp_create_nonce( "image_editor-$post->ID" ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2291 |
$image_edit_button = "<input type='button' id='imgedit-open-btn-$post->ID' onclick='imageEdit.open( $post->ID, \"$nonce\" )' class='button' value='" . esc_attr__( 'Edit Image' ) . "' /> <span class='spinner'></span>"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2292 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2293 |
?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2294 |
<div class="wp_attachment_holder"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2295 |
<div class="imgedit-response" id="imgedit-response-<?php echo $attachment_id; ?>"></div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2296 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2297 |
<div<?php if ( $open ) echo ' style="display:none"'; ?> class="wp_attachment_image" id="media-head-<?php echo $attachment_id; ?>"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2298 |
<p id="thumbnail-head-<?php echo $attachment_id; ?>"><img class="thumbnail" src="<?php echo set_url_scheme( $thumb_url[0] ); ?>" style="max-width:100%" alt="" /></p> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2299 |
<p><?php echo $image_edit_button; ?></p> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2300 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2301 |
<div<?php if ( ! $open ) echo ' style="display:none"'; ?> class="image-editor" id="image-editor-<?php echo $attachment_id; ?>"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2302 |
<?php if ( $open ) wp_image_editor( $attachment_id ); ?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2303 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2304 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2305 |
<?php endif; ?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2306 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2307 |
<div class="wp_attachment_details"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2308 |
<p> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2309 |
<label for="attachment_caption"><strong><?php _e( 'Caption' ); ?></strong></label><br /> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2310 |
<textarea class="widefat" name="excerpt" id="attachment_caption"><?php echo $post->post_excerpt; ?></textarea> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2311 |
</p> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2312 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2313 |
<?php if ( 'image' === substr( $post->post_mime_type, 0, 5 ) ) : ?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2314 |
<p> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2315 |
<label for="attachment_alt"><strong><?php _e( 'Alternative Text' ); ?></strong></label><br /> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2316 |
<input type="text" class="widefat" name="_wp_attachment_image_alt" id="attachment_alt" value="<?php echo esc_attr( $alt_text ); ?>" /> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2317 |
</p> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2318 |
<?php endif; ?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2319 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2320 |
<?php |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2321 |
$quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2322 |
$editor_args = array( |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2323 |
'textarea_name' => 'content', |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2324 |
'textarea_rows' => 5, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2325 |
'media_buttons' => false, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2326 |
'tinymce' => false, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2327 |
'quicktags' => $quicktags_settings, |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2328 |
); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2329 |
?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2330 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2331 |
<label for="content"><strong><?php _e( 'Description' ); ?></strong></label> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2332 |
<?php wp_editor( $post->post_content, 'attachment_content', $editor_args ); ?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2333 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2334 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2335 |
<?php |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2336 |
$extras = get_compat_media_markup( $post->ID ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2337 |
echo $extras['item']; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2338 |
echo '<input type="hidden" id="image-edit-context" value="edit-attachment" />' . "\n"; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2339 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2340 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2341 |
/** |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2342 |
* Displays non-editable attachment metadata in the publish metabox |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2343 |
* |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2344 |
* @since 3.5.0 |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2345 |
*/ |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2346 |
function attachment_submitbox_metadata() { |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2347 |
$post = get_post(); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2348 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2349 |
$filename = esc_html( basename( $post->guid ) ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2350 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2351 |
$media_dims = ''; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2352 |
$meta = wp_get_attachment_metadata( $post->ID ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2353 |
if ( is_array( $meta ) && array_key_exists( 'width', $meta ) && array_key_exists( 'height', $meta ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2354 |
$media_dims .= "<span id='media-dims-$post->ID'>{$meta['width']} × {$meta['height']}</span> "; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2355 |
$media_dims = apply_filters( 'media_meta', $media_dims, $post ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2356 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2357 |
$att_url = wp_get_attachment_url( $post->ID ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2358 |
?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2359 |
<div class="misc-pub-section"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2360 |
<label for="attachment_url"><?php _e( 'File URL:' ); ?></label> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2361 |
<input type="text" class="widefat urlfield" readonly="readonly" name="attachment_url" value="<?php echo esc_attr($att_url); ?>" /> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2362 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2363 |
<div class="misc-pub-section"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2364 |
<?php _e( 'File name:' ); ?> <strong><?php echo $filename; ?></strong> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2365 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2366 |
<div class="misc-pub-section"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2367 |
<?php _e( 'File type:' ); ?> <strong><?php |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2368 |
if ( preg_match( '/^.*?\.(\w+)$/', get_attached_file( $post->ID ), $matches ) ) |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2369 |
echo esc_html( strtoupper( $matches[1] ) ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2370 |
else |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2371 |
echo strtoupper( str_replace( 'image/', '', $post->post_mime_type ) ); |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2372 |
?></strong> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2373 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2374 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2375 |
<?php if ( $media_dims ) : ?> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2376 |
<div class="misc-pub-section"> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2377 |
<?php _e( 'Dimensions:' ); ?> <strong><?php echo $media_dims; ?></strong> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2378 |
</div> |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2379 |
<?php |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2380 |
endif; |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2381 |
} |
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2382 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2383 |
add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2384 |
add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2385 |
add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2386 |
add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
136 | 2387 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2388 |
add_action( 'media_upload_image', 'wp_media_upload_handler' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2389 |
add_action( 'media_upload_audio', 'wp_media_upload_handler' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2390 |
add_action( 'media_upload_video', 'wp_media_upload_handler' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2391 |
add_action( 'media_upload_file', 'wp_media_upload_handler' ); |
136 | 2392 |
|
194
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2393 |
add_filter( 'media_upload_gallery', 'media_upload_gallery' ); |
32102edaa81b
MAJ wordpress et ajout de plugin
Anthony Ly <anthonyly.com@gmail.com>
parents:
136
diff
changeset
|
2394 |
add_filter( 'media_upload_library', 'media_upload_library' ); |
204
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2395 |
|
09a1c134465b
man wordpress + plugins order post + slideshow
Anthony Ly <anthonyly.com@gmail.com>
parents:
194
diff
changeset
|
2396 |
add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' ); |