~katiekitty/+junk/wordpress-byet

« back to all changes in this revision

Viewing changes to wp-admin/press-this.php

  • Committer: kserver
  • Date: 2010-05-15 01:16:36 UTC
  • Revision ID: kserver@kserver-desktop-20100515011636-mnr1j7t637suptdq
Wordpress 2.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
function press_it() {
43
43
        // define some basic variables
44
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'] = '';
 
45
        $quick['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : null;
 
46
        $quick['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : null;
 
47
        $quick['post_title'] = ( trim($_POST['title']) != '' ) ? $_POST['title'] : '  ';
 
48
        $quick['post_content'] = isset($_POST['post_content']) ? $_POST['post_content'] : ''; 
49
49
 
50
50
        // insert the post with nothing in it, to get an ID
51
51
        $post_ID = wp_insert_post($quick, true);
52
 
        $content = isset($_REQUEST['content']) ? $_REQUEST['content'] : '';
 
52
        if ( is_wp_error($post_ID) )
 
53
                wp_die($post_ID);
 
54
 
 
55
        $content = isset($_POST['content']) ? $_POST['content'] : '';
53
56
 
54
57
        $upload = false;
55
 
        if( !empty($_REQUEST['photo_src']) && current_user_can('upload_files') )
56
 
                foreach( (array) $_REQUEST['photo_src'] as $key => $image)
 
58
        if( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
 
59
                foreach( (array) $_POST['photo_src'] as $key => $image) {
57
60
                        // 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] : '';
 
61
                        if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
 
62
                                $desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
60
63
                                $upload = media_sideload_image($image, $post_ID, $desc);
61
64
 
62
65
                                // 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);
 
66
                                if( !is_wp_error($upload) )
 
67
                                        $content = preg_replace('/<img ([^>]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
64
68
                        }
65
 
 
 
69
                }
 
70
        }
66
71
        // set the post_content and status
67
 
        $quick['post_status'] = isset($_REQUEST['publish']) ? 'publish' : 'draft';
 
72
        $quick['post_status'] = isset($_POST['publish']) ? 'publish' : 'draft';
68
73
        $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
74
        // error handling for media_sideload
74
 
        } elseif ( is_wp_error($upload)) {
 
75
        if ( is_wp_error($upload) ) {
 
76
                wp_delete_post($post_ID);
75
77
                wp_die($upload);
76
 
                wp_delete_post($post_ID);
77
78
        } else {
78
79
                $quick['ID'] = $post_ID;
79
80
                wp_update_post($quick);
91
92
}
92
93
 
93
94
// Set Variables
94
 
$title = isset($_GET['t']) ? esc_html(aposfix(stripslashes($_GET['t']))) : '';
95
 
$selection = isset($_GET['s']) ? trim( aposfix( stripslashes($_GET['s']) ) ) : '';
 
95
$title = isset( $_GET['t'] ) ? trim( strip_tags( aposfix( stripslashes( $_GET['t'] ) ) ) ) : '';
 
96
$selection = isset( $_GET['s'] ) ? trim( htmlspecialchars( html_entity_decode( aposfix( stripslashes( $_GET['s'] ) ) ) ) ) : '';
96
97
if ( ! empty($selection) ) {
97
98
        $selection = preg_replace('/(\r?\n|\r)/', '</p><p>', $selection);
98
99
        $selection = '<p>'.str_replace('<p></p>', '', $selection).'</p>';
99
100
}
 
101
 
100
102
$url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
101
103
$image = isset($_GET['i']) ? $_GET['i'] : '';
102
104
 
103
105
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;
 
106
        switch ($_REQUEST['ajax']) {
 
107
                case 'video': ?>
 
108
                        <script type="text/javascript" charset="utf-8">
 
109
                        /* <![CDATA[ */
 
110
                                jQuery('.select').click(function() {
 
111
                                        append_editor(jQuery('#embed-code').val());
 
112
                                        jQuery('#extra-fields').hide();
 
113
                                        jQuery('#extra-fields').html('');
 
114
                                });
 
115
                                jQuery('.close').click(function() {
 
116
                                        jQuery('#extra-fields').hide();
 
117
                                        jQuery('#extra-fields').html('');
 
118
                                });
 
119
                        /* ]]> */
 
120
                        </script>
 
121
                        <div class="postbox">
 
122
                                <h2><label for="embed-code"><?php _e('Embed Code') ?></label></h2>
 
123
                                <div class="inside">
 
124
                                        <textarea name="embed-code" id="embed-code" rows="8" cols="40"><?php echo wp_htmledit_pre( $selection ); ?></textarea>
 
125
                                        <p id="options"><a href="#" class="select button"><?php _e('Insert Video'); ?></a> <a href="#" class="close button"><?php _e('Cancel'); ?></a></p>
 
126
                                </div>
 
127
                        </div>
 
128
                        <?php break;
 
129
 
 
130
                case 'photo_thickbox': ?>
 
131
                        <script type="text/javascript" charset="utf-8">
 
132
                                /* <![CDATA[ */
 
133
                                jQuery('.cancel').click(function() {
 
134
                                        tb_remove();
 
135
                                });
 
136
                                jQuery('.select').click(function() {
 
137
                                        image_selector();
 
138
                                });
 
139
                                /* ]]> */
 
140
                        </script>
 
141
                        <h3 class="tb"><label for="this_photo_description"><?php _e('Description') ?></label></h3>
 
142
                        <div class="titlediv">
 
143
                                <div class="titlewrap">
 
144
                                        <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
 
145
                                </div>
 
146
                        </div>
 
147
 
 
148
                        <p class="centered">
 
149
                                <input type="hidden" name="this_photo" value="<?php echo esc_attr($image); ?>" id="this_photo" />
 
150
                                <a href="#" class="select">
 
151
                                        <img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr(__('Click to insert.')); ?>" title="<?php echo esc_attr(__('Click to insert.')); ?>" />
 
152
                                </a>
 
153
                        </p>
 
154
 
 
155
                        <p id="options"><a href="#" class="select button"><?php _e('Insert Image'); ?></a> <a href="#" class="cancel button"><?php _e('Cancel'); ?></a></p>
 
156
                        <?php break;
 
157
 
 
158
                case 'photo_thickbox_url': ?>
 
159
                        <script type="text/javascript" charset="utf-8">
 
160
                                /* <![CDATA[ */
 
161
                                jQuery('.cancel').click(function() {
 
162
                                        tb_remove();
 
163
                                });
 
164
 
 
165
                                jQuery('.select').click(function() {
 
166
                                        image_selector();
 
167
                                });
 
168
                                /* ]]> */
 
169
                        </script>
 
170
                        <h3 class="tb"><label for="this_photo"><?php _e('URL') ?></label></h3>
 
171
                        <div class="titlediv">
 
172
                                <div class="titlewrap">
 
173
                                        <input id="this_photo" name="this_photo" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" />
 
174
                                </div>
 
175
                        </div>
 
176
                        <h3 class="tb"><label for="photo_description"><?php _e('Description') ?></label></h3>
 
177
                        <div id="titlediv">
 
178
                                <div class="titlewrap">
 
179
                                        <input id="this_photo_description" name="photo_description" class="tbtitle text" onkeypress="if(event.keyCode==13) image_selector();" value="<?php echo esc_attr($title);?>"/>
 
180
                                </div>
 
181
                        </div>
 
182
 
 
183
                        <p id="options"><a href="#" class="select"><?php _e('Insert Image'); ?></a> | <a href="#" class="cancel"><?php _e('Cancel'); ?></a></p>
 
184
                        <?php break;
177
185
        case 'photo_images':
178
186
                /**
179
187
                 * Retrieve all image URLs from given URI.
186
194
                 * @return string
187
195
                 */
188
196
                function get_images_from_uri($uri) {
 
197
                        $uri = preg_replace('/\/#.+?$/','', $uri);
189
198
                        if( preg_match('/\.(jpg|jpe|jpeg|png|gif)$/', $uri) && !strpos($uri,'blogger.com') )
190
 
                                return "'".$uri."'";
 
199
                                return "'" . esc_attr( html_entity_decode($uri) ) . "'";
191
200
                        $content = wp_remote_fopen($uri);
192
201
                        if ( false === $content )
193
202
                                return '';
194
203
                        $host = parse_url($uri);
195
 
                        $pattern = '/<img ([^>]*)src=(\"|\')([^<>]+?\.(png|jpeg|jpg|jpe|gif))[^<>\'\"]*(\2)([^>\/]*)\/*>/is';
 
204
                        $pattern = '/<img ([^>]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/i';
 
205
                        $content = str_replace(array("\n","\t","\r"), '', $content);
196
206
                        preg_match_all($pattern, $content, $matches);
197
207
                        if ( empty($matches[0]) )
198
208
                                return '';
205
215
                                                $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
206
216
                                        else
207
217
                                                $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
208
 
                                $sources[] = esc_url($src);
 
218
                                $sources[] = esc_attr($src);
209
219
                        }
210
220
                        return "'" . implode("','", $sources) . "'";
211
221
                }
212
 
                $url = urldecode($url);
213
 
                $url = str_replace(' ', '%20', $url);
 
222
                $url = wp_kses(urldecode($url), null);
214
223
                echo 'new Array('.get_images_from_uri($url).')';
215
 
 
216
224
                break;
217
225
 
218
226
        case 'photo_js': ?>
219
227
                // gather images and load some default JS
220
228
                var last = null
221
229
                var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
 
230
                if(photostorage == false) {
 
231
                var my_src = eval(
 
232
                        jQuery.ajax({
 
233
                                type: "GET",
 
234
                                url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
 
235
                                cache : false,
 
236
                                async : false,
 
237
                                data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
 
238
                                dataType : "script"
 
239
                        }).responseText
 
240
                );
 
241
                if(my_src.length == 0) {
222
242
                        var my_src = eval(
223
243
                                jQuery.ajax({
224
 
                                        type: "GET",
225
 
                                        url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
 
244
                                        type: "GET",
 
245
                                        url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
226
246
                                        cache : false,
227
247
                                        async : false,
228
 
                                        data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
 
248
                                        data: "ajax=photo_images&u=<?php echo urlencode($url); ?>",
229
249
                                        dataType : "script"
230
250
                                }).responseText
231
251
                        );
232
252
                        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
 
                                }
 
253
                                strtoappend = '<?php _e('Unable to retrieve images or no images on page.'); ?>';
246
254
                        }
247
 
 
 
255
                }
 
256
                }
248
257
                for (i = 0; i < my_src.length; i++) {
249
258
                        img = new Image();
250
259
                        img.src = my_src[i];
289
298
                        desc = jQuery('#this_photo_description').val();
290
299
                        src = jQuery('#this_photo').val();
291
300
                        pick(src, desc);
292
 
                        jQuery('#extra_fields').hide();
293
 
                        jQuery('#extra_fields').html('');
 
301
                        jQuery('#extra-fields').hide();
 
302
                        jQuery('#extra-fields').html('');
294
303
                        return false;
295
304
                }
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
 
                                        });
 
