Completed
Pull Request — master (#1749)
by Devin
06:21
created

Give_Welcome::get_welcome_header()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 77
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 77
rs 8.9342
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 15.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Give Welcome Page Class
4
 *
5
 * Displays on plugin activation
6
 * @package     Give
7
 * @subpackage  Admin/Welcome
8
 * @copyright   Copyright (c) 2016, WordImpress
9
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
10
 * @since       1.0
11
 */
12
13
// Exit if accessed directly.
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
/**
19
 * Give_Welcome Class
20
 *
21
 * A general class for About and Credits page.
22
 *
23
 * @since 1.0
24
 */
25
class Give_Welcome {
26
27
	/**
28
	 * @var string The capability users should have to view the page
29
	 */
30
	public $minimum_capability = 'manage_options';
31
32
	/**
33
	 * Get things started
34
	 *
35
	 * @since 1.0
36
	 */
37
	public function __construct() {
38
		add_action( 'admin_menu', array( $this, 'admin_menus' ) );
39
		add_action( 'admin_head', array( $this, 'admin_head' ) );
40
		add_action( 'admin_init', array( $this, 'welcome' ) );
41
	}
42
43
	/**
44
	 * Register the Dashboard Pages which are later hidden but these pages
45
	 * are used to render the Welcome and Credits pages.
46
	 *
47
	 * @access public
48
	 * @since  1.0
49
	 * @return void
50
	 */
51
	public function admin_menus() {
52
		list( $display_version ) = explode( '-', GIVE_VERSION );
53
54
		// About Page
55
		add_dashboard_page(
56
		/* translators: %s: Give version */
57
			sprintf( esc_html__( 'Welcome to Give %s', 'give' ), $display_version ),
58
			esc_html__( 'Welcome to Give', 'give' ),
59
			$this->minimum_capability,
60
			'give-about',
61
			array( $this, 'about_screen' )
62
		);
63
64
		// Changelog Page
65
		add_dashboard_page(
66
			esc_html__( 'Give Changelog', 'give' ),
67
			esc_html__( 'Give Changelog', 'give' ),
68
			$this->minimum_capability,
69
			'give-changelog',
70
			array( $this, 'changelog_screen' )
71
		);
72
73
		// Getting Started Page
74
		add_dashboard_page(
75
		/* translators: %s: Give version */
76
			sprintf( esc_html__( 'Give %s - Getting Started Guide', 'give' ), $display_version ),
77
			esc_html__( 'Getting started with Give', 'give' ),
78
			$this->minimum_capability,
79
			'give-getting-started',
80
			array( $this, 'getting_started_screen' )
81
		);
82
83
		// Credits Page
84
		add_dashboard_page(
85
		/* translators: %s: Give version */
86
			sprintf( esc_html__( 'Give %s - Credits', 'give' ), $display_version ),
87
			esc_html__( 'The people that build Give', 'give' ),
88
			$this->minimum_capability,
89
			'give-credits',
90
			array( $this, 'credits_screen' )
91
		);
92
	}
93
94
	/**
95
	 * Hide Individual Dashboard Pages
96
	 *
97
	 * @access public
98
	 * @since  1.0
99
	 * @return void
100
	 */
101
	public function admin_head() {
102
103
		remove_submenu_page( 'index.php', 'give-about' );
104
		remove_submenu_page( 'index.php', 'give-changelog' );
105
		remove_submenu_page( 'index.php', 'give-getting-started' );
106
		remove_submenu_page( 'index.php', 'give-credits' );
107
108
	}
109
110
	/**
111
	 * Navigation tabs
112
	 *
113
	 * @access public
114
	 * @since  1.0
115
	 * @return void
116
	 */
117
	public function tabs() {
118
		$selected = isset( $_GET['page'] ) ? $_GET['page'] : 'give-about';
119
		?>
120
        <h2 class="nav-tab-wrapper">
121
            <a class="nav-tab <?php echo $selected == 'give-about' ? 'nav-tab-active' : ''; ?>"
122
               href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-about' ), 'index.php' ) ) ); ?>">
123
				<?php esc_html_e( 'About Give', 'give' ); ?>
124
            </a>
125
            <a class="nav-tab <?php echo $selected == 'give-getting-started' ? 'nav-tab-active' : ''; ?>"
126
               href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-getting-started' ), 'index.php' ) ) ); ?>">
127
				<?php esc_html_e( 'Getting Started', 'give' ); ?>
128
            </a>
129
            <a class="nav-tab <?php echo $selected == 'give-credits' ? 'nav-tab-active' : ''; ?>"
130
               href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'give-credits' ), 'index.php' ) ) ); ?>">
