本文整理汇总了PHP中GFAPI::add_forms方法的典型用法代码示例。如果您正苦于以下问题:PHP GFAPI::add_forms方法的具体用法?PHP GFAPI::add_forms怎么用?PHP GFAPI::add_forms使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFAPI
的用法示例。
在下文中一共展示了GFAPI::add_forms方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_json
public static function import_json($forms_json, &$forms = null)
{
$forms = json_decode($forms_json, true);
if (!$forms) {
GFCommon::log_debug(__METHOD__ . '(): Import Failed. Invalid form objects.');
return 0;
} else {
if (version_compare($forms['version'], self::$min_import_version, '<')) {
GFCommon::log_debug(__METHOD__ . '(): Import Failed. The JSON version is not compatible with the current Gravity Forms version.');
return -1;
}
}
//Error. JSON version is not compatible with current Gravity Forms version
unset($forms['version']);
$form_ids = GFAPI::add_forms($forms);
if (is_wp_error($form_ids)) {
GFCommon::log_debug(__METHOD__ . '(): Import Failed => ' . print_r($form_ids, 1));
$form_ids = array();
} else {
foreach ($form_ids as $key => $form_id) {
$forms[$key]['id'] = $form_id;
}
/**
* Fires after forms have been imported.
*
* Used to perform additional actions after import
*
* @param array $forms An array imported form objects.
*
*/
do_action('gform_forms_post_import', $forms);
}
return sizeof($form_ids);
}
示例2: import_json
public static function import_json($forms_json, &$forms = null)
{
$forms = json_decode($forms_json, true);
if (!$forms) {
return 0;
} else {
if (version_compare($forms['version'], self::$min_import_version, '<')) {
return -1;
}
}
//Error. JSON version is not compatible with current Gravity Forms version
unset($forms['version']);
$form_ids = GFAPI::add_forms($forms);
if (is_wp_error($form_ids)) {
$form_ids = array();
} else {
foreach ($form_ids as $key => $form_id) {
$forms[$key]['id'] = $form_id;
}
}
return sizeof($form_ids);
}
示例3: post_forms
public function post_forms($data)
{
$this->authorize("gravityforms_create_form");
$form_ids = GFAPI::add_forms($data);
if (is_wp_error($form_ids) || count($form_ids) == 0) {
$response = $this->get_error_response($form_ids);
$status = $this->get_error_status($form_ids);
} else {
$status = 201;
$response = $form_ids;
}
$this->end($status, $response);
}
示例4: post_forms
public function post_forms($data)
{
$this->log_debug(__METHOD__ . '(): Running.');
$capability = apply_filters('gform_web_api_capability_post_forms', 'gravityforms_create_form');
$this->authorize($capability);
$form_ids = GFAPI::add_forms($data);
if (is_wp_error($form_ids) || count($form_ids) == 0) {
$response = $this->get_error_response($form_ids);
$status = $this->get_error_status($form_ids);
} else {
$status = 201;
$response = $form_ids;
}
$this->end($status, $response);
}
示例5: import_json
public static function import_json($forms_json, &$forms = null)
{
$forms = json_decode($forms_json, true);
if (!$forms) {
return 0;
} else {
if (version_compare($forms['version'], self::$min_import_version, '<')) {
return -1;
}
}
//Error. JSON version is not compatible with current Gravity Forms version
unset($forms['version']);
$form_ids = GFAPI::add_forms($forms);
if (is_wp_error($form_ids)) {
$form_ids = array();
} else {
foreach ($form_ids as $key => $form_id) {
$forms[$key]['id'] = $form_id;
}
/**
* Fires after forms have been imported.
*
* @param array $forms An array imported form objects.
*
*/
do_action('gform_forms_post_import', $forms);
}
return sizeof($form_ids);
}