field */ public function __construct( $id, $field, $apply_hooks = true ) { $this->id = $id; $this->field = $field; $this->identifier = wp_generate_uuid4(); if ( $apply_hooks && method_exists( $this, 'hooks' ) ) { $this->hooks(); } } /** * Get Field HTML. * * @param boolean $return * * @return string */ abstract public function get_field_html( $return = false ); /** * Undocumented function * * @return void */ private function _get_field_html() { if ( ! empty( $this->field['custom_input'] ) ) { do_action( $this->id . '-settings-field-html-' . $this->field['key'], $this->field ); } else { $this->get_field_html(); } } /** * Get Custom Attributes HTML. * * @return void */ protected function custom_attributes_html( $attrs_key = 'attrs', $additional_attrs = array() ) { $attributes = ''; $attrs = array_merge( $this->field[ $attrs_key ] ?? array(), $additional_attrs ); if ( $attrs ) { foreach ( $attrs as $key => $value ) { $attributes .= esc_attr( $key ) . '="' . esc_attr( $value ) . '" '; } } if ( ! empty( $attributes ) ) { echo wp_kses_post( $attributes ); } } /** * Field Name * * @return void */ protected function field_name() { if ( ! empty( $this->field['noname'] ) ) { return; } echo esc_attr( 'name' ) . '="' . esc_attr( ! empty( $this->field['name'] ) ? $this->field['name'] : $this->id . ( ! empty( $this->field['variation_id'] ) ? '[' . absint( esc_attr( $this->field['variation_id'] ) ) . ']' : '' ) . '[' . $this->field['key'] . ']' . ( ! empty( $this->field['subkey'] ) ? '[' . $this->field['subkey'] . ']' : '' ) . ( ! empty( $this->field['multiple'] ) ? '[]' : '' ) ) . '"'; } /** * Field Classes. * * @return void */ protected function field_classes( $additional_classes = '' ) { echo esc_attr( 'class' ) . '="' . ( ! empty( $this->field['classes'] ) ? esc_attr( $this->field['classes'] ) : '' ) . esc_attr( ! empty( $additional_classes ) ? ' ' . $additional_classes . ' ' : '' ) . '"'; } /** * Field ID. * * @return void */ protected function field_id() { echo esc_attr( 'id' ) . '="' . esc_attr( ! empty( $this->field['id'] ) ? $this->field['id'] : $this->field['key'] ) . '"'; } /** * Is Checked. * * @param boolean $is_checked * @return void */ protected function checked( $is_checked = true ) { if ( $is_checked ) { echo esc_attr( 'checked' ) . '="' . esc_attr( 'checked' ) . '"'; } } /** * Settings Field HTML. * * @param boolean $echo * @return mixed */ public function add_field( $echo = true ) { if ( ! $echo ) { ob_start(); } $is_inline = ( ! isset( $this->field['inline'] ) || true === $this->field['inline'] ); ?> settings_field_wrapper_start(); ?> field['input_label'] ) ) : ?>
field['input_label_subheading'] ); ?>
id . '-after-settings-field-label-' . ( ! empty( $this->field['filter'] ) ? $this->field['filter'] : $this->field['key'] ), $this->field ); ?>field['input_suffix'] ); ?>
id . '-just-after-settings-field-' . ( ! empty( $this->field['filter'] ) ? $this->field['filter'] : $this->field['key'] ), $this->field ); ?>field['input_footer'] ); ?>
id . '-after-settings-field-' . ( ! empty( $this->field['filter'] ) ? $this->field['filter'] : $this->field['key'] ), $this->field ); if ( 'repeater' === $this->field['type'] ) { $this->new_repeater_row_btn(); } $this->settings_field_wrapper_end(); if ( ! $echo ) { return ob_get_clean(); } } /** * Settings Field Row Wrapper Start. * * @return void */ protected function settings_field_wrapper_start() { do_action( $this->id . '-before-settings-field', $this->field ); do_action( $this->id . '-before-settings-field-' . ( ! empty( $this->field['filter'] ) ? $this->field['filter'] : $this->field['key'] ), $this->field ); ?>field['field_subheading'] ); ?>