├── img ├── icon_32.png ├── sm_ico.png ├── card_array.png ├── information.png └── shortcode-generator-screenshot.jpg ├── css ├── custom_dashicons.eot ├── custom_dashicons.ttf ├── custom_dashicons.woff ├── images │ ├── ui-icons_222222_256x240.png │ ├── ui-icons_2e83ff_256x240.png │ ├── ui-icons_454545_256x240.png │ ├── ui-icons_888888_256x240.png │ ├── ui-icons_cd0a0a_256x240.png │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ ├── ui-bg_flat_75_ffffff_40x100.png │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ ├── ui-bg_glass_65_ffffff_1x400.png │ ├── ui-bg_glass_75_dadada_1x400.png │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ ├── ui-bg_glass_95_fef1ec_1x400.png │ └── ui-bg_highlight-soft_75_cccccc_1x100.png ├── wdf-mp6.css ├── custom_dashicons.svg └── wdf-admin.css ├── languages └── wdf-default.mo ├── lib ├── bp │ ├── js │ │ └── general.js │ ├── bp-wdf-cssjs.php │ ├── templates │ │ ├── readme.txt │ │ └── wdf │ │ │ ├── screen-one.php │ │ │ ├── index.php │ │ │ └── wdf-loop.php │ ├── bp-wdf-actions.php │ ├── bp-wdf-filters.php │ ├── bp-wdf-ajax.php │ ├── bp-wdf-widgets.php │ ├── bp-wdf-activity.php │ ├── bp-wdf-admin.php │ ├── bp-wdf-notifications.php │ ├── bp-wdf-classes.php │ ├── bp-wdf-template.php │ ├── bp-wdf-functions.php │ └── bp-wdf-screens.php ├── classes │ ├── class.wdf_admin_ms.php │ └── class.gateway.php ├── widgets │ ├── widget.recent_fundraisers.php │ ├── widget.fundraisers_list.php │ ├── widget.pledges_panel.php │ ├── widget.simple_donation.php │ └── widget.fundraiser_panel.php ├── wdf_tutorials.php ├── form.blog_dashboard.php ├── gateways │ └── manual.php └── external │ └── class.wd_help_tooltips.php ├── js ├── wdf-edit.js ├── wdf-widget.js ├── wdf-media.js ├── wdf-base.js └── wdf-post.js ├── fundraising-templates.txt ├── styles ├── wdf-minimal.css ├── wdf-note.css ├── wdf-dark.css ├── wdf-basic.css └── wdf-fresh.css ├── fundraiser-bp.php ├── README.md └── changelog.txt /img/icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/img/icon_32.png -------------------------------------------------------------------------------- /img/sm_ico.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/img/sm_ico.png -------------------------------------------------------------------------------- /img/card_array.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/img/card_array.png -------------------------------------------------------------------------------- /img/information.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/img/information.png -------------------------------------------------------------------------------- /css/custom_dashicons.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/custom_dashicons.eot -------------------------------------------------------------------------------- /css/custom_dashicons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/custom_dashicons.ttf -------------------------------------------------------------------------------- /css/custom_dashicons.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/custom_dashicons.woff -------------------------------------------------------------------------------- /languages/wdf-default.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/languages/wdf-default.mo -------------------------------------------------------------------------------- /css/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /css/images/ui-icons_2e83ff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-icons_2e83ff_256x240.png -------------------------------------------------------------------------------- /css/images/ui-icons_454545_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-icons_454545_256x240.png -------------------------------------------------------------------------------- /css/images/ui-icons_888888_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-icons_888888_256x240.png -------------------------------------------------------------------------------- /css/images/ui-icons_cd0a0a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-icons_cd0a0a_256x240.png -------------------------------------------------------------------------------- /img/shortcode-generator-screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/img/shortcode-generator-screenshot.jpg -------------------------------------------------------------------------------- /css/images/ui-bg_flat_0_aaaaaa_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_flat_0_aaaaaa_40x100.png -------------------------------------------------------------------------------- /css/images/ui-bg_flat_75_ffffff_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_flat_75_ffffff_40x100.png -------------------------------------------------------------------------------- /css/images/ui-bg_glass_55_fbf9ee_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_glass_55_fbf9ee_1x400.png -------------------------------------------------------------------------------- /css/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /css/images/ui-bg_glass_75_dadada_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_glass_75_dadada_1x400.png -------------------------------------------------------------------------------- /css/images/ui-bg_glass_75_e6e6e6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_glass_75_e6e6e6_1x400.png -------------------------------------------------------------------------------- /css/images/ui-bg_glass_95_fef1ec_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_glass_95_fef1ec_1x400.png -------------------------------------------------------------------------------- /css/images/ui-bg_highlight-soft_75_cccccc_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wpmudev/fundraising/master/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png -------------------------------------------------------------------------------- /lib/bp/js/general.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready( function() { 2 | // Put your JS in here, and it will run after the DOM has loaded. 3 | 4 | // jQuery.post( ajaxurl, { 5 | // action: 'my_wdf_action', 6 | // 'cookie': encodeURIComponent(document.cookie), 7 | // 'parameter_1': 'some_value' 8 | // }, 9 | // function(response) { 10 | // ... 11 | // } ); 12 | 13 | }); -------------------------------------------------------------------------------- /lib/bp/bp-wdf-cssjs.php: -------------------------------------------------------------------------------- 1 | current_component == $bp->wdf->slug ) 18 | wp_enqueue_script( 'bp-wdf-js', BP_WDF_PLUGIN_BASE_DIR . '/js/general.js' ); 19 | } 20 | add_action( 'template_redirect', 'bp_wdf_add_js', 1 ); 21 | 22 | ?> -------------------------------------------------------------------------------- /css/wdf-mp6.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'custom_dashicons'; 3 | src:url('custom_dashicons.eot'); 4 | src:url('custom_dashicons.eot?#iefix') format('embedded-opentype'), 5 | url('custom_dashicons.ttf') format('truetype'), 6 | url('custom_dashicons.woff') format('woff'), 7 | url('custom_dashicons.svg#icomoon') format('svg'); 8 | font-weight: normal; 9 | font-style: normal; 10 | } 11 | #adminmenu #menu-posts-funder div.wp-menu-image:before, #add_wdf:before { 12 | font-family: 'custom_dashicons' !important; 13 | content: "\e600"; 14 | } 15 | #add_wdf:before { 16 | font-size:18px; 17 | line-height: 28px 18 | } 19 | #adminmenu #menu-posts-funder div.wp-menu-image img, #add_wdf img { 20 | display: none; 21 | } -------------------------------------------------------------------------------- /js/wdf-edit.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready( function($) { 2 | if(WDF && WDF.hook == 'edit.php' && WDF.typenow == 'funder') { 3 | $('.wdf_goal_progress').progressbar({ 4 | value: 0, 5 | create: function() { 6 | $(this).progressbar( "option", "value", Math.round( parseInt( $(this).attr('total') * 100) ) / parseInt( $(this).attr('goal') ) ); 7 | } 8 | }); 9 | } 10 | if(WDF && WDF.hook == 'edit.php' && WDF.typenow == 'donation') { 11 | $('#menu-posts-funder, #menu-posts-funder > a').removeClass('wp-not-current-submenu').addClass('wp-has-current-submenu wp-menu-open'); 12 | $('#menu-posts-funder li a[href="edit.php?post_type=donation&post_status=donation_complete"]').addClass('current').parent().addClass('current'); 13 | } 14 | }); -------------------------------------------------------------------------------- /lib/bp/templates/readme.txt: -------------------------------------------------------------------------------- 1 | You can bundle template files in your plugin that are used to output screens. 2 | 3 | By default these will be loaded when you call bp_core_load_template(), however if a user 4 | copies a given template file into their active theme, they will override the templates in your plugin. That way users can style your templates for their own themes. 5 | 6 | If you make changes to the templates in future versions you will need to let users know what 7 | has changes, so they can update their templates accordingly. 8 | 9 | Of course, templates are not required. You can just build screens in your plugin files with HTML. 10 | However, this reduces flexbility for end users. 11 | 12 | For more information, see the functions bp_wdf_load_template_filter() for how template locations 13 | are filtered, and bp_wdf_screen_one() for how they are loaded for a screen (all in bp-wdf-core.php) -------------------------------------------------------------------------------- /js/wdf-widget.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready( function($) { 2 | 3 | // Use jQuery to find fundraising widgets and add some extra classes to bring out the associated widgets 4 | $.each($('div.widget'), function(i,e) { 5 | var id = $(e).attr('id'); 6 | if(id.indexOf('_wdf_') != -1) { 7 | $('#'+id).addClass('wdf_widget_highlite'); 8 | } 9 | }); 10 | $(document).on('change', '.autosave_widget', function(e) { 11 | $(this).parents('form').find('input[type="submit"]').trigger('click'); 12 | return false; 13 | }); 14 | $(document).on('change', 'select.wdf_toggle', function(e) { 15 | var rel = $(this).attr('rel'); 16 | var val = $(this).val(); 17 | if((rel == 'wdf_panel_single' || rel == 'wdf_panel_single_pledges') && val == '1') { 18 | var elm = $('*[rel="'+rel+'"]').not(this); 19 | elm.show(); 20 | } else { 21 | var elm = $('*[rel="'+rel+'"]').not(this); 22 | elm.hide(); 23 | } 24 | }); 25 | 26 | }); -------------------------------------------------------------------------------- /lib/classes/class.wdf_admin_ms.php: -------------------------------------------------------------------------------- 1 | 22 |
23 |

24 |

25 |
26 |
27 | 28 |
29 |
30 |
31 | 32 | _construct(); 36 | } 37 | 38 | }?> -------------------------------------------------------------------------------- /css/custom_dashicons.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /lib/bp/bp-wdf-actions.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/bp/bp-wdf-filters.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/bp/templates/wdf/screen-one.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 | 6 |
7 | 8 |
9 | 10 |
11 |
12 |
    13 | 14 |
15 |
16 |
17 | 18 |
19 | 20 |
21 |
    22 | 23 |
24 |
25 | 26 |

27 |

high-five!', 'wdf' ), bp_get_displayed_user_fullname(), wp_nonce_url( bp_displayed_user_domain() . bp_current_component() . '/screen-one/send-donation/', 'bp_wdf_send_donation' ) ) ?>

28 | 29 | 30 |

31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
$user_id, 'width' => 25, 'height' => 25 ) ) ?> 
40 | 41 | 42 |
43 | 44 |
45 |
46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /fundraising-templates.txt: -------------------------------------------------------------------------------- 1 | You can create new files inside your active theme's root folder to be used when displaying a fundraiser. 2 | 3 | There are 3 types of templates you can create. 4 | 5 | Template Hierarchy 6 | 7 | Single Fundraiser 8 | wdf_funder-{ID}.php 9 | wdf_funder-{slug}.php 10 | wdf_funder.php 11 | 12 | Fundraiser Checkout 13 | wdf_checkout-{ID}.php 14 | wdf_checkout-{slug}.php 15 | wdf_checkout.php 16 | 17 | Fundraiser Confirmation Page 18 | wdf_confirm-{ID}.php 19 | wdf_confirm-{slug}.php 20 | wdf_confirm.php 21 | 22 | 23 | == Custom Template Functions == 24 | You can change the location of the template-functions that are loaded in fundraising to an external location. 25 | This will insure that any custom changes you make to your template functions are not broken when updating the plugin in the future. 26 | 27 | Add a new define statement in your wp-config.php file containing a string pointing to the location. 28 | define('WDF_CUSTOM_TEMPLATE_FUNCTIONS','/full-server-path/and/filename.php'); 29 | 30 | 31 | == Custom Styles == 32 | Add any CSS file to your fundraising /styles/ folder for it to be available in your settings. 33 | 34 | You can also create a folder named "wdf-styles" in your wp-content folder 35 | OR 36 | you can set an external location using the following code in your wp-config.php file. 37 | 38 | define('WDF_EXTERNAL_STYLE_DIRECTORY','/full/server/path/to/styles/') 39 | 40 | By default the name of the style is the name of the file. You can manually adjust this using the "wdf_custom_style_name" filter 41 | 42 | Exmaple: 43 | add_filter('wdf_custom_style_name', 'my_custom_filter_style_name', 10, 2); 44 | 45 | function my_custom_filter_style_name($name, $file_name) { 46 | if($file_name == 'my-file.css') { 47 | $name = "My Custom Style"; 48 | } 49 | return $name; 50 | } -------------------------------------------------------------------------------- /lib/bp/templates/wdf/index.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 |
16 |
17 | 18 | 19 | 20 |
21 | 22 |

23 | 24 | 25 | 26 | 27 | 28 |
29 |
    30 |
  • %s', 'buddypress' ), bp_wdf_get_total_donation_count() ); ?>
  • 31 | 32 | 33 | 34 |
35 |
36 | 37 |
38 | 39 | 40 | 41 |
42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /lib/bp/templates/wdf/wdf-loop.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 |
18 | 19 | 20 | 21 |
22 | 23 |
24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 |
    34 | 35 | 36 | 37 |
  • 38 |
    39 | 40 |
    41 | 42 |
    43 |
    44 | 45 | 46 | 47 |
    48 | 49 |
    50 |
  • 51 | 52 | 53 | 54 |
55 | 56 | 57 | 58 |
59 | 60 |
61 | 62 | 63 | 64 |
65 | 66 |
67 | 68 | 69 | 70 |
71 | 72 |
73 | 74 | 75 | 76 |
77 |

78 |
79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /lib/widgets/widget.recent_fundraisers.php: -------------------------------------------------------------------------------- 1 | sprintf(__('The most recent %s on your site','wdf'),esc_attr($settings['funder_labels']['plural_name'])) 14 | ) ); 15 | } 16 | 17 | function widget( $args, $instance ) { 18 | // Widget output 19 | 20 | $content = $args['before_widget']; 21 | $content .= $args['before_title'] . esc_attr(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 22 | $query = array( 23 | 'numberposts' => $instance['numberposts'], 24 | 'post_type' => 'funder', 25 | 'post_status' => 'publish' 26 | ); 27 | $query = get_posts($query); 28 | $content .= '
    '; 29 | foreach($query as $funder) { 30 | $content .= '
  • '.$funder->post_title.'
  • '; 31 | } 32 | $content .= '
'; 33 | $content .= $args['after_widget']; 34 | echo $content; 35 | } 36 | 37 | function update( $new_instance, $old_instance ) { 38 | 39 | $instance = $old_instance; 40 | $instance['title'] = esc_attr($new_instance['title']); 41 | $instance['numberposts'] = absint($new_instance['numberposts']); 42 | 43 | return $instance; 44 | } 45 | 46 | function form( $instance ) { 47 | ?> 48 |

49 | 50 | 51 |

52 |

53 | 54 | 55 |

56 | -------------------------------------------------------------------------------- /lib/bp/bp-wdf-ajax.php: -------------------------------------------------------------------------------- 1 | loggedin_user->id, $_POST['fid'] ) ) { 38 | 39 | if ( !friends_remove_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) { 40 | echo __( 'Friendship could not be canceled.', 'bp-component' ); 41 | } else { 42 | echo '' . __( 'Add Friend', 'wdf' ) . ''; 43 | } 44 | 45 | } else if ( 'not_friends' == BP_Friends_Friendship::check_is_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) { 46 | 47 | if ( !friends_add_friend( $bp->loggedin_user->id, $_POST['fid'] ) ) { 48 | echo __( 'Friendship could not be requested.', 'wdf'); 49 | } else { 50 | echo '' . __( 'Friendship Requested', 'bp-component' ) . ''; 51 | } 52 | 53 | } else { 54 | echo __( 'Request Pending', 'bp-component' ); 55 | } 56 | 57 | return false; 58 | } 59 | //add_action( 'wp_ajax_addremove_friend', 'friends_ajax_addremove_friend' ); 60 | 61 | ?> -------------------------------------------------------------------------------- /lib/bp/bp-wdf-widgets.php: -------------------------------------------------------------------------------- 1 | 35 | 36 | 43 | 44 | 45 | 200, 'per_page' => 25 ) ); 61 | $per_page = strip_tags( $instance['per_page'] ); 62 | $max_items = strip_tags( $instance['max_items'] ); 63 | ?> 64 | 65 |

66 |

