Exemplo n.º 1
0
function genesis_extender_settings_write_styles()
{
    if (get_admin_page_title() != 'Theme Settings') {
        return;
    }
    genesis_extender_write_files($css = true, $ez = true, $custom = false);
}
/**
 * Import the specified Custom Option settings into
 * their appropriate sections of the wp_options table.
 *
 * @since 1.0
 */
function genesis_extender_custom_import($import_file, $theme_settings = '', $custom_css = '', $custom_functions = '', $custom_js = '', $custom_templates = '', $custom_labels = '', $conditionals = '', $widget_areas = '', $hook_boxes = '', $images = '')
{
    $genesis_extender_templates = get_option('genesis_extender_custom_templates');
    $genesis_extender_labels = get_option('genesis_extender_custom_labels');
    $genesis_extender_conditionals = get_option('genesis_extender_custom_conditionals');
    $genesis_extender_widgets = get_option('genesis_extender_custom_widget_areas');
    $genesis_extender_hooks = get_option('genesis_extender_custom_hook_boxes');
    if ('zip' == strtolower(substr(strrchr($import_file['name'], '.'), 1))) {
        genesis_extender_folders_open_permissions();
        require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
        $tmp_path = genesis_extender_get_stylesheet_location('path') . 'tmp';
        $tmp_import_folder = $tmp_path . '/import';
        $tmp_image_folder = $tmp_import_folder . '/images';
        $tmp_adthumbs_folder = $tmp_image_folder . '/adminthumbnails';
        $image_folder = genesis_extender_get_stylesheet_location('path') . 'images';
        $adthumbs_folder = $image_folder . '/adminthumbnails';
        if (!is_dir($tmp_path)) {
            @mkdir($tmp_path, 0755, true);
        }
        if (!is_dir($tmp_import_folder)) {
            @mkdir($tmp_import_folder, 0755, true);
        }
        $import_tmp_name = $import_file['tmp_name'];
        $zip_file = new PclZip($import_tmp_name);
        if (($unzip_result_list = $zip_file->extract(PCLZIP_OPT_PATH, $tmp_import_folder)) == 0) {
            die("Error : " . $zip_file->errorInfo(true));
        }
        $handle = opendir($tmp_import_folder);
        while (false !== ($file = readdir($handle))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'dat') {
                $import_data = file_get_contents($tmp_import_folder . '/' . $file);
                $genesis_extender_import = unserialize($import_data);
                if (!empty($theme_settings)) {
                    if (!empty($genesis_extender_import['genesis_extender_settings'])) {
                        $plugin_settings_import = array_merge(genesis_extender_settings_defaults(false, $genesis_extender_import['genesis_extender_settings']), $genesis_extender_import['genesis_extender_settings']);
                        update_option('genesis_extender_settings', $plugin_settings_import);
                    }
                }
                if (!empty($custom_css)) {
                    if (!empty($genesis_extender_import['genesis_extender_custom_css'])) {
                        $custom_css_import = array_merge(genesis_extender_custom_css_options_defaults(), $genesis_extender_import['genesis_extender_custom_css']);
                        update_option('genesis_extender_custom_css', $custom_css_import);
                    }
                }
                if (!empty($custom_functions)) {
                    if (!empty($genesis_extender_import['genesis_extender_custom_functions'])) {
                        $custom_functions_import = array_merge(genesis_extender_custom_functions_options_defaults(), $genesis_extender_import['genesis_extender_custom_functions']);
                        update_option('genesis_extender_custom_functions', $custom_functions_import);
                    }
                }
                if (!empty($custom_js)) {
                    if (!empty($genesis_extender_import['genesis_extender_custom_js'])) {
                        $custom_js_import = array_merge(genesis_extender_custom_js_options_defaults(), $genesis_extender_import['genesis_extender_custom_js']);
                        update_option('genesis_extender_custom_js', $custom_js_import);
                    }
                }
                if (!empty($custom_templates)) {
                    if (!empty($genesis_extender_import['genesis_extender_templates'])) {
                        $genesis_extender_templates_array = array();
                        foreach ($genesis_extender_templates as $key => $value) {
                            if (!in_array($genesis_extender_templates[$key]['template_file_name'], $genesis_extender_templates_array)) {
                                $genesis_extender_templates_array[] = $genesis_extender_templates[$key]['template_file_name'];
                            }
                        }
                        foreach ($genesis_extender_import['genesis_extender_templates'] as $key => $value) {
                            if (in_array($genesis_extender_import['genesis_extender_templates'][$key]['template_file_name'], $genesis_extender_templates_array)) {
                                unset($genesis_extender_import['genesis_extender_templates'][$key]);
                            }
                        }
                        $templates_import = array_merge($genesis_extender_templates, $genesis_extender_import['genesis_extender_templates']);
                        update_option('genesis_extender_custom_templates', $templates_import);
                    }
                }
                if (!empty($custom_labels)) {
                    if (!empty($genesis_extender_import['genesis_extender_labels'])) {
                        $genesis_extender_labels_array = array();
                        foreach ($genesis_extender_labels as $key => $value) {
                            if (!in_array($genesis_extender_labels[$key]['label_name'], $genesis_extender_labels_array)) {
                                $genesis_extender_labels_array[] = $genesis_extender_labels[$key]['label_name'];
                            }
                        }
                        foreach ($genesis_extender_import['genesis_extender_labels'] as $key => $value) {
                            if (in_array($genesis_extender_import['genesis_extender_labels'][$key]['label_name'], $genesis_extender_labels_array)) {
                                unset($genesis_extender_import['genesis_extender_labels'][$key]);
                            }
                        }
                        $labels_import = array_merge($genesis_extender_labels, $genesis_extender_import['genesis_extender_labels']);
                        update_option('genesis_extender_custom_labels', $labels_import);
                    }
                }
                if (!empty($conditionals)) {
                    if (!empty($genesis_extender_import['genesis_extender_conditionals'])) {
                        $genesis_extender_conditionals_array = array();
                        foreach ($genesis_extender_conditionals as $key => $value) {
                            $genesis_extender_conditionals_array[] = $genesis_extender_conditionals[$key]['conditional_id'];
                        }
                        foreach ($genesis_extender_import['genesis_extender_conditionals'] as $key => $value) {
                            if (in_array($genesis_extender_import['genesis_extender_conditionals'][$key]['conditional_id'], $genesis_extender_conditionals_array)) {
                                unset($genesis_extender_import['genesis_extender_conditionals'][$key]);
                            }
                        }
                        $conditionals_import = array_merge($genesis_extender_conditionals, $genesis_extender_import['genesis_extender_conditionals']);
                        update_option('genesis_extender_custom_conditionals', $conditionals_import);
                    }
                }
                if (!empty($widget_areas)) {
                    if (!empty($genesis_extender_import['genesis_extender_widgets'])) {
                        $genesis_extender_widgets_array = array();
                        foreach ($genesis_extender_widgets as $key => $value) {
                            if (!in_array($genesis_extender_widgets[$key]['widget_name'], $genesis_extender_widgets_array)) {
                                $genesis_extender_widgets_array[] = $genesis_extender_widgets[$key]['widget_name'];
                            }
                        }
                        foreach ($genesis_extender_import['genesis_extender_widgets'] as $key => $value) {
                            if (in_array($genesis_extender_import['genesis_extender_widgets'][$key]['widget_name'], $genesis_extender_widgets_array)) {
                                unset($genesis_extender_import['genesis_extender_widgets'][$key]);
                            }
                        }
                        $widgets_import = array_merge($genesis_extender_widgets, $genesis_extender_import['genesis_extender_widgets']);
                        update_option('genesis_extender_custom_widget_areas', $widgets_import);
                    }
                }
                if (!empty($hook_boxes)) {
                    if (!empty($genesis_extender_import['genesis_extender_hooks'])) {
                        $genesis_extender_hooks_array = array();
                        foreach ($genesis_extender_hooks as $key => $value) {
                            if (!in_array($genesis_extender_hooks[$key]['hook_name'], $genesis_extender_hooks_array)) {
                                $genesis_extender_hooks_array[] = $genesis_extender_hooks[$key]['hook_name'];
                            }
                        }
                        foreach ($genesis_extender_import['genesis_extender_hooks'] as $key => $value) {
                            if (in_array($genesis_extender_import['genesis_extender_hooks'][$key]['hook_name'], $genesis_extender_hooks_array)) {
                                unset($genesis_extender_import['genesis_extender_hooks'][$key]);
                            }
                        }
                        $hooks_import = array_merge($genesis_extender_hooks, $genesis_extender_import['genesis_extender_hooks']);
                        update_option('genesis_extender_custom_hook_boxes', $hooks_import);
                    }
                }
            }
        }
        closedir($handle);
        if (!empty($images)) {
            $handle = opendir($tmp_image_folder);
            while (false !== ($file = readdir($handle))) {
                $ext = strtolower(substr(strrchr($file, '.'), 1));
                if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                    copy($tmp_image_folder . '/' . $file, $image_folder . '/' . $file);
                }
            }
            closedir($handle);
            $handle = opendir($tmp_adthumbs_folder);
            while (false !== ($file = readdir($handle))) {
                $ext = strtolower(substr(strrchr($file, '.'), 1));
                if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                    copy($tmp_adthumbs_folder . '/' . $file, $adthumbs_folder . '/' . $file);
                }
            }
            closedir($handle);
        }
        genesis_extender_delete_dir($tmp_import_folder);
        genesis_extender_folders_close_permissions();
        genesis_extender_write_files();
        wp_redirect(admin_url('admin.php?page=genesis-extender-settings&activetab=genesis-extender-settings-nav-import-export&notice=import-complete'));
        exit;
    } elseif ('dat' == strtolower(substr(strrchr($import_file['name'], '.'), 1))) {
        $import_data = file_get_contents($import_file['tmp_name']);
        $genesis_extender_import = unserialize($import_data);
        if (!empty($theme_settings)) {
            if (!empty($genesis_extender_import['genesis_extender_settings'])) {
                $plugin_settings_import = array_merge(genesis_extender_settings_defaults(false, $genesis_extender_import['genesis_extender_settings']), $genesis_extender_import['genesis_extender_settings']);
                update_option('genesis_extender_settings', $plugin_settings_import);
            }
        }
        if (!empty($custom_css)) {
            if (!empty($genesis_extender_import['genesis_extender_custom_css'])) {
                $custom_css_import = array_merge(genesis_extender_custom_css_options_defaults(), $genesis_extender_import['genesis_extender_custom_css']);
                update_option('genesis_extender_custom_css', $custom_css_import);
            }
        }
        if (!empty($custom_functions)) {
            if (!empty($genesis_extender_import['genesis_extender_custom_functions'])) {
                $custom_functions_import = array_merge(genesis_extender_custom_functions_options_defaults(), $genesis_extender_import['genesis_extender_custom_functions']);
                update_option('genesis_extender_custom_functions', $custom_functions_import);
            }
        }
        if (!empty($custom_js)) {
            if (!empty($genesis_extender_import['genesis_extender_custom_js'])) {
                $custom_js_import = array_merge(genesis_extender_custom_js_options_defaults(), $genesis_extender_import['genesis_extender_custom_js']);
                update_option('genesis_extender_custom_js', $custom_functions_import);
            }
        }
        if (!empty($custom_templates)) {
            if (!empty($genesis_extender_import['genesis_extender_templates'])) {
                $genesis_extender_templates_array = array();
                foreach ($genesis_extender_templates as $key => $value) {
                    if (!in_array($genesis_extender_templates[$key]['template_file_name'], $genesis_extender_templates_array)) {
                        $genesis_extender_templates_array[] = $genesis_extender_templates[$key]['template_file_name'];
                    }
                }
                foreach ($genesis_extender_import['genesis_extender_templates'] as $key => $value) {
                    if (in_array($genesis_extender_import['genesis_extender_templates'][$key]['template_file_name'], $genesis_extender_templates_array)) {
                        unset($genesis_extender_import['genesis_extender_templates'][$key]);
                    }
                }
                $templates_import = array_merge($genesis_extender_templates, $genesis_extender_import['genesis_extender_templates']);
                update_option('genesis_extender_custom_templates', $templates_import);
            }
        }
        if (!empty($custom_labels)) {
            if (!empty($genesis_extender_import['genesis_extender_labels'])) {
                $genesis_extender_labels_array = array();
                foreach ($genesis_extender_labels as $key => $value) {
                    if (!in_array($genesis_extender_labels[$key]['label_name'], $genesis_extender_labels_array)) {
                        $genesis_extender_labels_array[] = $genesis_extender_labels[$key]['label_name'];
                    }
                }
                foreach ($genesis_extender_import['genesis_extender_labels'] as $key => $value) {
                    if (in_array($genesis_extender_import['genesis_extender_labels'][$key]['label_name'], $genesis_extender_labels_array)) {
                        unset($genesis_extender_import['genesis_extender_labels'][$key]);
                    }
                }
                $labels_import = array_merge($genesis_extender_labels, $genesis_extender_import['genesis_extender_labels']);
                update_option('genesis_extender_custom_labels', $labels_import);
            }
        }
        if (!empty($conditionals)) {
            if (!empty($genesis_extender_import['genesis_extender_conditionals'])) {
                $genesis_extender_conditionals_array = array();
                foreach ($genesis_extender_conditionals as $key => $value) {
                    $genesis_extender_conditionals_array[] = $genesis_extender_conditionals[$key]['conditional_id'];
                }
                foreach ($genesis_extender_import['genesis_extender_conditionals'] as $key => $value) {
                    if (in_array($genesis_extender_import['genesis_extender_conditionals'][$key]['conditional_id'], $genesis_extender_conditionals_array)) {
                        unset($genesis_extender_import['genesis_extender_conditionals'][$key]);
                    }
                }
                $conditionals_import = array_merge($genesis_extender_conditionals, $genesis_extender_import['genesis_extender_conditionals']);
                update_option('genesis_extender_custom_conditionals', $conditionals_import);
            }
        }
        if (!empty($widget_areas)) {
            if (!empty($genesis_extender_import['genesis_extender_widgets'])) {
                $genesis_extender_widgets_array = array();
                foreach ($genesis_extender_widgets as $key => $value) {
                    if (!in_array($genesis_extender_widgets[$key]['widget_name'], $genesis_extender_widgets_array)) {
                        $genesis_extender_widgets_array[] = $genesis_extender_widgets[$key]['widget_name'];
                    }
                }
                foreach ($genesis_extender_import['genesis_extender_widgets'] as $key => $value) {
                    if (in_array($genesis_extender_import['genesis_extender_widgets'][$key]['widget_name'], $genesis_extender_widgets_array)) {
                        unset($genesis_extender_import['genesis_extender_widgets'][$key]);
                    }
                }
                $widgets_import = array_merge($genesis_extender_widgets, $genesis_extender_import['genesis_extender_widgets']);
                update_option('genesis_extender_custom_widget_areas', $widgets_import);
            }
        }
        if (!empty($hook_boxes)) {
            if (!empty($genesis_extender_import['genesis_extender_hooks'])) {
                $genesis_extender_hooks_array = array();
                foreach ($genesis_extender_hooks as $key => $value) {
                    if (!in_array($genesis_extender_hooks[$key]['hook_name'], $genesis_extender_hooks_array)) {
                        $genesis_extender_hooks_array[] = $genesis_extender_hooks[$key]['hook_name'];
                    }
                }
                foreach ($genesis_extender_import['genesis_extender_hooks'] as $key => $value) {
                    if (in_array($genesis_extender_import['genesis_extender_hooks'][$key]['hook_name'], $genesis_extender_hooks_array)) {
                        unset($genesis_extender_import['genesis_extender_hooks'][$key]);
                    }
                }
                $hooks_import = array_merge($genesis_extender_hooks, $genesis_extender_import['genesis_extender_hooks']);
                update_option('genesis_extender_custom_hook_boxes', $hooks_import);
            }
        }
        genesis_extender_write_files();
        wp_redirect(admin_url('admin.php?page=genesis-extender-settings&activetab=genesis-extender-settings-nav-import-export&notice=import-complete'));
        exit;
    } else {
        wp_redirect(admin_url('admin.php?page=genesis-extender-settings&activetab=genesis-extender-settings-nav-import-export&notice=import-error'));
        exit;
    }
}
Exemplo n.º 3
0
/**
 * Use ajax to update the Custom Options based on the posted values.
 *
 * @since 1.0
 */
