MC4WP_Form_Element::get_form_element_attributes PHP Метод

get_form_element_attributes() защищенный Метод

Get all HTMl attributes for the form element
protected get_form_element_attributes ( ) : string
Результат string
    protected function get_form_element_attributes()
    {
        $form = $this;
        $form_action_attribute = null;
        $attributes = array('id' => $this->ID, 'class' => $this->get_css_classes());
        /**
         * Filters the `action` attribute of the `<form>` element.
         *
         * Defaults to `null`, which means no `action` attribute will be printed.
         *
         * @param string $form_action_attribute
         * @param MC4WP_Form $form
         */
        $form_action_attribute = apply_filters('mc4wp_form_action', $form_action_attribute, $form);
        if (is_string($form_action_attribute)) {
            $attributes['action'] = $form_action_attribute;
        }
        /**
         * Filters all attributes to be added to the `<form>` element
         *
         * @param array $attributes Key-value pairs of attributes.
         * @param MC4WP_Form $form
         */
        $attributes = (array) apply_filters('mc4wp_form_element_attributes', $attributes, $form);
        // hardcoded attributes, can not be changed.
        $attributes['method'] = 'post';
        $attributes['data-id'] = $this->form->ID;
        $attributes['data-name'] = $this->form->name;
        // build string of key="value" from array
        $string = '';
        foreach ($attributes as $name => $value) {
            $string .= sprintf('%s="%s" ', $name, esc_attr($value));
        }
        return $string;
    }