67 | -------------------------------------------------------------------------------- /styles/wdf-minimal.css: -------------------------------------------------------------------------------- 1 | .wdf-minimal input.wdf_pledge_amount { 2 | width: auto; 3 | margin: 0 0 3px 0; 4 | } 5 | .wdf-minimal .wdf_levels { 6 | clear: both; 7 | list-style: none; 8 | margin: 10px 0 0 0; 9 | padding: 0; 10 | background-color: #EEE; 11 | border: 1px solid #E5E5E5; 12 | padding: 10px; 13 | } 14 | .wdf-minimal .wdf_levels li{ 15 | cursor: pointer; 16 | padding: 10px; 17 | margin: 0 10px; 18 | } 19 | .wdf-minimal .wdf_levels li.item:hover { 20 | background: #fff; 21 | cursor: pointer; 22 | } 23 | .wdf-minimal .wdf_content { 24 | margin: 0; 25 | padding: 0; 26 | } 27 | .wdf-minimal .wdf_send_amount { 28 | width: 50px; 29 | } 30 | .wdf-minimal .wdf_progress_info { 31 | margin-bottom: 10px; 32 | font-style: italic; 33 | font-size: 1.4em; 34 | } 35 | .wdf-minimal .wdf_donate_now input[type="text"], textarea { 36 | margin: 0 0 0 5px; 37 | -webkit-border-radius: 5px; 38 | -moz-border-radius: 5px; 39 | border-radius: 5px; 40 | } 41 | .wdf-minimal .wdf_level_amount { 42 | } 43 | .wdf-minimal .wdf_send_donation, 44 | .wdf-minimal .wdf_button { 45 | color: #333; 46 | cursor: pointer; 47 | display: inline-block; 48 | line-height: normal; 49 | text-decoration:none; 50 | background: #eaeaea; 51 | padding: 5px 9px 6px; 52 | box-shadow: none; 53 | text-shadow:none; 54 | } 55 | .wdf-minimal .wdf_send_donation:hover { 56 | 57 | } 58 | .wdf-minimal .wdf_levels .reward { 59 | padding-left: 30px; 60 | } 61 | .wdf-minimal.wdf_fundraiser_panel > div { 62 | margin: 10px 0px; 63 | } 64 | .wdf-minimal .wdf_big_num { 65 | font-size: 2em; 66 | } 67 | .wdf-minimal .ui-progressbar{ 68 | height: 1em; 69 | margin: 10px 0 0 0; 70 | } 71 | .wdf-minimal div.wdf_backer_button { 72 | margin: 20px 0px 20px 0px; 73 | } 74 | .wdf-minimal .wdf_reward_item { 75 | margin: 10px 0px 10px 0px; 76 | } 77 | .wdf_fundraiser_panel.wdf-minimal .wdf_level_amount { 78 | } 79 | .wdf-minimal .wdf_bp_show_on_activity { 80 | 81 | } 82 | .wdf-minimal .wdf_reward_item { 83 | cursor: pointer; 84 | } 85 | .wdf-minimal .wdf_reward_item_disabled { 86 | cursor: default !important; 87 | opacity: 0.7; 88 | } 89 | .wdf_fundraiser_panel.wdf-minimal .wdf_reward_item { 90 | padding: 5px; 91 | } 92 | .wdf-minimal .wdf_choose_reward_title { 93 | font-size: 2.5em; 94 | margin-top: 15px; 95 | } 96 | .wdf-minimal .ui-progressbar{ 97 | height: 1em; 98 | margin: 10px 0 0 0; 99 | } 100 | 101 | .wdf-minimal .wdf_reward_limit { 102 | font-size: 0.7em; 103 | font-weight: normal; 104 | background: #fff7ce; 105 | display: inline-block; 106 | padding: 2px 4px; 107 | color: #000; 108 | margin: 2px; 109 | } 110 | .wdf-minimal .wdf_reward_limit_gone { 111 | background: #f7d4d4; 112 | } -------------------------------------------------------------------------------- /lib/bp/bp-wdf-activity.php: -------------------------------------------------------------------------------- 1 | For example: "Andy high-fived John", "Andy posted a new update". 14 | * 'type' => The type of action being carried out, for example 'new_friendship', 'joined_group'. This should be unique within your component. 15 | * 16 | * OPTIONAL PARAMS 17 | * 'id' => The ID of an existing activity item that you want to update. 18 | * 'content' => The content of your activity, if it has any, for example a photo, update content or blog post excerpt. 19 | * 'component' => The slug of the component. 20 | * 'primary_link' => The link for the title of the item when appearing in RSS feeds (defaults to the activity permalink) 21 | * 'item_id' => The ID of the main piece of data being recorded, for example a group_id, user_id, forum_post_id - useful for filtering and deleting later on. 22 | * 'user_id' => The ID of the user that this activity is being recorded for. Pass false if it's not for a user. 23 | * 'recorded_time' => (optional) The time you want to set as when the activity was carried out (defaults to now) 24 | * 'hide_sitewide' => Should this activity item appear on the site wide stream? 25 | * 'secondary_item_id' => (optional) If the activity is more complex you may need a second ID. For example a group forum post may need the group_id AND the forum_post_id. 26 | * ) 27 | * 28 | * Example usage would be: 29 | * 30 | * bp_wdf_record_activity( array( 'type' => 'new_donation', 'action' => 'Andy high-fived John', 'user_id' => $bp->loggedin_user->id, 'item_id' => $bp->displayed_user->id ) ); 31 | * 32 | */ 33 | function bp_wdf_record_activity( $args = '' ) { 34 | global $bp; 35 | 36 | if ( !function_exists( 'bp_activity_add' ) ) 37 | return false; 38 | 39 | $defaults = array( 40 | 'id' => false, 41 | 'user_id' => $bp->loggedin_user->id, 42 | 'action' => '', 43 | 'content' => '', 44 | 'primary_link' => '', 45 | 'component' => $bp->wdf->id, 46 | 'type' => false, 47 | 'item_id' => false, 48 | 'secondary_item_id' => false, 49 | 'recorded_time' => gmdate( "Y-m-d H:i:s" ), 50 | 'hide_sitewide' => false 51 | ); 52 | 53 | $r = wp_parse_args( $args, $defaults ); 54 | extract( $r ); 55 | 56 | return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); 57 | } 58 | 59 | ?> -------------------------------------------------------------------------------- /js/wdf-media.js: -------------------------------------------------------------------------------- 1 | function wdf_inject_shortcode () { 2 | 3 | var iFrame = jQuery('#TB_iframeContent').contents(); 4 | var cont = iFrame.find('.wdf_media_cont:first'); 5 | var type = cont.attr('id'); 6 | var form = cont.serializeArray(); 7 | 8 | switch(type) { 9 | case 'media_fundraising' : 10 | var funder_select = iFrame.find('#wdf_funder_select'); 11 | 12 | var shortcode = '[fundraiser_panel'; 13 | 14 | jQuery.each(form, function(i,e) { 15 | shortcode = shortcode + ' '+e.name+'="'+e.value+'"'; 16 | }); 17 | 18 | shortcode = shortcode + ']'; 19 | if(jQuery('#wp-content-wrap').hasClass('tmce-active')) { 20 | window.parent.tinyMCE.execCommand("mceInsertContent", true, shortcode); 21 | window.parent.tb_remove(); 22 | } else { 23 | window.parent.edInsertContent('',shortcode); 24 | window.parent.tb_remove(); 25 | } 26 | break; 27 | 28 | case 'media_pledges' : 29 | var funder_select = iFrame.find('#wdf_funder_select'); 30 | 31 | var shortcode = '[pledges_panel'; 32 | 33 | jQuery.each(form, function(i,e) { 34 | shortcode = shortcode + ' '+e.name+'="'+e.value+'"'; 35 | }); 36 | 37 | shortcode = shortcode + ']'; 38 | if(jQuery('#wp-content-wrap').hasClass('tmce-active')) { 39 | window.parent.tinyMCE.execCommand("mceInsertContent", true, shortcode); 40 | window.parent.tb_remove(); 41 | } else { 42 | window.parent.edInsertContent('',shortcode); 43 | window.parent.tb_remove(); 44 | } 45 | break; 46 | 47 | case 'media_donate_button' : 48 | var shortcode = '[donate_button'; 49 | jQuery.each(form, function(i,e) { 50 | if(e.value != '') 51 | shortcode = shortcode + ' '+e.name+'="'+e.value+'"'; 52 | }); 53 | shortcode = shortcode + ']'; 54 | if(jQuery('#wp-content-wrap').hasClass('tmce-active')) { 55 | window.parent.tinyMCE.execCommand("mceInsertContent", true, shortcode); 56 | window.parent.tb_remove(); 57 | } else { 58 | window.parent.edInsertContent('',shortcode); 59 | window.parent.tb_remove(); 60 | } 61 | break; 62 | 63 | case 'media_progress_bar' : 64 | var shortcode = '[progress_bar'; 65 | jQuery.each(form, function(i,e) { 66 | if(parseInt(e.value) !== 0) 67 | shortcode = shortcode + ' '+e.name+'="'+e.value+'"'; 68 | }); 69 | shortcode = shortcode + ']'; 70 | if(jQuery('#wp-content-wrap').hasClass('tmce-active')) { 71 | window.parent.tinyMCE.execCommand("mceInsertContent", true, shortcode); 72 | window.parent.tb_remove(); 73 | } else { 74 | window.parent.edInsertContent('',shortcode); 75 | window.parent.tb_remove(); 76 | } 77 | break; 78 | 79 | } 80 | } 81 | function wdf_input_switch(elm) { 82 | elm = jQuery(elm); 83 | var iFrame = jQuery('#TB_iframeContent').contents(); 84 | var rel = elm.attr('rel'); 85 | var val = elm.val(); 86 | 87 | /*$('select.wdf_toggle').on('change', function(e) { 88 | var rel = $(this).attr('rel'); 89 | var val = $(this).val(); 90 | //alert(rel + val); 91 | 92 | if(rel == 'wdf_panel_single' && val == '1') { 93 | var elm = $('*[rel="'+rel+'"]').not(this); 94 | elm.show(); 95 | } else { 96 | var elm = $('*[rel="'+rel+'"]').not(this); 97 | elm.hide(); 98 | } 99 | });*/ 100 | } -------------------------------------------------------------------------------- /fundraiser-bp.php: -------------------------------------------------------------------------------- 1 | ' ) ) 51 | require( WDF_PLUGIN_BASE_DIR . '/lib/bp/bp-wdf-loader.php' ); 52 | } 53 | add_action( 'bp_include', 'bp_wdf_init' ); 54 | 55 | /* Put setup procedures to be run when the plugin is activated in the following function */ 56 | function bp_wdf_activate() { 57 | 58 | } 59 | register_activation_hook( __FILE__, 'bp_wdf_activate' ); 60 | 61 | /* On deacativation, clean up anything your component has added. */ 62 | function bp_wdf_deactivate() { 63 | /* You might want to delete any options or tables that your component created. */ 64 | } 65 | register_deactivation_hook( __FILE__, 'bp_wdf_deactivate' ); 66 | ?> -------------------------------------------------------------------------------- /lib/widgets/widget.fundraisers_list.php: -------------------------------------------------------------------------------- 1 | sprintf(__('Choose a list of simple %s links you wish to display.','wdf'),esc_attr($settings['funder_labels']['plural_name'])) 14 | ) ); 15 | } 16 | 17 | function widget( $args, $instance ) { 18 | $limit = (isset($instance['limit']) && $instance['limit'] && is_numeric($instance['limit'])) ? $instance['limit'] : -1; 19 | // Widget output 20 | $content = $args['before_widget']; 21 | $content .= $args['before_title'] . esc_attr(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 22 | $query = array( 23 | 'post_type' => 'funder', 24 | 'post_status' => 'publish', 25 | 'posts_per_page' => $limit 26 | ); 27 | if(isset($instance['funders']) && is_array($instance['funders']) && count($instance['funders']) > 0) { 28 | $selected_funders = array(); 29 | foreach ($instance['funders'] as $funder_id => $true) 30 | $selected_funders[] = $funder_id; 31 | $query['post__in'] = $selected_funders; 32 | } 33 | $query = get_posts($query); 34 | $content .= '
    '; 35 | foreach($query as $funder) { 36 | $content .= '
  • '.$funder->post_title.'
  • '; 37 | } 38 | $content .= '
'; 39 | $content .= $args['after_widget']; 40 | echo $content; 41 | } 42 | 43 | function update( $new_instance, $old_instance ) { 44 | 45 | $instance = $old_instance; 46 | $instance['title'] = esc_attr($new_instance['title']); 47 | $instance['description'] = esc_textarea($new_instance['description']); 48 | $instance['limit'] = esc_attr($new_instance['limit']); 49 | $instance['funders'] = $new_instance['funders']; 50 | return $instance; 51 | } 52 | 53 | function form( $instance ) { 54 | $settings = get_option('wdf_settings'); 55 | ?> 56 |

57 |
58 | 59 |

60 |

61 |
62 | 63 |

64 |

65 |
66 | 67 |

68 | -1, 'post_type' => 'funder', 'post_status' => 'publish'); 70 | $query = get_posts($query); 71 | if(count($query) > 0) { 72 | echo '

'.sprintf(__('Optional: select %s to display','wdf'), esc_attr($settings['funder_labels']['plural_name'])).'
'; 73 | foreach($query as $funder) : ?> 74 |
78 | '; 81 | } 82 | } 83 | } 84 | ?> -------------------------------------------------------------------------------- /js/wdf-base.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * jQuery Bullseye v1.0 3 | * http://pixeltango.com 4 | * 5 | * Copyright 2010, Mickel Andersson 6 | * Dual licensed under the MIT or GPL Version 2 licenses. 7 | * 8 | * Date: Fri Aug 31 19:09:11 2010 +0100 9 | */ 10 | (function($){ 11 | jQuery.fn.bullseye = function (b, h) { b = jQuery.extend({ offsetTop: 0, offsetHeight: 0, extendDown: false }, b); return this.each(function () { var a = $(this), c = $(h == null ? window : h), g = function () { var d = a.outerWidth(), e = a.outerHeight() + b.offsetHeight; c.width(); var f = c.height(), i = c.scrollTop(), j = c.scrollLeft() + d; f = i + f; var k = a.offset().left; d = k + d; var l = a.offset().top + b.offsetTop; e = l + e; if (f < l || (b.extendDown ? false : i > e) || j < k || j > d) { if (a.data("is-focused")) { a.data("is-focused", false); a.trigger("leaveviewport") } } else if (!a.data("is-focused")) { a.data("is-focused", true); a.trigger("enterviewport") } }; c.scroll(g).resize(g); g() }) }; 12 | })(jQuery); 13 | 14 | jQuery(document).ready( function($) { 15 | var prog_default = { 16 | value: 0, 17 | create: function() { 18 | var value = Math.round( parseInt( $(this).attr('total') * 100) ) / parseInt( $(this).attr('goal') ); 19 | if(value > 100) { value = 100 } 20 | $(this).find('.ui-progressbar-value').animate({ width: value + '%'},4000,'swing'); 21 | $(this).progressbar( "option", "value", value); 22 | } 23 | }; 24 | 25 | $('.wdf_rewards .wdf_reward_item').on('click', function(e) { 26 | var _this = $(this); 27 | if (!_this.hasClass("wdf_reward_item_disabled")) { 28 | var rel = _this.find('.wdf_level_amount').attr('rel'); 29 | if($.isNumeric( rel )) 30 | _this.parent().find('input.wdf_pledge_amount').val(rel); 31 | 32 | _this.find('input:radio').prop('checked', true); 33 | } 34 | }); 35 | 36 | $('.wdf_pledge_amount').on('focusout', function(e) { 37 | var _this = $(this); 38 | var pledge_amount = Math.round(_this.val()); 39 | //_this.val(pledge_amount); 40 | 41 | var reward_amount = _this.parents('.wdf_rewards').find(".wdf_reward_item input:checked").parent().find('.wdf_level_amount').attr('rel'); 42 | if(pledge_amount < reward_amount) 43 | _this.parents('.wdf_rewards').find(".wdf_reward_item input:checked").prop('checked', false); 44 | 45 | _this.find('input:radio').prop('checked', true); 46 | }); 47 | 48 | $('.wdf_goal_progress').progressbar(prog_default).on('enterviewport', function() { 49 | if($(this).hasClass('not-seen')) { 50 | var value = Math.round( parseInt( $(this).attr('total') * 100) ) / parseInt( $(this).attr('goal') ); 51 | if(value > 100) { value = 100 } 52 | $(this).find('.ui-progressbar-value').width(0).animate({ width: value + '%'},4000,'swing'); 53 | $(this).removeClass('not-seen').addClass('seen'); 54 | $(this).progressbar( "option", "value", value); 55 | } else { 56 | //Do Nothing 57 | } 58 | }).bullseye(); 59 | 60 | $('.wdf_donate_btn.oneclick').click( function() { 61 | $(this).parents('form').trigger('submit'); 62 | return false; 63 | }); 64 | 65 | //loading dots 66 | if($(".wdf-loading-dots").length) { 67 | var dots = ""; 68 | loading_dots = setInterval(function() { 69 | if(!$(".wdf-loading-dots").length) 70 | clearInterval(loading_dots); 71 | if(dots.length == 6) { 72 | dots = ""; 73 | } 74 | else { 75 | dots += " ."; 76 | } 77 | $(".wdf-loading-dots").text(dots); 78 | } , 400); 79 | } 80 | 81 | //lets look for delayed pledges 82 | if($('.wdf-pledge-waiting').length && $('.wdf-pledge-waiting').attr('data-wdf-pledge-id')) { 83 | var pledge_check_count = 0 84 | 85 | var pledge_check = setInterval(function() { 86 | pledge_check_count ++; 87 | 88 | args = { 89 | action: 'wdf_look_for_pledge', 90 | pledge_id: $('.wdf-pledge-waiting').attr('data-wdf-pledge-id') 91 | }; 92 | $.post(wdf.ajaxurl, args, function(response) { 93 | if(response == 'not-found' && pledge_check_count > 3) { 94 | clearInterval(pledge_check); 95 | $('.wdf-pledge-waiting').remove(); 96 | $('.wdf-pledge-error').show(); 97 | } 98 | else if(response != 'not-found') { 99 | location.reload(); 100 | } 101 | }); 102 | } , 5000); 103 | } 104 | }); -------------------------------------------------------------------------------- /styles/wdf-note.css: -------------------------------------------------------------------------------- 1 | .wdf-note input.wdf_pledge_amount { 2 | width: auto; 3 | margin: 0 0 3px 0; 4 | } 5 | .wdf-note .wdf_rewards { 6 | clear: both; 7 | list-style: none; 8 | margin: 10px 0 0 0; 9 | padding: 0; 10 | background: #ffffe8; 11 | border: 1px dashed #efef1a; 12 | -webkit-border-radius: 4px; 13 | -moz-border-radius: 4px; 14 | border-radius: 4px; 15 | padding: 10px; 16 | } 17 | .wdf-note .wdf_rewards .wdf_reward_item { 18 | cursor: pointer; 19 | padding: 10px; 20 | border-bottom: 1px dashed #efef1a; 21 | } 22 | .wdf-note .wdf_rewards .wdf_reward_item_none { 23 | margin-bottom: 0px; 24 | border-bottom: none; 25 | } 26 | .wdf-note .wdf_rewards .wdf_reward_item:hover { 27 | background: #fff; 28 | -webkit-border-radius: 5px; 29 | -moz-border-radius: 5px; 30 | border-radius: 5px; 31 | cursor: pointer; 32 | } 33 | .wdf-note .wdf_content { 34 | margin: 0; 35 | padding 0; 36 | } 37 | .wdf-note .wdf_send_amount { 38 | width: 50px; 39 | } 40 | .wdf-note .wdf_progress_info { 41 | margin-bottom: 10px; 42 | font-style: italic; 43 | font-size: 1.4em; 44 | } 45 | .wdf-note .wdf_donate_now input[type="text"], textarea { 46 | margin: 0 0 0 5px; 47 | -webkit-border-radius: 5px; 48 | -moz-border-radius: 5px; 49 | border-radius: 5px; 50 | } 51 | .wdf-note .wdf_level_amount { 52 | } 53 | .wdf-note .wdf_reward_description { 54 | font-size: 1em; 55 | } 56 | .wdf-note .wdf_send_donation, 57 | .wdf-note .wdf_button { 58 | color: #fff; 59 | cursor: pointer; 60 | display: inline-block; 61 | background-color: #6eb850; 62 | background-image: -moz-linear-gradient(top, #62C462, #51A351); 63 | background-image: -ms-linear-gradient(top, #62C462, #51A351); 64 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62C462), to(#51A351)); 65 | background-image: -webkit-linear-gradient(top, #62C462, #51A351); 66 | background-image: -o-linear-gradient(top, #62C462, #51A351); 67 | background-image: linear-gradient(top, #62C462, #51A351); 68 | background-repeat: repeat-x; 69 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462', endColorstr='#51a351', GradientType=0); 70 | border-color: #51A351 #51A351 #387038; 71 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 72 | padding: 5px 9px 6px; 73 | text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); 74 | line-height: normal; 75 | border: 1px solid #5BB75B; 76 | -webkit-border-radius: 4px; 77 | -moz-border-radius: 4px; 78 | border-radius: 4px; 79 | -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 80 | -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 81 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 82 | -webkit-transition: 0.1s linear all; 83 | -moz-transition: 0.1s linear all; 84 | -ms-transition: 0.1s linear all; 85 | -o-transition: 0.1s linear all; 86 | transition: 0.1s linear all; 87 | text-decoration:none; 88 | } 89 | .wdf-note .wdf_send_donation:hover { 90 | background: #6eb850; 91 | } 92 | .wdf-note.wdf_fundraiser_panel > div { 93 | margin: 10px 0px; 94 | } 95 | .wdf-note .wdf_big_num { 96 | font-size: 2em; 97 | } 98 | .wdf-note .ui-progressbar{ 99 | height: 1em; 100 | margin: 10px 0 0 0; 101 | } 102 | .wdf-note div.wdf_backer_button { 103 | margin: 20px 0px 20px 0px; 104 | } 105 | .wdf-note .wdf_reward_item { 106 | margin: 10px 0px 10px 0px; 107 | } 108 | .wdf_fundraiser_panel.wdf-note .wdf_level_amount { 109 | } 110 | .wdf-note .wdf_bp_show_on_activity { 111 | 112 | } 113 | .wdf-note .wdf_reward_item { 114 | cursor: pointer; 115 | } 116 | .wdf-note .wdf_reward_item_disabled { 117 | cursor: default !important; 118 | opacity: 0.7; 119 | } 120 | .wdf_fundraiser_panel.wdf-note .wdf_reward_item { 121 | padding: 5px; 122 | } 123 | .wdf-note .wdf_choose_reward_title { 124 | font-size: 2.5em; 125 | margin-top: 15px; 126 | } 127 | .wdf-note .ui-progressbar{ 128 | height: 1em; 129 | margin: 10px 0 0 0; 130 | } 131 | .wdf-note .wdf_reward_limit { 132 | font-size: 0.7em; 133 | font-weight: normal; 134 | background: #fff7ce; 135 | display: inline-block; 136 | padding: 2px 4px; 137 | color: #000; 138 | margin: 2px; 139 | } 140 | .wdf-note .wdf_reward_limit_gone { 141 | background: #f7d4d4; 142 | } 143 | -------------------------------------------------------------------------------- /styles/wdf-dark.css: -------------------------------------------------------------------------------- 1 | .wdf-dark input.wdf_pledge_amount { 2 | width: auto; 3 | margin: 0 0 3px 0; 4 | } 5 | 6 | .wdf-dark .wdf_choose_reward_title { 7 | font-size: 1.5em; 8 | } 9 | .wdf-dark .wdf_rewards { 10 | clear: both; 11 | list-style: none; 12 | margin: 10px 0 0 0; 13 | padding: 10px; 14 | background-color: #272628; 15 | background-image: -o-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 16 | background-image: -moz-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 17 | background-image: -webkit-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 18 | background-image: -ms-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 19 | background-image: linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 20 | -webkit-border-radius: 5px; 21 | -moz-border-radius: 5px; 22 | border-radius: 5px; 23 | color: #fff; 24 | text-shadow: -1px -1px 0px #111; 25 | } 26 | 27 | .wdf-dark .wdf_rewards h4{ 28 | color: #fff; 29 | font-weight: 400; 30 | } 31 | .wdf-dark .wdf_rewards .wdf_reward_item{ 32 | cursor: pointer; 33 | padding: 10px; 34 | margin: 0; 35 | border-bottom: 1px solid #111; 36 | } 37 | .wdf-dark .wdf_rewards .wdf_reward_item:hover { 38 | background: rgba(255, 255, 255, 0.1); 39 | -webkit-border-radius: 5px; 40 | -moz-border-radius: 5px; 41 | border-radius: 5px; 42 | cursor: pointer; 43 | } 44 | .wdf-dark .wdf_content { 45 | 46 | } 47 | .wdf-dark .wdf_send_amount { 48 | width: 50px; 49 | } 50 | .wdf-dark .wdf_progress_info { 51 | margin-bottom: 10px; 52 | font-style: italic; 53 | font-size: 1.4em;; 54 | } 55 | .wdf-dark .wdf_donate_now input[type="text"], textarea { 56 | opacity: 0.5; 57 | margin: 0 0 0 5px; 58 | -webkit-border-radius: 5px; 59 | -moz-border-radius: 5px; 60 | border-radius: 5px; 61 | padding: 0; 62 | line-height: 1em; 63 | } 64 | .wdf-dark .wdf_level_amount { 65 | 66 | } 67 | .wdf-dark .wdf_send_donation, 68 | .wdf-dark .wdf_button { 69 | color: #eee; 70 | cursor: pointer; 71 | display: inline-block; 72 | background-color: #413E44; 73 | background-image: -o-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 74 | background-image: -moz-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 75 | background-image: -webkit-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 76 | background-image: -ms-linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 77 | background-image: linear-gradient(90deg , rgb(28,28,28) 0%, rgb(66,63,69) 100%); 78 | padding: 5px 9px 6px; 79 | text-shadow: -1px -1px 0 #111; 80 | line-height: normal; 81 | border: 1px solid #333; 82 | border-bottom-color: #111; 83 | -webkit-border-radius: 4px; 84 | -moz-border-radius: 4px; 85 | border-radius: 4px; 86 | text-decoration:none; 87 | box-shadow: none; 88 | } 89 | 90 | .wdf-dark .wdf_send_donation:hover, 91 | .wdf-dark .wdf_button:hover { 92 | 93 | } 94 | .wdf-dark .wdf_levels .reward { 95 | font-weight: bold; 96 | padding-left: 30px; 97 | } 98 | .wdf-dark.wdf_fundraiser_panel > div { 99 | margin: 10px 0px; 100 | } 101 | .wdf-dark .wdf_big_num { 102 | font-size: 2em; 103 | } 104 | .wdf-dark .ui-progressbar{ 105 | height: 1em; 106 | margin: 10px 0 0 0; 107 | } 108 | .wdf-dark div.wdf_backer_button { 109 | margin: 20px 0px 20px 0px; 110 | } 111 | .wdf-dark .wdf_reward_item { 112 | margin: 10px 0px 10px 0px; 113 | } 114 | .widget_wdf_fundraiser_panel .wdf-dark .wdf_level_amount { 115 | padding-right: 8px; 116 | } 117 | .wdf-dark .wdf_bp_show_on_activity { 118 | 119 | } 120 | .wdf-dark .wdf_reward_item { 121 | cursor: pointer; 122 | } 123 | .wdf-dark .wdf_reward_item_disabled { 124 | cursor: default !important; 125 | opacity: 0.9; 126 | } 127 | .wdf-dark .wdf_checkout_form .wdf_reward_choice input[type="radio"] { 128 | 129 | } 130 | .wdf-dark .wdf_choose_reward_title { 131 | font-size: 2.5em; 132 | margin-top: 15px; 133 | } 134 | .wdf-dark .ui-progressbar{ 135 | height: 1em; 136 | margin: 10px 0 0 0; 137 | background: #444; 138 | border: 1px solid #111; 139 | } 140 | .wdf-dark .wdf_reward_limit { 141 | font-size: 0.7em; 142 | font-weight: normal; 143 | background: #787f2c; 144 | display: inline-block; 145 | padding: 2px 4px; 146 | border-radius: 5px; 147 | color: #fff; 148 | margin: 2px; 149 | } 150 | .wdf-dark .wdf_reward_limit_gone { 151 | background: #7c2b2b; 152 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fundraising WordPress Plugin 2 | 3 | **INACTIVE NOTICE: This plugin is unsupported by WPMUDEV, we've published it here for those technical types who might want to fork and maintain it for their needs.** 4 | 5 | ## Crowdfund your next project complete with funding goals and reward packages, or quickly build a single donation page with recurring payment options. 6 | ---------------------------------------------------------------------------------------------------------------------------------------------------- 7 | 8 | ![fundit-home-735x470](https://premium.wpmudev.org/wp-content/uploads/2012/03/fundit-home-735x470-583x372.jpg) Create, host and manage your fundraisers and keep all the proceeds. 9 | 10 | ### More Money for Your Project 11 | 12 | Services like Kickstarter and Indiegogo take as much as 11% for admin and processing fees. Lose the outrageous fees and put the funds directly into your nonprofit, indie record release, or crazy invention instead. 13 | 14 | 15 | ### Power Features & Simple Setup 16 | 17 | If you're looking for a heavy duty fundraising system with thousands of settings – this isn't it. Other plugins can do that. Fundraising adds just the power-features for simple crowdfunding and quick setup. 18 | 19 | ![funding-page-735x470](https://premium.wpmudev.org/wp-content/uploads/2012/03/funding-page-735x470-583x372.jpg) All the key features to easily manage a fundraiser on your site. 20 | 21 | ![fundraising-shortcode-735x470](https://premium.wpmudev.org/wp-content/uploads/2012/03/fundraising-shortcode-735x470-583x373.jpg) Quickly insert Fundraising features into any post with the shortcode generator. 22 | 23 | ### Integrate With Your Theme 24 | 25 | The easy ‘getting started’ guide will have you creating fundraisers immediately. Five included style templates, the in-post shortcode generator and built-in widgets make integration with your existing theme simple. 26 | 27 | ### Easy Payment Processing 28 | 29 | Fundraising includes Paypal integration for convenience or lets you keep 100% of the donation with a manual processing option. Watch your progress bar climb. Process gifts in real-time at your next event. Input cash gifts, credit cards and pledges. 30 | 31 | ### Rewards & Milestones 32 | 33 | Set a start and end date with a specific goal and wait to take payment until the project is funded, or take donations as they come in. Create reward packages and limit availability to motivate potential supporters. Fundraising makes it easy! 34 | 35 | ![fundraiser-simple-735x470](https://premium.wpmudev.org/wp-content/uploads/2012/03/fundraiser-simple-735x470-583x373.jpg) Offer rewards to help inspire users to respond quickly 36 | 37 | ### Fundraising in all Shapes & Sizes 38 | 39 | **From simple donations to reward-based crowdfunding, Fundraising has you covered.** 40 | 41 | ![fundraising-code](https://premium.wpmudev.org/wp-content/uploads/2012/03/fundraising-code.png) 42 | 43 | **Simple Donations** 44 | 45 | Take continuous donation with no end date. Great for non-profits and donor supported organizations. 46 | 47 | ![crowdfund](https://premium.wpmudev.org/wp-content/uploads/2012/03/crowdfund.png) 48 | 49 | **Advanced Crowdfunding** 50 | 51 | Authorize pledges, then wait to process payments until after your goal is reached – like Kickstarter. 52 | 53 | ![shortcodes](https://premium.wpmudev.org/wp-content/uploads/2012/03/shortcodes.png) 54 | 55 | **Display Styles** 56 | 57 | Choose one of the included styles (Basic, Dark, Fresh, Minimal, Note) or create a custom style. 58 | 59 | ![calendar](https://premium.wpmudev.org/wp-content/uploads/2012/03/calendar.png) 60 | 61 | **Start & End Date** 62 | 63 | Schedule your start date and end date to create urgency with time sensitive projects. 64 | 65 | ![email](https://premium.wpmudev.org/wp-content/uploads/2012/03/email.png) 66 | 67 | **Thank You & Follow-Up** 68 | 69 | Built-in automated response emails send thank you messages and confirmation emails. 70 | 71 | ![reward](https://premium.wpmudev.org/wp-content/uploads/2012/03/reward.png) 72 | 73 | **Rewards** 74 | 75 | Set support levels and reward donors with a sticker, t-shirt or early release of your coffee table book depending on how much you give. 76 | 77 | ### User Access Control 78 | 79 | Work with a team? Give each user level permission to access only the fundraising features they need. From managing users and fundraisers to pledges and settings. 80 | 81 | ### Crowdfunding Network 82 | 83 | Fundraising is built to work with WordPress, Multisite and BuddyPress. Get creative and pair Fundraising with other well-coded plugins – like [Pro Sites](http://premium.wpmudev.org/project/pro-sites/ "Pro Sites"). Build and host your own awesome crowdfunding network. Charge a premium for the ability to run campaigns. 84 | -------------------------------------------------------------------------------- /styles/wdf-basic.css: -------------------------------------------------------------------------------- 1 | .wdf-basic input.wdf_pledge_amount { 2 | width: auto; 3 | margin: 0 0 3px 0; 4 | } 5 | 6 | .wdf-basic .wdf_levels { 7 | clear: both; 8 | list-style: none; 9 | margin: 0 0 0 10px; 10 | background-color: #EEE; 11 | background-repeat: repeat-x; 12 | background-image: -moz-linear-gradient(top, whiteSmoke 0%, #EEE 100%); 13 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,whiteSmoke), color-stop(100%,#EEE)); 14 | background-image: -webkit-linear-gradient(top, whiteSmoke 0%,#EEE 100%); 15 | background-image: -ms-linear-gradient(top, whiteSmoke 0%,#EEE 100%); 16 | background-image: -o-linear-gradient(top, whiteSmoke 0%,#EEE 100%); 17 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#eeeeee',GradientType=0 ); 18 | background-image: linear-gradient(top, whiteSmoke 0%,#EEE 100%); 19 | border: 1px solid #E5E5E5; 20 | -webkit-border-radius: 4px; 21 | -moz-border-radius: 4px; 22 | border-radius: 4px; 23 | padding: 0; 24 | } 25 | .wdf-basic .wdf_levels li{ 26 | cursor: pointer; 27 | padding: 10px; 28 | margin: 0 10px; 29 | } 30 | .wdf-basic .wdf_levels li.item:hover { 31 | background: #fff; 32 | -webkit-border-radius: 5px; 33 | -moz-border-radius: 5px; 34 | border-radius: 5px; 35 | cursor: pointer; 36 | } 37 | .wdf-basic .wdf_content { 38 | float: left; 39 | width: 65%; 40 | padding: 0px; 41 | margin: 0px; 42 | } 43 | .wdf-basic .wdf_send_amount { 44 | width: 50px; 45 | } 46 | .wdf-basic .wdf_progress_info { 47 | margin-bottom: 10px; 48 | font-style: italic; 49 | font-size: 1.4em; 50 | } 51 | 52 | .wdf-basic .wdf_level_amount { 53 | font-weight: bold; 54 | line-height:1em; 55 | } 56 | .wdf-basic .wdf_send_donation, 57 | .wdf-basic .wdf_button { 58 | margin-top: 10px; 59 | color: #75ab24; 60 | cursor: pointer; 61 | display: inline-block; 62 | background-color: #e6e6e6; 63 | background-repeat: no-repeat; 64 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), color-stop(25%, #ffffff), to(#e6e6e6)); 65 | background-image: -webkit-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6); 66 | background-image: -moz-linear-gradient(top, #ffffff, #ffffff 25%, #e6e6e6); 67 | background-image: -ms-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6); 68 | background-image: -o-linear-gradient(#ffffff, #ffffff 25%, #e6e6e6); 69 | background-image: linear-gradient(#ffffff, #ffffff 25%, #e6e6e6); 70 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0); 71 | padding: 5px 9px 6px; 72 | text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); 73 | line-height: normal; 74 | border: 1px solid #ccc; 75 | border-bottom-color: #bbb; 76 | -webkit-border-radius: 4px; 77 | -moz-border-radius: 4px; 78 | border-radius: 4px; 79 | -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 80 | -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 81 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 82 | -webkit-transition: 0.1s linear all; 83 | -moz-transition: 0.1s linear all; 84 | -ms-transition: 0.1s linear all; 85 | -o-transition: 0.1s linear all; 86 | transition: 0.1s linear all; 87 | text-decoration:none; 88 | } 89 | .wdf-basic .wdf_send_donation:hover { 90 | background-position: 0 -26px; 91 | } 92 | .wdf-basic .wdf_levels .reward { 93 | font-weight: bold; 94 | } 95 | .wdf-basic.wdf_fundraiser_panel > div { 96 | margin: 10px 0px; 97 | } 98 | .wdf-basic .wdf_big_num { 99 | font-size: 2em; 100 | } 101 | .wdf-basic .ui-progressbar{ 102 | height: 1em; 103 | margin: 10px 0 0 0; 104 | } 105 | .wdf-basic div.wdf_backer_button { 106 | margin: 20px 0px 20px 0px; 107 | } 108 | .wdf-basic .wdf_reward_item { 109 | margin: 10px 0px 10px 0px; 110 | } 111 | .widget_wdf_fundraiser_panel .wdf-basic .wdf_level_amount { 112 | padding-right: 8px; 113 | } 114 | .wdf-basic .wdf_bp_show_on_activity { 115 | 116 | } 117 | .wdf-basic .wdf_reward_item { 118 | cursor: pointer; 119 | } 120 | .wdf-basic .wdf_reward_item_disabled { 121 | cursor: default !important; 122 | opacity: 0.7; 123 | } 124 | .wdf-basic .wdf_choose_reward_title { 125 | font-size: 2.5em; 126 | margin-top: 15px; 127 | } 128 | .wdf-basic .wdf_reward_limit { 129 | font-size: 0.7em; 130 | font-weight: normal; 131 | background: #fff7ce; 132 | display: inline-block; 133 | padding: 2px 4px; 134 | color: #000; 135 | margin: 2px; 136 | } 137 | .wdf-basic .wdf_reward_limit_gone { 138 | background: #f7d4d4; 139 | } -------------------------------------------------------------------------------- /lib/wdf_tutorials.php: -------------------------------------------------------------------------------- 1 | restart(); 8 | 9 | $tutorial->set_textdomain = 'wdf'; 10 | 11 | $tutorial->add_style(''); 12 | 13 | $tutorial->set_capability = 'wdf_edit_settings'; 14 | 15 | $tutorial->add_step(admin_url('admin.php?page=wdf'), 'funder_page_wdf', '#wdf-getting-started', __('Getting Started Is Easy', 'wdf'), array( 16 | 'content' => '

