get_response(); $status = $submission->get_status(); // $output = array( 'message' => $response ); switch ( $status ) { case 'validation_failed': header('HTTP/1.1 403 Forbidden'); break; case 'acceptance_missing': header('HTTP/1.1 403 Forbidden'); break; case 'spam': header('HTTP/1.1 403 Forbidden'); break; case 'aborted': header('HTTP/1.1 403 Forbidden'); break; case 'mail_sent': header('HTTP/1.1 200 OK'); break; case 'mail_failed': header('HTTP/1.1 403 Forbidden'); break; default: break; } $verifyErrors = array(); foreach( $submission->get_invalid_fields() as $key => $val ){ $key = str_replace( '-', ' ', $key ); $key = ucfirst( $key ); $verifyErrors[]['name'] = $key; $verifyErrors[]['message'] = $key.' : '.$val['reason']; } $output['msg'] = $response; if( $status == 'validation_failed' ) $output['msg'] = ''; $output['verifyErrors'] = apply_filters( 'ampcf7_verify_errors', $verifyErrors ); echo json_encode( $output ); die; } add_action( 'wp_ajax_ampcf7_submit_form', 'ampcf7_submit_form' ); add_action( 'wp_ajax_nopriv_ampcf7_submit_form', 'ampcf7_submit_form' ); /** * Activate plugin **/ function ampcf7_on_activate(){ update_option( 'ampcf7_install_date', date('Y-m-d G:i:s'), false); update_option( 'ampcf7_ignore_notice', 'false', false); } register_activation_hook( __FILE__, 'ampcf7_on_activate' ); /** * Adming notice **/ function ampcf7_admin_notices(){ $install_date = get_option( 'ampcf7_install_date', ''); $install_date = date_create( $install_date ); $date_now = date_create( date('Y-m-d G:i:s') ); $date_diff = date_diff( $install_date, $date_now ); $view_notice = get_option( 'ampcf7_ignore_notice', '' ); if ( isset( $_GET['ampcf7-ignore-notice'] ) && ( '1' == $_GET['ampcf7-ignore-notice'] ) ) { update_option( 'ampcf7_ignore_notice', 'true', false ); $view_notice = 'true'; } if ( ( $date_diff->format("%d") < 7 ) || ( $view_notice == 'true' ) ){ return false; } echo '

'; printf(__( 'Awesome, you\'ve been using AMP Contact Form 7 for more than 1 week. May we ask you to give it a 5-star rating on WordPress? Ok, you deserved it | I already did | No, not good enough', 'amp-contact-form-7' ), 'admin.php?page=wpcf7&cf7-ignore-notice=1', 'https://wordpress.org/plugins/amp-contact-form-7/'); echo "

"; } add_action( 'wpcf7_admin_notices' , 'ampcf7_admin_notices' ); /** * Deactivation **/ function ampcf7_on_deactivate(){ delete_option( 'ampcf7_install_date' ); delete_option( 'ampcf7_ignore_notice' ); } register_deactivation_hook( __FILE__, 'ampcf7_on_deactivate' );