function rockthemes_fb_import_ajax() { if (!is_admin()) { die; } if (!isset($_POST['data']) || empty($_POST['data'])) { die('error'); } else { echo rockthemes_fb_import($_POST['data']); } exit; }
function rockthemes_to_import_all_datas($data) { //Remove any additional line breaks. Some PHP versions adds line breaks during json_encode / json_decode $data = preg_replace("/\r|\n/", "", $data); $array_data = json_decode($data, true); if (!is_array($array_data)) { echo 'its not an array'; $array_data = json_decode(stripslashes($data), true); } $modules = ''; $unprocessed_modules = array(); foreach ($array_data as $module) { if (!is_array($module)) { $module = stripslashes($module); } switch ($module['module']) { case 'rock_form_builder': if (function_exists('rockthemes_fb_import')) { rockthemes_fb_import(addslashes(str_replace('"', '"', $module['data']))); } break; case 'curvy_slider': if (function_exists('curvy_slider_import')) { curvy_slider_import(addslashes(str_replace('"', '"', $module['data']))); } break; case 'rock_page_builder': rockthemes_pb_import($module['data']); break; case 'rock_theme_options': rockthemes_to_import_to_datas($module['data']); break; } } return $modules; }