Exemple #1
0
        $response = wp_remote_post($url, array('body' => $payload, 'timeout' => apply_filters('camptix_paypal_timeout', 20), 'httpversion' => '1.1'));
        $status = wp_parse_args(wp_remote_retrieve_body($response));
        if (isset($status['ACK']) && 'SuccessWithWarning' == $status['ACK']) {
            $camptix->log('Warning during PayPal request', null, $response);
        }
        return $response;
    }
    /**
     * Validate an incoming IPN request
     *
     * @param array $payload
     *
     * @return mixed A WP_Error for a failed request, or an array for a successful response
     */
    function verify_ipn($payload = array())
    {
        // Replace credentials from a predefined account if any.
        $options = array_merge($this->options, $this->get_predefined_account($this->options['api_predef']));
        $url = $options['sandbox'] ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr';
        $payload = 'cmd=_notify-validate&' . http_build_query($payload);
        $request_args = array('body' => $payload, 'timeout' => apply_filters('camptix_paypal_timeout', 20), 'httpversion' => '1.1');
        return wp_remote_post($url, $request_args);
    }
}
/**
 * The last stage is to register your payment method with CampTix.
 * Since the CampTix_Payment_Method class extends from CampTix_Addon,
 * we use the camptix_register_addon function to register it.
 */
camptix_register_addon('CampTix_Payment_Method_PayPal');
Exemple #2
0
        }
        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }
    /**
     * [camptix_private] shortcode, this part displays the actual content in a #tix div
     * with notices.
     */
    function shortcode_private_display_content($atts, $content)
    {
        ob_start();
        echo '<div id="tix">';
        do_action('camptix_notices');
        echo do_shortcode($content);
        echo '</div>';
        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }
    function generate_view_token_for_attendee($attendee_id)
    {
        $email = get_post_meta($attendee_id, 'tix_email', true);
        $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
        $view_token = md5('tix-view-token-' . strtolower($email . $ip));
        return $view_token;
    }
}
// Register this class as a CampTix Addon.
camptix_register_addon('CampTix_Addon_Shortcodes');
    /**
     * Runs during camptix_init, @see CampTix_Addon
     */
    function camptix_init()
    {
        add_action('camptix_log_raw', array($this, 'camptix_log_raw'), 10, 4);
    }
    function camptix_log_raw($message, $post_id, $data, $section)
    {
        // If the log file is not opened yet, open it for writing.
        if (null === $this->_logfile) {
            $this->_logfile = fopen(apply_filters('camptix_logfile_path', '/tmp/camptix.log'), 'a+');
        }
        // If there was an error opening the log file, don't do anything else.
        if (!$this->_logfile) {
            return;
        }
        $url = parse_url(home_url());
        $message = sprintf('[%s] %s/%s: %s', date('Y-m-d H:i:s'), $url['host'], $section . ($post_id ? '/' . $post_id : ''), $message);
        fwrite($this->_logfile, $message . PHP_EOL);
    }
    function __destruct()
    {
        if ($this->_logfile) {
            fclose($this->_logfile);
        }
    }
}
// Register this class as a CampTix Addon.
camptix_register_addon('CampTix_Addon_Logging_File');
        $current_user = wp_get_current_user();
        $unknown_attendee_info = $this->get_unknown_attendee_info();
        $replacement_values = array('first_name' => $current_user->first_name, 'last_name' => $current_user->last_name, 'email' => $current_user->user_email);
        foreach ($ticket_info as $key => $value) {
            if ($value == $unknown_attendee_info[$key]) {
                $ticket_info[$key] = $replacement_values[$key];
            }
        }
        return $ticket_info;
    }
    /**
     * Remove unconfirmed attendees from the [attendees] shortcode output.
     *
     * @param array $query_args
     *
     * @return array
     */
    public function hide_unconfirmed_attendees($query_args)
    {
        $meta_query = array('key' => 'tix_username', 'value' => self::UNCONFIRMED_USERNAME, 'compare' => '!=');
        if (isset($query_args['meta_query'])) {
            $query_args['meta_query'][] = $meta_query;
        } else {
            $query_args['meta_query'] = array($meta_query);
        }
        return $query_args;
    }
}
// CampTix_Require_Login
camptix_register_addon('CampTix_Require_Login');
        ?>

		<select name="<?php 
        echo esc_attr($name);
        ?>