' . esc_js( __('Follow these tutorial steps to get your Fundraising project up and running quickly.', 'wdf') ) . '

', 17 | 'position' => array( 'edge' => 'top', 'align' => 'left' ), 18 | )); 19 | $tutorial->add_step(admin_url('edit.php?post_type=funder&page=wdf_settings&tab=payments'), 'funder_page_wdf_settings', '#wdf_settings_currency', __('Choose your currency', 'wdf'), array( 20 | 'content' => '

' . esc_js( __('Choose your preferred currency for your incoming donations.', 'wdf') ) . '

', 21 | 'position' => array( 'edge' => 'top', 'align' => 'left' ), 'post_type' => 'funder', 22 | )); 23 | $tutorial->add_step(admin_url('edit.php?post_type=funder&page=wdf_settings&tab=payments'), 'funder_page_wdf_settings', '#wdf_allowed_fundraier_types', __('Choose your allowed payment types.', 'wdf'), array( 24 | 'content' => '

' . esc_js( __('Simple payments act like regular donations. Advanced payments allow for the creation of Goals and Rewards. Advanced payments will only be approved initially. Approved payments will not process until the goal has been reached.', 'wdf') ) . '

', 25 | 'position' => array( 'edge' => 'left', 'align' => 'left' ), 'post_type' => 'funder', 26 | )); 27 | if(!get_option('permalink_structure')) { 28 | $tutorial->add_step(admin_url('options-permalink.php'), 'options-permalink.php', '#permalink_structure', __('Turn On Permalinks', 'wdf'), array( 29 | 'content' => '

' . esc_js( __('Permalinks must been enabled and configured before your donation page can be seen publicly.', 'wdf') ) . '

', 30 | 'position' => array( 'edge' => 'top', 'align' => 'left' ), 31 | )); 32 | } 33 | $tutorial->add_step(admin_url('post-new.php?post_type=funder'), 'post-new.php', '#titlediv', __('Create your First Fundraiser', 'wdf'), array( 34 | 'content' => '

' . esc_js( __('Now that you have setup your presentation and payment settings you can create your first fundraiser. Start by adding a title.', 'wdf') ) . '

', 35 | 'position' => array( 'edge' => 'top', 'align' => 'left' ), 'post_type' => 'funder', 36 | )); 37 | $tutorial->add_step(admin_url('post-new.php?post_type=funder'), 'post-new.php', '#wdf_type', __('Choose a fundraising type', 'wdf'), array( 38 | 'content' => '

' . esc_js( __('This step is crucial to how your fundraiser will operate. Remember: Simple Donations process automatically but can not set goals or rewards. Advanced Crowdfunding allows for goals and rewards but will only be approved until the goal has been reached. After you save your fundraising type you will have additional options depending on your choice. Enjoy!', 'wdf') ) . '

', 39 | 'position' => array( 'edge' => 'right', 'align' => 'left' ), 'post_type' => 'funder', 40 | )); 41 | /*$tutorial->add_step(admin_url('post-new.php?post_type=funder'), 'post-new.php', '#wdf_levels_table', __('Recommend Donation Levels', 'wdf'), array( 42 | 'content' => '

' . esc_js( __('You can recommend donation levels to your visitors, provide a title, short description, and dollar amount for each level you create.', 'wdf') ) . '

', 43 | 'position' => array( 'edge' => 'bottom', 'align' => 'right' ), 'post_type' => 'funder', 44 | )); 45 | $tutorial->add_step(admin_url('post-new.php?post_type=funder'), 'post-new.php', '#wdf_messages', __('Create Thank You Messages and Emails', 'wdf'), array( 46 | 'content' => '

' . esc_js( __('Send the user back to a specific url, any post or page ID, or enter a custom thank you message customizable with shortcodes.', 'wdf') ) . '

', 47 | 'position' => array( 'edge' => 'bottom', 'align' => 'right' ), 'post_type' => 'funder', 48 | )); 49 | $tutorial->add_step(admin_url('post-new.php?post_type=funder'), 'post-new.php', '#wdf_style', __('Choose A Style', 'wdf'), array( 50 | 'content' => '

' . esc_js( __('Choose a style that best fits your site, or apply no styles and use your own custom css.', 'wdf') ) . '

', 51 | 'position' => array( 'edge' => 'right', 'align' => 'left' ), 'post_type' => 'funder', 52 | )); 53 | $tutorial->add_step(admin_url('post-new.php?post_type=funder'), 'post-new.php', '#submitdiv', __('Publish or Save As Draft', 'wdf'), array( 54 | 'content' => '

' . esc_js( __('Publish your fundraiser, or save it as a draft. Now start fundraising! You can use the fundraiser url or insert the fundraising shortcodes directly into any page or post.', 'wdf')) . '