131
				<?php esc_html_e( 'Credits', 'give' ); ?>
132
            </a>
133
            <a class="nav-tab <?php echo $selected == 'give-add-ons' ? 'nav-tab-active' : ''; ?>"
134
               href="<?php echo esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-addons' ) ); ?>">
135
				<?php esc_html_e( 'Add-ons', 'give' ); ?>
136
            </a>
137
        </h2>
138
		<?php
139
	}
140
141
	/**
142
	 * Render About Screen
143
	 *
144
	 * @access public
145
	 * @since  1.0
146
	 * @return void
147
	 */
148
	public function about_screen() {
149
		list( $display_version ) = explode( '-', GIVE_VERSION );
150
		?>
151
        <div class="wrap about-wrap">
152
153
			<?php $this->get_welcome_header() ?>
154
155
            <p class="about-text"><?php
156
				printf(
157
				/* translators: %s: https://givewp.com/documenation/ */
158
					__( 'Thank you for activating or updating to the latest version of Give! If you\'re a first time user, welcome! You\'re well on your way to empowering your cause. We encourage you to check out the <a href="%s" target="_blank">plugin documentation</a> and getting started guide below.', 'give' ),
159
					esc_url( 'https://givewp.com/documenation/' )
160
				);
161
				?></p>
162
163
			<?php give_get_newsletter(); ?>
164
165
            <div class="give-badge"><?php
166
				printf(
167
				/* translators: %s: Give version */
168
					esc_html__( 'Version %s', 'give' ),
169
					$display_version
170
				);
171
				?></div>
172
173
			<?php $this->tabs(); ?>
174
175
            <div class="feature-section clearfix introduction">
176
177
                <div class="video feature-section-item">
178
                    <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/give-logo-photo-mashup.png' ?>"
179
                         alt="<?php esc_attr_e( 'Give', 'give' ); ?>">
180
                </div>
181
182
                <div class="content feature-section-item last-feature">
183
184
                    <h3><?php esc_html_e( 'Give - Democratizing Generosity', 'give' ); ?></h3>
185
186
                    <p><?php esc_html_e( 'Give empowers you to easily accept donations and setup fundraising campaigns, directly within WordPress. We created Give to provide a better donation experience for you and your users. Robust, flexible, and intuitive, the plugin is built from the ground up to be the goto donation solution for WordPress. Create powerful donation forms, embed them throughout your website, start a campaign, and exceed your fundraising goals with Give. This plugin is actively developed and proudly supported by folks who are dedicated to helping you and your cause.', 'give' ); ?></p>
187
                    <a href="https://givewp.com" target="_blank" class="button-secondary">
188
						<?php esc_html_e( 'Learn More', 'give' ); ?>
189
                        <span class="dashicons dashicons-external"></span>
190
                    </a>
191
192
                </div>
193
194
            </div>
195
            <!-- /.intro-section -->
196
197
            <div class="feature-section clearfix">
198
199
                <div class="content feature-section-item">
200
201
                    <h3><?php esc_html_e( 'Getting to Know Give', 'give' ); ?></h3>
202
203
                    <p><?php esc_html_e( 'Before you get started with Give we suggest you take a look at the online documentation. There you will find the getting started guide which will help you get up and running quickly. If you have a question, issue or bug with the Core plugin please submit an issue on the Give website. We also welcome your feedback and feature requests. Welcome to Give. We hope you much success with your cause.', 'give' ); ?></p>
204
205
                    <h4>Find Out More:</h4>
206
                    <ul class="ul-disc">
207
                        <li><a href="https://givewp.com/" target="_blank"><?php esc_html_e( 'Visit the Give Website', 'give' ); ?></a></li>
208
                        <li><a href="https://givewp.com/features/" target="_blank"><?php esc_html_e( 'View the Give Features', 'give' ); ?></a></li>
209
                        <li><a href="https://givewp.com/documentation/" target="_blank"><?php esc_html_e( 'Read the Documentation', 'give' ); ?></a></li>
210
                    </ul>
211
212
                </div>
213
214
                <div class="content  feature-section-item last-feature">
215
                    <img src="<?php echo GIVE_PLUGIN_URL . '/assets/images/admin/give-form-mockup.png' ?>"
216
                         alt="<?php esc_attr_e( 'A Give donation form', 'give' ); ?>">
217
                </div>
218
219
            </div>
220
            <!-- /.feature-section -->
221
222
223
        </div>
224
		<?php
225
	}
