コード例 #1
0
function maurisco_cf_plugin_callback()
{
    //	error_log('maurisco_cf_plugin_callback 1');
    //    $nonce = $_POST['maurisco_cf_nonce'];
    // The first thing we do is check the nonce and kill the script if wrong
    //    if ( ! wp_verify_nonce( $nonce, 'return_posts' ) ){
    //        die ( 'Wrong nonce!');
    //    }
    //    error_log($nonce);
    error_log(serialize($_POST));
    $name_0 = $_POST['name_0'] ? $_POST['name_0'] : null;
    $email_0 = $_POST['email_0'] ? $_POST['email_0'] : null;
    $name_1 = $_POST['name_1'] ? $_POST['name_1'] : null;
    $email_1 = $_POST['email_1'] ? $_POST['email_1'] : null;
    $name_2 = $_POST['name_2'] ? $_POST['name_2'] : null;
    $email_2 = $_POST['email_2'] ? $_POST['email_2'] : null;
    $phone = $_POST['phone'] ? $_POST['phone'] : null;
    $event_date = $_POST['event_date'] ? $_POST['event_date'] : null;
    $event_location_1 = $_POST['event_location_1'] ? $_POST['event_location_1'] : null;
    $event_type = $_POST['event_type'] ? $_POST['event_type'] : null;
    $question_1 = $_POST['question_1'] ? $_POST['question_1'] : null;
    $question_2 = $_POST['question_2'] ? $_POST['question_2'] : null;
    $comment_1 = $_POST['comment_1'] ? $_POST['comment_1'] : null;
    $userIp = $_POST['userIp'];
    $maurisco_api_id = get_option('maurisco_api_id');
    $maurisco_api_key = get_option('maurisco_api_key');
    get_transient('maurisco_lead_types_t');
    $type_arr = maurisco_cf_get_leadtypes();
    $event_type_id = maurisco_filter_lead_type($type_arr, $event_type);
    if (defined(MARUISCO_CF_DEBUG)) {
        $url = 'https://192.168.1.157:8000/api/v1/lead';
    } else {
        $url = 'https://mauris.co/api/v1/lead';
    }
    $data = array('apiId' => $maurisco_api_id, 'apiKey' => $maurisco_api_key, 'event_date' => $event_date, 'clients' => array('email_0' => $email_0, 'name_0' => $name_0, 'name_1' => $name_1, 'name_2' => $name_2), 'phone' => $phone, 'event_location_1' => $event_location_1, 'event_type' => $event_type, 'type' => $event_type_id, 'question_1' => $question_1, 'question_2' => $question_2, 'comment_1' => $comment_1, 'ip' => $userIp);
    $result = wp_remote_post($url, array('sslverify' => false, 'body' => $data));
    error_log(serialize($result));
    $response = array('what' => 'maurisco_cf_form', 'action' => 'post inquiry', 'id' => '1', 'data' => '<p>OK</p>');
    $xmlResponse = new WP_Ajax_Response($response);
    $xmlResponse->send();
    die;
}
コード例 #2
0
    /**
     * Render the settings page for this plugin.
     *
     * @since    1.0.0
     */
    public function display_plugin_admin_page()
    {
        include_once 'views/admin.php';
        if (!current_user_can('manage_options')) {
            wp_die(__('You do not have sufficient permissions to access this page.'));
        }
        $maurisco_api_id = get_option('maurisco_api_id');
        $maurisco_api_key = get_option('maurisco_api_key');
        $maurisco_style_input_bg_color = get_option('maurisco_style_input_bg_color');
        $maurisco_style_input_width_percentage = get_option('maurisco_style_input_width_percentage');
        $type_arr = maurisco_cf_get_leadtypes();
        foreach ($type_arr as $type) {
            error_log('--------------------------');
            error_log($type->{'name'});
            error_log($type->{'description'});
            error_log($type->{'_id'});
            if (property_exists($type, 'fields')) {
                error_log(serialize($type->{'fields'}));
            }
        }
        if (isset($_POST['maurisco_api_id']) && isset($_POST['maurisco_api_key'])) {
            $maurisco_api_id = $_POST['maurisco_api_id'];
            $maurisco_api_key = $_POST['maurisco_api_key'];
            $maurisco_style_input_bg_color = $_POST['maurisco_style_input_bg_color'];
            $maurisco_style_input_width_percentage = $_POST['maurisco_style_input_width_percentage'];
            update_option('maurisco_api_id', $maurisco_api_id);
            update_option('maurisco_api_key', $maurisco_api_key);
            update_option('maurisco_style_input_bg_color', $maurisco_style_input_bg_color);
            update_option('maurisco_style_input_width_percentage', $maurisco_style_input_width_percentage);
            ?>
<div class="updated"><p><strong><?php 
            _e('settings saved.', 'menu-test');
            ?>
</strong></p></div>
<?php 
        }
        echo 'Use the following short code on any page to include the contact form <pre>[maurisco_cf]</pre>';
        foreach ($type_arr as $type) {
            echo 'If you have a specific contact page for ' . $type->{'name'} . " lead types include an attribute in the short code like <pre>[maurisco_cf type='" . strtolower($type->{'name'}) . "']</pre>";
        }
        echo '<h2>Settings</h2>';
        echo '<form name="maurisco_admin_form" method="post" action="">';
        echo '<div class="wrap">';
        echo "<div>Enter your Maurisco API ID: <input id='maurisco_api_id' name='maurisco_api_id' size='20' \\\n\t\t\ttype='text' placeholder='xxxxxxxxxxxxxxxx'  value='" . $maurisco_api_id . "'></div>";
        echo "<div>Enter your Maurisco API KEY: <input id='maurisco_api_key' name='maurisco_api_key' size='40' \\\n\t\t\ttype='text' placeholder='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' value='" . $maurisco_api_key . "'></div>";
        echo '</div>';
        echo "<hr>";
        echo "<h2>Styling</h2>";
        echo "<div>Input Textbox Background (RGB Hex):<input id='maurisco_style_input_bg_color' \\\n\t\t name='maurisco_style_input_bg_color' size='40' \\\n\t\t type='text' placeholder='FFFFFF' value='" . $maurisco_style_input_bg_color . "'></div>";
        echo "<div>Input Textbox Width (%):<input id='maurisco_style_input_width_percentage' \\\n\t\t name='maurisco_style_input_width_percentage' size='40' \\\n\t\t type='text' placeholder='100' value='" . $maurisco_style_input_width_percentage . "'></div>";
        echo "<hr>";
        echo "<input type='submit' name='Save' class='button-primary' value='Save' />";
        echo '</form>';
    }
