function axiom_sc_prepare_scripts() { global $AXIOM_GLOBALS; if (!isset($AXIOM_GLOBALS['shortcodes_prepared'])) { $AXIOM_GLOBALS['shortcodes_prepared'] = true; ?> <script type="text/javascript"> jQuery(document).ready(function(){ AXIOM_GLOBALS['shortcodes'] = JSON.parse('<?php echo str_replace("'", "\\'", json_encode(axiom_array_prepare_to_json($AXIOM_GLOBALS['shortcodes']))); ?> '); AXIOM_GLOBALS['shortcodes_cp'] = '<?php echo is_admin() ? 'wp' : 'internal'; ?> '; }); </script> <?php } }
function axiom_array_prepare_to_json($arr) { if (is_array($arr)) { $new = array(); if (count($arr) > 0) { foreach ($arr as $k => $v) { $k = axiom_array_prepare_to_json($k); $v = axiom_array_prepare_to_json($v); $new[$k] = $v; } } } else { if (is_string($arr)) { $new = str_replace(array('"'), array('\\"'), $arr); } else { $new = $arr; } } return $new; }