equal
deleted
inserted
replaced
12 |
12 |
13 if ( ! defined( 'WP_ADMIN' ) ) { |
13 if ( ! defined( 'WP_ADMIN' ) ) { |
14 define( 'WP_ADMIN', true ); |
14 define( 'WP_ADMIN', true ); |
15 } |
15 } |
16 |
16 |
17 if ( defined( 'ABSPATH' ) ) { |
17 /** Load WordPress Bootstrap */ |
18 require_once ABSPATH . 'wp-load.php'; |
18 require_once dirname( __DIR__ ) . '/wp-load.php'; |
19 } else { |
|
20 require_once dirname( __DIR__ ) . '/wp-load.php'; |
|
21 } |
|
22 |
19 |
23 require_once ABSPATH . 'wp-admin/admin.php'; |
20 require_once ABSPATH . 'wp-admin/admin.php'; |
24 |
21 |
25 header( 'Content-Type: text/plain; charset=' . get_option( 'blog_charset' ) ); |
22 header( 'Content-Type: text/plain; charset=' . get_option( 'blog_charset' ) ); |
26 |
23 |
72 } else { |
69 } else { |
73 echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>'; |
70 echo '<span class="edit-attachment">' . _x( 'Success', 'media item' ) . '</span>'; |
74 } |
71 } |
75 ?> |
72 ?> |
76 <span class="media-item-copy-container copy-to-clipboard-container edit-attachment"> |
73 <span class="media-item-copy-container copy-to-clipboard-container edit-attachment"> |
77 <button type="button" class="button button-small copy-attachment-url" data-clipboard-text="<?php echo $file_url; ?>"><?php _e( 'Copy URL to clipboard' ); ?></button> |
74 <button type="button" class="button button-small copy-attachment-url" |
|
75 data-clipboard-text="<?php echo esc_url( $file_url ); ?>" |
|
76 ><?php _e( 'Copy URL to clipboard' ); ?></button> |
78 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> |
77 <span class="success hidden" aria-hidden="true"><?php _e( 'Copied!' ); ?></span> |
79 </span> |
78 </span> |
80 </div> |
79 </div> |
81 </div> |
80 </div> |
82 </div> |
81 </div> |
111 } |
110 } |
112 } |
111 } |
113 |
112 |
114 $id = media_handle_upload( 'async-upload', $post_id ); |
113 $id = media_handle_upload( 'async-upload', $post_id ); |
115 if ( is_wp_error( $id ) ) { |
114 if ( is_wp_error( $id ) ) { |
116 $message = sprintf( |
115 $button_unique_id = uniqid( 'dismiss-' ); |
|
116 $message = sprintf( |
117 '%s <strong>%s</strong><br />%s', |
117 '%s <strong>%s</strong><br />%s', |
118 sprintf( |
118 sprintf( |
119 '<button type="button" class="dismiss button-link" onclick="jQuery(this).parents(\'div.media-item\').slideUp(200, function(){jQuery(this).remove();});">%s</button>', |
119 '<button type="button" id="%s" class="dismiss button-link">%s</button>', |
|
120 esc_attr( $button_unique_id ), |
120 __( 'Dismiss' ) |
121 __( 'Dismiss' ) |
121 ), |
122 ), |
122 sprintf( |
123 sprintf( |
123 /* translators: %s: Name of the file that failed to upload. */ |
124 /* translators: %s: Name of the file that failed to upload. */ |
124 __( '“%s” has failed to upload.' ), |
125 __( '“%s” has failed to upload.' ), |
131 array( |
132 array( |
132 'additional_classes' => array( 'error-div', 'error' ), |
133 'additional_classes' => array( 'error-div', 'error' ), |
133 'paragraph_wrap' => false, |
134 'paragraph_wrap' => false, |
134 ) |
135 ) |
135 ); |
136 ); |
|
137 echo "<script>jQuery( 'button#{$button_unique_id}' ).on( 'click', function() {jQuery(this).parents('div.media-item').slideUp(200, function(){jQuery(this).remove();})});</script>\n"; |
136 exit; |
138 exit; |
137 } |
139 } |
138 |
140 |
139 if ( $_REQUEST['short'] ) { |
141 if ( $_REQUEST['short'] ) { |
140 // Short form response - attachment ID only. |
142 // Short form response - attachment ID only. |