acf_form_widget::admin_footer()publicACF 5.0.0

admin_footer

This function will add some custom HTML to the footer of the edit page

Метод класса: acf_form_widget{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$acf_form_widget = new acf_form_widget();
$acf_form_widget->admin_footer();

Список изменений

С версии 5.0.0 Введена.

Код acf_form_widget::admin_footer() ACF 6.0.4

<?php
function admin_footer() {
	?>
<script type="text/javascript">
(function($) {
	
	// vars
	acf.set('post_id', 'widgets');
	
	// Only initialize visible fields.
	acf.addFilter('find_fields', function( $fields ){

// not templates
$fields = $fields.not('#available-widgets .acf-field');

// not widget dragging in
$fields = $fields.not('.widget.ui-draggable-dragging .acf-field');

// return
return $fields;
	});
	
	// on publish
	$('#widgets-right').on('click', '.widget-control-save', function( e ){

// vars
var $button = $(this);
var $form = $button.closest('form');

// validate
var valid = acf.validateForm({
	form: $form,
	event: e,
	reset: true
});

// if not valid, stop event and allow validation to continue
if( !valid ) {
	e.preventDefault();
	e.stopImmediatePropagation();
}
	});
	
	// show
	$('#widgets-right').on('click', '.widget-top', function(){
var $widget = $(this).parent();
if( $widget.hasClass('open') ) {
	acf.doAction('hide', $widget);
} else {
	acf.doAction('show', $widget);
}
	});
	
	$(document).on('widget-added', function( e, $widget ){

// - use delay to avoid rendering issues with customizer (ensures div is visible)
setTimeout(function(){
	acf.doAction('append', $widget );
}, 100);
	});
	
})(jQuery);	
</script>
	<?php

}