本文整理汇总了PHP中GFCommon::log_debug方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::log_debug方法的具体用法?PHP GFCommon::log_debug怎么用?PHP GFCommon::log_debug使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::log_debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: acf_repeater_population
function acf_repeater_population($form)
{
GFCommon::log_debug("acf_repeater_population() function called for form {$form['id']}");
// filters are applied only to form ID 4. Change to your form ID
foreach ($form['fields'] as &$field) {
// if the field is not a radio button type or it does not have the CSS Class Name required, continue
if ('radio' != $field->type || false === strpos($field->cssClass, 'dates_from_acf')) {
continue;
}
// start with an empty choices array
$field->choices = array();
// need the ID of the current post
global $post;
GFCommon::log_debug("global post =>" . print_r($post, true));
$rows = get_field('coursedates');
if ($rows) {
GFCommon::log_debug("get_field() for coursedates: \$rows => " . print_r($rows, 1));
foreach ($rows as $row) {
$city = $row['city'];
$text = date_i18n('l j. F Y', strtotime($row['startdate'])) . " - " . $city;
$field->choices[] = array('text' => $text, 'value' => $row['startdate'] . " - " . $city);
}
} else {
$field->choices[] = array('text' => 'Ingen ledige datoer', 'value' => 'Ingen ledige datoer');
}
break;
}
// always return the form
return $form;
}
示例2: GFUEA_custom_notification_attachments
function GFUEA_custom_notification_attachments($notification, $form, $entry)
{
$log = 'rw_notification_attachments() - ';
GFCommon::log_debug($log . 'starting.');
# mail("greg@wpcms.ninja","Notification Fire" . date("Y-m-d h:i:s"), print_r($notification, true) . print_r($form,true) . print_r($entry,true));
if (substr($notification["name"], -5) == "GFUEA") {
//mail("greg@wpcms.ninja","Notification Fire" . date("Y-m-d h:i:s"), print_r($notification, true) . print_r($form,true) . print_r($entry,true));
$fileupload_fields = GFCommon::get_fields_by_type($form, array('fileupload'));
if (!is_array($fileupload_fields)) {
return $notification;
}
$attachments = array();
$upload_root = RGFormsModel::get_upload_root();
foreach ($fileupload_fields as $field) {
$url = $entry[$field['id']];
if (empty($url)) {
continue;
} elseif ($field['multipleFiles']) {
$uploaded_files = json_decode(stripslashes($url), true);
$zip = new ZipArchive();
//$filetext = date("Y-m-d his");
$filename = $upload_root . "/uploaded_files" . $entry['id'] . ".zip";
if ($zip->open($filename, ZipArchive::CREATE) !== TRUE) {
foreach ($uploaded_files as $uploaded_file) {
$attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file);
GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true));
$attachments[] = $attachment;
}
} else {
foreach ($uploaded_files as $uploaded_file) {
$attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $uploaded_file);
GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true));
$new_filename = substr($attachment, strrpos($attachment, '/') + 1);
$zip->addFile($attachment, $new_filename);
//$attachments[] = $attachment;
}
$zip->close();
$attachments[] = $filename;
add_filter('gform_confirmation', 'gfuea_clean_zips', 10, 4);
}
} else {
$attachment = preg_replace('|^(.*?)/gravity_forms/|', $upload_root, $url);
GFCommon::log_debug($log . 'attaching the file: ' . print_r($attachment, true));
$attachments[] = $attachment;
}
}
$notification['attachments'] = $attachments;
}
//mail("greg@wpcms.ninja","Notification Fire" . date("Y-m-d h:i:s"), "Attach IDs:\n" . print_r($attachIds, true) . "\nNotification:\n" . print_r($notification, true) . "\nForm:\n" .print_r($form,true) . "\nEntry:\n" .print_r($entry,true));
GFCommon::log_debug($log . 'stopping.');
return $notification;
}
示例3: wpan_send_form_tracking_event
function wpan_send_form_tracking_event($entry, $form)
{
global $post;
$msg = "About to send form tracking event to Google Analytics...";
wpan_log_debug($msg);
GFCommon::log_debug($msg);
/* Extract the plugin options from the database */
$options = wpan_get_options();
$tracking_uid = isset($options['tracking_uid']) ? $options['tracking_uid'] : '';
$debug = isset($options['debug']) ? $options['debug'] : '';
$form_title = $form['title'];
/* I have taken the following four lines of code from
https://github.com/theiconic/php-ga-measurement-protocol;
thank you! */
$document_path = str_replace(home_url(), '', $entry['source_url']);
$document_location = 'http' . (isset($_SERVER['HTTPS']) ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . '/' . $_SERVER['REQUEST_URI'];
$document_title = isset($post) && get_the_title($post) ? get_the_title($post) : 'no title';
/* Setup the class */
$ga_options = ['client_create_random_id' => true, 'client_fallback_id' => 555, 'client_id' => null, 'user_id' => null, 'adapter' => ['async' => true, 'ssl' => false]];
/* Connect to tracker */
$gatracking = new \Racecore\GATracking\GATracking($tracking_uid, $ga_options);
/* Build GA event */
$event = $gatracking->createTracking('Event');
$event->setAsNonInteractionHit(false);
$event->setEventCategory('Contact');
$event->setEventAction($form_title);
$event->setEventLabel($document_path);
$event->setDocumentPath($document_path);
$event->setDocumentLocation($document_location);
$event->setDocumentTitle($document_title);
/* Send event to GA severs */
$response = $gatracking->sendTracking($event);
/* Debug */
if ($debug) {
wpan_log_debug("Sent the following event to Google Analytics:");
wpan_log_debug($event);
wpan_log_debug("Received the following respons from Google Analytics (ASYNC, so it might be empty): ");
wpan_log_debug($response);
// wpan_log_debug( "This is the form that triggered the event:" );
// wpan_log_debug( $form );
// wpan_log_debug( "This is the entry of the form in Gravity Forms:" );
// wpan_log_debug( $entry );
}
}
示例4: deliver
/**
* Send the file.
*
* @param $form_id
* @param $file
*/
private static function deliver($form_id, $file)
{
$path = GFFormsModel::get_upload_path($form_id);
$file_path = trailingslashit($path) . $file;
GFCommon::log_debug("delivering file: {$file_path}");
if (file_exists($file_path)) {
GFCommon::log_debug("file exists - starting delivery");
$content_type = self::get_content_type($file_path);
$content_disposition = rgget('dl') ? 'attachment' : 'inline';
nocache_headers();
header('Robots: none');
header('Content-Type: ' . $content_type);
header('Content-Description: File Transfer');
header('Content-Disposition: ' . $content_disposition . '; filename="' . basename($file) . '"');
header('Content-Transfer-Encoding: binary');
self::readfile_chunked($file_path);
die;
} else {
GFCommon::log_debug("file does not exist. abort with 404");
self::die_404();
}
}
示例5: handle_page_request
public function handle_page_request()
{
global $HTTP_RAW_POST_DATA;
$route = get_query_var(GFWEBAPI_ROUTE_VAR);
if (false == $route) {
return;
}
self::authenticate();
$test_mode = rgget("test");
if ($test_mode) {
die("test mode");
}
$settings = get_option('gravityformsaddon_gravityformswebapi_settings');
if (empty($settings)) {
$this->die_not_authorized();
}
$account_id = $settings["impersonate_account"];
wp_set_current_user($account_id);
$route_parts = pathinfo($route);
$format = rgar($route_parts, 'extension');
if ($format) {
$route = str_replace("." . $format, "", $route);
}
$path_array = explode("/", $route);
$collection = strtolower(rgar($path_array, 0));
$id = rgar($path_array, 1);
if (strpos($id, ";") !== false) {
$id = explode(";", $id);
}
$collection2 = strtolower(rgar($path_array, 2));
$id2 = rgar($path_array, 3);
if (strpos($id2, ";") !== false) {
$id2 = explode(";", $id2);
}
if (empty($format)) {
$format = "json";
}
$schema = strtolower(rgget("schema"));
$offset = isset($_GET["paging"]["offset"]) ? strtolower($_GET["paging"]["offset"]) : 0;
$page_size = isset($_GET["paging"]["page_size"]) ? strtolower($_GET["paging"]["page_size"]) : 10;
$method = strtoupper($_SERVER['REQUEST_METHOD']);
$args = compact("offset", "page_size", "schema");
if (empty($collection2)) {
do_action("gform_webapi_" . strtolower($method) . "_" . $collection, $id, $format, $args);
} else {
do_action("gform_webapi_" . strtolower($method) . "_" . $collection . "_" . $collection2, $id, $id2, $format, $args);
}
if (!isset($HTTP_RAW_POST_DATA)) {
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
GFCommon::log_debug("WebAPI: HTTP_RAW_POST_DATA = " . $HTTP_RAW_POST_DATA);
$data = json_decode($HTTP_RAW_POST_DATA, true);
// todo: tidy up this mess
switch ($collection) {
case "forms":
switch ($collection2) {
case "results":
switch ($method) {
case 'GET':
$this->get_results($id);
break;
case 'DELETE':
case 'PUT':
case 'POST':
default:
$this->die_bad_request();
}
break;
case "properties":
switch ($method) {
case 'PUT':
$this->put_forms_properties($data, $id);
break;
default:
$this->die_bad_request();
}
break;
case "feeds":
if (false == empty($id2)) {
$this->die_bad_request();
}
switch ($method) {
case 'GET':
$this->get_feeds(null, $id);
break;
case 'DELETE':
$this->delete_feeds(null, $id);
break;
case 'PUT':
$this->die_not_implemented();
break;
case 'POST':
$this->post_feeds($data, $id);
break;
default:
$this->die_bad_request();
}
break;
case "entries":
if (false == empty($id2)) {
//.........这里部分代码省略.........
示例6: send_email
private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = "", $message_format = "html", $attachments = "")
{
$to = str_replace(" ", "", $to);
$bcc = str_replace(" ", "", $bcc);
//invalid to email address or no content. can't send email
if (!GFCommon::is_valid_email($to) || empty($subject) && empty($message)) {
return;
}
if (!GFCommon::is_valid_email($from)) {
$from = get_bloginfo("admin_email");
}
//invalid from address. can't send email
if (!GFCommon::is_valid_email($from)) {
return;
}
$content_type = $message_format == "html" ? "text/html" : "text/plain";
$name = empty($from_name) ? $from : $from_name;
$headers = "From: \"{$name}\" <{$from}> \r\n";
$headers .= GFCommon::is_valid_email($reply_to) ? "Reply-To: {$reply_to}\r\n" : "";
$headers .= GFCommon::is_valid_email($bcc) ? "Bcc: {$bcc}\r\n" : "";
$headers .= "Content-type: {$content_type}; charset=" . get_option('blog_charset') . "\r\n";
GFCommon::log_debug("Sending email via wp_mail()");
GFCommon::log_debug(print_r(compact("to", "subject", "message", "headers", "attachments"), true));
$result = wp_mail($to, $subject, $message, $headers, $attachments);
$result_text = $result ? "success" : "failed";
GFCommon::log_debug("Result from wp_mail(): {$result} ({$result_text})");
}
示例7: add_note_sidebar
function add_note_sidebar($lead, $form)
{
global $current_user;
$user_data = get_userdata($current_user->ID);
$project_name = $lead['151'];
$email_to = $_POST['gentry_email_notes_to_sidebar'];
$email_note_info = '';
//emailing notes if configured
if (!empty($email_to)) {
GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
$email_to = $_POST['gentry_email_notes_to_sidebar'];
$email_from = $current_user->user_email;
$email_subject = stripslashes('Response Required Maker Application: ' . $lead['id'] . ' ' . $project_name);
$entry_url = get_bloginfo('wpurl') . '/wp-admin/admin.php?page=mf_entries&view=mfentry&id=' . $form['id'] . '&lid=' . rgar($lead, 'id');
$body = stripslashes($_POST['new_note_sidebar']) . '<br /><br />Please reply in entry:<a href="' . $entry_url . '">' . $entry_url . '</a>';
$headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
//Enable HTML Email Formatting in the body
add_filter('wp_mail_content_type', 'wpse27856_set_content_type');
$result = wp_mail($email_to, $email_subject, $body, $headers);
//Remove HTML Email Formatting
remove_filter('wp_mail_content_type', 'wpse27856_set_content_type');
$email_note_info = '<br /><br />:SENT TO:[' . implode(",", $email_to) . ']';
}
mf_add_note($lead['id'], nl2br(stripslashes($_POST['new_note_sidebar'] . $email_note_info)));
}
示例8: is_auto_update_disabled
public static function is_auto_update_disabled()
{
// Currently WordPress won't ask Gravity Forms to update if background updates are disabled.
// Let's double check anyway.
// WordPress background updates are disabled if you don't want file changes.
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
return true;
}
if (defined('WP_INSTALLING')) {
return true;
}
$wp_updates_disabled = defined('AUTOMATIC_UPDATER_DISABLED') && AUTOMATIC_UPDATER_DISABLED;
$wp_updates_disabled = apply_filters('automatic_updater_disabled', $wp_updates_disabled);
if ($wp_updates_disabled) {
GFCommon::log_debug(__METHOD__ . '() - Background updates are disabled in WordPress.');
return true;
}
// Now check Gravity Forms Background Update Settings
$enabled = get_option('gform_enable_background_updates');
GFCommon::log_debug('GFForms::is_auto_update_disabled() - $enabled: ' . var_export($enabled, true));
/**
* Filter to disable Gravity Forms Automatic updates
*
* @param bool $enabled Check if automatic updates are enabled, and then disable it
*/
$disabled = apply_filters('gform_disable_auto_update', !$enabled);
GFCommon::log_debug('GFForms::is_auto_update_disabled() - $disabled: ' . var_export($disabled, true));
if (!$disabled) {
$disabled = defined('GFORM_DISABLE_AUTO_UPDATE') && GFORM_DISABLE_AUTO_UPDATE;
GFCommon::log_debug('GFForms::is_auto_update_disabled() - GFORM_DISABLE_AUTO_UPDATE: ' . var_export($disabled, true));
}
return $disabled;
}
示例9: trim_conditional_logic_values
/**
* Trims values from an array of elements e.g. notifications and confirmations
*
* @param array $meta_array Form object.
* @param array $form Form object.
* @param bool $updated Output parameter.
*
* @return array $meta_array
*/
public static function trim_conditional_logic_values($meta_array, $form, &$updated = false)
{
GFCommon::log_debug('GFFormsModel::trim_conditional_logic_values(): Starting.');
if (is_array($meta_array)) {
foreach ($meta_array as &$meta) {
$meta = self::trim_conditional_logic_values_from_element($meta, $form, $updated);
}
}
if ($updated) {
GFCommon::log_debug('GFFormsModel::trim_conditional_logic_values(): Conditional logic values trimmed.');
}
return $meta_array;
}
示例10: upload_files
private static function upload_files($form, $files)
{
//Creating temp folder if it does not exist
$target_path = RGFormsModel::get_upload_path($form["id"]) . "/tmp/";
wp_mkdir_p($target_path);
foreach ($form["fields"] as $field) {
$input_name = "input_{$field["id"]}";
//skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
$input_type = RGFormsModel::get_input_type($field);
if (!in_array($input_type, array("fileupload", "post_image")) || $field["failed_validation"] || empty($_FILES[$input_name]["name"])) {
GFCommon::log_debug("upload_files() - skipping field: {$field["label"]}({$field["id"]} - {$field["type"]})");
continue;
}
$file_info = RGFormsModel::get_temp_filename($form["id"], $input_name);
GFCommon::log_debug("upload_files() - temp file info: " . print_r($file_info, true));
if ($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info["temp_filename"])) {
$files[$input_name] = $file_info["uploaded_filename"];
GFCommon::log_debug("upload_files() - file uploaded successfully: {$file_info["uploaded_filename"]}");
} else {
GFCommon::log_error("upload_files() - file could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info["temp_filename"]);
}
}
return $files;
}
示例11: start_export
public static function start_export($form)
{
$form_id = $form['id'];
$fields = $_POST['export_field'];
$start_date = empty($_POST['export_date_start']) ? '' : self::get_gmt_date($_POST['export_date_start'] . ' 00:00:00');
$end_date = empty($_POST['export_date_end']) ? '' : self::get_gmt_date($_POST['export_date_end'] . ' 23:59:59');
$search_criteria['status'] = 'active';
$search_criteria['field_filters'] = GFCommon::get_field_filters_from_post($form);
if (!empty($start_date)) {
$search_criteria['start_date'] = $start_date;
}
if (!empty($end_date)) {
$search_criteria['end_date'] = $end_date;
}
$sorting = array('key' => 'date_created', 'direction' => 'DESC', 'type' => 'info');
GFCommon::log_debug("GFExport::start_export(): Start date: {$start_date}");
GFCommon::log_debug("GFExport::start_export(): End date: {$end_date}");
$form = self::add_default_export_fields($form);
$entry_count = GFAPI::count_entries($form_id, $search_criteria);
$page_size = 100;
$offset = 0;
//Adding BOM marker for UTF-8
$lines = chr(239) . chr(187) . chr(191);
// set the separater
$separator = gf_apply_filters('gform_export_separator', $form_id, ',', $form_id);
$field_rows = self::get_field_row_count($form, $fields, $entry_count);
//writing header
$headers = array();
foreach ($fields as $field_id) {
$field = RGFormsModel::get_field($form, $field_id);
$label = gf_apply_filters('gform_entries_field_header_pre_export', array($form_id, $field_id), GFCommon::get_label($field, $field_id), $form, $field);
$value = str_replace('"', '""', $label);
GFCommon::log_debug("GFExport::start_export(): Header for field ID {$field_id}: {$value}");
$headers[$field_id] = $value;
$subrow_count = isset($field_rows[$field_id]) ? intval($field_rows[$field_id]) : 0;
if ($subrow_count == 0) {
$lines .= '"' . $value . '"' . $separator;
} else {
for ($i = 1; $i <= $subrow_count; $i++) {
$lines .= '"' . $value . ' ' . $i . '"' . $separator;
}
}
GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
}
$lines = substr($lines, 0, strlen($lines) - 1) . "\n";
//paging through results for memory issues
while ($entry_count > 0) {
$paging = array('offset' => $offset, 'page_size' => $page_size);
$leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging);
$leads = gf_apply_filters('gform_leads_before_export', $form_id, $leads, $form, $paging);
foreach ($leads as $lead) {
foreach ($fields as $field_id) {
switch ($field_id) {
case 'date_created':
$lead_gmt_time = mysql2date('G', $lead['date_created']);
$lead_local_time = GFCommon::get_local_timestamp($lead_gmt_time);
$value = date_i18n('Y-m-d H:i:s', $lead_local_time, true);
break;
default:
$field = RGFormsModel::get_field($form, $field_id);
$value = is_object($field) ? $field->get_value_export($lead, $field_id, false, true) : rgar($lead, $field_id);
$value = apply_filters('gform_export_field_value', $value, $form_id, $field_id, $lead);
GFCommon::log_debug("GFExport::start_export(): Value for field ID {$field_id}: {$value}");
break;
}
if (isset($field_rows[$field_id])) {
$list = empty($value) ? array() : unserialize($value);
foreach ($list as $row) {
$row_values = array_values($row);
$row_str = implode('|', $row_values);
$lines .= '"' . str_replace('"', '""', $row_str) . '"' . $separator;
}
//filling missing subrow columns (if any)
$missing_count = intval($field_rows[$field_id]) - count($list);
for ($i = 0; $i < $missing_count; $i++) {
$lines .= '""' . $separator;
}
} else {
$value = maybe_unserialize($value);
if (is_array($value)) {
$value = implode('|', $value);
}
$lines .= '"' . str_replace('"', '""', $value) . '"' . $separator;
}
}
$lines = substr($lines, 0, strlen($lines) - 1);
GFCommon::log_debug("GFExport::start_export(): Lines: {$lines}");
$lines .= "\n";
}
$offset += $page_size;
$entry_count -= $page_size;
if (!seems_utf8($lines)) {
$lines = utf8_encode($lines);
}
$lines = apply_filters('gform_export_lines', $lines);
echo $lines;
$lines = '';
}
/**
* Fires after exporting all the entries in form
//.........这里部分代码省略.........
示例12: search_leads
public static function search_leads($form_id, $search_criteria = array(), $sorting = null, $paging = null)
{
global $wpdb;
$sort_field = isset($sorting["key"]) ? $sorting["key"] : "date_created";
// column, field or entry meta
if (is_numeric($sort_field)) {
$sql = self::sort_by_field_query($form_id, $search_criteria, $sorting, $paging);
} else {
$sql = self::sort_by_column_query($form_id, $search_criteria, $sorting, $paging);
}
//initializing rownum
$wpdb->query("select @rownum:=0");
GFCommon::log_debug($sql);
//getting results
$results = $wpdb->get_results($sql);
$leads = GFFormsModel::build_lead_array($results);
return $leads;
}
示例13: delete_orphaned_entries
/**
* Deletes all rows in the lead table that don't have corresponding rows in the details table.
*
* @since 2.0.0
* @access public
* @static
* @global $wpdb
*/
public static function delete_orphaned_entries()
{
global $wpdb;
GFCommon::log_debug(__METHOD__ . '(): Starting to delete orphaned entries');
$lead_table = GFFormsModel::get_lead_table_name();
$lead_details_table = GFFormsModel::get_lead_details_table_name();
$sql = "DELETE FROM {$lead_table} WHERE id NOT IN( SELECT lead_id FROM {$lead_details_table} )";
$result = $wpdb->query($sql);
GFCommon::log_debug(__METHOD__ . '(): Delete result: ' . print_r($result, true));
}
示例14: is_auto_update_disabled
public static function is_auto_update_disabled()
{
// Background updates are disabled if you don't want file changes.
if (defined('DISALLOW_FILE_MODS') && DISALLOW_FILE_MODS) {
return true;
}
if (defined('WP_INSTALLING')) {
return true;
}
$enabled = get_option('gform_enable_background_updates');
GFCommon::log_debug('GFForms::is_auto_update_disabled() - $enabled: ' . var_export($enabled, true));
$disabled = apply_filters('gform_disable_auto_update', !$enabled);
GFCommon::log_debug('GFForms::is_auto_update_disabled() - $disabled: ' . var_export($disabled, true));
if (!$disabled) {
$disabled = defined('GFORM_DISABLE_AUTO_UPDATE') && GFORM_DISABLE_AUTO_UPDATE;
GFCommon::log_debug('GFForms::is_auto_update_disabled() - GFORM_DISABLE_AUTO_UPDATE: ' . var_export($disabled, true));
}
return $disabled;
}
示例15: save_form_info
/**
* Saves form meta. Note the special requirements for the meta string.
*
* @param $id
* @param string $form_json A valid JSON string. The JSON is manipulated before decoding and is designed to work together with jQuery.toJSON() rather than json_encode. Avoid using json_encode as it will convert unicode characters into their respective entities with slashes. These slashes get stripped so unicode characters won't survive intact.
*
* @return array
*/
public static function save_form_info($id, $form_json)
{
global $wpdb;
$form_json = stripslashes($form_json);
$form_json = nl2br($form_json);
GFCommon::log_debug("form meta json:" . $form_json);
$form_meta = json_decode($form_json, true);
GFCommon::log_debug("form meta:");
GFCommon::log_debug(print_r($form_json, true));
if (!$form_meta) {
return array("status" => "invalid_json", "meta" => null);
}
$form_table_name = $wpdb->prefix . "rg_form";
//Making sure title is not duplicate
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower($form_meta["title"]) && rgar($form_meta, "id") != $form->id) {
return array("status" => "duplicate_title", "meta" => $form_meta);
}
}
if ($id > 0) {
$form_meta = GFFormsModel::trim_form_meta_values($form_meta);
RGFormsModel::update_form_meta($id, $form_meta);
//updating form title
$wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta["title"], $form_meta["id"]));
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, false);
return array("status" => $id, "meta" => $form_meta);
} else {
//inserting form
$id = RGFormsModel::insert_form($form_meta["title"]);
//updating object's id property
$form_meta["id"] = $id;
//creating default notification
if (apply_filters('gform_default_notification', true)) {
$default_notification = array("id" => uniqid(), "to" => "{admin_email}", "name" => __("Admin Notification", "gravityforms"), "event" => "form_submission", "toType" => "email", "subject" => __("New submission from", "gravityforms") . " {form_title}", "message" => "{all_fields}");
$notifications = array($default_notification["id"] => $default_notification);
//updating notifications form meta
RGFormsModel::save_form_notifications($id, $notifications);
}
// add default confirmation when saving a new form
$confirmation_id = uniqid();
$confirmations = array();
$confirmations[$confirmation_id] = array('id' => $confirmation_id, 'name' => __('Default Confirmation', 'gravityforms'), 'isDefault' => true, 'type' => 'message', 'message' => __("Thanks for contacting us! We will get in touch with you shortly.", "gravityforms"), 'url' => '', 'pageId' => '', 'queryString' => '');
GFFormsModel::save_form_confirmations($id, $confirmations);
//updating form meta
RGFormsModel::update_form_meta($id, $form_meta);
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, true);
return array("status" => $id * -1, "meta" => $form_meta);
}
}