/** * Use ajax to update the Custom Options based on the posted values. * * @since 1.0 */ function dynamik_custom_options_save() { check_ajax_referer('custom-options', 'security'); if (!empty($_POST['dynamik']['css_builder_popup_active']) || dynamik_get_custom_css('css_builder_popup_active')) { $custom_css = dynamik_get_custom_css('custom_css'); } else { $custom_css = $_POST['dynamik']['custom_css']; } $css_update = array('custom_css' => $custom_css, 'css_builder_popup_active' => !empty($_POST['dynamik']['css_builder_popup_active']) ? 1 : 0, 'css_builder_popup_editor_only' => !empty($_POST['dynamik']['css_builder_popup_editor_only']) ? 1 : 0); $css_update_merged = array_merge(dynamik_custom_css_options_defaults(), $css_update); update_option('dynamik_gen_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(dynamik_custom_functions_options_defaults(), $functions_update); update_option('dynamik_gen_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(dynamik_custom_js_options_defaults(), $js_update); update_option('dynamik_gen_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; } } dynamik_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; } } dynamik_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('-', '_', dynamik_sanatize_string($_POST['custom_label_names'][$key])); $custom_conditional_tags[] = 'dynamik_has_label(\'' . dynamik_sanatize_string($_POST['custom_label_names'][$key]) . '\')'; } dynamik_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; } } dynamik_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; } } dynamik_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; } } dynamik_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']); } dynamik_write_files($css = true, $ez = false); echo 'Custom Options Updated'; exit; }
/** * Use ajax to update the Custom CSS based on the posted values. * * @since 1.0 */ function dynamik_css_builder_save() { check_ajax_referer('css-builder-popup', 'security'); $update = array('custom_css' => $_POST['dynamik']['custom_css'], 'css_builder_popup_active' => dynamik_get_custom_css('css_builder_popup_active'), 'css_builder_popup_editor_only' => dynamik_get_custom_css('css_builder_popup_editor_only'), 'custom_functions' => dynamik_get_custom_css('custom_functions')); $update_merged = array_merge(dynamik_custom_css_options_defaults(), $update); update_option('dynamik_gen_custom_css', $update_merged); dynamik_write_files($css = true, $ez = false, $custom = false); echo 'Custom CSS Updated'; exit; }
/** * 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¬ice=dynamik-unwritable')); } }
/** * Clone the Genesis Extender Plugin Settings & Images over to the Dynamik Child Theme. * * @since 1.0.2 */ function genesis_extender_clone($clone_plugin_settings = '', $clone_plugin_metadata = '', $clone_plugin_images = '') { if (!empty($clone_plugin_settings)) { $plugin_settings_clone = array_merge(dynamik_theme_settings_defaults(), get_option('genesis_extender_settings')); update_option('dynamik_gen_theme_settings', $plugin_settings_clone); $custom_css_clone = array_merge(dynamik_custom_css_options_defaults(), get_option('genesis_extender_custom_css')); update_option('dynamik_gen_custom_css', $custom_css_clone); $custom_functions_clone = array_merge(dynamik_custom_functions_options_defaults(), get_option('genesis_extender_custom_functions')); update_option('dynamik_gen_custom_functions', $custom_functions_clone); $custom_js_clone = array_merge(dynamik_custom_js_options_defaults(), get_option('genesis_extender_custom_js')); update_option('dynamik_gen_custom_js', $custom_js_clone); update_option('dynamik_gen_custom_templates', get_option('genesis_extender_custom_templates')); update_option('dynamik_gen_custom_labels', get_option('genesis_extender_custom_labels')); $genesis_extender_custom_conditionals = get_option('genesis_extender_custom_conditionals'); foreach ($genesis_extender_custom_conditionals as $key => $value) { if (substr($value['conditional_tag'], 0, 8) == 'extender') { $genesis_extender_custom_conditionals[$key]['conditional_tag'] = str_replace(substr($value['conditional_tag'], 0, 8), 'dynamik', $value['conditional_tag']); } } update_option('dynamik_gen_custom_conditionals', $genesis_extender_custom_conditionals); update_option('dynamik_gen_custom_widget_areas', get_option('genesis_extender_custom_widget_areas')); update_option('dynamik_gen_custom_hook_boxes', get_option('genesis_extender_custom_hook_boxes')); } if (!empty($clone_plugin_metadata)) { global $wpdb; $wpdb->update($wpdb->postmeta, array('meta_key' => '_dyn_labels'), array('meta_key' => '_genext_labels')); } if (!empty($clone_plugin_images)) { dynamik_folders_open_permissions(); $plugin_image_folder = genesis_extender_get_stylesheet_location('path') . 'images'; $plugin_adthumbs_folder = $plugin_image_folder . '/adminthumbnails'; $theme_image_folder = dynamik_get_stylesheet_location('path') . 'images'; $theme_adthumbs_folder = $theme_image_folder . '/adminthumbnails'; dynamik_delete_images($theme_image_folder); dynamik_delete_images($theme_adthumbs_folder); $handle = opendir($plugin_image_folder); while (false !== ($file = readdir($handle))) { $ext = strtolower(substr(strrchr($file, '.'), 1)); if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') { copy($plugin_image_folder . '/' . $file, $theme_image_folder . '/' . $file); } } closedir($handle); $handle = opendir($plugin_adthumbs_folder); while (false !== ($file = readdir($handle))) { $ext = strtolower(substr(strrchr($file, '.'), 1)); if ($ext == 'jpg' || $ext == 'gif' || $ext == 'png') { copy($plugin_adthumbs_folder . '/' . $file, $theme_adthumbs_folder . '/' . $file); } } closedir($handle); dynamik_folders_close_permissions(); } dynamik_write_files($css = true, $ez = false); wp_redirect(admin_url('admin.php?page=dynamik-settings&activetab=dynamik-theme-settings-nav-import-export¬ice=plugin-clone-complete')); exit; }