Ordercss/admin.css000064400000010201147600272640007140 0ustar00#formatdiv, /* hide default radio button UI */ #titlewrap { display: none; } #post-body-content #postimagediv .inside p { text-align: center; } .clearfix:before, .clearfix:after { content: "\0020"; display: block; height: 0; overflow: hidden; } .clearfix:after { clear: both; } .clearfix { zoom: 1; } .vp-pfui-elm-block { margin-bottom: 18px; } .vp-pfui-elm-block label { color: #666; display: block; margin-bottom: 2px; padding-left: 10px; text-transform: uppercase; } .vp-pfui-elm-block input[type="text"], .vp-pfui-elm-block textarea, .vp-pfui-elm-block select, .vp-pfui-elm-block .vp-pfui-elm-container { border: 1px #dfdfdf solid; } .vp-pfui-elm-block input[type="text"], .vp-pfui-elm-block textarea { font-size: 18px; width: 100%; } .vp-pfui-elm-block textarea { height: 161px; padding-left: 8px; } .vp-pfui-elm-block input[type="text"] { padding-left: 8px; } .vp-pfui-elm-block .description { color: #999; display: block; font-size: 11px; line-height: 1.6; padding-left: 10px; } .vp-pfui-elm-block .vp-pfui-elm-source { height: 96px; } .vp-pfui-elm-block .vp-pfui-elm-container { background: #f0f0f0; padding: 10px; } .vp-pfui-elm-block .vp-pfui-elm-container p.none { text-align: center; } .vp-pfui-elm-block .vp-pfui-elm-image-gallery { margin: 0 0 -5px 0; padding: 0; } .vp-pfui-elm-block .vp-pfui-elm-container .gallery { margin: 0; padding-bottom: 8px; } .vp-pfui-elm-block .vp-pfui-elm-container .gallery li { display: inline-block; margin: 0 8px 8px 0; padding: 0; } .vp-pfui-elm-block .vp-pfui-elm-container .gallery li img { vertical-align: middle; } #vp-pfui-format-gallery-preview .vp-pfui-elm-container { background: #fff; } /* Video Field */ #vp-pfui-format-video-embed { height: 65px; } /* Featured Image */ #post-body-content #select-featured-image { text-align: center; } #post-body-content #select-featured-image img { display: block; margin: 0 auto 4px; } #post-body-content #select-featured-image a { float: none; } #post-body-content #select-featured-image a.button-secondary { margin-right: 10px; } #vp-post-formats-ui-tabs { margin-bottom: 0; } /** tab navigation -------------------------------------------------- */ .vp-pfui-nav { border-bottom: 1px solid #ccc; margin: 10px 0 20px 0; width: 100%; } .vp-pfui-nav ul { list-style-type: none; margin: 0 10px; padding: 0em; } .vp-pfui-nav ul li, .vp-pfui-nav ul li a { float: left; margin: 0; } .vp-pfui-nav ul li a { display: block; color: #999; background-color: #eee; border: 1px solid #ddd; border-bottom: 0; font-size: 12px; height: 25px; line-height: 25px; margin-right: 5px; padding: 0 10px; text-decoration: none; text-shadow: #fff 0 1px 1px; -moz-border-radius-topleft: 3px; -webkit-border-top-left-radius: 3px; border-top-left-radius: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 3px; border-top-right-radius: 3px; } .vp-pfui-nav ul li a:hover { color: #666; } .vp-pfui-nav ul li a.current { background: none; border: 1px solid #ccc; border-bottom: 1px solid #f1f1f1; color: #464646; margin-bottom: -1px; } .vp-pfui-nav ul li a:focus { outline: none; } /* Gallery */ .vp-pfui-gallery-picker .gallery{ overflow: auto; } .vp-pfui-gallery-picker .gallery span{ width: 120px; height: 120px; display: block; float: left; position: relative; margin: 4px; border: solid 1px #eeeeee; } .vp-pfui-gallery-picker .gallery span.close{ width: 8px; height: 8px; line-height: 8px; position: absolute; top: 0px; right: 0px; background: #fff; color: #000; text-align: center; display: none; border: none; cursor: pointer; } .vp-pfui-gallery-picker .gallery span:hover span.close{ display: block; } .vp-pfui-gallery-picker .gallery img{ width: 100%; height: 100%; display: block; } .vp-pfui-gallery-picker .gallery span.vp-pfui-ui-state-highlight { width: 120px; height: 120px; display: inline-block; border: 1px dotted #bbbbbb; background: #eeeeee; } .vp-pfui-gallery-picker .gallery span { padding: 5px; border: solid 1px #EFEFEF; } .vp-pfui-gallery-picker .gallery > span:hover { border: solid 1px #CCC; -moz-box-shadow: 1px 1px 5px #999; -webkit-box-shadow: 1px 1px 5px #999; box-shadow: 1px 1px 5px #999; }js/admin.js000064400000013653147600272640006626 0ustar00jQuery(function($) { var VP_PFUI = VP_PFUI || {}; VP_PFUI.postFormats = function($) { return { switchTab: function(clicked) { var $this = $(clicked), $tab = $this.closest('li'); if (!$this.hasClass('current')) { $this.addClass('current'); $tab.siblings().find('a').removeClass('current'); this.switchWPFormat($this.attr('href')); } }, switchWPFormat: function(formatHash) { $(formatHash).trigger('click'); switch (formatHash) { case '#post-format-0': case '#post-format-aside': case '#post-format-chat': VP_PFUI.postFormats.standard(); break; case '#post-format-status': case '#post-format-link': case '#post-format-image': case '#post-format-gallery': case '#post-format-video': case '#post-format-quote': case '#post-format-audio': VP_PFUI.postFormats[formatHash.replace('#post-format-', '')](); } $(document).trigger('vp-post-formats-ui-switch', formatHash); }, standard: function() { $('#vp-pfui-format-link-url, #vp-pfui-format-quote-fields, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields, #vp-pfui-format-gallery-preview').hide(); $('#titlewrap').show(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); }, status: function() { $('#titlewrap, #vp-pfui-format-link-url, #vp-pfui-format-quote-fields, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields, #vp-pfui-format-gallery-preview').hide(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); $('#content:visible').focus(); }, link: function() { $('#vp-pfui-format-quote-fields, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields, #vp-pfui-format-gallery-preview').hide(); $('#titlewrap, #vp-pfui-format-link-url').show(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); }, image: function() { $('#vp-pfui-format-link-url, #vp-pfui-format-quote-fields, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields, #vp-pfui-format-gallery-preview').hide(); $('#titlewrap').show(); $('#postimagediv').after('
').insertAfter('#titlediv'); }, gallery: function() { $('#vp-pfui-format-link-url, #vp-pfui-format-quote-fields, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields').hide(); $('#titlewrap, #vp-pfui-format-gallery-preview').show(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); }, video: function() { $('#vp-pfui-format-link-url, #vp-pfui-format-quote-fields, #vp-pfui-format-gallery-preview, #vp-pfui-format-audio-fields').hide(); $('#titlewrap, #vp-pfui-format-video-fields').show(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); }, quote: function() { $('#titlewrap, #vp-pfui-format-link-url, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields, #vp-pfui-format-gallery-preview').hide(); $('#vp-pfui-format-quote-fields').show().find(':input:first').focus(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); }, audio: function() { $('#vp-pfui-format-link-url, #vp-pfui-format-quote-fields, #vp-pfui-format-video-fields, #vp-pfui-format-gallery-preview').hide(); $('#titlewrap, #vp-pfui-format-audio-fields').show(); $('#postimagediv-placeholder').replaceWith($('#postimagediv')); } }; }(jQuery); // move tabs in to place $('#vp-post-formats-ui-tabs').insertBefore($('form#post')).show(); $('#vp-pfui-format-link-url, #vp-pfui-format-video-fields, #vp-pfui-format-audio-fields').insertAfter($('#titlediv')); $('#vp-pfui-format-gallery-preview').find('dt a').each(function() { $(this).replaceWith($(this.childNodes)); // remove links }).end().insertAfter($('#titlediv')); $('#vp-pfui-format-quote-fields').insertAfter($('#titlediv')); $(document).trigger('vp-post-formats-ui-init'); // tab switch $('#vp-post-formats-ui-tabs a').on('click', function(e) { VP_PFUI.postFormats.switchTab(this); e.stopPropagation(); e.preventDefault(); }).filter('.current').each(function() { VP_PFUI.postFormats.switchWPFormat($(this).attr('href')); }); // Gallery Management var postId = $('#post_ID').val(), $gallery = $('.vp-pfui-gallery-picker .gallery'); VPPFUIMediaControl = { // Init a new media manager or returns existing frame frame: function() { if( this._frame ) return this._frame; this._frame = wp.media({ title: vp_pfui_post_format.media_title, library: { type: 'image' }, button: { text: vp_pfui_post_format.media_button }, multiple: true }); this._frame.on('open', this.updateFrame).state('library').on('select', this.select); return this._frame; }, select: function() { var selection = this.get('selection'); selection.each(function(model) { var thumbnail = model.attributes.url; if( model.attributes.sizes !== undefined && model.attributes.sizes.thumbnail !== undefined ) thumbnail = model.attributes.sizes.thumbnail.url; $gallery.append('x'); $gallery.trigger('update'); }); }, updateFrame: function() { }, init: function() { $('#wpbody').on('click', '.vp-pfui-gallery-button', function(e){ e.preventDefault(); VPPFUIMediaControl.frame().open(); }); } } VPPFUIMediaControl.init(); $gallery.on('update', function(){ var ids = []; $(this).find('> span').each(function(){ ids.push($(this).data('id')); }); $('[name="_format_gallery_images"]').val(ids.join(',')); }); $gallery.sortable({ placeholder: "vp-pfui-ui-state-highlight", revert: 200, tolerance: 'pointer', stop: function () { $gallery.trigger('update'); } }); $gallery.on('click', 'span.close', function(e){ $(this).parent().fadeOut(200, function(){ $(this).remove(); $gallery.trigger('update'); }); }); }); views/format-video.php000064400000000760147600272640011021 0ustar00 views/format-quote.php000064400000001543147600272640011050 0ustar00 views/tabs.php000064400000001230147600272640007347 0ustar00views/format-audio.php000064400000000760147600272640011014 0ustar00 views/format-gallery.php000064400000002176147600272640011355 0ustar00views/format-link.php000064400000000722147600272640010646 0ustar00 README.md000064400000001156147600272640006036 0ustar00Vafpress Post Formats UI ======================== Forked version of crowdfavorite's WordPress Post Formats, what's changed? - Change the default gallery UI, now use post meta to enable more flexibility (images doesn't have to be uploaded to the post and easily sortable)

