Changeset 888474
- Timestamp:
- 04/06/2014 08:31:46 PM (12 years ago)
- Location:
- simple-page-ordering
- Files:
-
- 13 added
- 2 deleted
- 5 edited
-
assets/screenshot-1.png (added)
-
assets/screenshot-2.png (added)
-
tags/2.2 (added)
-
tags/2.2/localization (added)
-
tags/2.2/localization/simple-page-ordering-es_ES.mo (added)
-
tags/2.2/localization/simple-page-ordering-es_ES.po (added)
-
tags/2.2/localization/simple-page-ordering-nl_NL.mo (added)
-
tags/2.2/localization/simple-page-ordering-nl_NL.po (added)
-
tags/2.2/readme.txt (added)
-
tags/2.2/simple-page-ordering.css (added)
-
tags/2.2/simple-page-ordering.dev.js (added)
-
tags/2.2/simple-page-ordering.js (added)
-
tags/2.2/simple-page-ordering.php (added)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/screenshot-1.png (deleted)
-
trunk/screenshot-2.png (deleted)
-
trunk/simple-page-ordering.css (modified) (2 diffs)
-
trunk/simple-page-ordering.dev.js (modified) (2 diffs)
-
trunk/simple-page-ordering.js (modified) (1 diff)
-
trunk/simple-page-ordering.php (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-page-ordering/trunk/readme.txt
r720603 r888474 3 3 Donate link: http://10up.com/plugins/simple-page-ordering-wordpress/ 4 4 Tags: order, re-order, ordering, pages, page, manage, menu_order, hierarchical, ajax, drag-and-drop, admin 5 Requires at least: 3. 46 Tested up to: 3. 67 Stable tag: 2. 1.25 Requires at least: 3.8 6 Tested up to: 3.9 7 Stable tag: 2.2 8 8 9 9 Order your pages and other hierarchical post types with simple drag and drop right from the standard page list. … … 78 78 == Changelog == 79 79 80 = 2.2 = 81 * Updated look and feel to better match WordPress 3.8 admin redesign 82 * Improved awareness of and compatibility with Quick Edit (inline editor) 83 * Prevent collisions with themes and plugins bundling Simple Page Ordering 84 80 85 = 2.1.2 = 81 86 * Bug fix: hierarchical custom post types without page-attributes was still broken - doh! -
simple-page-ordering/trunk/simple-page-ordering.css
r715085 r888474 2 2 cursor: move; 3 3 } 4 .wp-list-table .spo-updating tr { 4 5 .wp-list-table .spo-updating tr, 6 .wp-list-table .ui-sortable tr.inline-editor { 5 7 cursor: default; 6 8 } 9 7 10 .wp-list-table .ui-sortable-placeholder { 8 border: 0; 9 height: 51px; 10 background: #808080; 11 background-image: -webkit-gradient(linear, left bottom, left top, from(#6d6d6d), to(#808080)); 12 background-image: -webkit-linear-gradient(bottom, #6d6d6d, #808080); 13 background-image: -moz-linear-gradient(bottom, #6d6d6d, #808080); 14 background-image: -o-linear-gradient(bottom, #6d6d6d, #808080); 15 background-image: linear-gradient(to top, #6d6d6d, #808080); 11 outline: 1px dashed #bbb; 12 background: #F1F1F1; 16 13 visibility: visible !important; 17 14 } 18 15 .wp-list-table .ui-sortable-helper { 19 16 background-color: #fff; 20 margin-left: -1px; 21 border: 1px solid #dfdfdf; 17 outline: 1px solid #e1e1e1; 22 18 } 23 .wp-list-table .ui-sortable-helper th,24 .wp-list-table .ui-sortable-helper td {25 border-bottom-width: 0 !important;26 }27 28 19 .spo-updating-row .check-column { 29 background: url('../../../wp-admin/images/ wpspin_light.gif') centerno-repeat;20 background: url('../../../wp-admin/images/spinner.gif') 11px 11px no-repeat; 30 21 } 31 22 @media print, … … 34 25 (min-resolution: 120dpi) { 35 26 .spo-updating-row .check-column { 36 background-image: url('../../../wp-admin/images/ wpspin_light-2x.gif');37 background-size: 16px 16px;27 background-image: url('../../../wp-admin/images/spinner-2x.gif'); 28 background-size: 20px 20px; 38 29 } 39 30 } -
simple-page-ordering/trunk/simple-page-ordering.dev.js
r720603 r888474 64 64 axis: 'y', 65 65 containment: 'table.widefat', 66 scrollSensitivity: 40,67 66 cancel: '.inline-edit-row', 68 distance: 5, 69 opacity: .85, 70 forceHelperSize: true, 67 distance: 2, 68 opacity: .8, 69 tolerance: 'pointer', 70 start: function(e, ui){ 71 if ( typeof(inlineEditPost) !== 'undefined' ) { 72 inlineEditPost.revert(); 73 } 74 ui.placeholder.height(ui.item.height()); 75 }, 71 76 update: function(event, ui) { 72 77 sortable_post_table.sortable('disable').addClass('spo-updating'); … … 100 105 } 101 106 } 107 // fix quick edit 102 108 } 103 109 }); -
simple-page-ordering/trunk/simple-page-ordering.js
r720603 r888474 1 function update_simple_ordering_callback(e){if("children"===e){window.location.reload();return}var t=jQuery.parseJSON(e);var n=t.new_pos;for(var r in n){if("next"===r)continue;var i=document.getElementById("inline_"+r);if(null!==i&&n.hasOwnProperty(r)){var s=i.querySelector(".menu_order");if(undefined!==n[r]["menu_order"]){if(null!==s)s.innerHTML=n[r]["menu_order"];var o=i.querySelector(".post_parent");if(null!==o)o.innerHTML=n[r]["post_parent"];var u=null;var a=i.querySelector(".post_title");if(null!==a)u=a.innerHTML;var f=0;while(f<n[r]["depth"]){u=" — "+u;f++}var l=i.parentNode.querySelector(".row-title");if(null!==l&&null!==u)l.innerHTML=u}else if(null!==s){s.innerHTML=n[r]}}}if(t.next){jQuery.post(ajaxurl,{action:"simple_page_ordering",id:t.next["id"],previd:t.next["previd"],nextid:t.next["nextid"],start:t.next["start"],excluded:t.next["excluded"]},update_simple_ordering_callback)}else{jQuery(document.querySelector(".spo-updating-row")).removeClass("spo-updating-row");sortable_post_table.removeClass("spo-updating").sortable("enable")}}var sortable_post_table=jQuery(document.querySelector(".wp-list-table tbody"));sortable_post_table.sortable({items:"> tr",cursor:"move",axis:"y",containment:"table.widefat",scrollSensitivity:40,cancel:".inline-edit-row",distance:5,opacity:.85,forceHelperSize:true,update:function(e,t){sortable_post_table.sortable("disable").addClass("spo-updating");t.item.addClass("spo-updating-row");var n=t.item[0].id.substr(5);var r=false;var i=t.item.prev();if(i.length>0){r=i.attr("id").substr(5)}var s=false;var o=t.item.next();if(o.length>0){s=o.attr("id").substr(5)}jQuery.post(ajaxurl,{action:"simple_page_ordering",id:n,previd:r,nextid:s},update_simple_ordering_callback);var u=document.querySelectorAll("tr.iedit"),a=u.length;while(a--){if(a%2==0){jQuery(u[a]).addClass("alternate")}else{jQuery(u[a]).removeClass("alternate")}}}})1 function update_simple_ordering_callback(e){if("children"===e){window.location.reload();return}var t=jQuery.parseJSON(e);var n=t.new_pos;for(var r in n){if("next"===r)continue;var i=document.getElementById("inline_"+r);if(null!==i&&n.hasOwnProperty(r)){var s=i.querySelector(".menu_order");if(undefined!==n[r]["menu_order"]){if(null!==s)s.innerHTML=n[r]["menu_order"];var o=i.querySelector(".post_parent");if(null!==o)o.innerHTML=n[r]["post_parent"];var u=null;var a=i.querySelector(".post_title");if(null!==a)u=a.innerHTML;var f=0;while(f<n[r]["depth"]){u="— "+u;f++}var l=i.parentNode.querySelector(".row-title");if(null!==l&&null!==u)l.innerHTML=u}else if(null!==s){s.innerHTML=n[r]}}}if(t.next){jQuery.post(ajaxurl,{action:"simple_page_ordering",id:t.next["id"],previd:t.next["previd"],nextid:t.next["nextid"],start:t.next["start"],excluded:t.next["excluded"]},update_simple_ordering_callback)}else{jQuery(document.querySelector(".spo-updating-row")).removeClass("spo-updating-row");sortable_post_table.removeClass("spo-updating").sortable("enable")}}var sortable_post_table=jQuery(document.querySelector(".wp-list-table tbody"));sortable_post_table.sortable({items:"> tr",cursor:"move",axis:"y",containment:"table.widefat",cancel:".inline-edit-row",distance:2,opacity:.8,tolerance:"pointer",start:function(e,t){if(typeof inlineEditPost!=="undefined"){inlineEditPost.revert()}t.placeholder.height(t.item.height())},update:function(e,t){sortable_post_table.sortable("disable").addClass("spo-updating");t.item.addClass("spo-updating-row");var n=t.item[0].id.substr(5);var r=false;var i=t.item.prev();if(i.length>0){r=i.attr("id").substr(5)}var s=false;var o=t.item.next();if(o.length>0){s=o.attr("id").substr(5)}jQuery.post(ajaxurl,{action:"simple_page_ordering",id:n,previd:r,nextid:s},update_simple_ordering_callback);var u=document.querySelectorAll("tr.iedit"),a=u.length;while(a--){if(a%2==0){jQuery(u[a]).addClass("alternate")}else{jQuery(u[a]).removeClass("alternate")}}}}) -
simple-page-ordering/trunk/simple-page-ordering.php
r720603 r888474 4 4 Plugin URI: http://10up.com/plugins/simple-page-ordering-wordpress/ 5 5 Description: Order your pages and hierarchical post types using drag and drop on the built in page list. For further instructions, open the "Help" tab on the Pages screen. 6 Version: 2. 1.26 Version: 2.2 7 7 Author: Jake Goldman, 10up 8 8 Author URI: http://10up.com … … 10 10 */ 11 11 12 if ( ! class_exists( 'Simple_Page_Ordering' ) ) : 13 12 14 class Simple_Page_Ordering { 13 15 14 public function __construct() { 15 add_action( 'load-edit.php', array( $this, 'load_edit_screen' ) ); 16 add_action( 'wp_ajax_simple_page_ordering', array( $this, 'ajax_simple_page_ordering' ) ); 17 } 18 19 public function load_edit_screen() { 16 /** 17 * Handles initializing this class and returning the singleton instance after it's been cached. 18 * 19 * @return null|Simple_page_Ordering 20 */ 21 public static function get_instance() { 22 // Store the instance locally to avoid private static replication 23 static $instance = null; 24 25 if ( null === $instance ) { 26 $instance = new self(); 27 self::_add_actions(); 28 } 29 30 return $instance; 31 } 32 33 /** 34 * An empty constructor 35 */ 36 public function __construct() { /* Purposely do nothing here */ } 37 38 /** 39 * Handles registering hooks that initialize this plugin. 40 */ 41 public static function _add_actions() { 42 add_action( 'load-edit.php', array( __CLASS__, 'load_edit_screen' ) ); 43 add_action( 'wp_ajax_simple_page_ordering', array( __CLASS__, 'ajax_simple_page_ordering' ) ); 44 } 45 46 /** 47 * Load up page ordering scripts for the edit screen 48 */ 49 public static function load_edit_screen() { 20 50 $screen = get_current_screen(); 21 51 $post_type = $screen->post_type; … … 23 53 // is post type sortable? 24 54 $sortable = ( post_type_supports( $post_type, 'page-attributes' ) || is_post_type_hierarchical( $post_type ) ); // check permission 25 if ( ! $sortable = apply_filters( 'simple_page_ordering_is_sortable', $sortable, $post_type ) ) 55 if ( ! $sortable = apply_filters( 'simple_page_ordering_is_sortable', $sortable, $post_type ) ) { 26 56 return; 57 } 27 58 28 59 // does user have the right to manage these post objects? 29 if ( ! $this->check_edit_others_caps( $post_type ) )60 if ( ! self::check_edit_others_caps( $post_type ) ) { 30 61 return; 31 32 add_filter( 'views_' . $screen->id, array( $this, 'sort_by_order_link' ) ); // add view by menu order to views 33 add_action( 'wp', array( $this, 'wp' ) ); 34 add_action( 'admin_head', array( $this, 'admin_head' ) ); 35 } 36 37 public function wp() { 38 if ( 0 === strpos( get_query_var('orderby'), 'menu_order' ) ) { // we can only sort if we're organized by menu order 62 } 63 64 add_filter( 'views_' . $screen->id, array( __CLASS__, 'sort_by_order_link' ) ); // add view by menu order to views 65 add_action( 'wp', array( __CLASS__, 'wp' ) ); 66 add_action( 'admin_head', array( __CLASS__, 'admin_head' ) ); 67 } 68 69 /** 70 * when we load up our posts query, if we're actually sorting by menu order, initialize sorting scripts 71 */ 72 public static function wp() { 73 if ( 0 === strpos( get_query_var('orderby'), 'menu_order' ) ) { 39 74 $script_name = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? 'simple-page-ordering.dev.js' : 'simple-page-ordering.js'; 40 75 wp_enqueue_script( 'simple-page-ordering', plugins_url( $script_name, __FILE__ ), array('jquery-ui-sortable'), '2.1', true ); … … 43 78 } 44 79 45 public function admin_head() { 80 /** 81 * Add page ordering help to the help tab 82 */ 83 public static function admin_head() { 46 84 $screen = get_current_screen(); 47 85 $screen->add_help_tab(array( … … 52 90 } 53 91 54 public function ajax_simple_page_ordering() {92 public static function ajax_simple_page_ordering() { 55 93 // check and make sure we have what we need 56 if ( empty( $_POST['id'] ) || ( !isset( $_POST['previd'] ) && !isset( $_POST['nextid'] ) ) ) 94 if ( empty( $_POST['id'] ) || ( !isset( $_POST['previd'] ) && !isset( $_POST['nextid'] ) ) ) { 57 95 die(-1); 96 } 58 97 59 98 // real post? 60 if ( ! $post = get_post( $_POST['id'] ) ) 99 if ( ! $post = get_post( $_POST['id'] ) ) { 61 100 die(-1); 101 } 62 102 63 103 // does user have the right to manage these post objects? 64 if ( ! $this->check_edit_others_caps( $post->post_type ) )104 if ( ! self::check_edit_others_caps( $post->post_type ) ) { 65 105 die(-1); 106 } 66 107 67 108 // badly written plug-in hooks for save post can break things 68 if ( ! defined( 'WP_DEBUG' ) || !WP_DEBUG )109 if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) { 69 110 error_reporting( 0 ); 111 } 70 112 71 113 $previd = empty( $_POST['previd'] ) ? false : (int) $_POST['previd']; … … 91 133 } 92 134 // if the next post's parent isn't our parent, it might as well be false (irrelevant to our query) 93 if ( $next_post_parent !== $parent_id ) 135 if ( $next_post_parent !== $parent_id ) { 94 136 $nextid = false; 137 } 95 138 96 139 $max_sortable_posts = (int) apply_filters( 'simple_page_ordering_limit', 50 ); // should reliably be able to do about 50 at a time 97 if ( $max_sortable_posts < 5 ) // don't be ridiculous!140 if ( $max_sortable_posts < 5 ) { // don't be ridiculous! 98 141 $max_sortable_posts = 50; 142 } 99 143 100 144 // we need to handle all post stati, except trash (in case of custom stati) … … 124 168 125 169 // don't handle the actual post 126 if ( $sibling->ID === $post->ID ) 170 if ( $sibling->ID === $post->ID ) { 127 171 continue; 172 } 128 173 129 174 // if this is the post that comes after our repositioned post, set our repositioned post position and increment menu order … … 211 256 } 212 257 213 public function sort_by_order_link( $views ) { 258 /** 259 * Append a sort by order link to the post actions 260 * 261 * @param string $views 262 * @return string 263 */ 264 public static function sort_by_order_link( $views ) { 214 265 $class = ( get_query_var('orderby') == 'menu_order title' ) ? 'current' : ''; 215 266 $query_string = remove_query_arg(array( 'orderby', 'order' )); … … 222 273 * Checks to see if the current user has the capability to "edit others" for a post type 223 274 * 224 * @param (string)$post_type Post type name225 * @return (bool)True or false226 */ 227 p ublic function check_edit_others_caps( $post_type ) {275 * @param string $post_type Post type name 276 * @return bool True or false 277 */ 278 private static function check_edit_others_caps( $post_type ) { 228 279 $post_type_object = get_post_type_object( $post_type ); 229 280 $edit_others_cap = empty( $post_type_object ) ? 'edit_others_' . $post_type . 's' : $post_type_object->cap->edit_others_posts; … … 232 283 } 233 284 234 $simple_page_ordering = new Simple_Page_Ordering; 285 Simple_Page_Ordering::get_instance(); 286 287 endif;
Note: See TracChangeset
for help on using the changeset viewer.