', 55 | 'position' => array( 'edge' => 'right', 'align' => 'left' ), 'post_type' => 'funder', 56 | ));*/ 57 | $tutorial->initialize(); 58 | ?> -------------------------------------------------------------------------------- /styles/wdf-fresh.css: -------------------------------------------------------------------------------- 1 | .wdf-fresh input.wdf_pledge_amount { 2 | width: auto; 3 | margin: 0 0 3px 0; 4 | } 5 | 6 | .wdf-fresh .wdf_levels { 7 | clear: both; 8 | list-style: none; 9 | margin: 10px 0 0 0; 10 | padding: 0; 11 | background-color: #EEE; 12 | background-repeat: repeat-x; 13 | background-image: -moz-linear-gradient(top, whiteSmoke 0%, #EEE 100%); 14 | background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,whiteSmoke), color-stop(100%,#EEE)); 15 | background-image: -webkit-linear-gradient(top, whiteSmoke 0%,#EEE 100%); 16 | background-image: -ms-linear-gradient(top, whiteSmoke 0%,#EEE 100%); 17 | background-image: -o-linear-gradient(top, whiteSmoke 0%,#EEE 100%); 18 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f5f5', endColorstr='#eeeeee',GradientType=0 ); 19 | background-image: linear-gradient(top, whiteSmoke 0%,#EEE 100%); 20 | border: 1px solid #E5E5E5; 21 | -webkit-border-radius: 4px; 22 | -moz-border-radius: 4px; 23 | border-radius: 4px; 24 | padding: 10px; 25 | } 26 | .wdf-fresh .wdf_levels li{ 27 | cursor: pointer; 28 | padding: 10px; 29 | margin: 0 10px; 30 | } 31 | .wdf-fresh .wdf_levels li.item:hover { 32 | background: #fff; 33 | -webkit-border-radius: 5px; 34 | -moz-border-radius: 5px; 35 | border-radius: 5px; 36 | cursor: pointer; 37 | } 38 | .wdf-fresh .wdf_content { 39 | margin: 0; 40 | padding 0; 41 | } 42 | .wdf-fresh .wdf_send_amount { 43 | width: 50px; 44 | } 45 | .wdf-fresh .wdf_progress_info { 46 | margin-bottom: 10px; 47 | font-style: italic; 48 | font-size: 1.4em; 49 | } 50 | .wdf-fresh .wdf_donate_now input[type="text"], textarea { 51 | margin: 0 0 0 5px; 52 | -webkit-border-radius: 5px; 53 | -moz-border-radius: 5px; 54 | border-radius: 5px; 55 | } 56 | .wdf-fresh .wdf_level_amount { 57 | } 58 | .wdf-fresh .wdf_button, 59 | .wdf-fresh .wdf_send_donation { 60 | color: #333; 61 | cursor: pointer; 62 | display: inline-block; 63 | background-color: #5BB75B; 64 | background-image: -moz-linear-gradient(top, #62C462, #51A351); 65 | background-image: -ms-linear-gradient(top, #62C462, #51A351); 66 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#62C462), to(#51A351)); 67 | background-image: -webkit-linear-gradient(top, #62C462, #51A351); 68 | background-image: -o-linear-gradient(top, #62C462, #51A351); 69 | background-image: linear-gradient(top, #62C462, #51A351); 70 | background-repeat: repeat-x; 71 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462', endColorstr='#51a351', GradientType=0); 72 | border-color: #51A351 #51A351 #387038; 73 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 74 | padding: 5px 9px 6px; 75 | text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); 76 | line-height: normal; 77 | border: 1px solid #5BB75B; 78 | -webkit-border-radius: 4px; 79 | -moz-border-radius: 4px; 80 | border-radius: 4px; 81 | -webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 82 | -moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 83 | box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); 84 | -webkit-transition: 0.1s linear all; 85 | -moz-transition: 0.1s linear all; 86 | -ms-transition: 0.1s linear all; 87 | -o-transition: 0.1s linear all; 88 | transition: 0.1s linear all; 89 | text-decoration:none; 90 | } 91 | .wdf-fresh .wdf_send_donation:hover, 92 | .wdf-fresh .wdf_button:hover { 93 | 94 | } 95 | .wdf-fresh .wdf_levels .reward { 96 | font-weight: bold; 97 | padding-left: 30px; 98 | } 99 | .wdf-fresh. wdf_send_donation:hover { 100 | background: #6eb850; 101 | } 102 | .wdf-fresh.wdf_fundraiser_panel > div { 103 | margin: 10px 0px; 104 | } 105 | .wdf-fresh .wdf_big_num { 106 | font-size: 2em; 107 | } 108 | .wdf-fresh .ui-progressbar{ 109 | height: 1em; 110 | margin: 10px 0 0 0; 111 | } 112 | .wdf-fresh div.wdf_backer_button { 113 | margin: 20px 0px 20px 0px; 114 | } 115 | .wdf-fresh .wdf_reward_item { 116 | margin: 10px 0px 10px 0px; 117 | } 118 | .wdf_fundraiser_panel.wdf-fresh .wdf_level_amount { 119 | } 120 | .wdf-fresh .wdf_bp_show_on_activity { 121 | 122 | } 123 | .wdf-fresh .wdf_reward_item { 124 | cursor: pointer; 125 | } 126 | .wdf-fresh .wdf_reward_item_disabled { 127 | cursor: default !important; 128 | opacity: 0.7; 129 | } 130 | .wdf_fundraiser_panel.wdf-fresh .wdf_reward_item { 131 | padding: 0px; 132 | } 133 | .wdf-fresh .wdf_choose_reward_title { 134 | font-size: 2.5em; 135 | margin-top: 15px; 136 | } 137 | .wdf-fresh .ui-progressbar{ 138 | height: 1em; 139 | margin: 10px 0 0 0; 140 | } 141 | .wdf-fresh .wdf_reward_limit { 142 | font-size: 0.7em; 143 | font-weight: normal; 144 | background: #fff7ce; 145 | display: inline-block; 146 | padding: 2px 4px; 147 | color: #000; 148 | margin: 2px; 149 | } 150 | .wdf-fresh .wdf_reward_limit_gone { 151 | background: #f7d4d4; 152 | } -------------------------------------------------------------------------------- /lib/bp/bp-wdf-admin.php: -------------------------------------------------------------------------------- 1 | 50 |
51 |

52 |
53 | 54 |

" . __('Settings Updated.', 'wdf') . "

" ?> 55 | 56 |
57 | 58 | 59 | 60 | 61 | 64 | 65 | 66 | 69 | 70 |
62 | 63 |
67 | 68 |
71 |

72 | 73 |

74 | 75 | 79 |
80 | 81 | charset) ) 106 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; 107 | 108 | /** 109 | * If you want to create new tables you'll need to install them on 110 | * activation. 111 | * 112 | * You should try your best to use existing tables if you can. The 113 | * activity stream and meta tables are very flexible. 114 | * 115 | * Write your table definition below, you can define multiple 116 | * tables by adding SQL to the $sql array. 117 | */ 118 | $sql = array(); 119 | $sql[] = "CREATE TABLE IF NOT EXISTS {$wpdb->base_prefix}bp_wdf ( 120 | id bigint(20) NOT NULL AUTO_INCREMENT PRIMARY KEY, 121 | funder_id bigint(20) NOT NULL, 122 | recipient_id bigint(20) NOT NULL, 123 | date_notified datetime NOT NULL, 124 | KEY funder_id (funder_id), 125 | KEY recipient_id (recipient_id) 126 | ) {$charset_collate};"; 127 | 128 | //require_once( ABSPATH . 'wp-admin/upgrade.php' ); 129 | 130 | /** 131 | * The dbDelta call is commented out so the wdf table is not installed. 132 | * Once you define the SQL for your new table, uncomment this line to install 133 | * the table. (Make sure you increment the BP_WDF_DB_VERSION constant though). 134 | */ 135 | dbDelta($sql); 136 | 137 | update_site_option( 'bp-wdf-db-version', BP_WDF_DB_VERSION ); 138 | } 139 | //add_action( 'admin_init', 'bp_wdf_install_tables' ); 140 | ?> -------------------------------------------------------------------------------- /js/wdf-post.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready( function($) { 2 | 3 | $('form#post').submit(function(e){ 4 | if($('#titlediv input').val() == '') { 5 | e.preventDefault(); 6 | alert(wdf.title_remind); 7 | return false; 8 | } 9 | 10 | }); 11 | 12 | 13 | $('#wdf_type input').change(function(e){ 14 | if($(this).val() == 'simple') { 15 | $('#wdf_has_goal').prop("disabled", false).val('0').trigger("change"); 16 | $('#wdf_recurring').show(); 17 | } 18 | else { 19 | $('#wdf_has_goal').prop("disabled", true).val('1').trigger("change"); 20 | $('#wdf_recurring').hide(); 21 | } 22 | }); 23 | 24 | 25 | var dates = $( "#wdf_goal_start_date, #wdf_goal_end_date" ).datepicker({ 26 | dateFormat: 'yy-mm-dd', 27 | changeMonth: true, 28 | numberOfMonths: 2, 29 | }); 30 | 31 | //$('.wdf_level .wdf_check_switch').live('change', function(e) { 32 | // if($(this).is(':checked')) { 33 | // $(this).parents('.wdf_level').next('tr').find('div.wdf_reward_toggle').slideDown(400); 34 | // } else { 35 | // $(this).parents('.wdf_level').next('tr').find('div.wdf_reward_toggle').slideUp(400); 36 | // } 37 | //}); 38 | 39 | //Fire fixDelete() on load 40 | fixDelete(); 41 | 42 | //Delete Level Line Item 43 | $('#wdf_levels_table').on('click', "#wdf_add_level", function(e){ 44 | e.preventDefault(); 45 | var current = returnNameIndex($('#wdf_levels_table tr.wdf_level.last').find('input:first').attr('name')); 46 | var newi = parseInt(current) + 1; 47 | $('#wdf_level_index').val(parseInt($('#wdf_level_index').val()) + 1); 48 | var template = $('tr[rel="wdf_level_template"]').clone().removeAttr('rel').show(); 49 | var level = template.filter('tr:first').addClass('wdf_level'); 50 | //Replace the name for all inputs with the appropriate index 51 | $.each($(template).find(':input'), function(i,e) { 52 | var rel = $(e).attr('rel'); 53 | $(e).attr('name',rel.replace('wdf[levels][','wdf[levels][' + String(newi))) 54 | $(e).removeAttr('rel'); 55 | }); 56 | $('tr[rel="wdf_level_template"]:first').before(template); 57 | fixDelete(); 58 | 59 | $('.wdf_level.last .delete a').click(function(e) { 60 | e.preventDefault(); 61 | var reward = $(this).parents('tr.wdf_level.last').next('tr.wdf_reward_options'); 62 | $(this).parents('tr.wdf_level.last').add(reward).remove(); 63 | fixDelete(); 64 | }); 65 | return false; 66 | }); 67 | $('#wdf_levels_table').on('click', ".wdf_level.last .delete a", function(e){ 68 | e.preventDefault(); 69 | var reward = $(this).parents('tr.wdf_level.last').next('tr.wdf_reward_options'); 70 | $(this).parents('tr.wdf_level.last').add(reward).remove(); 71 | fixDelete(); 72 | return false; 73 | }); 74 | 75 | $('.postbox-container').on('click', "#tooltip_submit", function(){ 76 | $('#publish').trigger('click'); 77 | return false; 78 | }); 79 | 80 | function fixDelete() { 81 | if($('#wdf_levels_table tbody .wdf_level').length < 1){ 82 | return false; 83 | } 84 | $('#wdf_levels_table tbody .wdf_level').removeClass('last'); 85 | $('#wdf_levels_table tbody .wdf_level:last').addClass('last'); 86 | fixInputs(); 87 | } 88 | 89 | function returnNameIndex(string) { 90 | if($('#wdf_levels_table tr.wdf_level').length > 9) 91 | return string.substr(12,2); 92 | else 93 | return string.substr(12,1); 94 | } 95 | 96 | $('.wdf_actvity_level').hover( function() { 97 | $(this).find('td:last a').show(); 98 | }, function() { 99 | $(this).find('td:last a').hide(); 100 | }); 101 | $('.wdf_goal_progress').progressbar({ 102 | value: 0, 103 | create: function() { 104 | $(this).progressbar( "option", "value", Math.round( parseInt( $(this).attr('total') * 100) ) / parseInt( $(this).attr('goal') ) ); 105 | } 106 | }); 107 | 108 | function fixInputs() { 109 | var input_switches = $('.wdf_input_switch'); 110 | 111 | $.each(input_switches, function(i,elm) { 112 | if(elm.localName == 'textarea') { 113 | var current = $(elm).html(); 114 | } else if(elm.localName == 'input') { 115 | var current = $(elm).val(); 116 | } 117 | $(elm).bind('focusin focusout', function(e) { 118 | 119 | if(e.type == 'focusout') { 120 | $(elm).prev('.wdf_bignum').addClass('wdf_disabled'); 121 | } else { 122 | $(elm).prev('.wdf_bignum').removeClass('wdf_disabled'); 123 | } 124 | }); 125 | }); 126 | } 127 | //run fix_inputs() on load 128 | fixInputs(); 129 | 130 | $('select.wdf_toggle').bind('change', function(e) { 131 | var rel = $(this).attr('rel'); 132 | var val = $(this).val(); 133 | if(rel == 'wdf_has_goal' && val == '1') { 134 | var elm = $('*[rel="'+rel+'"]').not(this); 135 | elm.show(); 136 | } else if(rel == 'wdf_has_reward') { 137 | var elm = $('*[rel="'+rel+'"]').not(this); 138 | if(val == '1') { 139 | elm.show(); 140 | } else { 141 | elm.hide(); 142 | } 143 | } else if(rel == 'wdf_collect_address') { 144 | var elm = $('*[rel="'+rel+'"]').not(this); 145 | if(val == '1') { 146 | elm.show(); 147 | } else { 148 | elm.hide(); 149 | } 150 | } else if(rel == 'wdf_thanks_type') { 151 | $('*[rel="'+rel+'"]').not(this).hide(1, function() { 152 | $('.wdf_thanks_'+val+'[rel="'+rel+'"]').show(); 153 | }); 154 | } else if(rel == 'wdf_has_goal' && val == '0') { 155 | var elm = $('*[rel="'+rel+'"]').not(this); 156 | elm.hide(); 157 | } else if(rel == 'wdf_send_email') { 158 | if(val == '1') 159 | $('*[rel="'+rel+'"]').not(this).show(); 160 | else 161 | $('*[rel="'+rel+'"]').not(this).hide(); 162 | } else if(rel == 'wdf_recurring') { 163 | if(val == 'yes') 164 | $('*[rel="'+rel+'"]').not(this).show(); 165 | else 166 | $('*[rel="'+rel+'"]').not(this).hide(); 167 | } 168 | }); 169 | 170 | }); -------------------------------------------------------------------------------- /css/wdf-admin.css: -------------------------------------------------------------------------------- 1 | #wdf_levels_table .wdf_level .delete > * { 2 | display: none; 3 | } 4 | #wdf_levels_table .wdf_level.last .delete > * { 5 | display: block; 6 | } 7 | #wdf_levels_table .wdf_level.last:first-child .delete > * { 8 | display: none; 9 | } 10 | #wdf_levels_table .delete { 11 | width: 65px; 12 | vertical-align: middle; 13 | } 14 | #wdf_levels_table td.delete span.wdf_ico_del{ 15 | height: 10px; 16 | width: 10px; 17 | left: -5px; 18 | position: relative; 19 | display: block; 20 | float: left; 21 | top: 2px; 22 | background-repeat: no-repeat; 23 | background-position: top left; 24 | } 25 | #wdf_levels_table .wdf_level.last a:hover > span.wdf_ico_del { 26 | background-position: top right; 27 | } 28 | #icon-wdf-admin, 29 | #icon-edit { 30 | background: url(../img/icon_32.png); 31 | } 32 | .wdf_goal_progress.column.ui-progressbar { 33 | width: 122px; 34 | height: 17px; 35 | } 36 | .column-donation_amount { 37 | width: 100px; 38 | } 39 | .column-funder_pledges { 40 | width: 65px; 41 | } 42 | .column-funder_raised { 43 | width: 150px; 44 | } 45 | .column-funder_time_left { 46 | width: 160px; 47 | } 48 | .welcome-panel .wp-badge { 49 | background: url(../img/donate.jpg) no-repeat center center; 50 | } 51 | span.special { 52 | padding-right: 5px; 53 | font-weight: 700; 54 | } 55 | .wdf_actvity_edit { 56 | width: 75px; 57 | } 58 | .wdf_actvity_level:hover { 59 | background: #eaeaea; 60 | } 61 | td.wdf_actvity_edit a { 62 | display: none; 63 | } 64 | #wdf_goal, 65 | .wdf_biginput { 66 | width: 90%; 67 | height: 40px; 68 | } 69 | #wdf_options .wdf_biginput { 70 | width: 58%; 71 | } 72 | #wdf_goal, 73 | .wdf_bignum { 74 | line-height: 30px; 75 | font-size: 24px; 76 | font-weight: 700; 77 | } 78 | .wdf_level_title .wdf_bignum { 79 | font-size: 16px; 80 | } 81 | #wdf_options .wdf_bignum { 82 | padding-right: 8px; 83 | } 84 | tr.wdf_level > td { 85 | border-bottom-color: #F5F5F5; 86 | } 87 | .wdf_level_title { 88 | width: 180px 89 | } 90 | .wdf_level_description { 91 | 92 | } 93 | .wdf_level_amount, .wdf_level_limit { 94 | width: 100px; 95 | } 96 | .wdf_level_reward { 97 | width: 110px; 98 | } 99 | td.wdf_level_reward { 100 | vertical-align: middle; 101 | text-align: center; 102 | } 103 | th.wdf_level_reward { 104 | text-align: center; 105 | } 106 | .wdf_level_description { 107 | 108 | } 109 | .wdf_level_amount input { 110 | width: 75px; 111 | } 112 | .wdf_level_description textarea { 113 | width:100%; 114 | height: 100px; 115 | } 116 | #wdf_goal, 117 | #wdf_goal_amount, 118 | #wdf_levels_table input, 119 | #wdf_levels_table textarea, 120 | .wdf_input_switch, 121 | #wdf_goal.wdf_disabled, 122 | #wdf_options .wdf_bignum.wdf_disabled, 123 | .wdf_bignum.wdf_disabled { 124 | color: #999; 125 | } 126 | #wdf_goal:focus, 127 | #wdf_goal_amount:focus, 128 | #wdf_levels_table input:focus, 129 | #wdf_levels_table textarea:focus, 130 | #wdf_options .wdf_bignum, 131 | .wdf_input_switch:focus { 132 | color: #555; 133 | } 134 | .wdf_complete { 135 | color: #0C0; 136 | } 137 | td.column-funder_raised .wdf_complete { 138 | font-weight: bold; 139 | } 140 | #wdf_progress .ui-progressbar-value.wdf_complete { 141 | 142 | } 143 | #wdf_steps li { 144 | line-height: 30px; 145 | border-bottom: 1px solid #DDD; 146 | font-weight: bold; 147 | text-shadow: -1px -1px 0px white; 148 | } 149 | #wdf_steps a.wdf_goto_step { 150 | float: right; 151 | } 152 | #wdf_video_url { 153 | width: 100%; 154 | } 155 | .post-new-php .donationstutorial-pointer.wp-pointer-right { 156 | 157 | } 158 | .column-funder_raised { 159 | width: 150px; 160 | } 161 | .column-funder_thumb { 162 | width: 80px; 163 | } 164 | #wdf_activity td { 165 | vertical-align: middle; 166 | } 167 | td.column-funder_pledges { 168 | vertical-align: middle; 169 | } 170 | #wdf_thanks_custom, #wdf_collect_address_message { 171 | width: 100%; 172 | height: 100px; 173 | } 174 | #wdf_email_msg { 175 | width: 100%; 176 | height: 287px; 177 | } 178 | .wdf_goal_amount { 179 | width: 150px; 180 | } 181 | td.wdf_goal_amount input { 182 | width: 120px; 183 | } 184 | .wdf_goal_start_date, 185 | .wdf_goal_end_date { 186 | width: 165px; 187 | } 188 | td.wdf_goal_start_date input, 189 | td.wdf_goal_end_date input { 190 | background-repeat: no-repeat; 191 | background-position: 8px 12px; 192 | padding-left: 35px; 193 | width: 140px; 194 | } 195 | .wp-list-table #funder_type { 196 | width: 150px; 197 | } 198 | .wdf_widget_highlite .widget-title, 199 | .wdf_widget_highlite .widget-title h4, 200 | .wdf_widget_highlite.widget { 201 | border-color: #003!important; 202 | } 203 | .wdf_widget_highlite .widget-top { 204 | color: white!important; 205 | text-shadow: 0 -1px 0 #000000!important; 206 | border-color: #003!important; 207 | moz-box-shadow: none!important; 208 | -webkit-box-shadow: none!important; 209 | box-shadow: none!important; 210 | background: rgb(7,67,112)!important; /* Old browsers */ 211 | background: -moz-linear-gradient(top, rgba(7,67,112,1) 0%, rgba(5,50,84,1) 100%)!important; /* FF3.6+ */ 212 | background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(7,67,112,1)), color-stop(100%,rgba(5,50,84,1)))!important; /* Chrome,Safari4+ */ 213 | background: -webkit-linear-gradient(top, rgba(7,67,112,1) 0%,rgba(5,50,84,1) 100%)!important; /* Chrome10+,Safari5.1+ */ 214 | background: -o-linear-gradient(top, rgba(7,67,112,1) 0%,rgba(5,50,84,1) 100%)!important; /* Opera 11.10+ */ 215 | background: -ms-linear-gradient(top, rgba(7,67,112,1) 0%,rgba(5,50,84,1) 100%)!important; /* IE10+ */ 216 | background: linear-gradient(top, rgba(7,67,112,1) 0%,rgba(5,50,84,1) 100%)!important; /* W3C */ 217 | filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#074370', endColorstr='#053254',GradientType=0 )!important; /* IE6-9 */ 218 | } 219 | ul.wdf_shortcode_breakdown li p.attr_description { 220 | padding-left: 35px; 221 | } 222 | ul.wdf_shortcode_breakdown code { 223 | font-size: 1.25em; 224 | } 225 | .wdf_shortcode_ss { 226 | float:right; 227 | } 228 | #wdf_permissions { 229 | width: auto; 230 | } 231 | 232 | h1.wdf_goal { 233 | line-height: 1.0em; 234 | } -------------------------------------------------------------------------------- /lib/form.blog_dashboard.php: -------------------------------------------------------------------------------- 1 |
2 |

3 |

4 |

5 |
6 | 7 | 8 |
9 |

10 |
11 |
12 |

13 |
14 |
    15 |
  1. 16 |
  2. 17 |
  3. 18 |
19 |
20 |
21 | 22 | 23 |
24 |

25 |
26 |

27 |
    28 |
  • 29 |

    30 |

    31 | [fundraiser_panel id="" style="" show_title="" show_content=""] 32 |

    id:

    33 |

    style:

    34 |

    show_title:

    35 |

    show_content:

    36 |
  • 37 |
  • 38 |

    39 |

    40 | [donate_button title="" description="" donation_amount="" button_type="default/custom" style="" button_text="" show_cc="yes/no" small_button="yes/no" paypal_email=""] 41 | 42 |

    title:

    43 |

    description:

    44 |

    donation_amount:

    45 |

    button_type:

    46 |

    style:

    47 |

    button_text:

    48 |

    type:

    49 |
  • 50 |
  • 51 |

    52 |

    53 | [progress_bar id="" style="" show_title="yes/no" show_totals="yes/no"] 54 |

    id:

    55 |

    style:

    56 |

    show_title:

    57 |

    show_totals:

    58 |
  • 59 |
60 |
61 |
62 | 63 | 64 |
65 |