305
                        jQuery('#extra-fields').html('<div class="postbox"><h2>Add Photos <small id="photo_directions">(<?php _e("click images to select") ?>)</small></h2><ul class="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>');
306
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
307
                <?php break;
313
308
}
314
309
die;
323
318
 
324
319
<?php
325
320
        add_thickbox();
326
 
        wp_enqueue_style('press-this');
327
 
        wp_enqueue_style('press-this-ie');
 
321
        wp_enqueue_style( 'press-this' );
 
322
        wp_enqueue_style( 'press-this-ie');
328
323
        wp_enqueue_style( 'colors' );
329
324
        wp_enqueue_script( 'post' );
330
 
        wp_enqueue_script('editor');
 
325
        wp_enqueue_script( 'editor' );
331
326
?>
332
327
<script type="text/javascript">
333
328
//<![CDATA[
334
329
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
330
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'); ?>';
 
331
var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', pagenow = 'press-this';
 
332
var photostorage = false;
337
333
//]]>
338
334
</script>
339
335
 
342
338
        do_action('admin_print_scripts');
343
339
        do_action('admin_head');
344
340
 
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
 
        }
 
341
        if ( user_can_richedit() )
 
342
                wp_tiny_mce( true, array( 'height' => '370' ) );
349
343
?>
350
344
        <script type="text/javascript">
