__( 'Add to Calendar', 'add-to-google-calendar-contact-form-7' ), 'callback' => 'atccf7_editor_panel', ); return $panels; } function atccf7_editor_panel( $form ) { if ( ! $form->id() ) { echo '' . __( 'Please first create and save your form. ', 'add-to-google-clendar-contact-form-7') . ''; } else { atccf7_render_editor( $form ); } } function atccf7_render_editor( $form ) { $postmeta_temp = get_post_meta( $form->id(), 'atccf7_options_form', true ); $postmeta_atc = ( $postmeta_temp !== '' ? $postmeta_temp : false ); if ( is_array( $postmeta_atc ) && count( $postmeta_atc ) < 1 ) { $atc_on = ''; $date_1 = ''; $date_2 = ''; $event_name = ''; $specific_date = ''; } else { $atc_on = ( isset( $postmeta_atc['atc_on'] ) ? $postmeta_atc['atc_on'] : false ); $date_1 = ( isset( $postmeta_atc['date_1'] ) ? $postmeta_atc['date_1'] : '' ); $date_2 = ( isset( $postmeta_atc['date_2'] ) ? $postmeta_atc['date_2'] : '' ); $event_name = ( isset( $postmeta_atc['event_name'] ) ? $postmeta_atc['event_name'] : '' ); $specific_date = ( isset( $postmeta_atc['specific_date'] ) ? $postmeta_atc['specific_date'] : '' ); $event_description = ( isset( $postmeta_atc['event_description'] ) ? $postmeta_atc['event_description'] : '' ); $event_location = ( isset( $postmeta_atc['event_location'] ) ? $postmeta_atc['event_location'] : '' ); $event_btn = ( isset( $postmeta_atc['event_btn'] ) ? $postmeta_atc['event_btn'] : '' ); $color_btn = ( isset( $postmeta_atc['color_btn'] ) ? $postmeta_atc['color_btn'] : '' ); $color_text = ( isset( $postmeta_atc['color_text'] ) ? $postmeta_atc['color_text'] : '' ); } $actual_fields = $form->scan_form_tags(); if ( count( $actual_fields ) > 0 ) { $options_fields = array(); for ( $i = 0, $length_fields = count( $actual_fields ); $i < $length_fields; $i++ ) { $field = $actual_fields[$i]; if ( $field['basetype'] != 'date' && $field['basetype'] != 'text' ) { continue; } array_push( $options_fields, $field['name'] ); } } ?>

>





' . esc_html__( 'There are not date/text fields yet! Please create them first.', 'add-to-google-calendar-contact-form-7' ) . ''; return; } // check if there are more than one date field. if ( $x === 2 && count( $options_fields ) < 2 ) { echo '' . esc_html__( 'There is only one date/text field.', 'add-to-google-calendar-contact-form-7' ) . ''; return; } $select = ''; echo $select; } // when contact form is saved. add_action( 'wpcf7_save_contact_form', 'atccf7_save_dataform' ); function atccf7_save_dataform( $form ) { $post_id = $form->id(); if ( ! $post_id ) return; $atc_on = 1; if ( ! isset( $_POST['atc_on'] ) ) { $atc_on = 0; } $atccf7_options_form = array( 'atc_on' => $atc_on, 'event_name' => sanitize_text_field( $_POST['event_name'] ), 'event_description' => sanitize_text_field( $_POST['event_description'] ), 'event_location' => sanitize_text_field( $_POST['event_location'] ), 'event_btn' => sanitize_text_field( $_POST['event_btn'] ), 'color_btn' => sanitize_text_field( $_POST['color_btn'] ), 'color_text' => sanitize_text_field( $_POST['color_text'] ), ); if( isset ( $_POST['specific_date'] ) ) { $atccf7_options_form['specific_date'] = sanitize_text_field( $_POST['specific_date'] ); } if ( isset ( $_POST['date_1'] ) ) { $atccf7_options_form['date_1'] = sanitize_text_field( $_POST['date_1'] ); } if ( isset( $_POST['date_2'] ) ) { $atccf7_options_form['date_2'] = sanitize_text_field( $_POST['date_2'] ); } update_post_meta( $post_id, 'atccf7_options_form', $atccf7_options_form ); return; };