66 |
67 |
68 | 69 | 70 |
71 |
72 |
73 | 74 | 75 |
76 |
-------------------------------------------------------------------------------- /lib/widgets/widget.pledges_panel.php: -------------------------------------------------------------------------------- 1 | sprintf(__('If the current page is a single %1$s page then this panel will display recent %2$s for the %1$s. You can also use it to display information for a specific %1$s or all','wdf'),esc_attr($settings['funder_labels']['singular_name']),esc_attr($settings['donation_labels']['plural_name'])) 14 | ) ); 15 | } 16 | 17 | function widget( $args, $instance ) { 18 | // Widget output 19 | global $wp_query, $wdf; 20 | 21 | if($instance['single_fundraiser'] == '1') { 22 | $donations = $wdf->get_pledge_list($instance['funder']); 23 | if($donations) { 24 | // Specific Single Fundraiser 25 | $content = $args['before_widget']; 26 | 27 | if(isset($instance['title']) && !empty($instance['title'])) 28 | $content .= $args['before_title'] . esc_attr(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 29 | 30 | $content .= wdf_pledges_panel( false, $instance['funder'], 'widget', $instance ); 31 | $content .= $args['after_widget']; 32 | echo $content; 33 | } 34 | } else { 35 | if($wp_query->query_vars['post_type'] == 'funder' && $wp_query->is_single && (!isset($wp_query->query_vars['funder_checkout']) || $wp_query->query_vars['funder_checkout'] != '1') && (!isset($wp_query->query_vars['funder_confirm']) || $wp_query->query_vars['funder_confirm'] != '1') ) { 36 | $donations = $wdf->get_pledge_list($wp_query->posts[0]->ID); 37 | if($donations) { 38 | // Single Fundraiser Page 39 | $content = $args['before_widget']; 40 | 41 | if(isset($instance['title']) && !empty($instance['title'])) 42 | $content .= $args['before_title'] . esc_attr(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 43 | 44 | $content .= wdf_pledges_panel( false, $wp_query->posts[0]->ID, 'widget', $instance ); 45 | $content .= $args['after_widget']; 46 | echo $content; 47 | } 48 | } 49 | } 50 | } 51 | 52 | function update( $new_instance, $old_instance ) { 53 | 54 | $instance = $old_instance; 55 | $instance['title'] = esc_attr($new_instance['title']); 56 | $instance['sort_type'] = esc_attr($new_instance['sort_type']); 57 | $instance['number_pledges'] = absint($new_instance['number_pledges']); 58 | $instance['single_fundraiser'] = esc_attr($new_instance['single_fundraiser']); 59 | $instance['funder'] = esc_attr( absint($new_instance['funder']) ); 60 | 61 | return $instance; 62 | } 63 | 64 | function form( $instance ) { 65 | global $wdf; 66 | $settings = get_option('wdf_settings'); 67 | 68 | $instance_defaults = array( 'title', 'number_pledges', 'style', 'single_fundraiser', 'funder', 'sort_type' ); 69 | foreach($instance_defaults as $instance_default) 70 | if(!isset($instance[$instance_default])) 71 | $instance[$instance_default] = ''; 72 | ?> 73 |

74 |
75 | 76 |

77 |

78 | 79 | 80 |

81 |

82 | 83 | 87 |

88 | 89 |

90 | 91 | 95 |

96 | 97 |
> 98 | 99 | -1, 'post_type' => 'funder', 'post_status' => 'publish'); ?> 100 | 101 | 102 |

103 |
107 | 108 |
112 | 113 |

114 | 115 |

116 | 117 |
118 | '; 66 | $pre .= sprintf( '

'.__('Your pledge of %s is almost complete.','wdf').'

',$wdf->format_currency('',$_SESSION['wdf_pledge']) /*. ' ' .($_SESSION['wdf_recurring'] != '0' ? 'every ' . $_SESSION['wdf_recurring'] : '')*/ ); 67 | if(isset($wdf->wdf_error) && $wdf->wdf_error == true) { 68 | $pre .= apply_filters('wdf_error_gateway',''); 69 | } 70 | $pre .= ''; 71 | 72 | $new = apply_filters('wdf_pre_payment_form',$pre); 73 | $new .= '
'; 74 | $new .= $content; 75 | $new .= ''; 76 | 77 | $new .= ''; 78 | $new .= '
'; 79 | 80 | return $new; 81 | } 82 | function _pre_process() { 83 | 84 | if( !isset($_SESSION['funder_id']) || !isset($_SESSION['wdf_pledge']) || !isset($_SESSION['wdf_gateway']) || !isset($_SESSION['wdf_step']) ) { 85 | $this->create_gateway_error(__('There was an unknown problem processing your payment.','wdf')); 86 | } 87 | } 88 | function create_gateway_error($msg) { 89 | global $wdf; 90 | $wdf->create_error($msg, 'gateway'); 91 | } 92 | function __construct() { 93 | 94 | 95 | $settings = get_option('wdf_settings'); 96 | 97 | add_action('wdf_gateway_settings_form_'.$this->plugin_name, array(&$this,'admin_settings')); 98 | add_action('wdf_gateway_plugins_loaded', array(&$this,'save_gateway_settings')); 99 | 100 | add_action('wdf_gateway_pre_process_'.$this->plugin_name, array(&$this,'_pre_process'), 10); 101 | add_action('wdf_gateway_process_simple_'.$this->plugin_name, array(&$this,'process_simple'), 10); 102 | add_action('wdf_gateway_process_standard_'.$this->plugin_name, array(&$this,'process_standard'), 10); 103 | add_action('wdf_gateway_process_advanced_'.$this->plugin_name, array(&$this,'process_advanced'), 10); 104 | add_action('wdf_gateway_confirm_'.$this->plugin_name, array(&$this, 'confirm'), 10); 105 | add_action('wdf_execute_payment_'.$this->plugin_name, array(&$this, 'execute_payment'), 10, 3); 106 | 107 | //Handle all our Instant Notifications 108 | add_action( 'init', array( &$this, 'add_rewrite_rules' ), 1 ); 109 | add_action( 'init', array( &$this, 'add_rewrite_tags' ), 1 ); 110 | add_action( 'pre_get_posts', array( &$this, 'handle_payment_return'), 1 ); 111 | $this->ipn_url = apply_filters('wdf_payment_return_url_' . $this->plugin_name, (get_option('permalink_structure') ? trailingslashit(home_url('wdf-payment-return/' . esc_attr($this->plugin_name))) : home_url('index.php?paymentgateway=' . esc_attr($this->plugin_name))) ); 112 | add_action( 'wp_ajax_nopriv_wdf-ipn-return-'.$this->plugin_name, array(&$this,'handle_ipn') ); 113 | add_action( 'wdf_gateway_handle_payment_return_'.$this->plugin_name, array(&$this,'handle_ipn') ); 114 | 115 | // This is the gateway form 116 | add_filter('wdf_checkout_payment_form_'.$this->plugin_name, array(&$this,'payment_form'), 10); 117 | // This is the gateway form wrapper. Notice the priorities 118 | add_filter('wdf_checkout_payment_form_'.$this->plugin_name, array(&$this,'_payment_form_wrapper'), 20); 119 | add_filter('wdf_gateway_payment_info_' . $this->plugin_name, array(&$this,'payment_info'), 10, 2 ); 120 | $this->on_creation(); 121 | } 122 | 123 | public function handle_payment_return( $wp_query ) { 124 | if( ! empty( $wp_query->query_vars['paymentgateway'] ) ) { 125 | do_action( 'wdf_gateway_handle_payment_return_' . $wp_query->query_vars['paymentgateway'] ); 126 | } 127 | } 128 | 129 | /** 130 | * Add rewrite rules. 131 | * 132 | * @since 2.6.1.3 133 | * @return void 134 | */ 135 | public function add_rewrite_rules() { 136 | add_rewrite_rule( 137 | '^wdf-payment-return/(.+)/?$', 138 | 'index.php?paymentgateway=$matches[1]', 139 | 'top' 140 | ); 141 | } 142 | 143 | /** 144 | * Add rewrite tags. 145 | * 146 | * @since 2.6.1.3 147 | * @return void 148 | */ 149 | public function add_rewrite_tags() { 150 | add_rewrite_tag( '%paymentgateway%', '(.+)' ); 151 | } 152 | } 153 | } 154 | /** 155 | * Use this function to register your gateway plugin class 156 | * 157 | * @param string $class_name - the case sensitive name of your plugin class 158 | * @param string $plugin_name - the sanitized private name for your plugin 159 | * @param string $admin_name - pretty name of your gateway, for the admin side. 160 | * @param array $payment_types - Array of allowed payment types for this gateway: Use 'simple' 'standard' 'advanced' 161 | */ 162 | function wdf_register_gateway_plugin($class_name, $plugin_name, $admin_name, $payment_types) { 163 | global $wdf_gateway_plugins; 164 | 165 | if (!is_array($wdf_gateway_plugins)) { 166 | $wdf_gateway_plugins = array(); 167 | } 168 | 169 | if (class_exists($class_name)) { 170 | $wdf_gateway_plugins[$plugin_name] = array($class_name, $admin_name, $payment_types); 171 | } else { 172 | return false; 173 | } 174 | } 175 | ?> -------------------------------------------------------------------------------- /lib/widgets/widget.simple_donation.php: -------------------------------------------------------------------------------- 1 | sprintf(__('Create a simple button for taking %s','wdf'),esc_attr($settings['donation_labels']['singular_name'])) 15 | ) ); 16 | } 17 | 18 | function widget( $args, $instance ) { 19 | // Widget output 20 | 21 | $content = $args['before_widget']; 22 | if(isset($instance['title']) && !empty($instance['title'])) 23 | $content .= $args['before_title'] . esc_attr(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 24 | $content .= '

' . esc_attr($instance['description']) . '

'; 25 | $content .= wdf_pledge_button(false,'widget_simple_donate',null,array('widget_args' => $instance)); 26 | $content .= $args['after_widget']; 27 | echo $content; 28 | } 29 | 30 | function update( $new_instance, $old_instance ) { 31 | 32 | $instance = $old_instance; 33 | $instance['title'] = esc_attr($new_instance['title']); 34 | $instance['description'] = esc_attr($new_instance['description']); 35 | $instance['thankyou_msg'] = esc_textarea($new_instance['thankyou_msg']); 36 | $instance['style'] = esc_attr($new_instance['style']); 37 | $instance['button_type'] = esc_attr($new_instance['button_type']); 38 | $instance['button_text'] = esc_attr($new_instance['button_text']); 39 | $instance['show_cc'] = esc_attr($new_instance['show_cc']); 40 | $instance['allow_note'] = esc_attr($new_instance['allow_note']); 41 | $instance['small_button'] = esc_attr($new_instance['small_button']); 42 | $instance['ref_label'] = esc_attr($new_instance['ref_label']); 43 | 44 | if($new_instance['donation_amount'] == '') 45 | unset($instance['donation_amount']); 46 | else 47 | $instance['donation_amount'] = round(preg_replace("/[^0-9.]/", "", $new_instance['donation_amount']), 2); 48 | 49 | if($new_instance['paypal_email'] == '') 50 | unset($instance['paypal_email']); 51 | else 52 | $instance['paypal_email'] = is_email($new_instance['paypal_email']); 53 | 54 | 55 | 56 | 57 | return $instance; 58 | } 59 | 60 | function form( $instance ) { 61 | $settings = get_option('wdf_settings'); 62 | global $wdf; 63 | ?> 64 |

65 |
66 |
68 | 70 |

71 |

72 | 73 | 74 |

75 |

76 | 77 | 78 |

79 | 80 |

81 |
82 | 83 |

84 | 85 | 86 |

87 | 88 | 95 |

96 |

97 | 98 | 99 |

100 | 101 | 102 |

103 | 104 | />
105 | 106 | />
107 | 108 | /> 109 |

110 | 111 | 112 |

113 |
114 | 115 |

116 | 117 |

118 |
119 |
120 | 121 |

122 | -------------------------------------------------------------------------------- /lib/bp/bp-wdf-notifications.php: -------------------------------------------------------------------------------- 1 | Notifications within a users profile page they will see 24 | * settings to turn off notifications for each component. 25 | * 26 | * You can plug your custom notification settings into this page, so that when your 27 | * component is active, the user will see options to turn off notifications that are 28 | * specific to your component. 29 | */ 30 | 31 | /** 32 | * Each option is stored in a posted array notifications[SETTING_NAME] 33 | * When saved, the SETTING_NAME is stored as usermeta for that user. 34 | * 35 | * For example, notifications[notification_friends_friendship_accepted] could be 36 | * used like this: 37 | * 38 | * if ( 'no' == get_user_meta( $bp->displayed_user->id, 'notification_friends_friendship_accepted', true ) ) 39 | * // don't send the email notification 40 | * else 41 | * // send the email notification. 42 | */ 43 | 44 | ?> 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 |
id, 'notification_wdf_action_one', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_wdf_action_one', true ) ) { ?>checked="checked" />id, 'notification_wdf_action_one') == 'no' ) { ?>checked="checked" />
id, 'notification_wdf_action_two', true ) || 'yes' == get_user_meta( $current_user->id, 'notification_wdf_action_two', true ) ) { ?>checked="checked" />id, 'notification_wdf_action_two', true ) ) { ?>checked="checked" />
74 | loggedin_user->id, $bp->wdf->slug, 'new_donation' ); 92 | } 93 | add_action( 'bp_wdf_screen_one', 'bp_wdf_remove_screen_notifications' ); 94 | add_action( 'xprofile_screen_display_profile', 'bp_wdf_remove_screen_notifications' ); 95 | 96 | 97 | /** 98 | * bp_wdf_format_notifications() 99 | * 100 | * The format notification function will take DB entries for notifications and format them 101 | * so that they can be displayed and read on the screen. 102 | * 103 | * Notifications are "screen" notifications, that is, they appear on the notifications menu 104 | * in the site wide navigation bar. They are not for email notifications. 105 | * 106 | * 107 | * The recording is done by using bp_core_add_notification() which you can search for in this file for 108 | * examples of usage. 109 | */ 110 | function bp_wdf_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) { 111 | global $bp; 112 | 113 | switch ( $action ) { 114 | case 'new_donation': 115 | /* In this case, $item_id is the user ID of the user who sent the high five. */ 116 | 117 | /*** 118 | * We don't want a whole list of similar notifications in a users list, so we group them. 119 | * If the user has more than one action from the same component, they are counted and the 120 | * notification is rendered differently. 121 | */ 122 | if ( (int)$total_items > 1 ) { 123 | return apply_filters( 'bp_wdf_multiple_new_donation_notification', '' . sprintf( __( '%d new high-fives, multi-five!', 'wdf' ), (int)$total_items ) . '', $total_items ); 124 | } else { 125 | $user_fullname = bp_core_get_user_displayname( $item_id, false ); 126 | $user_url = bp_core_get_user_domain( $item_id ); 127 | return apply_filters( 'bp_wdf_single_new_donation_notification', '' . sprintf( __('%s sent you a high-five!', 'wdf'), $user_fullname ) . '', $user_fullname ); 128 | } 129 | break; 130 | } 131 | 132 | do_action( 'bp_wdf_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 133 | 134 | return false; 135 | } 136 | 137 | /** 138 | * Notification functions are used to send email notifications to users on specific events 139 | * They will check to see the users notification settings first, if the user has the notifications 140 | * turned on, they will be sent a formatted email notification. 141 | * 142 | * You should use your own custom actions to determine when an email notification should be sent. 143 | */ 144 | 145 | function bp_wdf_send_donation_notification( $to_user_id, $from_user_id ) { 146 | global $bp; 147 | 148 | /* Let's grab both user's names to use in the email. */ 149 | $sender_name = bp_core_get_user_displayname( $from_user_id, false ); 150 | $reciever_name = bp_core_get_user_displayname( $to_user_id, false ); 151 | 152 | /* We need to check to see if the recipient has opted not to recieve high-five emails */ 153 | if ( 'no' == get_user_meta( (int)$to_user_id, 'notification_wdf_new_donation', true ) ) 154 | return false; 155 | 156 | /* Get the userdata for the reciever and sender, this will include usernames and emails that we need. */ 157 | $reciever_ud = get_userdata( $to_user_id ); 158 | $sender_ud = get_userdata( $from_user_id ); 159 | 160 | /* Now we need to construct the URL's that we are going to use in the email */ 161 | $sender_profile_link = site_url( BP_MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->profile->slug ); 162 | $sender_donation_link = site_url( BP_MEMBERS_SLUG . '/' . $sender_ud->user_login . '/' . $bp->wdf->slug . '/screen-one' ); 163 | $reciever_settings_link = site_url( BP_MEMBERS_SLUG . '/' . $reciever_ud->user_login . '/settings/notifications' ); 164 | 165 | /* Set up and send the message */ 166 | $to = $reciever_ud->user_email; 167 | $subject = '[' . get_blog_option( 1, 'blogname' ) . '] ' . sprintf( __( '%s high-fived you!', 'wdf' ), stripslashes($sender_name) ); 168 | 169 | $message = sprintf( __( 170 | '%s sent you a high-five! Why not send one back? 171 | 172 | To see %s\'s profile: %s 173 | 174 | To send %s a high five: %s 175 | 176 | --------------------- 177 | ', 'wdf' ), $sender_name, $sender_name, $sender_profile_link, $sender_name, $sender_donation_link ); 178 | 179 | $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'wdf' ), $reciever_settings_link ); 180 | 181 | // Send it! 182 | wp_mail( $to, $subject, $message ); 183 | } 184 | add_action( 'bp_wdf_send_donation', 'bp_wdf_send_donation_notification', 10, 2 ); 185 | 186 | ?> 187 | -------------------------------------------------------------------------------- /lib/bp/bp-wdf-classes.php: -------------------------------------------------------------------------------- 1 | 0, 38 | 'funder_id' => 0, 39 | 'recipient_id' => 0, 40 | 'date' => date( 'Y-m-d H:i:s' ) 41 | ); 42 | 43 | // Parse the defaults with the arguments passed 44 | $r = wp_parse_args( $args, $defaults ); 45 | extract( $r ); 46 | 47 | if ( $id ) { 48 | $this->id = $id; 49 | $this->populate( $this->id ); 50 | } else { 51 | foreach( $r as $key => $value ) { 52 | $this->{$key} = $value; 53 | } 54 | } 55 | } 56 | 57 | /** 58 | * populate() 59 | * 60 | * This method will populate the object with a row from the database, based on the 61 | * ID passed to the constructor. 62 | */ 63 | function populate() { 64 | global $wpdb, $bp, $creds; 65 | 66 | if ( $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$bp->wdf->table_name} WHERE id = %d", $this->id ) ) ) { 67 | $this->funder_id = $row->funder_id; 68 | $this->recipient_id = $row->recipient_id; 69 | $this->date = $row->date; 70 | } 71 | } 72 | 73 | /** 74 | * save() 75 | * 76 | * This method will save an object to the database. It will dynamically switch between 77 | * INSERT and UPDATE depending on whether or not the object already exists in the database. 78 | */ 79 | 80 | function save() { 81 | global $wpdb, $bp; 82 | 83 | /*** 84 | * In this save() method, you should add pre-save filters to all the values you are 85 | * saving to the database. This helps with two things - 86 | * 87 | * 1. Blanket filtering of values by plugins (for example if a plugin wanted to 88 | * force a specific value for all saves) 89 | * 90 | * 2. Security - attaching a wp_filter_kses() call to all filters, so you are not 91 | * saving potentially dangerous values to the database. 92 | * 93 | * It's very important that for number 2 above, you add a call like this for each 94 | * filter to 'bp-wdf-filters.php' 95 | * 96 | * add_filter( 'wdf_data_fieldname1_before_save', 'wp_filter_kses' ); 97 | */ 98 | 99 | $this->funder_id = apply_filters( 'bp_wdf_data_funder_id_before_save', $this->funder_id, $this->id ); 100 | $this->recipient_id = apply_filters( 'bp_wdf_data_recipient_id_before_save', $this->recipient_id, $this->id ); 101 | $this->date = apply_filters( 'bp_wdf_data_date_before_save', $this->date, $this->id ); 102 | 103 | // Call a before save action here 104 | do_action( 'bp_wdf_data_before_save', $this ); 105 | 106 | if ( $this->id ) { 107 | // Set up the arguments for wp_insert_post() 108 | $wp_update_post_args = array( 109 | 'ID' => $this->id, 110 | 'post_author' => $this->funder_id, 111 | 'post_title' => sprintf( __( '%1$s high-fives %2$s', 'wdf' ), bp_core_get_user_displayname( $this->funder_id ), bp_core_get_user_displayname( $this->recipient_id ) ) 112 | ); 113 | 114 | // Save the post 115 | $result = wp_update_post( $wp_update_post_args ); 116 | 117 | // We'll store the reciever's ID as postmeta 118 | if ( $result ) { 119 | update_post_meta( $result, 'bp_wdf_recipient_id', $this->recipient_id ); 120 | } 121 | } else { 122 | // Set up the arguments for wp_insert_post() 123 | $wp_insert_post_args = array( 124 | 'post_status' => 'publish', 125 | 'post_type' => 'donation', 126 | 'post_author' => $this->funder_id, 127 | 'post_title' => sprintf( __( '%1$s donated to %2$s', 'wdf' ), bp_core_get_user_displayname( $this->funder_id ), bp_core_get_user_displayname( $this->recipient_id ) ) 128 | ); 129 | 130 | // Save the post 131 | $result = wp_insert_post( $wp_insert_post_args ); 132 | 133 | // We'll store the reciever's ID as postmeta 134 | if ( $result ) { 135 | update_post_meta( $result, 'bp_wdf_recipient_id', $this->recipient_id ); 136 | } 137 | } 138 | 139 | /* Add an after save action here */ 140 | do_action( 'bp_wdf_data_after_save', $this ); 141 | 142 | return $result; 143 | } 144 | 145 | /** 146 | * Fire the WP_Query 147 | * 148 | * @package BuddyPress_Skeleton_Component 149 | * @since 1.6 150 | */ 151 | function get( $args = array() ) { 152 | // Only run the query once 153 | if ( empty( $this->query ) ) { 154 | $defaults = array( 155 | 'funder_id' => 0, 156 | 'recipient_id' => 0, 157 | 'per_page' => 10, 158 | 'paged' => 1 159 | ); 160 | 161 | $r = wp_parse_args( $args, $defaults ); 162 | extract( $r ); 163 | 164 | $query_args = array( 165 | 'post_status' => 'publish', 166 | 'post_type' => 'donation', 167 | 'posts_per_page' => $per_page, 168 | 'paged' => $paged, 169 | 'meta_query' => array() 170 | ); 171 | 172 | // Some optional query args 173 | // Note that some values are cast as arrays. This allows you to query for multiple 174 | // authors/recipients at a time 175 | if ( $funder_id ) { 176 | $query_args['author'] = (array)$funder_id; 177 | } 178 | 179 | // We can filter by postmeta by adding a meta_query argument. Note that 180 | if ( $recipient_id ) { 181 | $query_args['meta_query'][] = array( 182 | 'key' => 'bp_wdf_recipient_id', 183 | 'value' => (array)$recipient_id, 184 | 'compare' => 'IN' // Allows $recipient_id to be an array 185 | ); 186 | } 187 | 188 | // Run the query, and store as an object property, so we can access from 189 | // other methods 190 | $this->query = new WP_Query( $query_args ); 191 | 192 | // Let's also set up some pagination 193 | $this->pag_links = paginate_links( array( 194 | 'base' => esc_url(add_query_arg( 'items_page', '%#%' )), 195 | 'format' => '', 196 | 'total' => ceil( (int) $this->query->found_posts / (int) $this->query->query_vars['posts_per_page'] ), 197 | 'current' => (int) $paged, 198 | 'prev_text' => '←', 199 | 'next_text' => '→', 200 | 'mid_size' => 1 201 | ) ); 202 | } 203 | } 204 | 205 | /** 206 | * Part of our bp_wdf_has_donations() loop 207 | * 208 | * @package BuddyPress_Skeleton_Component 209 | * @since 1.6 210 | */ 211 | function have_posts() { 212 | return $this->query->have_posts(); 213 | } 214 | 215 | /** 216 | * Part of our bp_wdf_has_donations() loop 217 | * 218 | * @package BuddyPress_Skeleton_Component 219 | * @since 1.6 220 | */ 221 | function the_post() { 222 | return $this->query->the_post(); 223 | } 224 | 225 | /** 226 | * delete() 227 | * 228 | * This method will delete the corresponding row for an object from the database. 229 | */ 230 | function delete() { 231 | return wp_trash_post( $this->id ); 232 | } 233 | 234 | /* Static Functions */ 235 | 236 | /** 237 | * Static functions can be used to bulk delete items in a table, or do something that 238 | * doesn't necessarily warrant the instantiation of the class. 239 | * 240 | * Look at bp-core-classes.php for examples of mass delete. 241 | */ 242 | 243 | function delete_all() { 244 | 245 | } 246 | 247 | function delete_by_user_id() { 248 | 249 | } 250 | } 251 | 252 | ?> -------------------------------------------------------------------------------- /lib/widgets/widget.fundraiser_panel.php: -------------------------------------------------------------------------------- 1 | sprintf(__('If the current page is a single %1$s page then this panel will display information and call to actions for the %1$s. You can also use it to display information for a specific %1$s','wdf'),esc_attr($settings['funder_labels']['singular_name'])) 15 | ) ); 16 | 17 | } 18 | 19 | function widget( $args, $instance ) { 20 | // Widget output 21 | global $wp_query, $wdf; 22 | 23 | if($instance['single_fundraiser'] == '1') { 24 | // Specific Single Fundraiser 25 | $wdf->front_scripts($instance['funder']); 26 | if(isset($instance['style']) && !empty($instance['style'])) 27 | $wdf->load_style($instance['style']); 28 | 29 | $content = $args['before_widget']; 30 | 31 | if(isset($instance['title']) && !empty($instance['title'])) 32 | $content .= $args['before_title'] . apply_filters('fundraiser_panel_funder_widget_title', get_the_title($instance['funder']), $instance['funder']) . $args['after_title']; 33 | 34 | $content .= $this->show_thumb($instance); 35 | $content .= '