351
345
        function insert_plain_editor(text) {
373
367
        }
374
368
 
375
369
        function show(tab_name) {
376
 
                jQuery('#extra_fields').html('');
377
 
                jQuery('#extra_fields').show();
 
370
                jQuery('#extra-fields').html('');
378
371
                switch(tab_name) {
379
372
                        case 'video' :
380
 
                                jQuery('#extra_fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
 
373
                                jQuery('#extra-fields').load('<?php echo esc_url($_SERVER['PHP_SELF']); ?>', { ajax: 'video', s: '<?php echo esc_attr($selection); ?>'}, function() {
381
374
                                        <?php
382
375
                                        $content = '';
383
376
                                        if ( preg_match("/youtube\.com\/watch/i", $url) ) {
399
392
                                        ?>
400
393
                                        jQuery('#embed-code').prepend('<?php echo htmlentities($content); ?>');
401
394
                                });
 
395
                                jQuery('#extra-fields').show();
402
396
                                return false;
403
397
                                break;
404
398
                        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
 
                                });
 
399
                                function setup_photo_actions() {
 
400
                                        jQuery('.close').click(function() {
 
401
                                                jQuery('#extra-fields').hide();
 
402
                                                jQuery('#extra-fields').html('');
 
403
                                        });
 
404
                                        jQuery('.refresh').click(function() {
 
405
                                                photostorage = false;
 
406
                                                show('photo');
 
407
                                        });
 
408
                                        jQuery('#photo-add-url').attr('href', '?ajax=photo_thickbox_url&height=200&width=500');
 
409
                                        tb_init('#extra-fields .thickbox');
 
410
                                        jQuery('#waiting').hide();
 
411
                                        jQuery('#extra-fields').show();
 
412
                                }
 
413
                                jQuery('#extra-fields').before('<div id="waiting"><img src="images/wpspin_light.gif" alt="" /> <?php echo esc_js( __( 'Loading...' ) ); ?></div>');
 
414
                                
 
415
                                if(photostorage == false) {
 
416
                                        jQuery.ajax({
 
417
                                                type: "GET",
 
418
                                                cache : false,
 
419
                                                url: "<?php echo esc_url($_SERVER['PHP_SELF']); ?>",
 
420
                                                data: "ajax=photo_js&u=<?php echo urlencode($url)?>",
 
421
                                                dataType : "script",
 
422
                                                success : function(data) {
 
423
                                                        eval(data);
 
424
                                                        photostorage = jQuery('#extra-fields').html();
 
425
                                                        setup_photo_actions();
 
426
                                                }
 
427
                                        });
 
428
                                } else {
 
429
                                        jQuery('#extra-fields').html(photostorage);
 
430
                                        setup_photo_actions();
 
431
                                }
416
432
                                return false;
417
433
                                break;
418
434
                }
419
435
        }
