PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / admin / class-extensions.php
foogallery / includes / admin Last commit date
class-admin-notice-custom-css.php 4 weeks ago class-admin-notices.php 4 weeks ago class-admin.php 4 weeks ago class-attachment-fields.php 4 weeks ago class-columns.php 4 weeks ago class-demo-content.php 4 weeks ago class-extensions.php 4 weeks ago class-gallery-attachment-modal.php 4 weeks ago class-gallery-datasources.php 4 weeks ago class-gallery-editor.php 4 weeks ago class-gallery-metabox-fields.php 4 weeks ago class-gallery-metabox-items.php 4 weeks ago class-gallery-metabox-settings-helper.php 4 weeks ago class-gallery-metabox-settings.php 4 weeks ago class-gallery-metabox-template.php 4 weeks ago class-gallery-metaboxes.php 4 weeks ago class-menu.php 4 weeks ago class-pro-promotion.php 4 weeks ago class-settings.php 4 weeks ago class-silent-installer-skin.php 4 weeks ago class-trial-mode.php 4 weeks ago demo-content-galleries.php 4 weeks ago demo-content-images.php 4 weeks ago index.php 4 weeks ago pro-features.php 4 weeks ago view-features.php 4 weeks ago view-help-demos.php 4 weeks ago view-help-getting-started.php 4 weeks ago view-help-pro.php 4 weeks ago view-help.php 4 weeks ago view-system-info.php 4 weeks ago
class-extensions.php
113 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /*
8 * FooGallery Admin Extension class
9 */
10
11 if ( ! class_exists( 'FooGallery_Admin_Extensions' ) ) {
12
13 class FooGallery_Admin_Extensions {
14
15 function __construct() {
16 add_action( 'init', array( $this, 'init' ) );
17 add_action( 'deactivated_plugin', array( $this, 'handle_extensions_deactivation' ), 10, 2 );
18 add_action( 'activated_plugin', array( $this, 'handle_extensions_activation' ), 10, 2 );
19 }
20
21 function init() {
22 add_action( 'admin_init', array( $this, 'handle_extension_action' ) );
23 }
24
25 function handle_extensions_deactivation( $plugin, $network_deactivating ) {
26 //make sure that if we are dealing with a FooGallery extension, that we deactivate it too
27 $api = new FooGallery_Extensions_API();
28 $api->handle_wordpress_plugin_deactivation( $plugin );
29 }
30
31 function handle_extensions_activation( $plugin, $network_deactivating ) {
32 //make sure that if we are dealing with a FooGallery extension, that we deactivate it too
33 $api = new FooGallery_Extensions_API();
34 $api->handle_wordpress_plugin_activation( $plugin );
35 }
36
37 function handle_extension_action() {
38
39 $action = sanitize_key( safe_get_from_request( 'action' ) );
40 $extension_slug = sanitize_key( safe_get_from_request( 'extension' ) );
41 $has_error = safe_get_from_request( 'has_error' );
42
43 if ( !empty( $extension_slug ) || $has_error ) {
44 if ( !check_admin_referer( 'foogallery_extension_action' ) ) {
45 return;
46 }
47 }
48
49 if ( ( 'download' === $action || 'activate' === $action || 'deactivate' === $action ) && $extension_slug ) {
50 $api = new FooGallery_Extensions_API();
51
52 $fatal_error_redirect = remove_query_arg( 'action' );
53 wp_redirect( add_query_arg( 'has_error', 'yes', $fatal_error_redirect ) ); // we'll override this later if the plugin can be included without fatal error
54 ob_start();
55
56 switch ( $action ) {
57 case 'download':
58 $result = $api->download( $extension_slug );
59 break;
60 case 'activate':
61 $result = $api->activate( $extension_slug );
62 break;
63 case 'deactivate':
64 $result = $api->deactivate( $extension_slug );
65 break;
66 }
67
68 //if we get here then no fatal error - cool!
69 if ( ob_get_length() > 0 ) {
70 ob_end_clean();
71 }
72
73 //store the result in a short-lived transient
74 if ( isset($result) ) {
75 set_transient( FOOGALLERY_EXTENSIONS_MESSAGE_TRANSIENT_KEY, $result, 30 );
76 }
77
78 //first, remove unwanted query args
79 $redirect_url = remove_query_arg( array( 'extension', 'action' ) );
80 //then add a query arg for our message
81 $redirect_url = add_query_arg( 'show_message', 'yes', $redirect_url );
82 //finally, allow extensions to override their own redirect
83 $redirect_url = apply_filters( 'foogallery_extensions_redirect_url-' . $extension_slug, $redirect_url, $action );
84
85 //redirect to this page, so the plugin can be properly activated/deactivated etc
86 if ( $redirect_url ) {
87 wp_redirect( $redirect_url );
88 die();
89 }
90 } else if ( $has_error ) {
91 $api = new FooGallery_Extensions_API();
92 $api->deactivate( $extension_slug, true, false );
93
94 $result = array(
95 'message' => __( 'The extension could not be activated due to an error!', 'foogallery' ),
96 'type' => 'error',
97 );
98
99 set_transient( FOOGALLERY_EXTENSIONS_MESSAGE_TRANSIENT_KEY, $result, 30 );
100
101 $api->add_to_error_extensions( $extension_slug, __( 'Activation Error!', 'foogallery' ) );
102
103 //first, remove unwanted query args
104 $redirect_url = remove_query_arg( array( 'extension', 'action', 'has_error' ) );
105 //then add a query arg for our message
106 $redirect_url = add_query_arg( 'show_message', 'yes', $redirect_url );
107
108 wp_redirect( $redirect_url );
109 }
110 }
111 }
112 }
113