コード例 #3
0
 /**
  * maurisco_cf_sc handle shortcode generation
  *
  * @since    1.0.0
  */
 public function maurisco_cf_sc($atts)
 {
     $a = shortcode_atts(array('type' => ''), $atts);
     $maurisco_api_id = get_option('maurisco_api_id');
     $type_arr = maurisco_cf_get_leadtypes();
     $match = 0;
     if ($atts['type'] && is_array($type_arr)) {
         foreach ($type_arr as $type) {
             error_log('looking at ' . $atts['type'] . ' ' . $type->{'name'});
             if (!strcasecmp($atts['type'], $type->{'name'})) {
                 $match = $type;
                 error_log('found match');
             }
         }
     }
     $output = "<div><form id='maurisco_cf' class='maurisco_cf_form' name='maurisco_cf'>";
     $output .= "<div><input id='maurisco_cf_nonce' type='hidden' value='" . wp_create_nonce('return_posts') . "' /></div>";
     $output .= "<div><input id='maurisco_id' type='hidden' value='" . md5($maurisco_api_id) . "' /></div>";
     $output .= "<div><input id='maurisco_cf_url' type='hidden' value='" . admin_url('admin-ajax.php') . "' /></div>";
     if ($match) {
         $output .= "<div><input id='maurisco_cf_event_type' type='hidden' value='" . $match->{'name'} . "'/></div>";
         if (is_array($type_arr)) {
             foreach ($match->{'fields'} as $field) {
                 $field_markup = $this->field_parser($field);
                 error_log($field_markup);
                 if ($field_markup) {
                     $output .= $field_markup;
                 }
             }
         } else {
             error_log('ERROR : not field types found');
         }
     } else {
         $output .= "<div><input id='maurisco_cf_first_name' class='maurisco_cf_input u-full-width maurisco_cf_text' type='text' required autofocus placeholder='First Name'/></div>";
         $output .= "<div><input id='maurisco_cf_last_name' class='maurisco_cf_input u-full-width maurisco_cf_text' type='text' required autofocus placeholder='Last Name'/></div>";
         $output .= "<div><input id='maurisco_cf_email' class='maurisco_cf_input u-full-width maurisco_cf_email' type='email' required placeholder='Email'/></div>";
         $output .= "<div><input id='maurisco_cf_date' class='maurisco_cf_input u-full-width maurisco_cf_date' type='text' required placeholder='Date' size='20'/></div>";
         if (is_array($type_arr)) {
             $output .= "<div><select id='maurisco_cf_event_type' class='maurisco_cf_select' name='event_type'>";
             foreach ($type_arr as $type) {
                 $output .= "  <option value='" . $type->{'name'} . "'>" . $type->{'name'} . "</option>";
             }
             $output .= "</select></div>";
         }
         $output .= "<div><input id='maurisco_cf_location' class='maurisco_cf_input u-full-width maurisco_cf_text' type='text' required placeholder='Event Location'/></div>";
         $output .= "<div><textarea id='maurisco_cf_comments1' class='maurisco_cf_input u-full-width maurisco_cf_text_area' required placeholder='Comments or questions?' rows='10' cols='50'></textarea></div>";
     }
     $output .= "<div><button id='maurisco_cf_submit' type='submit' class='maurisco_cf_button'>Submit</button></div>";
     $output .= "</form></div>";
     $output .= "<div id='maurisco_cf_message' class='maurisco-cf-message'></div>";
     return $output;
 }