name = 'acf_cf7'; $this->label = __('Contact Form 7'); // do not delete! parent::__construct(); } /* * load_value() * * This filter is appied to the $value after it is loaded from the db * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value - the value found in the database * @param $post_id - the $post_id from which the value was loaded from * @param $field - the field array holding all the field options * * @return $value - the value to be saved in te database */ function load_value( $value, $post_id, $field ) { return $value; } /* * update_value() * * This filter is appied to the $value before it is updated in the db * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value - the value which will be saved in the database * @param $field - the field array holding all the field options * @param $post_id - the $post_id of which the value will be saved * * @return $value - the modified value */ function update_value( $value, $field, $post_id ) { return $value; } /* * format_value() * * This filter is appied to the $value after it is loaded from the db and before it is passed to the create_field action * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value - the value which was loaded from the database * @param $field - the field array holding all the field options * * @return $value - the modified value */ function format_value( $value, $field ) { return $value; } /* * format_value_for_api() * * This filter is appied to the $value after it is loaded from the db and before it is passed back to the api functions such as the_field * * @type filter * @since 3.6 * @date 23/01/13 * * @param $value - the value which was loaded from the database * @param $field - the field array holding all the field options * * @return $value - the modified value */ function format_value_for_api( $value, $field ) { if(!$value || $value == 'null'){ return 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); $f = do_shortcode('[contact-form-7 id="'.$form->ID.'" title="'.$form->post_title.'"]'); $value[$k] = array(); $value[$k] = $f; } //Else return single form markup }else{ $form = get_post($value); $value = do_shortcode('[contact-form-7 id="'.$form->ID.'" title="'.$form->post_title.'"]'); } return $value; } /* * load_field() * * This filter is appied to the $field after it is loaded from the database * * @type filter * @since 3.6 * @date 23/01/13 * * @param $field - the field array holding all the field options * * @return $field - the field array holding all the field options */ function load_field( $field ) { return $field; } /* * update_field() * * This filter is appied to the $field before it is saved to the database * * @type filter * @since 3.6 * @date 23/01/13 * * @param $field - the field array holding all the field options * @param $post_id - the field group ID (post_type = acf) * * @return $field - the modified field */ function update_field( $field, $post_id ) { return $field; } /* * create_field() * * Create the HTML interface for your field * * @type action * @since 3.6 * @date 23/01/13 * * @param $field - an array holding all the field's data */ 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 ''; } /* * create_options() * * Create extra options for your field. This is rendered when editing a field. * The value of $field['name'] can be used (like bellow) to save extra data to the $field * * @type action * @since 3.6 * @date 23/01/13 * * @param $field - an array holding all the field's data */ 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'), 0 => __("No",'acf'), ), 'layout' => 'horizontal', )); ?> 'radio', 'name' => 'fields['.$key.'][multiple]', 'value' => $field['multiple'], 'choices' => array( 1 => __("Yes",'acf'), 0 => __("No",'acf'), ), 'layout' => 'horizontal', )); ?> 'radio', 'name' => 'fields['.$key.'][hide_disabled]', 'value' => $field['hide_disabled'], 'choices' => array( 1 => __("Yes",'acf'), 0 => __("No",'acf'), ), 'layout' => 'horizontal', )); ?>