本文整理汇总了PHP中Give函数的典型用法代码示例。如果您正苦于以下问题:PHP Give函数的具体用法?PHP Give怎么用?PHP Give使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Give函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* Set it up.
*/
function setUp()
{
parent::setUp();
$args = array('email' => 'customer@test.com');
$this->_customer_id = Give()->customers->add($args);
$this->_customer = new Give_Customer($this->_customer_id);
}
示例2: donor_dropdown
/**
* Renders an HTML Dropdown of all customers
*
* @access public
* @since 1.0
*
* @param array $args
*
* @return string $output Donor dropdown
*/
public function donor_dropdown($args = array())
{
$defaults = array('name' => 'customers', 'id' => 'customers', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => true, 'placeholder' => __('Select a Donor', 'give'), 'number' => 30);
$args = wp_parse_args($args, $defaults);
$customers = Give()->customers->get_customers(array('number' => $args['number']));
$options = array();
if ($customers) {
$options[0] = __('No donor attached', 'give');
foreach ($customers as $customer) {
$options[absint($customer->id)] = esc_html($customer->name . ' (' . $customer->email . ')');
}
} else {
$options[0] = __('No donors found', 'give');
}
if (!empty($args['selected'])) {
// If a selected customer has been specified, we need to ensure it's in the initial list of customers displayed
if (!array_key_exists($args['selected'], $options)) {
$customer = new Give_Customer($args['selected']);
if ($customer) {
$options[absint($args['selected'])] = esc_html($customer->name . ' (' . $customer->email . ')');
}
}
}
$output = $this->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'] . ' give-customer-select', 'options' => $options, 'multiple' => $args['multiple'], 'chosen' => $args['chosen'], 'show_option_all' => false, 'show_option_none' => false));
return $output;
}
示例3: test_unset_error
public function test_unset_error()
{
$error = give_unset_error('invalid_email');
$errors = Give()->session->get('give_errors');
$expected = array('invalid_user' => 'The user information is invalid.', 'username_incorrect' => 'The username you entered does not exist.', 'password_incorrect' => 'The password you entered is incorrect.');
$this->assertEquals($expected, $errors);
}
示例4: admin_scripts
function admin_scripts()
{
$user = wp_get_current_user();
wp_enqueue_script('give-charts', GIVE_CHARTS_URL . 'build/js/give-api-app.js', array('jquery'), GIVE_CHARTS_VERISON, false);
if ($user) {
$local_object = array('key' => Give()->api->get_user_public_key($user->ID), 'token' => Give()->api->get_token($user->ID));
} else {
$local_object = array('key' => false, 'token' => false);
}
$local_object['give_api_url'] = get_bloginfo('wpurl') . '/give-api/v1';
wp_localize_script('give-charts', 'give_local', $local_object);
}
示例5: give_add_options_links
/**
* Creates the admin submenu pages under the Give menu and assigns their
* links to global variables
*
* @since 1.0
*
* @global $give_settings_page
* @global $give_payments_page
*
* @return void
*/
function give_add_options_links()
{
global $give_settings_page, $give_payments_page, $give_reports_page, $give_add_ons_page, $give_upgrades_screen, $give_donors_page;
//Payments
$give_payment = get_post_type_object('give_payment');
$give_payments_page = add_submenu_page('edit.php?post_type=give_forms', $give_payment->labels->name, $give_payment->labels->menu_name, 'edit_give_payments', 'give-payment-history', 'give_payment_history_page');
//Donors
$give_donors_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donors', 'give'), esc_html__('Donors', 'give'), 'view_give_reports', 'give-donors', 'give_customers_page');
//Reports`
$give_reports_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Donation Reports', 'give'), esc_html__('Reports', 'give'), 'view_give_reports', 'give-reports', 'give_reports_page');
//Settings
$give_settings_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Settings', 'give'), esc_html__('Settings', 'give'), 'manage_give_settings', 'give-settings', array(Give()->give_settings, 'admin_page_display'));
//Add-ons
$give_add_ons_page = add_submenu_page('edit.php?post_type=give_forms', esc_html__('Give Add-ons', 'give'), esc_html__('Add-ons', 'give'), 'install_plugins', 'give-addons', 'give_add_ons_page');
//Upgrades
$give_upgrades_screen = add_submenu_page(null, esc_html__('Give Upgrades', 'give'), esc_html__('Give Upgrades', 'give'), 'manage_give_settings', 'give-upgrades', 'give_upgrades_screen');
}
示例6: recent_donors_function
/**
* Shortcode to list recent donors
* Originally contributed by [@jasontucker](https://github.com/jasontucker)
*
*/
function recent_donors_function()
{
//Get the latest 100 Give Donors
$args = array('number' => 100);
$donors = Give()->customers->get_customers($args);
foreach ($donors as $donor) {
$output = $donor->name . ", ";
// First and Last Name
$name = $donor->name;
//Split up the names
$separate = explode(" ", $name);
//find the surname
$last = array_pop($separate);
//Shorten up the name so it's Jason T. instead of Jason Tucker
$shortenedname = implode(' ', $separate) . " " . $last[0] . ".";
//Display the Jason T. and include a , after it.
$output .= $shortenedname . ", ";
}
$output .= " and many more.";
return $output;
}
示例7: array
}
}
// Delete Taxonomies
$wpdb->delete($wpdb->term_taxonomy, array('taxonomy' => $taxonomy), array('%s'));
}
// Delete the Plugin Pages
$give_created_pages = array('success_page', 'failure_page', 'history_page');
foreach ($give_created_pages as $p) {
$page = give_get_option($p, false);
if ($page) {
wp_delete_post($page, true);
}
}
// Delete all the Plugin Options
delete_option('give_settings');
delete_option('give_version');
// Delete Capabilities
Give()->roles->remove_caps();
// Delete the Roles
$give_roles = array('give_manager', 'give_accountant', 'give_worker', 'give_vendor');
foreach ($give_roles as $role) {
remove_role($role);
}
// Remove all database tables
$wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "give_donors");
$wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "give_customers");
// Cleanup Cron Events
wp_clear_scheduled_hook('give_daily_scheduled_events');
wp_clear_scheduled_hook('give_daily_cron');
wp_clear_scheduled_hook('give_weekly_cron');
}
示例8: give_get_purchase_session
/**
* Retrieve Purchase Data from Session
*
* Used for retrieving info about purchase
* after completing a purchase
*
* @since 1.0
* @uses Give()->session->get()
* @return mixed array | false
*/
function give_get_purchase_session()
{
return Give()->session->get('give_purchase');
}
示例9: give_unset_error
/**
* Removes (unsets) a stored error
*
* @since 1.0
* @uses Give_Session::set()
*
* @param int $error_id ID of the error being set
*
* @return string
*/
function give_unset_error($error_id)
{
$errors = give_get_errors();
if ($errors) {
unset($errors[$error_id]);
Give()->session->set('give_errors', $errors);
}
}
示例10: give_get_email_body_content
/**
* Email Template Body
*
* @since 1.0
*
* @param int $payment_id Payment ID
* @param array $payment_data Payment Data
*
* @return string $email_body Body of the email
*/
function give_get_email_body_content($payment_id = 0, $payment_data = array())
{
global $give_options;
$default_email_body = __("Dear", "give") . " {name},\n\n";
$default_email_body .= __("Thank you for your donation. Your generosity is appreciated! Please click on the link below to view your receipt.", "give") . "\n\n" . '{receipt_link}';
$default_email_body .= "\n\nSincerely,\n{sitename}";
$email = isset($give_options['donation_receipt']) ? stripslashes($give_options['donation_receipt']) : $default_email_body;
$email_body = wpautop($email);
$email_body = apply_filters('give_donation_receipt_' . Give()->emails->get_template(), $email_body, $payment_id, $payment_data);
return apply_filters('give_donation_receipt', $email_body, $payment_id, $payment_data);
}
示例11: query
/**
* Performs the key query
*
* @access public
* @since 1.1
* @return void
*/
public function query()
{
$users = get_users(array('meta_value' => 'give_user_secret_key', 'number' => $this->per_page, 'offset' => $this->per_page * ($this->get_paged() - 1)));
$keys = array();
foreach ($users as $user) {
$keys[$user->ID]['id'] = $user->ID;
$keys[$user->ID]['email'] = $user->user_email;
$keys[$user->ID]['user'] = '<a href="' . add_query_arg('user_id', $user->ID, 'user-edit.php') . '"><strong>' . $user->user_login . '</strong></a>';
$keys[$user->ID]['key'] = Give()->api->get_user_public_key($user->ID);
$keys[$user->ID]['secret'] = Give()->api->get_user_secret_key($user->ID);
$keys[$user->ID]['token'] = Give()->api->get_token($user->ID);
}
return $keys;
}
示例12: setUp
public function setUp()
{
parent::setUp();
$this->object = Give();
}
示例13: give_process_purchase_form
/**
* Process Purchase Form
*
* Handles the purchase form process.
*
* @access private
* @since 1.0
* @return void
*/
function give_process_purchase_form()
{
do_action('give_pre_process_purchase');
// Validate the form $_POST data
$valid_data = give_purchase_form_validate_fields();
// Allow themes and plugins to hook to errors
do_action('give_checkout_error_checks', $valid_data, $_POST);
$is_ajax = isset($_POST['give_ajax']);
// Process the login form
if (isset($_POST['give_login_submit'])) {
give_process_form_login();
}
// Validate the user
$user = give_get_purchase_form_user($valid_data);
if (false === $valid_data || give_get_errors() || !$user) {
if ($is_ajax) {
do_action('give_ajax_checkout_errors');
give_die();
} else {
return false;
}
}
//If AJAX send back success to proceed with form submission
if ($is_ajax) {
echo 'success';
give_die();
}
//After AJAX: Setup session if not using php_sessions
if (!Give()->session->use_php_sessions()) {
//Double-check that set_cookie is publicly accessible;
// we're using a slightly modified class-wp-sessions.php
$session_reflection = new ReflectionMethod('WP_Session', 'set_cookie');
if ($session_reflection->isPublic()) {
// Manually set the cookie.
Give()->session->init()->set_cookie();
}
}
// Setup user information
$user_info = array('id' => $user['user_id'], 'email' => $user['user_email'], 'first_name' => $user['user_first'], 'last_name' => $user['user_last'], 'address' => $user['address']);
$auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
$price = isset($_POST['give-amount']) ? (double) apply_filters('give_donation_total', give_sanitize_amount(give_format_amount($_POST['give-amount']))) : '0.00';
$purchase_key = strtolower(md5($user['user_email'] . date('Y-m-d H:i:s') . $auth_key . uniqid('give', true)));
// Setup purchase information
$purchase_data = array('price' => $price, 'purchase_key' => $purchase_key, 'user_email' => $user['user_email'], 'date' => date('Y-m-d H:i:s', current_time('timestamp')), 'user_info' => stripslashes_deep($user_info), 'post_data' => $_POST, 'gateway' => $valid_data['gateway'], 'card_info' => $valid_data['cc_info']);
// Add the user data for hooks
$valid_data['user'] = $user;
// Allow themes and plugins to hook before the gateway
do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data);
//Sanity check for price
if (!$purchase_data['price']) {
// Revert to manual
$purchase_data['gateway'] = 'manual';
$_POST['give-gateway'] = 'manual';
}
// Allow the purchase data to be modified before it is sent to the gateway
$purchase_data = apply_filters('give_purchase_data_before_gateway', $purchase_data, $valid_data);
// Setup the data we're storing in the purchase session
$session_data = $purchase_data;
// Make sure credit card numbers are never stored in sessions
unset($session_data['card_info']['card_number']);
unset($session_data['post_data']['card_number']);
// Used for showing data to non logged-in users after purchase, and for other plugins needing purchase data.
give_set_purchase_session($session_data);
// Send info to the gateway for payment processing
give_send_to_gateway($purchase_data['gateway'], $purchase_data);
give_die();
}
示例14: reports_data
/**
* Build all the reports data
*
* @access public
* @since 1.0
* @global object $wpdb Used to query the database using the WordPress
* Database API
* @return array $reports_data All the data for donor reports
*/
public function reports_data()
{
global $wpdb;
$data = array();
$paged = $this->get_paged();
$offset = $this->per_page * ($paged - 1);
$search = $this->get_search();
$order = isset($_GET['order']) ? sanitize_text_field($_GET['order']) : 'DESC';
$orderby = isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) : 'id';
$args = array('number' => $this->per_page, 'offset' => $offset, 'order' => $order, 'orderby' => $orderby);
if (is_email($search)) {
$args['email'] = $search;
} elseif (is_numeric($search)) {
$args['id'] = $search;
}
$donors = Give()->customers->get_customers($args);
if ($donors) {
$this->count = count($donors);
foreach ($donors as $donor) {
$user_id = !empty($donor->user_id) ? absint($donor->user_id) : 0;
$data[] = array('id' => $donor->id, 'user_id' => $user_id, 'name' => $donor->name, 'email' => $donor->email, 'num_purchases' => $donor->purchase_count, 'amount_spent' => $donor->purchase_value);
}
}
return $data;
}
示例15: pre_fetch
/**
* Pre Fetch
*/
public function pre_fetch()
{
if ($this->step == 1) {
$this->delete_data('give_temp_reset_ids');
}
$items = get_option('give_temp_reset_ids', false);
if (false === $items) {
$items = array();
$give_types_for_reset = array('give_forms', 'give_log', 'give_payment');
$give_types_for_reset = apply_filters('give_reset_store_post_types', $give_types_for_reset);
$args = apply_filters('give_tools_reset_stats_total_args', array('post_type' => $give_types_for_reset, 'post_status' => 'any', 'posts_per_page' => -1));
$posts = get_posts($args);
foreach ($posts as $post) {
$items[] = array('id' => (int) $post->ID, 'type' => $post->post_type);
}
$customer_args = array('number' => -1);
$customers = Give()->customers->get_customers($customer_args);
foreach ($customers as $customer) {
$items[] = array('id' => (int) $customer->id, 'type' => 'customer');
}
// Allow filtering of items to remove with an unassociative array for each item
// The array contains the unique ID of the item, and a 'type' for you to use in the execution of the get_data method
$items = apply_filters('give_reset_store_items', $items);
$this->store_data('give_temp_reset_ids', $items);
}
}