PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.7.2
GiveWP – Donation Plugin and Fundraising Platform v2.7.2
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / class-give-welcome.php
give / includes / admin Last commit date
add-ons 6 years ago donors 6 years ago emails 6 years ago forms 6 years ago payments 6 years ago reports 6 years ago settings 6 years ago shortcodes 6 years ago tools 6 years ago upgrades 5 years ago views 6 years ago abstract-admin-settings-page.php 6 years ago admin-actions.php 6 years ago admin-filters.php 6 years ago admin-footer.php 6 years ago admin-pages.php 6 years ago class-addon-activation-banner.php 6 years ago class-admin-settings.php 6 years ago class-api-keys-table.php 6 years ago class-blank-slate.php 6 years ago class-give-admin.php 6 years ago class-give-html-elements.php 6 years ago class-give-welcome.php 6 years ago class-i18n-module.php 6 years ago dashboard-widgets.php 6 years ago give-metabox-functions.php 6 years ago import-functions.php 6 years ago misc-functions.php 6 years ago plugins.php 6 years ago setting-page-functions.php 6 years ago
class-give-welcome.php
1037 lines
1 <?php
2 /**
3 * Give Welcome Page Class
4 *
5 * Displays on plugin activation
6 *
7 * @package Give
8 * @subpackage Admin/Welcome
9 * @copyright Copyright (c) 2019, GiveWP
10 * @license https://opensource.org/licenses/gpl-license GNU Public License
11 * @since 1.0
12 */
13
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 /**
20 * Give_Welcome Class
21 *
22 * A general class for Welcome and Credits pages.
23 *
24 * @since 1.0
25 */
26 class Give_Welcome {
27
28 /**
29 * @var string The capability users should have to view the page
30 */
31 public $minimum_capability = 'manage_options';
32
33 /**
34 * Get things started
35 *
36 * @since 1.0
37 */
38 public function __construct() {
39 add_action( 'admin_menu', [ $this, 'admin_menus' ] );
40 add_action( 'admin_head', [ $this, 'admin_head' ] );
41 add_action( 'admin_init', [ $this, 'welcome' ] );
42 }
43
44 /**
45 * Register the Dashboard Pages which are later hidden but these pages
46 * are used to render the Welcome and Credits pages.
47 *
48 * @access public
49 * @return void
50 * @since 1.0
51 */
52 public function admin_menus() {
53 list( $display_version ) = explode( '-', GIVE_VERSION );
54
55 // Changelog Page
56 add_dashboard_page(
57 esc_html__( 'What\'s New', 'give' ),
58 esc_html__( 'What\'s New', 'give' ),
59 $this->minimum_capability,
60 'give-changelog',
61 [ $this, 'changelog_screen' ]
62 );
63
64 // Getting Started Page
65 add_dashboard_page(
66 /* translators: %s: Give version */
67 sprintf( esc_html__( 'GiveWP %s - Getting Started Guide', 'give' ), $display_version ),
68 esc_html__( 'Getting started with Give', 'give' ),
69 $this->minimum_capability,
70 'give-getting-started',
71 [ $this, 'getting_started_screen' ]
72 );
73
74 // Credits Page
75 add_dashboard_page(
76 /* translators: %s: Give version */
77 sprintf( esc_html__( 'GiveWP %s - Credits', 'give' ), $display_version ),
78 esc_html__( 'The people that build Give', 'give' ),
79 $this->minimum_capability,
80 'give-credits',
81 [ $this, 'credits_screen' ]
82 );
83 }
84
85 /**
86 * Hide Individual Dashboard Pages
87 *
88 * @access public
89 * @return void
90 * @since 1.0
91 */
92 public function admin_head() {
93
94 remove_submenu_page( 'index.php', 'give-changelog' );
95 remove_submenu_page( 'index.php', 'give-getting-started' );
96 remove_submenu_page( 'index.php', 'give-credits' );
97
98 }
99
100 /**
101 * Navigation tabs
102 *
103 * @access public
104 * @return void
105 * @since 1.0
106 */
107 public function tabs() {
108 $selected = isset( $_GET['page'] ) ? $_GET['page'] : 'give-getting-started';
109 ?>
110 <div class="nav-tab-wrapper give-nav-tab-wrapper">
111 <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>"
112 href="<?php echo esc_url( admin_url( add_query_arg( [ 'page' => 'give-getting-started' ], 'index.php' ) ) ); ?>">
113 <?php esc_html_e( 'Getting Started', 'give' ); ?>
114 </a>
115 <a class="nav-tab <?php echo $selected == 'give-changelog' ? 'nav-tab-active' : ''; ?>"
116 href="<?php echo esc_url( admin_url( add_query_arg( [ 'page' => 'give-changelog' ], 'index.php' ) ) ); ?>">
117 <?php esc_html_e( 'What\'s New', 'give' ); ?>
118 </a>
119 <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>"
120 href="https://givewp.com/addons/?utm_source=welcome-screen&utm_medium=getting-started" target="_blank">
121 <?php esc_html_e( 'Add-ons', 'give' ); ?>
122 </a>
123 <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>"
124 href="<?php echo esc_url( admin_url( add_query_arg( [ 'page' => 'give-credits' ], 'index.php' ) ) ); ?>">
125 <?php esc_html_e( 'Credits', 'give' ); ?>
126 </a>
127 </div>
128 <?php
129 }
130
131 /**
132 * The header section for the welcome screen.
133 *
134 * @since 1.8.8
135 */
136 public function get_welcome_header() {
137 // Badge for welcome page
138 list( $display_version ) = explode( '-', GIVE_VERSION );
139
140 $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
141 if ( empty( $page ) ) {
142 return;
143 }
144
145 switch ( $page ) {
146 case 'give-getting-started':
147 $title = sprintf( esc_html__( 'Welcome to GiveWP %s', 'give' ), $display_version );
148 $content = esc_html__( 'You\'re now using the best fundraising platform for WordPress. The three steps below will set you and your organization up for success in online donations.', 'give' );
149 break;
150
151 case 'give-changelog':
152 $title = sprintf( esc_html__( 'What\'s New in GiveWP %s', 'give' ), $display_version );
153 $content = esc_html__( 'GiveWP is regularly updated with new features and fixes to ensure your fundraising campaigns run smoothly and securely. The only version that is actively supported is the latest version. Please stay up to date.', 'give' );
154 break;
155
156 case 'give-credits':
157 $title = sprintf( esc_html__( 'GitHub Contributors', 'give' ) );
158 $content = sprintf(
159 /* translators: %s: https://github.com/impress-org/give */
160 __( 'GiveWP is backed by a dedicated team of in-house developers and a vibrant open source community. If you are interested in contributing code, translations, or other improvements, please visit the <a href="%s" target="_blank">GitHub Repository</a>.', 'give' ),
161 esc_url( 'https://github.com/impress-org/give' )
162 );
163
164 break;
165
166 default:
167 $title = get_admin_page_title();
168 $content = '';
169 break;
170
171 }
172
173 ?>
174 <div class="give-welcome-header">
175
176 <div class="give-welcome-header-inner">
177
178 <h1 class="give-welcome-h1"><?php echo $title; ?></h1>
179
180 <?php $this->social_media_elements(); ?>
181
182 <p class="give-welcome-text"><?php echo $content; ?></p>
183
184 <?php $this->get_newsletter(); ?>
185
186 <div class="give-badge">
187 <?php
188 printf(
189 /* translators: %s: Give version */
190 esc_html__( 'Version %s', 'give' ),
191 $display_version
192 );
193 ?>
194 </div>
195
196 </div>
197 </div>
198
199 <?php
200 }
201
202 /**
203 * Render Getting Started Screen
204 *
205 * @access public
206 * @return void
207 * @since 1.0
208 */
209 public function getting_started_screen() {
210 ?>
211 <div class="give-welcome-wrap get-started">
212
213 <?php $this->get_welcome_header(); ?>
214
215 <?php $this->tabs(); ?>
216
217 <div class="give-welcome-content-wrap">
218
219 <p class="give-welcome-content-intro"><?php esc_html_e( 'Getting started with GiveWP is as easy as the following three steps! GiveWP is designed with "smart defaults" based on online donation best practices, and backed by a team of folks who are passionate about your success in online donations. It\'s their number one priority.', 'give' ); ?></p>
220
221 <div class="give-feature-section give-clearfix">
222 <div class="give-feature-section__inner">
223 <div class="give-feature-section-item">
224 <div class="give-feature-section-item__container">
225 <h3>
226 <span class="give-feature-section-item-number">1</span>
227 <?php esc_html_e( 'Configure your payment gateways.', 'give' ); ?>
228 </h3>
229
230 <p><?php esc_html_e( 'GiveWP is not a payment processor, and for PCI compliance reasons, that\'s a very good thing. Instead, GiveWP supports connecting to many of the top payment processors. Stripe and PayPal Standard are included for free in the main plugin, while other payment gateways can be integrated by activating GiveWP add-ons. Please ensure your site is running securely with a valid SSL certificate before accepting online payments.', 'give' ); ?></p>
231
232 <p><?php echo sprintf( __( 'Having Trouble? A team of online donation (and WordPress) experts is available to help. Contact the <a href="%s" target="_blank">GiveWP support team</a> for speedy help from folks who won\'t make you feel silly for asking for it.', 'give' ), 'https://givewp.com/support/?utm_source=welcome-screen&utm_medium=getting-started' ); ?></p>
233
234 <div class="give-welcome-connect-gateways">
235
236 <ul class="give-feature-btns">
237 <li>
238 <?php echo give_stripe_connect_button(); ?>
239 </li>
240 <li>
241 <?php echo give_paypal_connect_button(); ?>
242 </li>
243 <li style="display: block; margin: 20px 0 0;">
244 <a href="https://givewp.com/addons/category/payment-gateways/?utm_source=welcome-screen&utm_medium=getting-started"
245 class="give-feature-btn-link"
246 target="_blank"
247 title="<?php esc_attr_e( 'View Premium Gateway Add-ons', 'give' ); ?>"><?php esc_html_e( 'View Premium Gateway Add-ons', 'give' ); ?></a>
248 </li>
249 </ul>
250
251 <p class="give-welcome-gateway-notice give-field-description"><?php esc_html_e( 'Note: The free version of the Stripe payment gateway for GiveWP allows for credit card, SEPA direct debit, BECS direct debit, and Stripe Checkout. Using the free version of Stripe incurs an additional 2% fee on one-time donations in addition to the standard Stripe processing fee. To enable Apple Pay or Google Pay, as well as to remove the additional 2% fee, install and activate the premium Stripe add-on. The only way to avoid that additional fee is to install and activate the premium Stripe add-on. Those fees are non-refundable. Using PayPal Standard does not incur any additional fees.', 'give' ); ?></p>
252
253 </div>
254
255
256 </div>
257 </div>
258
259 <div class="give-feature-section-item">
260 <div class="give-ipad-showcase-wrap">
261 <div class="give-ipad-showcase-inner">
262 <img
263 src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-step-1.gif">
264 </div>
265 </div>
266 </div>
267
268 </div>
269 <!-- /.give-feature-section__inner -->
270 </div>
271 <!-- /.give-feature-section -->
272
273 <div class="give-feature-section give-feature-section__step2 give-clearfix">
274 <div class="give-feature-section__inner">
275 <div class="give-feature-section-item">
276 <div class=" give-ipad-showcase-wrap">
277 <div class="give-ipad-showcase-inner">
278 <img
279 src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-step-2.gif">
280 </div>
281 </div>
282 </div>
283
284 <div class="give-feature-section-item">
285 <div
286 class="give-feature-section-item__container give-feature-section-item__container-right">
287 <h3>
288 <span class="give-feature-section-item-number">2</span>
289 <?php esc_html_e( 'Create your first donation form.', 'give' ); ?>
290 </h3>
291
292 <p><?php esc_html_e( 'Donations are accepted through customizable donation forms. Forms can be stand-alone pages or embedded throughout your website using a block, shortcode, or widget. Start simple with a multi-step form template which uses smart defaults to supercharge your fundraising using online donation best practices! Once you\'re comfortable with a simple form, take a look at the GiveWP documentation and some premium add-ons to take your online donations to the next level! You can create multi-level forms which allow donors to choose from preconfigured donation amounts, allow for custom amounts, and even set a fundraising goal.', 'give' ); ?></p>
293
294 <ul class="give-feature-btns">
295 <li>
296 <a href="<?php echo admin_url( 'post-new.php?post_type=give_forms' ); ?>"
297 class="button button-primary button-large"
298 title="<?php esc_attr_e( 'Add a new donation form', 'give' ); ?>"><?php esc_html_e( 'Add Donation Form', 'give' ); ?></a>
299 </li>
300 <li>
301 <a href="http://docs.givewp.com/give-forms" class="give-feature-btn-link"
302 target="_blank"
303 title="<?php esc_attr_e( 'Learn more about creating forms', 'give' ); ?>"><?php esc_html_e( 'Learn more', 'give' ); ?></a>
304 </li>
305 </ul>
306
307 </div>
308 </div>
309
310 </div>
311 <!-- /.give-feature-section__inner -->
312 </div>
313 <!-- /.give-feature-section -->
314
315 <div class="give-feature-section give-clearfix">
316 <div class="give-feature-section__inner">
317
318 <div class="give-feature-section-item">
319 <div class="give-feature-section-item__container">
320 <h3>
321 <span class="give-feature-section-item-number">3</span>
322 <?php esc_html_e( 'Test and launch your campaign!', 'give' ); ?>
323 </h3>
324
325 <p><?php esc_html_e( 'Once you\'ve placed your form on a page using the GiveWP block or shortcode, you\'re ready to test it out. Before you go live, take advantage of GiveWP\'s built-in Test Mode for testing donations without using real money. Try getting a true donor experience by viewing your new form in an incognito or private browser, and processing a Test Mode donation. GiveWP defaults to Test Mode when you first install it. Once you\'ve confirmed everything is working, disable Test Mode and get to fundraising!', 'give' ); ?></p>
326
327 <ul class="give-feature-btns">
328 <li>
329 <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways' ); ?>"
330 class="button button-primary button-large"
331 title="<?php esc_attr_e( 'Configure Test Mode', 'give' ); ?>"><?php esc_html_e( 'Configure Test Mode', 'give' ); ?></a>
332 </li>
333 <li>
334 <a href="http://docs.givewp.com/test-mode" class="give-feature-btn-link"
335 target="_blank"
336 title="<?php esc_attr_e( 'Learn more about Test Mode', 'give' ); ?>"><?php esc_html_e( 'Learn more', 'give' ); ?></a>
337 </li>
338 </ul>
339
340 </div>
341 </div>
342
343 <div class="give-feature-section-item">
344 <div class="give-ipad-showcase-wrap">
345 <div class="give-ipad-showcase-inner">
346 <img
347 src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-step-3.gif">
348 </div>
349 </div>
350 </div>
351
352 </div>
353 <!-- /.give-feature-section__inner -->
354 </div>
355 <!-- /.give-feature-section -->
356
357 </div>
358 <!-- /.give-welcome-content-wrap -->
359
360 <?php $this->support_widgets(); ?>
361
362 </div>
363 <?php
364 }
365
366 /**
367 * Render Changelog Screen
368 *
369 * @access public
370 * @return void
371 * @since 1.0
372 */
373 public function changelog_screen() {
374 ?>
375 <div class="give-welcome-wrap">
376
377 <?php $this->get_welcome_header(); ?>
378
379 <?php $this->tabs(); ?>
380
381 <div class="give-welcome-content-wrap give-changelog-wrap">
382
383 <p class="give-welcome-content-intro"><?php printf( __( 'See what\'s new in version %1$s of Give! If you need clarity on anything you see here, don\'t hesitate to <a href="%2$s" target="_blank">contact support</a>.', 'give' ), GIVE_VERSION, 'https://givewp.com/support/?utm_source=welcome-screen&utm_medium=getting-started' ); ?></p>
384
385 <div class="give-changelog">
386 <?php echo $this->parse_readme(); ?>
387 </div>
388
389 </div>
390
391 <?php $this->support_widgets(); ?>
392
393 </div>
394 <?php
395 }
396
397 /**
398 * Render Credits Screen
399 *
400 * @access public
401 * @return void
402 * @since 1.0
403 */
404 public function credits_screen() {
405 ?>
406 <div class="wrap give-welcome-wrap">
407
408 <?php $this->get_welcome_header(); ?>
409
410 <?php $this->tabs(); ?>
411
412 <div class="give-welcome-content-wrap give-changelog-wrap">
413
414 <p class="give-welcome-content-intro">
415
416 <?php
417 printf(
418 /* translators: %s: https://github.com/impress-org/give */
419 __( 'GiveWP is backed by a dedicated team of in-house developers and a vibrant open source community. If you are interested in contributing please visit the <a href="%s" target="_blank">GitHub Repository</a>.', 'give' ),
420 esc_url( 'https://github.com/impress-org/give' )
421 );
422 ?>
423 </p>
424
425 <?php echo $this->contributors(); ?>
426
427 </div>
428
429 </div>
430 <?php
431 }
432
433
434 /**
435 * Parse the GIVE readme.txt file
436 *
437 * @return string $readme HTML formatted readme file
438 * @since 1.0
439 */
440 public function parse_readme() {
441 $file = file_exists( GIVE_PLUGIN_DIR . 'readme.txt' ) ? GIVE_PLUGIN_DIR . 'readme.txt' : null;
442
443 if ( ! $file ) {
444 $readme = '<p>' . esc_html__( 'No valid changlog was found.', 'give' ) . '</p>';
445 } else {
446 $readme = file_get_contents( $file );
447 $readme = nl2br( esc_html( $readme ) );
448 $readme = explode( '== Changelog ==', $readme );
449 $readme = end( $readme );
450
451 $readme = preg_replace( '/`(.*?)`/', '<code>\\1</code>', $readme );
452 $readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme );
453 $readme = preg_replace( '/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme );
454 $readme = preg_replace( '/= (.*?) =/', '<h4>\\1</h4>', $readme );
455 $readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme );
456 }
457
458 return $readme;
459 }
460
461
462 /**
463 * Render Contributors List
464 *
465 * @return string $contributor_list HTML formatted list of all the contributors for GIVE
466 * @uses Give_Welcome::get_contributors()
467 * @since 1.0
468 */
469 public function contributors() {
470 $contributors = $this->get_contributors();
471
472 if ( empty( $contributors ) ) {
473 return '';
474 }
475
476 $contributor_list = '<ul class="give-contributor-group">';
477
478 foreach ( $contributors as $contributor ) {
479 $contributor_list .= '<li class="give-contributor">';
480 $contributor_list .= sprintf(
481 '<a href="%1$s" target="_blank"><img src="%2$s" width="64" height="64" class="gravatar" alt="%3$s" /><span>%3$s</span></a>',
482 esc_url( 'https://github.com/' . $contributor->login ),
483 esc_url( $contributor->avatar_url ),
484 esc_attr( $contributor->login )
485 );
486 $contributor_list .= '</li>';
487 }
488
489 $contributor_list .= '</ul>';
490
491 return $contributor_list;
492 }
493
494 /**
495 * Retrieve list of contributors from GitHub.
496 *
497 * @access public
498 * @return array $contributors List of contributors
499 * @since 1.0
500 */
501 public function get_contributors() {
502 $contributors = Give_Cache::get( 'give_contributors', true );
503
504 if ( false !== $contributors ) {
505 return $contributors;
506 }
507
508 $response = wp_remote_get( 'https://api.github.com/repos/impress-org/give/contributors', [ 'sslverify' => false ] );
509
510 if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
511 return [];
512 }
513
514 $contributors = json_decode( wp_remote_retrieve_body( $response ) );
515
516 if ( ! is_array( $contributors ) ) {
517 return [];
518 }
519
520 Give_Cache::set( 'give_contributors', $contributors, HOUR_IN_SECONDS, true );
521
522 return $contributors;
523 }
524
525 /**
526 * Social Media Like Buttons
527 *
528 * Various social media elements to Give
529 */
530 public function social_media_elements() {
531 ?>
532
533 <div class="social-items-wrap">
534
535 <iframe
536 src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fwpgive&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21&amp;appId=220596284639969"
537 scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;"
538 allowTransparency="true"></iframe>
539
540 <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false">
541 <?php
542 printf(
543 /* translators: %s: Give twitter user @givewp */
544 esc_html_e( 'Follow %s', 'give' ),
545 '@givewp'
546 );
547 ?>
548 </a>
549 <script>!function( d, s, id ) {
550 var js, fjs = d.getElementsByTagName( s )[ 0 ], p = /^http:/.test( d.location ) ? 'http' : 'https';
551 if ( !d.getElementById( id ) ) {
552 js = d.createElement( s );
553 js.id = id;
554 js.src = p + '://platform.twitter.com/widgets.js';
555 fjs.parentNode.insertBefore( js, fjs );
556 }
557 }( document, 'script', 'twitter-wjs' );
558 </script>
559
560 </div>
561 <!--/.social-items-wrap -->
562
563 <?php
564 }
565
566 /**
567 * Support widgets.
568 *
569 * @since 2.5.0
570 */
571 public function support_widgets() {
572 ?>
573
574 <div class="give-welcome-widgets give-clearfix">
575 <div class="give-welcome-widgets__inner">
576
577 <div class="give-welcome-widgets__heading">
578 <h2><?php esc_html_e( 'Start off on the right foot', 'give' ); ?></h2>
579 <p><?php esc_html_e( 'If you aren’t quite sure how to get started or you want to see the best ways to use GiveWP for your fundraising needs, book a live demo. The Customer Success Team is happy to help.', 'give' ); ?></p>
580
581 <a href="https://givewp.com/schedule-a-demo/?utm_source=welcome-screen&utm_medium=getting-started"
582 class="give-welcome-widgets__demo-btn button button-large"
583 target="_blank"><?php esc_html_e( 'Schedule a Demo', 'give' ); ?></a>
584 </div>
585
586 <div class="give-welcome-widgets__col give-welcome-widgets__support">
587 <div class="give-welcome-widgets__col-inner">
588 <h3><?php esc_html_e( 'Support', 'give' ); ?></h3>
589 <p><?php esc_html_e( 'Inevitably questions arise when building great fundraising websites. GiveWP has a dedicated team of world-class experts who are trained to help with personal, patient support.', 'give' ); ?></p>
590
591 <a href="https://givewp.com/support/?utm_source=welcome-screen&utm_medium=getting-started" class="give-welcome-widgets__link"
592 target="_blank"><?php esc_html_e( 'How support works', 'give' ); ?></a>
593
594 </div>
595 </div>
596 <div class="give-welcome-widgets__col give-welcome-widgets__addons">
597 <div class="give-welcome-widgets__col-inner">
598 <h3><?php esc_html_e( 'Add-ons', 'give' ); ?></h3>
599 <p><?php esc_html_e( 'Accept recurring donations, add custom donation form fields, ask donors to cover processing fees and more! Level up your fundraisers by extending GiveWP with add-ons.', 'give' ); ?></p>
600 <a href="https://givewp.com/addons/?utm_source=welcome-screen&utm_medium=getting-started" class="give-welcome-widgets__link"
601 target="_blank"><?php esc_html_e( 'Power up my fundraising', 'give' ); ?></a>
602 </div>
603 </div>
604 <div class="give-welcome-widgets__col give-welcome-widgets__documentation">
605 <div class="give-welcome-widgets__col-inner">
606 <h3><?php esc_html_e( 'Documentation', 'give' ); ?></h3>
607 <p><?php esc_html_e( 'Learn the ins and outs of GiveWP with well organized and clearly written documentation. You can search using a keyword to find articles for GiveWP Core and each add-on. ', 'give' ); ?></p>
608 <a href="https://givewp.com/documentation/?utm_source=welcome-screen&utm_medium=getting-started" class="give-welcome-widgets__link"
609 target="_blank"><?php esc_html_e( 'Check out the docs', 'give' ); ?></a>
610 </div>
611 </div>
612
613 </div>
614 </div>
615 <?php
616 }
617
618 /**
619 * Sends user to the Welcome page on first activation of Give.
620 *
621 * @access public
622 * @return void
623 * @since 1.0
624 */
625 public function welcome() {
626
627 // Bail if no activation redirect
628 if ( ! Give_Cache::get( '_give_activation_redirect', true ) || wp_doing_ajax() ) {
629 return;
630 }
631
632 // Delete the redirect transient
633 Give_Cache::delete( Give_Cache::get_key( '_give_activation_redirect' ) );
634
635 // Bail if activating from network, or bulk
636 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
637 return;
638 }
639
640 $upgrade = get_option( 'give_version_upgraded_from' );
641
642 if ( ! $upgrade ) {
643 // First time install
644 wp_safe_redirect( admin_url( 'index.php?page=give-getting-started' ) );
645 exit;
646 } elseif ( ! give_is_setting_enabled( give_get_option( 'welcome' ) ) ) {
647 // Welcome is disabled in settings
648 } else { // Welcome is NOT disabled in settings
649 wp_safe_redirect( admin_url( 'index.php?page=give-changelog' ) );
650 exit;
651 }
652 }
653
654 /**
655 * Give Newsletter
656 *
657 * Returns the main Give newsletter form
658 */
659 public function get_newsletter() {
660 $current_user = wp_get_current_user();
661 ?>
662 <div class="give-newsletter-form-wrap">
663
664 <p class="give-newsletter-intro"><?php esc_html_e( 'Sign up for the WordPress Nonprofit Newsletter for the latest updates, online donation best practices, and exclusive promotions.', 'give' ); ?></p>
665
666 <form method="POST" action="https://givewp.activehosted.com/proc.php" id="_form_3_" class="_form _form_3 _inline-form _dark" novalidate>
667 <input type="hidden" name="u" value="3"/>
668 <input type="hidden" name="f" value="3"/>
669 <input type="hidden" name="s"/>
670 <input type="hidden" name="c" value="0"/>
671 <input type="hidden" name="m" value="0"/>
672 <input type="hidden" name="act" value="sub"/>
673 <input type="hidden" name="v" value="2"/>
674 <div class="_form-content">
675 <div class="_form_element _x26983741 give-welcome-newsletter-fname">
676 <label class="_form-label" style="display: none;">
677 First Name
678 </label>
679 <div class="_field-wrapper">
680 <input type="text" name="firstname" placeholder="Type your first name" value="<?php echo $current_user->user_firstname; ?>"/>
681 </div>
682 </div>
683 <div class="_form_element _x63244763 give-welcome-newsletter-email">
684 <label class="_form-label" style="display: none;">
685 Email*
686 </label>
687 <div class="_field-wrapper">
688 <input type="text" name="email" placeholder="Type your email" value="<?php echo $current_user->user_email; ?>" required/>
689 </div>
690 </div>
691 <div class="_form_element _field1 _full_width give-welcome-newsletter-siteurl" style="display: none;">
692 <label class="_form-label" style="display: none;">
693 Organization Website
694 </label>
695 <div class="_field-wrapper">
696 <input type="text" name="field[1]" value="<?php echo get_home_url(); ?>" placeholder=""/>
697 </div>
698 </div>
699 <div class="_button-wrapper _full_width">
700 <button id="_form_3_submit" class="_submit button button-primary" type="submit">
701 Submit
702 </button>
703 </div>
704 </div>
705 <div class="_form-thank-you" style="display:none;">
706 </div>
707
708 </form>
709 <script type="text/javascript">
710 window.cfields = { "1": "organization_website" };
711 window._show_thank_you = function( id, message, trackcmp_url ) {
712 var form = document.getElementById( '_form_' + id + '_' ),
713 thank_you = form.querySelector( '._form-thank-you' );
714 form.querySelector( '._form-content' ).style.display = 'none';
715 thank_you.innerHTML = message;
716 thank_you.style.display = 'block';
717 if ( typeof ( trackcmp_url ) != 'undefined' && trackcmp_url ) {
718 // Site tracking URL to use after inline form submission.
719 _load_script( trackcmp_url );
720 }
721 if ( typeof window._form_callback !== 'undefined' ) window._form_callback( id );
722 };
723 window._show_error = function( id, message, html ) {
724 var form = document.getElementById( '_form_' + id + '_' ), err = document.createElement( 'div' ),
725 button = form.querySelector( 'button' ), old_error = form.querySelector( '._form_error' );
726 if ( old_error ) old_error.parentNode.removeChild( old_error );
727 err.innerHTML = message;
728 err.className = '_error-inner _form_error _no_arrow';
729 var wrapper = document.createElement( 'div' );
730 wrapper.className = '_form-inner';
731 wrapper.appendChild( err );
732 button.parentNode.insertBefore( wrapper, button );
733 document.querySelector( '[id^="_form"][id$="_submit"]' ).disabled = false;
734 if ( html ) {
735 var div = document.createElement( 'div' );
736 div.className = '_error-html';
737 div.innerHTML = html;
738 err.appendChild( div );
739 }
740 };
741 window._load_script = function( url, callback ) {
742 var head = document.querySelector( 'head' ), script = document.createElement( 'script' ), r = false;
743 script.type = 'text/javascript';
744 script.charset = 'utf-8';
745 script.src = url;
746 if ( callback ) {
747 script.onload = script.onreadystatechange = function() {
748 if ( !r && ( !this.readyState || this.readyState == 'complete' ) ) {
749 r = true;
750 callback();
751 }
752 };
753 }
754 head.appendChild( script );
755 };
756 ( function() {
757 if ( window.location.search.search( "excludeform" ) !== - 1 ) return false;
758 var getCookie = function( name ) {
759 var match = document.cookie.match( new RegExp( '(^|; )' + name + '=([^;]+)' ) );
760 return match ? match[ 2 ] : null;
761 }
762 var setCookie = function( name, value ) {
763 var now = new Date();
764 var time = now.getTime();
765 var expireTime = time + 1000 * 60 * 60 * 24 * 365;
766 now.setTime( expireTime );
767 document.cookie = name + '=' + value + '; expires=' + now + ';path=/';
768 }
769 var addEvent = function( element, event, func ) {
770 if ( element.addEventListener ) {
771 element.addEventListener( event, func );
772 } else {
773 var oldFunc = element[ 'on' + event ];
774 element[ 'on' + event ] = function() {
775 oldFunc.apply( this, arguments );
776 func.apply( this, arguments );
777 };
778 }
779 }
780 var _removed = false;
781 var form_to_submit = document.getElementById( '_form_3_' );
782 var allInputs = form_to_submit.querySelectorAll( 'input, select, textarea' ), tooltips = [],
783 submitted = false;
784
785 var getUrlParam = function( name ) {
786 var regexStr = '[\?&]' + name + '=([^&#]*)';
787 var results = new RegExp( regexStr, 'i' ).exec( window.location.href );
788 return results != undefined ? decodeURIComponent( results[ 1 ] ) : false;
789 };
790
791 for ( var i = 0; i < allInputs.length; i ++ ) {
792 var regexStr = "field\\[(\\d+)\\]";
793 var results = new RegExp( regexStr ).exec( allInputs[ i ].name );
794 if ( results != undefined ) {
795 allInputs[ i ].dataset.name = window.cfields[ results[ 1 ] ];
796 } else {
797 allInputs[ i ].dataset.name = allInputs[ i ].name;
798 }
799 var fieldVal = getUrlParam( allInputs[ i ].dataset.name );
800
801 if ( fieldVal ) {
802 if ( allInputs[ i ].dataset.autofill === "false" ) {
803 continue;
804 }
805 if ( allInputs[ i ].type == "radio" || allInputs[ i ].type == "checkbox" ) {
806 if ( allInputs[ i ].value == fieldVal ) {
807 allInputs[ i ].checked = true;
808 }
809 } else {
810 allInputs[ i ].value = fieldVal;
811 }
812 }
813 }
814
815 var remove_tooltips = function() {
816 for ( var i = 0; i < tooltips.length; i ++ ) {
817 tooltips[ i ].tip.parentNode.removeChild( tooltips[ i ].tip );
818 }
819 tooltips = [];
820 };
821 var remove_tooltip = function( elem ) {
822 for ( var i = 0; i < tooltips.length; i ++ ) {
823 if ( tooltips[ i ].elem === elem ) {
824 tooltips[ i ].tip.parentNode.removeChild( tooltips[ i ].tip );
825 tooltips.splice( i, 1 );
826 return;
827 }
828 }
829 };
830 var create_tooltip = function( elem, text ) {
831 var tooltip = document.createElement( 'div' ), arrow = document.createElement( 'div' ),
832 inner = document.createElement( 'div' ), new_tooltip = {};
833 if ( elem.type != 'radio' && elem.type != 'checkbox' ) {
834 tooltip.className = '_error';
835 arrow.className = '_error-arrow';
836 inner.className = '_error-inner';
837 inner.innerHTML = text;
838 tooltip.appendChild( arrow );
839 tooltip.appendChild( inner );
840 elem.parentNode.appendChild( tooltip );
841 } else {
842 tooltip.className = '_error-inner _no_arrow';
843 tooltip.innerHTML = text;
844 elem.parentNode.insertBefore( tooltip, elem );
845 new_tooltip.no_arrow = true;
846 }
847 new_tooltip.tip = tooltip;
848 new_tooltip.elem = elem;
849 tooltips.push( new_tooltip );
850 return new_tooltip;
851 };
852 var resize_tooltip = function( tooltip ) {
853 var rect = tooltip.elem.getBoundingClientRect();
854 var doc = document.documentElement,
855 scrollPosition = rect.top - ( ( window.pageYOffset || doc.scrollTop ) - ( doc.clientTop || 0 ) );
856 if ( scrollPosition < 40 ) {
857 tooltip.tip.className = tooltip.tip.className.replace( / ?(_above|_below) ?/g, '' ) + ' _below';
858 } else {
859 tooltip.tip.className = tooltip.tip.className.replace( / ?(_above|_below) ?/g, '' ) + ' _above';
860 }
861 };
862 var resize_tooltips = function() {
863 if ( _removed ) return;
864 for ( var i = 0; i < tooltips.length; i ++ ) {
865 if ( !tooltips[ i ].no_arrow ) resize_tooltip( tooltips[ i ] );
866 }
867 };
868 var validate_field = function( elem, remove ) {
869 var tooltip = null, value = elem.value, no_error = true;
870 remove ? remove_tooltip( elem ) : false;
871 if ( elem.type != 'checkbox' ) elem.className = elem.className.replace( / ?_has_error ?/g, '' );
872 if ( elem.getAttribute( 'required' ) !== null ) {
873 if ( elem.type == 'radio' || ( elem.type == 'checkbox' && /any/.test( elem.className ) ) ) {
874 var elems = form_to_submit.elements[ elem.name ];
875 if ( !( elems instanceof NodeList || elems instanceof HTMLCollection ) || elems.length <= 1 ) {
876 no_error = elem.checked;
877 } else {
878 no_error = false;
879 for ( var i = 0; i < elems.length; i ++ ) {
880 if ( elems[ i ].checked ) no_error = true;
881 }
882 }
883 if ( !no_error ) {
884 tooltip = create_tooltip( elem, "Please select an option." );
885 }
886 } else if ( elem.type == 'checkbox' ) {
887 var elems = form_to_submit.elements[ elem.name ], found = false, err = [];
888 no_error = true;
889 for ( var i = 0; i < elems.length; i ++ ) {
890 if ( elems[ i ].getAttribute( 'required' ) === null ) continue;
891 if ( !found && elems[ i ] !== elem ) return true;
892 found = true;
893 elems[ i ].className = elems[ i ].className.replace( / ?_has_error ?/g, '' );
894 if ( !elems[ i ].checked ) {
895 no_error = false;
896 elems[ i ].className = elems[ i ].className + ' _has_error';
897 err.push( "Checking %s is required".replace( "%s", elems[ i ].value ) );
898 }
899 }
900 if ( !no_error ) {
901 tooltip = create_tooltip( elem, err.join( '<br/>' ) );
902 }
903 } else if ( elem.tagName == 'SELECT' ) {
904 var selected = true;
905 if ( elem.multiple ) {
906 selected = false;
907 for ( var i = 0; i < elem.options.length; i ++ ) {
908 if ( elem.options[ i ].selected ) {
909 selected = true;
910 break;
911 }
912 }
913 } else {
914 for ( var i = 0; i < elem.options.length; i ++ ) {
915 if ( elem.options[ i ].selected && !elem.options[ i ].value ) {
916 selected = false;
917 }
918 }
919 }
920 if ( !selected ) {
921 elem.className = elem.className + ' _has_error';
922 no_error = false;
923 tooltip = create_tooltip( elem, "Please select an option." );
924 }
925 } else if ( value === undefined || value === null || value === '' ) {
926 elem.className = elem.className + ' _has_error';
927 no_error = false;
928 tooltip = create_tooltip( elem, "This field is required." );
929 }
930 }
931 if ( no_error && elem.name == 'email' ) {
932 if ( !value.match( /^[\+_a-z0-9-'&=]+(\.[\+_a-z0-9-']+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$/i ) ) {
933 elem.className = elem.className + ' _has_error';
934 no_error = false;
935 tooltip = create_tooltip( elem, "Enter a valid email address." );
936 }
937 }
938 if ( no_error && /date_field/.test( elem.className ) ) {
939 if ( !value.match( /^\d\d\d\d-\d\d-\d\d$/ ) ) {
940 elem.className = elem.className + ' _has_error';
941 no_error = false;
942 tooltip = create_tooltip( elem, "Enter a valid date." );
943 }
944 }
945 tooltip ? resize_tooltip( tooltip ) : false;
946 return no_error;
947 };
948 var needs_validate = function( el ) {
949 return el.name == 'email' || el.getAttribute( 'required' ) !== null;
950 };
951 var validate_form = function( e ) {
952 var err = form_to_submit.querySelector( '._form_error' ), no_error = true;
953 if ( !submitted ) {
954 submitted = true;
955 for ( var i = 0, len = allInputs.length; i < len; i ++ ) {
956 var input = allInputs[ i ];
957 if ( needs_validate( input ) ) {
958 if ( input.type == 'text' ) {
959 addEvent( input, 'blur', function() {
960 this.value = this.value.trim();
961 validate_field( this, true );
962 } );
963 addEvent( input, 'input', function() {
964 validate_field( this, true );
965 } );
966 } else if ( input.type == 'radio' || input.type == 'checkbox' ) {
967 ( function( el ) {
968 var radios = form_to_submit.elements[ el.name ];
969 for ( var i = 0; i < radios.length; i ++ ) {
970 addEvent( radios[ i ], 'click', function() {
971 validate_field( el, true );
972 } );
973 }
974 } )( input );
975 } else if ( input.tagName == 'SELECT' ) {
976 addEvent( input, 'change', function() {
977 validate_field( this, true );
978 } );
979 } else if ( input.type == 'textarea' ) {
980 addEvent( input, 'input', function() {
981 validate_field( this, true );
982 } );
983 }
984 }
985 }
986 }
987 remove_tooltips();
988 for ( var i = 0, len = allInputs.length; i < len; i ++ ) {
989 var elem = allInputs[ i ];
990 if ( needs_validate( elem ) ) {
991 if ( elem.tagName.toLowerCase() !== "select" ) {
992 elem.value = elem.value.trim();
993 }
994 validate_field( elem ) ? true : no_error = false;
995 }
996 }
997 if ( !no_error && e ) {
998 e.preventDefault();
999 }
1000 resize_tooltips();
1001 return no_error;
1002 };
1003 addEvent( window, 'resize', resize_tooltips );
1004 addEvent( window, 'scroll', resize_tooltips );
1005 window._old_serialize = null;
1006 if ( typeof serialize !== 'undefined' ) window._old_serialize = window.serialize;
1007 _load_script( "//d3rxaij56vjege.cloudfront.net/form-serialize/0.3/serialize.min.js", function() {
1008 window._form_serialize = window.serialize;
1009 if ( window._old_serialize ) window.serialize = window._old_serialize;
1010 } );
1011 var form_submit = function( e ) {
1012 e.preventDefault();
1013 if ( validate_form() ) {
1014 // use this trick to get the submit button & disable it using plain javascript
1015 document.querySelector( '#_form_3_submit' ).disabled = true;
1016 var serialized = _form_serialize( document.getElementById( '_form_3_' ) );
1017 var err = form_to_submit.querySelector( '._form_error' );
1018 err ? err.parentNode.removeChild( err ) : false;
1019 _load_script( 'https://givewp.activehosted.com/proc.php?' + serialized + '&jsonp=true' );
1020 }
1021 return false;
1022 };
1023 addEvent( form_to_submit, 'submit', form_submit );
1024 } )();
1025
1026 </script>
1027
1028 </div>
1029
1030
1031 <?php
1032 }
1033
1034 }
1035
1036 new Give_Welcome();
1037