226
227
	/**
228
	 * Render Changelog Screen
229
	 *
230
	 * @access public
231
	 * @since  1.0
232
	 * @return void
233
	 */
234
	public function changelog_screen() {
235
		list( $display_version ) = explode( '-', GIVE_VERSION );
236
		?>
237
        <div class="wrap about-wrap">
238
            <h1><?php echo get_admin_page_title(); ?></h1>
239
240
            <p class="about-text"><?php
241
				printf(
242
				/* translators: %s: Give version */
243
					esc_html__( 'Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give' ),
244
					$display_version
245
				);
246
				?></p>
247
            <div class="give-badge"><?php
248
				printf(
249
				/* translators: %s: Give version */
250
					esc_html__( 'Version %s', 'give' ),
251
					$display_version
252
				);
253
				?></div>
254
255
			<?php $this->tabs(); ?>
256
257
            <div class="changelog">
258
                <h3><?php esc_html_e( 'Full Changelog', 'give' ); ?></h3>
259
260
                <div class="feature-section">
261
					<?php echo $this->parse_readme(); ?>
262
                </div>
263
            </div>
264
265
            <div class="return-to-dashboard">
266
                <a href="<?php echo esc_url( admin_url( add_query_arg( array(
267
					'post_type' => 'give_forms',
268
					'page'      => 'give-settings'
269
				), 'edit.php' ) ) ); ?>"><?php esc_html_e( 'Give Settings', 'give' ); ?></a>
270
            </div>
271
        </div>
272
		<?php
273
	}
274
275
	/**
276
	 * Render Getting Started Screen
277
	 *
278
	 * @access public
279
	 * @since  1.0
280
	 * @return void
281
	 */
282
	public function getting_started_screen() {
283
		list( $display_version ) = explode( '-', GIVE_VERSION );
284
		?>
285
        <div class="wrap about-wrap get-started">
286
287
			<?php $this->get_welcome_header() ?>
288
289
            <p class="about-text"><?php esc_html_e( 'Welcome to the getting started guide.', 'give' ); ?></p>
290
291
			<?php give_get_newsletter(); ?>
292
293
            <div class="give-badge"><?php
294
				printf(
295
				/* translators: %s: Give version */
296
					esc_html__( 'Version %s', 'give' ),
297
					$display_version
298
				);
299
				?></div>
300
301
			<?php $this->tabs(); ?>
302
303
            <p class="about-text"><?php printf( esc_html__( 'Getting started with Give is easy! We put together this quick start guide to help first time users of the plugin. Our goal is to get you up and running in no time. Let\'s begin!', 'give' ), $display_version ); ?></p>
304
305
            <div class="feature-section clearfix">
306
307
                <div class="content feature-section-item">
308
                    <h3><?php esc_html_e( 'STEP 1: Create a New Form', 'give' ); ?></h3>
309
310
                    <p><?php esc_html_e( 'Give is driven by it\'s powerful donation form building features. However, it is much more than just a "donation form". From the "Add Form" page you\'ll be able to choose how and where you want to receive your donations. You will also be able to set the preferred donation amounts.', 'give' ); ?></p>
311
312
                    <p><?php esc_html_e( 'All of these features begin by simply going to the menu and choosing "Donations > Add Form".', 'give' ); ?></p>
313
                </div>
314
315
                <div class="content feature-section-item last-feature">
316
                    <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/images/admin/getting-started-add-new-form.png">
317
                </div>
318
319
            </div>
320
            <!-- /.feature-section -->
321
322
            <div class="feature-section clearfix">
323
324
                <div class="content feature-section-item multi-level-gif">
325
                    <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/images/admin/getting-started-new-form-multi-level.gif">
326
                </div>
327
328
                <div class="content feature-section-item last-feature">
329
                    <h3><?php esc_html_e( 'STEP 2: Customize Your Donation Forms', 'give' ); ?></h3>
330
331
                    <p><?php esc_html_e( 'Each donation form you create can be customized to receive either a pre-determined set donation amount or have multiple suggested levels of giving. Choosing "Multi-level Donation" opens up the donation levels view where you can add as many levels as you\'d like with your own custom names and suggested amounts. As well, you can allow donors to give a custom amount and even set up donation goals.', 'give' ); ?></p>
332
                </div>
333
334
            </div>
335
            <!-- /.feature-section -->
336
337
            <div class="feature-section clearfix">
338
339
                <div class="content feature-section-item add-content">
340
                    <h3><?php esc_html_e( 'STEP 3: Add Additional Content', 'give' ); ?></h3>
341
342
                    <p><?php esc_html_e( 'Every donation form you create with Give can be used on its own stand-alone page, or it can be inserted into any other page or post throughout your site via a shortcode or widget.', 'give' ); ?></p>
343
344
                    <p><?php esc_html_e( 'You can choose these different modes by going to the "Form Content" section. From there, you can choose to add content before or after the donation form on a page, or if you choose "None" perhaps you want to instead use the shortcode. You can find the shortcode in the top right column directly under the Publish/Save button. This feature gives you the most amount of flexibility with controlling your content on your website all within the same page.', 'give' ); ?></p>
345
                </div>
346
347
                <div class="content feature-section-item last-feature">
348
                    <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/images/admin/getting-started-add-content.png">
349
                </div>
350
351
            </div>
352
            <!-- /.feature-section -->
353
354
            <div class="feature-section clearfix">
355
356
                <div class="content feature-section-item display-options">
357
                    <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/images/admin/getting-started-display-options.png">
358
                </div>
359
360
                <div class="content feature-section-item last-feature">
361
                    <h3><?php esc_html_e( 'STEP 4: Configure Your Display Options', 'give' ); ?></h3>
362
363
                    <p><?php esc_html_e( 'Lastly, you can present the form in a number of different ways that each create their own unique donor experience. The "Modal" display mode opens the credit card fieldset within a popup window. The "Reveal" mode will slide into place the additional fields. If you\'re looking for a simple button, then "Button" more is the way to go. This allows you to create a customizable "Donate Now" button which will open the donation form upon clicking. There\'s tons of possibilities here, give it a try!', 'give' ); ?></p>
364
                </div>
365
366
367
            </div>
368
            <!-- /.feature-section -->
369
370
371
        </div>
372
		<?php
373
	}
