Example #1
0
/**
 * Perform Dynamik activation actions.
 *
 * @since 1.0
 */
function dynamik_activate()
{
    global $dynamik_folders;
    if (!get_option('dynamik_gen_version_number')) {
        update_option('dynamik_gen_version_number', '1.2.2');
    }
    if (!get_option('dynamik_gen_theme_settings')) {
        update_option('dynamik_gen_theme_settings', dynamik_theme_settings_defaults());
    }
    if (!get_option('dynamik_gen_design_options')) {
        update_option('dynamik_gen_design_options', dynamik_design_options_defaults());
    }
    if (!get_option('dynamik_gen_responsive_options')) {
        update_option('dynamik_gen_responsive_options', dynamik_responsive_options_defaults());
    }
    if (!get_option('dynamik_gen_design_snapshot_options')) {
        dynamik_design_snapshot_update($activation = true);
    }
    if (!get_option('dynamik_gen_custom_css')) {
        update_option('dynamik_gen_custom_css', dynamik_custom_css_options_defaults());
    }
    if (!get_option('dynamik_gen_custom_functions')) {
        update_option('dynamik_gen_custom_functions', dynamik_custom_functions_options_defaults());
    }
    if (!get_option('dynamik_gen_custom_js')) {
        update_option('dynamik_gen_custom_js', dynamik_custom_js_options_defaults());
    }
    if (!get_option('dynamik_gen_custom_templates')) {
        update_option('dynamik_gen_custom_templates', array());
    }
    if (!get_option('dynamik_gen_custom_labels')) {
        update_option('dynamik_gen_custom_labels', array());
    }
    if (!get_option('dynamik_gen_custom_conditionals')) {
        update_option('dynamik_gen_custom_conditionals', array());
    }
    if (!get_option('dynamik_gen_custom_widget_areas')) {
        update_option('dynamik_gen_custom_widget_areas', array());
    }
    if (!get_option('dynamik_gen_custom_hook_boxes')) {
        update_option('dynamik_gen_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(dynamik_get_stylesheet_location('path', $root = true))) {
        mkdir(dynamik_get_stylesheet_location('path', $root = true));
        @chmod(dynamik_get_stylesheet_location('path', $root = true), 0755);
    }
    if (!is_dir(dynamik_get_stylesheet_location('path', $root = true) . 'theme')) {
        mkdir(dynamik_get_stylesheet_location('path', $root = true) . 'theme');
        @chmod(dynamik_get_stylesheet_location('path', $root = true) . 'theme', 0755);
    }
    if (!is_dir(dynamik_get_stylesheet_location('path') . 'default-images')) {
        mkdir(dynamik_get_stylesheet_location('path') . 'default-images');
        @chmod(dynamik_get_stylesheet_location('path') . 'default-images', 0755);
        mkdir(dynamik_get_stylesheet_location('path') . 'default-images/post-formats');
        @chmod(dynamik_get_stylesheet_location('path') . 'default-images/post-formats', 0755);
        $handle = opendir(CHILD_DIR . '/images');
        while (false !== ($file = readdir($handle))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                copy(CHILD_DIR . '/images/' . $file, dynamik_get_stylesheet_location('path') . 'default-images/' . $file);
            }
        }
        closedir($handle);
        $handle2 = opendir(CHILD_DIR . '/images/post-formats');
        while (false !== ($file = readdir($handle2))) {
            $ext = strtolower(substr(strrchr($file, '.'), 1));
            if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') {
                copy(CHILD_DIR . '/images/post-formats/' . $file, dynamik_get_stylesheet_location('path') . 'default-images/post-formats/' . $file);
            }
        }
        closedir($handle2);
    }
    $handle3 = opendir(CHILD_DIR . '/images');
    while (false !== ($file = readdir($handle3))) {
        if ($file == 'icon-plus.png' || $file == 'icon-plus-white.png') {
            copy(CHILD_DIR . '/images/' . $file, dynamik_get_stylesheet_location('path') . 'default-images/' . $file);
        }
    }
    closedir($handle3);
    if (!is_dir(dynamik_get_stylesheet_location('path') . 'images')) {
        mkdir(dynamik_get_stylesheet_location('path') . 'images');
        @chmod(dynamik_get_stylesheet_location('path') . 'images', 0755);
    }
    if (!is_dir(dynamik_get_stylesheet_location('path') . 'images/adminthumbnails')) {
        mkdir(dynamik_get_stylesheet_location('path') . 'images/adminthumbnails');
        @chmod(dynamik_get_stylesheet_location('path') . 'images/adminthumbnails', 0755);
    }
    if (!is_dir(dynamik_get_stylesheet_location('path') . 'tmp')) {
        mkdir(dynamik_get_stylesheet_location('path') . 'tmp');
        @chmod(dynamik_get_stylesheet_location('path') . 'tmp', 0755);
    }
    if (!is_dir(dynamik_get_stylesheet_location('path') . 'tmp/images')) {
        mkdir(dynamik_get_stylesheet_location('path') . 'tmp/images');
        @chmod(dynamik_get_stylesheet_location('path') . 'tmp/images', 0755);
    }
    if (!is_dir(dynamik_get_stylesheet_location('path') . 'tmp/images/adminthumbnails')) {
        mkdir(dynamik_get_stylesheet_location('path') . 'tmp/images/adminthumbnails');
        @chmod(dynamik_get_stylesheet_location('path') . 'tmp/images/adminthumbnails', 0755);
    }
    dynamik_write_files();
    dynamik_create_custom_functions_file();
    $dynamik_unwritable = false;
    foreach ($dynamik_folders as $dynamik_folder) {
        if (is_dir($dynamik_folder) && !dynamik_writable($dynamik_folder)) {
            $dynamik_unwritable = true;
        }
    }
    if ($dynamik_unwritable) {
        wp_redirect(admin_url('admin.php?page=dynamik-settings&notice=dynamik-unwritable'));
    }
}
Example #2
0
/**
 * Check for Import/Export $_POST actions and react appropriately.
 *
 * @since 1.0
 */
