| 1 |
<?php |
| 2 |
function accua_form_Load($class) { |
| 3 |
if (substr($class,0,10) === 'AccuaForm_') { |
| 4 |
$class = substr($class, 10); |
| 5 |
$file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . str_replace("_", DIRECTORY_SEPARATOR, $class) . ".php"; |
| 6 |
if(is_file($file)) { |
| 7 |
include_once $file; |
| 8 |
} |
| 9 |
} |
| 10 |
} |
| 11 |
spl_autoload_register("accua_form_Load"); |
| 12 |
|
| 13 |
require_once('PFBC/Form.php'); |
| 14 |
require_once('AccuaForm.php'); |
| 15 |
|
| 16 |
add_action('plugins_loaded', 'accua_form_init'); |
| 17 |
|
| 18 |
define('ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages/'); |
| 19 |
function accua_form_init(){ |
| 20 |
wp_enqueue_script('jquery'); |
| 21 |
|
| 22 |
wp_enqueue_style( 'accua-forms-api-base', plugins_url('accua-form-api.css', __FILE__), array(), '2'); |
| 23 |
|
| 24 |
load_plugin_textdomain( 'accua-form-api', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH); |
| 25 |
AccuaForm::isValid(); |
| 26 |
} |
| 27 |
|
| 28 |
add_action('wp_ajax_accua_form_submit', 'accua_form_ajax_submit_handler'); |
| 29 |
add_action('wp_ajax_nopriv_accua_form_submit', 'accua_form_ajax_submit_handler'); |
| 30 |
function accua_form_ajax_submit_handler(){ |
| 31 |
header('Content-Type: text/html; charset='.get_option('blog_charset')); |
| 32 |
|
| 33 |
echo '<html><head></head><body><pre id="accua-form-ajax-response">'; |
| 34 |
|
| 35 |
echo strtr(json_encode(AccuaForm::ajaxSubmit()), |
| 36 |
array( |
| 37 |
'&' => '\\u0026', |
| 38 |
'<' => '\\u003C', |
| 39 |
'>' => '\\u003E', |
| 40 |
)); |
| 41 |
|
| 42 |
echo '</pre><div id="accua-form-ajax-response-loaded"></div>'; |
| 43 |
|
| 44 |
echo <<<EOJS |
| 45 |
<script type="text/javascript"> |
| 46 |
<!-- |
| 47 |
try { |
| 48 |
window.parent.postMessage(document.getElementById("accua-form-ajax-response").innerHTML, '*'); |
| 49 |
} catch (err) { |
| 50 |
} |
| 51 |
// --> |
| 52 |
</script> |
| 53 |
EOJS; |
| 54 |
|
| 55 |
echo '</body></html>'; |
| 56 |
die (""); |
| 57 |
} |
| 58 |
|