Created
August 3, 2014 16:58
-
-
Save dancameron/c696ec47caf78c55c74e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: NinjaDemo AJAX Callbacks | |
| Plugin URI: https://sproutapps.co/ | |
| Description: Allow for the demo form to be remotely retreived. | |
| Author: Sprout Apps | |
| Version: 0.8 | |
| Author URI: https://sproutapps.co | |
| */ | |
| function sa_try_demo_form() { | |
| $allowed_domains = array( | |
| home_url(), | |
| 'http://sprout.dev', | |
| 'https://sproutapps.co' | |
| ); | |
| // Check to make sure that the requested origin is an allowed domain. | |
| // This will prevent direct access too. | |
| if ( in_array( $_SERVER['HTTP_ORIGIN'], $allowed_domains ) ) { | |
| header('Access-Control-Allow-Origin: *'); | |
| // Form | |
| print do_shortcode( '[try_demo]' ); | |
| } | |
| exit(); | |
| } | |
| add_action( 'wp_ajax_nopriv_try_demo_form', 'sa_try_demo_form', 10, 0 ); | |
| add_action( 'wp_ajax_try_demo_form', 'sa_try_demo_form', 10, 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment