WPIntell

Source evidence

Quick Edit and Admin Columns Problem

Term Menu Order · support · 2014-01-17T11:22:00+00:00

complaintsentiment
mediumseverity
0.92relevance
6replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 25 rows with source links

16.0% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

21 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
ralphonz unresolved
Hi, First of all, thanks for a great plugin. It’s great to find a custom taxonomy order plugin that actually works and doesn’t use a silly drag and drop page… There seems to be a conflict with the admin columns and quick edit fields. It’s not preventing the plugin from working but could be potentially confusing to some using the site admin. The quick edit shows an order field for each additional column that has been added to the taxonomy admin table. For example I’ve added some meta to my custom taxonomy shopp_departments using (this is in my themes’ functions.php): // Register the column for departments meta function department_add_dynamic_hooks() { $taxonomy = 'shopp_department'; add_filter( 'manage_' . $taxonomy . '_custom_column', 'department_taxonomy_rows', 15, 3 ); add_filter( 'manage_edit-' . $taxonomy . '_columns', 'department_taxonomy_columns' ); } add_action( 'admin_init', 'department_add_dynamic_hooks' ); function department_taxonomy_columns( $columns ) { $columns['frontpage'] = __('Front Page', 'rastafairies'); return $columns; } function department_taxonomy_rows( $row, $column_name, $term_id ) { $t_id = $term_id; $meta = get_option( "taxonomy_$t_id" ); if ( 'frontpage' === $column_name ) { if ($meta == true) { return $row . 'Yes'; } else { return $row . 'No'; } } return $row; } The above code results in two order fields being shown in the quick edit, while the first does nothing the second receives the value but neither display the currently set value. I’m also using the Taxonomy Images plugin, which when activated adds yet another order field to the quick edit (as it also adds an admin column). I’m not sure if this is due to my code (and the taxonomy images code) or the code in this plugin and it’s more of a bug than a real problem. Still I think it needs to be addressed. Thanks for all the work on this so far, if i can provide you with any more info please let me know. http://wordpress.org/plugins/term-menu-order/ I solved this problem too, The quick edit function you call in the class needs to check the column name like so: public function quick_edit_menu_order ($column_name, $post_type) { $menu_order_field = '<fieldset><div class="inline-edit-col"><label><span class="title">' . __( 'Order' , 'term-menu-order') . '</span><span class="input-text-wrap"><input class="ptitle" name="'. self::$form_field_name . '" type="text" value="" /></span></label></div></fieldset>'; $menu_order_field .= '<script type="text/javascript"> </script>'; switch ($column_name) { case 'menu_order': echo $menu_order_field; break; } } Please add to the next update! Thanks Thanks for that, ralphonz! It solves the double Order field bug, but I’m still seeing the second part of your issue, namely, the field doesn’t display a currently set value for me even after adding your edits. Note: I’ve also made some changes to my Categories, mainly renaming it and sharing it between regular Posts and some other custom post types, and this issue is happening for me. Hi, Well I think the issue is that it’s not adding in the current value to the quick edit field as per the wordpress codex . That is why the saved order is cleared if the title or slug is changed and no value is entered for the order (in the quick edit) as mentioned in the previous support post on here . Seems like this whole bit of the plugin needs a re-write. I can’t see that the plugin actually loads any of the javascript from the plugins js folder either. The trick it seems is calling the extra bit of javascript (mentioned in the codex) from the footer but i couldn’t get that to work from the NS_TMO_Plugin class as I’m no expert… Any help appreciated! Ok I’ve fixed it! 1. Create the file quick-edit.js in the term-menu-order/js folder 2. Add the following to quick-edit.js you just made: (function($) { // we create a copy of the WP inline edit post function var $wp_inline_edit = inlineEditTax.edit; // and then we overwrite the function with our own code inlineEditTax.edit = function( id ) { // "call" the original WP edit function // we don't want to leave WordPress hanging $wp_inline_edit.apply( this, arguments ); // now we take care of our business // get the post ID var $term_id = 0; if ( typeof( id ) == 'object' ) $term_id = parseInt( this.getId( id ) ); if ( $term_id > 0 ) { // define the edit row var $edit_row = $( '.inline-edit-row' ); var $post_row = $( '#tag-' + $term_id ); // get the data var $menu_order_value = $( '.column-menu_order', $post_row ).html(); // populate the data $( ':input[name="ns_tmo_menu_order"]', $edit_row ).val( $menu_order_value ); } }; })(jQuery); 3. Then add the following code to the bottom of term-menu-order.php add_action('admin_footer-edit-tags.php', 'add_quick_edit_admin_scripts', 10, 1); function add_quick_edit_admin_scripts() { global $pagenow; if($pagenow == 'edit-tags.php' && (isset($_GET['taxonomy'])) && !isset($_GET['action'])) { echo '<script type="text/javascript" src="'. plugins_url('/js/quick-edit.js', __FILE__) .'"></script>'; } } Now that should be working 🙂 Thanks so much for the quick help, Ralphonz! Hopefully this can be rolled in to the next plugin update. Yeah hope it gets updated, I don’t see the developer on here though…

