Make Categories and Tags required in admin

The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to this:

function my_publish_admin_hook(){
if(is_admin())
{
    echo"               
    <script language=\"javascript\" type=\"text/javascript\">
        jQuery(document).ready(function() {
            jQuery('#publish').click(function() {

                var form_data = jQuery('#post').serializeArray();
                form_data = jQuery.param(form_data);
                var data = {
                    action: 'my_pre_submit_validation',
                    security: '";echo wp_create_nonce( 'pre_publish_validation' ); echo"',
                    form_data: form_data
                };
                jQuery.post(ajaxurl, data, function(response) {
                    if (response=='true') {
                        jQuery('#ajax-loading').hide();
                        jQuery('#publish').removeClass('button-primary-disabled');
            jQuery('#post').submit();
                    }else{
                        alert('Correggi i seguenti errori: ' + response);
                        jQuery('#ajax-loading').hide();
                        jQuery('#publish').removeClass('button-primary-disabled');
                        return false;
                    }
                });
                return false;
            });
        });
    </script>
    ";
    }
}

Leave a Comment