| @@ -1,77 +1,69 @@ | ||
| 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 | -add_action( 'wp_print_scripts', 'accua_form_init_scripts'); | |
| 18 | - | |
| 19 | -define('ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages/'); | |
| 20 | - | |
| 21 | -function accua_form_init_scripts(){ | |
| 22 | - global $wp_scripts; | |
| 23 | - wp_enqueue_script('jquery'); | |
| 24 | - | |
| 25 | - if(!wp_script_is('wp-color-picker', 'registered')) { | |
| 26 | - if (!wp_script_is('iris', 'registered')) { | |
| 27 | - $wp_scripts->add( 'iris', '/wp-admin/js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 ); | |
| 28 | - } | |
| 29 | - $wp_scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker$suffix.js", array( 'iris' ), false, 1 ); | |
| 30 | - $wp_scripts->localize( 'wp-color-picker', 'wpColorPickerL10n', array( | |
| 31 | - 'clear' => __( 'Clear' ), | |
| 32 | - 'defaultString' => __( 'Default' ), | |
| 33 | - 'pick' => __( 'Select Color' ), | |
| 34 | - 'current' => __( 'Current Color' ), | |
| 35 | - ) ); | |
| 36 | - } | |
| 37 | - wp_enqueue_script('wp-color-picker'); | |
| 38 | -} | |
| 39 | -function accua_form_init(){ | |
| 40 | - | |
| 41 | - wp_enqueue_style( 'wp-color-picker' ); | |
| 42 | - wp_enqueue_style( 'accua-forms-api-base', plugins_url('accua-form-api.css', __FILE__), array(), '2'); | |
| 43 | - | |
| 44 | - load_plugin_textdomain( 'accua-form-api', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH); | |
| 45 | - AccuaForm::isValid(); | |
| 46 | -} | |
| 47 | - | |
| 48 | -add_action('wp_ajax_accua_form_submit', 'accua_form_ajax_submit_handler'); | |
| 49 | -add_action('wp_ajax_nopriv_accua_form_submit', 'accua_form_ajax_submit_handler'); | |
| 50 | -function accua_form_ajax_submit_handler(){ | |
| 51 | - header('Content-Type: text/html; charset='.get_option('blog_charset')); | |
| 52 | - | |
| 53 | - echo '<html><head></head><body><pre id="accua-form-ajax-response">'; | |
| 54 | - | |
| 55 | - echo strtr(json_encode(AccuaForm::ajaxSubmit()), | |
| 56 | - array( | |
| 57 | - '&' => '\\u0026', | |
| 58 | - '<' => '\\u003C', | |
| 59 | - '>' => '\\u003E', | |
| 60 | - )); | |
| 61 | - | |
| 62 | - echo '</pre><div id="accua-form-ajax-response-loaded"></div>'; | |
| 63 | - | |
| 64 | - echo <<<EOJS | |
| 65 | -<script type="text/javascript"> | |
| 66 | -<!-- | |
| 67 | -try { | |
| 68 | - window.parent.postMessage(document.getElementById("accua-form-ajax-response").innerHTML, '*'); | |
| 69 | -} catch (err) { | |
| 70 | -} | |
| 71 | -// --> | |
| 72 | -</script> | |
| 73 | -EOJS; | |
| 74 | - | |
| 75 | - echo '</body></html>'; | |
| 76 | - die(''); | |
| 77 | -} | |
| 1 | +<?php | |
| 2 | +function accua_form_Load($class) { | |
| 3 | + if (substr($class,0,10) === 'AccuaForm_') { | |
| 4 | + $class = substr($class, 10); | |
| 5 | + $file = ACCUA_FORMS_DIR . 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 | +define('ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__ ) ) . '/languages/'); | |
| 17 | + | |
| 18 | +add_action( 'wp_print_scripts', 'accua_form_init_scripts'); | |
| 19 | +function accua_form_init_scripts(){ | |
| 20 | + wp_enqueue_script('jquery'); | |
| 21 | + AccuaForm_Element_ColorPicker::maybe_load_colorPicker_scripts(); | |
| 22 | +} | |
| 23 | + | |
| 24 | +add_action('wp_enqueue_scripts', 'accua_form_enqueue_styles'); | |
| 25 | +add_action('admin_enqueue_scripts', 'accua_form_enqueue_styles'); | |
| 26 | +add_action('login_enqueue_scripts', 'accua_form_enqueue_styles'); | |
| 27 | +add_action('wp_print_styles', 'accua_form_enqueue_styles'); | |
| 28 | +function accua_form_enqueue_styles(){ | |
| 29 | + static $first = TRUE; | |
| 30 | + if ($first) { | |
| 31 | + AccuaForm_Element_ColorPicker::maybe_load_colorPicker_styles(); | |
| 32 | + wp_enqueue_style('accua-forms-api-base', plugins_url('accua-form-api.css', ACCUA_FORMS_FILE), array(), ACCUA_FORMS_CSS_VERSION); | |
| 33 | + $first = FALSE; | |
| 34 | + } | |
| 35 | +} | |
| 36 | + | |
| 37 | +add_action('plugins_loaded', 'accua_form_init'); | |
| 38 | +function accua_form_init(){ | |
| 39 | + load_plugin_textdomain( 'contact-forms', false, ACCUA_FORM_API_PLUGIN_TEXTDOMAIN_PATH); | |
| 40 | + if (!defined('DOING_CRON')) { | |
| 41 | + AccuaForm::isValid(); | |
| 42 | + } | |
| 43 | +} | |
| 44 | + | |
| 45 | +add_action('wp_ajax_accua_form_submit', 'accua_form_ajax_submit_handler'); | |
| 46 | +add_action('wp_ajax_nopriv_accua_form_submit', 'accua_form_ajax_submit_handler'); | |
| 47 | +function accua_form_ajax_submit_handler(){ | |
| 48 | + header('Content-Type: text/html; charset='.get_option('blog_charset')); | |
| 49 | + | |
| 50 | + echo '<html><head></head><body><pre id="accua-form-ajax-response">'; | |
| 51 | + | |
| 52 | + print _accua_forms_json_encode(AccuaForm::ajaxSubmit()); | |
| 53 | + | |
| 54 | + echo '</pre><div id="accua-form-ajax-response-loaded"></div>'; | |
| 55 | + | |
| 56 | + echo <<<EOJS | |
| 57 | +<script type="text/javascript"> | |
| 58 | +<!-- | |
| 59 | +try { | |
| 60 | + window.parent.postMessage(document.getElementById("accua-form-ajax-response").innerHTML, '*'); | |
| 61 | +} catch (err) { | |
| 62 | +} | |
| 63 | +// --> | |
| 64 | +</script> | |
| 65 | +EOJS; | |
| 66 | + | |
| 67 | + echo '</body></html>'; | |
| 68 | + die(''); | |
| 69 | +} | |