/** * Renders an HTML Dropdown of all the Give Forms * * @access public * @since 1.0 * * @param array $args Arguments for the dropdown * * @return string $output Give forms dropdown */ public function forms_dropdown($args = array()) { $defaults = array('name' => 'forms', 'id' => 'forms', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'number' => 30, 'placeholder' => sprintf(__('Select a %s', 'give'), give_get_forms_label_singular())); $args = wp_parse_args($args, $defaults); $forms = get_posts(array('post_type' => 'give_forms', 'orderby' => 'title', 'order' => 'ASC', 'posts_per_page' => $args['number'])); $options = array(); if ($forms) { $options[0] = sprintf(__('Select a %s', 'give'), give_get_forms_label_singular()); foreach ($forms as $form) { $options[absint($form->ID)] = esc_html($form->post_title); } } else { $options[0] = __('No Give Forms Found', 'give'); } // This ensures that any selected forms are included in the drop down if (is_array($args['selected'])) { foreach ($args['selected'] as $item) { if (!in_array($item, $options)) { $options[$item] = get_the_title($item); } } } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { if (!in_array($args['selected'], $options)) { $options[$args['selected']] = get_the_title($args['selected']); } } $output = $this->select(array('name' => $args['name'], 'selected' => $args['selected'], 'id' => $args['id'], 'class' => $args['class'], 'options' => $options, 'chosen' => $args['chosen'], 'multiple' => $args['multiple'], 'placeholder' => $args['placeholder'], 'show_option_all' => false, 'show_option_none' => false)); return $output; }
/** * Updated Messages * * Returns an array of with all updated messages. * * @since 1.0 * * @param array $messages Post updated message * * @return array $messages New post updated messages */ function give_updated_messages($messages) { global $post, $post_ID; $url1 = '<a href="' . get_permalink($post_ID) . '">'; $url2 = give_get_forms_label_singular(); $url3 = '</a>'; $messages['give_forms'] = array(1 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), 4 => sprintf(__('%2$s updated. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), 6 => sprintf(__('%2$s published. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), 7 => sprintf(__('%2$s saved. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3), 8 => sprintf(__('%2$s submitted. %1$sView %2$s%3$s.', 'give'), $url1, $url2, $url3)); return $messages; }
/** * Load Admin Scripts * * Enqueues the required admin scripts. * * @since 1.0 * @global $post * * @param string $hook Page hook * * @return void */ function give_load_admin_scripts($hook) { global $wp_version, $post, $post_type; //Directories of assets $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; //Global Admin: wp_register_style('give-admin-bar-notification', $css_dir . 'adminbar-style.css'); wp_enqueue_style('give-admin-bar-notification'); //Give Admin Only: if (!apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { return; } //CSS wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css'); wp_enqueue_style('jquery-ui-css'); wp_register_style('give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION); wp_enqueue_style('give-admin'); wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION); wp_enqueue_style('jquery-chosen'); wp_enqueue_style('thickbox'); //JS wp_register_script('jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array('jquery'), GIVE_VERSION); wp_enqueue_script('jquery-chosen'); wp_register_script('give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-admin-scripts'); wp_register_script('jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js'); wp_enqueue_script('jquery-flot'); wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-qtip'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('thickbox'); //Forms CPT Script if ($post_type === 'give_forms') { wp_register_script('give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-admin-forms-scripts'); } //Localize strings & variables for JS wp_localize_script('give-admin-scripts', 'give_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'give_version' => GIVE_VERSION, 'quick_edit_warning' => __('Sorry, not available for variable priced forms.', 'give'), 'delete_payment' => __('Are you sure you wish to delete this payment?', 'give'), 'delete_payment_note' => __('Are you sure you wish to delete this note?', 'give'), 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'give'), 'revoke_api_key' => __('Are you sure you wish to revoke this API key?', 'give'), 'regenerate_api_key' => __('Are you sure you wish to regenerate this API key?', 'give'), 'resend_receipt' => __('Are you sure you wish to resend the donation receipt?', 'give'), 'copy_download_link_text' => __('Copy these links to your clipboard and give them to your donor', 'give'), 'delete_payment_download' => sprintf(__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), 'one_price_min' => __('You must have at least one price', 'give'), 'one_file_min' => __('You must have at least one file', 'give'), 'one_field_min' => __('You must have at least one field', 'give'), 'one_option' => sprintf(__('Choose a %s', 'give'), give_get_forms_label_singular()), 'one_or_more_option' => sprintf(__('Choose one or more %s', 'give'), give_get_forms_label_plural()), 'numeric_item_price' => __('Item price must be numeric', 'give'), 'numeric_quantity' => __('Quantity must be numeric', 'give'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'currency_decimals' => give_currency_decimal_filter(), 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), 'remove_text' => __('Remove', 'give'), 'type_to_search' => sprintf(__('Type to search %s', 'give'), give_get_forms_label_plural()))); if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { //call for new media manager wp_enqueue_media(); } }
/** * Retrieve the table columns * * @access public * @since 1.0 * @return array $columns Array of all the list table columns */ public function get_columns() { $columns = array('title' => give_get_forms_label_singular(), 'sales' => __('Donations', 'give'), 'earnings' => __('Income', 'give'), 'average_sales' => __('Monthly Average Donations', 'give'), 'average_earnings' => __('Monthly Average Income', 'give'), 'details' => __('Detailed Report', 'give')); return $columns; }
/** * Get things started * * @since 1.0 * @uses Give_Payment_History_Table::get_payment_counts() * @see WP_List_Table::__construct() */ public function __construct() { global $status, $page; // Set parent defaults parent::__construct(array('singular' => give_get_forms_label_singular(), 'plural' => give_get_forms_label_plural(), 'ajax' => false)); $this->get_payment_counts(); $this->process_bulk_action(); $this->base_url = admin_url('edit.php?post_type=give_forms&page=give-payment-history'); }
/** * Retrieve the table columns * * @access public * @since 1.0 * @return array $columns Array of all the list table columns */ public function get_columns() { $columns = array('ID' => esc_html__('Log ID', 'give'), 'user_id' => esc_html__('Donor', 'give'), 'form' => give_get_forms_label_singular(), 'amount' => esc_html__('Donation Amount', 'give'), 'status' => esc_html__('Status', 'give'), 'payment_id' => esc_html__('Transaction ID', 'give'), 'date' => esc_html__('Date', 'give')); return $columns; }
/** * Widget constructor * * @since 1.0 * @access public * * @return void */ public function __construct() { $give_label_singular = function_exists('give_get_forms_label_singular') ? strtolower(give_get_forms_label_singular()) : null; // widget settings $widget_ops = array('classname' => 'give-donators-gravatars', 'description' => sprintf(esc_html__('Displays gravatars of people who have donated using your your %1$s. Will only show on the single %2$s page.', 'give'), $give_label_singular, $give_label_singular)); // widget control settings $control_ops = array('width' => 250, 'height' => 350, 'id_base' => 'give_gravatars_widget'); // create the widget parent::__construct('give_donators_gravatars_widget', esc_html__('Give Donators Gravatars', 'give'), $widget_ops, $control_ops); }
/** * Load Admin Scripts * * Enqueues the required admin scripts. * * @since 1.0 * * @global $post * @global $give_options * * @param string $hook Page hook * * @return void */ function give_load_admin_scripts($hook) { global $wp_version, $post, $post_type, $give_options; //Directories of assets $js_dir = GIVE_PLUGIN_URL . 'assets/js/admin/'; $js_plugins = GIVE_PLUGIN_URL . 'assets/js/plugins/'; $css_dir = GIVE_PLUGIN_URL . 'assets/css/'; // Use minified libraries if SCRIPT_DEBUG is turned off $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; //Global Admin: wp_register_style('give-admin-bar-notification', $css_dir . 'adminbar-style.css'); wp_enqueue_style('give-admin-bar-notification'); //Give Admin Only: if (!apply_filters('give_load_admin_scripts', give_is_admin_page(), $hook)) { return; } //CSS wp_register_style('jquery-ui-css', $css_dir . 'jquery-ui-fresh' . $suffix . '.css'); wp_enqueue_style('jquery-ui-css'); wp_register_style('give-admin', $css_dir . 'give-admin' . $suffix . '.css', GIVE_VERSION); wp_enqueue_style('give-admin'); wp_register_style('jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', array(), GIVE_VERSION); wp_enqueue_style('jquery-chosen'); wp_enqueue_style('thickbox'); //JS wp_register_script('jquery-chosen', $js_plugins . 'chosen.jquery' . $suffix . '.js', array('jquery'), GIVE_VERSION); wp_enqueue_script('jquery-chosen'); wp_register_script('give-accounting', $js_plugins . 'accounting' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-accounting'); wp_register_script('give-admin-scripts', $js_dir . 'admin-scripts' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-admin-scripts'); wp_register_script('jquery-flot', $js_plugins . 'jquery.flot' . $suffix . '.js'); wp_enqueue_script('jquery-flot'); wp_register_script('give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-qtip'); wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_script('thickbox'); // Forms CPT Script. if ($post_type === 'give_forms') { wp_register_script('give-admin-forms-scripts', $js_dir . 'admin-forms' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-admin-forms-scripts'); } //Settings Scripts if (isset($_GET['page']) && $_GET['page'] == 'give-settings') { wp_register_script('give-admin-settings-scripts', $js_dir . 'admin-settings' . $suffix . '.js', array('jquery'), GIVE_VERSION, false); wp_enqueue_script('give-admin-settings-scripts'); } // Price Separators. $thousand_separator = give_get_price_thousand_separator(); $decimal_separator = give_get_price_decimal_separator(); //Localize strings & variables for JS wp_localize_script('give-admin-scripts', 'give_vars', array('post_id' => isset($post->ID) ? $post->ID : null, 'give_version' => GIVE_VERSION, 'thousands_separator' => $thousand_separator, 'decimal_separator' => $decimal_separator, 'quick_edit_warning' => esc_html__('Sorry, not available for variable priced forms.', 'give'), 'delete_payment' => esc_html__('Are you sure you wish to delete this payment?', 'give'), 'delete_payment_note' => esc_html__('Are you sure you wish to delete this note?', 'give'), 'revoke_api_key' => esc_html__('Are you sure you wish to revoke this API key?', 'give'), 'regenerate_api_key' => esc_html__('Are you sure you wish to regenerate this API key?', 'give'), 'resend_receipt' => esc_html__('Are you sure you wish to resend the donation receipt?', 'give'), 'copy_download_link_text' => esc_html__('Copy these links to your clipboard and give them to your donor.', 'give'), 'delete_payment_download' => sprintf(esc_html__('Are you sure you wish to delete this %s?', 'give'), give_get_forms_label_singular()), 'one_price_min' => esc_html__('You must have at least one price.', 'give'), 'one_file_min' => esc_html__('You must have at least one file.', 'give'), 'one_field_min' => esc_html__('You must have at least one field.', 'give'), 'one_option' => sprintf(esc_html__('Choose a %s', 'give'), give_get_forms_label_singular()), 'one_or_more_option' => sprintf(esc_html__('Choose one or more %s', 'give'), give_get_forms_label_plural()), 'numeric_item_price' => esc_html__('Item price must be numeric.', 'give'), 'numeric_quantity' => esc_html__('Quantity must be numeric.', 'give'), 'currency_sign' => give_currency_filter(''), 'currency_pos' => isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before', 'currency_decimals' => give_currency_decimal_filter(give_get_price_decimals()), 'new_media_ui' => apply_filters('give_use_35_media_ui', 1), 'remove_text' => esc_html__('Remove', 'give'), 'type_to_search' => sprintf(esc_html__('Type to search %s', 'give'), give_get_forms_label_plural()), 'batch_export_no_class' => esc_html__('You must choose a method.', 'give'), 'batch_export_no_reqs' => esc_html__('Required fields not completed.', 'give'), 'reset_stats_warn' => __('Are you sure you want to reset Give? This process is <strong><em>not reversible</em></strong> and will delete all data regardless of test or live mode. Please be sure you have a recent backup before proceeding.', 'give'), 'price_format_guide' => sprintf(esc_html__('Please enter amount in monetary decimal ( %1$s ) format without thousand separator ( %2$s ) .', 'give'), $decimal_separator, $thousand_separator))); if (function_exists('wp_enqueue_media') && version_compare($wp_version, '3.5', '>=')) { //call for new media manager wp_enqueue_media(); } }
/** * Output the settings update form. * * @param array $instance Current settings. * * @return string */ public function form($instance) { $defaults = array('title' => '', 'id' => '', 'float_labels' => ''); $instance = wp_parse_args((array) $instance, $defaults); extract($instance); // Query Give Forms $args = array('post_type' => 'give_forms', 'posts_per_page' => -1, 'post_status' => 'publish'); $give_forms = get_posts($args); // Widget: Title ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title:', 'give'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo esc_attr($title); ?> " /><br> <small><?php _e('Leave blank to hide the widget title.', 'give'); ?> </small> </p><?php // Widget: Give Form ?> <p> <label for="<?php echo esc_attr($this->get_field_id('id')); ?> "><?php printf(__('Give %s:', 'give'), give_get_forms_label_singular()); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?> " id="<?php echo esc_attr($this->get_field_id('id')); ?> "> <option value="current"><?php _e('— Select —', 'give'); ?> </option> <?php foreach ($give_forms as $give_form) { ?> <option <?php selected(absint($id), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?> "><?php echo $give_form->post_title; ?> </option> <?php } ?> </select><br> <small><?php _e('Select a Give Form to embed in this widget.', 'give'); ?> </small> </p><?php // Widget: Floating Labels ?> <p> <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?> "><?php _e('Floating Labels (optional):', 'give'); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('float_labels')); ?> " id="<?php echo esc_attr($this->get_field_id('float_labels')); ?> "> <option value="" <?php selected(esc_attr($float_labels), ''); ?> >– <?php _e('Select', 'give'); ?> –</option> <option value="enabled" <?php selected(esc_attr($float_labels), 'enabled'); ?> ><?php _e('Enabled', 'give'); ?> </option> <option value="disabled" <?php selected(esc_attr($float_labels), 'disabled'); ?> ><?php _e('Disabled', 'give'); ?> </option> </select><br> <small><?php printf(__('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), esc_url("http://bradfrost.com/blog/post/float-label-pattern/")); ?> </small> </p><?php }
/** * Adds price field to Quick Edit options * * @since 1.0 * * @param string $column_name Name of the column * @param string $post_type Current Post Type (i.e. forms) * * @return void */ function give_price_field_quick_edit($column_name, $post_type) { if ($column_name != 'price' || $post_type != 'give_forms') { return; } ?> <fieldset class="inline-edit-col-left"> <div id="give-give-data" class="inline-edit-col"> <h4><?php echo sprintf(__('%s Configuration', 'give'), give_get_forms_label_singular()); ?> </h4> <label> <span class="title"><?php _e('Price', 'give'); ?> </span> <span class="input-text-wrap"> <input type="text" name="_give_regprice" class="text regprice" /> </span> </label> <br class="clear" /> </div> </fieldset> <?php }
/** * Retrieve the table columns * * @access public * @since 1.0 * @return array $columns Array of all the list table columns */ public function get_columns() { $columns = array('ID' => __('Log ID', 'give'), 'user_id' => __('User', 'give'), 'form' => give_get_forms_label_singular(), 'amount' => __('Item Amount', 'give'), 'payment_id' => __('Payment ID', 'give'), 'date' => __('Date', 'give')); return $columns; }
/** * Back-end widget form. * * @param array $instance * * @return null * @see WP_Widget::form() */ public function form($instance) { $instance = wp_parse_args((array) $instance, $this->widget_defaults); ?> <!-- Title --> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Widget Title', 'gpr'); ?> </label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " type="text" value="<?php echo $instance['title']; ?> " /> </p> <?php //Query Give Forms $args = array('post_type' => 'give_forms', 'posts_per_page' => -1, 'post_status' => 'publish'); $give_forms = get_posts($args); ?> <p> <label for="<?php echo esc_attr($this->get_field_id('id')); ?> "><?php printf(__('Give %s', 'give'), give_get_forms_label_singular()); ?> <span class="dashicons dashicons-editor-help give-tooltip" style="opacity:0.6" data-tooltip="<?php _e('Select a Give Form that you would like to embed in this widget area.', 'give'); ?> "></span> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?> " id="<?php echo esc_attr($this->get_field_id('id')); ?> "> <option value="current"><?php _e('Please select...', 'give'); ?> </option> <?php foreach ($give_forms as $give_form) { ?> <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?> "><?php echo $give_form->post_title; ?> </option> <?php } ?> </select> </p> <!-- Give Form Field --> <?php }
/** * Admin Footer For Thickbox * * Prints the footer code needed for the Insert Download * TinyMCE button. * * @since 1.0 * @global $pagenow * @global $typenow * @return void */ function give_admin_footer_for_thickbox() { global $pagenow, $typenow; // Only run in post/page creation and edit screens if (in_array($pagenow, array('post.php', 'page.php', 'post-new.php', 'post-edit.php')) && $typenow != 'give_forms' && $typenow != 'give_campaigns') { ?> <script type="text/javascript"> function insertGiveForm() { var id = jQuery( '.give-select#forms' ).val(); // Return early if no form is selected if ( id === '' ) { alert( '<?php _e("You must choose a form", "give"); ?> ' ); return; } // Send the shortcode to the editor window.send_to_editor( '[give_form id="' + id + '"]' ); } jQuery( document ).ready( function ( $ ) { $( '#select-give-style' ).change( function () { if ( $( this ).val() === 'button' ) { $( '#give-color-choice' ).slideDown(); } else { $( '#give-color-choice' ).slideUp(); } } ); } ); </script> <div id="choose-give-form" style="display: none;"> <div class="wrap" style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"> <div> <p><?php echo sprintf(__('Use the form below to insert the shortcode for a %s', 'give'), give_get_forms_label_singular()); ?> </p> <?php echo Give()->html->forms_dropdown(array('chosen' => true)); ?> </div> <p class="submit"> <input type="button" id="give-insert-download" class="button-primary" value="<?php echo sprintf(__('Insert %s', 'give'), give_get_forms_label_singular()); ?> " onclick="insertGiveForm();" /> <a id="give-cancel-download-insert" class="button-secondary" onclick="tb_remove();" title="<?php _e('Cancel', 'give'); ?> "><?php _e('Cancel', 'give'); ?> </a> </p> </div> </div> <?php } }
/** * Output the settings update form. * * @param array $instance Current settings. * * @return string */ public function form($instance) { $defaults = array('title' => '', 'id' => '', 'float_labels' => 'global', 'display_style' => 'modal'); $instance = wp_parse_args((array) $instance, $defaults); // Backward compatibility: Set float labels as default if, it was set as empty previous. $instance['float_labels'] = empty($instance['float_labels']) ? 'global' : $instance['float_labels']; // Query Give Forms $args = array('post_type' => 'give_forms', 'posts_per_page' => -1, 'post_status' => 'publish'); $give_forms = get_posts($args); // Widget: Title ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php esc_html_e('Title:', 'give'); ?> </label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php esc_attr_e($instance['title']); ?> " /><br> <small class="give-field-description"><?php esc_html_e('Leave blank to hide the widget title.', 'give'); ?> </small> </p><?php // Widget: Give Form ?> <p> <label for="<?php echo esc_attr($this->get_field_id('id')); ?> "><?php printf(esc_html__('Give %s:', 'give'), give_get_forms_label_singular()); ?> </label> <select class="widefat" name="<?php echo esc_attr($this->get_field_name('id')); ?> " id="<?php echo esc_attr($this->get_field_id('id')); ?> "> <option value="current"><?php esc_html_e('— Select —', 'give'); ?> </option> <?php foreach ($give_forms as $give_form) { ?> <option <?php selected(absint($instance['id']), $give_form->ID); ?> value="<?php echo esc_attr($give_form->ID); ?> "><?php echo $give_form->post_title; ?> </option> <?php } ?> </select><br> <small class="give-field-description"><?php esc_html_e('Select a Give Form to embed in this widget.', 'give'); ?> </small> </p> <?php // Widget: Display Style ?> <p> <label for="<?php echo esc_attr($this->get_field_id('display_style')); ?> "><?php esc_html_e('Display style:', 'give'); ?> </label><br> <label for="<?php echo $this->get_field_id('display_style'); ?> -onpage"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?> -onpage" name="<?php echo $this->get_field_name('display_style'); ?> " value="onpage" <?php checked($instance['display_style'], 'onpage'); ?> > <?php echo esc_html__('All Fields', 'give'); ?> </label> <label for="<?php echo $this->get_field_id('display_style'); ?> -reveal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?> -reveal" name="<?php echo $this->get_field_name('display_style'); ?> " value="reveal" <?php checked($instance['display_style'], 'reveal'); ?> > <?php echo esc_html__('Reveal', 'give'); ?> </label> <label for="<?php echo $this->get_field_id('display_style'); ?> -modal"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('display_style'); ?> -modal" name="<?php echo $this->get_field_name('display_style'); ?> " value="modal" <?php checked($instance['display_style'], 'modal'); ?> > <?php echo esc_html__('Modal', 'give'); ?> </label><br> <small class="give-field-description"> <?php echo esc_html__('Select a Give Form style.', 'give'); ?> </small> </p> <?php // Widget: Floating Labels ?> <p> <label for="<?php echo esc_attr($this->get_field_id('float_labels')); ?> "><?php esc_html_e('Floating Labels (optional):', 'give'); ?> </label><br> <label for="<?php echo $this->get_field_id('float_labels'); ?> -global"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?> -global" name="<?php echo $this->get_field_name('float_labels'); ?> " value="global" <?php checked($instance['float_labels'], 'global'); ?> > <?php echo esc_html__('Global Options', 'give'); ?> </label> <label for="<?php echo $this->get_field_id('float_labels'); ?> -enabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?> -enabled" name="<?php echo $this->get_field_name('float_labels'); ?> " value="enabled" <?php checked($instance['float_labels'], 'enabled'); ?> > <?php echo esc_html__('Yes', 'give'); ?> </label> <label for="<?php echo $this->get_field_id('float_labels'); ?> -disabled"><input type="radio" class="widefat" id="<?php echo $this->get_field_id('float_labels'); ?> -disabled" name="<?php echo $this->get_field_name('float_labels'); ?> " value="disabled" <?php checked($instance['float_labels'], 'disabled'); ?> > <?php echo esc_html__('No', 'give'); ?> </label><br> <small class="give-field-description"> <?php printf(__('Override the <a href="%s" target="_blank">floating labels</a> setting for this Give form.', 'give'), esc_url('https://givewp.com/documentation/core/give-forms/creating-give-forms/#floating-labels')); ?> </small> </p><?php }
/** * Get things started. * * @since 1.0 * @see WP_List_Table::__construct() */ public function __construct() { // Set parent defaults. parent::__construct(array('singular' => give_get_forms_label_singular(), 'plural' => give_get_forms_label_plural(), 'ajax' => false)); }
/** * Add download count to At a glance widget * * @since 1.0 * @return void */ function give_dashboard_at_a_glance_widget($items) { $num_posts = wp_count_posts('give_forms'); if ($num_posts && $num_posts->publish) { $text = _n('%s Give ' . give_get_forms_label_singular(), '%s Give ' . give_get_forms_label_plural(), $num_posts->publish); $text = sprintf($text, number_format_i18n($num_posts->publish)); if (current_user_can('edit_give_forms', get_the_ID())) { $text = sprintf('<a class="give-forms-count" href="edit.php?post_type=give_forms">%1$s</a>', $text); } else { $text = sprintf('<span class="give-forms-count">%1$s</span>', $text); } $items[] = $text; } return $items; }
/** * View a customer * * @since 1.0 * * @param $customer The Customer object being displayed * * @return void */ function give_customers_view($customer) { $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments'); ?> <?php do_action('give_donor_card_top', $customer); ?> <div id="donor-summary" class="info-wrapper customer-section postbox"> <form id="edit-customer-info" method="post" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer->id); ?> "> <div class="customer-info"> <div class="donor-bio-header clearfix"> <div class="avatar-wrap left" id="customer-avatar"> <?php echo get_avatar($customer->email); ?> </div> <div class="customer-id" class="left"> #<?php echo $customer->id; ?> </div> <div id="customer-name-wrap" class="left"> <span class="customer-name info-item edit-item"><input size="15" data-key="name" name="customerinfo[name]" type="text" value="<?php echo esc_attr($customer->name); ?> " placeholder="<?php _e('Donor Name', 'give'); ?> " /></span> <span class="customer-name info-item editable"><span data-key="name"><?php echo $customer->name; ?> </span></span> </div> <p class="customer-since info-item"> <?php _e('Donor since', 'give'); ?> <?php echo date_i18n(get_option('date_format'), strtotime($customer->date_created)); ?> </p> <?php if (current_user_can($customer_edit_role)) { ?> <a title="<?php _e('Edit Donor', 'give'); ?> " href="#" id="edit-customer" class="button info-item editable customer-edit-link"><?php _e('Edit Donor', 'give'); ?> </a> <?php } ?> </div> <!-- /donor-bio-header --> <div class="customer-main-wrapper"> <table class="widefat"> <tbody> <tr> <td><label for="tablecell"><?php esc_attr_e('Email', 'give'); ?> </label></td> <td class="row-title"> <span class="customer-name info-item edit-item"><input size="20" data-key="email" name="customerinfo[email]" type="text" value="<?php echo $customer->email; ?> " placeholder="<?php _e('Donor Email', 'give'); ?> " /></span> <span class="customer-email info-item editable" data-key="email"><?php echo $customer->email; ?> </span> </td> </tr> <tr class="alternate"> <td><label for="tablecell"><?php esc_attr_e('User ID', 'give'); ?> </label></td> <td class="row-title"> <span class="customer-user-id info-item edit-item"> <?php $user_id = $customer->user_id > 0 ? $customer->user_id : ''; $data_atts = array('key' => 'user_login', 'exclude' => $user_id); $user_args = array('name' => 'customerinfo[user_login]', 'class' => 'give-user-dropdown', 'data' => $data_atts); if (!empty($user_id)) { $userdata = get_userdata($user_id); $user_args['value'] = $userdata->user_login; } echo Give()->html->ajax_user_search($user_args); ?> <input type="hidden" name="customerinfo[user_id]" data-key="user_id" value="<?php echo $customer->user_id; ?> " /> </span> <span class="customer-user-id info-item editable"> <?php if (intval($customer->user_id) > 0) { ?> <span data-key="user_id"><?php echo $customer->user_id; ?> </span> <?php } else { ?> <span data-key="user_id"><?php _e('none', 'give'); ?> </span> <?php } ?> <?php if (current_user_can($customer_edit_role) && intval($customer->user_id) > 0) { ?> <span class="disconnect-user"> - <a id="disconnect-customer" href="#disconnect" title="<?php _e('Disconnects the current user ID from this customer record', 'give'); ?> "><?php _e('Disconnect User', 'give'); ?> </a></span> <?php } ?> </span> </td> </tr> <tr> <td><?php esc_attr_e('Address', 'give'); ?> </td> <td class="row-title"> <div class="customer-address-wrapper"> <?php if (isset($customer->user_id) && $customer->user_id > 0) { ?> <?php $address = get_user_meta($customer->user_id, '_give_user_address', true); $defaults = array('line1' => '', 'line2' => '', 'city' => '', 'state' => '', 'country' => '', 'zip' => ''); $address = wp_parse_args($address, $defaults); ?> <?php if (!empty($address)) { ?> <span class="customer-address info-item editable"> <span class="info-item" data-key="line1"><?php echo $address['line1']; ?> </span><br> <span class="info-item" data-key="line2"><?php echo $address['line2']; ?> </span><br> <span class="info-item" data-key="city">City: <?php echo $address['city']; ?> </span><br> <span class="info-item" data-key="state">State: <?php echo $address['state']; ?> </span><br> <span class="info-item" data-key="country">Country: <?php echo $address['country']; ?> </span><br> <span class="info-item" data-key="zip">Zip: <?php echo $address['zip']; ?> </span><br> </span> <?php } ?> <span class="customer-address info-item edit-item"> <input class="info-item" type="text" data-key="line1" name="customerinfo[line1]" placeholder="<?php _e('Address 1', 'give'); ?> " value="<?php echo $address['line1']; ?> " /> <input class="info-item" type="text" data-key="line2" name="customerinfo[line2]" placeholder="<?php _e('Address 2', 'give'); ?> " value="<?php echo $address['line2']; ?> " /> <input class="info-item" type="text" data-key="city" name="customerinfo[city]" placeholder="<?php _e('City', 'give'); ?> " value="<?php echo $address['city']; ?> " /> <select data-key="country" name="customerinfo[country]" id="billing_country" class="billing_country give-select edit-item"> <?php $selected_country = $address['country']; $countries = give_get_country_list(); foreach ($countries as $country_code => $country) { echo '<option value="' . esc_attr($country_code) . '"' . selected($country_code, $selected_country, false) . '>' . $country . '</option>'; } ?> </select> <?php $selected_state = give_get_state(); $states = give_get_states($selected_country); $selected_state = isset($address['state']) ? $address['state'] : $selected_state; if (!empty($states)) { ?> <select data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-select info-item"> <?php foreach ($states as $state_code => $state) { echo '<option value="' . $state_code . '"' . selected($state_code, $selected_state, false) . '>' . $state . '</option>'; } ?> </select> <?php } else { ?> <input type="text" size="6" data-key="state" name="customerinfo[state]" id="card_state" class="card_state give-input info-item" placeholder="<?php _e('State / Province', 'give'); ?> " /> <?php } ?> <input class="info-item" type="text" data-key="zip" name="customerinfo[zip]" placeholder="<?php _e('Postal', 'give'); ?> " value="<?php echo $address['zip']; ?> " /> </span> <?php } else { echo "none"; } ?> </div> </td> </tr> </tbody> </table> </div> </div> <span id="customer-edit-actions" class="edit-item"> <input type="hidden" data-key="id" name="customerinfo[id]" value="<?php echo $customer->id; ?> " /> <?php wp_nonce_field('edit-customer', '_wpnonce', false, true); ?> <input type="hidden" name="give_action" value="edit-customer" /> <input type="submit" id="give-edit-customer-save" class="button-secondary" value="<?php _e('Update Donor', 'give'); ?> " /> <a id="give-edit-customer-cancel" href="" class="delete"><?php _e('Cancel', 'give'); ?> </a> </span> </form> </div> <?php do_action('give_donor_before_stats', $customer); ?> <div id="customer-stats-wrapper" class="customer-section postbox clear"> <ul> <li> <a title="<?php _e('View All Purchases', 'give'); ?> " href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='******'%d Completed Donation', '%d Completed Donations', $customer->purchase_count, 'give'), $customer->purchase_count); ?> </a> </li> <li> <span class="dashicons dashicons-chart-area"></span> <?php echo give_currency_filter(give_format_amount($customer->purchase_value)); ?> <?php _e('Lifetime Donations', 'give'); ?> </li> <?php do_action('give_donor_stats_list', $customer); ?> </ul> </div> <?php do_action('give_donor_before_tables_wrapper', $customer); ?> <div id="customer-tables-wrapper" class="customer-section"> <?php do_action('give_donor_before_tables', $customer); ?> <h3><?php _e('Recent Donations', 'give'); ?> </h3> <?php $payment_ids = explode(',', $customer->payment_ids); $payments = give_get_payments(array('post__in' => $payment_ids)); $payments = array_slice($payments, 0, 10); ?> <table class="wp-list-table widefat striped payments"> <thead> <tr> <th><?php _e('ID', 'give'); ?> </th> <th><?php _e('Amount', 'give'); ?> </th> <th><?php _e('Date', 'give'); ?> </th> <th><?php _e('Status', 'give'); ?> </th> <th><?php _e('Actions', 'give'); ?> </th> </tr> </thead> <tbody> <?php if (!empty($payments)) { ?> <?php foreach ($payments as $payment) { ?> <tr> <td><?php echo $payment->ID; ?> </td> <td><?php echo give_payment_amount($payment->ID); ?> </td> <td><?php echo date_i18n(get_option('date_format'), strtotime($payment->post_date)); ?> </td> <td><?php echo give_get_payment_status($payment, true); ?> </td> <td> <a title="<?php _e('View Details for Donation', 'give'); echo ' ' . $payment->ID; ?> " href="<?php echo admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $payment->ID); ?> "> <?php _e('View Details', 'give'); ?> </a> <?php do_action('give_donor_recent_purchases_actions', $customer, $payment); ?> </td> </tr> <?php } ?> <?php } else { ?> <tr> <td colspan="5"><?php _e('No Donations Found', 'give'); ?> </td> </tr> <?php } ?> </tbody> </table> <h3><?php _e('Completed Donations', 'give'); ?> </h3> <?php $donations = give_get_users_completed_donations($customer->email); ?> <table class="wp-list-table widefat striped downloads"> <thead> <tr> <th><?php echo give_get_forms_label_singular(); ?> </th> <th width="120px"><?php _e('Actions', 'give'); ?> </th> </tr> </thead> <tbody> <?php if (!empty($donations)) { ?> <?php foreach ($donations as $donation) { ?> <tr> <td><?php echo $donation->post_title; ?> </td> <td> <a title="<?php echo esc_attr(sprintf(__('View %s', 'give'), $donation->post_title)); ?> " href="<?php echo esc_url(admin_url('post.php?action=edit&post=' . $donation->ID)); ?> "> <?php printf(__('View %s', 'give'), give_get_forms_label_singular()); ?> </a> </td> </tr> <?php } ?> <?php } else { ?> <tr> <td colspan="2"><?php _e('No Completed Donations Found', 'give'); ?> </td> </tr> <?php } ?> </tbody> </table> <?php do_action('give_donor_after_tables', $customer); ?> </div> <?php do_action('give_donor_card_bottom', $customer); ?> <?php }
/** * Display the recount stats tools * * @since 1.5 * @return void */ function give_tools_recount_stats_display() { if (!current_user_can('manage_give_settings')) { return; } do_action('give_tools_recount_stats_before'); ?> <div id="poststuff"> <div class="postbox"> <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e('Recount Stats', 'give'); ?> </span></h2> <div class="inside recount-stats-controls"> <p><?php esc_html_e('Use these tools to recount stats, delete test transactions, or reset stats.', 'give'); ?> </p> <form method="post" id="give-tools-recount-form" class="give-export-form"> <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> <select name="give-export-class" id="recount-stats-type"> <option value="0" selected="selected" disabled="disabled"><?php esc_html_e('Please select an option', 'give'); ?> </option> <option data-type="recount-stats" value="Give_Tools_Recount_Income"><?php esc_html_e('Recalculate Total Donation Income Amount', 'give'); ?> </option> <option data-type="recount-form" value="Give_Tools_Recount_Form_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for a Form', 'give'); ?> </option> <option data-type="recount-all" value="Give_Tools_Recount_All_Stats"><?php esc_html_e('Recalculate Income Amount and Donation Counts for All Forms', 'give'); ?> </option> <option data-type="recount-customer-stats" value="Give_Tools_Recount_Customer_Stats"><?php esc_html_e('Recalculate Donor Statistics', 'give'); ?> </option> <option data-type="delete-test-transactions" value="Give_Tools_Delete_Test_Transactions"><?php esc_html_e('Delete Test Transactions', 'give'); ?> </option> <option data-type="reset-stats" value="Give_Tools_Reset_Stats"><?php esc_html_e('Delete All Data', 'give'); ?> </option> <?php do_action('give_recount_tool_options'); ?> </select> <span id="tools-form-dropdown" style="display: none"> <?php $args = array('name' => 'form_id', 'number' => -1, 'chosen' => true); echo Give()->html->forms_dropdown($args); ?> </span> <input type="submit" id="recount-stats-submit" value="<?php esc_attr_e('Submit', 'give'); ?> " class="button-secondary"/> <br/> <span class="give-recount-stats-descriptions"> <span id="recount-stats"><?php esc_html_e('Recalculates the overall donation income amount.', 'give'); ?> </span> <span id="recount-form"><?php printf(esc_html__('Recalculates the donation and income stats for a specific %s.', 'give'), give_get_forms_label_singular(true)); ?> </span> <span id="recount-all"><?php printf(esc_html__('Recalculates the earnings and sales stats for all %s.', 'give'), give_get_forms_label_plural(true)); ?> </span> <span id="recount-customer-stats"><?php esc_html_e('Recalculates the lifetime value and donation counts for all donors.', 'give'); ?> </span> <?php do_action('give_recount_tool_descriptions'); ?> <span id="delete-test-transactions"><?php _e('<strong>Deletes</strong> all TEST payment records, donors, and related log entries.', 'give'); ?> </span> <span id="reset-stats"><?php _e('<strong>Deletes</strong> ALL transaction records, donors, and related log entries regardless of test or live mode.', 'give'); ?> </span> </span> <span class="spinner"></span> </form> <?php do_action('give_tools_recount_forms'); ?> </div><!-- .inside --> </div><!-- .postbox --> </div><!-- #poststuff --> <?php do_action('give_tools_recount_stats_after'); }