1 | <?php
|
---|
2 | /**
|
---|
3 | * Press This Display and Handler.
|
---|
4 | *
|
---|
5 | * @package WordPress
|
---|
6 | * @subpackage Press_This
|
---|
7 | */
|
---|
8 |
|
---|
9 | /** WordPress Administration Bootstrap */
|
---|
10 | require_once('admin.php');
|
---|
11 | header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
---|
12 |
|
---|
13 | if ( ! current_user_can('edit_posts') )
|
---|
14 | wp_die( __( 'Cheatin’ uh?' ) );
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Convert characters.
|
---|
18 | *
|
---|
19 | * @package WordPress
|
---|
20 | * @subpackage Press_This
|
---|
21 | * @since 2.6.0
|
---|
22 | *
|
---|
23 | * @param string $text
|
---|
24 | * @return string
|
---|
25 | */
|
---|
26 | function aposfix($text) {
|
---|
27 | $translation_table[chr(34)] = '"';
|
---|
28 | $translation_table[chr(38)] = '&';
|
---|
29 | $translation_table[chr(39)] = ''';
|
---|
30 | return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($text, $translation_table));
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Press It form handler.
|
---|
35 | *
|
---|
36 | * @package WordPress
|
---|
37 | * @subpackage Press_This
|
---|
38 | * @since 2.6.0
|
---|
39 | *
|
---|
40 | * @return int Post ID
|
---|
41 | */
|
---|
42 | function press_it() {
|
---|
43 | // define some basic variables
|
---|
44 | $quick['post_status'] = 'draft'; // set as draft first
|
---|
45 | $quick['post_category'] = isset($_REQUEST['post_category']) ? $_REQUEST['post_category'] : null;
|
---|
46 | $quick['tax_input'] = isset($_REQUEST['tax_input']) ? $_REQUEST['tax_input'] : '';
|
---|
47 | $quick['post_title'] = isset($_REQUEST['title']) ? $_REQUEST['title'] : '';
|
---|
48 | $quick['post_content'] = '';
|
---|
49 |
|
---|
50 | // insert the post with nothing in it, to get an ID
|
---|
51 | $post_ID = wp_insert_post($quick, true);
|
---|
52 | $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
|
---|
53 |
|
---|
54 | $upload = false;
|
---|
55 | if( !empty($_REQUEST['photo_src']) && current_user_can('upload_files') )
|
---|
56 | foreach( (array) $_REQUEST['photo_src'] as $key => $image)
|
---|
57 | // see if files exist in content - we don't want to upload non-used selected files.
|
---|
58 | if( strpos($_REQUEST['content'], $image) !== false ) {
|
---|
59 | $desc = isset($_REQUEST['photo_description'][$key]) ? $_REQUEST['photo_description'][$key] : '';
|
---|
60 | $upload = media_sideload_image($image, $post_ID, $desc);
|
---|
61 |
|
---|
62 | // Replace the POSTED content <img> with correct uploaded ones. Regex contains fix for Magic Quotes
|
---|
63 | if( !is_wp_error($upload) ) $content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote($image, '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
|
---|
64 | }
|
---|
65 |
|
---|
66 | // set the post_content and status
|
---|
67 | $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
|
---|
68 | $quick['post_content'] = $content;
|
---|
69 | // error handling for $post
|
---|
70 | if ( is_wp_error($post_ID)) {
|
---|
71 | wp_die($id);
|
---|
72 | wp_delete_post($post_ID);
|
---|
73 | // error handling for media_sideload
|
---|
74 | } elseif ( is_wp_error($upload)) {
|
---|
75 | wp_die($upload);
|
---|
76 | wp_delete_post($post_ID);
|
---|
77 | } else {
|
---|
78 | $quick['ID'] = $post_ID;
|
---|
79 | wp_update_post($quick);
|
---|
80 | }
|
---|
81 | return $post_ID;
|
---|
82 | }
|
---|
83 |
|
---|
84 | // For submitted posts.
|
---|
85 | if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
|
---|
86 | check_admin_referer('press-this');
|
---|
87 | $post_ID = press_it();
|
---|
88 | $posted = $post_ID;
|
---|
89 | } else {
|
---|
90 | $post_ID = 0;
|
---|
91 | }
|
---|
92 |
|
---|
93 | // Set Variables
|
---|
94 | $title = isset($_GET['t']) ? esc_html(aposfix(stripslashes($_GET['t']))) : '';
|
---|
95 | $selection = isset($_GET['s']) ? trim( aposfix( stripslashes($_GET['s']) ) ) : '';
|
---|
96 | if ( ! empty($selection) ) {
|
---|
97 | $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
|
---|
98 | $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
|
---|
99 | }
|
---|
100 | $url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
|
---|
101 | $image = isset($_GET['i']) ? $_GET['i'] : '';
|
---|
102 |
|
---|
103 | if ( !empty($_REQUEST['ajax']) ) {
|
---|
104 | switch ($_REQUEST['ajax']) {
|
---|
105 | case 'video': ?>
|
---|
106 | <script type="text/javascript" charset="utf-8">
|
---|
107 | jQuery('.select').click(function() {
|
---|
108 | append_editor(jQuery('#embed-code').val());
|
---|
109 | jQuery('#extra_fields').hide();
|
---|
110 | jQuery('#extra_fields').html('');
|
---|
111 | });
|
---|
112 | jQuery('.close').click(function() {
|
---|
113 | jQuery('#extra_fields').hide();
|
---|
114 | jQuery('#extra_fields').html('');
|
---|
115 | });
|
---|
116 | </script>
|
---|
117 | <div class="postbox">
|
---|
118 | <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
|
---|
119 | <div class="inside">
|
---|
120 | <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo format_to_edit($selection, true); ?></textarea>
|
---|
121 | <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
|
---|
122 | </div>
|
---|
123 | </div>
|
---|
124 | <?php break;
|
---|
125 |
|
---|
126 | case 'photo_thickbox': ?>
|
---|
127 | <script type="text/javascript" charset="utf-8">
|
---|
128 | jQuery('.cancel').click(function() {
|
---|
129 | tb_remove();
|
---|
130 | });
|
---|
131 | jQuery('.select').click(function() {
|
---|
132 | image_selector();
|
---|
133 | });
|
---|
134 | </script>
|
---|
135 | <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
|
---|
136 | <div class="titlediv">
|
---|
137 | <div class="titlewrap">
|
---|
138 | <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
|
---|
139 | </div>
|
---|
140 | </div>
|
---|
141 |
|
---|
142 | <p class="centered"><input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="this_photo" />
|
---|
143 | <a href="#" class="select"><img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" /></a></p>
|
---|
144 |
|
---|
145 | <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
|
---|
146 |
|
---|
147 |
|
---|
148 | <?php break;
|
---|
149 |
|
---|
150 | case 'photo_thickbox_url': ?>
|
---|
151 | <script type="text/javascript" charset="utf-8">
|
---|
152 | jQuery('.cancel').click(function() {
|
---|
153 | tb_remove();
|
---|
154 | });
|
---|
155 |
|
---|
156 | jQuery('.select').click(function() {
|
---|
157 | image_selector();
|
---|
158 | });
|
---|
159 | </script>
|
---|
160 | <h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
|
---|
161 | <div class="titlediv">
|
---|
162 | <div class="titlewrap">
|
---|
163 | <input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
|
---|
164 | </div>
|
---|
165 | </div>
|
---|
166 |
|
---|
167 |
|
---|
168 | <h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
|
---|
169 | <div id="titlediv">
|
---|
170 | <div class="titlewrap">
|
---|
171 | <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
|
---|
172 | </div>
|
---|
173 | </div>
|
---|
174 |
|
---|
175 | <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
|
---|
176 | <?php break;
|
---|
177 | case 'photo_images':
|
---|
178 | /**
|
---|
179 | * Retrieve all image URLs from given URI.
|
---|
180 | *
|
---|
181 | * @package WordPress
|
---|
182 | * @subpackage Press_This
|
---|
183 | * @since 2.6.0
|
---|
184 | *
|
---|
185 | * @param string $uri
|
---|
186 | * @return string
|
---|
187 | */
|
---|
188 | function get_images_from_uri($uri) {
|
---|
189 | if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
|
---|
190 | return "'".$uri."'";
|
---|
191 | $content = wp_remote_fopen($uri);
|
---|
192 | if ( false === $content )
|
---|
193 | return '';
|
---|
194 | $host = parse_url($uri);
|
---|
195 | $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
|
---|
196 | preg_match_all($pattern, $content, $matches);
|
---|
197 | if ( empty($matches[0]) )
|
---|
198 | return '';
|
---|
199 | $sources = array();
|
---|
200 | foreach ($matches[3] as $src) {
|
---|
201 | // if no http in url
|
---|
202 | if(strpos($src, 'http') === false)
|
---|
203 | // if it doesn't have a relative uri
|
---|
204 | if( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
|
---|
205 | $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
|
---|
206 | else
|
---|
207 | $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
|
---|
208 | $sources[] = esc_url($src);
|
---|
209 | }
|
---|
210 | return "'" . implode("','", $sources) . "'";
|
---|
211 | }
|
---|
212 | $url = urldecode($url);
|
---|
213 | $url = str_replace(' ', '%20', $url);
|
---|
214 | echo 'new Array('.get_images_from_uri($url).')';
|
---|
215 |
|
---|
216 | break;
|
---|
217 |
|
---|
218 | case 'photo_js': ?>
|
---|
219 | // gather images and load some default JS
|
---|
220 | var last = null
|
---|
221 | var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
|
---|
222 | var my_src = eval(
|
---|
223 | jQuery.ajax({
|
---|
224 | type: "GET",
|
---|
225 | url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
|
---|
226 | cache : false,
|
---|
227 | async : false,
|
---|
228 | data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
|
---|
229 | dataType : "script"
|
---|
230 | }).responseText
|
---|
231 | );
|
---|
232 | if(my_src.length == 0) {
|
---|
233 | var my_src = eval(
|
---|
234 | jQuery.ajax({
|
---|
235 | type: "GET",
|
---|
236 | url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
|
---|
237 | cache : false,
|
---|
238 | async : false,
|
---|
239 | data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
|
---|
240 | dataType : "script"
|
---|
241 | }).responseText
|
---|
242 | );
|
---|
243 | if(my_src.length == 0) {
|
---|
244 | strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
|
---|
245 | }
|
---|
246 | }
|
---|
247 |
|
---|
248 | for (i = 0; i < my_src.length; i++) {
|
---|
249 | img = new Image();
|
---|
250 | img.src = my_src[i];
|
---|
251 | img_attr = 'id="img' + i + '"';
|
---|
252 | skip = false;
|
---|
253 |
|
---|
254 | maybeappend = '<a href="?ajax=photo_thickbox&i=' + encodeURIComponent(img.src) + '&u=<?php echo urlencode($url); ?>&height=400&width=500" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>';
|
---|
255 |
|
---|
256 | if (img.width && img.height) {
|
---|
257 | if (img.width >= 30 && img.height >= 30) {
|
---|
258 | aspect = img.width / img.height;
|
---|
259 | scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
|
---|
260 |
|
---|
261 | w = img.width;
|
---|
262 | h = img.height;
|
---|
263 |
|
---|
264 | if (scale < 1) {
|
---|
265 | w = parseInt(img.width * scale);
|
---|
266 | h = parseInt(img.height * scale);
|
---|
267 | }
|
---|
268 | img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
|
---|
269 | strtoappend += maybeappend;
|
---|
270 | }
|
---|
271 | } else {
|
---|
272 | strtoappend += maybeappend;
|
---|
273 | }
|
---|
274 | }
|
---|
275 |
|
---|
276 | function pick(img, desc) {
|
---|
277 | if (img) {
|
---|
278 | if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
|
---|
279 | if(length == 0) length = 1;
|
---|
280 | jQuery('.photolist').append('<input name="photo_src[' + length + ']" value="' + img +'" type="hidden"/>');
|
---|
281 | jQuery('.photolist').append('<input name="photo_description[' + length + ']" value="' + desc +'" type="hidden"/>');
|
---|
282 | insert_editor( "\n\n" + encodeURI('<p style="text-align: center;"><a href="<?php echo $url; ?>"><img src="' + img +'" alt="' + desc + '" /></a></p>'));
|
---|
283 | }
|
---|
284 | return false;
|
---|
285 | }
|
---|
286 |
|
---|
287 | function image_selector() {
|
---|
288 | tb_remove();
|
---|
289 | desc = jQuery('#this_photo_description').val();
|
---|
290 | src = jQuery('#this_photo').val();
|
---|
291 | pick(src, desc);
|
---|
292 | jQuery('#extra_fields').hide();
|
---|
293 | jQuery('#extra_fields').html('');
|
---|
294 | return false;
|
---|
295 | }
|
---|
296 |
|
---|
297 | jQuery(document).ready(function() {
|
---|
298 | jQuery('#extra_fields').html('<div class="postbox"><h2>Photo <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul id="actions"><li><a href="#" id="photo_add_url" class="thickbox button"><?php _e("Add from URL") ?> +</a></li></ul><div class="inside"><div class="titlewrap"><div id="img_container"></div></div><p id="options"><a href="#" class="close button"><?php _e('Cancel'); ?></a><a href="#" class="refresh button"><?php _e('Refresh'); ?></a></p></div>');
|
---|
299 | jQuery('.close').click(function() {
|
---|
300 | jQuery('#extra_fields').hide();
|
---|
301 | jQuery('#extra_fields').html('');
|
---|
302 | });
|
---|
303 | jQuery('.refresh').click(function() {
|
---|
304 | show('photo');
|
---|
305 | });
|
---|
306 | jQuery('#img_container').html(strtoappend);
|
---|
307 | jQuery('#photo_add_url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
|
---|
308 | tb_init('#extra_fields .thickbox');
|
---|
309 |
|
---|
310 |
|
---|
311 | });
|
---|
312 | <?php break;
|
---|
313 | }
|
---|
314 | die;
|
---|
315 | }
|
---|
316 |
|
---|
317 | ?>
|
---|
318 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
---|
319 | <html xmlns="http://www.w3.org/1999/xhtml" <?php do_action('admin_xml_ns'); ?> <?php language_attributes(); ?>>
|
---|
320 | <head>
|
---|
321 | <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
|
---|
322 | <title><?php _e('Press This') ?></title>
|
---|
323 |
|
---|
324 | <?php
|
---|
325 | add_thickbox();
|
---|
326 | wp_enqueue_style('press-this');
|
---|
327 | wp_enqueue_style('press-this-ie');
|
---|
328 | wp_enqueue_style( 'colors' );
|
---|
329 | wp_enqueue_script( 'post' );
|
---|
330 | wp_enqueue_script('editor');
|
---|
331 | ?>
|
---|
332 | <script type="text/javascript">
|
---|
333 | //<![CDATA[
|
---|
334 | 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();}}};
|
---|
335 | 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() ?>'};
|
---|
336 | var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
|
---|
337 | //]]>
|
---|
338 | </script>
|
---|
339 |
|
---|
340 | <?php
|
---|
341 | do_action('admin_print_styles');
|
---|
342 | do_action('admin_print_scripts');
|
---|
343 | do_action('admin_head');
|
---|
344 |
|
---|
345 | if ( user_can_richedit() ) {
|
---|
346 | add_filter( 'teeny_mce_before_init', create_function( '$a', '$a["height"] = "400"; $a["onpageload"] = ""; $a["mode"] = "textareas"; $a["editor_selector"] = "mceEditor"; return $a;' ) );
|
---|
347 | wp_tiny_mce( true );
|
---|
348 | }
|
---|
349 | ?>
|
---|
350 | <script type="text/javascript">
|
---|
351 | function insert_plain_editor(text) {
|
---|
352 | edCanvas = document.getElementById('content');
|
---|
353 | edInsertContent(edCanvas, text);
|
---|
354 | }
|
---|
355 | function set_editor(text) {
|
---|
356 | if ( '' == text || '<p></p>' == text ) text = '<p><br /></p>';
|
---|
357 | if ( tinyMCE.activeEditor ) tinyMCE.execCommand('mceSetContent', false, text);
|
---|
358 | }
|
---|
359 | function insert_editor(text) {
|
---|
360 | if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
|
---|
361 | tinyMCE.execCommand('mceInsertContent', false, '<p>' + decodeURI(tinymce.DOM.decode(text)) + '</p>', {format : 'raw'});
|
---|
362 | } else {
|
---|
363 | insert_plain_editor(decodeURI(text));
|
---|
364 | }
|
---|
365 | }
|
---|
366 | function append_editor(text) {
|
---|
367 | if ( '' != text && tinyMCE.activeEditor && ! tinyMCE.activeEditor.isHidden()) {
|
---|
368 | tinyMCE.execCommand('mceSetContent', false, tinyMCE.activeEditor.getContent({format : 'raw'}) + '<p>' + text + '</p>');
|
---|
369 | tinyMCE.execCommand('mceCleanup');
|
---|
370 | } else {
|
---|
371 | insert_plain_editor(text);
|
---|
372 | }
|
---|
373 | }
|
---|
374 |
|
---|
375 | function show(tab_name) {
|
---|
376 | jQuery('#extra_fields').html('');
|
---|
377 | jQuery('#extra_fields').show();
|
---|
378 | switch(tab_name) {
|
---|
379 | case 'video' :
|
---|
380 | jQuery('#extra_fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
|
---|
381 | <?php
|
---|
382 | $content = '';
|
---|
383 | if ( preg_match("/youtube\.com\/watch/i", $url) ) {
|
---|
384 | list($domain, $video_id) = split("v=", $url);
|
---|
385 | $video_id = esc_attr($video_id);
|
---|
386 | $content = '<object width="425" height="350"><param name="movie" value="http://www.youtube.com/v/' . $video_id . '"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/' . $video_id . '" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350"></embed></object>';
|
---|
387 |
|
---|
388 | } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) {
|
---|
389 | list($domain, $video_id) = split(".com/", $url);
|
---|
390 | $video_id = esc_attr($video_id);
|
---|
391 | $content = '<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /> <embed src="http://www.vimeo.com/moogaloop.swf?clip_id=' . $video_id . '&server=www.vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object>';
|
---|
392 |
|
---|
393 | if ( trim($selection) == '' )
|
---|
394 | $selection = '<p><a href="http://www.vimeo.com/' . $video_id . '?pg=embed&sec=' . $video_id . '">' . $title . '</a> on <a href="http://vimeo.com?pg=embed&sec=' . $video_id . '">Vimeo</a></p>';
|
---|
395 |
|
---|
396 | } elseif ( strpos( $selection, '<object' ) !== false ) {
|
---|
397 | $content = $selection;
|
---|
398 | }
|
---|
399 | ?>
|
---|
400 | jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
|
---|
401 | });
|
---|
402 | return false;
|
---|
403 | break;
|
---|
404 | case 'photo' :
|
---|
405 | jQuery('#extra_fields').before('<p id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></p>');
|
---|
406 | jQuery.ajax({
|
---|
407 | type: "GET",
|
---|
408 | cache : false,
|
---|
409 | url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
|
---|
410 | data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
|
---|
411 | dataType : "script",
|
---|
412 | success : function() {
|
---|
413 | jQuery('#waiting').remove();
|
---|
414 | }
|
---|
415 | });
|
---|
416 | return false;
|
---|
417 | break;
|
---|
418 | }
|
---|
419 | }
|
---|
420 | jQuery(document).ready(function() {
|
---|
421 | //resize screen
|
---|
422 | window.resizeTo(720,570);
|
---|
423 | // set button actions
|
---|
424 | jQuery('#photo_button').click(function() { show('photo'); return false; });
|
---|
425 | jQuery('#video_button').click(function() { show('video'); return false; });
|
---|
426 | // auto select
|
---|
427 | <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?>
|
---|
428 | show('video');
|
---|
429 | <?php } elseif ( preg_match("/vimeo\.com\/[0-9]+/i", $url) ) { ?>
|
---|
430 | show('video');
|
---|
431 | <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?>
|
---|
432 | show('photo');
|
---|
433 | <?php } ?>
|
---|
434 | jQuery('#title').unbind();
|
---|
435 | jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
|
---|
436 | });
|
---|
437 | </script>
|
---|
438 | </head>
|
---|
439 | <body class="press-this">
|
---|
440 | <div id="wphead"></div>
|
---|
441 | <form action="press-this.php?action=post" method="post">
|
---|
442 | <div id="poststuff" class="metabox-holder">
|
---|
443 | <div id="side-info-column">
|
---|
444 | <div class="sleeve">
|
---|
445 | <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> › <?php _e('Press This') ?></a></span></h1>
|
---|
446 |
|
---|
447 | <?php wp_nonce_field('press-this') ?>
|
---|
448 | <input type="hidden" name="post_type" id="post_type" value="text"/>
|
---|
449 | <input type="hidden" name="autosave" id="autosave" />
|
---|
450 | <input type="hidden" id="original_post_status" name="original_post_status" value="draft" />
|
---|
451 | <input type="hidden" id="prev_status" name="prev_status" value="draft" />
|
---|
452 |
|
---|
453 | <!-- This div holds the photo metadata -->
|
---|
454 | <div class="photolist"></div>
|
---|
455 |
|
---|
456 | <div id="submitdiv" class="stuffbox">
|
---|
457 | <h3><?php _e('Publish') ?></h3>
|
---|
458 | <div class="inside">
|
---|
459 | <p>
|
---|
460 | <input class="button" type="submit" name="draft" value="<?php esc_attr_e('Save Draft') ?>" id="save" />
|
---|
461 | <?php if ( current_user_can('publish_posts') ) { ?>
|
---|
462 | <input class="button-primary" type="submit" name="publish" value="<?php esc_attr_e('Publish') ?>" id="publish" />
|
---|
463 | <?php } else { ?>
|
---|
464 | <br /><br /><input class="button-primary" type="submit" name="review" value="<?php esc_attr_e('Submit for Review') ?>" id="review" />
|
---|
465 | <?php } ?>
|
---|
466 | <img src="images/wpspin_light.gif" alt="" id="saving" style="display:none;" />
|
---|
467 | </p>
|
---|
468 | </div>
|
---|
469 | </div>
|
---|
470 |
|
---|
471 | <div id="categorydiv" class="stuffbox">
|
---|
472 | <h3><?php _e('Categories') ?></h3>
|
---|
473 | <div class="inside">
|
---|
474 |
|
---|
475 | <div id="categories-all" class="tabs-panel">
|
---|
476 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
|
---|
477 | <?php wp_category_checklist($post_ID, false) ?>
|
---|
478 | </ul>
|
---|
479 | </div>
|
---|
480 |
|
---|
481 | <div id="category-adder" class="wp-hidden-children">
|
---|
482 | <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php _e( '+ Add New Category' ); ?></a>
|
---|
483 | <p id="category-add" class="wp-hidden-child">
|
---|
484 | <label class="screen-reader-text" for="newcat"><?php _e( 'Add New Category' ); ?></label><input type="text" name="newcat" id="newcat" class="form-required form-input-tip" value="<?php esc_attr_e( 'New category name' ); ?>" tabindex="3" aria-required="true"/>
|
---|
485 | <label class="screen-reader-text" for="newcat_parent"><?php _e('Parent category'); ?>:</label><?php wp_dropdown_categories( array( 'hide_empty' => 0, 'name' => 'newcat_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('Parent category'), 'tab_index' => 3 ) ); ?>
|
---|
486 | <input type="button" id="category-add-sumbit" class="add:categorychecklist:category-add button" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
|
---|
487 | <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
|
---|
488 | <span id="category-ajax-response"></span>
|
---|
489 | </p>
|
---|
490 | </div>
|
---|
491 | </div>
|
---|
492 | </div>
|
---|
493 |
|
---|
494 | <div id="tagsdiv-post_tag" class="stuffbox" >
|
---|
495 | <h3><span><?php _e('Post Tags'); ?></span></h3>
|
---|
496 | <div class="inside">
|
---|
497 | <div class="tagsdiv" id="post_tag">
|
---|
498 | <p class="jaxtag">
|
---|
499 | <label class="screen-reader-text" for="newtag"><?php _e('Post Tags'); ?></label>
|
---|
500 | <input type="hidden" name="tax_input[post_tag]" class="the-tags" id="tax-input[post_tag]" value="" />
|
---|
501 | <span class="ajaxtag" style="display:none;">
|
---|
502 | <input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="<?php esc_attr_e('Add new tag'); ?>" />
|
---|
503 | <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
|
---|
504 | </span>
|
---|
505 | </p>
|
---|
506 | <div class="tagchecklist"></div>
|
---|
507 | </div>
|
---|
508 | <p class="tagcloud-link"><a href="#titlediv" class="tagcloud-link" id="link-post_tag"><?php _e('Choose from the most used tags in Post Tags'); ?></a></p>
|
---|
509 | </div>
|
---|
510 | </div>
|
---|
511 | </div>
|
---|
512 | </div>
|
---|
513 |
|
---|
514 | <div class="posting">
|
---|
515 | <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
|
---|
516 | <div id="message" class="updated fade"><p><strong><?php _e('Your post has been saved.'); ?></strong> <a onclick="window.opener.location.replace(this.href); window.close();" href="<?php echo get_permalink( $post_ID); ?>"><?php _e('View post'); ?></a> | <a href="<?php echo get_edit_post_link( $post_ID ); ?>" onclick="window.opener.location.replace(this.href); window.close();"><?php _e('Edit post'); ?></a> | <a href="#" onclick="window.close();"><?php _e('Close Window'); ?></a></p></div>
|
---|
517 | <?php } ?>
|
---|
518 |
|
---|
519 | <div id="titlediv">
|
---|
520 | <div class="titlewrap">
|
---|
521 | <input name="title" id="title" class="text" value="<?php echo esc_attr($title);?>"/>
|
---|
522 | </div>
|
---|
523 | </div>
|
---|
524 |
|
---|
525 | <div id="extra_fields" style="display: none"></div>
|
---|
526 |
|
---|
527 | <div class="postdivrich">
|
---|
528 | <ul id="actions">
|
---|
529 |
|
---|
530 | <li id="photo_button">
|
---|
531 | Add: <?php if ( current_user_can('upload_files') ) { ?><a title="<?php _e('Insert an Image'); ?>" href="#">
|
---|
532 | <img alt="<?php _e('Insert an Image'); ?>" src="images/media-button-image.gif"/></a>
|
---|
533 | <?php } ?>
|
---|
534 | </li>
|
---|
535 | <li id="video_button">
|
---|
536 | <a title="<?php _e('Embed a Video'); ?>" href="#"><img alt="<?php _e('Embed a Video'); ?>" src="images/media-button-video.gif"/></a>
|
---|
537 | </li>
|
---|
538 | <?php if( user_can_richedit() ) { ?>
|
---|
539 | <li id="switcher">
|
---|
540 | <?php wp_print_scripts( 'quicktags' ); ?>
|
---|
541 | <?php add_filter('the_editor_content', 'wp_richedit_pre'); ?>
|
---|
542 | <a id="edButtonHTML" onclick="switchEditors.go('content', 'html');"><?php _e('HTML'); ?></a>
|
---|
543 | <a id="edButtonPreview" class="active" onclick="switchEditors.go('content', 'tinymce');"><?php _e('Visual'); ?></a>
|
---|
544 | <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('content')" /></div>
|
---|
545 | </li>
|
---|
546 | <?php } ?>
|
---|
547 | </ul>
|
---|
548 | <div id="quicktags"></div>
|
---|
549 | <div class="editor-container">
|
---|
550 | <textarea name="content" id="content" style="width:100%;" class="mceEditor" rows="15">
|
---|
551 | <?php if ($selection) echo wp_richedit_pre(htmlspecialchars_decode($selection)); ?>
|
---|
552 | <?php if ($url) { echo '<p>'; if($selection) _e('via '); echo "<a href='$url'>$title</a>."; echo '</p>'; } ?>
|
---|
553 | </textarea>
|
---|
554 | </div>
|
---|
555 | </div>
|
---|
556 | </div>
|
---|
557 | </div>
|
---|
558 | </form>
|
---|
559 | <?php do_action('admin_print_footer_scripts'); ?>
|
---|
560 | <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
|
---|
561 | </body>
|
---|
562 | </html>
|
---|