/** * Set it up. */ function setUp() { parent::setUp(); $args = array('email' => '*****@*****.**'); $this->_customer_id = Give()->customers->add($args); $this->_customer = new Give_Customer($this->_customer_id); }
/** * 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; }
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); }
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); }
/** * 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'); }
/** * 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; }
} } // 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'); }
/** * 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'); }
/** * 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); } }
/** * 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); }
/** * 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'] = '******' . 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; }
public function setUp() { parent::setUp(); $this->object = Give(); }
/** * 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(); }
/** * 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; }
/** * 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); } }
/** * Has the user authenticated? * * @since 1.0 * @access public * * @return void */ public function check_for_token() { $token = isset($_GET['give_nl']) ? $_GET['give_nl'] : ''; // Check for cookie if (empty($token)) { $token = isset($_COOKIE['give_nl']) ? $_COOKIE['give_nl'] : ''; } if (!empty($token)) { if (!$this->is_valid_token($token)) { if (!$this->is_valid_verify_key($token)) { return; } } $this->token_exists = true; // Set cookie $lifetime = current_time('timestamp') + Give()->session->set_expiration_time(); @setcookie('give_nl', $token, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); } }
?> </strong><br /> <?php echo Give()->html->select(array('options' => give_get_country_list(), 'name' => 'give-payment-address[0][country]', 'selected' => $address['country'], 'show_option_all' => false, 'show_option_none' => false, 'chosen' => true, 'placeholder' => __('Select a country', 'give'))); ?> </p> <p id="give-order-address-state-wrap"> <strong class="order-data-address-line"><?php echo _x('State / Province:', 'State / province of address', 'give'); ?> </strong><br /> <?php $states = give_get_states($address['country']); if (!empty($states)) { echo Give()->html->select(array('options' => $states, 'name' => 'give-payment-address[0][state]', 'selected' => $address['state'], 'show_option_all' => false, 'show_option_none' => false, 'chosen' => true, 'placeholder' => __('Select a state', 'give'))); } else { ?> <input type="text" name="give-payment-address[0][state]" value="<?php echo esc_attr($address['state']); ?> " class="medium-text" /> <?php } ?> </p> </div> </div> </div> </div> <!-- /#give-order-address -->
give_set_error('give_recaptcha_test_failed', apply_filters('give_recaptcha_test_failed_message', __('reCAPTCHA test failed', 'give'))); } } else { //Connection issue give_set_error('give_recaptcha_connection_issue', apply_filters('give_recaptcha_connection_issue_message', __('Unable to connect to reCAPTCHA server', 'give'))); } } else { give_set_error('give_recaptcha_failed', apply_filters('give_recaptcha_failed_message', __('Sorry, it looks like the reCAPTCHA test has failed', 'give'))); } } //If no errors or only expired token key error - then send email if (!give_get_errors()) { $customer = Give()->customers->get_customer_by('email', $email); if (isset($customer->id)) { if (Give()->email_access->can_send_email($customer->id)) { Give()->email_access->send_email($customer->id, $email); $show_form = false; } } else { give_set_error('give_no_donor_email_exists', apply_filters('give_no_donor_email_exists_message', __('Sorry, it looks like that donor email address does not exist', 'give'))); } } } //Print any messages & errors give_print_errors(0); //Show the email login form? if ($show_form) { ?> <div class="give-form">
/** * Post-installation * * Runs just after plugin installation and exposes the give_after_install hook. * * @since 1.0 * @return void */ function give_after_install() { if (!is_admin()) { return; } $give_options = get_transient('_give_installed'); // Exit if not in admin or the transient doesn't exist if (false === $give_options) { return; } // Create the donors database (this ensures it creates it on multisite instances where it is network activated) @Give()->customers->create_table(); // Delete the transient delete_transient('_give_installed'); do_action('give_after_install', $give_options); }
/** * Renders the 'Export' tab on the Reports Page * * @since 1.0 * @return void */ function give_reports_tab_export() { ?> <div id="give-dashboard-widgets-wrap"> <div id="post-body"> <div id="post-body-content"> <?php do_action('give_reports_tab_export_content_top'); ?> <table class="widefat export-options-table give-table"> <thead> <tr> <th class="row-title"><?php _e('Export Type', 'give'); ?> </th> <th><?php _e('Export Options', 'give'); ?> </th> </tr> </thead> <tbody> <?php do_action('give_reports_tab_export_table_top'); ?> <tr class="give-export-pdf-sales-earnings"> <td class="row-title"> <h3><span><?php _e('Export PDF of Donations and Income', 'give'); ?> </span></h3> <p><?php _e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?> </p> </td> <td> <a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?> "><?php _e('Generate PDF', 'give'); ?> </a> </td> </tr> <tr class="alternate give-export-sales-earnings"> <td class="row-title"> <h3><span><?php _e('Export Income and Donation Stats', 'give'); ?> </span></h3> <p><?php _e('Download a CSV of income and donations over time.', 'give'); ?> </p> </td> <td> <form method="post"> <?php echo Give()->html->year_dropdown('start_year'); ?> <?php echo Give()->html->month_dropdown('start_month'); ?> <?php echo _x('to', 'Date one to date two', 'give'); ?> <?php echo Give()->html->year_dropdown('end_year'); ?> <?php echo Give()->html->month_dropdown('end_month'); ?> <input type="hidden" name="give-action" value="earnings_export" /> <input type="submit" value="<?php _e('Generate CSV', 'give'); ?> " class="button-secondary" /> </form> </td> </tr> <tr class="give-export-payment-history"> <td class="row-title"> <h3><span><?php _e('Export Donation History', 'give'); ?> </span></h3> <p><?php _e('Download a CSV of all donations recorded.', 'give'); ?> </p> </td> <td> <form method="post"> <?php echo Give()->html->year_dropdown(); ?> <?php echo Give()->html->month_dropdown(); ?> <select name="give_export_payment_status"> <option value="0"><?php _e('All Statuses', 'give'); ?> </option> <?php $statuses = give_get_payment_statuses(); foreach ($statuses as $status => $label) { echo '<option value="' . $status . '">' . $label . '</option>'; } ?> </select> <input type="hidden" name="give-action" value="payment_export" /> <input type="submit" value="<?php _e('Generate CSV', 'give'); ?> " class="button-secondary" /> </form> </td> </tr> <tr class="alt give-export-donors"> <td class="row-title"> <h3><span><?php _e('Export Donors in CSV', 'give'); ?> </span></h3> <p><?php _e('Download a CSV of all donors\' emails. Optionally export only donors that have donated to a particular form. Note: if you have a large number of donors, exporting the donation stats may fail.', 'give'); ?> </p> </td> <td> <form method="post" id="give_donor_export"> <select name="give_export_download" id="give_donor_export_download"> <option value="0"><?php printf(__('All %s', 'give'), give_get_forms_label_plural()); ?> </option> <?php $forms = get_posts(array('post_type' => 'give_forms', 'posts_per_page' => -1)); if ($forms) { foreach ($forms as $form) { echo '<option value="' . $form->ID . '">' . get_the_title($form->ID) . '</option>'; } } ?> </select> <select name="give_export_option" id="give_donor_export_option"> <option value="emails"><?php _e('Emails', 'give'); ?> </option> <option value="emails_and_names"><?php _e('Emails and Names', 'give'); ?> </option> <option value="full"><?php _e('Emails, Names, and Purchase Stats', 'give'); ?> </option> </select> <input type="hidden" name="give-action" value="email_export" /> <input type="submit" value="<?php _e('Generate CSV', 'give'); ?> " class="button-secondary" /> </form> </td> </tr> <?php do_action('give_reports_tab_export_table_bottom'); ?> </tbody> </table> <?php do_action('give_reports_tab_export_content_bottom'); ?> </div> <!-- .post-body-content --> </div> <!-- .post-body --> </div><!-- #give-dashboard-widgets-wrap --> <?php }
public function test_count_customers() { $this->assertEquals(1, Give()->customers->count()); $args = array('date' => array('start' => 'January 1 ' . date('Y') + 1, 'end' => 'January 1 ' . date('Y') + 2)); $this->assertEquals(0, Give()->customers->count($args)); }
/** * Attaches the category filter to the log views * * @access public * @since 1.0 * @return void */ public function category_filter() { $categories = get_terms('form_category'); if ($categories && !is_wp_error($categories)) { echo Give()->html->category_dropdown('category', $this->get_category()); } }
load_textdomain('give', $mofile_global); } elseif (file_exists($mofile_local)) { // Look in local /wp-content/plugins/give/languages/ folder load_textdomain('give', $mofile_local); } else { // Load the default language files load_plugin_textdomain('give', false, $give_lang_dir); } } } } // End if class_exists check /** * The main function responsible for returning the one true Give * Instance to functions everywhere. * * Use this function like you would a global variable, except without needing * to declare the global. * * Example: <?php $give = Give(); ?> * * @since 1.0 * @return object - The one true Give Instance */ function Give() { return Give::instance(); } // Get Give Running Give();
/** * Get system info * * @since 1.0 * @access public * @global object $wpdb Used to query the database using the WordPress Database API * @global array $give_options Array of all Give options * @return string $return A string containing the info to output */ function give_tools_sysinfo_get() { global $wpdb, $give_options; if (!class_exists('Browser')) { require_once GIVE_PLUGIN_DIR . 'includes/libraries/browser.php'; } $browser = new Browser(); // Get theme info if (get_bloginfo('version') < '3.4') { $theme_data = get_theme_data(get_stylesheet_directory() . '/style.css'); $theme = $theme_data['Name'] . ' ' . $theme_data['Version']; } else { $theme_data = wp_get_theme(); $theme = $theme_data->Name . ' ' . $theme_data->Version; } // Try to identify the hosting provider $host = give_get_host(); $return = '### Begin System Info ###' . "\n\n"; // Start with the basics... $return .= '-- Site Info' . "\n\n"; $return .= 'Site URL: ' . site_url() . "\n"; $return .= 'Home URL: ' . home_url() . "\n"; $return .= 'Multisite: ' . (is_multisite() ? 'Yes' : 'No') . "\n"; $return = apply_filters('give_sysinfo_after_site_info', $return); // Can we determine the site's host? if ($host) { $return .= "\n" . '-- Hosting Provider' . "\n\n"; $return .= 'Host: ' . $host . "\n"; $return = apply_filters('give_sysinfo_after_host_info', $return); } // The local users' browser information, handled by the Browser class $return .= "\n" . '-- User Browser' . "\n\n"; $return .= $browser; $return = apply_filters('give_sysinfo_after_user_browser', $return); // WordPress configuration $return .= "\n" . '-- WordPress Configuration' . "\n\n"; $return .= 'Version: ' . get_bloginfo('version') . "\n"; $return .= 'Language: ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n"; $return .= 'Permalink Structure: ' . (get_option('permalink_structure') ? get_option('permalink_structure') : 'Default') . "\n"; $return .= 'Active Theme: ' . $theme . "\n"; $return .= 'Show On Front: ' . get_option('show_on_front') . "\n"; // Only show page specs if frontpage is set to 'page' if (get_option('show_on_front') == 'page') { $front_page_id = get_option('page_on_front'); $blog_page_id = get_option('page_for_posts'); $return .= 'Page On Front: ' . ($front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset') . "\n"; $return .= 'Page For Posts: ' . ($blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset') . "\n"; } // Make sure wp_remote_post() is working $request['cmd'] = '_notify-validate'; $params = array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'Give/' . GIVE_VERSION, 'body' => $request); $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', $params); if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) { $WP_REMOTE_POST = 'wp_remote_post() works'; } else { $WP_REMOTE_POST = 'wp_remote_post() does not work'; } $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n"; $return .= 'Table Prefix: ' . 'Length: ' . strlen($wpdb->prefix) . ' Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable') . "\n"; $return .= 'Admin AJAX: ' . (give_test_ajax_works() ? 'Accessible' : 'Inaccessible') . "\n"; $return .= 'WP_DEBUG: ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n"; $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n"; $return .= 'Registered Post Stati: ' . implode(', ', get_post_stati()) . "\n"; $return = apply_filters('give_sysinfo_after_wordpress_config', $return); // GIVE configuration $return .= "\n" . '-- Give Configuration' . "\n\n"; $return .= 'Version: ' . GIVE_VERSION . "\n"; $return .= 'Upgraded From: ' . get_option('give_version_upgraded_from', 'None') . "\n"; $return .= 'Test Mode: ' . (give_is_test_mode() ? "Enabled\n" : "Disabled\n"); $return .= 'Currency Code: ' . give_get_currency() . "\n"; $return .= 'Currency Position: ' . give_get_option('currency_position', 'before') . "\n"; $return .= 'Decimal Separator: ' . give_get_option('decimal_separator', '.') . "\n"; $return .= 'Thousands Separator: ' . give_get_option('thousands_separator', ',') . "\n"; $return = apply_filters('give_sysinfo_after_give_config', $return); // GIVE pages $return .= "\n" . '-- Give Page Configuration' . "\n\n"; $return .= 'Success Page: ' . (!empty($give_options['success_page']) ? get_permalink($give_options['success_page']) . "\n" : "Unset\n"); $return .= 'Failure Page: ' . (!empty($give_options['failure_page']) ? get_permalink($give_options['failure_page']) . "\n" : "Unset\n"); $return .= 'Give Forms Slug: ' . (defined('GIVE_SLUG') ? '/' . GIVE_SLUG . "\n" : "/donations\n"); $return = apply_filters('give_sysinfo_after_give_pages', $return); // GIVE gateways $return .= "\n" . '-- Give Gateway Configuration' . "\n\n"; $active_gateways = give_get_enabled_payment_gateways(); if ($active_gateways) { $default_gateway_is_active = give_is_gateway_active(give_get_default_gateway(null)); if ($default_gateway_is_active) { $default_gateway = give_get_default_gateway(null); $default_gateway = $active_gateways[$default_gateway]['admin_label']; } else { $default_gateway = 'Test Payment'; } $gateways = array(); foreach ($active_gateways as $gateway) { $gateways[] = $gateway['admin_label']; } $return .= 'Enabled Gateways: ' . implode(', ', $gateways) . "\n"; $return .= 'Default Gateway: ' . $default_gateway . "\n"; } else { $return .= 'Enabled Gateways: None' . "\n"; } $return = apply_filters('give_sysinfo_after_give_gateways', $return); // GIVE Templates $dir = get_stylesheet_directory() . '/give_templates/*'; if (is_dir($dir) && count(glob("{$dir}/*")) !== 0) { $return .= "\n" . '-- Give Template Overrides' . "\n\n"; foreach (glob($dir) as $file) { $return .= 'Filename: ' . basename($file) . "\n"; } $return = apply_filters('give_sysinfo_after_give_templates', $return); } // Must-use plugins $muplugins = get_mu_plugins(); if (count($muplugins > 0)) { $return .= "\n" . '-- Must-Use Plugins' . "\n\n"; foreach ($muplugins as $plugin => $plugin_data) { $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n"; } $return = apply_filters('give_sysinfo_after_wordpress_mu_plugins', $return); } // WordPress active plugins $return .= "\n" . '-- WordPress Active Plugins' . "\n\n"; $plugins = get_plugins(); $active_plugins = get_option('active_plugins', array()); foreach ($plugins as $plugin_path => $plugin) { if (!in_array($plugin_path, $active_plugins)) { continue; } $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } $return = apply_filters('give_sysinfo_after_wordpress_plugins', $return); // WordPress inactive plugins $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n"; foreach ($plugins as $plugin_path => $plugin) { if (in_array($plugin_path, $active_plugins)) { continue; } $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } $return = apply_filters('give_sysinfo_after_wordpress_plugins_inactive', $return); if (is_multisite()) { // WordPress Multisite active plugins $return .= "\n" . '-- Network Active Plugins' . "\n\n"; $plugins = wp_get_active_network_plugins(); $active_plugins = get_site_option('active_sitewide_plugins', array()); foreach ($plugins as $plugin_path) { $plugin_base = plugin_basename($plugin_path); if (!array_key_exists($plugin_base, $active_plugins)) { continue; } $plugin = get_plugin_data($plugin_path); $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n"; } $return = apply_filters('give_sysinfo_after_wordpress_ms_plugins', $return); } // Server configuration (really just versioning) $return .= "\n" . '-- Webserver Configuration' . "\n\n"; $return .= 'PHP Version: ' . PHP_VERSION . "\n"; $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n"; $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n"; $return = apply_filters('give_sysinfo_after_webserver_config', $return); // PHP configs... now we're getting to the important stuff $return .= "\n" . '-- PHP Configuration' . "\n\n"; $return .= 'Safe Mode: ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n"); $return .= 'Memory Limit: ' . ini_get('memory_limit') . "\n"; $return .= 'Upload Max Size: ' . ini_get('upload_max_filesize') . "\n"; $return .= 'Post Max Size: ' . ini_get('post_max_size') . "\n"; $return .= 'Upload Max Filesize: ' . ini_get('upload_max_filesize') . "\n"; $return .= 'Time Limit: ' . ini_get('max_execution_time') . "\n"; $return .= 'Max Input Vars: ' . ini_get('max_input_vars') . "\n"; $return .= 'Display Errors: ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n"; $return = apply_filters('give_sysinfo_after_php_config', $return); // PHP extensions and such $return .= "\n" . '-- PHP Extensions' . "\n\n"; $return .= 'cURL: ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "\n"; $return .= 'fsockopen: ' . (function_exists('fsockopen') ? 'Supported' : 'Not Supported') . "\n"; $return .= 'SOAP Client: ' . (class_exists('SoapClient') ? 'Installed' : 'Not Installed') . "\n"; $return .= 'Suhosin: ' . (extension_loaded('suhosin') ? 'Installed' : 'Not Installed') . "\n"; $return = apply_filters('give_sysinfo_after_php_ext', $return); // Session stuff $return .= "\n" . '-- Session Configuration' . "\n\n"; $return .= 'Give Use Sessions: ' . (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS ? 'Enforced' : (Give()->session->use_php_sessions() ? 'Enabled' : 'Disabled')) . "\n"; $return .= 'Session: ' . (isset($_SESSION) ? 'Enabled' : 'Disabled') . "\n"; // The rest of this is only relevant is session is enabled if (isset($_SESSION)) { $return .= 'Session Name: ' . esc_html(ini_get('session.name')) . "\n"; $return .= 'Cookie Path: ' . esc_html(ini_get('session.cookie_path')) . "\n"; $return .= 'Save Path: ' . esc_html(ini_get('session.save_path')) . "\n"; $return .= 'Use Cookies: ' . (ini_get('session.use_cookies') ? 'On' : 'Off') . "\n"; $return .= 'Use Only Cookies: ' . (ini_get('session.use_only_cookies') ? 'On' : 'Off') . "\n"; } $return = apply_filters('give_sysinfo_after_session_config', $return); $return .= "\n" . '### End System Info ###'; return $return; }
/** * Search content for email tags and filter email tags through their hooks. * * @param string $content Content to search for email tags. * @param int $payment_id The payment id. * * @since 1.0 * * @return string Content with email tags filtered out. */ function give_do_email_tags($content, $payment_id) { // Replace all tags $content = Give()->email_tags->do_tags($content, $payment_id); // Maintaining backwards compatibility $content = apply_filters('give_email_template_tags', $content, give_get_payment_meta($payment_id), $payment_id); // Return content return $content; }
/** * 1.6 Upgrade routine to create the customer meta table. * * @since 1.6 * @return void */ function give_v16_upgrades() { @Give()->customers->create_table(); @Give()->customer_meta->create_table(); }
/** * Process Get Customers API Request * * @access public * @since 1.1 * @global object $wpdb Used to query the database using the WordPress * Database API * * @param int $customer Customer ID * * @return array $customers Multidimensional array of the customers */ public function get_customers($customer = null) { $customers = array(); $error = array(); if (!user_can($this->user_id, 'view_give_sensitive_data') && !$this->override) { return $customers; } global $wpdb; $paged = $this->get_paged(); $per_page = $this->per_page(); $offset = $per_page * ($paged - 1); if (is_numeric($customer)) { $field = 'id'; } else { $field = 'email'; } $customer_query = Give()->customers->get_customers(array('number' => $per_page, 'offset' => $offset, $field => $customer)); $customer_count = 0; if ($customer_query) { foreach ($customer_query as $customer_obj) { $names = explode(' ', $customer_obj->name); $first_name = !empty($names[0]) ? $names[0] : ''; $last_name = ''; if (!empty($names[1])) { unset($names[0]); $last_name = implode(' ', $names); } $customers['donors'][$customer_count]['info']['user_id'] = ''; $customers['donors'][$customer_count]['info']['username'] = ''; $customers['donors'][$customer_count]['info']['display_name'] = ''; $customers['donors'][$customer_count]['info']['customer_id'] = $customer_obj->id; $customers['donors'][$customer_count]['info']['first_name'] = $first_name; $customers['donors'][$customer_count]['info']['last_name'] = $last_name; $customers['donors'][$customer_count]['info']['email'] = $customer_obj->email; if (!empty($customer_obj->user_id)) { $user_data = get_userdata($customer_obj->user_id); // Customer with registered account $customers['donors'][$customer_count]['info']['user_id'] = $customer_obj->user_id; $customers['donors'][$customer_count]['info']['username'] = $user_data->user_login; $customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name; } $customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count; $customers['donors'][$customer_count]['stats']['total_spent'] = $customer_obj->purchase_value; $customer_count++; } } elseif ($customer) { $error['error'] = sprintf(__('Donor %s not found!', 'give'), $customer); return $error; } else { $error['error'] = __('No donors found!', 'give'); return $error; } return $customers; }
/** * Retrieve a states drop down * * @since 1.0 * @return void */ function give_ajax_get_states_field() { if (empty($_POST['country'])) { $_POST['country'] = give_get_country(); } $states = give_get_states($_POST['country']); if (!empty($states)) { $args = array('name' => $_POST['field_name'], 'id' => $_POST['field_name'], 'class' => $_POST['field_name'] . ' give-select', 'options' => give_get_states($_POST['country']), 'show_option_all' => false, 'show_option_none' => false); $response = Give()->html->select($args); } else { $response = 'nostates'; } echo $response; give_die(); }
function give_customers_delete_view($customer) { $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); ?> <?php do_action('give_customer_delete_top', $customer); ?> <div class="info-wrapper customer-section"> <form id="delete-customer" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer->id); ?> "> <div class="customer-notes-header"> <?php echo get_avatar($customer->email, 30); ?> <span><?php echo $customer->name; ?> </span> </div> <div class="customer-info delete-customer"> <span class="delete-customer-options"> <p> <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-confirm')); ?> <label for="give-customer-delete-confirm"><?php _e('Are you sure you want to delete this donor?', 'give'); ?> </label> </p> <p> <?php echo Give()->html->checkbox(array('name' => 'give-customer-delete-records', 'options' => array('disabled' => true))); ?> <label for="give-customer-delete-records"><?php _e('Delete all associated payments and records?', 'give'); ?> </label> </p> <?php do_action('give_customer_delete_inputs', $customer); ?> </span> <span id="customer-edit-actions"> <input type="hidden" name="customer_id" value="<?php echo $customer->id; ?> " /> <?php wp_nonce_field('delete-customer', '_wpnonce', false, true); ?> <input type="hidden" name="give_action" value="delete-customer" /> <input type="submit" disabled="disabled" id="give-delete-customer" class="button-primary" value="<?php _e('Delete Donor', 'give'); ?> " /> <a id="give-delete-customer-cancel" href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id); ?> " class="delete"><?php _e('Cancel', 'give'); ?> </a> </span> </div> </form> </div> <?php do_action('give_customer_delete_bottom', $customer); }
/** * Receipt Shortcode. * * Shows a donation receipt. * * @since 1.0 * * @param array $atts Shortcode attributes. * @param string $content * * @return string */ function give_receipt_shortcode($atts, $content = null) { global $give_receipt_args, $payment; $give_receipt_args = shortcode_atts(array('error' => esc_html__('Sorry, you are missing the payment key to view this donation receipt.', 'give'), 'price' => true, 'donor' => true, 'date' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'give_receipt'); //set $session var $session = give_get_purchase_session(); //set payment key var if (isset($_GET['payment_key'])) { $payment_key = urldecode($_GET['payment_key']); } elseif ($session) { $payment_key = $session['purchase_key']; } elseif ($give_receipt_args['payment_key']) { $payment_key = $give_receipt_args['payment_key']; } $email_access = give_get_option('email_access'); // No payment_key found & Email Access is Turned on: if (!isset($payment_key) && $email_access == 'on' && !Give()->email_access->token_exists) { ob_start(); give_get_template_part('email-login-form'); return ob_get_clean(); } elseif (!isset($payment_key)) { return give_output_error($give_receipt_args['error'], false, 'error'); } $payment_id = give_get_purchase_id_by_key($payment_key); $user_can_view = give_can_view_receipt($payment_key); // Key was provided, but user is logged out. Offer them the ability to login and view the receipt. if (!$user_can_view && $email_access == 'on' && !Give()->email_access->token_exists) { ob_start(); give_get_template_part('email-login-form'); return ob_get_clean(); } elseif (!$user_can_view) { global $give_login_redirect; $give_login_redirect = give_get_current_page_url(); ob_start(); give_output_error(apply_filters('give_must_be_logged_in_error_message', esc_html__('You must be logged in to view this donation payment receipt.', 'give'))); give_get_template_part('shortcode', 'login'); $login_form = ob_get_clean(); return $login_form; } /* * Check if the user has permission to view the receipt. * * If user is logged in, user ID is compared to user ID of ID stored in payment meta * or if user is logged out and purchase was made as a guest, the purchase session is checked for * or if user is logged in and the user can view sensitive shop data. * */ if (!apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { return give_output_error($give_receipt_args['error'], false, 'error'); } ob_start(); give_get_template_part('shortcode', 'receipt'); $display = ob_get_clean(); return $display; }