• Resolved madaplus

    (@madaplus)


    Hey

    This is completely annoying. We gave a secondary title to 222 projects and they all renamed themselves to follow other project posts. And when we try to edit them with quick edit, they dont update. They only update if we edit them in the full page ‘Edit’ of the post.

    Huge problem…any thoughts?

    Adam

    https://www.ads-software.com/plugins/secondary-title/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author thaikolja

    (@thaikolja)

    Hi there,

    it’s true, there’s a small bug when it comes to the “quick edit” function, mainly because WP is a bit limited when it comes to extending “quick edit”. I’ll see what I can do for the next release.

    Hi,
    had the same problem. I fixed it for me locally and would really appreciate if you included it into your code.

    hooks.php (add it)

    /**
    	 * Add a custom input field to the quick edit menu
    	 */
    	function secondary_title_quick_edit_custom_box($column_name, $post_type){
    
    		// return early for all columns not owned by us
    		if( $column_name !== 'secondary_title')
    			return;
    
    		// quite the same like secondary_title_overview_quick_edit() but class name differs
    		echo '<label class="my-secondary-title-quick-edit-label">';
    		echo '<span class="title">' . __("Sec. title", "secondary_title") . '</span>';
    		// no value here (will be inserted on click on a.editinline)
    		echo '<span class="input-text-wrap"><input type="text" name="secondary_title" value="" /></span>';
    		echo "</label>";
    
    	}
    
    	add_action('quick_edit_custom_box',  'secondary_title_quick_edit_custom_box', 10, 2);

    admin.js (modify)

    /**
    		 * Add the "Sec. title" input field to the quick edit.
    		 */
    		jQuery('tr#inline-edit td .inline-edit-col-left > .inline-edit-col > label').eq(0).after(jQuery('.my-secondary-title-quick-edit-label'));
    
    		/**
    		 * Scripts executed on post overview page.
    		 */
    		if(jQuery(".edit-php").length > 0) {
    			jQuery("a.editinline").click(
    				function() {
    					var postId = jQuery(this).parents("tr").attr("id").replace("post-", "");
    					// var secondaryTitle = jQuery(".my-secondary-title-quick-edit-label").clone();
    					setTimeout(
    						function() {
    							// jQuery("#edit-" + postId).find(".inline-edit-col label:first").after(secondaryTitle).show();
    							jQuery("#edit-" + postId).find(".my-secondary-title-quick-edit-label input").val(
    								jQuery('#post-' + postId).find('.secondary_title').text()
    							);
    						}, 50
    					);
    				}
    			);
    		}

    Plugin Author thaikolja

    (@thaikolja)

    Hi Simne7,

    I really apprecite your effort and review the code and ten oribably inculde it in the next version with a reference to your name again.

    thaikolja

    Plugin Author thaikolja

    (@thaikolja)

    @simne7: I’ve implemented the fix. However, it still contains one bug that I’ve been struggling to get solved for weeks: When clicking the “quick edit”, changing the value and then saving, the jQuery(“a.editinline”).click() is no longer being triggered. Do you have the same issue? I’m using Chrome, latest version.

    Hey,
    sorry, I’ve been quite busy. Hm, yes, I experience the same error under Firefox. I’ll have a look.

    The problem was that clicking “update” in the quick-edit view triggers a re-creation of the row for page/post. Thus the handler gets killed. But if we use a delegated handler it works again

    /**
     * Scripts executed on post overview page.
     */
    if(jQuery(".edit-php").length > 0) {
    	jQuery('#the-list').on('click', 'a.editinline',	function() {
    			var postId = jQuery(this).parents("tr").attr("id").replace("post-", "");
    			// var secondaryTitle = jQuery(".my-secondary-title-quick-edit-label").clone();
    			setTimeout(
    				function() {
    					// jQuery("#edit-" + postId).find(".inline-edit-col label:first").after(secondaryTitle).show();
    							jQuery("#edit-" + postId).find(".my-secondary-title-quick-edit-label input").val(
    								jQuery('#post-' + postId).find('.secondary_title').text()
    					);
    				}, 50
    			);
    		}
    	);
    }

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘quick edit displays wrong secondary title and wont update’ is closed to new replies.