function genesis_extender_settings_save()
{
    check_ajax_referer('plugin-settings', 'security');
    $update = $_POST['extender'];
    update_option('genesis_extender_settings', $update);
    genesis_extender_get_settings(null, $args = array('cached' => false, 'array' => false));
    genesis_extender_write_files($css = true, $ez = true, $custom = false);
    echo 'Plugin Settings Updated';
    exit;
}
Exemplo n.º 4
0
/**
 * Use ajax to update the Custom CSS based on the posted values.
 *
 * @since 1.0
 */
function genesis_extender_css_builder_save()
{
    check_ajax_referer('css-builder-popup', 'security');
    $update = array('custom_css' => $_POST['extender']['custom_css'], 'css_builder_popup_active' => genesis_extender_get_custom_css('css_builder_popup_active'), 'css_builder_popup_editor_only' => genesis_extender_get_custom_css('css_builder_popup_editor_only'), 'custom_functions' => genesis_extender_get_custom_css('custom_functions'));
    $update_merged = array_merge(genesis_extender_custom_css_options_defaults(), $update);
    update_option('genesis_extender_custom_css', $update_merged);
    genesis_extender_write_files($css = true, $ez = false, $custom = false);
    echo 'Custom CSS Updated';
    exit;
}
Exemplo n.º 5
0
/**
 * Clone the Dynamik Child Theme Settings & Images over to the Genesis Extender Plugin.
 *
 * @since 1.0.2
 */