">
			<?php 
        foreach ($countries as $country) {
            ?>
				<option value="<?php 
            echo esc_attr($country);
            ?>
" <?php 
            selected($country, $user_value);
            ?>
>
					<?php 
            echo esc_html($country);
            ?>
				</option>
			<?php 
        }
        ?>
		</select>

		<?php 
    }
}
// Register this class as a CampTix Addon.
camptix_register_addon('CampTix_Addon_Country_Field');
				<?php 
        _e('Mark as attended', 'camptix');
        ?>
			</a>
		</script>

		<?php 
    }
    /**
     * AJAX handler to mark a ticket holder as having actually attended the event.
     */
    public function bulk_mark_as_attended()
    {
        if (empty($_REQUEST['action']) || empty($_REQUEST['attendee_id']) || empty($_REQUEST['nonce'])) {
            wp_send_json_error(array('error' => 'Required parameters not set.'));
        }
        $attendee_id = absint($_REQUEST['attendee_id']);
        if (!wp_verify_nonce($_REQUEST['nonce'], 'tix_mark_attended_' . $attendee_id) || !current_user_can('edit_post', $attendee_id)) {
            wp_send_json_error(array('error' => 'Permission denied.'));
        }
        $attendee = get_post($attendee_id);
        if (!is_a($attendee, 'WP_Post') || 'tix_attendee' != $attendee->post_type) {
            wp_send_json_error(array('error' => 'Invalid attendee.'));
        }
        update_post_meta($attendee_id, 'tix_attended', true);
        wp_send_json_success();
    }
}
// Register this class as a CampTix Addon.
camptix_register_addon('CampTix_Track_Attendance');
Exemple #7
0
        global $camptix;
        $this->questions = $camptix->get_all_questions();
    }
    function attendees_shortcode_item($attendee_id)
    {
        foreach ($this->questions as $question) {
            if (get_post_meta($question->ID, 'tix_type', true) != 'url') {
                continue;
            }
            $answers = (array) get_post_meta($attendee_id, 'tix_questions', true);
            if (!isset($answers[$question->ID])) {
                continue;
            }
            $url = esc_url_raw(trim($answers[$question->ID]));
            if ($url) {
                $parsed = parse_url($url);
                $label = $parsed['host'];
                if (isset($parsed['path'])) {
                    $label .= untrailingslashit($parsed['path']);
                }
                if (substr($label, 0, 4) == 'www.') {
                    $label = substr($label, 4);
                }
                printf('<a class="tix-field tix-attendee-url" href="%s">%s</a>', esc_url($url), esc_html($label));
            }
        }
    }
}
// Register this class as a CampTix Addon.
camptix_register_addon('CampTix_Addon_URL_Field');
        }
        return $output;
    }
    /**
     * This is the main method of your class. It is fired as soon as a user
     * initiates the checkout process with your payment method selected. At any
     * point in time, you can use $this->payment_result to return a payment result
     * back to CampTix. This does not necessarily have to happen in this function.
     * See the PayPal example for details.
     */
    function payment_checkout($payment_token)
    {
        global $camptix;
        // Process $order and do something.
        $order = $this->get_order($payment_token);
        do_action('camptix_before_payment', $payment_token);
        $payment_data = array('transaction_id' => 'tix-blackhole-' . md5(sprintf('tix-blackhole-%s-%s-%s', print_r($order, true), time(), rand(1, 9999))), 'transaction_details' => array('raw' => array('payment_method' => 'blackhole')));
        if ($this->options['always_succeed']) {
            return $this->payment_result($payment_token, $camptix::PAYMENT_STATUS_COMPLETED, $payment_data);
        } else {
            return $this->payment_result($payment_token, $camptix::PAYMENT_STATUS_FAILED);
        }
    }
}
/**
 * The last stage is to register your payment method with CampTix.
 * Since the CampTix_Payment_Method class extends from CampTix_Addon,
 * we use the camptix_register_addon function to register it.
 */
camptix_register_addon('CampTix_Payment_Method_Blackhole');
    {
        $post_types = array('tix_attendee', 'tix_ticket', 'tix_coupon', 'tix_email');
        foreach ($post_types as $post_type) {
            add_meta_box('tix_log', 'CampTix Meta Log', array($this, 'metabox_log'), $post_type, 'normal');
        }
    }
    /**
     * CampTix Log metabox for various post types.
     */
    function metabox_log()
    {
        global $post, $camptix;
        $rows = array();
        // The log is stored in an array of array( 'timestamp' => x, 'message' => y ) format.
        $log = get_post_meta($post->ID, 'tix_log', true);
        if (!$log) {
            $log = array();
        }
        // Add entries as rows.
        foreach ($log as $entry) {
            $rows[] = array(date('Y-m-d H:i:s', intval($entry['timestamp'])), esc_html($entry['message']));
        }
        if (count($rows) < 1) {
            $rows[] = array('No log entries yet.', '');
        }
        $camptix->table($rows, 'tix-log-table');
    }
}
// Register this class as a CampTix Addon.
camptix_register_addon('CampTix_Addon_Logging_Meta');