374
375
	/**
376
	 * Render Credits Screen
377
	 *
378
	 * @access public
379
	 * @since  1.0
380
	 * @return void
381
	 */
382
	public function credits_screen() {
383
		list( $display_version ) = explode( '-', GIVE_VERSION );
384
		?>
385
        <div class="wrap about-wrap">
386
387
			<?php $this->get_welcome_header() ?>
388
389
            <p class="about-text"><?php esc_html_e( 'Thanks to all those who have contributed code directly or indirectly.', 'give' ); ?></p>
390
391
			<?php give_get_newsletter(); ?>
392
393
            <div class="give-badge"><?php
394
				printf(
395
				/* translators: %s: Give version */
396
					esc_html__( 'Version %s', 'give' ),
397
					$display_version
398
				);
399
				?></div>
400
401
			<?php $this->tabs(); ?>
402
403
            <p class="about-description"><?php
404
				printf(
405
				/* translators: %s: https://github.com/WordImpress/give */
406
					__( 'Give is created by a dedicated team of developers. If you are interested in contributing please visit the <a href="%s" target="_blank">GitHub Repo</a>.', 'give' ),
407
					esc_url( 'https://github.com/WordImpress/give' )
408
				);
409
				?></p>
410
411
			<?php echo $this->contributors(); ?>
412
        </div>
413
		<?php
414
	}
415
416
417
	/**
418
	 * Parse the GIVE readme.txt file
419
	 *
420
	 * @since 1.0
421
	 * @return string $readme HTML formatted readme file
422
	 */
423
	public function parse_readme() {
424
		$file = file_exists( GIVE_PLUGIN_DIR . 'readme.txt' ) ? GIVE_PLUGIN_DIR . 'readme.txt' : null;
425
426
		if ( ! $file ) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $file of type string|null is loosely compared to false; this is ambiguous if the string can be empty. You might want to explicitly use === null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
427
			$readme = '<p>' . esc_html__( 'No valid changlog was found.', 'give' ) . '</p>';
428
		} else {
429
			$readme = file_get_contents( $file );
430
			$readme = nl2br( esc_html( $readme ) );
431
			$readme = explode( '== Changelog ==', $readme );
432
			$readme = end( $readme );
433
434
			$readme = preg_replace( '/`(.*?)`/', '<code>\\1</code>', $readme );
435
			$readme = preg_replace( '/[\040]\*\*(.*?)\*\*/', ' <strong>\\1</strong>', $readme );
436
			$readme = preg_replace( '/[\040]\*(.*?)\*/', ' <em>\\1</em>', $readme );
437
			$readme = preg_replace( '/= (.*?) =/', '<h4>\\1</h4>', $readme );
438
			$readme = preg_replace( '/\[(.*?)\]\((.*?)\)/', '<a href="\\2">\\1</a>', $readme );
439
		}
