function enlightenment_page_builder_form_save_postdata($post_id) { if (!isset($_POST['enlightenment_page_builder'])) { return $post_id; } $nonce = $_POST['enlightenment_page_builder_form_nonce']; if (!wp_verify_nonce($nonce, 'enlightenment_page_builder_form')) { return $post_id; } if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } $post = get_post($post_id); if (!current_user_can(get_post_type_object($post->post_type)->cap->edit_post, $post_id)) { return $post_id; } if (isset($_POST['enlightenment_default_template_hooks']) && $_POST['enlightenment_default_template_hooks']) { update_post_meta($post_id, '_enlightenment_page_builder', ''); return; } $hooks = $_POST['enlightenment_page_builder']; foreach ($hooks as $hook => $functions) { $functions = explode(',', $functions); $atts = enlightenment_get_template_hook($hook); foreach ($functions as $key => $function) { if (!in_array($function, $atts['functions'])) { unset($functions[$key]); } } $hooks[$hook] = $functions; } update_post_meta($post_id, '_enlightenment_page_builder', $hooks); }
function enlightenment_validate_post_formats_editor($input) { foreach ($input['template_hooks'] as $post_format => $hooks) { if ($post_format != $input['select_post_format']) { unset($input['template_hooks'][$post_format]); } } $post_format = $input['select_post_format']; unset($input['select_post_format']); foreach ($input['template_hooks'][$post_format] as $hook => $functions) { if (!in_array($hook, array_keys(enlightenment_entry_hooks()))) { unset($input['template_hooks'][$post_format][$hook]); } } foreach ($input['template_hooks'][$post_format] as $hook => $functions) { $functions = explode(',', $functions); $atts = enlightenment_get_template_hook($hook); foreach ($functions as $key => $function) { if (!in_array($function, $atts['functions'])) { unset($functions[$key]); } } $input['template_hooks'][$post_format][$hook] = $functions; } $option = enlightenment_theme_option('template_hooks', array()); $input['template_hooks'] = array_merge($option, $input['template_hooks']); return $input; }
function enlightenment_validate_template_editor($input) { foreach ($input['template_hooks'] as $template => $hooks) { if ($template != $input['select_template']) { unset($input['template_hooks'][$template]); } } $template = $input['select_template']; unset($input['select_template']); $atts = enlightenment_get_template($template); foreach ($input['template_hooks'][$template] as $hook => $functions) { if (!in_array($hook, $atts['hooks'])) { unset($input['template_hooks'][$template][$hook]); } } foreach ($input['template_hooks'][$template] as $hook => $functions) { $functions = explode(',', $functions); $atts = enlightenment_get_template_hook($hook); foreach ($functions as $key => $function) { if (!in_array($function, $atts['functions'])) { unset($functions[$key]); } } $input['template_hooks'][$template][$hook] = $functions; } $option = enlightenment_theme_option('template_hooks', array()); $input['template_hooks'] = array_merge($option, $input['template_hooks']); return $input; }