/** * Define the metabox and field configurations. * * @param array $meta_boxes * * @return array */ function give_single_forms_cmb2_metaboxes(array $meta_boxes) { $post_id = give_get_admin_post_id(); $price = give_get_form_price($post_id); $goal = give_get_form_goal($post_id); $variable_pricing = give_has_variable_prices($post_id); $prices = give_get_variable_prices($post_id); //No empty prices - min. 1.00 for new forms if (empty($price)) { $price = esc_attr(give_format_amount('1.00')); } // Start with an underscore to hide fields from custom fields list $prefix = '_give_'; /** * Repeatable Field Groups */ $meta_boxes['form_field_options'] = apply_filters('give_forms_field_options', array('id' => 'form_field_options', 'title' => __('Donation Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array(array('name' => __('Donation Option', 'give'), 'description' => __('Would you like this form to have one set donation price or multiple levels (for example, $10 silver, $20 gold, $50 platinum)?', 'give'), 'id' => $prefix . 'price_option', 'type' => 'radio_inline', 'default' => 'set', 'options' => apply_filters('give_forms_price_options', array('set' => __('Set Donation', 'give'), 'multi' => __('Multi-level Donation', 'give')))), array('name' => __('Set Donation', 'give'), 'description' => __('This is the set donation amount for this form.', 'give'), 'id' => $prefix . 'set_price', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'value' => $price, 'class' => 'cmb-type-text-small give-money-field')), array('id' => $prefix . 'levels_header', 'type' => 'levels_repeater_header'), array('id' => $prefix . 'donation_levels', 'type' => 'group', 'row_classes' => 'give-subfield', 'options' => array('add_button' => __('Add Level', 'give'), 'remove_button' => __('<span class="dashicons dashicons-no"></span>', 'give'), 'sortable' => true), 'fields' => apply_filters('give_donation_levels_table_row', array(array('name' => __('ID', 'give'), 'id' => $prefix . 'id', 'type' => 'levels_id'), array('name' => __('Amount', 'give'), 'id' => $prefix . 'amount', 'type' => 'text_small', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('1.00'), 'class' => 'cmb-type-text-small give-money-field'), 'before' => 'give_format_admin_multilevel_amount'), array('name' => __('Text', 'give'), 'id' => $prefix . 'text', 'type' => 'text', 'attributes' => array('placeholder' => __('Donation Level', 'give'), 'rows' => 3)), array('name' => __('Default', 'give'), 'id' => $prefix . 'default', 'type' => 'give_default_radio_inline')))), array('name' => __('Display Style', 'give'), 'description' => __('Set how the donations levels will display on the form.', 'give'), 'id' => $prefix . 'display_style', 'type' => 'radio_inline', 'default' => 'buttons', 'options' => array('buttons' => __('Buttons', 'give'), 'radios' => __('Radios', 'give'), 'dropdown' => __('Dropdown', 'give'))), array('name' => __('Custom Amount', 'give'), 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), 'id' => $prefix . 'custom_amount', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Custom Amount Text', 'give'), 'description' => __('This text appears as a label next to the custom amount field for single level forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option). Add your own message or leave this field blank to prevent it from displaying within your form.', 'give'), 'id' => $prefix . 'custom_amount_text', 'type' => 'text', 'row_classes' => 'give-subfield', 'attributes' => array('rows' => 3, 'placeholder' => __('Give a Custom Amount', 'give'))), array('name' => __('Set Goal?', 'give'), 'description' => __('Do you want to set a donation goal for this form?', 'give'), 'id' => $prefix . 'goal_option', 'type' => 'radio_inline', 'default' => 'no', 'options' => array('yes' => __('Yes', 'give'), 'no' => __('No', 'give'))), array('name' => __('Set Goal', 'give'), 'description' => __('This is the goal you want to achieve for this form.', 'give'), 'id' => $prefix . 'set_goal', 'type' => 'text_small', 'row_classes' => 'give-subfield', 'before_field' => give_get_option('currency_position') == 'before' ? '<span class="give-money-symbol give-money-symbol-before">' . give_currency_symbol() . '</span>' : '', 'after_field' => give_get_option('currency_position') == 'after' ? '<span class="give-money-symbol give-money-symbol-after">' . give_currency_symbol() . '</span>' : '', 'attributes' => array('placeholder' => give_format_amount('0.00'), 'value' => isset($goal) ? esc_attr(give_format_amount($goal)) : '', 'class' => 'cmb-type-text-small give-money-field')), array('name' => __('Goal Progress Bar Color', 'give'), 'id' => $prefix . 'goal_color', 'type' => 'colorpicker', 'row_classes' => 'give-subfield', 'default' => '#2bc253'))))); /** * Content Field */ $meta_boxes['form_content_options'] = apply_filters('give_forms_content_options', array('id' => 'form_content_options', 'title' => __('Form Content', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_content_options_metabox_fields', array(array('name' => __('Display Content', 'give'), 'description' => __('Do you want to display content? If you select "Yes" a WYSIWYG editor will appear which you will be able to enter content to display above or below the form.', 'give'), 'id' => $prefix . 'content_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No content', 'give'), 'give_pre_form' => __('Yes, display content ABOVE the form fields', 'give'), 'give_post_form' => __('Yes, display content BELOW the form fields', 'give'))), 'default' => 'none'), array('name' => __('Content', 'give'), 'description' => __('This content will display on the single give form page.', 'give'), 'id' => $prefix . 'form_content', 'row_classes' => 'give-subfield', 'type' => 'wysiwyg'))))); /** * Display Options */ $meta_boxes['form_display_options'] = apply_filters('give_form_display_options', array('id' => 'form_display_options', 'title' => __('Form Display Options', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'show_names' => true, 'fields' => apply_filters('give_forms_display_options_metabox_fields', array(array('name' => __('Payment Fields', 'give'), 'desc' => __('How would you like to display payment information for this form? The "Show on Page" option will display the entire form when the page loads. "Reveal Upon Click" places a button below the donation fields and upon clicks slides into view the rest of the fields. "Modal Window Upon Click" is a similar option, rather than sliding into view the fields they will open in a shadow box or "modal" window.', 'give'), 'id' => $prefix . 'payment_display', 'type' => 'select', 'options' => array('onpage' => __('Show on Page', 'give'), 'reveal' => __('Reveal Upon Click', 'give'), 'modal' => __('Modal Window Upon Click', 'give')), 'default' => 'onpage'), array('id' => $prefix . 'reveal_label', 'name' => __('Reveal / Modal Open Text', 'give'), 'desc' => __('The button label for completing the donation.', 'give'), 'type' => 'text_small', 'row_classes' => 'give-subfield', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('id' => $prefix . 'checkout_label', 'name' => __('Complete Donation Text', 'give'), 'desc' => __('The button label for completing a donation.', 'give'), 'type' => 'text_small', 'attributes' => array('placeholder' => __('Donate Now', 'give'))), array('name' => __('Default Gateway', 'give'), 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), 'id' => $prefix . 'default_gateway', 'type' => 'default_gateway'), array('name' => __('Disable Guest Donations', 'give'), 'desc' => __('Do you want to require users be logged-in to make donations?', 'give'), 'id' => $prefix . 'logged_in_only', 'type' => 'checkbox'), array('name' => __('Register / Login Form', 'give'), 'desc' => __('Display the registration and login forms in the checkout section for non-logged-in users. Note: this option will not require users to register or log in prior to completing a donation. It simply determines whether the login and/or registration form are displayed on the checkout page.', 'give'), 'id' => $prefix . 'show_register_form', 'type' => 'select', 'options' => array('both' => __('Registration and Login Forms', 'give'), 'registration' => __('Registration Form Only', 'give'), 'login' => __('Login Form Only', 'give'), 'none' => __('None', 'give')), 'default' => 'none'), array('name' => __('Floating Labels', 'give'), 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form.<br>Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url("http://bradfrost.com/blog/post/float-label-pattern/")), 'id' => $prefix . 'form_floating_labels', 'type' => 'select', 'options' => array('' => __('Use the global setting', 'give'), 'enabled' => __('Enabled', 'give'), 'disabled' => __('Disabled', 'give')), 'default' => 'none'))))); /** * Terms & Conditions */ $meta_boxes['form_terms_options'] = apply_filters('give_forms_terms_options', array('id' => 'form_terms_options', 'title' => __('Terms and Conditions', 'give'), 'object_types' => array('give_forms'), 'context' => 'normal', 'priority' => 'high', 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array(array('name' => __('Terms and Conditions', 'give'), 'description' => __('Do you want to require the user to agree to terms and conditions prior to being able to complete their donation?', 'give'), 'id' => $prefix . 'terms_option', 'type' => 'select', 'options' => apply_filters('give_forms_content_options_select', array('none' => __('No', 'give'), 'yes' => __('Yes', 'give'))), 'default' => 'none'), array('id' => $prefix . 'agree_label', 'name' => __('Agree to Terms Label', 'give'), 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), 'type' => 'text', 'row_classes' => 'give-subfield', 'size' => 'regular', 'attributes' => array('placeholder' => __('Agree to Terms?', 'give'))), array('id' => $prefix . 'agree_text', 'row_classes' => 'give-subfield', 'name' => __('Agreement Text', 'give'), 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), 'type' => 'wysiwyg'))))); return $meta_boxes; }
/** * Register Styles * * Checks the styles option and hooks the required filter. * * @since 1.0 * @return void */ function give_register_styles() { if (give_get_option('disable_css', false)) { return; } // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; $file = 'give' . $suffix . '.css'; $templates_dir = give_get_theme_template_dir_name(); $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()) . $templates_dir . $file; $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()) . $templates_dir . 'give.css'; $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file; $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'give.css'; $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()) . $file; // Look in the child theme directory first, followed by the parent theme, followed by the Give core templates directory // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled. // This allows users to copy just give.css to their theme if (file_exists($child_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2))) { if (!empty($nonmin)) { $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . 'give.css'; } else { $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . $file; } } elseif (file_exists($parent_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2))) { if (!empty($nonmin)) { $url = trailingslashit(get_template_directory_uri()) . $templates_dir . 'give.css'; } else { $url = trailingslashit(get_template_directory_uri()) . $templates_dir . $file; } } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) { $url = trailingslashit(give_get_templates_url()) . $file; } wp_register_style('give-styles', $url, array(), GIVE_VERSION, 'all'); wp_enqueue_style('give-styles'); }
/** * Get things started * * Defines our WP_Session constants, includes the necessary libraries and * retrieves the WP Session instance * * @since 1.0 */ public function __construct() { $this->use_php_sessions = $this->use_php_sessions(); $this->exp_option = give_get_option('session_lifetime'); if ($this->use_php_sessions) { if (is_multisite()) { $this->prefix = '_' . get_current_blog_id(); } // Use PHP SESSION (must be enabled via the GIVE_USE_PHP_SESSIONS constant) add_action('init', array($this, 'maybe_start_session'), -2); } else { // Use WP_Session (default) if (!defined('WP_SESSION_COOKIE')) { define('WP_SESSION_COOKIE', 'give_wp_session'); } if (!class_exists('Recursive_ArrayAccess')) { require_once GIVE_PLUGIN_DIR . 'includes/libraries/class-recursive-arrayaccess.php'; } if (!class_exists('WP_Session')) { require_once GIVE_PLUGIN_DIR . 'includes/libraries/class-wp-session.php'; require_once GIVE_PLUGIN_DIR . 'includes/libraries/wp-session.php'; } add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); } if (empty($this->session) && !$this->use_php_sessions) { add_action('plugins_loaded', array($this, 'init'), -1); } else { add_action('init', array($this, 'init'), -1); } }
/** * Register styles. * * Checks the styles option and hooks the required filter. * * @since 1.0 * @return void */ function give_register_styles() { if (give_get_option('disable_css', false)) { return; } wp_register_style('give-styles', give_get_stylesheet_uri(), array(), GIVE_VERSION, 'all'); wp_enqueue_style('give-styles'); }
/** * Set the CSV columns. * * @access public * @since 1.5 * @return array $cols All the columns. */ public function csv_cols() { $cols = array('id' => esc_html__('ID', 'give'), 'seq_id' => esc_html__('Payment Number', 'give'), 'email' => esc_html__('Email', 'give'), 'first' => esc_html__('First Name', 'give'), 'last' => esc_html__('Last Name', 'give'), 'address1' => esc_html__('Address', 'give'), 'address2' => esc_html__('Address (Line 2)', 'give'), 'city' => esc_html__('City', 'give'), 'state' => esc_html__('State', 'give'), 'country' => esc_html__('Country', 'give'), 'zip' => esc_html__('Zip / Postal Code', 'give'), 'form_id' => esc_html__('Form ID', 'give'), 'form_name' => esc_html__('Form Name', 'give'), 'amount' => esc_html__('Amount', 'give') . ' (' . html_entity_decode(give_currency_filter('')) . ')', 'gateway' => esc_html__('Payment Method', 'give'), 'trans_id' => esc_html__('Transaction ID', 'give'), 'key' => esc_html__('Purchase Key', 'give'), 'date' => esc_html__('Date', 'give'), 'user' => esc_html__('User', 'give'), 'status' => esc_html__('Status', 'give')); if (!give_get_option('enable_sequential')) { unset($cols['seq_id']); } return $cols; }
/** * Test that the give_register_styles() function will bail when the 'disable_css' * option is set to true. * * @since 1.0 */ public function test_register_styles_bail_option() { // Prepare test $origin_disable_css = give_get_option('disable_css', false); give_update_option('disable_css', true); // Assert $this->assertNull(give_register_styles()); // Reset to origin give_update_option('disable_css', $origin_disable_css); }
/** * Output sidebar option * @description Determines whether the user has enabled or disabled the sidebar for Single Give forms * @since 1.3 * */ public function give_output_sidebar_option() { $sidebar_option = give_get_option('disable_form_sidebar'); //Add full width class when feature image is disabled AND no widgets are present if ($sidebar_option !== 'on') { add_action('give_before_single_form_summary', 'give_left_sidebar_pre_wrap', 5); add_action('give_before_single_form_summary', 'give_show_form_images', 10); add_action('give_before_single_form_summary', 'give_get_forms_sidebar', 20); add_action('give_before_single_form_summary', 'give_left_sidebar_post_wrap', 30); } }
/** * Give Forms Columns * * Defines the custom columns and their order * * @since 1.0 * * @param array $give_form_columns Array of forms columns * * @return array $form_columns Updated array of forms columns * Post Type List Table */ function give_form_columns($give_form_columns) { //Standard columns $give_form_columns = array('cb' => '<input type="checkbox"/>', 'title' => __('Name', 'give'), 'form_category' => __('Categories', 'give'), 'form_tag' => __('Tags', 'give'), 'price' => __('Price', 'give'), 'goal' => __('Goal', 'give'), 'donations' => __('Donations', 'give'), 'earnings' => __('Income', 'give'), 'shortcode' => __('Shortcode', 'give'), 'date' => __('Date', 'give')); //Does the user want categories / tags? if (give_get_option('enable_categories') !== 'on') { unset($give_form_columns['form_category']); } if (give_get_option('enable_tags') !== 'on') { unset($give_form_columns['form_tag']); } return apply_filters('give_forms_columns', $give_form_columns); }
/** * Echo the widget content. * * @param array $args Display arguments including before_title, after_title, * before_widget, and after_widget. * @param array $instance The settings for the particular instance of the widget. */ public function widget($args, $instance) { $title = !empty($instance['title']) ? $instance['title'] : ''; $title = apply_filters('widget_title', $title, $instance, $this->id_base); // If user set float labels to global then check global float label setting and update donation form widget accordingly. if ('global' === $instance['float_labels']) { $instance['float_labels'] = 'on' === give_get_option('enable_floatlabels', '') ? 'enabled' : 'disabled'; } echo $args['before_widget']; do_action('give_before_forms_widget'); echo $title ? $args['before_title'] . $title . $args['after_title'] : ''; give_get_donation_form($instance); echo $args['after_widget']; do_action('give_after_forms_widget'); }
/** * Class Constructor * * Defines our session constants, includes the necessary libraries and retrieves the session instance. * * @since 1.0 * @access public * * @return void */ public function __construct() { $this->use_php_sessions = $this->use_php_sessions(); $this->exp_option = give_get_option('session_lifetime'); //PHP Sessions if ($this->use_php_sessions) { if (is_multisite()) { $this->prefix = '_' . get_current_blog_id(); } add_action('init', array($this, 'maybe_start_session'), -2); } else { if (!$this->should_start_session()) { return; } // Use WP_Session if (!defined('WP_SESSION_COOKIE')) { define('WP_SESSION_COOKIE', 'give_wp_session'); } if (!class_exists('Recursive_ArrayAccess')) { require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; } if (!class_exists('WP_Session')) { require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; } add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); } //Init Session if (empty($this->session) && !$this->use_php_sessions) { add_action('plugins_loaded', array($this, 'init'), -1); } else { add_action('init', array($this, 'init'), -1); } //Set cookie on Donation Completion page add_action('give_pre_process_purchase', array($this, 'set_session_cookies')); }
/** * Send Offline Donation Instructions * * @description Sends a notice to the donor with offline instructions; can be customized per form * * @param int $payment_id * * @since 1.0 * @return void */ function give_offline_send_donor_instructions($payment_id = 0) { $payment_data = give_get_payment_meta($payment_id); $post_offline_customization_option = get_post_meta($payment_data['form_id'], '_give_customize_offline_donations', true); //Customize email content depending on whether the single form has been customized $email_content = give_get_option('global_offline_donation_email'); if ($post_offline_customization_option === 'yes') { $email_content = get_post_meta($payment_data['form_id'], '_give_offline_donation_email', true); } $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); $from_email = give_get_option('from_email', get_bloginfo('admin_email')); $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); $to_email = give_get_payment_user_email($payment_id); $subject = give_get_option('offline_donation_subject', __('Offline Donation Instructions', 'give')); if ($post_offline_customization_option === 'yes') { $subject = get_post_meta($payment_data['form_id'], '_give_offline_donation_subject', true); } $subject = apply_filters('give_offline_donation_subject', wp_strip_all_tags($subject), $payment_id); $subject = give_do_email_tags($subject, $payment_id); $attachments = apply_filters('give_offline_donation_attachments', array(), $payment_id, $payment_data); $message = give_do_email_tags($email_content, $payment_id); $emails = Give()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('heading', __('Offline Donation Instructions', 'give')); $headers = apply_filters('give_receipt_headers', $emails->get_headers(), $payment_id, $payment_data); $emails->__set('headers', $headers); $emails->send($to_email, $subject, $message, $attachments); }
/** * Determines if secure checkout pages are enforced * * @since 1.0 * @return bool True if enforce SSL is enabled, false otherwise */ function give_is_ssl_enforced() { $ssl_enforced = give_get_option('enforce_ssl', false); return (bool) apply_filters('give_is_ssl_enforced', $ssl_enforced); }
/** * Send the user's token * * @since 1.0 * @access public * * @param $customer_id Customer id. * @param $email Customer email. * * @return void */ public function send_email($customer_id, $email) { $verify_key = wp_generate_password(20, false); // Generate a new verify key $this->set_verify_key($customer_id, $email, $verify_key); // Get the purchase history URL $page_id = give_get_option('history_page'); $access_url = add_query_arg(array('give_nl' => $verify_key), get_permalink($page_id)); //Nice subject and message $subject = apply_filters('give_email_access_token_subject', sprintf(esc_html__('Your Access Link to %s', 'give'), get_bloginfo('name'))); $message = esc_html__('You or someone in your organization requested an access link be sent to this email address. This is a temporary access link for you to view your donation information. Click on the link below to view:', 'give') . "\n\n"; $message .= '<a href="' . esc_url($access_url) . '" target="_blank">' . esc_html__('Access My Donation Details »', 'give') . '</a>' . "\n\n"; $message .= "\n\n"; $message .= esc_html__('Sincerely,', 'give') . "\n"; $message .= get_bloginfo('name') . "\n"; $message = apply_filters('give_email_access_token_message', $message); // Send the email Give()->emails->__set('heading', apply_filters('give_email_access_token_heading', esc_html__('Your Access Link', 'give'))); Give()->emails->send($email, $subject, $message); }
/** * Test Mode Frontend Warning * * @description Displays a notice on the frontend for donation forms * @since 1.1 */ function give_test_mode_frontend_warning() { $test_mode = give_get_option('test_mode'); if ($test_mode == 'on') { echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . __('Notice', 'give') . '</strong>: ' . __('Test mode is enabled. While in test mode no live transactions are processed.', 'give') . '</p></div>'; } }
/** * Install * * Runs on plugin install by setting up the post types, custom taxonomies, flushing rewrite rules to initiate the new 'donations' slug and also creates the plugin and populates the settings fields for those plugin pages. After successful install, the user is redirected to the Give Welcome screen. * * @since 1.0 * @global $wpdb * @global $wp_version * @return void */ function give_install() { global $give_options; // Setup the Give Custom Post Types give_setup_post_types(); // Clear the permalinks flush_rewrite_rules(false); // Add Upgraded From Option $current_version = get_option('give_version'); if ($current_version) { update_option('give_version_upgraded_from', $current_version); } // Setup some default options $options = array(); // Checks if the Success Page option exists AND that the page exists if (!get_post(give_get_option('success_page'))) { // Purchase Confirmation (Success) Page $success = wp_insert_post(array('post_title' => __('Donation Confirmation', 'give'), 'post_content' => __('Thank you for your donation! [give_receipt]', 'give'), 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed')); // Store our page IDs $options['success_page'] = $success; } // Checks if the Failure Page option exists AND that the page exists if (!get_post(give_get_option('failure_page'))) { // Failed Purchase Page $failed = wp_insert_post(array('post_title' => __('Transaction Failed', 'give'), 'post_content' => __('Your transaction failed, please try again or contact site support.', 'give'), 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed')); $options['failure_page'] = $failed; } // Checks if the History Page option exists AND that the page exists if (!get_post(give_get_option('history_page'))) { // Purchase History (History) Page $history = wp_insert_post(array('post_title' => __('Donation History', 'give'), 'post_content' => '[donation_history]', 'post_status' => 'publish', 'post_author' => 1, 'post_type' => 'page', 'comment_status' => 'closed')); $options['history_page'] = $history; } //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency if (empty($current_version)) { $options['base_country'] = 'US'; $options['test_mode'] = 1; $options['currency'] = 'USD'; $options['session_lifetime'] = '604800'; $options['gateways']['manual'] = 1; $options['default_gateway'] = 'manual'; //default is manual //Offline Gateway Setup $options['gateways']['offline'] = 1; $options['global_offline_donation_content'] = give_get_default_offline_donation_content(); //Emails $options['donation_notification'] = give_get_default_donation_notification_email(); } // Populate some default values update_option('give_settings', array_merge($give_options, $options)); update_option('give_version', GIVE_VERSION); //Update Version Number if ($current_version) { update_option('give_version_upgraded_from', $current_version); } // Create Give roles $roles = new Give_Roles(); $roles->add_roles(); $roles->add_caps(); $api = new Give_API(); update_option('give_default_api_version', 'v' . $api->get_version()); // Create the customers database @Give()->customers->create_table(); // Check for PHP Session support, and enable if available Give()->session->use_php_sessions(); // Add a temporary option to note that Give pages have been created set_transient('_give_installed', $options, 30); // Bail if activating from network, or bulk if (is_network_admin() || isset($_GET['activate-multi'])) { return; } if (!$current_version) { require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; // When new upgrade routines are added, mark them as complete on fresh install $upgrade_routines = array('upgrade_give_payment_customer_id', 'upgrade_give_offline_status'); foreach ($upgrade_routines as $upgrade) { give_set_upgrade_complete($upgrade); } } // Add the transient to redirect set_transient('_give_activation_redirect', true, 30); }
/** * Process an API key generation/revocation * * @access public * @since 1.1 * * @param array $args * * @return void */ public function process_api_key($args) { if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { wp_die(__('Nonce verification failed', 'give'), __('Error', 'give'), array('response' => 403)); } if (is_numeric($args['user_id'])) { $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); } else { $userdata = get_user_by('login', $args['user_id']); $user_id = $userdata->ID; } $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; if ($user_id == get_current_user_id() && !give_get_option('allow_user_api_keys') && !current_user_can('manage_give_settings')) { wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403)); } elseif (!current_user_can('manage_give_settings')) { wp_die(sprintf(__('You do not have permission to %s API keys for this user', 'give'), $process), __('Error', 'give'), array('response' => 403)); } switch ($process) { case 'generate': if ($this->generate_api_key($user_id)) { delete_transient('give-total-api-keys'); wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); exit; } else { wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); exit; } break; case 'regenerate': $this->generate_api_key($user_id, true); delete_transient('give-total-api-keys'); wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); exit; break; case 'revoke': $this->revoke_api_key($user_id); delete_transient('give-total-api-keys'); wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); exit; break; default: break; } }
/** * Returns a ordered list of all available gateways. * * @since 1.4.5 * * @param array $gateways List of payment gateways * * @return array $gateways All the available gateways */ function give_get_ordered_payment_gateways($gateways) { // Get gateways setting. $gateways_setting = isset($_POST['gateways']) ? $_POST['gateways'] : give_get_option('gateways'); // Return from here if we do not have gateways setting. if (empty($gateways_setting)) { return $gateways; } // Reverse array to order payment gateways. $gateways_setting = array_reverse($gateways_setting); // Reorder gateways array foreach ($gateways_setting as $gateway_key => $value) { $new_gateway_value = isset($gateways[$gateway_key]) ? $gateways[$gateway_key] : ''; unset($gateways[$gateway_key]); if (!empty($new_gateway_value)) { $gateways = array_merge(array($gateway_key => $new_gateway_value), $gateways); } } /** * Filter payment gateways order. * * @since 1.4.5 * * @param array $gateways All the available gateways */ return apply_filters('give_payment_gateways_order', $gateways); }
/** * Process a step * * @since 1.5 * @return bool */ public function process_step() { if (!$this->can_export()) { wp_die(esc_html__('You do not have permission to export data.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); } $had_data = $this->get_data(); if ($had_data) { $this->done = false; return true; } else { update_option('give_earnings_total', 0); delete_transient('give_earnings_total'); delete_transient('give_estimated_monthly_stats' . true); delete_transient('give_estimated_monthly_stats' . false); $this->delete_data('give_temp_reset_ids'); // Reset the sequential order numbers if (give_get_option('enable_sequential')) { delete_option('give_last_payment_number'); } $this->done = true; $this->message = esc_html__('Donation forms, income, donations counts, and logs successfully reset.', 'give'); return false; } }
/** * Give Sidebars * * @description This option adds Give sidebars; registered late so it display last in list * */ function give_widgets_init() { //Single Give Forms (disabled if single turned off in settings) if (give_get_option('disable_forms_singular') !== 'on' && give_get_option('disable_form_sidebar') !== 'on') { register_sidebar(apply_filters('give_forms_single_sidebar', array('name' => __('Give Single Form Sidebar', 'give'), 'id' => 'give-forms-sidebar', 'description' => __('Widgets in this area will be shown on the single Give forms aside area. This sidebar will not display for embedded forms.', 'give'), 'before_widget' => '<div id="%1$s" class="widget %2$s">', 'after_widget' => '</div>', 'before_title' => '<h3 class="widgettitle widget-title">', 'after_title' => '</h3>'))); } }
/** * Get the enabled email template * * @since 1.0 */ public function get_template() { if (!$this->template) { $this->template = give_get_option('email_template', 'default'); } return apply_filters('give_email_template', $this->template); }
/** * 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; }
/** * Receipt Shortcode * * Shows an order 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; //set $session var $session = give_get_purchase_session(); //set payment key var if (isset($_GET['payment_key'])) { $payment_key = urldecode($_GET['payment_key']); } elseif ($give_receipt_args['payment_key']) { $payment_key = $give_receipt_args['payment_key']; } else { if ($session) { $payment_key = $session['purchase_key']; } } ob_start(); //Check for payment key if (empty($payment_key)) { ?> <div class="give_errors"> <p class="give_error"><?php echo apply_filters('give_receipt_no_payment_key', __('Sorry, there was a problem identifying this donation. Please contact the site owner for more information.', 'give')); ?> </p> </div> <?php return ob_get_clean(); //return error } //Set our important payment information variables $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); $donor_id = give_get_payment_user_id($give_receipt_args['id']); $payment = get_post($give_receipt_args['id']); $give_receipt_args = shortcode_atts(array('error' => __('Sorry, it appears the viewing window for this donation receipt has expired or you do not have the permission to view this donation receipt.', 'give'), 'price' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'give_receipt'); //Is registration open? If so, add better error messaging to tell user their session expired if (get_option('users_can_register')) { $email = get_post_meta($payment->ID, '_give_payment_user_email', true); $donation_history = get_permalink(give_get_option('history_page')); $give_receipt_args['error'] .= sprintf(__(' To view your receipt, please <a href="%s">create an account</a> using the following email %s (the email attached to this donation) and visit the <a href="%s">donation history page</a>'), wp_registration_url(), '<strong>' . $email . '</strong>', $donation_history); } /* * 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 donation was made as a guest, the donation session is checked for * * Or if user is logged in and the user can view sensitive donor data */ $user_can_view = is_user_logged_in() && $donor_id == get_current_user_id() || ($donor_id == 0 || $donor_id == '-1') && !is_user_logged_in() && give_get_purchase_session() || current_user_can('view_give_sensitive_data'); if (!apply_filters('give_user_can_view_receipt', $user_can_view, $give_receipt_args)) { ?> <div class="give_errors"> <p class="give_error"><?php echo $give_receipt_args['error']; ?> </p> </div> <?php return ob_get_clean(); // ?> <?php } give_get_template_part('shortcode', 'receipt'); $display = ob_get_clean(); return $display; }
/** * Output the product image before the single product summary. */ function give_show_form_images() { $featured_image_option = give_get_option('disable_form_featured_img'); if ($featured_image_option !== 'on') { give_get_template_part('single-give-form/featured-image'); } }
/** * Search * * @since 1.0 * @access public * * @return void */ public function search() { if (!isset($this->args['s'])) { return; } $search = trim($this->args['s']); if (empty($search)) { return; } $is_email = is_email($search) || strpos($search, '@') !== false; $is_user = strpos($search, strtolower('user:'******'search_in_notes'])) { $notes = give_get_payment_notes(0, $search); if (!empty($notes)) { $payment_ids = wp_list_pluck((array) $notes, 'comment_post_ID'); $this->__set('post__in', $payment_ids); } $this->__unset('s'); } elseif ($is_email || strlen($search) == 32) { $key = $is_email ? '_give_payment_user_email' : '_give_payment_purchase_key'; $search_meta = array('key' => $key, 'value' => $search, 'compare' => 'LIKE'); $this->__set('meta_query', $search_meta); $this->__unset('s'); } elseif ($is_user) { $search_meta = array('key' => '_give_payment_user_id', 'value' => trim(str_replace('user:'******'', strtolower($search)))); $this->__set('meta_query', $search_meta); if (give_get_option('enable_sequential')) { $search_meta = array('key' => '_give_payment_number', 'value' => $search, 'compare' => 'LIKE'); $this->__set('meta_query', $search_meta); $this->args['meta_query']['relation'] = 'OR'; } $this->__unset('s'); } elseif (give_get_option('enable_sequential') && (false !== strpos($search, give_get_option('sequential_prefix')) || false !== strpos($search, give_get_option('sequential_postfix')))) { $search_meta = array('key' => '_give_payment_number', 'value' => $search, 'compare' => 'LIKE'); $this->__set('meta_query', $search_meta); $this->__unset('s'); } elseif (is_numeric($search)) { $post = get_post($search); if (is_object($post) && $post->post_type == 'give_payment') { $arr = array(); $arr[] = $search; $this->__set('post__in', $arr); $this->__unset('s'); } } elseif ('#' == substr($search, 0, 1)) { $search = str_replace('#:', '', $search); $search = str_replace('#', '', $search); $this->__set('give_forms', $search); $this->__unset('s'); } else { $this->__set('s', $search); } }
/** * Sends the Admin Sale Notification Email * * @since 1.0 * * @param int $payment_id Payment ID (default: 0) * @param array $payment_data Payment Meta and Data * * @return void */ function give_admin_email_notice($payment_id = 0, $payment_data = array()) { $payment_id = absint($payment_id); if (empty($payment_id)) { return; } if (!give_get_payment_by('id', $payment_id)) { return; } $from_name = give_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('give_purchase_from_name', $from_name, $payment_id, $payment_data); $from_email = give_get_option('from_email', get_bloginfo('admin_email')); $from_email = apply_filters('give_purchase_from_address', $from_email, $payment_id, $payment_data); $subject = give_get_option('donation_notification_subject', sprintf(__('New Donation - Payment #%1$s', 'give'), $payment_id)); $subject = apply_filters('give_admin_donation_notification_subject', wp_strip_all_tags($subject), $payment_id); $subject = give_do_email_tags($subject, $payment_id); $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; $headers .= "Reply-To: " . $from_email . "\r\n"; //$headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; $headers = apply_filters('give_admin_donation_notification_headers', $headers, $payment_id, $payment_data); $attachments = apply_filters('give_admin_donation_notification_attachments', array(), $payment_id, $payment_data); $message = give_get_donation_notification_body_content($payment_id, $payment_data); $emails = Give()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('headers', $headers); $emails->__set('heading', __('New Donation!', 'give')); $emails->send(give_get_admin_notice_emails(), $subject, $message, $attachments); }
/** * Set the Page Style for PayPal Purchase page * * @since 1.0 * @return string */ function give_get_paypal_page_style() { $page_style = trim(give_get_option('paypal_page_style', 'PayPal')); return apply_filters('give_paypal_page_style', $page_style); }
/** * Email template tag: receipt_link. * * Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly. * * @param int $payment_id * * @return string receipt_link */ function give_email_tag_receipt_link($payment_id) { $receipt_url = esc_url(add_query_arg(array('payment_key' => give_get_payment_key($payment_id), 'give_action' => 'view_receipt'), home_url())); $formatted = sprintf('<a href="%1$s">%2$s</a>', $receipt_url, esc_html__('View it in your browser', 'give')); if (give_get_option('email_template') !== 'none') { return $formatted; } else { return $receipt_url; } }
/** * 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; }
foreach (array_unique(array_filter($give_taxonomies)) as $taxonomy) { $terms = $wpdb->get_results($wpdb->prepare("SELECT t.*, tt.* FROM {$wpdb->terms} AS t INNER JOIN {$wpdb->term_taxonomy} AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('%s') ORDER BY t.name ASC", $taxonomy)); // Delete Terms if ($terms) { foreach ($terms as $term) { $wpdb->delete($wpdb->term_taxonomy, array('term_taxonomy_id' => $term->term_taxonomy_id)); $wpdb->delete($wpdb->terms, array('term_id' => $term->term_id)); } } // 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
<?php /** * Session Refresh Form * * @description: This template is used to display an email form which will when submitted send an update donation receipt and also refresh the users session */ $show_form = true; $email = isset($_POST['give_email']) ? $_POST['give_email'] : ''; //reCAPTCHA $recaptcha_key = give_get_option('recaptcha_key'); $recaptcha_secret = give_get_option('recaptcha_secret'); $enable_recaptcha = !empty($recaptcha_key) && !empty($recaptcha_secret) ? true : false; // Form submission if (is_email($email) && wp_verify_nonce($_POST['_wpnonce'], 'give')) { // Use reCAPTCHA if ($enable_recaptcha) { $args = array('secret' => $recaptcha_secret, 'response' => $_POST['g-recaptcha-response'], 'remoteip' => $_POST['give_ip']); if (!empty($args['response'])) { $request = wp_remote_post('https://www.google.com/recaptcha/api/siteverify', array('body' => $args)); if (!is_wp_error($request) || 200 == wp_remote_retrieve_response_code($request)) { $response = json_decode($request['body'], true); // reCAPTCHA fail if (!$response['success']) { 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 {