/** * Update Custom Labels in the database from current settings posted * in the Custom Options > Custom Labels admin page. * * @since 1.2 */ function genesis_extender_update_labels($label_names = '') { $these_labels = array(); $label_name_array = array(); if (!empty($label_names[1])) { foreach ($label_names as $key => $value) { $these_labels[$key]['label_name'] = $value; } } if (!empty($these_labels)) { foreach ($these_labels as $this_label) { $genesis_extender_labels = get_option('genesis_extender_custom_labels'); $label_name = $this_label['label_name']; $label_id = genesis_extender_sanatize_string($label_name); if (!empty($label_name)) { $new_values = array($label_id => array('label_id' => $label_id, 'label_name' => $label_name)); $merged_page_label = array_merge($genesis_extender_labels, $new_values); update_option('genesis_extender_custom_labels', $merged_page_label); } } } }
/** * Use ajax to update the Custom Options based on the posted values. * * @since 1.0 */ function genesis_extender_custom_options_save() { check_ajax_referer('custom-options', 'security'); if (!empty($_POST['extender']['css_builder_popup_active']) || genesis_extender_get_custom_css('css_builder_popup_active')) { $custom_css = genesis_extender_get_custom_css('custom_css'); } else { $custom_css = $_POST['extender']['custom_css']; } $css_update = array('custom_css' => $custom_css, 'css_builder_popup_active' => !empty($_POST['extender']['css_builder_popup_active']) ? 1 : 0, 'css_builder_popup_editor_only' => !empty($_POST['extender']['css_builder_popup_editor_only']) ? 1 : 0); $css_update_merged = array_merge(genesis_extender_custom_css_options_defaults(), $css_update); update_option('genesis_extender_custom_css', $css_update_merged); $functions_default = '<?php /* Do not remove this line. Add your functions below. */ '; if (!empty($_POST['custom_functions'])) { $functions_update = array('custom_functions_effect_admin' => !empty($_POST['custom_functions']['custom_functions_effect_admin']) ? 1 : 0, 'custom_functions' => $_POST['custom_functions']['custom_functions'] != '' ? $_POST['custom_functions']['custom_functions'] : $functions_default); $functions_update_merged = array_merge(genesis_extender_custom_functions_options_defaults(), $functions_update); update_option('genesis_extender_custom_functions', $functions_update_merged); } if (!empty($_POST['custom_js'])) { $js_update = array('custom_js_in_head' => !empty($_POST['custom_js']['custom_js_in_head']) ? 1 : 0, 'custom_js' => $_POST['custom_js']['custom_js']); $js_update_merged = array_merge(genesis_extender_custom_js_options_defaults(), $js_update); update_option('genesis_extender_custom_js', $js_update_merged); } if (!empty($_POST['custom_template_ids'])) { $template_ids_empty = true; foreach ($_POST['custom_template_ids'] as $key) { if (!empty($key)) { $template_ids_empty = false; } } foreach ($_POST['custom_template_ids'] as $key) { if (empty($key) && !$template_ids_empty) { echo 'Please fill in ALL "File Name" fields'; exit; } } genesis_extender_update_templates($_POST['custom_template_ids'], $_POST['custom_template_names'], $_POST['custom_template_types'], $_POST['custom_template_textarea']); } if (!empty($_POST['custom_label_names'])) { $label_names_empty = true; foreach ($_POST['custom_label_names'] as $key) { if (!empty($key)) { $label_names_empty = false; } } foreach ($_POST['custom_label_names'] as $key) { if (empty($key) && !$label_names_empty) { echo 'Please fill in ALL "Name" fields'; exit; } } genesis_extender_update_labels($_POST['custom_label_names']); if (!empty($_POST['custom_label_create_conditionals'])) { $custom_conditional_ids = array(); $custom_conditional_tags = array(); foreach ($_POST['custom_label_create_conditionals'] as $key => $value) { $custom_conditional_ids[] = 'has_label_' . str_replace('-', '_', genesis_extender_sanatize_string($_POST['custom_label_names'][$key])); $custom_conditional_tags[] = 'extender_has_label(\'' . genesis_extender_sanatize_string($_POST['custom_label_names'][$key]) . '\')'; } genesis_extender_update_conditionals($custom_conditional_ids, $custom_conditional_tags); } } if (!empty($_POST['custom_widget_conditionals_list'])) { $custom_widget_conditionals_list = $_POST['custom_widget_conditionals_list']; } else { $custom_widget_conditionals_list = array(); } if (!empty($_POST['custom_hook_conditionals_list'])) { $custom_hook_conditionals_list = $_POST['custom_hook_conditionals_list']; } else { $custom_hook_conditionals_list = array(); } if (!empty($_POST['custom_conditional_ids'])) { $conditional_ids_empty = true; foreach ($_POST['custom_conditional_ids'] as $key) { if (!empty($key)) { $conditional_ids_empty = false; } } foreach ($_POST['custom_conditional_ids'] as $key) { if (empty($key) && !$conditional_ids_empty) { echo 'Please fill in ALL "Name" fields'; exit; } } genesis_extender_update_conditionals($_POST['custom_conditional_ids'], $_POST['custom_conditional_tags']); } if (!empty($_POST['custom_widget_ids'])) { $widget_ids_empty = true; foreach ($_POST['custom_widget_ids'] as $key) { if (!empty($key)) { $widget_ids_empty = false; } } foreach ($_POST['custom_widget_ids'] as $key) { if (empty($key) && !$widget_ids_empty) { echo 'Please fill in ALL "Name" fields'; exit; } } genesis_extender_update_widgets($_POST['custom_widget_ids'], $custom_widget_conditionals_list, $_POST['custom_widget_hook'], $_POST['custom_widget_class'], $_POST['custom_widget_status'], $_POST['custom_widget_priority']); } if (!empty($_POST['custom_hook_ids'])) { $hook_ids_empty = true; foreach ($_POST['custom_hook_ids'] as $key) { if (!empty($key)) { $hook_ids_empty = false; } } foreach ($_POST['custom_hook_ids'] as $key) { if (empty($key) && !$hook_ids_empty) { echo 'Please fill in ALL "Name" fields'; exit; } } genesis_extender_update_hooks($_POST['custom_hook_ids'], $custom_hook_conditionals_list, $_POST['custom_hook_hook'], $_POST['custom_hook_status'], $_POST['custom_hook_priority'], $_POST['custom_hook_textarea']); } genesis_extender_write_files($css = true, $ez = false); echo 'Custom Options Updated'; exit; }