本文整理汇总了PHP中TribeEvents::setNetworkOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP TribeEvents::setNetworkOptions方法的具体用法?PHP TribeEvents::setNetworkOptions怎么用?PHP TribeEvents::setNetworkOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TribeEvents
的用法示例。
在下文中一共展示了TribeEvents::setNetworkOptions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* save the settings
*
* @since 2.0.5
* @author jkudish
* @return void
*/
public function save()
{
// some hooks
do_action('tribe_settings_save');
do_action('tribe_settings_save_tab_' . $this->currentTab);
// we'll need this later
$parent_options = array();
/**
* loop through each validated option and either
* save it as is or figure out its parent option ID
* (in that case, it's a serialized option array and
* will be saved in the next loop)
*/
if (!empty($this->validated)) {
foreach ($this->validated as $field_id => $validated_field) {
// get the value and filter it
$value = $validated_field->value;
$value = apply_filters('tribe_settings_save_field_value', $value, $field_id, $validated_field);
// figure out the parent option [could be set to false] and filter it
if (is_network_admin()) {
$parent_option = isset($validated_field->field['parent_option']) ? $validated_field->field['parent_option'] : TribeEvents::OPTIONNAMENETWORK;
}
if (!is_network_admin()) {
$parent_option = isset($validated_field->field['parent_option']) ? $validated_field->field['parent_option'] : TribeEvents::OPTIONNAME;
}
$parent_option = apply_filters('tribe_settings_save_field_parent_option', $parent_option, $field_id);
// some hooks
do_action('tribe_settings_save_field', $field_id, $value, $validated_field);
do_action('tribe_settings_save_field_' . $field_id, $value, $validated_field);
if (!$parent_option) {
if (is_network_admin()) {
update_site_option($field_id, $value);
} else {
update_option($field_id, $value);
}
} else {
// set the parent option
$parent_options[$parent_option][$field_id] = $value;
}
}
}
/**
* loop through parent option arrays
* and save them
* NOTE: in the case of the main option Tribe Options,
* this will save using the TribeEvents:setOptions method.
*/
foreach ($parent_options as $option_id => $new_options) {
// get the old options
if ($option_id == TribeEvents::OPTIONNAME) {
$old_options = (array) get_option($option_id);
} else {
$old_options = (array) get_site_option($option_id);
}
// set the options by parsing old + new and filter that
$options = apply_filters('tribe_settings_save_option_array', wp_parse_args($new_options, $old_options), $option_id);
if ($option_id == TribeEvents::OPTIONNAME) {
// save using the TribeEvents method
TribeEvents::setOptions($options);
} elseif ($option_id == TribeEvents::OPTIONNAMENETWORK) {
TribeEvents::setNetworkOptions($options);
} else {
// save using regular WP method
if (is_network_admin()) {
update_site_option($option_id, $options);
} else {
update_option($option_id, $options);
}
}
}
do_action('tribe_settings_after_save');
do_action('tribe_settings_after_save_' . $this->currentTab);
remove_action('shutdown', array($this, 'deleteOptions'));
add_option('tribe_settings_sent_data', $_POST);
add_option('tribe_settings_errors', $this->errors);
add_option('tribe_settings_major_error', $this->major_error);
wp_redirect(add_query_arg(array('saved' => true), $this->url));
exit;
}