').text(b))}function x(a){w(a,!0)}function y(){L.errors&&L.errors.length&&a.each(L.errors,function(a,b){x(b)}),L.v&&L._version&&L.v!==L._version&&a(".should-upgrade-bookmarklet").removeClass("is-hidden")}function z(){var b=Q||"",c=a("#title-container");P||(a("#title-field").val(b),c.text(b),a(".post-title-placeholder").addClass("is-hidden")),c.on("keyup",function(){J=!0}).on("paste",function(){J=!0,setTimeout(function(){c.text(c.text())},100)})}function A(){R&&R.length&&(I||(I=b.tinymce.get("pressthis")),I&&(I.setContent(R),I.on("focus",function(){S=!0})))}function B(){var b=a("#featured-media-container"),d=a("#all-media-container"),e=0;return d.empty(),(O&&O.length||N&&N.length)&&d.append('
"),b.wpPressThisConfig||{}),L=b.wpPressThisData||{},M=128,N=o(L)||[],O=m(L)||[],P=!1,Q=i(L),R=j(L),S=!1,T=[],U=function(){var a=document.documentElement.style;return"undefined"!=typeof a.transition?"transitionend":"undefined"!=typeof a.WebkitTransition?"webkitTransitionEnd":!1}();return a(document).ready(function(){F(),G(),H()}),{renderNotice:w,renderError:x}};b.wp=b.wp||{},b.wp.pressThis=new c}(jQuery,window);
\ No newline at end of file
diff --git a/wp-admin/js/tags-box.js b/wp-admin/js/tags-box.js
new file mode 100644
index 0000000000..0cf97b53ed
--- /dev/null
+++ b/wp-admin/js/tags-box.js
@@ -0,0 +1,222 @@
+/* jshint curly: false, eqeqeq: false */
+/* global ajaxurl, wpAjax */
+
+/**
+ * The functions and classes in that code are a straight cut-and-paste out of
+ * /wp-admin/js/post.js, coupled with Press This' usage of the post_tags_meta_box()
+ * PHP function.
+ *
+ * If Press This makes it into core, we can refactor that code out of post.js and
+ * make it more reusable, as well as improve it to work better, everywhere.
+ *
+ * Copied-and-pasted instead of enqueuing post.js because the latter has much more,
+ * and has processing instead of just functions/classes.
+ */
+var tagBox, array_unique_noempty;
+
+( function( $ ) {
+ // Return an array with any duplicate, whitespace or empty values removed
+ array_unique_noempty = function( array ) {
+ var out = [];
+
+ $.each( array, function( key, val ) {
+ val = $.trim( val );
+
+ if ( val && $.inArray( val, out ) === -1 ) {
+ out.push( val );
+ }
+ } );
+
+ return out;
+ }
+
+ tagBox = {
+ clean : function(tags) {
+ var comma = window.tagsBoxL10n.tagDelimiter;
+ if ( ',' !== comma )
+ tags = tags.replace(new RegExp(comma, 'g'), ',');
+ tags = tags.replace(/\s*,\s*/g, ',').replace(/,+/g, ',').replace(/[,\s]+$/, '').replace(/^[,\s]+/, '');
+ if ( ',' !== comma )
+ tags = tags.replace(/,/g, comma);
+ return tags;
+ },
+
+ parseTags : function(el) {
+ var id = el.id,
+ num = id.split('-check-num-')[1],
+ taxbox = $(el).closest('.tagsdiv'),
+ thetags = taxbox.find('.the-tags'),
+ comma = window.tagsBoxL10n.tagDelimiter;
+ current_tags = thetags.val().split( comma ),
+ new_tags = [];
+
+ delete current_tags[num];
+
+ $.each( current_tags, function( key, val ) {
+ val = $.trim( val );
+ if ( val ) {
+ new_tags.push( val );
+ }
+ });
+
+ thetags.val( this.clean( new_tags.join( comma ) ) );
+
+ this.quickClicks( taxbox );
+ return false;
+ },
+
+ quickClicks : function( el ) {
+ var thetags = $('.the-tags', el),
+ tagchecklist = $('.tagchecklist', el),
+ id = $(el).attr('id'),
+ current_tags, disabled;
+
+ if ( ! thetags.length )
+ return;
+
+ disabled = thetags.prop('disabled');
+
+ current_tags = thetags.val().split( window.tagsBoxL10n.tagDelimiter );
+ tagchecklist.empty();
+
+ $.each( current_tags, function( key, val ) {
+ var span, xbutton;
+
+ val = $.trim( val );
+
+ if ( ! val )
+ return;
+
+ // Create a new span, and ensure the text is properly escaped.
+ span = $('
').text( val );
+
+ // If tags editing isn't disabled, create the X button.
+ if ( ! disabled ) {
+ xbutton = $( '
X' );
+
+ xbutton.on( 'click keypress', function( e ) {
+ // Trigger function if pressed Enter - keyboard navigation
+ if ( e.type === 'click' || e.keyCode === 13 ) {
+ // When using keyboard, move focus back to the new tag field.
+ if ( e.keyCode === 13 ) {
+ $( this ).closest( '.tagsdiv' ).find( 'input.newtag' ).focus();
+ }
+
+ tagBox.parseTags( this );
+ }
+ });
+
+ span.prepend( ' ' ).prepend( xbutton );
+ }
+
+ // Append the span to the tag list.
+ tagchecklist.append( span );
+ });
+ },
+
+ flushTags : function( el, a, f ) {
+ var tagsval, newtags, text,
+ tags = $( '.the-tags', el ),
+ newtag = $( 'input.newtag', el ),
+ comma = window.tagsBoxL10n.tagDelimiter;
+
+ a = a || false;
+
+ text = a ? $(a).text() : newtag.val();
+ tagsval = tags.val();
+ newtags = tagsval ? tagsval + comma + text : text;
+
+ newtags = this.clean( newtags );
+ newtags = array_unique_noempty( newtags.split( comma ) ).join( comma );
+ tags.val( newtags );
+ this.quickClicks( el );
+
+ if ( ! a )
+ newtag.val('');
+ if ( 'undefined' == typeof( f ) )
+ newtag.focus();
+
+ return false;
+ },
+
+ get : function( id ) {
+ var tax = id.substr( id.indexOf('-') + 1 );
+
+ $.post( ajaxurl, { 'action': 'get-tagcloud', 'tax': tax }, function( r, stat ) {
+ if ( 0 === r || 'success' != stat ) {
+ return;
+ }
+
+ r = $( '
' + r + '
' );
+
+ $( 'a', r ).click( function() {
+ tagBox.flushTags( $( '#' + tax ), this );
+ return false;
+ });
+
+ $( '#' + id ).after( r );
+ });
+ },
+
+ init : function() {
+ var t = this, ajaxtag = $('div.ajaxtag');
+
+ $('.tagsdiv').each( function() {
+ tagBox.quickClicks(this);
+ });
+
+ $('.tagadd', ajaxtag).click(function(){
+ t.flushTags( $(this).closest('.tagsdiv') );
+ });
+
+ $('div.taghint', ajaxtag).click(function(){
+ $(this).css('visibility', 'hidden').parent().siblings('.newtag').focus();
+ });
+
+ $('input.newtag', ajaxtag).blur(function() {
+ if ( '' === this.value )
+ $(this).parent().siblings('.taghint').css('visibility', '');
+ }).focus(function(){
+ $(this).parent().siblings('.taghint').css('visibility', 'hidden');
+ }).keyup(function(e){
+ if ( 13 == e.which ) {
+ tagBox.flushTags( $(this).closest('.tagsdiv') );
+ return false;
+ }
+ }).keypress(function(e){
+ if ( 13 == e.which ) {
+ e.preventDefault();
+ return false;
+ }
+ }).each( function() {
+ var tax = $(this).closest('div.tagsdiv').attr('id');
+ $(this).suggest(
+ ajaxurl + '?action=ajax-tag-search&tax=' + tax,
+ { delay: 500, minchars: 2, multiple: true, multipleSep: window.tagsBoxL10n.tagDelimiter + ' ' }
+ );
+ });
+
+ // save tags on post save/publish
+ $('#post').submit(function(){
+ $('div.tagsdiv').each( function() {
+ tagBox.flushTags(this, false, 1);
+ });
+ });
+
+ // tag cloud
+ $('a.tagcloud-link').click(function(){
+ tagBox.get( $(this).attr('id') );
+ $(this).unbind().click(function(){
+ $(this).siblings('.the-tagcloud').toggle();
+ return false;
+ });
+ return false;
+ });
+ }
+ };
+
+ $( document ).ready( function() {
+ tagBox.init();
+ });
+
+}( jQuery ));
diff --git a/wp-admin/js/tags-box.min.js b/wp-admin/js/tags-box.min.js
new file mode 100644
index 0000000000..b72b50087b
--- /dev/null
+++ b/wp-admin/js/tags-box.min.js
@@ -0,0 +1 @@
+var tagBox,array_unique_noempty;!function(a){array_unique_noempty=function(b){var c=[];return a.each(b,function(b,d){d=a.trim(d),d&&-1===a.inArray(d,c)&&c.push(d)}),c},tagBox={clean:function(a){var b=window.tagsBoxL10n.tagDelimiter;return","!==b&&(a=a.replace(new RegExp(b,"g"),",")),a=a.replace(/\s*,\s*/g,",").replace(/,+/g,",").replace(/[,\s]+$/,"").replace(/^[,\s]+/,""),","!==b&&(a=a.replace(/,/g,b)),a},parseTags:function(b){var c=b.id,d=c.split("-check-num-")[1],e=a(b).closest(".tagsdiv"),f=e.find(".the-tags"),g=window.tagsBoxL10n.tagDelimiter;return current_tags=f.val().split(g),new_tags=[],delete current_tags[d],a.each(current_tags,function(b,c){c=a.trim(c),c&&new_tags.push(c)}),f.val(this.clean(new_tags.join(g))),this.quickClicks(e),!1},quickClicks:function(b){var c,d,e=a(".the-tags",b),f=a(".tagchecklist",b),g=a(b).attr("id");e.length&&(d=e.prop("disabled"),c=e.val().split(window.tagsBoxL10n.tagDelimiter),f.empty(),a.each(c,function(b,c){var e,h;c=a.trim(c),c&&(e=a("
").text(c),d||(h=a('
X'),h.on("click keypress",function(b){("click"===b.type||13===b.keyCode)&&(13===b.keyCode&&a(this).closest(".tagsdiv").find("input.newtag").focus(),tagBox.parseTags(this))}),e.prepend(" ").prepend(h)),f.append(e))}))},flushTags:function(b,c,d){var e,f,g,h=a(".the-tags",b),i=a("input.newtag",b),j=window.tagsBoxL10n.tagDelimiter;return c=c||!1,g=c?a(c).text():i.val(),e=h.val(),f=e?e+j+g:g,f=this.clean(f),f=array_unique_noempty(f.split(j)).join(j),h.val(f),this.quickClicks(b),c||i.val(""),"undefined"==typeof d&&i.focus(),!1},get:function(b){var c=b.substr(b.indexOf("-")+1);a.post(ajaxurl,{action:"get-tagcloud",tax:c},function(d,e){0!==d&&"success"==e&&(d=a('
'+d+"
"),a("a",d).click(function(){return tagBox.flushTags(a("#"+c),this),!1}),a("#"+b).after(d))})},init:function(){var b=this,c=a("div.ajaxtag");a(".tagsdiv").each(function(){tagBox.quickClicks(this)}),a(".tagadd",c).click(function(){b.flushTags(a(this).closest(".tagsdiv"))}),a("div.taghint",c).click(function(){a(this).css("visibility","hidden").parent().siblings(".newtag").focus()}),a("input.newtag",c).blur(function(){""===this.value&&a(this).parent().siblings(".taghint").css("visibility","")}).focus(function(){a(this).parent().siblings(".taghint").css("visibility","hidden")}).keyup(function(b){return 13==b.which?(tagBox.flushTags(a(this).closest(".tagsdiv")),!1):void 0}).keypress(function(a){return 13==a.which?(a.preventDefault(),!1):void 0}).each(function(){var b=a(this).closest("div.tagsdiv").attr("id");a(this).suggest(ajaxurl+"?action=ajax-tag-search&tax="+b,{delay:500,minchars:2,multiple:!0,multipleSep:window.tagsBoxL10n.tagDelimiter+" "})}),a("#post").submit(function(){a("div.tagsdiv").each(function(){tagBox.flushTags(this,!1,1)})}),a("a.tagcloud-link").click(function(){return tagBox.get(a(this).attr("id")),a(this).unbind().click(function(){return a(this).siblings(".the-tagcloud").toggle(),!1}),!1})}},a(document).ready(function(){tagBox.init()})}(jQuery);
\ No newline at end of file
diff --git a/wp-admin/options-writing.php b/wp-admin/options-writing.php
index 4c761d2646..75f7e10158 100644
--- a/wp-admin/options-writing.php
+++ b/wp-admin/options-writing.php
@@ -113,16 +113,6 @@ do_settings_fields('writing', 'remote_publishing'); // A deprecated section.
?>
-
-
-
-
-
-
-
cap->create_posts ) )
wp_die( __( 'Cheatin’ uh?' ), 403 );
-/**
- * Press It form handler.
- *
- * @since 2.6.0
- *
- * @return int Post ID
- */
-function press_it() {
-
- $post = get_default_post_to_edit();
- $post = get_object_vars($post);
- $post_ID = $post['ID'] = (int) $_POST['post_id'];
-
- if ( !current_user_can('edit_post', $post_ID) )
- wp_die(__('You are not allowed to edit this post.'));
-
- $post['post_category'] = isset($_POST['post_category']) ? $_POST['post_category'] : '';
- $post['tax_input'] = isset($_POST['tax_input']) ? $_POST['tax_input'] : '';
- $post['post_title'] = isset($_POST['title']) ? $_POST['title'] : '';
- $content = isset($_POST['content']) ? $_POST['content'] : '';
-
- $upload = false;
- if ( !empty($_POST['photo_src']) && current_user_can('upload_files') ) {
- foreach( (array) $_POST['photo_src'] as $key => $image) {
- // See if files exist in content - we don't want to upload non-used selected files.
- if ( strpos($_POST['content'], htmlspecialchars($image)) !== false ) {
- $desc = isset($_POST['photo_description'][$key]) ? $_POST['photo_description'][$key] : '';
- $upload = media_sideload_image($image, $post_ID, $desc);
-
- // Replace the POSTED content
with correct uploaded ones. Regex contains fix for Magic Quotes
- if ( !is_wp_error($upload) )
- $content = preg_replace('/
]*)src=\\\?(\"|\')'.preg_quote(htmlspecialchars($image), '/').'\\\?(\2)([^>\/]*)\/*>/is', $upload, $content);
- }
- }
- }
- // Set the post_content and status.
- $post['post_content'] = $content;
- if ( isset( $_POST['publish'] ) && current_user_can( 'publish_posts' ) )
- $post['post_status'] = 'publish';
- elseif ( isset( $_POST['review'] ) )
- $post['post_status'] = 'pending';
- else
- $post['post_status'] = 'draft';
-
- // Error handling for media_sideload.
- if ( is_wp_error($upload) ) {
- wp_delete_post($post_ID);
- wp_die( esc_html( $upload->get_error_message() ) );
- } else {
- // Post formats.
- if ( isset( $_POST['post_format'] ) ) {
- if ( current_theme_supports( 'post-formats', $_POST['post_format'] ) )
- set_post_format( $post_ID, $_POST['post_format'] );
- elseif ( '0' == $_POST['post_format'] )
- set_post_format( $post_ID, false );
- }
-
- $post_ID = wp_update_post($post);
- }
-
- return $post_ID;
+if ( empty( $GLOBALS['wp_press_this'] ) ) {
+ include( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
}
-// For submitted posts.
-if ( isset($_REQUEST['action']) && 'post' == $_REQUEST['action'] ) {
- check_admin_referer('press-this');
- $posted = $post_ID = press_it();
-} else {
- $post = get_default_post_to_edit('post', true);
- $post_ID = $post->ID;
-}
-
-// Set Variables
-$title = isset( $_GET['t'] ) ? trim( strip_tags( html_entity_decode( wp_unslash( $_GET['t'] ) , ENT_QUOTES) ) ) : '';
-
-$selection = '';
-if ( !empty($_GET['s']) ) {
- $selection = str_replace(''', "'", wp_unslash($_GET['s']));
- $selection = trim( htmlspecialchars( html_entity_decode($selection, ENT_QUOTES) ) );
-}
-
-if ( ! empty($selection) ) {
- $selection = preg_replace('/(\r?\n|\r)/', '
', $selection);
- $selection = '
' . str_replace('
', '', $selection) . '';
-}
-
-$url = isset($_GET['u']) ? esc_url($_GET['u']) : '';
-$image = isset($_GET['i']) ? $_GET['i'] : '';
-
-if ( !empty($_REQUEST['ajax']) ) {
- switch ($_REQUEST['ajax']) {
- case 'video': ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ]*)src=(\"|\')([^<>\'\"]+)(\2)([^>]*)\/*>/i';
- $content = str_replace(array("\n","\t","\r"), '', $content);
- preg_match_all($pattern, $content, $matches);
- if ( empty($matches[0]) )
- return '';
- $sources = array();
- foreach ($matches[3] as $src) {
-
- // If no http in URL.
- if (strpos($src, 'http') === false)
- // If it doesn't have a relative URI.
- if ( strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0)
- $src = 'http://'.str_replace('//','/', $host['host'].'/'.$src);
- else
- $src = 'http://'.str_replace('//','/', $host['host'].'/'.dirname($host['path']).'/'.$src);
- $sources[] = esc_url($src);
- }
- return "'" . implode("','", $sources) . "'";
- }
- $url = wp_kses(urldecode($url), null);
- echo 'new Array('.get_images_from_uri($url).')';
- break;
-
- case 'photo_js': ?>
- // Gather images and load some default JS.
- var last = null
- var img, img_tag, aspect, w, h, skip, i, strtoappend = "";
- if(photostorage == false) {
- var my_src = eval(
- jQuery.ajax({
- type: "GET",
- url: "",
- cache : false,
- async : false,
- data: "ajax=photo_images&u=",
- dataType : "script"
- }).responseText
- );
- if(my_src.length == 0) {
- var my_src = eval(
- jQuery.ajax({
- type: "GET",
- url: "",
- cache : false,
- async : false,
- data: "ajax=photo_images&u=",
- dataType : "script"
- }).responseText
- );
- if(my_src.length == 0) {
- strtoappend = '';
- }
- }
- }
- for (i = 0; i < my_src.length; i++) {
- img = new Image();
- img.src = my_src[i];
- img_attr = 'id="img' + i + '"';
- skip = false;
-
- maybeappend = '
';
-
- if (img.width && img.height) {
- if (img.width >= 30 && img.height >= 30) {
- aspect = img.width / img.height;
- scale = (aspect > 1) ? (71 / img.width) : (71 / img.height);
-
- w = img.width;
- h = img.height;
-
- if (scale < 1) {
- w = parseInt(img.width * scale);
- h = parseInt(img.height * scale);
- }
- img_attr += ' style="width: ' + w + 'px; height: ' + h + 'px;"';
- strtoappend += maybeappend;
- }
- } else {
- strtoappend += maybeappend;
- }
- }
-
- function pick(img, desc) {
- if (img) {
- if('object' == typeof jQuery('.photolist input') && jQuery('.photolist input').length != 0) length = jQuery('.photolist input').length;
- if(length == 0) length = 1;
- jQuery('.photolist').append('
');
- jQuery('.photolist').append('
');
- insert_editor( "\n\n" + encodeURI('
'));
- }
- return false;
- }
-
- function image_selector(el) {
- var desc, src, parent = jQuery(el).closest('#photo-add-url-div');
-
- if ( parent.length ) {
- desc = parent.find('input.tb_this_photo_description').val() || '';
- src = parent.find('input.tb_this_photo').val() || ''
- } else {
- desc = jQuery('#tb_this_photo_description').val() || '';
- src = jQuery('#tb_this_photo').val() || ''
- }
-
- tb_remove();
- pick(src, desc);
- jQuery('#extra-fields').hide();
- jQuery('#extra-fields').html('');
- return false;
- }
-
- jQuery('#extra-fields').html('
()
');
- jQuery('#img_container').html(strtoappend);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-