This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Give Welcome Page Class |
||
4 | * |
||
5 | * Displays on plugin activation |
||
6 | * @package Give |
||
7 | * @subpackage Admin/Welcome |
||
8 | * @copyright Copyright (c) 2016, GiveWP |
||
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 { |
||
0 ignored issues
–
show
|
|||
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 | View Code Duplication | public function tabs() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
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: http://docs.givewp.com/docs */ |
||
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( 'http://docs.givewp.com/docs' ) |
||
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/dist/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/" |
||
208 | target="_blank"><?php esc_html_e( 'Visit the Give Website', 'give' ); ?></a></li> |
||
209 | <li><a href="https://givewp.com/features/" |
||
210 | target="_blank"><?php esc_html_e( 'View the Give Features', 'give' ); ?></a></li> |
||
211 | <li><a href="https://givewp.com/documentation/" |
||
212 | target="_blank"><?php esc_html_e( 'Read the Documentation', 'give' ); ?></a></li> |
||
213 | </ul> |
||
214 | |||
215 | </div> |
||
216 | |||
217 | <div class="content feature-section-item last-feature"> |
||
218 | <img src="<?php echo GIVE_PLUGIN_URL . '/assets/dist/images/admin/give-form-mockup.png' ?>" |
||
219 | alt="<?php esc_attr_e( 'A Give donation form', 'give' ); ?>"> |
||
220 | </div> |
||
221 | |||
222 | </div> |
||
223 | <!-- /.feature-section --> |
||
224 | |||
225 | |||
226 | </div> |
||
227 | <?php |
||
228 | } |
||
229 | |||
230 | /** |
||
231 | * Render Changelog Screen |
||
232 | * |
||
233 | * @access public |
||
234 | * @since 1.0 |
||
235 | * @return void |
||
236 | */ |
||
237 | public function changelog_screen() { |
||
238 | list( $display_version ) = explode( '-', GIVE_VERSION ); |
||
239 | ?> |
||
240 | <div class="wrap about-wrap"> |
||
241 | <h1><?php echo get_admin_page_title(); ?></h1> |
||
242 | |||
243 | <p class="about-text"><?php |
||
244 | printf( |
||
245 | /* translators: %s: Give version */ |
||
246 | esc_html__( 'Thank you for updating to the latest version! Give %s is ready to make your online store faster, safer, and better!', 'give' ), |
||
247 | $display_version |
||
248 | ); |
||
249 | ?></p> |
||
250 | <div class="give-badge"><?php |
||
251 | printf( |
||
252 | /* translators: %s: Give version */ |
||
253 | esc_html__( 'Version %s', 'give' ), |
||
254 | $display_version |
||
255 | ); |
||
256 | ?></div> |
||
257 | |||
258 | <?php $this->tabs(); ?> |
||
259 | |||
260 | <div class="changelog"> |
||
261 | <h3><?php esc_html_e( 'Full Changelog', 'give' ); ?></h3> |
||
262 | |||
263 | <div class="feature-section"> |
||
264 | <?php echo $this->parse_readme(); ?> |
||
265 | </div> |
||
266 | </div> |
||
267 | |||
268 | <div class="return-to-dashboard"> |
||
269 | <a href="<?php echo esc_url( admin_url( add_query_arg( array( |
||
270 | 'post_type' => 'give_forms', |
||
271 | 'page' => 'give-settings' |
||
272 | ), 'edit.php' ) ) ); ?>"><?php esc_html_e( 'Give Settings', 'give' ); ?></a> |
||
273 | </div> |
||
274 | </div> |
||
275 | <?php |
||
276 | } |
||
277 | |||
278 | /** |
||
279 | * Render Getting Started Screen |
||
280 | * |
||
281 | * @access public |
||
282 | * @since 1.0 |
||
283 | * @return void |
||
284 | */ |
||
285 | public function getting_started_screen() { |
||
286 | list( $display_version ) = explode( '-', GIVE_VERSION ); |
||
287 | ?> |
||
288 | <div class="wrap about-wrap get-started"> |
||
289 | |||
290 | <?php $this->get_welcome_header() ?> |
||
291 | |||
292 | <p class="about-text"><?php esc_html_e( 'Welcome to the getting started guide.', 'give' ); ?></p> |
||
293 | |||
294 | <?php give_get_newsletter(); ?> |
||
295 | |||
296 | <div class="give-badge"><?php |
||
297 | printf( |
||
298 | /* translators: %s: Give version */ |
||
299 | esc_html__( 'Version %s', 'give' ), |
||
300 | $display_version |
||
301 | ); |
||
302 | ?></div> |
||
303 | |||
304 | <?php $this->tabs(); ?> |
||
305 | |||
306 | <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> |
||
307 | |||
308 | <div class="feature-section clearfix"> |
||
309 | |||
310 | <div class="content feature-section-item"> |
||
311 | <h3><?php esc_html_e( 'STEP 1: Create a New Form', 'give' ); ?></h3> |
||
312 | |||
313 | <p><?php esc_html_e( 'Give is driven by its 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> |
||
314 | |||
315 | <p><?php esc_html_e( 'All of these features begin by simply going to the menu and choosing "Donations > Add Form."', 'give' ); ?></p> |
||
316 | </div> |
||
317 | |||
318 | <div class="content feature-section-item last-feature"> |
||
319 | <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-add-new-form.png"> |
||
320 | </div> |
||
321 | |||
322 | </div> |
||
323 | <!-- /.feature-section --> |
||
324 | |||
325 | <div class="feature-section clearfix"> |
||
326 | |||
327 | <div class="content feature-section-item multi-level-gif"> |
||
328 | <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-new-form-multi-level.gif"> |
||
329 | </div> |
||
330 | |||
331 | <div class="content feature-section-item last-feature"> |
||
332 | <h3><?php esc_html_e( 'STEP 2: Customize Your Donation Forms', 'give' ); ?></h3> |
||
333 | |||
334 | <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> |
||
335 | </div> |
||
336 | |||
337 | </div> |
||
338 | <!-- /.feature-section --> |
||
339 | |||
340 | <div class="feature-section clearfix"> |
||
341 | |||
342 | <div class="content feature-section-item add-content"> |
||
343 | <h3><?php esc_html_e( 'STEP 3: Add Additional Content', 'give' ); ?></h3> |
||
344 | |||
345 | <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> |
||
346 | |||
347 | <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> |
||
348 | </div> |
||
349 | |||
350 | <div class="content feature-section-item last-feature"> |
||
351 | <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-add-content.png"> |
||
352 | </div> |
||
353 | |||
354 | </div> |
||
355 | <!-- /.feature-section --> |
||
356 | |||
357 | <div class="feature-section clearfix"> |
||
358 | |||
359 | <div class="content feature-section-item display-options"> |
||
360 | <img src="<?php echo GIVE_PLUGIN_URL; ?>assets/dist/images/admin/getting-started-display-options.png"> |
||
361 | </div> |
||
362 | |||
363 | <div class="content feature-section-item last-feature"> |
||
364 | <h3><?php esc_html_e( 'STEP 4: Configure Your Display Options', 'give' ); ?></h3> |
||
365 | |||
366 | <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> |
||
367 | </div> |
||
368 | |||
369 | |||
370 | </div> |
||
371 | <!-- /.feature-section --> |
||
372 | |||
373 | |||
374 | </div> |
||
375 | <?php |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * Render Credits Screen |
||
380 | * |
||
381 | * @access public |
||
382 | * @since 1.0 |
||
383 | * @return void |
||
384 | */ |
||
385 | public function credits_screen() { |
||
386 | list( $display_version ) = explode( '-', GIVE_VERSION ); |
||
387 | ?> |
||
388 | <div class="wrap about-wrap"> |
||
389 | |||
390 | <?php $this->get_welcome_header() ?> |
||
391 | |||
392 | <p class="about-text"><?php esc_html_e( 'Thanks to all those who have contributed code directly or indirectly.', 'give' ); ?></p> |
||
393 | |||
394 | <?php give_get_newsletter(); ?> |
||
395 | |||
396 | <div class="give-badge"><?php |
||
397 | printf( |
||
398 | /* translators: %s: Give version */ |
||
399 | esc_html__( 'Version %s', 'give' ), |
||
400 | $display_version |
||
401 | ); |
||
402 | ?></div> |
||
403 | |||
404 | <?php $this->tabs(); ?> |
||
405 | |||
406 | <p class="about-description"><?php |
||
407 | printf( |
||
408 | /* translators: %s: https://github.com/impress-org/give */ |
||
409 | __( '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' ), |
||
410 | esc_url( 'https://github.com/impress-org/give' ) |
||
411 | ); |
||
412 | ?></p> |
||
413 | |||
414 | <?php echo $this->contributors(); ?> |
||
415 | </div> |
||
416 | <?php |
||
417 | } |
||
418 | |||
419 | |||
420 | /** |
||
421 | * Parse the GIVE readme.txt file |
||
422 | * |
||
423 | * @since 1.0 |
||
424 | * @return string $readme HTML formatted readme file |
||
425 | */ |
||
426 | public function parse_readme() { |
||
427 | $file = file_exists( GIVE_PLUGIN_DIR . 'readme.txt' ) ? GIVE_PLUGIN_DIR . 'readme.txt' : null; |
||
428 | |||
429 | if ( ! $file ) { |
||
0 ignored issues
–
show
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 For '' == false // true
'' == null // true
'ab' == false // false
'ab' == null // false
// It is often better to use strict comparison
'' === false // false
'' === null // false
![]() |
|||
430 | $readme = '<p>' . esc_html__( 'No valid changlog was found.', 'give' ) . '</p>'; |
||
431 | } else { |
||
432 | $readme = file_get_contents( $file ); |
||
433 | $readme = nl2br( esc_html( $readme ) ); |
||
434 | $readme = explode( '== Changelog ==', $readme ); |
||
435 | $readme = end( $readme ); |
||
436 | |||
437 | $readme = give_get_format_md( $readme ); |
||
438 | } |
||
439 | |||
440 | return $readme; |
||
441 | } |
||
442 | |||
443 | |||
444 | /** |
||
445 | * Render Contributors List |
||
446 | * |
||
447 | * @since 1.0 |
||
448 | * @uses Give_Welcome::get_contributors() |
||
449 | * @return string $contributor_list HTML formatted list of all the contributors for GIVE |
||
450 | */ |
||
451 | public function contributors() { |
||
452 | $contributors = $this->get_contributors(); |
||
453 | |||
454 | if ( empty( $contributors ) ) { |
||
455 | return ''; |
||
456 | } |
||
457 | |||
458 | $contributor_list = '<ul class="wp-people-group">'; |
||
459 | |||
460 | foreach ( $contributors as $contributor ) { |
||
461 | $contributor_list .= '<li class="wp-person">'; |
||
462 | $contributor_list .= sprintf( |
||
463 | '<a href="%1$s" target="_blank"><img src="%2$s" width="64" height="64" class="gravatar" alt="%3$s" /></a>', |
||
464 | esc_url( 'https://github.com/' . $contributor->login ), |
||
465 | esc_url( $contributor->avatar_url ), |
||
466 | esc_attr( $contributor->login ) |
||
467 | ); |
||
468 | $contributor_list .= sprintf( |
||
469 | '<a class="web" target="_blank" href="%1$s">%2$s</a>', |
||
470 | esc_url( 'https://github.com/' . $contributor->login ), |
||
471 | esc_html( $contributor->login ) |
||
472 | ); |
||
473 | $contributor_list .= '</li>'; |
||
474 | } |
||
475 | |||
476 | $contributor_list .= '</ul>'; |
||
477 | |||
478 | return $contributor_list; |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * Retreive list of contributors from GitHub. |
||
483 | * |
||
484 | * @access public |
||
485 | * @since 1.0 |
||
486 | * @return array $contributors List of contributors |
||
487 | */ |
||
488 | View Code Duplication | public function get_contributors() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
489 | $contributors = Give_Cache::get( 'give_contributors', true ); |
||
490 | |||
491 | if ( false !== $contributors ) { |
||
492 | return $contributors; |
||
493 | } |
||
494 | |||
495 | $response = wp_remote_get( 'https://api.github.com/repos/impress-org/give/contributors', array( 'sslverify' => false ) ); |
||
496 | |||
497 | if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) { |
||
498 | return array(); |
||
499 | } |
||
500 | |||
501 | $contributors = json_decode( wp_remote_retrieve_body( $response ) ); |
||
502 | |||
503 | if ( ! is_array( $contributors ) ) { |
||
504 | return array(); |
||
505 | } |
||
506 | |||
507 | Give_Cache::set( 'give_contributors', $contributors, HOUR_IN_SECONDS, true ); |
||
508 | |||
509 | return $contributors; |
||
510 | } |
||
511 | |||
512 | /** |
||
513 | * The header section for the welcome screen. |
||
514 | * |
||
515 | * @since 1.8.8 |
||
516 | */ |
||
517 | public function get_welcome_header() { |
||
518 | // Badge for welcome page |
||
519 | $badge_url = GIVE_PLUGIN_URL . 'assets/dist/images/give-badge.png'; |
||
520 | ?> |
||
521 | <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1> |
||
522 | <?php $this->social_media_elements(); ?> |
||
523 | |||
524 | <style type="text/css" media="screen"> |
||
525 | /*<![CDATA[*/ |
||
526 | .give-badge { |
||
527 | background: url('<?php echo $badge_url; ?>') no-repeat; |
||
528 | } |
||
529 | |||
530 | /*]]>*/ |
||
531 | </style> |
||
532 | <script> |
||
533 | //FitVids |
||
534 | (function (e) { |
||
535 | "use strict"; |
||
536 | e.fn.fitVids = function (t) { |
||
537 | var n = {customSelector: null, ignore: null}; |
||
538 | if (!document.getElementById("fit-vids-style")) { |
||
539 | var r = document.head || document.getElementsByTagName("head")[0]; |
||
540 | 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%;}"; |
||
541 | var s = document.createElement("div"); |
||
542 | s.innerHTML = '<p>x</p><style id="fit-vids-style">' + i + "</style>"; |
||
543 | r.appendChild(s.childNodes[1]) |
||
544 | } |
||
545 | if (t) { |
||
546 | e.extend(n, t) |
||
547 | } |
||
548 | return this.each(function () { |
||
549 | 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"]; |
||
550 | if (n.customSelector) { |
||
551 | t.push(n.customSelector) |
||
552 | } |
||
553 | var r = ".fitvidsignore"; |
||
554 | if (n.ignore) { |
||
555 | r = r + ", " + n.ignore |
||
556 | } |
||
557 | var i = e(this).find(t.join(",")); |
||
558 | i = i.not("object object"); |
||
559 | i = i.not(r); |
||
560 | i.each(function () { |
||
561 | var t = e(this); |
||
562 | if (t.parents(r).length > 0) { |
||
563 | return |
||
564 | } |
||
565 | if (this.tagName.toLowerCase() === "embed" && t.parent("object").length || t.parent(".fluid-width-video-wrapper").length) { |
||
566 | return |
||
567 | } |
||
568 | if (!t.css("height") && !t.css("width") && (isNaN(t.attr("height")) || isNaN(t.attr("width")))) { |
||
569 | t.attr("height", 9); |
||
570 | t.attr("width", 16) |
||
571 | } |
||
572 | var n = this.tagName.toLowerCase() === "object" || t.attr("height") && !isNaN(parseInt(t.attr("height"), 10)) ? parseInt(t.attr("height"), 10) : t.height(), |
||
573 | i = !isNaN(parseInt(t.attr("width"), 10)) ? parseInt(t.attr("width"), 10) : t.width(), |
||
574 | s = n / i; |
||
575 | if (!t.attr("id")) { |
||
576 | var o = "fitvid" + Math.floor(Math.random() * 999999); |
||
577 | t.attr("id", o) |
||
578 | } |
||
579 | t.wrap('<div class="fluid-width-video-wrapper"></div>').parent(".fluid-width-video-wrapper").css("padding-top", s * 100 + "%"); |
||
580 | t.removeAttr("height").removeAttr("width") |
||
581 | }) |
||
582 | }) |
||
583 | } |
||
584 | })(window.jQuery || window.Zepto); |
||
585 | jQuery(document).ready(function ($) { |
||
586 | |||
587 | // Target your .container, .wrapper, .post, etc. |
||
588 | $(".wrap").fitVids(); |
||
589 | |||
590 | }); |
||
591 | |||
592 | </script> |
||
593 | <?php } |
||
594 | |||
595 | |||
596 | /** |
||
597 | * Social Media Like Buttons |
||
598 | * |
||
599 | * Various social media elements to Give |
||
600 | */ |
||
601 | public function social_media_elements() { ?> |
||
602 | |||
603 | <div class="social-items-wrap"> |
||
604 | |||
605 | <iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Fwpgive&send=false&layout=button_count&width=100&show_faces=false&font&colorscheme=light&action=like&height=21&appId=220596284639969" |
||
606 | scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" |
||
607 | allowTransparency="true"></iframe> |
||
608 | |||
609 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
||
610 | printf( |
||
611 | /* translators: %s: Give twitter user @givewp */ |
||
612 | esc_html_e( 'Follow %s', 'give' ), |
||
613 | '@givewp' |
||
614 | ); |
||
615 | ?></a> |
||
616 | <script>!function (d, s, id) { |
||
617 | var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https'; |
||
618 | if (!d.getElementById(id)) { |
||
619 | js = d.createElement(s); |
||
620 | js.id = id; |
||
621 | js.src = p + '://platform.twitter.com/widgets.js'; |
||
622 | fjs.parentNode.insertBefore(js, fjs); |
||
623 | } |
||
624 | }(document, 'script', 'twitter-wjs'); |
||
625 | </script> |
||
626 | |||
627 | </div> |
||
628 | <!--/.social-items-wrap --> |
||
629 | |||
630 | <?php |
||
631 | } |
||
632 | |||
633 | |||
634 | /** |
||
635 | * Sends user to the Welcome page on first activation of GIVE as well as each |
||
636 | * time GIVE is upgraded to a new version |
||
637 | * |
||
638 | * @access public |
||
639 | * @since 1.0 |
||
640 | * |
||
641 | * @return void |
||
642 | */ |
||
643 | View Code Duplication | public function welcome() { |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
644 | |||
645 | // Bail if no activation redirect |
||
646 | if ( ! Give_Cache::get( '_give_activation_redirect', true ) || wp_doing_ajax() ) { |
||
647 | return; |
||
648 | } |
||
649 | |||
650 | // Delete the redirect transient |
||
651 | Give_Cache::delete( Give_Cache::get_key( '_give_activation_redirect' ) ); |
||
652 | |||
653 | // Bail if activating from network, or bulk |
||
654 | if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
||
655 | return; |
||
656 | } |
||
657 | |||
658 | $upgrade = get_option( 'give_version_upgraded_from' ); |
||
659 | |||
660 | if ( ! $upgrade ) { // First time install |
||
661 | wp_safe_redirect( admin_url( 'index.php?page=give-about' ) ); |
||
662 | exit; |
||
663 | } elseif ( ! give_is_setting_enabled( give_get_option( 'welcome' ) ) ) { // Welcome is disabled in settings |
||
664 | |||
665 | } else { // Welcome is NOT disabled in settings |
||
666 | wp_safe_redirect( admin_url( 'index.php?page=give-about' ) ); |
||
667 | exit; |
||
668 | } |
||
669 | } |
||
670 | |||
671 | } |
||
672 | |||
673 | new Give_Welcome(); |
||
674 |
This check looks for classes that have been defined more than once.
If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.
This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.