Support » Fixing WordPress » WordPress 5.5 had destroyed my ever surviving CPT with custom Metabox

  • Resolved hsupyaenaung

    (@hsupyaenaung)


    Years back, I had built this custom Metabox (by fusing tons of codes) for my custom post type that allows repeatable field as ACF did not allow to use repeatable fields for free back then. It was doing well with WP upgrades since 2015. However, this recent WP 5.5 kind of broke many of its functions.

    I can no longer access to localisation tab integrated with “WP Multilang” plugin for some of my custom post types.

    Those that aren’t working uses my custom metabox. So I believe it has problems with my custom metabox.

    I am a self-taught web designer/programmer who survived many ‘code wars’ by burning hours of my life searching for answer at google. So this seems beyond my capabilities. :/

    When I downgrade the wordpress at my test server, it’s working just fine.
    Here are the photo as attached.

    OLD VER
    https://ibb.co/NCMXfk9
    NEW VER
    https://ibb.co/Z6GSPHQ

    • This topic was modified 8 months, 1 week ago by hsupyaenaung.
    • This topic was modified 8 months, 1 week ago by hsupyaenaung.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    Please try installing https://wordpress.org/plugins/enable-jquery-migrate-helper/ to see if that fixes the issue.

    Thread Starter hsupyaenaung

    (@hsupyaenaung)

    Oh yes~!

    Thanks Steven. This temporarily solved the issue and starts to show the log. But I am not sure how I can fix it still. The log is as follows:

    metabox/admin/js/scripts.js:130:36): jQuery.fn.live() is deprecated
    metabox/admin/js/scripts.js:172:32): jQuery.fn.live() is deprecated

    So WP no longer supports jQuery.fn.live() ? is there any alternatives?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    I’m no javascript guy. Is this in your code?

    Thread Starter hsupyaenaung

    (@hsupyaenaung)

    Same.. I rarely noodle around with java unless it is really neccessary.

    And yes, here are the 2 regarding the log.

    		$('.meta_box_repeatable_remove').live('click', function () {
    			$(this).closest('tr').remove();
    			return false;
    		});
    
    	// repeatable fields
    	$('.meta_box_repeatable_add').live('click', function (e) {
    		// clone
    		e.preventDefault();
    		var row = $(this).closest('.meta_box_repeatable').find('tbody tr:last-child');
    		var clone = row.clone();
    		clone.find('select.chosen').removeAttr('style','').removeAttr('id','').removeClass('chzn-done').data('chosen', null).next().remove();
    		clone.find('input.regular-text, textarea, select, .meta_box_upload_file ').val('');
    		clone.find('input[type=checkbox], input[type=radio]').attr('checked', false);
    		clone.find('span.meta_box_filename').html('');
    
    		/** = i have to restore functionality of buttons
    		 */
    		var clndbtn = clone.find('.meta_box_upload_file_button');
    		var clndbtnimg = clone.find('.meta_box_upload_image_button');
    		var cleanImgFieldBtn = clone.find('.meta_box_clear_image_button');
    
    		clone.find('img.meta_box_preview_image').attr('src','');
    
    		addUploaderFunctionToButton(clndbtn);
    		addImageuploaderFunctionToButton(clndbtnimg);
    		clearImgField(cleanImgFieldBtn);
    
    		row.after(clone);
    		// increment name and id
    		clone.find('input, textarea, select')
    				.attr('name', function (index, name) {
    					return name.replace(/(\d+)/, function (fullMatch, n) {
    						return Number(n) + 1;
    					});
    				});
    
    		var arr = [];
    
    		$('input.repeatable_id:text').each(function () {
    			arr.push($(this).val());
    		});
    		clone.find('input.repeatable_id')
    				.val(Number(Math.max.apply(Math, arr)) + 1);
    		if (!!$.prototype.chosen) {
    			clone.find('select.chosen')
    					.chosen({allow_single_deselect: true});
    		}
    		//
    		return false;
    	});
    • This reply was modified 8 months, 1 week ago by hsupyaenaung.
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Forum Moderator & Support Team Volunteer

    You should read up on the live() function in jQuery.

    @hsupyaenaung Looking at the code you shared, you should be able to replace all occurrences of .live() with .on() and you should be able to disable the jQuery Migrate Helper plugin. Documentation on .on(): https://api.jquery.com/on/

    Thread Starter hsupyaenaung

    (@hsupyaenaung)

    Hey Jonathan,

    It’s working perfectly after doing that. Thank you so much. I thought it would be needed to do lots of overhaul. I guess that is it. Once again, thanks all for your support.

    I wouldn’t be able to diagnose the cause of this if Steven didn’t direct me to jQuery Migrate Helper plugin as well 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘WordPress 5.5 had destroyed my ever surviving CPT with custom Metabox’ is closed to new replies.