// Adding the json endpoint add_action( 'init', 'awesome2_filter_endpoint' ,3); function awesome2_filter_endpoint() { add_rewrite_endpoint('f', EP_ALL ); } add_action('init', 'awesome2_rewrite_rules',2); function awesome2_rewrite_rules() { add_rewrite_endpoint('f', EP_ALL ); } add_filter( 'template_include', 'spa_template_select', 99 ); function spa_template_select( $template ) { $f=aw2_library::get_request('f'); if($f==null || $f==''){} else{ $pieces= explode( '/' ,$f); foreach ($pieces as $value) { $pair=explode(':',$value); if(isset($pair[1])){ aw2_library::setparam($pair[0],$pair[1]); } } } if(isset($_REQUEST['spa_call']) && $_REQUEST['spa_call']=='true') { if(is_single()){ $new_template = plugin_dir_path( __FILE__ ).'php_templates/single.php'; return $new_template ; } if(is_page()){ $new_template = plugin_dir_path( __FILE__ ).'php_templates/page.php'; return $new_template ; } if(is_post_type_archive() || is_tax() || is_category() || is_tag()){ $new_template = plugin_dir_path( __FILE__ ).'php_templates/archive.php'; return $new_template ; } } return $template; } add_action('wp_ajax_run_module', 'run_module_handler'); add_action('wp_ajax_nopriv_run_module', 'run_module_handler'); add_action('wp_ajax_run_awesome2_block', 'run_module_handler'); add_action('wp_ajax_nopriv_run_awesome2_block', 'run_module_handler'); function run_module_handler(){ global $aw2_ajax; $aw2_ajax=true; $slug=aw2_library::get_request('slug'); $template=aw2_library::get_request('template'); echo aw2_library::run_module($slug,$template); exit(); } add_action('wp_ajax_app_ajax', 'app_ajax'); add_action('wp_ajax_nopriv_app_ajax', 'app_ajax'); function app_ajax(){ global $aw2_ajax; $aw2_ajax=true; $app_slug=aw2_library::get_request('app'); $app = new aw2_app(); $app->setup($app_slug); $slug=aw2_library::get_request('slug'); $template=aw2_library::get_request('template'); echo aw2_library::run_module($slug,$template); exit(); } add_action('wp_enqueue_scripts', 'aw2_scripts'); function aw2_scripts() { wp_register_script('labjs', plugins_url('shortcodes/lib/labjs/LAB.min.js',dirname(__FILE__)) , '', null, true); wp_enqueue_script('labjs'); } add_action( 'admin_head', 'aw2_homeurl' ); function aw2_homeurl() { ?>