Comments

6 shown
ralphonz 2014-01-18T12:34:00+00:00

I solved this problem too, The quick edit function you call in the class needs to check the column name like so: public function quick_edit_menu_order ($column_name, $post_type) { $menu_order_field = '<fieldset><div class="inline-edit-col"><label><span class="title">' . __( 'Order' , 'term-menu-order') . '</span><span class="input-text-wrap"><input class="ptitle" name="'. self::$form_field_name . '" type="text" value="" /></span></label></div></fieldset>'; $menu_order_field .= '<script type="text/javascript"> </script>'; switch ($column_name) { case 'menu_order': echo $menu_order_field; break; } } Please add to the next update! Thanks

thirdboxcar 2014-01-18T22:52:00+00:00

Thanks for that, ralphonz! It solves the double Order field bug, but I’m still seeing the second part of your issue, namely, the field doesn’t display a currently set value for me even after adding your edits. Note: I’ve also made some changes to my Categories, mainly renaming it and sharing it between regular Posts and some other custom post types, and this issue is happening for me.

ralphonz 2014-01-18T23:03:00+00:00

Hi, Well I think the issue is that it’s not adding in the current value to the quick edit field as per the wordpress codex . That is why the saved order is cleared if the title or slug is changed and no value is entered for the order (in the quick edit) as mentioned in the previous support post on here . Seems like this whole bit of the plugin needs a re-write. I can’t see that the plugin actually loads any of the javascript from the plugins js folder either. The trick it seems is calling the extra bit of javascript (mentioned in the codex) from the footer but i couldn’t get that to work from the NS_TMO_Plugin class as I’m no expert… Any help appreciated!

ralphonz 2014-01-19T09:30:00+00:00

Ok I’ve fixed it! 1. Create the file quick-edit.js in the term-menu-order/js folder 2. Add the following to quick-edit.js you just made: (function($) { // we create a copy of the WP inline edit post function var $wp_inline_edit = inlineEditTax.edit; // and then we overwrite the function with our own code inlineEditTax.edit = function( id ) { // "call" the original WP edit function // we don't want to leave WordPress hanging $wp_inline_edit.apply( this, arguments ); // now we take care of our business // get the post ID var $term_id = 0; if ( typeof( id ) == 'object' ) $term_id = parseInt( this.getId( id ) ); if ( $term_id > 0 ) { // define the edit row var $edit_row = $( '.inline-edit-row' ); var $post_row = $( '#tag-' + $term_id ); // get the data var $menu_order_value = $( '.column-menu_order', $post_row ).html(); // populate the data $( ':input[name="ns_tmo_menu_order"]', $edit_row ).val( $menu_order_value ); } }; })(jQuery); 3. Then add the following code to the bottom of term-menu-order.php add_action('admin_footer-edit-tags.php', 'add_quick_edit_admin_scripts', 10, 1); function add_quick_edit_admin_scripts() { global $pagenow; if($pagenow == 'edit-tags.php' && (isset($_GET['taxonomy'])) && !isset($_GET['action'])) { echo '<script type="text/javascript" src="'. plugins_url('/js/quick-edit.js', __FILE__) .'"></script>'; } } Now that should be working 🙂

thirdboxcar 2014-01-20T20:26:00+00:00

Thanks so much for the quick help, Ralphonz! Hopefully this can be rolled in to the next plugin update.

ralphonz 2014-01-20T22:36:00+00:00

Yeah hope it gets updated, I don’t see the developer on here though…