' . $instance['description'] . '

'; 36 | 37 | $content .= wdf_fundraiser_panel( false, $instance['funder'], 'widget', $instance ); 38 | $content .= $args['after_widget']; 39 | echo $content; 40 | } else { 41 | if(!isset($wp_query) || !isset($wp_query->query)) { 42 | echo 'This widget can only work when actual page is being viewed'; 43 | return; 44 | } 45 | if($wp_query->query_vars['post_type'] == 'funder' && $wp_query->is_single && (!isset($wp_query->query_vars['funder_checkout']) || $wp_query->query_vars['funder_checkout'] != '1') && (!isset($wp_query->query_vars['funder_confirm']) || $wp_query->query_vars['funder_confirm'] != '1') ) { 46 | // Single Fundraiser Page 47 | $wdf->front_scripts(get_the_ID()); 48 | if(isset($instance['style']) && !empty($instance['style'])) 49 | $wdf->load_style($instance['style']); 50 | 51 | $content = $args['before_widget']; 52 | 53 | if(isset($instance['title']) && !empty($instance['title'])) 54 | $content .= $args['before_title'] . esc_attr(apply_filters('widget_title', $instance['title'])) . $args['after_title']; 55 | 56 | $content .= $this->show_thumb($instance); 57 | 58 | if(isset($instance['description']) && !empty($instance['description'])) 59 | $content .= '

' . $instance['description'] . '

'; 60 | 61 | $content .= wdf_fundraiser_panel( false, get_the_ID(), 'widget', $instance ); 62 | $content .= $args['after_widget']; 63 | echo $content; 64 | } /*else if($wp_query->query_vars['post_type'] == 'funder' && $wp_query->query_vars['funder_checkout'] == '1'){ 65 | // Fundraiser Checkout & Confirm Page 66 | $wdf->front_scripts($wp_query->posts[0]->ID); 67 | $content = $args['before_widget']; 68 | 69 | //if(isset($instance['title']) && !empty($instance['title'])) 70 | $content .= $args['before_title'] . esc_attr(get_the_title($wp_query->posts[0]->ID)) . $args['after_title']; 71 | 72 | $content .= '
'.__('Go Back','wdf').'
'; 73 | $content .= $args['after_widget']; 74 | echo $content; 75 | }*/ 76 | } 77 | } 78 | function show_thumb($instance) { 79 | global $wp_query; 80 | if( function_exists('has_post_thumbnail') ) { 81 | if( isset($instance['show_thumb']) && (int)$instance['show_thumb'] == 1 ) { 82 | $post_id = ($instance['single_fundraiser'] == '1' ? $instance['funder'] : $wp_query->posts[0]->ID ); 83 | if( has_post_thumbnail($post_id) ) { 84 | // Width and Height Default to the blog's thumbnail size if they are not set in the widget options. 85 | $width = (isset($instance['thumb_width']) && !empty($instance['thumb_width']) ? $instance['thumb_width'] : get_option('thumbnail_size_w')); 86 | $height = (isset($instance['thumb_height']) && !empty($instance['thumb_height']) ? $instance['thumb_height'] : get_option('thumbnail_size_h')); 87 | 88 | // Run the size and attributes through some filters incase you wanna do hoodrat stuff with your friends 89 | $size = apply_filters('wdf_panel_widget_thumb_size',array($width,$height)); 90 | $attr = apply_filters('wdf_panel_widget_thumb_atts',''); 91 | 92 | $thumb_id = apply_filters('wdf_panel_widget_thumb_id',get_post_thumbnail_id($post_id)); 93 | return get_the_post_thumbnail( $post_id, $size, $attr ); 94 | } 95 | } 96 | } 97 | } 98 | function update( $new_instance, $old_instance ) { 99 | 100 | $instance = $old_instance; 101 | $instance['title'] = esc_attr($new_instance['title']); 102 | $instance['show_thumb'] = esc_attr($new_instance['show_thumb']); 103 | if(isset($new_instance['thumb_width']) && !empty($new_instance['thumb_width'])) 104 | $instance['thumb_width'] = absint($new_instance['thumb_width']); 105 | else 106 | unset($instance['thumb_width']); 107 | 108 | if(isset($new_instance['thumb_height']) && !empty($new_instance['thumb_height'])) 109 | $instance['thumb_height'] = absint($new_instance['thumb_height']); 110 | else 111 | unset($instance['thumb_height']); 112 | 113 | $instance['style'] = esc_attr($new_instance['style']); 114 | $instance['single_fundraiser'] = esc_attr($new_instance['single_fundraiser']); 115 | $instance['description'] = esc_textarea($new_instance['description']); 116 | $instance['funder'] = esc_attr( absint($new_instance['funder']) ); 117 | return $instance; 118 | } 119 | 120 | function form( $instance ) { 121 | global $wdf; 122 | $settings = get_option('wdf_settings'); 123 | 124 | $instance_defaults = array( 'description', 'show_thumb', 'thumb_width', 'thumb_height', 'style', 'single_fundraiser', 'funder' ); 125 | foreach($instance_defaults as $instance_default) 126 | if(!isset($instance[$instance_default])) 127 | $instance[$instance_default] = ''; 128 | ?> 129 | 130 |

131 |
132 | 133 |

134 |

135 |
136 | 137 |

138 | 139 |

140 | 144 |

145 |

146 | 150 |

151 |

152 | 156 |

157 | 158 |

159 | 160 | 168 |

169 | 170 |

171 | 172 | 176 |

177 |
> 178 | 179 | -1, 'post_type' => 'funder', 'post_status' => 'publish'); 181 | if($query = get_posts($query) ) : ?> 182 |

183 | $funder) : ?> 184 |
188 | 189 |

190 | 191 |