function dynamik_theme_clone($clone_theme_settings = '', $clone_theme_metadata = '', $clone_theme_images = '')
{
    if (!empty($clone_theme_settings)) {
        $plugin_settings_clone = array_merge(genesis_extender_settings_defaults(), get_option('dynamik_gen_theme_settings'));
        update_option('genesis_extender_settings', $plugin_settings_clone);
        $custom_css_clone = array_merge(genesis_extender_custom_css_options_defaults(), get_option('dynamik_gen_custom_css'));
        update_option('genesis_extender_custom_css', $custom_css_clone);
        $custom_functions_clone = array_merge(genesis_extender_custom_functions_options_defaults(), get_option('dynamik_gen_custom_functions'));
        update_option('genesis_extender_custom_functions', $custom_functions_clone);
        $custom_js_clone = array_merge(genesis_extender_custom_js_options_defaults(), get_option('dynamik_gen_custom_js'));
        update_option('genesis_extender_custom_js', $custom_js_clone);
        update_option('genesis_extender_custom_templates', get_option('dynamik_gen_custom_templates'));
        update_option('genesis_extender_custom_labels', get_option('dynamik_gen_custom_labels'));
        $dynamik_custom_conditionals = get_option('dynamik_gen_custom_conditionals');
        foreach ($dynamik_custom_conditionals as $key => $value) {
            if (substr($value['conditional_tag'], 0, 7) == 'dynamik') {
                $dynamik_custom_conditionals[$key]['conditional_tag'] = str_replace(substr($value['conditional_tag'], 0, 7), 'extender', $value['conditional_tag']);
            }
        }
        update_option('genesis_extender_custom_conditionals', $dynamik_custom_conditionals);
        update_option('genesis_extender_custom_widget_areas', get_option('dynamik_gen_custom_widget_areas'));
        update_option('genesis_extender_custom_hook_boxes', get_option('dynamik_gen_custom_hook_boxes'));
    }
    if (!empty($clone_theme_metadata)) {
        global $wpdb;
        $wpdb->update($wpdb->postmeta, array('meta_key' => '_genext_labels'), array('meta_key' => '_dyn_labels'));
    }
    if (!empty($clone_theme_images)) {
        dynamik_folders_open_permissions();
        $theme_image_folder = dynamik_get_stylesheet_location('path') . 'images';
        $theme_adthumbs_folder = $theme_image_folder . '/adminthumbnails';
        $plugin_image_folder = genesis_extender_get_stylesheet_location('path') . 'images';
        $plugin_adthumbs_folder = $plugin_image_folder . '/adminthumbnails';
        dynamik_delete_images($plugin_image_folder);
        dynamik_delete_images($plugin_adthumbs_folder);
        $handle = opendir($theme_image_folder);
        while (false !== ($file = readdir($handle))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                copy($theme_image_folder . '/' . $file, $plugin_image_folder . '/' . $file);
            }
        }
        closedir($handle);
        $handle = opendir($theme_adthumbs_folder);
        while (false !== ($file = readdir($handle))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                copy($theme_adthumbs_folder . '/' . $file, $plugin_adthumbs_folder . '/' . $file);
            }
        }
        closedir($handle);
        dynamik_folders_close_permissions();
    }
    genesis_extender_write_files();
    wp_redirect(admin_url('admin.php?page=dynamik-settings&activetab=dynamik-theme-settings-nav-import-export&notice=theme-clone-complete'));
    exit;
}
/**
 * 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;
}
Exemplo n.º 7
0
/**
 * Perform Genesis Extender activation actions.
 *
 * @since 1.0
 */
