| 68 | | function category_div() { |
| 69 | | ?> |
| 70 | | <div id="categories"> |
| 71 | | <div class="submitbox" id="submitpost"> |
| 72 | | <div id="previewview"> <h2><?php _e('Categories') ?></h2></div> |
| 73 | | <div class="inside"> |
| 74 | | <div id="categories-all"> |
| 75 | | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
| 76 | | <?php wp_category_checklist() ?> |
| 77 | | </ul> |
| | 68 | function category_div() { |
| | 69 | ?> |
| | 70 | <div id="categories"> |
| | 71 | <div class="submitbox" id="submitpost"> |
| | 72 | <div id="previewview"> <h2><?php _e('Categories') ?></h2></div> |
| | 73 | <div class="inside"> |
| | 74 | <div id="categories-all"> |
| | 75 | <ul id="categorychecklist" class="list:category categorychecklist form-no-clear"> |
| | 76 | <?php wp_category_checklist() ?> |
| | 77 | </ul> |
| | 78 | </div> |
| 79 | | </div> |
| 80 | | <p class="submit"> |
| 81 | | <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> |
| 82 | | <img src="images/loading.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> |
| 83 | | </p> |
| 84 | | </div> |
| 85 | | <?php |
| | 80 | <p class="submit"> |
| | 81 | <input type="submit" value="<?php _e('Publish') ?>" onclick="document.getElementById('photo_saving').style.display = '';"/> |
| | 82 | <img src="images/loading.gif" alt="" id="photo_saving" style="width:16px; height:16px; vertical-align:-4px; display:none;"/> |
| | 83 | </p> |
| | 84 | </div> |
| | 85 | <?php |
| | 86 | } |
| | 87 | |
| | 88 | // For posts submitted |
| | 89 | if ( 'post' == $_REQUEST['action'] ) { |
| | 90 | check_admin_referer('press-this'); $post_ID = press_it(); ?> |
| | 91 | <script>if(confirm("<?php _e('Your post is saved. Do you want to view the post?') ?>")){window.opener.location.replace("<?php echo get_permalink($post_ID);?>");}window.close();</script> |
| | 92 | <?php die; |
| 96 | | $pattern = '/<img[^>]+src=[\'"]([^\'" >]+?)[\'" >]/is'; |
| 97 | | preg_match_all($pattern, $content, $matches); |
| 98 | | if ( empty($matches[1]) ) return ''; |
| 99 | | |
| 100 | | $sources = array(); |
| | 107 | if($_REQUEST['ajax'] == 'photo_images') { |
| | 108 | function get_images_from_uri($uri) { |
| | 109 | $content = wp_remote_fopen($uri); |
| | 110 | $uri = str_replace(basename($uri), '', $uri); |
| | 111 | $host = parse_url($uri); |
| | 112 | |
| | 113 | if ( false === $content ) return ''; |
| 102 | | foreach ($matches[1] as $src) { |
| 103 | | if ( false !== strpos($src, '&') ) |
| 104 | | continue; |
| 105 | | $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); |
| | 115 | $pattern = '/<img[^>]+src=[\'"]([^\'" >]+?)[\'" >]/is'; |
| | 116 | preg_match_all($pattern, $content, $matches); |
| | 117 | if ( empty($matches[1]) ) return ''; |
| | 118 | |
| | 119 | $sources = array(); |
| | 120 | |
| | 121 | foreach ($matches[1] as $src) { |
| | 122 | if ( false !== strpos($src, '&') ) continue; |
| | 123 | if(strpos($src, 'http') === false) { |
| | 124 | if(strpos($src, '../') === false && strpos($src, './') === false) { |
| | 125 | $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src); |
| | 126 | } else { |
| | 127 | $src = 'http://'.str_replace('//','/', $host['host'].'/'.$host['path'].'/'.$src); |
| | 128 | } |
| | 129 | } |
| | 130 | $sources[] = $src; |
| | 131 | } |
| | 132 | return "'" . implode("','", $sources) . "'"; |
| | 133 | } |
| | 139 | if($_REQUEST['ajax'] == 'photo_js') { ?> |
| | 140 | |
| | 141 | var last = null |
| | 142 | function pick(img) { |
| | 143 | |
| | 144 | if (last) last.style.backgroundColor = '#f4f4f4'; |
| | 145 | if (img) { |
| | 146 | jQuery('#photo_src').val(img.src); |
| | 147 | img.style.backgroundColor = '#44f'; |
| | 148 | } |
| | 149 | last = img; |
| | 150 | |
| | 151 | /*noel's code to select more than one image.... |
| | 152 | jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + |
| | 153 | '<div class="titlewrap">' + |
| | 154 | '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + |
| | 155 | '</div>');*/ |
| | 156 | |
| | 157 | return false; |
| | 158 | } |
| | 159 | |
| | 160 | jQuery('.remove').click(function() { |
| | 161 | jQuery(this).remove; |
| | 162 | }); |
| | 163 | |
| | 164 | |
| | 165 | var my_src, img, img_tag, aspect, w, h, skip, i, strtoappend = ""; |
| | 166 | |
| | 167 | var my_src =eval( |
| | 168 | jQuery.ajax({ |
| | 169 | type: "GET", |
| | 170 | url: "<?php echo $_SERVER['PHP_SELF']; ?>", |
| | 171 | cache : false, |
| | 172 | async : false, |
| | 173 | data: "ajax=photo_images&url=<?php echo $url?>", |
| | 174 | dataType : "script" |
| | 175 | }).responseText); |
| | 176 | |
| | 177 | for (i = 0; i < my_src.length; i++) { |
| | 178 | img = new Image(); |
| | 179 | img.src = my_src[i]; |
| | 180 | img_attr = 'id="img' + i + '" onclick="pick(this);"'; |
| | 181 | skip = false; |
| | 182 | |
| | 183 | if (img.width && img.height) { |
| | 184 | if (img.width * img.height < 2500) skip = true; |
| | 185 | aspect = img.width / img.height; |
| | 186 | if (aspect > 1) { // Image is wide |
| | 187 | scale = 75 / img.width; |
| | 188 | } else { // Image is tall or square |
| | 189 | scale = 75 / img.height; |
| | 190 | } |
| | 191 | if (scale < 1) { |
| | 192 | w = parseInt(img.width * scale); |
| | 193 | h = parseInt(img.height * scale); |
| | 194 | } else { |
| | 195 | w = img.width; |
| | 196 | h = img.height; |
| | 197 | } |
| | 198 | img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; |
| | 199 | } |
| | 200 | |
| | 201 | if (!skip) strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; |
| | 202 | |
| | 203 | } |
| | 204 | |
| | 205 | jQuery('#img_container').html(strtoappend); |
| | 206 | |
| | 207 | tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox |
| | 208 | |
| | 209 | |
| | 210 | <?php die; } |
| | 211 | |
| | 212 | if($_REQUEST['ajax'] == 'photo') { ?> |
| | 213 | <h2><?php _e('Photo URL') ?></h2> |
| | 214 | <div class="titlewrap"> |
| | 215 | <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> |
| | 216 | </div> |
| | 217 | |
| | 218 | <div class="photolist"></div> |
| | 219 | |
| | 220 | <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?> |
| | 221 | <div class="titlewrap"> |
| | 222 | <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/> |
| | 223 | </div> |
| | 224 | |
| | 225 | <small><?php _e('Click images to select:') ?></small> |
| | 226 | <div class="titlewrap"> |
| | 227 | <div id="img_container">Loading Images...</div> |
| | 228 | </div> |
| | 229 | <?php die; } |
| | 230 | |
| 184 | | jQuery('#tagadd').click( tag_flush_to_text ); |
| 185 | | jQuery('#newtag').focus(function() { |
| 186 | | if ( this.value == postL10n.addTag ) |
| 187 | | jQuery(this).val( '' ).removeClass( 'form-input-tip' ); |
| 188 | | }); |
| 189 | | jQuery('#newtag').blur(function() { |
| 190 | | if ( this.value == '' ) |
| 191 | | jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); |
| 192 | | }); |
| | 303 | jQuery('#tagadd').click( tag_flush_to_text ); |
| | 304 | jQuery('#newtag').focus(function() { |
| | 305 | if ( this.value == postL10n.addTag ) |
| | 306 | jQuery(this).val( '' ).removeClass( 'form-input-tip' ); |
| | 307 | }); |
| | 308 | jQuery('#newtag').blur(function() { |
| | 309 | if ( this.value == '' ) |
| | 310 | jQuery(this).val( postL10n.addTag ).addClass( 'form-input-tip' ); |
| | 311 | }); |
| 209 | | |
| 210 | | var last = null; |
| 211 | | function pick(img) { |
| 212 | | if (last) last.style.backgroundColor = '#f4f4f4'; |
| 213 | | if (img) { |
| 214 | | document.getElementById('photo_src').value = img.src; |
| 215 | | img.style.backgroundColor = '#44f'; |
| 216 | | } |
| 217 | | last = img; |
| 218 | | |
| 219 | | /*noel's code to select more than one image.... |
| 220 | | jQuery('.photolist').append('<h2><?php _e("Photo URL") ?></h2>' + |
| 221 | | '<div class="titlewrap">' + |
| 222 | | '<a href="#" class="remove">remove <input name="photo_src" id="photo_src[]" value ="'+ img.src +'" class="text" onkeydown="pick(0);"/></a>' + |
| 223 | | '</div>');*/ |
| 224 | | |
| 225 | | return false; |
| | 328 | function reset_height() { |
| | 329 | tinyMCE.height = '170px'; |
| | 331 | function show(tab_name) { |
| | 332 | jQuery('body').removeClass('video_split'); |
| | 333 | jQuery('#extra_fields').hide(); |
| | 334 | switch(tab_name) { |
| | 335 | case 'text' : |
| | 336 | reset_height(); |
| | 337 | jQuery('.editor-container').show(); |
| | 338 | jQuery('#content_type').show(); |
| | 339 | set_menu('text'); |
| | 340 | set_title('<?php _e('Text') ?>'); |
| | 341 | set_editor('<?php echo $selection; ?>'); |
| | 342 | return false; |
| | 343 | break; |
| | 344 | case 'quote' : |
| | 345 | reset_height(); |
| | 346 | jQuery('.editor-container').show(); |
| | 347 | jQuery('#content_type').show(); |
| | 348 | set_menu('quote'); |
| | 349 | set_title('<?php _e('Quote') ?>'); |
| | 350 | set_editor('<blockquote><p><?php echo $selection; ?> </p><p><cite><a href="<?php echo $url; ?>"><?php echo $title; ?></a></cite> </p></blockquote>'); |
| 228 | | jQuery(document).ready(function() { |
| 229 | | |
| 230 | | |
| 231 | | <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> |
| 232 | | |
| 233 | | <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> |
| | 352 | return false; |
| | 353 | break; |
| | 354 | case 'video' : |
| | 355 | jQuery('.editor-container').show(); |
| | 356 | tinyMCE.height = '700px'; |
| | 357 | jQuery('#content_type').show(); |
| | 358 | set_menu('video'); |
| | 359 | set_title('<?php _e('Caption') ?>'); |
| | 360 | <?php |
| | 361 | if ( preg_match("/youtube\.com\/watch/i", $url) ) { |
| | 362 | list($domain, $video_id) = split("v=", $url); |
| | 363 | $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>'; } else { ?> |
| | 364 | jQuery('#extra_fields').html(); |
| | 365 | jQuery('#extra_fields').show(); |
| | 366 | jQuery('body').addClass('video_split'); |
| | 367 | jQuery('body').addClass('video_split'); |
| | 368 | jQuery('#extra_fields').load('<?php echo $_SERVER['PHP_SELF'].'/?ajax=video&selection='.attribute_escape($selection); ?>'); |
| | 369 | <?php } ?> |
| | 370 | set_editor('<?php echo $content; ?>'); |
| | 371 | return false; |
| | 372 | break; |
| 240 | | jQuery("#text_button").click(function () { |
| 241 | | jQuery('.editor-container').show(); |
| 242 | | jQuery('#content_type').show(); |
| 243 | | jQuery('#photo_fields').hide(); |
| 244 | | set_menu('text'); |
| 245 | | set_title('<?php _e('Text') ?>'); |
| 246 | | set_editor('<?php echo $selection; ?>'); |
| 247 | | return false; |
| | 400 | jQuery(document).ready(function() { |
| | 401 | jQuery('#menu li').click(function (){ |
| | 402 | tab_name = this.id.split('_'); |
| | 403 | tab_name = tab_name[0]; |
| | 404 | show(tab_name); |
| 261 | | |
| 262 | | jQuery("#video_button").click(function () { |
| 263 | | jQuery('.editor-container').show(); |
| 264 | | jQuery('#content_type').show(); |
| 265 | | jQuery('#photo_fields').hide(); |
| 266 | | set_menu('video'); |
| 267 | | set_title('<?php _e('Video') ?>'); |
| 268 | | set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>'); |
| 269 | | <?php /* |
| 270 | | <!--list($garbage,$video_id) = split("v=", $_REQUEST['content']); |
| 271 | | $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>';--> |
| 272 | | */?> |
| 273 | | return false; |
| 274 | | }); |
| 275 | | |
| 276 | | |
| 277 | | jQuery("#photo_button").click(function () { |
| 278 | | set_menu('photo'); |
| 279 | | set_title('Caption'); |
| 280 | | set_editor('<a href="<?php echo $url; ?>"><?php echo $title; ?></a>'); |
| 281 | | jQuery('#photo_fields').show(); |
| 282 | | jQuery('.remove').click(function() { |
| 283 | | jQuery(this).remove; |
| 284 | | |
| 285 | | }); |
| 286 | | |
| 287 | | |
| 288 | | var img, img_tag, aspect, w, h, skip, i, strtoappend = ""; |
| 289 | | var my_src = [<?php echo get_images_from_uri($url); ?>]; |
| 290 | | |
| 291 | | for (i = 0; i < my_src.length; i++) { |
| 292 | | img = new Image(); |
| 293 | | img.src = my_src[i]; |
| 294 | | img_attr = 'id="img' + i + '" onclick="pick(this);"'; |
| 295 | | skip = false; |
| 296 | | |
| 297 | | if (img.width && img.height) { |
| 298 | | if (img.width * img.height < 2500) skip = true; |
| 299 | | aspect = img.width / img.height; |
| 300 | | if (aspect > 1) { // Image is wide |
| 301 | | scale = 75 / img.width; |
| 302 | | } else { // Image is tall or square |
| 303 | | scale = 75 / img.height; |
| 304 | | } |
| 305 | | if (scale < 1) { |
| 306 | | w = parseInt(img.width * scale); |
| 307 | | h = parseInt(img.height * scale); |
| 308 | | } else { |
| 309 | | w = img.width; |
| 310 | | h = img.height; |
| 311 | | } |
| 312 | | img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"'; |
| 313 | | } |
| 314 | | |
| 315 | | if (!skip) strtoappend += '<a href="' + img.src + '" title="" class="thickbox"><img src="' + img.src + '" ' + img_attr + '/></a>'; |
| 316 | | |
| 317 | | } |
| 318 | | |
| 319 | | jQuery('#img_container').html(strtoappend); |
| 320 | | |
| 321 | | tb_init('a.thickbox, area.thickbox, input.thickbox'); //pass where to apply thickbox |
| 322 | | |
| 323 | | }); |
| | 407 | <?php if ( preg_match("/youtube\.com\/watch/i", $url) ) { ?> |
| | 408 | show('video'); |
| | 409 | <?php } elseif ( preg_match("/flickr\.com/i", $url) ) { ?> |
| | 410 | show('photo'); |
| | 411 | <?php } ?> |
| 351 | | <div id="photo_fields" style="display: none;"> |
| 352 | | <h2><?php _e('Photo URL') ?></h2> |
| 353 | | <div class="titlewrap"> |
| 354 | | <input name="photo_src" id="photo_src" class="text" onkeydown="pick(0);"/> |
| 355 | | </div> |
| 356 | | |
| 357 | | <div class="photolist"></div> |
| 358 | | |
| 359 | | <h2><?php _e('Link Photo to following URL') ?></h2><?php _e('(leave blank to leave the photo unlinked)') ?> |
| 360 | | <div class="titlewrap"> |
| 361 | | <input name="photo_link" id="photo_link" class="text" value="<?php echo attribute_escape($url);?>"/> |
| 362 | | </div> |
| 363 | | |
| 364 | | <small><?php _e('Click images to select:') ?></small> |
| 365 | | <div class="titlewrap"> |
| 366 | | <div id="img_container"></div> |
| 367 | | </div> |
| 368 | | |
| 369 | | </div> |
| 370 | | |
| | 437 | |
| | 438 | <div id="extra_fields" style="display: none"></div> |
| | 439 | <div class="editor_area"> |