192 | 193 |
194 | -------------------------------------------------------------------------------- /lib/gateways/manual.php: -------------------------------------------------------------------------------- 1 | public_name = $this->admin_name = __('Manual','wdf'); 28 | } 29 | 30 | function payment_form() { 31 | $content = '
'; 32 | 33 | $content .= '

'.__('Please fill out all details','wdf').'

'; 34 | 35 | $content .= '

'; 36 | $content .= '
'; 37 | $content .= '
'; 38 | $content .= '
'; 39 | $content .= '
'; 40 | $content .= '
'; 41 | $content .= ''; 42 | $content .= '

'; 43 | 44 | $funder_id = get_the_ID(); 45 | if(get_post_meta($funder_id,'wdf_collect_address', true)) { 46 | $collect_address_message = get_post_meta($funder_id,'wdf_collect_address_message', true); 47 | if($collect_address_message) 48 | $content .= '

'.$collect_address_message.'

'; 49 | 50 | $content .= '

'; 51 | $collect_address_country = get_post_meta($funder_id,'wdf_collect_address_country', true); 52 | if($collect_address_country){ 53 | $content .= '
'; 54 | $content .= '
'; 55 | } 56 | $content .= '
'; 57 | $content .= '
'; 58 | $content .= '
'; 59 | $content .= '
'; 60 | $content .= '
'; 61 | $content .= '
'; 62 | $content .= '
'; 63 | $content .= '
'; 64 | $content .= '
'; 65 | $content .= ''; 66 | $content .= '

'; 67 | } 68 | 69 | $content .= '
'; 70 | return $content; 71 | } 72 | 73 | function process_simple() { 74 | if( !empty($_POST['first_name']) && !empty($_POST['last_name']) && 75 | !empty($_POST['e-mail']) && preg_match("/^[-+\\.0-9=a-z_]+@([-0-9a-z]+\\.)+([0-9a-z]){2,4}$/i", $_POST['e-mail']) && 76 | (isset($_POST['city']) && !empty($_POST['address1']) && !empty($_POST['city'])) || !isset($_POST['city']) && 77 | (isset($_POST['country']) && !empty($_POST['country'])) || !isset($_POST['country']) 78 | ) { 79 | global $wdf; 80 | $settings = get_option('wdf_settings'); 81 | $funder_id = $_SESSION['funder_id']; 82 | 83 | if($funder = get_post($funder_id) ){ 84 | $pledge_id = $wdf->generate_pledge_id(); 85 | $this->return_url = add_query_arg('pledge_id', $pledge_id, wdf_get_funder_page('confirmation',$funder->ID)); 86 | 87 | $_SESSION['wdf_pledge_id'] = $pledge_id; 88 | 89 | $settings = get_option('wdf_settings'); 90 | 91 | $transaction = array(); 92 | 93 | $transaction['gross'] = $_SESSION['wdf_pledge']; 94 | $transaction['type'] = 'simple'; 95 | $transaction['currency_code'] = ( isset($settings['currency']) ? $settings['currency'] : 'USD'); 96 | $transaction['first_name'] = (isset($_POST['first_name']) ? $_POST['first_name'] : '' ); 97 | $transaction['last_name'] = (isset($_POST['last_name']) ? $_POST['last_name'] : '' ); 98 | $transaction['payer_email'] = (isset($_POST['e-mail']) ? $_POST['e-mail'] : '' ); 99 | $transaction['gateway_public'] = $this->public_name; 100 | $transaction['gateway'] = $this->plugin_name; 101 | $status = (isset($settings['manual']['status']) ? $settings['manual']['status'] : 'wdf_complete' ); 102 | $transaction['status'] = __('Pending/Approved','wdf'); 103 | $transaction['gateway_msg'] = __('Manual Payment.','wdf'); 104 | 105 | if(isset($_SESSION['wdf_reward'])) 106 | $transaction['reward'] = $_SESSION['wdf_reward']; 107 | 108 | $collect_address = get_post_meta($funder_id,'wdf_collect_address', true); 109 | if($collect_address) { 110 | $transaction['country'] = (isset($_POST['country']) ? $_POST['country'] : '' ); 111 | $transaction['address1'] = (isset($_POST['address1']) ? $_POST['address1'] : '' ); 112 | $transaction['address2'] = (isset($_POST['address2']) ? $_POST['address2'] : '' ); 113 | $transaction['city'] = (isset($_POST['city']) ? $_POST['city'] : '' ); 114 | $transaction['state'] = (isset($_POST['state']) ? $_POST['state'] : '' ); 115 | $transaction['zip'] = (isset($_POST['zip']) ? $_POST['zip'] : '' ); 116 | } 117 | 118 | 119 | $wdf->update_pledge( $pledge_id, $funder_id, $status, $transaction); 120 | 121 | if(!headers_sent()) { 122 | wp_redirect($this->return_url); 123 | exit; 124 | } 125 | 126 | } else { 127 | $_POST['wdf_step'] = 'gateway'; 128 | //No $_SESSION['funder_id'] was passed to this function. 129 | $this->create_gateway_error(__('Could not determine fundraiser','wdf')); 130 | } 131 | } else { 132 | $_POST['wdf_step'] = 'gateway'; 133 | $this->create_gateway_error(__('Make sure all details are filled out correctly.','wdf')); 134 | } 135 | } 136 | function process_advanced() { 137 | $this->process_simple(); 138 | } 139 | function confirm() { 140 | } 141 | function payment_info( $content, $transaction ) { 142 | $settings = get_option('wdf_settings'); 143 | 144 | $content = '
'; 145 | $content .= html_entity_decode(stripslashes($settings['manual']['after_info'])); 146 | $content .= '
'; 147 | return $content; 148 | } 149 | function handle_ipn() { 150 | } 151 | function execute_payment($type, $pledge, $transaction) { 152 | } 153 | 154 | function admin_settings() { 155 | $settings = get_option('wdf_settings'); 156 | ?> 157 | 158 | 159 | 160 | 163 | 169 | 170 | 171 | 174 | 177 | 178 | 179 |
161 | 162 | 168 |
172 | 173 | 175 | 176 |
180 | 202 | -------------------------------------------------------------------------------- /changelog.txt: -------------------------------------------------------------------------------- 1 | Plugin Name: Fundraising 2 | Author: WPMUDEV 3 | Lead developer: Maniu 4 | Contributors: Cole Stevenson, Jose Jaureguiberry 5 | 6 | == Changelog == 7 | 8 | = 2.6.4.9 = 9 | Fixed remaining deprecated constructors 10 | Fixed rewards count on pledge status change 11 | Improved UX for configuring simple donations with goals 12 | 13 | = 2.6.4.8 = 14 | Fixed issue causing redirects to a blank page when pledge is submitted 15 | Fixed issue forcing no funding goal for advanced crowd funding 16 | Fixed deprecated constructor for one of the classes 17 | 18 | = 2.6.4.7 = 19 | Fixed BuddyPress compatibility issues 20 | Fixed manual payment country field issues 21 | 22 | = 2.6.4.6 = 23 | Removed PHP 4 constructor 24 | 25 | = 2.6.4.5 = 26 | Fixed issues with counting reward limits 27 | 28 | = 2.6.4.4 = 29 | Fixed issues with address colection for manual gateway 30 | WPMUDEV dashboard notice update 31 | 32 | = 2.6.4.3 = 33 | Fixed "Times Up!" issues with simple donation fundraising 34 | 35 | = 2.6.4.2 = 36 | Improved FE styling (please check compatibility with active theme) 37 | Improved UX for jumping between Simple and Advanced fundraising type 38 | Improved fundraising start/end date handling 39 | Improved PP error handling 40 | Added ajax check for delayed pledges 41 | Enabled address collecting without rewards 42 | Fixed typo 43 | 44 | = 2.6.4.1 = 45 | Improved Upfront compatibility 46 | Added ability to hide standard Fundraising Panel (may be useful in some scenarios) 47 | Fixed widgets related PHP notices 48 | Fixed BP related PHP strick notices 49 | 50 | = 2.6.4 = 51 | Fixed compatibility with PayPal changes 52 | Fixed widget's edit screen markup 53 | 54 | = 2.6.3 = 55 | Fixed issues with tutorial 56 | 57 | = 2.6.2 = 58 | Added support for refunds in recurring payments 59 | Fixed recurring payments amount problem for currencies different than US Dollars 60 | 61 | = 2.6.1.9 = 62 | Improved UX when switching to advanced payments 63 | Fixed problems with address storing when using advanced payments 64 | 65 | = 2.6.1.8 = 66 | Fixed is_subdomain_install error 67 | 68 | = 2.6.1.7 = 69 | Added possibility to collect address even when rewards are disabled 70 | Fixed some permalink issues 71 | Fixed storing of custom data for PayPal 72 | 73 | = 2.6.1.6 = 74 | Added default WP filter for titles in widgets 75 | 76 | = 2.6.1.5 = 77 | Added missing jquery ui images 78 | 79 | = 2.6.1.4 = 80 | Fixed SSL loading issues 81 | 82 | = 2.6.1.3 = 83 | Changed IPN url for better server compatibility 84 | Fixed pledge button for touch devices 85 | Fixed recurring payments 86 | Fixed rewards counting after donation removal 87 | 88 | = 2.6.1.2 = 89 | Fixed top pledges sorting 90 | 91 | = 2.6.1.1 = 92 | Fixed counting of rewards left 93 | 94 | = 2.6.1 = 95 | Added pledges panel widget and shortcode to list recent or top pledges 96 | Added ability to set custom message for situation when pledge was not found 97 | Improved UX for creating new Fundraisers 98 | Improved respect for label settings inside admin panel 99 | Fixed PHP warnings 100 | Fixed time left counting for Fundraisers 101 | Fixed session cleaning 102 | 103 | = 2.6.0.5 = 104 | Added back front permalink option on main site in multisite 105 | Fixed buddypress activity item being added for unlogged users 106 | Other small improvements 107 | 108 | = 2.6.0.4 = 109 | Fixed missing translation strings 110 | 111 | = 2.6.0.3 = 112 | Fixed missing ")" causing php error 113 | 114 | = 2.6.0.2 = 115 | Fixed rounding of raised amount 116 | Fixed problems with older Internet explorers 117 | Fixed notifications about minimal amount 118 | Fixed limit of listed fundraisers in widget 119 | Small visual improvements 120 | 121 | = 2.6.0.1 = 122 | Update plugins for WP 3.8. UI changes. 123 | 124 | = 2.6 = 125 | Added ability to collect address 126 | Added ability to limit number of rewards 127 | Small improvements to UI 128 | Fixed problem with fundraisers list widget 129 | 130 | = 2.5.3 = 131 | Fixed forms not being closed for custom buttons in some configurations 132 | 133 | = 2.5.2 = 134 | Added missing translation 135 | Unnecessary string removal 136 | 137 | = 2.5.1 = 138 | Removed "front" permalink option for multisite 139 | Fixed permalink problem with /%category%/ inside 140 | Other small improvements 141 | 142 | = 2.5 = 143 | Added ability to control access to fundraisings features for all available user types 144 | Fixed email subject in fundraising not saving correctly 145 | 146 | = 2.4.2 = 147 | Allows shortcodes inside fundraising if ID is not the same as current fundraising 148 | 149 | = 2.4.1 = 150 | Fixed problem with fundraising content not being displayed 151 | 152 | = 2.4 = 153 | Disables fundraising shortcodes inside fundraising 154 | PayPal Support for all UTF-8 characters 155 | 156 | = 2.3.9 = 157 | Fixed styles on older browsers 158 | 159 | = 2.3.8 = 160 | Fixed bug with fundraising panel not being displayed when only specific fundraising widget is configured in sidebar 161 | Fixed mistype in manual payment getaway 162 | 163 | = 2.3.7 = 164 | Allowed HTML tags in reward description 165 | Added information about choosen reward(id) in admin panel 166 | Changed paypal url for possible ipn problem fixes 167 | Fixed security issue 168 | 169 | = 2.3.6 = 170 | Replaced .live jQuery functions with .on 171 | Fixed small UI issue in chrome for fundraising type chooser 172 | Fixed "Add reward" button not working after deleting all rewards before last 173 | 174 | = 2.3.5 = 175 | Fixed manual payment status not saving 176 | Changed/fixed behavior of permalinks and rewrite flushing 177 | Added ability to disable "front" in permalinks from main MU site ("blog/" by default) 178 | Added option to select default getaway 179 | Added workaround for EURO sign in email 180 | 181 | = 2.3.1 = 182 | Added manual payment getaway 183 | 184 | = 2.2.5 = 185 | Fixed php notices about undefined indexes 186 | Fixed notifications from paypal to wordpress about payments with special characters in payment details ( ', " ...) 187 | 188 | = 2.2.4 = 189 | Added new external style locations. Check fundraising-templates.txt for more info 190 | Added new filter and reference label option for standard payments and simple donation buttons 191 | 192 | = 2.2.3 = 193 | Rewrite Flush Issue Fixed 194 | Fixed issue with subscriber error in admin panel 195 | Currency characters are properly decoded for thank you emails 196 | New "wdf_paypal_gateway_standard_item_number" filter for changing the "Reference" on checkout 197 | 198 | = 2.2 = 199 | Fundraising slug now functional with multisite subdirectory. 200 | Fundraiser menu ancestry now works properly when using menus in your theme. 201 | Fixed problem concerning per checkout types breaking panel display. 202 | Adjusted all concatenated translation strings to sprintf() strings. 203 | Fixed action name not displaying in fundraising widget 204 | 205 | 206 | = 2.1.8 = 207 | Fixed issue with fundraisers with goals not showing in shortcode generator 208 | Fixed problem with styles not loading in particular situations 209 | Custom css styling available, but simply adding a css file to /styles folder, see fundraising-templates.txt for more info 210 | 211 | = 2.1.7 = 212 | Shortcode generator now inserts properly into both the HTML and Visual editor 213 | Fixed problem with above/below content option not displaying the current setting 214 | Backer Label now displays a singular label when only one pledge has been taken 215 | Fixed issue with displaying email settings correctly 216 | 217 | = 2.1.6 = 218 | Fixed bug with not allowing more than 10 rewards 219 | 220 | = 2.1.5 = 221 | Fundraising now has it's own metabox in your Theme's Appearance Menus 222 | Multiple php warning fixes 223 | Corrected x.com links for creating an application 224 | Added the ability to set checkout type per fundraiser 225 | Fixed currency display issues 226 | Better display of options on the shortcode generator pop-up 227 | Small change to menu order due to compatibility errors with other plugins and hosting services 228 | New fundraising-templates.txt file in root folder that explains the template hierarchy 229 | 230 | 231 | = 2.1.1 = 232 | Fixed Manual Pledge Payments 233 | Rewards and Goals can now be set independently of each other 234 | 235 | 236 | = 2.1 = 237 | Fixed Canadian Currency Issue 238 | New plugin labeling system 239 | Fixed HTML structure error on checkout pages 240 | Added global custom CSS box in presentation settings (better styles in next release) 241 | Added Minutes to wdf_time_left() 242 | Changed Featured Fundraisers widget to Fundraiser List 243 | 244 | 245 | = 2.0-RC-3 = 246 | Paypal error codes now correctly display if redirection fails. 247 | 248 | Fixed headers already sent error with certain themes. 249 | 250 | Simple Fundraisers can now use rewards and goals again 251 | - Advanced Payments still may not change goals and rewards if the fundraiser has been published and pledges have already been taken. 252 | 253 | New wdf_has_date_range() template function. 254 | 255 | Added new option in presentation settings for checking out directly from the fundraising panel. 256 | 257 | 258 | = 2.0-RC-2 = 259 | Fixed issues with PayPal App ID not saving. 260 | 261 | Fixed problem with PayPal redirect on certain server setups 262 | 263 | 264 | = 2.0-RC-1 = 265 | New Payment Gateway API 266 | - Fundraisers are now split into two types: Simple and Advanced 267 | - Simple payments are donations that are accepted immediately. ( No Goals or Rewards ) 268 | - Advanced Payments are pre-approved and only processed after the completion of the fundraiser's goal. ( Goals and Rewards allowed ) 269 | 270 | Donations are now refered to as pledges. 271 | - 4 new pledge statuses are available. ( Complete, Approved, Canceled, Refunded ) 272 | 273 | New Fundraising Panel 274 | - Use either a shortcode or widget to display relevant fundraiser information 275 | 276 | New Reset option for clearing all fundraising data 277 | - add define('WDF_ALLOW_RESET',true); in your wp-config file to add an extra reset tab to your settings page. 278 | 279 | Limited BuddyPress Integration 280 | - Users are allow to publicly display their plegde as an activity item if they choose to do so. This option display requires that BuddyPress be activated on your site. 281 | 282 | CSS style containers are now all
elements to allow for easier customization. 283 | 284 | New permalink structure 285 | - Each fundraiser now contains a checkout and confirmation page. 286 | 287 | Template functions can now be overridden using the action 'wdf_custom_template_functions' 288 | - fundraiser.php line: 1521 289 | 290 | Fixed shortcode media button errors 291 | 292 | New custom template structure for your theme 293 | - wdf_funder-{$name/$id}.php 294 | - wdf_checkout-{$name/$id}.php 295 | - wdf_confirm-{$name/$id}.php 296 | 297 | Addition of several action and filter hooks for external plugins or theme function files. -------------------------------------------------------------------------------- /lib/bp/bp-wdf-template.php: -------------------------------------------------------------------------------- 1 | 21 | * 22 | * 23 | * 24 | *

25 | * 26 | * 27 | * 28 | * 29 | * 30 | *

No items!

31 | * 32 | * 33 | * 34 | * Obviously, you'd want to be more specific than the word 'item'. 35 | * 36 | * In our example here, we've used a custom post type for storing and fetching our content. Though 37 | * the custom post type method is recommended, you can also create custom database tables for this 38 | * purpose. See bp-example-classes.php for more details. 39 | * 40 | */ 41 | 42 | function bp_wdf_has_items( $args = '' ) { 43 | global $bp, $items_template; 44 | 45 | // This keeps us from firing the query more than once 46 | if ( empty( $items_template ) ) { 47 | /*** 48 | * This function should accept arguments passes as a string, just the same 49 | * way a 'query_posts()' call accepts parameters. 50 | * At a minimum you should accept 'per_page' and 'max' parameters to determine 51 | * the number of items to show per page, and the total number to return. 52 | * 53 | * e.g. bp_get_wdf_has_items( 'per_page=10&max=50' ); 54 | */ 55 | 56 | /*** 57 | * Set the defaults for the parameters you are accepting via the "bp_get_wdf_has_items()" 58 | * function call 59 | */ 60 | $defaults = array( 61 | 'donation_id' => 0, 62 | 'recipient_id' => 0, 63 | 'per_page' => 10, 64 | 'paged' => 1 65 | ); 66 | 67 | /*** 68 | * This function will extract all the parameters passed in the string, and turn them into 69 | * proper variables you can use in the code - $per_page, $max 70 | */ 71 | $r = wp_parse_args( $args, $defaults ); 72 | extract( $r, EXTR_SKIP ); 73 | 74 | $items_template = new BP_WDF_Donation(); 75 | $items_template->get( $r ); 76 | } 77 | 78 | return $items_template->have_posts(); 79 | } 80 | 81 | function bp_wdf_the_item() { 82 | global $items_template; 83 | return $items_template->query->the_post(); 84 | } 85 | 86 | function bp_wdf_item_name() { 87 | echo bp_wdf_get_item_name(); 88 | } 89 | /* Always provide a "get" function for each template tag, that will return, not echo. */ 90 | function bp_wdf_get_item_name() { 91 | global $items_template; 92 | echo apply_filters( 'bp_wdf_get_item_name', $items_template->item->name ); // Example: $items_template->item->name; 93 | } 94 | 95 | /** 96 | * Echo "Viewing x of y pages" 97 | * 98 | * @package BuddyPress_Skeleton_Component 99 | * @since 1.6 100 | */ 101 | function bp_wdf_pagination_count() { 102 | echo bp_wdf_get_pagination_count(); 103 | } 104 | /** 105 | * Return "Viewing x of y pages" 106 | * 107 | * @package BuddyPress_Skeleton_Component 108 | * @since 1.6 109 | */ 110 | function bp_wdf_get_pagination_count() { 111 | global $items_template; 112 | 113 | $pagination_count = sprintf( __( 'Viewing page %1$s of %2$s', 'wdf' ), $items_template->query->query_vars['paged'], $items_template->query->max_num_pages ); 114 | 115 | return apply_filters( 'bp_wdf_get_pagination_count', $pagination_count ); 116 | } 117 | 118 | /** 119 | * Echo pagination links 120 | * 121 | * @package BuddyPress_Skeleton_Component 122 | * @since 1.6 123 | */ 124 | function bp_wdf_item_pagination() { 125 | echo bp_wdf_get_item_pagination(); 126 | } 127 | /** 128 | * return pagination links 129 | * 130 | * @package BuddyPress_Skeleton_Component 131 | * @since 1.6 132 | */ 133 | function bp_wdf_get_item_pagination() { 134 | global $items_template; 135 | return apply_filters( 'bp_wdf_get_item_pagination', $items_template->pag_links ); 136 | } 137 | 138 | /** 139 | * Echo the high-fiver avatar (post author) 140 | * 141 | * @package BuddyPress_Skeleton_Component 142 | * @since 1.6 143 | */ 144 | function bp_wdf_funder_avatar( $args = array() ) { 145 | echo bp_wdf_get_funder_avatar( $args ); 146 | } 147 | /** 148 | * Return the high-fiver avatar (the post author) 149 | * 150 | * @package BuddyPress_Skeleton_Component 151 | * @since 1.6 152 | * 153 | * @param mixed $args Accepts WP style arguments - either a string of URL params, or an array 154 | * @return str The HTML for a user avatar 155 | */ 156 | function bp_wdf_get_funder_avatar( $args = array() ) { 157 | $defaults = array( 158 | 'item_id' => get_the_author_meta( 'ID' ), 159 | 'object' => 'user' 160 | ); 161 | 162 | $r = wp_parse_args( $args, $defaults ); 163 | 164 | return bp_core_fetch_avatar( $r ); 165 | } 166 | 167 | /** 168 | * Echo the "title" of the high-five 169 | * 170 | * @package BuddyPress_Skeleton_Component 171 | * @since 1.6 172 | */ 173 | function bp_wdf_donation_title() { 174 | echo bp_wdf_get_donation_title(); 175 | } 176 | /** 177 | * Return the "title" of the high-five 178 | * 179 | * We'll assemble the title out of the available information. This way, we can insert 180 | * fancy stuff link links, and secondary avatars. 181 | * 182 | * @package BuddyPress_Skeleton_Component 183 | * @since 1.6 184 | */ 185 | function bp_wdf_get_donation_title() { 186 | // First, set up the high fiver's information 187 | $funder_link = bp_core_get_userlink( get_the_author_meta( 'ID' ) ); 188 | 189 | // Next, get the information for the high five recipient 190 | $recipient_id = get_post_meta( get_the_ID(), 'bp_wdf_recipient_id', true ); 191 | $recipient_link = bp_core_get_userlink( $recipient_id ); 192 | 193 | // Use sprintf() to make a translatable message 194 | $title = sprintf( __( '%1$s gave %2$s a high-five!', 'wdf' ), $funder_link, $recipient_link ); 195 | 196 | return apply_filters( 'bp_wdf_get_donation_title', $title, $funder_link, $recipient_link ); 197 | } 198 | 199 | /** 200 | * Is this page part of the Example component? 201 | * 202 | * Having a special function just for this purpose makes our code more readable elsewhere, and also 203 | * allows us to place filter 'bp_is_wdf_component' for other components to interact with. 204 | * 205 | * @package BuddyPress_Skeleton_Component 206 | * @since 1.6 207 | * 208 | * @uses bp_is_current_component() 209 | * @uses apply_filters() to allow this value to be filtered 210 | * @return bool True if it's the example component, false otherwise 211 | */ 212 | function bp_is_wdf_component() { 213 | $is_wdf_component = bp_is_current_component( 'wdf_bp' ); 214 | 215 | return apply_filters( 'bp_is_wdf_component', $is_wdf_component ); 216 | } 217 | 218 | /** 219 | * Echo the component's slug 220 | * 221 | * @package BuddyPress_Skeleton_Component 222 | * @since 1.6 223 | */ 224 | function bp_wdf_slug() { 225 | echo bp_get_wdf_slug(); 226 | } 227 | /** 228 | * Return the component's slug 229 | * 230 | * Having a template function for this purpose is not absolutely necessary, but it helps to 231 | * avoid too-frequent direct calls to the $bp global. 232 | * 233 | * @package BuddyPress_Skeleton_Component 234 | * @since 1.6 235 | * 236 | * @uses apply_filters() Filter 'bp_get_wdf_slug' to change the output 237 | * @return str $example_slug The slug from $bp->wdf->slug, if it exists 238 | */ 239 | function bp_get_wdf_slug() { 240 | global $bp; 241 | 242 | // Avoid PHP warnings, in case the value is not set for some reason 243 | $wdf_slug = isset( $bp->wdf->slug ) ? $bp->wdf->slug : ''; 244 | 245 | return apply_filters( 'bp_get_wdf_slug', $wdf_slug ); 246 | } 247 | 248 | /** 249 | * Echo the component's root slug 250 | * 251 | * @package BuddyPress_Skeleton_Component 252 | * @since 1.6 253 | */ 254 | function bp_wdf_root_slug() { 255 | echo bp_get_wdf_root_slug(); 256 | } 257 | /** 258 | * Return the component's root slug 259 | * 260 | * Having a template function for this purpose is not absolutely necessary, but it helps to 261 | * avoid too-frequent direct calls to the $bp global. 262 | * 263 | * @package BuddyPress_Skeleton_Component 264 | * @since 1.6 265 | * 266 | * @uses apply_filters() Filter 'bp_get_wdf_root_slug' to change the output 267 | * @return str $wdf_root_slug The slug from $bp->wdf->root_slug, if it exists 268 | */ 269 | function bp_get_wdf_root_slug() { 270 | global $bp; 271 | 272 | // Avoid PHP warnings, in case the value is not set for some reason 273 | $wdf_root_slug = isset( $bp->wdf->root_slug ) ? $bp->wdf->root_slug : ''; 274 | 275 | return apply_filters( 'bp_get_wdf_root_slug', $wdf_root_slug ); 276 | } 277 | 278 | /** 279 | * Echo the total of all donations across the site 280 | * 281 | * @package BuddyPress_Skeleton_Component 282 | * @since 1.6 283 | */ 284 | function bp_wdf_total_donation_count() { 285 | echo bp_wdf_get_total_donation_count(); 286 | } 287 | /** 288 | * Return the total of all donations across the site 289 | * 290 | * The most straightforward way to get a post count is to run a WP_Query. In your own plugin 291 | * you might consider storing data like this with update_option(), incrementing each time 292 | * a new item is published. 293 | * 294 | * @package BuddyPress_Skeleton_Component 295 | * @since 1.6 296 | * 297 | * @return int 298 | */ 299 | function bp_wdf_get_total_donation_count() { 300 | $donations = new BP_WDF_Donation(); 301 | $donations->get(); 302 | 303 | return apply_filters( 'bp_wdf_get_total_donation_count', $donations->query->found_posts, $donations ); 304 | } 305 | 306 | /** 307 | * Echo the total of all donations given to a particular user 308 | * 309 | * @package BuddyPress_Skeleton_Component 310 | * @since 1.6 311 | */ 312 | function bp_wdf_total_donation_count_for_user( $user_id = false ) { 313 | echo bp_wdf_get_total_donation_count_for_user( $user_id = false ); 314 | } 315 | /** 316 | * Return the total of all donations given to a particular user 317 | * 318 | * The most straightforward way to get a post count is to run a WP_Query. In your own plugin 319 | * you might consider storing data like this with update_option(), incrementing each time 320 | * a new item is published. 321 | * 322 | * @package BuddyPress_Skeleton_Component 323 | * @since 1.6 324 | * 325 | * @return int 326 | */ 327 | function bp_wdf_get_total_donation_count_for_user( $user_id = false ) { 328 | // If no explicit user id is passed, fall back on the loggedin user 329 | if ( !$user_id ) { 330 | $user_id = bp_loggedin_user_id(); 331 | } 332 | 333 | if ( !$user_id ) { 334 | return 0; 335 | } 336 | 337 | $donations = new BP_WDF_Donation(); 338 | $donations->get( array( 'recipient_id' => $user_id ) ); 339 | 340 | return apply_filters( 'bp_wdf_get_total_donation_count', $donations->query->found_posts, $donations ); 341 | } 342 | 343 | ?> -------------------------------------------------------------------------------- /lib/bp/bp-wdf-functions.php: -------------------------------------------------------------------------------- 1 | current_component != $bp->wdf->slug ) 31 | return $found_template; 32 | 33 | foreach ( (array) $templates as $template ) { 34 | if ( file_exists( STYLESHEETPATH . '/' . $template ) ) 35 | $filtered_templates[] = STYLESHEETPATH . '/' . $template; 36 | else 37 | $filtered_templates[] = dirname( __FILE__ ) . '/templates/' . $template; 38 | } 39 | 40 | $found_template = $filtered_templates[0]; 41 | 42 | return apply_filters( 'bp_wdf_load_template_filter', $found_template ); 43 | } 44 | add_filter( 'bp_located_template', 'bp_wdf_load_template_filter', 10, 2 ); 45 | 46 | /*** 47 | * From now on you will want to add your own functions that are specific to the component you are developing. 48 | * For example, in this section in the friends component, there would be functions like: 49 | * friends_add_friend() 50 | * friends_remove_friend() 51 | * friends_check_friendship() 52 | * 53 | * Some guidelines: 54 | * - Don't set up error messages in these functions, just return false if you hit a problem and 55 | * deal with error messages in screen or action functions. 56 | * 57 | * - Don't directly query the database in any of these functions. Use database access classes 58 | * or functions in your bp-example-classes.php file to fetch what you need. Spraying database 59 | * access all over your plugin turns into a maintenance nightmare, trust me. 60 | * 61 | * - Try to include add_action() functions within all of these functions. That way others will 62 | * find it easy to extend your component without hacking it to pieces. 63 | */ 64 | 65 | /** 66 | * bp_wdf_accept_terms() 67 | * 68 | * Accepts the terms and conditions screen for the logged in user. 69 | * Records an activity stream item for the user. 70 | */ 71 | function bp_wdf_accept_terms() { 72 | global $bp; 73 | 74 | /** 75 | * First check the nonce to make sure that the user has initiated this 76 | * action. Remember the wp_nonce_url() call? The second parameter is what 77 | * you need to check for. 78 | */ 79 | check_admin_referer( 'bp_wdf_accept_terms' ); 80 | 81 | /*** 82 | * Here is a good example of where we can post something to a users activity stream. 83 | * The user has excepted the terms on screen two, and now we want to post 84 | * "Andy accepted the really exciting terms and conditions!" to the stream. 85 | */ 86 | $user_link = bp_core_get_userlink( $bp->loggedin_user->id ); 87 | 88 | bp_wdf_record_activity( array( 89 | 'type' => 'accepted_terms', 90 | 'action' => apply_filters( 'bp_wdf_accepted_terms_activity_action', sprintf( __( '%s accepted the really exciting terms and conditions!', 'wdf' ), $user_link ), $user_link ), 91 | ) ); 92 | 93 | /* See bp_wdf_reject_terms() for an explanation of deleting activity items */ 94 | if ( function_exists( 'bp_activity_delete') ) 95 | bp_activity_delete( array( 'type' => 'rejected_terms', 'user_id' => $bp->loggedin_user->id ) ); 96 | 97 | /* Add a do_action here so other plugins can hook in */ 98 | do_action( 'bp_wdf_accept_terms', $bp->loggedin_user->id ); 99 | 100 | /*** 101 | * You'd want to do something here, like set a flag in the database, or set usermeta. 102 | * just for the sake of the demo we're going to return true. 103 | */ 104 | 105 | return true; 106 | } 107 | 108 | /** 109 | * bp_wdf_reject_terms() 110 | * 111 | * Rejects the terms and conditions screen for the logged in user. 112 | * Records an activity stream item for the user. 113 | */ 114 | function bp_wdf_reject_terms() { 115 | global $bp; 116 | 117 | check_admin_referer( 'bp_wdf_reject_terms' ); 118 | 119 | /*** 120 | * In this example component, the user can reject the terms even after they have 121 | * previously accepted them. 122 | * 123 | * If a user has accepted the terms previously, then this will be in their activity 124 | * stream. We don't want both 'accepted' and 'rejected' in the activity stream, so 125 | * we should remove references to the user accepting from all activity streams. 126 | * A real world example of this would be a user deleting a published blog post. 127 | */ 128 | 129 | $user_link = bp_core_get_userlink( $bp->loggedin_user->id ); 130 | 131 | /* Now record the new 'rejected' activity item */ 132 | bp_wdf_record_activity( array( 133 | 'type' => 'rejected_terms', 134 | 'action' => apply_filters( 'bp_wdf_rejected_terms_activity_action', sprintf( __( '%s rejected the really exciting terms and conditions.', 'wdf' ), $user_link ), $user_link ), 135 | ) ); 136 | 137 | /* Delete any accepted_terms activity items for the user */ 138 | if ( function_exists( 'bp_activity_delete') ) 139 | bp_activity_delete( array( 'type' => 'accepted_terms', 'user_id' => $bp->loggedin_user->id ) ); 140 | 141 | do_action( 'bp_wdf_reject_terms', $bp->loggedin_user->id ); 142 | 143 | return true; 144 | } 145 | 146 | /** 147 | * bp_wdf_send_donation() 148 | * 149 | * Sends a high five message to a user. Registers an notification to the user 150 | * via their notifications menu, as well as sends an email to the user. 151 | * 152 | * Also records an activity stream item saying "User 1 high-fived User 2". 153 | */ 154 | function bp_wdf_send_donation( $to_user_id, $from_user_id ) { 155 | global $bp; 156 | 157 | check_admin_referer( 'bp_wdf_send_donation' ); 158 | 159 | /** 160 | * We'll store donations as usermeta, so we don't actually need 161 | * to do any database querying. If we did, and we were storing them 162 | * in a custom DB table, we'd want to reference a function in 163 | * bp-wdf-classes.php that would run the SQL query. 164 | */ 165 | delete_user_meta( $to_user_id, 'donations' ); 166 | /* Get existing fives */ 167 | $existing_fives = maybe_unserialize( get_user_meta( $to_user_id, 'donations', true ) ); 168 | 169 | /* Check to see if the user has already high-fived. That's okay, but lets not 170 | * store duplicate donations in the database. What's the point, right? 171 | */ 172 | if ( !in_array( $from_user_id, (array)$existing_fives ) ) { 173 | $existing_fives[] = (int)$from_user_id; 174 | 175 | /* Now wrap it up and fire it back to the database overlords. */ 176 | update_user_meta( $to_user_id, 'donations', serialize( $existing_fives ) ); 177 | 178 | // Let's also record it in our custom database tables 179 | $db_args = array( 180 | 'recipient_id' => (int)$to_user_id, 181 | 'funder_id' => (int)$from_user_id 182 | ); 183 | 184 | $donation = new BP_WDF_Donation( $db_args ); 185 | $donation->save(); 186 | } 187 | 188 | /*** 189 | * Now we've registered the new high-five, lets work on some notification and activity 190 | * stream magic. 191 | */ 192 | 193 | /*** 194 | * Post a screen notification to the user's notifications menu. 195 | * Remember, like activity streams we need to tell the activity stream component how to format 196 | * this notification in bp_wdf_format_notifications() using the 'new_donation' action. 197 | */ 198 | bp_core_add_notification( $from_user_id, $to_user_id, $bp->wdf->slug, 'new_donation' ); 199 | 200 | /* Now record the new 'new_donation' activity item */ 201 | $to_user_link = bp_core_get_userlink( $to_user_id ); 202 | $from_user_link = bp_core_get_userlink( $from_user_id ); 203 | 204 | bp_wdf_record_activity( array( 205 | 'type' => 'rejected_terms', 206 | 'action' => apply_filters( 'bp_wdf_new_donation_activity_action', sprintf( __( '%s supported %s!', 'wdf' ), $from_user_link, $to_user_link ), $from_user_link, $to_user_link ), 207 | 'item_id' => $to_user_id, 208 | ) ); 209 | 210 | /* We'll use this do_action call to send the email notification. See bp-wdf-notifications.php */ 211 | do_action( 'bp_wdf_send_donation', $to_user_id, $from_user_id ); 212 | 213 | return true; 214 | } 215 | 216 | /** 217 | * bp_wdf_get_donations_for_user() 218 | * 219 | * Returns an array of user ID's for users who have high fived the user passed to the function. 220 | */ 221 | function bp_wdf_get_donations_for_user( $user_id ) { 222 | global $bp; 223 | 224 | if ( !$user_id ) 225 | return false; 226 | 227 | return maybe_unserialize( get_user_meta( $user_id, 'donations', true ) ); 228 | } 229 | 230 | 231 | /** 232 | * bp_wdf_remove_data() 233 | * 234 | * It's always wise to clean up after a user is deleted. This stops the database from filling up with 235 | * redundant information. 236 | */ 237 | function bp_wdf_remove_data( $user_id ) { 238 | /* You'll want to run a function here that will delete all information from any component tables 239 | for this $user_id */ 240 | 241 | /* Remember to remove usermeta for this component for the user being deleted */ 242 | delete_user_meta( $user_id, 'bp_wdf_some_setting' ); 243 | 244 | do_action( 'bp_wdf_remove_data', $user_id ); 245 | } 246 | add_action( 'wpmu_delete_user', 'bp_wdf_remove_data', 1 ); 247 | add_action( 'delete_user', 'bp_wdf_remove_data', 1 ); 248 | 249 | /*** 250 | * Object Caching Support ---- 251 | * 252 | * It's a good idea to implement object caching support in your component if it is fairly database 253 | * intensive. This is not a requirement, but it will help ensure your component works better under 254 | * high load environments. 255 | * 256 | * In parts of this wdf component you will see calls to wp_cache_get() often in template tags 257 | * or custom loops where database access is common. This is where cached data is being fetched instead 258 | * of querying the database. 259 | * 260 | * However, you will need to make sure the cache is cleared and updated when something changes. For example, 261 | * the groups component caches groups details (such as description, name, news, number of members etc). 262 | * But when those details are updated by a group admin, we need to clear the group's cache so the new 263 | * details are shown when users view the group or find it in search results. 264 | * 265 | * We know that there is a do_action() call when the group details are updated called 'groups_settings_updated' 266 | * and the group_id is passed in that action. We need to create a function that will clear the cache for the 267 | * group, and then add an action that calls that function when the 'groups_settings_updated' is fired. 268 | * 269 | * Example: 270 | * 271 | * function groups_clear_group_object_cache( $group_id ) { 272 | * wp_cache_delete( 'groups_group_' . $group_id ); 273 | * } 274 | * add_action( 'groups_settings_updated', 'groups_clear_group_object_cache' ); 275 | * 276 | * The "'groups_group_' . $group_id" part refers to the unique identifier you gave the cached object in the 277 | * wp_cache_set() call in your code. 278 | * 279 | * If this has completely confused you, check the function documentation here: 280 | * http://codex.wordpress.org/Function_Reference/WP_Cache 281 | * 282 | * If you're still confused, check how it works in other BuddyPress components, or just don't use it, 283 | * but you should try to if you can (it makes a big difference). :) 284 | */ 285 | 286 | ?> -------------------------------------------------------------------------------- /lib/bp/bp-wdf-screens.php: -------------------------------------------------------------------------------- 1 | is_directory flag to true, which help other 21 | // content to display content properly on your directory. 22 | bp_update_is_directory( true, 'wdf' ); 23 | 24 | // Add an action so that plugins can add content or modify behavior 25 | do_action( 'bp_wdf_directory_setup' ); 26 | 27 | bp_core_load_template( apply_filters( 'wdf_directory_template', 'wdf/index' ) ); 28 | } 29 | } 30 | add_action( 'bp_screens', 'bp_wdf_directory_setup' ); 31 | 32 | 33 | /** 34 | * bp_wdf_screen_one() 35 | * 36 | * Sets up and displays the screen output for the sub nav item "wdf/screen-one" 37 | */ 38 | function bp_wdf_screen_one() { 39 | global $bp; 40 | 41 | /** 42 | * There are three global variables that you should know about and you will 43 | * find yourself using often. 44 | * 45 | * $bp->current_component (string) 46 | * This will tell you the current component the user is viewing. 47 | * 48 | * Example: If the user was on the page http://example.org/members/andy/groups/my-groups 49 | * $bp->current_component would equal 'groups'. 50 | * 51 | * $bp->current_action (string) 52 | * This will tell you the current action the user is carrying out within a component. 53 | * 54 | * Example: If the user was on the page: http://example.org/members/andy/groups/leave/34 55 | * $bp->current_action would equal 'leave'. 56 | * 57 | * $bp->action_variables (array) 58 | * This will tell you which action variables are set for a specific action 59 | * 60 | * Example: If the user was on the page: http://example.org/members/andy/groups/join/34 61 | * $bp->action_variables would equal array( '34' ); 62 | * 63 | * There are three handy functions you can use for these purposes: 64 | * bp_is_current_component() 65 | * bp_is_current_action() 66 | * bp_is_action_variable() 67 | */ 68 | 69 | /* Add a do action here, so your component can be extended by others. */ 70 | do_action( 'bp_wdf_screen_one' ); 71 | 72 | /**** 73 | * Displaying Content 74 | */ 75 | 76 | /**** 77 | * OPTION 1: 78 | * You've got a few options for displaying content. Your first option is to bundle template files 79 | * with your plugin that will be used to output content. 80 | * 81 | * In an earlier function bp_wdf_load_template_filter() we set up a filter on the core BP template 82 | * loading function that will make it first look in the plugin directory for template files. 83 | * If it doesn't find any matching templates it will look in the active theme directory. 84 | * 85 | * This example component comes bundled with a template for screen one, so we can load that 86 | * template to display what we need. If you copied this template from the plugin into your theme 87 | * then it would load that one instead. This allows users to override templates in their theme. 88 | */ 89 | 90 | /* This is going to look in wp-content/plugins/[plugin-name]/includes/templates/ first */ 91 | bp_core_load_template( apply_filters( 'bp_wdf_template_screen_one', 'wdf/screen-one' ) ); 92 | 93 | /**** 94 | * OPTION 2 (NOT USED FOR THIS SCREEN): 95 | * If your component is simple, and you just want to insert some HTML into the user's active theme 96 | * then you can use the bundle plugin template. 97 | * 98 | * There are two actions you need to hook into. One for the title, and one for the content. 99 | * The functions you hook these into should simply output the content you want to display on the 100 | * page. 101 | * 102 | * The follow lines are commented out because we are not using this method for this screen. 103 | * You'd want to remove the OPTION 1 parts above and uncomment these lines if you want to use 104 | * this option instead. 105 | * 106 | * Generally, this method of adding content is preferred, as it makes your plugin 107 | * work better with a wider variety of themes. 108 | */ 109 | 110 | // add_action( 'bp_template_title', 'bp_wdf_screen_one_title' ); 111 | // add_action( 'bp_template_content', 'bp_wdf_screen_one_content' ); 112 | 113 | // bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); 114 | } 115 | /*** 116 | * The second argument of each of the above add_action() calls is a function that will 117 | * display the corresponding information. The functions are presented below: 118 | */ 119 | function bp_wdf_screen_one_title() { 120 | _e( 'Fundraiser Projects', 'wdf' ); 121 | } 122 | 123 | function bp_wdf_screen_one_content() { 124 | global $bp; 125 | 126 | $donations = bp_wdf_get_donations_for_user( $bp->displayed_user->id ); 127 | 128 | /** 129 | * For security reasons, we MUST use the wp_nonce_url() function on any actions. 130 | * This will stop naughty people from tricking users into performing actions without their 131 | * knowledge or intent. 132 | */ 133 | $send_link = wp_nonce_url( $bp->displayed_user->domain . $bp->current_component . '/screen-one/send-donation', 'bp_wdf_send_donation' ); 134 | ?> 135 |

136 |

high-five!', 'wdf' ), $bp->displayed_user->fullname, $send_link ) ?>

137 | 138 | 139 |

140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 |
$user_id, 'width' => 25, 'height' => 25 ) ) ?> 
149 | 150 | 218 | 219 |

