PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.1.7
GiveWP – Donation Plugin and Fundraising Platform v2.1.7
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 / plugins.php
give / includes / admin Last commit date
donors 8 years ago emails 8 years ago forms 8 years ago payments 8 years ago reports 8 years ago settings 8 years ago shortcodes 8 years ago tools 8 years ago upgrades 7 years ago views 8 years ago EDD_SL_Plugin_Updater.php 8 years ago abstract-admin-settings-page.php 8 years ago add-ons.php 8 years ago admin-actions.php 8 years ago admin-filters.php 8 years ago admin-footer.php 8 years ago admin-pages.php 8 years ago class-addon-activation-banner.php 8 years ago class-admin-settings.php 8 years ago class-api-keys-table.php 8 years ago class-blank-slate.php 8 years ago class-give-settings.php 8 years ago class-i18n-module.php 8 years ago dashboard-widgets.php 8 years ago give-metabox-functions.php 8 years ago plugins.php 8 years ago welcome.php 8 years ago
plugins.php
418 lines
1 <?php
2 /**
3 * Admin Plugins
4 *
5 * @package Give
6 * @subpackage Admin/Plugins
7 * @copyright Copyright (c) 2016, WordImpress
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 1.4
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Plugins row action links
19 *
20 * @since 1.4
21 *
22 * @param array $actions An array of plugin action links.
23 *
24 * @return array An array of updated action links.
25 */
26 function give_plugin_action_links( $actions ) {
27 $new_actions = array(
28 'settings' => sprintf(
29 '<a href="%1$s">%2$s</a>',
30 admin_url( 'edit.php?post_type=give_forms&page=give-settings' ),
31 __( 'Settings', 'give' )
32 ),
33 );
34
35 return array_merge( $new_actions, $actions );
36 }
37
38 add_filter( 'plugin_action_links_' . GIVE_PLUGIN_BASENAME, 'give_plugin_action_links' );
39
40
41 /**
42 * Plugin row meta links
43 *
44 * @since 1.4
45 *
46 * @param array $plugin_meta An array of the plugin's metadata.
47 * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
48 *
49 * @return array
50 */
51 function give_plugin_row_meta( $plugin_meta, $plugin_file ) {
52 if ( GIVE_PLUGIN_BASENAME !== $plugin_file ) {
53 return $plugin_meta;
54 }
55
56 $new_meta_links = array(
57 sprintf(
58 '<a href="%1$s" target="_blank">%2$s</a>',
59 esc_url(
60 add_query_arg(
61 array(
62 'utm_source' => 'plugins-page',
63 'utm_medium' => 'plugin-row',
64 'utm_campaign' => 'admin',
65 ), 'https://givewp.com/documentation/'
66 )
67 ),
68 __( 'Documentation', 'give' )
69 ),
70 sprintf(
71 '<a href="%1$s" target="_blank">%2$s</a>',
72 esc_url(
73 add_query_arg(
74 array(
75 'utm_source' => 'plugins-page',
76 'utm_medium' => 'plugin-row',
77 'utm_campaign' => 'admin',
78 ), 'https://givewp.com/addons/'
79 )
80 ),
81 __( 'Add-ons', 'give' )
82 ),
83 );
84
85 return array_merge( $plugin_meta, $new_meta_links );
86 }
87
88 add_filter( 'plugin_row_meta', 'give_plugin_row_meta', 10, 2 );
89
90
91 /**
92 * Get the Parent Page Menu Title in admin section.
93 * Based on get_admin_page_title WordPress Function.
94 *
95 * @since 1.8.17
96 *
97 * @global array $submenu
98 * @global string $plugin_page
99 *
100 * @return string $title Page title
101 */
102 function give_get_admin_page_menu_title() {
103 $title = '';
104 global $submenu, $plugin_page;
105
106 foreach ( array_keys( $submenu ) as $parent ) {
107 if ( 'edit.php?post_type=give_forms' !== $parent ) {
108 continue;
109 }
110
111 foreach ( $submenu[ $parent ] as $submenu_array ) {
112 if ( $plugin_page !== $submenu_array[2] ) {
113 continue;
114 }
115
116 $title = isset( $submenu_array[0] ) ?
117 $submenu_array[0] :
118 $submenu_array[3];
119 }
120 }
121
122 return $title;
123 }
124
125 /**
126 * Store recently activated Give's addons to wp options.
127 *
128 * @since 2.1.0
129 */
130 function give_recently_activated_addons() {
131 // Check if action is set.
132 if ( isset( $_REQUEST['action'] ) ) {
133 $plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' );
134 $plugins = array();
135
136 switch ( $plugin_action ) {
137 case 'activate': // Single add-on activation.
138 $plugins[] = $_REQUEST['plugin'];
139 break;
140 case 'activate-selected': // If multiple add-ons activated.
141 $plugins = $_REQUEST['checked'];
142 break;
143 }
144
145
146 if ( ! empty( $plugins ) ) {
147
148 $give_addons = give_get_recently_activated_addons();
149
150 foreach ( $plugins as $plugin ) {
151 // Get plugins which has 'Give-' as prefix.
152 if ( stripos( $plugin, 'Give-' ) !== false ) {
153 $give_addons[] = $plugin;
154 }
155 }
156
157 if ( ! empty( $give_addons ) ) {
158 // Update the Give's activated add-ons.
159 update_option( 'give_recently_activated_addons', $give_addons );
160 }
161 }
162 }
163 }
164
165 // Add add-on plugins to wp option table.
166 add_action( 'activated_plugin', 'give_recently_activated_addons', 10 );
167
168 /**
169 * Create new menu in plugin section that include all the add-on
170 *
171 * @since 2.1.0
172 *
173 * @param $plugin_menu
174 *
175 * @return mixed
176 */
177 function give_filter_addons_do_filter_addons( $plugin_menu ) {
178 global $plugins;
179
180 foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) {
181
182 if ( false !== strpos( $plugin_data['Name'], 'Give' ) && false !== strpos( $plugin_data['AuthorName'], 'WordImpress' ) ) {
183 $plugins['give'][ $plugin_slug ] = $plugins['all'][ $plugin_slug ];
184 $plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug;
185 // replicate the next step.
186 if ( current_user_can( 'update_plugins' ) ) {
187 $current = get_site_transient( 'update_plugins' );
188 if ( isset( $current->response[ $plugin_slug ] ) ) {
189 $plugins['give'][ $plugin_slug ]['update'] = true;
190 }
191 }
192 }
193 }
194
195 return $plugin_menu;
196
197 }
198
199 add_filter( 'show_advanced_plugins', 'give_filter_addons_do_filter_addons' );
200 add_filter( 'show_network_active_plugins', 'give_filter_addons_do_filter_addons' );
201
202 /**
203 * Make the Give Menu as an default menu and update the Menu Name
204 *
205 * @since 2.1.0
206 *
207 * @param $views
208 *
209 * @return mixed
210 */
211 function give_filter_addons_filter_addons( $views ) {
212
213 global $status, $plugins;
214
215 if ( ! empty( $plugins['give'] ) ) {
216 $class = '';
217
218 if ( 'give' === $status ) {
219 $class = 'current';
220 }
221
222 $views['give'] = sprintf(
223 '<a class="%s" href="plugins.php?plugin_status=give"> %s <span class="count">(%s) </span></a>',
224 $class,
225 __( 'Give', 'give' ),
226 count( $plugins['give'] )
227 );
228 }
229
230 return $views;
231 }
232
233 add_filter( 'views_plugins', 'give_filter_addons_filter_addons' );
234 add_filter( 'views_plugins-network', 'give_filter_addons_filter_addons' );
235
236 /**
237 * Set the Give as the Main menu when admin click on the Give Menu in Plugin section.
238 *
239 * @since 2.1.0
240 *
241 * @param $plugins
242 *
243 * @return mixed
244 */
245 function give_prepare_filter_addons( $plugins ) {
246 global $status;
247
248 if ( isset( $_REQUEST['plugin_status'] ) && 'give' === $_REQUEST['plugin_status'] ) {
249 $status = 'give';
250 }
251
252 return $plugins;
253 }
254
255 add_filter( 'all_plugins', 'give_prepare_filter_addons' );
256
257
258 /**
259 * Display the upgrade notice message.
260 *
261 * @param array $data Array of plugin metadata.
262 * @param array $response An array of metadata about the available plugin update.
263 *
264 * @since 2.1
265 */
266 function give_in_plugin_update_message( $data, $response ) {
267 $new_version = $data['new_version'];
268 $current_version_parts = explode( '.', GIVE_VERSION );
269 $new_version_parts = explode( '.', $new_version );
270
271 // If it is a minor upgrade then return.
272 if ( version_compare( $current_version_parts[0] . '.' . $current_version_parts[1], $new_version_parts[0] . '.' . $new_version_parts[1], '=' ) ) {
273
274 return;
275 }
276
277 // Get the upgrade notice from the trunk.
278 $upgrade_notice = give_get_plugin_upgrade_notice( $new_version );
279
280 // Display upgrade notice.
281 echo apply_filters( 'give_in_plugin_update_message', $upgrade_notice ? '</p>' . wp_kses_post( $upgrade_notice ) . '<p class="dummy">' : '' );
282 }
283
284 // Display upgrade notice.
285 add_action( 'in_plugin_update_message-' . GIVE_PLUGIN_BASENAME, 'give_in_plugin_update_message', 10, 2 );
286
287
288 /**
289 * Get the upgrade notice from WordPress.org.
290 *
291 * Note: internal purpose use only
292 *
293 * @since 2.1
294 *
295 * @param string $new_version New verison of the plugin.
296 *
297 * @return string
298 */
299 function give_get_plugin_upgrade_notice( $new_version ) {
300
301 // Cache the upgrade notice.
302 $transient_name = "give_upgrade_notice_{$new_version}";
303 $upgrade_notice = get_transient( $transient_name );
304
305 if ( false === $upgrade_notice ) {
306 $response = wp_safe_remote_get( 'https://plugins.svn.wordpress.org/give/trunk/readme.txt' );
307
308 if ( ! is_wp_error( $response ) && ! empty( $response['body'] ) ) {
309 $upgrade_notice = give_parse_plugin_update_notice( $response['body'], $new_version );
310 set_transient( $transient_name, $upgrade_notice, DAY_IN_SECONDS );
311 }
312 }
313
314 return $upgrade_notice;
315 }
316
317
318 /**
319 * Parse update notice from readme file.
320 *
321 * Note: internal purpose use only
322 *
323 * @since 2.1
324 *
325 * @param string $content Content of the readme.txt file.
326 * @param string $new_version The version with current version is compared.
327 *
328 * @return string
329 */
330 function give_parse_plugin_update_notice( $content, $new_version ) {
331 $version_parts = explode( '.', $new_version );
332 $check_for_notices = array(
333 $version_parts[0] . '.0',
334 $version_parts[0] . '.0.0',
335 $version_parts[0] . '.' . $version_parts[1] . '.' . '0',
336 );
337
338 // Regex to extract Upgrade notice from the readme.txt file.
339 $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
340
341 $upgrade_notice = '';
342
343 foreach ( $check_for_notices as $check_version ) {
344 if ( version_compare( GIVE_VERSION, $check_version, '>' ) ) {
345 continue;
346 }
347
348 $matches = null;
349
350 if ( preg_match( $notice_regexp, $content, $matches ) ) {
351 $notices = (array) preg_split( '~[\r\n]+~', trim( $matches[2] ) );
352
353 if ( version_compare( trim( $matches[1] ), $check_version, '=' ) ) {
354 $upgrade_notice .= '<p class="give-plugin-upgrade-notice">';
355
356 foreach ( $notices as $index => $line ) {
357 $upgrade_notice .= preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line );
358 }
359
360 $upgrade_notice .= '</p>';
361 }
362
363 if ( ! empty( $upgrade_notice ) ) {
364 break;
365 }
366 }
367 }
368
369 return wp_kses_post( $upgrade_notice );
370 }
371
372
373 /**
374 * Add styling to the plugin upgrade notice.
375 *
376 * @since 2.1
377 */
378 function give_plugin_notice_css() {
379 ?>
380 <style type="text/css">
381 #give-update .give-plugin-upgrade-notice {
382 font-weight: 400;
383 background: #fff8e5!important;
384 border-left: 4px solid #ffb900;
385 border-top: 1px solid #ffb900;
386 padding: 9px 0 9px 12px!important;
387 margin: 0 -12px 0 -16px!important;
388 }
389
390 #give-update .give-plugin-upgrade-notice:before {
391 content: '\f348';
392 display: inline-block;
393 font: 400 18px/1 dashicons;
394 speak: none;
395 margin: 0 8px 0 -2px;
396 vertical-align: top;
397 }
398
399 #give-update .dummy {
400 display: none;
401 }
402 </style>
403 <?php
404 }
405
406 add_action( 'admin_head', 'give_plugin_notice_css' );
407
408 /**
409 * Get list of add-on last activated.
410 *
411 * @since 2.1.3
412 *
413 * @return mixed|array list of recently activated add-on
414 */
415 function give_get_recently_activated_addons() {
416 return get_option( 'give_recently_activated_addons', array() );
417 }
418