function sola_set_theme($theme_array, $camp_id) { global $sola_nl_camp_tbl; global $wpdb; if (!$theme_array[0] || $theme_array[0] == "") { return new WP_Error('sola_error', __('Please select a theme before continuing', 'sola'), ''); } $theme_dir = $theme_array[0]; $theme_url = $theme_array[1]; $site_url = get_site_url(); /* check for trailing forward slash */ if (substr($site_url, -1) != "/") { $site_url = $site_url . "/"; } $theme_name = basename($theme_dir); $theme_data = sola_nl_get_theme_data($theme_dir); $serialized_styles = maybe_serialize(sola_nl_save_style($theme_data['styles'], null)); /* change reference of ../ and ./ to the actual URL of the theme */ $theme_html = $theme_data['html']; $theme_html = str_replace("../", $site_url, $theme_html); $theme_html = str_replace("./", $site_url, $theme_html); $check = $wpdb->query($wpdb->prepare("UPDATE `{$sola_nl_camp_tbl}` SET `theme_data` = %s, `email` = %s, `styles` = %s WHERE `camp_id` = %d LIMIT 1", json_encode($theme_array), $theme_html, $serialized_styles, $camp_id)); if ($check === false) { return new WP_Error('db_query_error', __('Could not execute query', 'sola'), $wpdb->last_error); } else { return true; } exit; }
<?php $sola_nl_ajax_nonce = wp_create_nonce("sola_nl"); $camp_details = sola_nl_get_camp_details($_GET['camp_id']); $theme_id = $camp_details->theme_id; if (isset($camp_details->theme_data)) { $theme_array = json_decode($camp_details->theme_data); $theme_data = sola_nl_get_theme_data(stripslashes($theme_array[0])); } $styles = $camp_details->styles; ?> <script language="javascript"> var sola_nl_nonce = '<?php echo $sola_nl_ajax_nonce; ?> '; var sola_is_editing = false; var sola_is_editing_id = null; var camp_id = <?php echo $_GET['camp_id']; ?> ; </script> <?php $camp_type = maybe_unserialize($camp_details->automatic_data); if (isset($camp_type['action'])) { $auto_camp_type = $camp_type['action']; } else { $auto_camp_type = '2';