440
441
		return $readme;
442
	}
443
444
445
	/**
446
	 * Render Contributors List
447
	 *
448
	 * @since 1.0
449
	 * @uses  Give_Welcome::get_contributors()
450
	 * @return string $contributor_list HTML formatted list of all the contributors for GIVE
451
	 */
452
	public function contributors() {
453
		$contributors = $this->get_contributors();
454
455
		if ( empty( $contributors ) ) {
456
			return '';
457
		}
458
459
		$contributor_list = '<ul class="wp-people-group">';
460
461
		foreach ( $contributors as $contributor ) {
462
			$contributor_list .= '<li class="wp-person">';
463
			$contributor_list .= sprintf(
464
				'<a href="%1$s" target="_blank"><img src="%2$s" width="64" height="64" class="gravatar" alt="%3$s" /></a>',
465
				esc_url( 'https://github.com/' . $contributor->login ),
466
				esc_url( $contributor->avatar_url ),
467
				esc_attr( $contributor->login )
468
			);
469
			$contributor_list .= sprintf(
470
				'<a class="web" target="_blank" href="%1$s">%2$s</a>',
471
				esc_url( 'https://github.com/' . $contributor->login ),
472
				esc_html( $contributor->login )
473
			);
474
			$contributor_list .= '</li>';
475
		}
476
477
		$contributor_list .= '</ul>';
478
479
		return $contributor_list;
480
	}
481
482
	/**
483
	 * Retreive list of contributors from GitHub.
484
	 *
485
	 * @access public
486
	 * @since  1.0
487
	 * @return array $contributors List of contributors
488
	 */
489
	public function get_contributors() {
490
		$contributors = Give_Cache::get( 'give_contributors', true );
491
492
		if ( false !== $contributors ) {
493
			return $contributors;
494
		}
495
496
		$response = wp_remote_get( 'https://api.github.com/repos/WordImpress/Give/contributors', array( 'sslverify' => false ) );
497
498
		if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) {
499
			return array();
500
		}
501
502
		$contributors = json_decode( wp_remote_retrieve_body( $response ) );
503
504
		if ( ! is_array( $contributors ) ) {
505
			return array();
506
		}
507
508
		Give_Cache::set( 'give_contributors', $contributors, HOUR_IN_SECONDS, true );
509
510
		return $contributors;
511
	}
512
513
	/**
514
	 * The header section for the welcome screen.
515
	 *
516
	 * @since 1.8.8
517
	 */