function dynamik_import_export_check()
{
    if (!empty($_POST['action']) && $_POST['action'] == 'dynamik_design_export') {
        $export_name = $_POST['design_export_name'] != '' ? $_POST['design_export_name'] : false;
        $include_images = isset($_POST['include_images']) ? 'yes' : 'no';
        dynamik_design_export($export_name, $include_images);
    }
    if (!empty($_POST['action']) && $_POST['action'] == 'dynamik_design_import') {
        dynamik_design_import($_FILES['design_import_file']);
    }
    if (!empty($_POST['action']) && $_POST['action'] == 'child_export') {
        $parent_at_style = isset($_POST['parent_at_style']) ? 'yes' : 'no';
        $include_theme_settings = isset($_POST['include_theme_settings']) ? 'yes' : 'no';
        $include_dynamik_design = isset($_POST['include_dynamik_design']) ? 'yes' : 'no';
        $include_custom_css = isset($_POST['include_custom_css']) ? 'yes' : 'no';
        $include_custom_functions = isset($_POST['include_custom_functions']) ? 'yes' : 'no';
        $include_custom_js = isset($_POST['include_custom_js']) ? 'yes' : 'no';
        $include_custom_templates = isset($_POST['include_custom_templates']) ? 'yes' : 'no';
        $include_custom_labels = isset($_POST['include_custom_labels']) ? 'yes' : 'no';
        $include_custom_widget_areas = isset($_POST['include_custom_widget_areas']) ? 'yes' : 'no';
        $include_custom_hook_boxes = isset($_POST['include_custom_hook_boxes']) ? 'yes' : 'no';
        child_export($_POST['child_name'], $_POST['child_author'], $_POST['child_author_uri'], $parent_at_style, $include_theme_settings, $include_dynamik_design, $include_custom_css, $include_custom_functions, $include_custom_js, $include_custom_templates, $include_custom_labels, $include_custom_widget_areas, $include_custom_hook_boxes);
    }
    if (!empty($_POST['action']) && $_POST['action'] == 'dynamik_design_snapshot_update') {
        dynamik_design_snapshot_update();
    }
    if (!empty($_POST['action']) && $_POST['action'] == 'dynamik_design_snapshot_restore') {
        dynamik_design_snapshot_restore();
    }
    if (!empty($_POST['action']) && $_POST['action'] == 'dynamik_custom_export') {
        $export_name = $_POST['dynamik_export_name'] != '' ? $_POST['dynamik_export_name'] : false;
        $theme_settings = isset($_POST['export_settings']) ? $_POST['export_settings'] : '';
        $custom_css = isset($_POST['export_css']) ? $_POST['export_css'] : '';
        $custom_functions = isset($_POST['export_functions']) ? $_POST['export_functions'] : '';
        $custom_js = isset($_POST['export_js']) ? $_POST['export_js'] : '';
        $custom_templates = isset($_POST['export_templates']) ? $_POST['export_templates'] : '';
        $custom_labels = isset($_POST['export_labels']) ? $_POST['export_labels'] : '';
        $conditionals = isset($_POST['export_conditionals']) ? $_POST['export_conditionals'] : '';
        $widget_areas = isset($_POST['export_widgets']) ? $_POST['export_widgets'] : '';
        $hook_boxes = isset($_POST['export_hooks']) ? $_POST['export_hooks'] : '';
        dynamik_custom_export($export_name, $theme_settings, $custom_css, $custom_functions, $custom_js, $custom_templates, $custom_labels, $conditionals, $widget_areas, $hook_boxes);
    }
    if (!empty($_POST['action']) && $_POST['action'] == 'dynamik_custom_import') {
        $theme_settings = isset($_POST['import_settings']) ? $_POST['import_settings'] : '';
        $custom_css = isset($_POST['import_css']) ? $_POST['import_css'] : '';
        $custom_functions = isset($_POST['import_functions']) ? $_POST['import_functions'] : '';
        $custom_js = isset($_POST['import_js']) ? $_POST['import_js'] : '';
        $custom_templates = isset($_POST['import_templates']) ? $_POST['import_templates'] : '';
        $custom_labels = isset($_POST['import_labels']) ? $_POST['import_labels'] : '';
        $conditionals = isset($_POST['import_conditionals']) ? $_POST['import_conditionals'] : '';
        $widget_areas = isset($_POST['import_widgets']) ? $_POST['import_widgets'] : '';
        $hook_boxes = isset($_POST['import_hooks']) ? $_POST['import_hooks'] : '';
        dynamik_custom_import($_FILES['custom_import_file'], $theme_settings, $custom_css, $custom_functions, $custom_js, $custom_templates, $custom_labels, $conditionals, $widget_areas, $hook_boxes);
    }
    if (defined('GENEXT_VERSION') && !empty($_POST['action']) && $_POST['action'] == 'dynamik_theme_clone') {
        $clone_theme_settings = isset($_POST['clone_theme_settings']) ? $_POST['clone_theme_settings'] : '';
        $clone_theme_metadata = isset($_POST['clone_theme_metadata']) ? $_POST['clone_theme_metadata'] : '';
        $clone_theme_images = isset($_POST['clone_theme_images']) ? $_POST['clone_theme_images'] : '';
        dynamik_theme_clone($clone_theme_settings, $clone_theme_metadata, $clone_theme_images);
    }
    if (defined('GENEXT_VERSION') && !empty($_POST['action']) && $_POST['action'] == 'genesis_extender_clone') {
        $clone_plugin_settings = isset($_POST['clone_plugin_settings']) ? $_POST['clone_plugin_settings'] : '';
        $clone_plugin_metadata = isset($_POST['clone_plugin_metadata']) ? $_POST['clone_plugin_metadata'] : '';
        $clone_plugin_images = isset($_POST['clone_plugin_images']) ? $_POST['clone_plugin_images'] : '';
        genesis_extender_clone($clone_plugin_settings, $clone_plugin_metadata, $clone_plugin_images);
    }
}