Changeset 1723652
- Timestamp:
- 09/02/2017 01:15:13 PM (9 years ago)
- Location:
- admin-collapse-subpages/trunk
- Files:
-
- 8 edited
-
admin_collapse_subpages.php (modified) (4 diffs)
-
css/style.css (modified) (1 diff)
-
js/admin_collapse_subpages.js (modified) (2 diffs)
-
readme.txt (modified) (4 diffs)
-
screenshot-1.png (modified) (previous)
-
screenshot-2.png (modified) (previous)
-
screenshot-3.png (modified) (previous)
-
screenshot-4.png (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
admin-collapse-subpages/trunk/admin_collapse_subpages.php
r1022208 r1723652 2 2 /* 3 3 Plugin Name: Admin Collapse Subpages 4 Plugin URI: http ://cloudspier.com/admin-collapse-subpages/4 Plugin URI: https://bravokeyl.com/admin-collapse-subpages/ 5 5 Description: Using this plugin one can easily collapse/expand pages / custom post types with children and grand children. 6 6 Author: Alex Chalupka 7 Author URI: http ://cloudspier.com8 Version: 2. 37 Author URI: https://bravokeyl.com 8 Version: 2.4 9 9 Text Domain: admin-collapse-subpages 10 10 Domain Path: /languages … … 16 16 the Free Software Foundation, either version 2 of the License, or 17 17 any later version. 18 18 19 19 Admin Collapse Subpages is distributed in the hope that it will be useful, 20 20 but WITHOUT ANY WARRANTY; without even the implied warranty of 21 21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 22 GNU General Public License for more details. 23 23 24 24 You should have received a copy of the GNU General Public License 25 25 along with Admin Collapse Subpages. If not, see http://www.gnu.org/licenses/gpl-2.0.html. … … 30 30 31 31 class Admin_Collapse_Subpages { 32 32 33 33 function __construct() { 34 34 35 35 function acs_textdomain() { 36 36 load_plugin_textdomain( 'admin-collapse-subpages', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' ); 37 37 } 38 38 add_action( 'plugins_loaded', 'acs_textdomain' ); 39 39 40 40 function acs_scripts(){ 41 41 global $pagenow; 42 42 43 if(isset($_GET['post_type']) ) { 44 $post_type = $_GET['post_type']; 45 if(is_post_type_hierarchical($post_type)) { 46 add_filter( 'admin_body_class', 'acs_admin_body_class' ); 47 } 48 49 function acs_admin_body_class( $classes ) 50 { 43 if(isset($_GET['post_type']) || isset($_GET['taxonomy'])) { 44 if(isset($_GET['post_type'])) { 45 $post_type = $_GET['post_type']; 46 if(is_post_type_hierarchical($post_type)) { 47 add_filter( 'admin_body_class', 'acs_admin_body_class' ); 48 } 49 } 50 if(isset($_GET['taxonomy']) && isset($_GET['taxonomy']) == 'category') { 51 add_filter( 'admin_body_class', 'acs_admin_body_class' ); 52 } 53 function acs_admin_body_class( $classes ) { 51 54 $classes .= ' ' .'acs-hier'; 52 55 return $classes; 53 56 } 57 } 54 58 55 } 56 57 if ( is_admin() && isset($_GET['post_type']) && $pagenow =='edit.php' ) { 58 59 if ( is_admin() && ( (isset($_GET['post_type']) && $pagenow =='edit.php') || $pagenow =='edit-tags.php' ) ) { 60 59 61 //make sure jquery is loaded 60 62 wp_enqueue_script('jquery'); 61 62 //cookie script for saving collapse states 63 wp_enqueue_script('jquery-cookie', plugins_url('js/jquery.cookie.js', __FILE__ ), 'jquery', '1.4.0'); 64 63 65 64 //main collapse pages script 66 wp_enqueue_script('acs-js',plugins_url('js/a dmin_collapse_subpages.js', __FILE__ ), false, '2.0');67 65 wp_enqueue_script('acs-js',plugins_url('js/acs.js', __FILE__ ), array('jquery'), '2.0'); 66 68 67 //Load Styles 69 68 wp_enqueue_style('acs-css', plugins_url('css/style.css', __FILE__ ), false, '2.0', 'screen'); … … 80 79 81 80 } 82 81 83 82 global $collapsePages; 84 83 $collapsePages = new Admin_Collapse_Subpages(); 85 84 } 86 87 ?> -
admin-collapse-subpages/trunk/css/style.css
r874297 r1723652 1 /* simple styles for +/- links */ 2 3 .expand_link a{ 4 display:inline-block; 5 width: 16px; 6 height: 16px; 7 margin:0 0 0 10px; 8 text-indent: -9999px; 9 background: url(../images/plus.png) no-repeat top left transparent; 10 padding:2px; 1 .expand_link a { 2 display: inline-block; 3 font-family: dashicons; 4 font-size: 16px; 5 line-height: 1; 6 height: 16px; 7 width: 16px; 8 margin: 0 0 0 10px; 9 vertical-align: middle; 11 10 } 12 13 .expand_link a.minus{ 14 background: url(../images/minus.png) no-repeat top left transparent; 11 .expand_link a:before { 12 content: "\f132"; 15 13 } 14 .expand_link a.minus:before { 15 content: "\f460"; 16 } -
admin-collapse-subpages/trunk/js/admin_collapse_subpages.js
r1022208 r1723652 2 2 * Collapse Sub Pages 3 3 */ 4 4 5 5 jQuery().ready(function($){ 6 6 … … 10 10 * Add Expand/Collapse ALL Links to DOM (has to be first for listeners) 11 11 */ 12 jQuery(' .acs-hier .subsubsub').append(links); 12 jQuery(' .acs-hier .subsubsub').append(links); 13 13 14 14 /* 15 15 * Initial loading 16 16 */ 17 initial_collapse_work();18 reset_listeners();19 17 //initial_collapse_work(); 18 //reset_listeners(); 19 20 20 /* 21 21 * Does all initial stuff (adding plus/minus buttons, adding top links, perform initial collapse) 22 */ 22 */ 23 23 function initial_collapse_work(){ 24 24 25 25 /* 26 26 * Loop through to add parent and post-id data 27 */ 28 29 jQuery('.pages #the-list tr').each(function(){ 30 27 */ 28 29 jQuery('.pages #the-list tr').each(function(){ 30 31 31 var parent = jQuery(this).find('.post_parent').html(); 32 32 var id = jQuery(this).find('[name="post[]"]').attr('value'); 33 33 34 34 jQuery(this).attr('data-parent', parent); 35 35 jQuery(this).attr('data-post-id', id); 36 36 jQuery(this).attr('data-collapsed', 0); 37 38 }); 39 37 38 }); 39 40 40 /* 41 41 * Loop through again to add +/- as needed 42 42 */ 43 43 jQuery('.pages #the-list tr').each(function(){ 44 44 45 45 var id = jQuery(this).find('[name="post[]"]').attr('value'); 46 47 if(jQuery('#the-list').find('[data-parent="' + id + '"]'). size()> 0)48 jQuery(this).find('.page-title strong').append('<span class="expand_link"><a href="javascript:void(0);" class="minus">[children]</a></span>'); 49 }); 50 46 47 if(jQuery('#the-list').find('[data-parent="' + id + '"]').length > 0) 48 jQuery(this).find('.page-title strong').append('<span class="expand_link"><a href="javascript:void(0);" class="minus">[children]</a></span>'); 49 }); 50 51 51 /* 52 52 * Collapse from cookie to start with 53 53 */ 54 54 collapse_from_cookie(); 55 56 57 } 58 55 56 57 } 58 59 59 function reset_listeners() 60 60 { 61 61 /* 62 62 * Called on click, expands and contracts pages by calling functions below 63 */ 63 */ 64 64 jQuery('.expand_link').click(function(){ 65 66 var row = jQuery(this).closest('tr'); 65 66 var row = jQuery(this).closest('tr'); 67 67 var post_id = row.attr('data-post-id'); 68 69 jQuery(this).children('a').toggleClass('minus'); 70 68 69 jQuery(this).children('a').toggleClass('minus'); 70 71 71 if(row.attr('data-collapsed') == 0) 72 { 72 { 73 73 //make cookie here 74 add_to_cookie(post_id); 75 74 add_to_cookie(post_id); 75 76 76 collapse_subpages(post_id); 77 77 row.attr('data-collapsed', 1); 78 78 } 79 79 else 80 { 80 { 81 81 //remove from cookie if exists 82 82 remove_from_cookie(post_id); 83 83 84 84 expand_subpages(post_id); 85 85 row.attr('data-collapsed', 0); 86 } 87 }); 88 86 } 87 }); 88 89 89 /* 90 90 * Called on click when "Quick Update" is used 91 */ 91 */ 92 92 jQuery('.inline-edit-save .save').click(function(){ 93 93 94 94 /* 95 * delay before reset, allows WordPress to finish reseting rows 95 * delay before reset, allows WordPress to finish reseting rows 96 96 * (not ideal, but the "Quick Edit" is a little wonky to begin with) 97 97 */ 98 98 setTimeout(function(){ 99 99 100 100 //console.log(jQuery('#the-list tr')); 101 101 102 102 jQuery('#the-list tr').show(); 103 103 jQuery('.expand_link').remove(); 104 104 105 105 //redo collapses 106 initial_collapse_work(); 106 initial_collapse_work(); 107 107 reset_listeners(); 108 108 109 }, 1000); 110 111 }); 112 109 }, 1000); 110 111 }); 112 113 113 /* 114 114 * Expand and collapse all links 115 */ 115 */ 116 116 jQuery('.expand_all_link a').click(function(){ 117 117 expand_all(); 118 }); 118 }); 119 119 jQuery('.collapse_all_link a').click(function(){ 120 120 collapse_all(); 121 }); 122 } 123 121 }); 122 } 123 124 124 function collapse_all() 125 { 126 jQuery('.pages #the-list tr').each(function(){ 127 128 var post_id = jQuery(this).attr('data-post-id'); 129 125 { 126 jQuery('.pages #the-list tr').each(function(){ 127 128 var post_id = jQuery(this).attr('data-post-id'); 129 130 130 if(jQuery(this).attr('data-collapsed') == 0) 131 { 131 { 132 132 //make cookie here 133 add_to_cookie(post_id); 134 133 add_to_cookie(post_id); 134 135 135 collapse_subpages(post_id); 136 136 jQuery(this).attr('data-collapsed', 1).find('.expand_link a').toggleClass('minus'); 137 138 } 139 }); 140 } 137 138 } 139 }); 140 } 141 141 function expand_all() 142 142 { 143 143 jQuery('.pages #the-list tr').each(function(){ 144 145 var post_id = jQuery(this).attr('data-post-id'); 146 144 145 var post_id = jQuery(this).attr('data-post-id'); 146 147 147 if(jQuery(this).attr('data-collapsed') == 1) 148 { 148 { 149 149 //remove from cookie if exists 150 150 remove_from_cookie(post_id); 151 151 152 152 expand_subpages(post_id); 153 153 jQuery(this).attr('data-collapsed', 0).find('.expand_link a').toggleClass('minus'); 154 } 155 }); 156 } 157 154 } 155 }); 156 } 157 158 158 /* 159 159 * Two recursive functions that show/hide the table rows 160 */ 160 */ 161 161 function collapse_subpages(parent_id) 162 { 162 { 163 163 jQuery('#the-list').find('[data-parent="' + parent_id + '"]').each(function(){ 164 164 165 165 jQuery(this).hide(); 166 167 collapse_subpages(jQuery(this).attr('data-post-id')); 168 }); 169 } 166 167 collapse_subpages(jQuery(this).attr('data-post-id')); 168 }); 169 } 170 170 function expand_subpages(parent_id) 171 { 171 { 172 172 jQuery('#the-list').find('[data-parent="' + parent_id + '"]').each(function(){ 173 173 174 174 jQuery(this).show(); 175 175 176 176 //does not unhide rows if group was previously hidden 177 177 if(jQuery(this).attr('data-collapsed') == 0) 178 178 expand_subpages(jQuery(this).attr('data-post-id')); 179 179 }); 180 } 180 } 181 181 182 182 /* 183 183 * Add value to cookie 184 */ 184 */ 185 185 function add_to_cookie(row_id) 186 186 { 187 187 var cookie = $.cookie('collapsed'); 188 188 var values; 189 190 if(cookie){ 189 190 if(cookie){ 191 191 values = cookie.split(','); 192 192 if(jQuery.inArray(row_id, values) == -1) 193 values.push(row_id); 194 }else{ 195 values = new Array(row_id); 196 } 197 193 values.push(row_id); 194 }else{ 195 values = new Array(row_id); 196 } 197 198 198 $.cookie('collapsed',values); 199 199 200 200 } 201 201 202 202 /* 203 203 * Remove value from cookie 204 */ 204 */ 205 205 function remove_from_cookie(row_id) 206 206 { 207 207 var cookie = $.cookie('collapsed'); 208 208 var values; 209 210 if(cookie){ 209 210 if(cookie){ 211 211 values = cookie.split(','); 212 212 213 213 values = jQuery.grep(values, function(value) { 214 214 return value != row_id; 215 }); 216 215 }); 216 217 217 $.cookie('collapsed',values); 218 219 } 218 219 } 220 220 } 221 221 222 222 /* 223 223 * Read cookie and expand pages as needed 224 */ 224 */ 225 225 function collapse_from_cookie() 226 226 { 227 227 var cookie = $.cookie('collapsed'); 228 228 var values; 229 230 if(cookie){ 229 230 if(cookie){ 231 231 values = cookie.split(','); 232 232 233 233 jQuery.each(values,function(index, value){ 234 234 jQuery('#the-list').find('[data-post-id="' + value + '"]').attr('data-collapsed', 1).find('.expand_link a').toggleClass('minus'); 235 }); 235 }); 236 236 237 237 jQuery.each(values,function(index, value){ 238 238 collapse_subpages(value); 239 }); 240 } 239 }); 240 } 241 241 } 242 242 -
admin-collapse-subpages/trunk/readme.txt
r1532930 r1723652 1 1 === Admin Collapse Subpages === 2 Contributors: lupka , bravokeyl3 Donate link: http ://alexchalupka.com/donate2 Contributors: bravokeyl, lupka 3 Donate link: https://bravokeyl.com/contact/ 4 4 Tags: page, post, links,pages, admin , link ,plugin, random, posts, widget, categories, date, date range, timeframe, excerpt, randomize, sidebar, category 5 Requires at least: 3.06 Tested up to: 4. 6.15 Requires at least: 4.6 6 Tested up to: 4.8.1 7 7 Stable tag: trunk 8 8 License: GPLv2 or later … … 15 15 Simple plugin that allows you to collapse subpages in the Pages admin list also for custom post types that are heirarchial. Especially helpful if you have a ton of pages /cpt's with heiararchial set to true. It uses a cookie to save the expand/collapse status of your pages. 16 16 17 This is loosely based on Collapse Sub-Pages by Dan Dietz, which broke with the 3.0 upgrade due to UI changes and hasn't been updated. I've had to rewrite the jQuery to make it work with 3.x versions. 17 This is loosely based on Collapse Sub-Pages by Dan Dietz, which broke with the 3.0 upgrade due to UI changes and hasn't been updated. I've had to rewrite the jQuery to make it work with 3.x versions. 18 18 19 19 Because this is a jQuery, it's possible that they could make additional changes that would break it. I'll do my best to stay on top of it, but let me know if it stops working. … … 23 23 From version 2.3 our plugin supports internationalization, which means you can have plugin in your specified language. 24 24 25 It's currently available in US English ,UK Engli h, Chinese, Telugu , Serbian.25 It's currently available in US English ,UK English, Chinese, Telugu , Serbian. 26 26 27 27 <h3>Support us by Translating</h3> … … 59 59 == Changelog == 60 60 61 = 1.0 = 62 * Initial version of the plugin 61 = 2.4 = 62 63 ** New 64 65 * Added support for category pages 66 67 ** Changed 68 69 * Used localStorage instead of jquery.cookie 70 * Used dashicons for plus/minus instead of images 71 72 = 2.1 = 73 * Added support custom post types which are hierarchical 63 74 64 75 = 2.0 = 65 76 * Fixed bug - Adding expand/collapse links to all list tables 66 77 * Updated jquery.cookie.js to 1.4.0 67 * Enhanced loading of scripts and styles 68 = 2.1 = 69 * Added support custom post types which are hieararchial 78 * Enhanced loading of scripts and styles 79 80 = 1.0 = 81 * Initial version of the plugin 82 70 83 == Upgrade Notice == 71 84 72 = 1.0 = 73 * N/A 74 = 2.0 = 75 * Enjoy !! 76 = 2.1 = 77 * Added support custom post types which are hieararchial 78 = 2.1 = 79 * Added support custom post types which are hieararchial 80 = 2.3 = 81 * Internationalizing the plugin 85 * Nothing to worry
Note: See TracChangeset
for help on using the changeset viewer.