name = 'acf_cf7'; $this->label = __( 'Contact Form 7', 'acf-field-for-contact-form-7' ); // do not delete! parent::__construct(); } /** * Loads a value. * * @param string $value The value * @param int $post_id The post identifier * @param string $field The field * * @return string ( return field value ) */ function load_value( $value, $post_id, $field ) { return $value; } /** * Update value. * * @param string $value The value * @param string $field The field * @param int $post_id The post identifier * * @return string ( return field value ) */ function update_value( $value, $field, $post_id ) { return $value; } /** * Format value. * * @param string $value The value * @param string $field The field * * @return string ( return field value ) */ function format_value( $value, $field ) { return $value; } /** * Format value for API. * * @param string $value The value * @param string $field The field * * @return boolean|string */ function format_value_for_api( $value, $field ) { if ( ! $value || $value == 'null' ) { return false; } // apply filter $contact_obj = apply_filters( 'acf_cf7_object', false ); //If there are multiple forms, construct and return an array of form markup if ( is_array( $value ) ) { foreach ( $value as $k => $v ) { $form = get_post($v); if ( $contact_obj ) { $value = $form; } else { $f = do_shortcode( '[contact-form-7 id="'.$form->ID.'" title="'.$form->post_title.'"]' ); $value[$k] = array(); $value[$k] = $f; } } } else { $form = get_post( $value ); if ( $contact_obj ) { $value = $form; } else { $value = do_shortcode( '[contact-form-7 id="'.$form->ID.'" title="'.$form->post_title.'"]' ); } } return $value; } /** * Loads a field. * * @param string $field The field * * @return string ( return field ) */ function load_field( $field ) { return $field; } /** * Update field. * * @param string $field The field * @param int $post_id The post identifier * * @return string ( return field ) */ function update_field( $field, $post_id ) { return $field; } /** * Creates a field. * * @param string $field The field */ function create_field( $field ) { $field['multiple'] = isset( $field['multiple'] ) ? $field['multiple'] : false; $field['disable'] = isset( $field['disable'] ) ? $field['disable'] : false; $field['hide_disabled'] = isset( $field['hide_disabled'] ) ? $field['hide_disabled'] : false; // Add multiple select functionality as required $multiple = ''; if ( $field['multiple'] == '1' ) { $multiple = ' multiple="multiple" size="5" '; $field['name'] .= '[]'; } // Begin HTML select field echo ''; } /** * Creates options. * * @param string $field The field */ function create_options( $field ) { // vars $defaults = array( 'multiple' => 0, 'allow_null' => 0, 'default_value' => '', 'choices' => '', 'disable' => '', 'hide_disabled' => 0, ); $field = array_merge( $defaults, $field ); $key = $field['name']; ?>

'wpcf7_contact_form', 'orderby' => 'id', 'order' => 'ASC', 'posts_per_page' => 999, 'numberposts' => 999 ) ); $choices = array(); $choices[0] = '---'; $k = 1; foreach ( $forms as $f ) { $choices[$k] = $f->post_title; $k++; } do_action( 'acf/create_field', array( 'type' => 'select', 'name' => 'fields['.$key.'][disable]', 'value' => $field['disable'], 'multiple' => '1', 'allow_null' => '0', 'choices' => $choices, 'layout' => 'horizontal', ) ); ?> 'radio', 'name' => 'fields['.$key.'][allow_null]', 'value' => $field['allow_null'], 'choices' => array( 1 => __("Yes",'acf-field-for-contact-form-7'), 0 => __("No",'acf-field-for-contact-form-7'), ), 'layout' => 'horizontal', ) ); ?> 'radio', 'name' => 'fields['.$key.'][multiple]', 'value' => $field['multiple'], 'choices' => array( 1 => __( 'Yes', 'acf-field-for-contact-form-7' ), 0 => __( 'No', 'acf-field-for-contact-form-7' ), ), 'layout' => 'horizontal', )); ?> 'radio', 'name' => 'fields['.$key.'][hide_disabled]', 'value' => $field['hide_disabled'], 'choices' => array( 1 => __( 'Yes','acf-field-for-contact-form-7'), 0 => __( 'No','acf-field-for-contact-form-7'), ), 'layout' => 'horizontal', )); ?>