mega['settings'] ); echo wpautop( $text ), '
'; $this->getForm(); echo '', '', '', '', wp_nonce_field( 'contact_data', 'security', true, false ), '
'; } public function ajaxCallback() { check_ajax_referer( 'contact_data', 'security' ); $post = stripslashes_deep( $_POST );//wp_unslash $this->parseWidgetSettings( $post['ins'] ); $mega_error = new Mega_Error(); if (( current_time( 'timestamp' ) - intval( $post['aa'] )) < 5 ) { $mega_error->add_error( '', esc_html__( 'It seems you are submitting too fast, take it slowly!', 'mega' )); } unset( $post['security'], $post['action'], $post['ins'], $post['aa'], $post['_wp_http_referer'] ); foreach( $post as $po => $poval ) { call_user_func( $this->megaForm['validate'][$po]['callback'], $poval, $mega_error ); $post[$po] = call_user_func( $this->megaForm['sanitize'][$po]['callback'], $poval ); } $this->validate( $post, $mega_error ); if ( !$mega_error->errors ) { //echo json_encode( $mega_error->errors ); $this->ajax( $post ); } else { foreach( $mega_error->errors as $j => $dat ) { echo '
  • ' . ucwords( $dat['type'] ) . ': ' . $dat['log'] . '
  • '; } die(); } exit; } public function validate( $post, $mega_error ) {} public function setForm( $args ) { if ( !empty( $args['name'] )) { $this->megaForm['defaults'][$args['name']] = $args['value']; $this->megaForm['sanitize'][$args['name']]['callback'] = $args['sanitize']; $this->megaForm['validate'][$args['name']]['callback'] = $args['validate']; } } }