- Added hooks to enable customizations (e.g. before and after custom UI), example of adding a field:

Example how to accomplish this: https://gist.github.com/ayublin/8818074vp-post-formats-ui.php000064400000021444147600272640010766 0ustar00 __('Loading...', 'vp-post-formats-ui'), 'wpspin_light' => admin_url('images/wpspin_light.gif'), 'media_title' => __('Pick Gallery Images', 'vp-post-formats-ui'), 'media_button' => __('Add Image(s)', 'vp-post-formats-ui') ) ); global $wp_version; if( 5 > $wp_version ){ add_action('edit_form_after_title', 'vp_pfui_post_admin_setup'); } else { add_action('block_editor_meta_box_hidden_fields', 'vp_pfui_post_admin_setup'); } } } add_action('add_meta_boxes', 'vp_pfui_add_meta_boxes'); /** * Show the post format navigation tabs * A lot of cues are taken from the `post_format_meta_box` * * @return void */ function vp_pfui_post_admin_setup() { $post_formats = get_theme_support('post-formats'); if (!empty($post_formats[0]) && is_array($post_formats[0])) { global $post; $current_post_format = get_post_format($post->ID); $hacked_format = null; // support the possibility of people having hacked in custom // post-formats or that this theme doesn't natively support // the post-format in the current post - a tab will be added // for this format but the default WP post UI will be shown ~sp if (!empty($current_post_format) && !in_array($current_post_format, $post_formats[0])) { $hacked_format = $current_post_format; array_push($post_formats[0], $current_post_format); } array_unshift($post_formats[0], 'standard'); $post_formats = $post_formats[0]; include('views/tabs.php'); // prevent added un-supported custom post format from view output if(!is_null($hacked_format) and ($key = array_search($current_post_format, $post_formats)) !== false) { unset($post_formats[$key]); } $format_views = array( 'link', 'quote', 'video', 'gallery', 'audio', ); foreach ($format_views as $format) { if (in_array($format, $post_formats)) { include('views/format-'.$format.'.php'); } } } } function vp_pfui_format_link_save_post($post_id) { if (!defined('XMLRPC_REQUEST') && isset($_POST['_format_link_url'])) { update_post_meta($post_id, '_format_link_url', $_POST['_format_link_url']); } } // action added in vp_pfui_admin_init() function vp_pfui_format_auto_title_post($post_id, $post) { // get out early if a title is already set if (!empty($post->post_title)) { return; } remove_action('save_post', 'vp_pfui_format_status_save_post', 10, 2); remove_action('save_post', 'vp_pfui_format_quote_save_post', 10, 2); $content = trim(strip_tags($post->post_content)); $title = substr($content, 0, 50); if (strlen($content) > 50) { $title .= '...'; } $title = apply_filters('vp_pfui_format_auto_title', $title, $post); wp_update_post(array( 'ID' => $post_id, 'post_title' => $title )); add_action('save_post', 'vp_pfui_format_status_save_post', 10, 2); add_action('save_post', 'vp_pfui_format_quote_save_post', 10, 2); } function vp_pfui_format_status_save_post($post_id, $post) { if (has_post_format('status', $post)) { vp_pfui_format_auto_title_post($post_id, $post); } } // action added in vp_pfui_admin_init() function vp_pfui_format_quote_save_post($post_id, $post) { if (!defined('XMLRPC_REQUEST')) { $keys = array( '_format_quote_source_name', '_format_quote_source_url', ); foreach ($keys as $key) { if (isset($_POST[$key])) { update_post_meta($post_id, $key, $_POST[$key]); } } } if (has_post_format('quote', $post)) { vp_pfui_format_auto_title_post($post_id, $post); } } // action added in vp_pfui_admin_init() function vp_pfui_format_video_save_post($post_id) { if (!defined('XMLRPC_REQUEST') && isset($_POST['_format_video_embed'])) { update_post_meta($post_id, '_format_video_embed', $_POST['_format_video_embed']); } } // action added in vp_pfui_admin_init() function vp_pfui_format_audio_save_post($post_id) { if (!defined('XMLRPC_REQUEST') && isset($_POST['_format_audio_embed'])) { update_post_meta($post_id, '_format_audio_embed', $_POST['_format_audio_embed']); } } // action added in vp_pfui_admin_init() function vp_pfui_format_gallery_save_post($post_id) { if (!defined('XMLRPC_REQUEST') && isset($_POST['_format_gallery_images'])) { global $post; if( $_POST['_format_gallery_images'] !== '' ) { $images = explode(',', $_POST['_format_gallery_images']); } else { $images = array(); } update_post_meta($post_id, '_format_gallery_images', $images); } } // action added in vp_pfui_admin_init() function vp_pfui_gallery_preview() { if (empty($_POST['id']) || !($post_id = intval($_POST['id']))) { exit; } global $post; $post->ID = $post_id; ob_start(); include('views/format-gallery.php'); $html = ob_get_clean(); header('Content-type: text/javascript'); echo json_encode(compact('html')); exit; } add_action('wp_ajax_vp_pfui_gallery_preview', 'vp_pfui_gallery_preview'); function vp_pfui_post_has_gallery($post_id = null) { if (empty($post_id)) { $post_id = get_the_ID(); } $images = new WP_Query(array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_status' => 'inherit', 'posts_per_page' => 1, // -1 to show all 'post_mime_type' => 'image%', 'orderby' => 'menu_order', 'order' => 'ASC' )); return (bool) $images->post_count; } function vp_pfui_pre_ping_post_links($post_links, $pung, $post_id = null) { // return if we don't get a post ID (pre WP 3.4) if (empty($post_id)) { return; } $url = get_post_meta($post_id, '_format_link_url', true); if (!empty($url) && !in_array($url, $pung) && !in_array($url, $post_links)) { $post_links[] = $url; } } add_filter('pre_ping', 'vp_pfui_pre_ping_post_links', 10, 3); // For integration with Social plugin (strips {title} from broadcast format on status posts) function vp_pfui_social_broadcast_format($format, $post) { if (get_post_format($post) == 'status') { $format = trim(str_replace( array( '{title}:', '{title} -', '{title}', ), '', $format )); } return $format; } add_filter('social_broadcast_format', 'vp_pfui_social_broadcast_format', 10, 2); } // end defined check CHANGELOG.txt000064400000001560147600272640006606 0ustar00# Vafpress Post Formats UI ## Version 1.5 - Initial Release For Vafpress Forked Version - Modify gallery post format behavior - Added some hooks ## Version 1.3.1 - (fix) WordPress 3.8 admin UI compatibility ## Version 1.3 - (fix) WordPress 3.8 admin UI compatibility ## Version 1.2 - (fix) Don't auto-set the post title for status posts if a title already exists ## Version 1.1 - WordPress 3.5 compatibility - Requires WordPress 3.5 ## Version 1.0.2 - Gallery is displayed as expected when images have already been uploaded before gallery tab is selected - Fix audio fields showing on Video tab (props DrewAPicture) - Fix quote fields showing on Link tab (props dariodev) - Compatibility with Social broadcasting of Status posts ## Version 1.0.1 - added CHANGELOG - add compatibility with `pre_ping` changes in WordPress 3.4 ## Version 1.0 - first public release