本文整理汇总了PHP中GFCommon::add_error_message方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::add_error_message方法的具体用法?PHP GFCommon::add_error_message怎么用?PHP GFCommon::add_error_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::add_error_message方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: maybe_save_plugin_settings
/**
* Fork of maybe_save_plugin_settings to get auth token..
*
* @access public
* @return void
*/
public function maybe_save_plugin_settings()
{
if ($this->is_save_postback()) {
// store a copy of the previous settings for cases where action whould only happen if value has changed
$this->set_previous_settings($this->get_plugin_settings());
$settings = $this->get_posted_settings();
if ($this->have_plugin_settings_changed()) {
$settings = $this->update_auth_token($settings);
}
$sections = $this->plugin_settings_fields();
$is_valid = $this->validate_settings($sections, $settings);
if ($is_valid) {
$settings = $this->filter_settings($sections, $settings);
$this->update_plugin_settings($settings);
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
}
}
示例2: maybe_save_plugin_settings
public function maybe_save_plugin_settings()
{
//Make sure we're really saving..
if ($this->is_save_postback()) {
//Get settings that were posted
$settings = $this->get_posted_settings();
//See if the key is there
if (array_key_exists('gfdo_key', (array) $settings)) {
//Put new key in var
$newKey = trim($settings['gfdo_key']);
//Reset old key var
$oldKey = "";
//Get existing settings
$gfdo_settings = get_option('gfdosettings');
//See if settings is an array
if (is_array($gfdo_settings)) {
//If old settings has a key...
if (array_key_exists('gfdo_key', (array) $gfdo_settings)) {
//...Assign it to a var
$oldKey = $gfdo_settings['gfdo_key'];
//If the new key is longer than 0 characters..
if (strlen($newKey) > 0) {
//Put the new key in the array
$gfdo_settings['gfdo_key'] = $newKey;
//And update options with it
update_option('gfdosettings', $gfdo_settings);
}
} else {
$gfdo_settings['gfdo_key'] = $newKey;
update_option('gfdosettings', $gfdo_settings);
}
} else {
$gfdo_settings['gfdo_key'] = $newKey;
update_option('gfdosettings', $gfdo_settings);
}
}
//ORIGINAL CODE BELOW FOR SAVING
// store a copy of the previous settings for cases where action whould only happen if value has changed
$this->set_previous_settings($this->get_plugin_settings());
$sections = $this->plugin_settings_fields();
$is_valid = $this->validate_settings($sections, $settings);
if ($is_valid) {
$this->update_plugin_settings($settings);
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
}
}
示例3: import_form_page
public static function import_form_page()
{
if (!GFCommon::current_user_can_any('gravityforms_edit_forms')) {
wp_die('You do not have permission to access this page');
}
if (isset($_POST['import_forms'])) {
check_admin_referer('gf_import_forms', 'gf_import_forms_nonce');
if (!empty($_FILES['gf_import_file']['tmp_name'])) {
$count = self::import_file($_FILES['gf_import_file']['tmp_name'], $forms);
if ($count == 0) {
GFCommon::add_error_message(__('Forms could not be imported. Please make sure your export file is in the correct format.', 'gravityforms'));
} else {
if ($count == '-1') {
GFCommon::add_error_message(__('Forms could not be imported. Your export file is not compatible with your current version of Gravity Forms.', 'gravityforms'));
} else {
$form_text = $count > 1 ? __('forms', 'gravityforms') : __('form', 'gravityforms');
$edit_link = $count == 1 ? "<a href='admin.php?page=gf_edit_forms&id={$forms[0]['id']}'>" . __('Edit Form', 'gravityforms') . '</a>' : '';
GFCommon::add_message(sprintf(__("Gravity Forms imported %d {$form_text} successfully", 'gravityforms'), $count) . ". {$edit_link}");
}
}
}
}
self::page_header(__('Import Forms', 'gravityforms'));
?>
<p class="textleft">
<?php
esc_html_e('Select the Gravity Forms export file you would like to import. When you click the import button below, Gravity Forms will import the forms.', 'gravityforms');
?>
</p>
<div class="hr-divider"></div>
<form method="post" enctype="multipart/form-data" style="margin-top:10px;">
<?php
wp_nonce_field('gf_import_forms', 'gf_import_forms_nonce');
?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<label for="gf_import_file"><?php
esc_html_e('Select File', 'gravityforms');
?>
</label> <?php
gform_tooltip('import_select_file');
?>
</th>
<td><input type="file" name="gf_import_file" id="gf_import_file" /></td>
</tr>
</table>
<br /><br />
<input type="submit" value="<?php
esc_html_e('Import', 'gravityforms');
?>
" name="import_forms" class="button button-large button-primary" />
</form>
<?php
self::page_footer();
}
示例4: maybe_save_feed_settings
protected function maybe_save_feed_settings($feed_id, $form_id)
{
if (!rgpost('gform-settings-save')) {
return $feed_id;
}
// store a copy of the previous settings for cases where action would only happen if value has changed
$feed = $this->get_feed($feed_id);
$this->set_previous_settings($feed['meta']);
$settings = $this->get_posted_settings();
$sections = $this->get_feed_settings_fields();
$settings = $this->trim_conditional_logic_vales($settings, $form_id);
$is_valid = $this->validate_settings($sections, $settings);
$result = false;
if ($is_valid) {
$feed_id = $this->save_feed_settings($feed_id, $form_id, $settings);
if ($feed_id) {
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
return $feed_id;
}
示例5: maybe_process_notification_list_action
public static function maybe_process_notification_list_action()
{
if (empty($_POST) || !check_admin_referer('gform_notification_list_action', 'gform_notification_list_action')) {
return;
}
$action = rgpost('action');
$object_id = rgpost('action_argument');
switch ($action) {
case 'delete':
$notification_deleted = GFNotification::delete_notification($object_id, rgget('id'));
if ($notification_deleted) {
GFCommon::add_message(__('Notification deleted.', 'gravityforms'));
} else {
GFCommon::add_error_message(__('There was an issue deleting this notification.', 'gravityforms'));
}
break;
case 'duplicate':
$notification_duplicated = GFNotification::duplicate_notification($object_id, rgget('id'));
if ($notification_duplicated) {
GFCommon::add_message(__('Notification duplicates.', 'gravityforms'));
} else {
GFCommon::add_error_message(__('There was an issue duplicating this notification.', 'gravityforms'));
}
break;
}
}
示例6: validate_notification
private static function validate_notification()
{
$is_valid = self::is_valid_notification_to() && !rgempty('gform_notification_subject') && !rgempty('gform_notification_message');
$bcc = rgpost('gform_notification_bcc');
if (!empty($bcc) && !self::is_valid_notification_email($bcc)) {
$is_valid = false;
GFCommon::add_error_message(esc_html__('Please enter a valid email address or merge tag in the BCC field.', 'gravityforms'));
}
$reply_to = rgpost('gform_notification_reply_to');
if (!empty($bcc) && !self::is_valid_notification_email($reply_to)) {
$is_valid = false;
GFCommon::add_error_message(esc_html__('Please enter a valid email address or merge tag in the Reply To field.', 'gravityforms'));
}
return $is_valid;
}
示例7: maybe_save_app_settings
/**
* Saves the plugin settings if the submit button was pressed
*
*/
public function maybe_save_app_settings()
{
if ($this->is_save_postback()) {
check_admin_referer($this->_slug . '_save_settings', '_' . $this->_slug . '_save_settings_nonce');
if (!$this->current_user_can_any($this->_capabilities_app_settings)) {
GFCommon::add_error_message(esc_html__("You don't have sufficient permissions to update the settings.", 'gravityforms'));
return false;
}
// store a copy of the previous settings for cases where action would only happen if value has changed
$this->set_previous_settings($this->get_app_settings());
$settings = $this->get_posted_settings();
$sections = $this->app_settings_fields();
$is_valid = $this->validate_settings($sections, $settings);
if ($is_valid) {
$settings = $this->filter_settings($sections, $settings);
$this->update_app_settings($settings);
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
}
}
示例8: maybe_save_form_settings
public function maybe_save_form_settings($form)
{
if ($this->is_save_postback()) {
// store a copy of the previous settings for cases where action whould only happen if value has changed
$this->set_previous_settings($this->get_form_settings($form));
$settings = $this->get_posted_settings();
$sections = $this->form_settings_fields($form);
$is_valid = $this->validate_settings($sections, $settings);
$result = false;
if ($is_valid) {
$result = $this->save_form_settings($form, $settings);
}
if ($result) {
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
return $result;
}
}
示例9: maybe_save_feed_settings
public function maybe_save_feed_settings($feed_id, $form_id)
{
if (!rgpost('gform-settings-save')) {
return $feed_id;
}
check_admin_referer($this->_slug . '_save_settings', '_' . $this->_slug . '_save_settings_nonce');
if (!$this->current_user_can_any($this->_capabilities_form_settings)) {
GFCommon::add_error_message(esc_html__("You don't have sufficient permissions to update the form settings.", 'gravityforms'));
return $feed_id;
}
// store a copy of the previous settings for cases where action would only happen if value has changed
$feed = $this->get_feed($feed_id);
$this->set_previous_settings($feed['meta']);
$settings = $this->get_posted_settings();
$sections = $this->get_feed_settings_fields();
$settings = $this->trim_conditional_logic_vales($settings, $form_id);
$is_valid = $this->validate_settings($sections, $settings);
$result = false;
if ($is_valid) {
$settings = $this->filter_settings($sections, $settings);
$feed_id = $this->save_feed_settings($feed_id, $form_id, $settings);
if ($feed_id) {
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
return $feed_id;
}
示例10: maybe_save_feed_settings
protected function maybe_save_feed_settings($feed_id, $form_id)
{
if (!rgpost('gform-settings-save')) {
return $feed_id;
}
$settings = $this->get_posted_settings();
$is_valid = $this->validate_settings($this->get_feed_settings_fields(), $settings);
$result = false;
if ($is_valid) {
$result = $this->save_feed_settings($feed_id, $form_id, $settings);
}
if ($result) {
GFCommon::add_message(__('Feed updated successfully.', 'gravityforms'));
} else {
GFCommon::add_error_message(__('There was an error updating this feed. Please review all errors below and try again.', 'gravityforms'));
}
// if no $feed_id is passed, assume that a new feed was created and return new $feed_id
if (!$feed_id) {
$feed_id = $result;
}
return $feed_id;
}
示例11: get_posted_settings
/**
* When the settings are saved, make sure the license key matches the previously activated key
*
* @return array settings from parent::get_posted_settings(), with `license_key_response` and `license_key_status` potentially unset
*/
public function get_posted_settings()
{
$posted_settings = parent::get_posted_settings();
// If the posted key doesn't match the activated/deactivated key (set using the Activate License button, AJAX response),
// then we assume it's changed. If it's changed, unset the status and the previous response.
if (isset($posted_settings['license_key']) && isset($posted_settings['license_key_response']['license_key']) && $posted_settings['license_key'] !== $posted_settings['license_key_response']['license_key']) {
unset($posted_settings['license_key_response']);
unset($posted_settings['license_key_status']);
GFCommon::add_error_message(__('The license key you entered has been saved, but not activated. Please activate the license.', 'gravityview'));
}
return $posted_settings;
}
示例12: maybe_save_feed_settings
protected function maybe_save_feed_settings($feed_id, $form_id)
{
if (!rgpost('gform-settings-save')) {
return $feed_id;
}
// store a copy of the previous settings for cases where action whould only happen if value has changed
$feed = $this->get_feed($feed_id);
$this->set_previous_settings($feed['meta']);
$settings = $this->get_posted_settings();
$sections = $this->get_feed_settings_fields();
$is_valid = $this->validate_settings($sections, $settings);
$result = false;
if ($is_valid) {
$result = $this->save_feed_settings($feed_id, $form_id, $settings);
}
if ($result) {
GFCommon::add_message($this->get_save_success_message($sections));
} else {
GFCommon::add_error_message($this->get_save_error_message($sections));
}
// if no $feed_id is passed, assume that a new feed was created and return new $feed_id
if (!$feed_id) {
$feed_id = $result;
}
return $feed_id;
}
示例13: import_form_page
public static function import_form_page()
{
if (isset($_POST["import_forms"])) {
check_admin_referer("gf_import_forms", "gf_import_forms_nonce");
if (!empty($_FILES["gf_import_file"]["tmp_name"])) {
$count = self::import_file($_FILES["gf_import_file"]["tmp_name"], $forms);
if ($count == 0) {
GFCommon::add_error_message(__("Forms could not be imported. Please make sure your XML export file is in the correct format.", "gravityforms"));
} else {
if ($count == "-1") {
GFCommon::add_error_message(__("Forms could not be imported. Your XML export file is not compatible with your current version of Gravity Forms.", "gravityforms"));
} else {
$form_text = $count > 1 ? __("forms", "gravityforms") : __("form", "gravityforms");
$edit_link = $count == 1 ? "<a href='admin.php?page=gf_edit_forms&id={$forms[0]["id"]}'>" . __("Edit Form", "gravityforms") . "</a>" : "";
GFCommon::add_message(sprintf(__("Gravity Forms imported %d {$form_text} successfully", "gravityforms"), $count) . ". {$edit_link}");
}
}
}
}
self::page_header(__('Import Forms'));
?>
<style type="text/css">
.wrap.import_form .icon32 { background-image: url(<?php
echo GFCommon::get_base_url();
?>
/images/gravity-import-icon-32.png) !important; }
</style>
<p class="textleft">
<?php
_e("Select the Gravity Forms XML file you would like to import. When you click the import button below, Gravity Forms will import the forms.", "gravityforms");
?>
</p>
<div class="hr-divider"></div>
<form method="post" enctype="multipart/form-data" style="margin-top:10px;">
<?php
echo wp_nonce_field("gf_import_forms", "gf_import_forms_nonce");
?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="gf_import_file"><?php
_e("Select File", "gravityforms");
?>
</label></th>
<td><input type="file" name="gf_import_file" id="gf_import_file"/></td>
</tr>
</table>
<br /><br />
<input type="submit" value="<?php
_e("Import", "gravityforms");
?>
" name="import_forms" class="button button-large button-primary" />
</form>
<?php
self::page_footer();
}
示例14: zapier_edit_page
private static function zapier_edit_page($form_id, $zap_id)
{
$zap = empty($zap_id) ? array() : GFZapierData::get_feed($zap_id);
$is_new_zap = empty($zap_id) || empty($zap);
$is_valid = true;
$is_update = false;
$form = RGFormsModel::get_form_meta($form_id);
if (rgpost("save")) {
check_admin_referer('gforms_save_zap', 'gforms_save_zap');
if (rgar($zap, "url") != rgpost("gform_zapier_url")) {
$is_update = true;
}
$zap["name"] = rgpost("gform_zapier_name");
$zap["url"] = rgpost("gform_zapier_url");
$zap["is_active"] = rgpost("gform_zapier_active");
//conditional
$zap["meta"]["zapier_conditional_enabled"] = rgpost("gf_zapier_conditional_enabled");
$zap["meta"]["zapier_conditional_field_id"] = rgpost("gf_zapier_conditional_field_id");
$zap["meta"]["zapier_conditional_operator"] = rgpost("gf_zapier_conditional_operator");
$zap["meta"]["zapier_conditional_value"] = rgpost("gf_zapier_conditional_value");
if (empty($zap["url"]) || empty($zap["name"])) {
$is_valid = false;
}
if ($is_valid) {
$zap = apply_filters('gform_zap_before_save', apply_filters("gform_zap_before_save_{$form['id']}", $zap, $form), $form);
$zap_id = GFZapierData::update_feed($zap_id, $form_id, $zap["is_active"], $zap["name"], $zap["url"], $zap["meta"]);
GFCommon::add_message(sprintf(__('Zap saved successfully. %sBack to list.%s', 'gravityformszapier'), '<a href="' . esc_url(remove_query_arg('zid')) . '">', '</a>'));
if ($is_new_zap || $is_update) {
//send field info to zap when new or url has changed
$sent = self::send_form_data_to_zapier("", $form);
}
} else {
GFCommon::add_error_message(__('Zap could not be updated. Please enter all required information below.', 'gravityformszapier'));
}
}
GFFormSettings::page_header(__('Zapier', 'gravityformszapier'));
?>
<style type="text/css">
a.limit-text { display: block; height: 18px; line-height: 18px; overflow: hidden; padding-right: 5px;
color: #555; text-overflow: ellipsis; white-space: nowrap; }
a.limit-text:hover { color: #555; }
th.column-name { width: 30%; }
th.column-type { width: 20%; }
</style>
<div style="<?php
echo $is_new_zap ? "display:block" : "display:none";
?>
">
<?php
_e(sprintf("To create a new zap, you must have the Webhook URL. The Webhook URL may be found when you go to your %sZapier dashboard%s and create a new zap, or when you edit an existing zap. Once you have saved your new feed the form fields will be available for mapping on the Zapier site.", "<a href='https://zapier.com/app/dashboard' target='_blank'>", "</a>"));
?>
</div>
<form method="post" id="gform_zapier_form">
<?php
wp_nonce_field('gforms_save_zap', 'gforms_save_zap');
?>
<input type="hidden" id="gform_zap_id" name="gform_zap_id" value="<?php
echo $zap_id;
?>
" />
<table class="form-table">
<tr valign="top">
<th scope="row">
<label for="gform_zapier_name">
<?php
_e("Zap Name", "gravityformszapier");
?>
<span class="gfield_required">*</span>
<?php
gform_tooltip("zapier_name");
?>
</label>
</th>
<td>
<input type="text" class="fieldwidth-2" name="gform_zapier_name" id="gform_zapier_name" value="<?php
echo esc_attr(rgar($zap, "name"));
?>
"/>
</td>
</tr>
<tr valign="top">
<th scope="row">
<label for="gform_zapier_url">
<?php
_e("Webhook URL", "gravityformszapier");
?>
<span class="gfield_required">*</span>
<?php
gform_tooltip("zapier_url");
?>
</label>
</th>
<td>
<input type="text" class="fieldwidth-2" name="gform_zapier_url" id="gform_zapier_url" value="<?php
echo esc_attr(rgar($zap, "url"));
?>
"/>
</td>
</tr>
//.........这里部分代码省略.........