420
 
        jQuery(document).ready(function() {
 
436
        jQuery(document).ready(function($) {
421
437
                //resize screen
422
 
                window.resizeTo(720,570);
 
438
                window.resizeTo(720,540);
423
439
                // set button actions
424
440
        jQuery('#photo_button').click(function() { show('photo'); return false; });
425
441
                jQuery('#video_button').click(function() { show('video'); return false; });
433
449
                <?php } ?>
434
450
                jQuery('#title').unbind();
435
451
                jQuery('#publish, #save').click(function() { jQuery('#saving').css('display', 'inline'); });
 
452
 
 
453
                $('#tagsdiv-post_tag, #categorydiv').children('h3, .handlediv').click(function(){
 
454
                        $(this).siblings('.inside').toggle();
 
455
                });
436
456
        });
437
457
</script>
438
458
</head>
439
 
<body class="press-this">
 
459
<body class="press-this wp-admin">
440
460
<div id="wphead"></div>
441
461
<form action="press-this.php?action=post" method="post">
442
462
<div id="poststuff" class="metabox-holder">
443
463
        <div id="side-info-column">
444
464
                <div class="sleeve">
445
 
                        <h1 id="viewsite"><a class="button" href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
 
465
                        <h1 id="viewsite"><a href="<?php echo get_option('home'); ?>/" target="_blank"><?php bloginfo('name'); ?> &rsaquo; <?php _e('Press This') ?></a></span></h1>
446
466
 
447
467
                        <?php wp_nonce_field('press-this') ?>
448
468
                        <input type="hidden" name="post_type" id="post_type" value="text"/>
454
474
                        <div class="photolist"></div>
455
475
 
456
476
                        <div id="submitdiv" class="stuffbox">
 
477
                                <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
 
478
                                        <br/>
 
479
                                </div>
457
480
                                <h3><?php _e('Publish') ?></h3>
458
481
                                <div class="inside">
459
482
                                        <p>
469
492
                        </div>
470
493
 
471
494
                        <div id="categorydiv" class="stuffbox">
 
495
                                <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
 
496
                                        <br/>
 
497
                                </div>
472
498
                                <h3><?php _e('Categories') ?></h3>
473
499
                                <div class="inside">
474
500
 
475
501
                                        <div id="categories-all" class="tabs-panel">
 
502
 
476
503
                                                <ul id="categorychecklist" class="list:category categorychecklist form-no-clear">
477
504
                                                        <?php wp_category_checklist($post_ID, false) ?>
478
505
                                                </ul>
492
519
                        </div>
493
520
 
494
521
                        <div id="tagsdiv-post_tag" class="stuffbox" >
 
522
                                <div class="handlediv" title="<?php _e( 'Click to toggle' ); ?>">
 
523
                                        <br/>
 
524
                                </div>
495
525
                                <h3><span><?php _e('Post Tags'); ?></span></h3>
496
526
                                <div class="inside">
497
527
                                        <div class="tagsdiv" id="post_tag">
498
528
                                                <p class="jaxtag">
499
529
                                                        <label class="screen-reader-text" for="newtag"><?php _e('Post Tags'); ?></label>
500
530
                                                        <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'); ?>" />
 
531
                                                        <div class="ajaxtag">
 
532
                                                                <input type="text" name="newtag[post_tag]" class="newtag form-input-tip" size="16" autocomplete="off" value="" />
503
533
                                                                <input type="button" class="button tagadd" value="<?php esc_attr_e('Add'); ?>" tabindex="3" />
504
 
                                                        </span>
 
534
                                                        </div>
505
535
                                                </p>
506
536
                                                <div class="tagchecklist"></div>
507
537
                                        </div>
510
540
                        </div>
511
541
                </div>
512
542
        </div>
513
 
 
514
543
        <div class="posting">
515
544
                <?php if ( isset($posted) && intval($posted) ) { $post_ID = intval($posted); ?>
516
545
                <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>
522
551
                        </div>
523
552
                </div>
524
553
 
525
 
                <div id="extra_fields" style="display: none"></div>
 
554
                <div id="extra-fields" style="display: none"></div>
526
555
 
527
556
                <div class="postdivrich">
528
 
                        <ul id="actions">
 
557
                        <ul id="actions" class="actions">
529
558
 
530
559
                                <li id="photo_button">
531
560
                                        Add: <?php if ( current_user_can('upload_files') ) { ?><a title="<?php _e('Insert an Image'); ?>" href="#">
547
576
                        </ul>
548
577
                        <div id="quicktags"></div>
549
578
                        <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>
 
579
                                <textarea name="content" id="content" style="width:100%;" class="theEditor" rows="15"><?php
 
580
                                        if ( $selection )
 
581
                                                echo wp_richedit_pre($selection);
 
582
                                        if ( $url ) {
 
583
                                                echo '<p>';
 
584
                                                if ( $selection )
 
585
                                                        _e('via ');
 
586
                                                printf( "<a href='%s'>%s</a>.</p>", esc_url( $url ), esc_html( $title ) );
 
587
                                        }
 
588
                                ?></textarea>
554
589
                        </div>
555
590
                </div>
556
591
        </div>