function genesis_extender_activate()
{
    if (!get_option('genesis_extender_version_number')) {
        update_option('genesis_extender_version_number', '1.2.2');
    }
    if (!get_option('genesis_extender_settings')) {
        update_option('genesis_extender_settings', genesis_extender_settings_defaults());
    }
    if (!get_option('genesis_extender_custom_css')) {
        update_option('genesis_extender_custom_css', genesis_extender_custom_css_options_defaults());
    }
    if (!get_option('genesis_extender_custom_functions')) {
        update_option('genesis_extender_custom_functions', genesis_extender_custom_functions_options_defaults());
    }
    if (!get_option('genesis_extender_custom_js')) {
        update_option('genesis_extender_custom_js', genesis_extender_custom_js_options_defaults());
    }
    if (!get_option('genesis_extender_custom_templates')) {
        update_option('genesis_extender_custom_templates', array());
    }
    if (!get_option('genesis_extender_custom_labels')) {
        update_option('genesis_extender_custom_labels', array());
    }
    if (!get_option('genesis_extender_custom_conditionals')) {
        update_option('genesis_extender_custom_conditionals', array());
    }
    if (!get_option('genesis_extender_custom_widget_areas')) {
        update_option('genesis_extender_custom_widget_areas', array());
    }
    if (!get_option('genesis_extender_custom_hook_boxes')) {
        update_option('genesis_extender_custom_hook_boxes', array());
    }
    if (!is_dir(CHILD_DIR . '/my-templates')) {
        mkdir(CHILD_DIR . '/my-templates');
        @chmod(CHILD_DIR . '/my-templates', 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path', $root = true))) {
        mkdir(genesis_extender_get_stylesheet_location('path', $root = true));
        @chmod(genesis_extender_get_stylesheet_location('path', $root = true), 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path', $root = true) . 'plugin')) {
        mkdir(genesis_extender_get_stylesheet_location('path', $root = true) . 'plugin');
        @chmod(genesis_extender_get_stylesheet_location('path', $root = true) . 'plugin', 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path') . 'default-images')) {
        mkdir(genesis_extender_get_stylesheet_location('path') . 'default-images');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'default-images', 0755);
        mkdir(genesis_extender_get_stylesheet_location('path') . 'default-images/post-formats');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'default-images/post-formats', 0755);
        $handle = opendir(GENEXT_PATH . 'images');
        while (false !== ($file = readdir($handle))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                copy(GENEXT_PATH . 'images/' . $file, genesis_extender_get_stylesheet_location('path') . 'default-images/' . $file);
            }
        }
        closedir($handle);
        $handle2 = opendir(GENEXT_PATH . 'images/post-formats');
        while (false !== ($file = readdir($handle2))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                copy(GENEXT_PATH . 'images/post-formats/' . $file, genesis_extender_get_stylesheet_location('path') . 'default-images/post-formats/' . $file);
            }
        }
        closedir($handle2);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path') . 'images')) {
        mkdir(genesis_extender_get_stylesheet_location('path') . 'images');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'images', 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path') . 'images/adminthumbnails')) {
        mkdir(genesis_extender_get_stylesheet_location('path') . 'images/adminthumbnails');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'images/adminthumbnails', 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path') . 'tmp')) {
        mkdir(genesis_extender_get_stylesheet_location('path') . 'tmp');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'tmp', 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path') . 'tmp/images')) {
        mkdir(genesis_extender_get_stylesheet_location('path') . 'tmp/images');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'tmp/images', 0755);
    }
    if (!is_dir(genesis_extender_get_stylesheet_location('path') . 'tmp/images/adminthumbnails')) {
        mkdir(genesis_extender_get_stylesheet_location('path') . 'tmp/images/adminthumbnails');
        @chmod(genesis_extender_get_stylesheet_location('path') . 'tmp/images/adminthumbnails', 0755);
    }
    genesis_extender_write_files();
    genesis_extender_create_custom_functions_file();
    $genesis_extender_folders = array(genesis_extender_get_stylesheet_location('path'), genesis_extender_get_stylesheet_location('path') . 'images', genesis_extender_get_stylesheet_location('path') . 'adminthumbnails', genesis_extender_get_stylesheet_location('path') . 'tmp', genesis_extender_get_stylesheet_location('path') . 'tmp/images', genesis_extender_get_stylesheet_location('path') . 'tmp/images/adminthumbnails');
    $genesis_extender_unwritable = false;
    foreach ($genesis_extender_folders as $genesis_extender_folder) {
        if (is_dir($genesis_extender_folder) && !genesis_extender_writable($genesis_extender_folder)) {
            $genesis_extender_unwritable = true;
        }
    }
    if ($genesis_extender_unwritable) {
        wp_redirect(admin_url('admin.php?page=genesis-extender-settings&notice=genesis-extender-unwritable'));
    }
}