name = esc_html__( 'Fields', 'wpforms-lite' );
$this->slug = 'fields';
$this->icon = 'fa-list-alt';
$this->order = 10;
$this->sidebar = true;
if ( $this->form ) {
add_action( 'wpforms_builder_fields', array( $this, 'fields' ) );
add_action( 'wpforms_builder_fields_options', array( $this, 'fields_options' ) );
add_action( 'wpforms_builder_preview', array( $this, 'preview' ) );
// Template for form builder previews.
add_action( 'wpforms_builder_print_footer_scripts', array( $this, 'field_preview_templates' ) );
}
}
/**
* Enqueue assets for the Fields panel.
*
* @since 1.0.0
*/
public function enqueues() {
// CSS.
wp_enqueue_style(
'wpforms-builder-fields',
WPFORMS_PLUGIN_URL . 'assets/css/admin-builder-fields.css',
null,
WPFORMS_VERSION
);
}
/**
* Output the Field panel sidebar.
*
* @since 1.0.0
*/
public function panel_sidebar() {
// Sidebar contents are not valid unless we have a form.
if ( ! $this->form ) {
return;
}
?>
form ); ?>
form ); ?>
form ) {
echo '
';
echo wp_kses(
__( 'You need to setup your form before you can manage the fields.', 'wpforms-lite' ),
array(
'a' => array(
'href' => array(),
'class' => array(),
'data-panel' => array(),
),
)
);
echo '
';
}
}
/**
* No fields options markup.
*
* @since 1.6.0
*/
public function no_fields_options() {
printf(
'
%s
',
esc_html__( 'You don\'t have any fields yet.', 'wpforms-lite' )
);
}
/**
* No fields preview placeholder markup.
*
* @since 1.6.0
*/
public function no_fields_preview() {
printf(
'
%1$s
%2$s
',
esc_html__( 'You don\'t have any fields yet. Add some!', 'wpforms-lite' ),
esc_html__( 'Take your pick from our wide variety of fields and start building out your form!', 'wpforms-lite' )
);
}
/**
* Sort Add Field buttons by order provided.
*
* @since 1.0.0
*
* @param array $a
* @param array $b
*
* @return array
*/
public function field_order( $a, $b ) {
return $a['order'] - $b['order'];
}
/**
* Template for form builder preview.
*
* @since 1.4.5
*/
public function field_preview_templates() {
// phpcs:disable WordPress.WP.I18n
// Checkbox, Radio, and Payment Multiple/Checkbox field choices.
?>