220 | 221 | loggedin_user->domain . $bp->wdf->slug . '/screen-two/accept', 'bp_wdf_accept_terms' ) . '">' . __( 'Accept', 'wdf' ) . ''; 223 | $reject_link = '' . __( 'Reject', 'wdf' ) . ''; 224 | ?> 225 | 226 |

227 | loggedin_user->id, 'bp-wdf-option-one', attribute_escape( $_POST['bp-wdf-option-one'] ) ); 247 | } 248 | 249 | add_action( 'bp_template_content_header', 'bp_wdf_screen_settings_menu_header' ); 250 | add_action( 'bp_template_title', 'bp_wdf_screen_settings_menu_title' ); 251 | add_action( 'bp_template_content', 'bp_wdf_screen_settings_menu_content' ); 252 | 253 | bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) ); 254 | } 255 | 256 | function bp_wdf_screen_settings_menu_header() { 257 | _e( 'Fundraising Settings Header', 'wdf' ); 258 | } 259 | 260 | function bp_wdf_screen_settings_menu_title() { 261 | _e( 'Fundraising Settings', 'wdf' ); 262 | } 263 | 264 | function bp_wdf_screen_settings_menu_content() { 265 | global $bp, $bp_settings_updated; ?> 266 | 267 | 268 |
269 |

270 |
271 | 272 | 273 |
274 | 275 | loggedin_user->id, 'bp-wdf-option-one', true ) ) : ?> checked="checked" /> 276 |

277 | 278 |

279 | 280 | 284 | 285 |
286 | -------------------------------------------------------------------------------- /lib/external/class.wd_help_tooltips.php: -------------------------------------------------------------------------------- 1 | 7 | * if (!class_exists('WpmuDev_HelpTooltips')) require_once YOUR_PLUGIN_BASE_DIR . '/lib/external/class.wd_help_tooltips.php'; 8 | * $tips = new WpmuDev_HelpTooltips(); 9 | * $tips->set_icon_url("URL_TO_YOUR_ICON"); 10 | * echo $tips->add_tip("Tip 1 text here"); 11 | * // ... 12 | * echo $tips->add_tip("Tip 2 text here"); 13 | * 14 | * This is a basic usage scenario. 15 | * 16 | * Alternative usage example: 17 | * 18 | * if (!class_exists('WpmuDev_HelpTooltips')) require_once YOUR_PLUGIN_BASE_DIR . '/lib/external/class.wd_help_tooltips.php'; 19 | * $tips = new WpmuDev_HelpTooltips(); 20 | * $tips->set_icon_url("URL_TO_YOUR_ICON"); 21 | * $tips->bind_tip('My tip text here', '.icon32:first ~h2'); 22 | * // Note that you don't echo anything in this usage example - the tip will be 23 | * // added automatically next to the supplied selector (second argument) 24 | * 25 | * This scenario may be useful for e.g. adding our tips to UI elements created by WP or other plugins. 26 | * You can freely alternate between add_tip() and bind_tip() methods, 27 | * just remember to echo add_tip() and *not* echo bind_tip(). 28 | * 29 | * Another alternative usage example, setting tips for multiple pages in one place: 30 | * 31 | * if (!class_exists('WpmuDev_HelpTooltips')) require_once YOUR_PLUGIN_BASE_DIR . '/lib/external/class.wd_help_tooltips.php'; 32 | * // Tips added to $tips1 object will only show on Social Marketing add/edit advert page 33 | * $tips1 = new WpmuDev_HelpTooltips(); 34 | * $tips1->set_icon_url("URL_TO_YOUR_ICON"); 35 | * $tips1->set_screen_id("social_marketing_ad"); 36 | * $tips1->bind_tip('My tip 1 text here', '.icon32:first ~h2'); 37 | * // ... 38 | * // Tips added to $tips2 object will only show on Social Marketing getting started page 39 | * $tips2 = new WpmuDev_HelpTooltips(); 40 | * $tips2->set_icon_url("URL_TO_YOUR_ICON"); 41 | * $tips2->set_screen_id("social_marketing_ad_page_wdsm-get_started"); 42 | * $tips2->bind_tip('My tip 2 text here', '.icon32:first ~h2'); 43 | * 44 | * Using add_tip() method will do nothing in this last scenario, as it doesn't make sense in that context. 45 | * This scenario may be useful for adding tooltips to all pages in one central location. 46 | * E.g. for adding tooltips in a plugin add-on. 47 | */ 48 | 49 | class WpmuDev_HelpTooltips { 50 | 51 | /** 52 | * Holds an array of inline tips: used as dependency inclusion switch. 53 | */ 54 | private $_inline_tips = array(); 55 | 56 | /** 57 | * Holds an array of bound tips: used as dependency inclusion switch and bound tips buffer. 58 | */ 59 | private $_bound_tips = array(); 60 | 61 | /** 62 | * Holds an array of bound tips selectors: used as bound tips selectors buffer. 63 | */ 64 | private $_bound_selectors = array(); 65 | 66 | /** 67 | * Full URL to help icon, which is used as tip anchor 68 | * and as notice background image. 69 | */ 70 | private $_icon_url; 71 | 72 | /** 73 | * Flag that determines do we want to use notices 74 | * (tips expanded on click). 75 | * Defaults to true. 76 | */ 77 | private $_use_notice = true; 78 | 79 | /** 80 | * Limits tip output to a screen (page). 81 | * Optional. 82 | * Works best with bind_tip() method. 83 | */ 84 | private $_screen_id = false; 85 | 86 | /** 87 | * Bind to footer hooks when instantiated. 88 | */ 89 | public function __construct () { 90 | global $wp_version; 91 | $version = preg_replace('/-.*$/', '', $wp_version); 92 | 93 | if (version_compare($version, '3.3', '>=')) { 94 | add_action('admin_footer', array($this, 'add_bound_tips'), 999); 95 | add_action('admin_print_footer_scripts', array($this, 'initialize')); 96 | } 97 | } 98 | 99 | /** 100 | * Sets icon URL. 101 | * @param string $icon_url Full URL to help anchor icon 102 | */ 103 | public function set_icon_url ($icon_url) { 104 | $this->_icon_url = $icon_url; 105 | } 106 | 107 | /** 108 | * Set show notices (tips expanded on click) flag. 109 | * @param bool $use_notice True to use notices (default), false otherwise. 110 | */ 111 | public function set_use_notice ($use_notice=true) { 112 | $this->_use_notice = $use_notice; 113 | } 114 | 115 | /** 116 | * Set screen limiting flag. 117 | * @param $screen_id Screen ID that tips in this object apply to. 118 | */ 119 | public function set_screen_id ($screen_id) { 120 | $this->_screen_id = $screen_id; 121 | } 122 | 123 | /** 124 | * Returns inline tip markup. 125 | * Scenario: for echoing inline tips next to elements on the page. 126 | * Usage example: 127 | * 128 | * echo $tips->add_tip('My tip text here'); 129 | * 130 | * @param string $tip Tip text 131 | * @return string Inline tip markup 132 | */ 133 | public function add_tip ($tip) { 134 | if (!$this->_check_screen()) return false; 135 | $this->_inline_tips[] = $tip; 136 | return $this->_get_tip_markup($tip); 137 | } 138 | 139 | /** 140 | * Binds a tip to selector. 141 | * This is different from inline tips, as you don't have to output them yourself. 142 | * Scenario: for adding help tips next to elements determined by the selector on page load time. 143 | * Usage example: 144 | * 145 | * $tips->bind_tip('My tip text here', '.icon32:first ~h2'); 146 | * 147 | * @param string $tip Tip text 148 | * @param string $selector jQuery selector of the element that tip is related to. 149 | */ 150 | public function bind_tip ($tip, $bind_to_selector) { 151 | $tip_id = 'wpmudev-help-tip-for-' . md5($bind_to_selector); 152 | $this->_bound_tips[$tip_id] = $tip; 153 | $this->_bound_selectors[$tip_id] = $bind_to_selector; 154 | } 155 | 156 | /** 157 | * Bounded tips injection handler. 158 | * Will queue up the bounded tips. 159 | */ 160 | function add_bound_tips () { 161 | if (!$this->_check_screen()) return false; 162 | if (!$this->_bound_tips) return false; 163 | 164 | foreach ($this->_bound_tips as $id => $tip) { 165 | echo $this->_get_tip_markup($tip, 'id="' . $id . '" style=display:none'); 166 | } 167 | } 168 | 169 | /** 170 | * Dependency injection handler. 171 | * Will only add dependencies if there are actual tooltips to show. 172 | */ 173 | function initialize () { 174 | if (!$this->_check_screen()) return false; 175 | if (!$this->_inline_tips && !$this->_bound_tips) return false; 176 | 177 | $this->_print_styles(); 178 | $this->_print_scripts(); 179 | } 180 | 181 | /** 182 | * Screen limitation check. 183 | * @return bool True if we're good to go, false if we're on a wrong screen. 184 | */ 185 | private function _check_screen () { 186 | if (!$this->_screen_id) return true; // No screen dependency 187 | 188 | $screen = get_current_screen(); 189 | if (!is_object($screen)) return false; // Actually older then 3.3 190 | if ($this->_screen_id != @$screen->id) return false; // Not for this screen 191 | 192 | return true; 193 | } 194 | 195 | private function _get_tip_markup ($tip, $arg='') { 196 | return "{$tip}"; 197 | } 198 | 199 | /** 200 | * Private helper method that prints style dependencies. 201 | */ 202 | private function _print_styles () { 203 | // Have we already done this? 204 | if (!defined('WPMUDEV_TOOLTIPS_CSS_ADDED')) define('WPMUDEV_TOOLTIPS_CSS_ADDED', true); 205 | else return false; 206 | 207 | ?> 208 | 274 | _bound_selectors); 287 | 288 | ?> 289 | 461 |