518
	public function get_welcome_header() {
519
		// Badge for welcome page
520
		$badge_url = GIVE_PLUGIN_URL . 'assets/images/give-badge.png';
521
		?>
522
        <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1>
523
		<?php $this->social_media_elements(); ?>
524
525
        <style type="text/css" media="screen">
526
            /*<![CDATA[*/
527
            .give-badge {
528
                background: url('<?php echo $badge_url; ?>') no-repeat;
529
            }
530
531
            /*]]>*/
532
        </style>
533
        <script>
534
            //FitVids
535
            (function (e) {
536
                "use strict";
537
                e.fn.fitVids = function (t) {
538
                    var n = {customSelector: null, ignore: null};
539
                    if (!document.getElementById("fit-vids-style")) {
540
                        var r = document.head || document.getElementsByTagName("head")[0];
541
                        var i = ".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";
542
                        var s = document.createElement("div");
543
                        s.innerHTML = '<p>x</p><style id="fit-vids-style">' + i + "</style>";
544
                        r.appendChild(s.childNodes[1])
545
                    }
546
                    if (t) {
547
                        e.extend(n, t)
548
                    }
549
                    return this.each(function () {
550
                        var t = ['iframe[src*="player.vimeo.com"]', 'iframe[src*="youtube.com"]', 'iframe[src*="youtube-nocookie.com"]', 'iframe[src*="kickstarter.com"][src*="video.html"]', "object", "embed"];
551
                        if (n.customSelector) {
552
                            t.push(n.customSelector)
553
                        }
554
                        var r = ".fitvidsignore";
555
                        if (n.ignore) {
556
                            r = r + ", " + n.ignore
557
                        }
558
                        var i = e(this).find(t.join(","));
559
                        i = i.not("object object");
560
                        i = i.not(r);
561
                        i.each(function () {
562
                            var t = e(this);
563
                            if (t.parents(r).length > 0) {
564
                                return
565
                            }
566
                            if (this.tagName.toLowerCase() === "embed" && t.parent("object").length || t.parent(".fluid-width-video-wrapper").length) {
567
                                return
568
                            }
569
                            if (!t.css("height") && !t.css("width") && (isNaN(t.attr("height")) || isNaN(t.attr("width")))) {
570
                                t.attr("height", 9);
571
                                t.attr("width", 16)
572
                            }
573
                            var n = this.tagName.toLowerCase() === "object" || t.attr("height") && !isNaN(parseInt(t.attr("height"), 10)) ? parseInt(t.attr("height"), 10) : t.height(),
574
                                i = !isNaN(parseInt(t.attr("width"), 10)) ? parseInt(t.attr("width"), 10) : t.width(),
575
                                s = n / i;
576
                            if (!t.attr("id")) {
577
                                var o = "fitvid" + Math.floor(Math.random() * 999999);
578
                                t.attr("id", o)
579
                            }
580
                            t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top", s * 100 + "%");
581
                            t.removeAttr("height").removeAttr("width")
582
                        })
583
                    })
584
                }
585
            })(window.jQuery || window.Zepto);
586
            jQuery(document).ready(function ($) {
587
588
                // Target your .container, .wrapper, .post, etc.
589
                $(".wrap").fitVids();
590
591
            });
592
593
        </script>
594
	<?php }
595
596
597
	/**
598
	 * Social Media Like Buttons
599
	 *
600
	 * Various social media elements to Give
601
	 */
602
	public function social_media_elements() { ?>
603
604
        <div class="social-items-wrap">
605
606
            <iframe 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"
607
                    scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;"
608
                    allowTransparency="true"></iframe>
609
610
            <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php
611
				printf(
612
				/* translators: %s: Give twitter user @givewp */
613
					esc_html_e( 'Follow %s', 'give' ),
614
					'@givewp'
615
				);
616
				?></a>
617
            <script>!function (d, s, id) {
618
                    var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
619
                    if (!d.getElementById(id)) {
620
                        js = d.createElement(s);
621
                        js.id = id;
622
                        js.src = p + '://platform.twitter.com/widgets.js';
623
                        fjs.parentNode.insertBefore(js, fjs);
624
                    }
625
                }(document, 'script', 'twitter-wjs');
626
            </script>
627
628
        </div>
629
        <!--/.social-items-wrap -->
630
631
		<?php
632
	}
633
634
635
	/**
636
	 * Sends user to the Welcome page on first activation of GIVE as well as each
637
	 * time GIVE is upgraded to a new version
638
	 *
639
	 * @access public
640
	 * @since  1.0
641
	 *
642
	 * @return void
643
	 */
644
	public function welcome() {
645
646
		// Bail if no activation redirect
647
		if ( ! Give_Cache::get( '_give_activation_redirect', true ) ) {
648
			return;
649
		}
650
651
		// Delete the redirect transient
652
		Give_Cache::delete( Give_Cache::get_key( '_give_activation_redirect' ) );
653
654
		// Bail if activating from network, or bulk
655
		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
656
			return;
657
		}
658
659
		$upgrade = get_option( 'give_version_upgraded_from' );
660
661
		if ( ! $upgrade ) { // First time install
662
			wp_safe_redirect( admin_url( 'index.php?page=give-about' ) );
663
			exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method welcome() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
664
		} elseif ( ! give_is_setting_enabled( give_get_option( 'welcome' ) ) ) { // Welcome is disabled in settings
0 ignored issues
show
Unused Code introduced by
This elseif statement is empty, and could be removed.

This check looks for the bodies of elseif statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These elseif bodies can be removed. If you have an empty elseif but statements in the else branch, consider inverting the condition.

Loading history...
665
666
		} else { // Welcome is NOT disabled in settings
667
			wp_safe_redirect( admin_url( 'index.php?page=give-about' ) );
668
			exit;
0 ignored issues
show
Coding Style Compatibility introduced by
The method welcome() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
669
		}
670
	}
671
672
}
673
674
new Give_Welcome();
675