[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 require_once ( 'admin.php' ); 3 4 require_once ( 'includes/functions.bb-plugin.php' ); 5 6 $plugin_request = 'all'; 7 8 if ( isset( $_GET['plugin_request'] ) ) { 9 $plugin_request = (string) $_GET['plugin_request']; 10 } 11 12 switch ( $plugin_request ) { 13 case 'active': 14 $_plugin_type = 'normal'; 15 $_plugin_status = 'active'; 16 break; 17 case 'inactive': 18 $_plugin_type = 'normal'; 19 $_plugin_status = 'inactive'; 20 break; 21 case 'autoload': 22 $_plugin_type = 'autoload'; 23 $_plugin_status = 'all'; 24 break; 25 default: 26 $plugin_request = 'all'; // For sanitisation 27 $_plugin_type = 'all'; 28 $_plugin_status = 'all'; 29 break; 30 } 31 32 $plugin_nav_class = array( 33 'all' => '', 34 'active' => '', 35 'inactive' => '', 36 'autoload' => '' 37 ); 38 $plugin_nav_class[$plugin_request] = ' class="current"'; 39 40 // Get plugin counts 41 extract( bb_get_plugin_counts() ); 42 43 // Get requested plugins 44 $requested_plugins = bb_get_plugins( 'all', $_plugin_type, $_plugin_status ); 45 46 // Get currently active 47 $active_plugins = (array) bb_get_option( 'active_plugins' ); 48 49 // Check for missing plugin files and remove them from the active plugins array 50 $update = false; 51 foreach ( $active_plugins as $index => $plugin ) { 52 if ( !file_exists( bb_get_plugin_path( $plugin ) ) ) { 53 $update = true; 54 unset( $active_plugins[$index] ); 55 } 56 } 57 if ( $update ) { 58 bb_update_option( 'active_plugins', $active_plugins ); 59 } 60 unset( $update, $index, $plugin ); 61 62 // Set the action 63 $action = ''; 64 if( isset( $_GET['action'] ) && !empty( $_GET['action'] ) ) { 65 $action = trim( $_GET['action'] ); 66 } 67 68 // Set the plugin 69 $plugin = isset( $_GET['plugin'] ) ? trim( stripslashes( $_GET['plugin'] ) ) : ''; 70 71 // Deal with user actions 72 if ( !empty( $action ) ) { 73 switch ( $action ) { 74 case 'activate': 75 // Activation 76 bb_check_admin_referer( 'activate-plugin_' . $plugin ); 77 78 $result = bb_activate_plugin( $plugin, 'plugins.php?message=error&plugin=' . urlencode( $plugin ) ); 79 if ( is_wp_error( $result ) ) 80 bb_die( $result ); 81 82 // Overrides the ?message=error one above 83 wp_redirect( 'plugins.php?plugin_request=' . $plugin_request . '&message=activate&plugin=' . urlencode( $plugin ) ); 84 break; 85 86 case 'deactivate': 87 // Deactivation 88 bb_check_admin_referer( 'deactivate-plugin_' . $plugin ); 89 90 // Remove the deactivated plugin 91 bb_deactivate_plugins( $plugin ); 92 93 // Redirect 94 wp_redirect( 'plugins.php?plugin_request=' . $plugin_request . '&message=deactivate&plugin=' . urlencode( $plugin ) ); 95 break; 96 97 case 'scrape': 98 // Scrape php errors from the plugin 99 bb_check_admin_referer('scrape-plugin_' . $plugin); 100 101 $valid_path = bb_validate_plugin( $plugin ); 102 if ( is_wp_error( $valid_path ) ) 103 bb_die( $valid_path ); 104 105 // Pump up the errors and output them to screen 106 error_reporting( E_ALL ^ E_NOTICE ); 107 @ini_set( 'display_errors', true ); 108 109 include( $valid_path ); 110 break; 111 } 112 113 // Stop processing 114 exit; 115 } 116 117 // Display notices 118 if ( isset($_GET['message']) ) { 119 switch ( $_GET['message'] ) { 120 case 'error' : 121 bb_admin_notice( __( '<strong>Plugin could not be activated, it produced a Fatal Error</strong>. The error is shown below.' ), 'error' ); 122 break; 123 case 'activate' : 124 $plugin_data = bb_get_plugin_data( $plugin ); 125 bb_admin_notice( sprintf( __( '<strong>"%s" plugin activated</strong>' ), esc_attr( $plugin_data['name'] ) ) ); 126 break; 127 case 'deactivate' : 128 $plugin_data = bb_get_plugin_data( $plugin ); 129 bb_admin_notice( sprintf( __( '<strong>"%s" plugin deactivated</strong>' ), esc_attr( $plugin_data['name'] ) ) ); 130 break; 131 } 132 } 133 134 if ( isset( $bb->safemode ) && $bb->safemode === true ) { 135 bb_admin_notice( __( '<strong>"Safe mode" is on, all plugins are disabled even if they are listed as active.</strong>' ), 'error' ); 136 } 137 138 $bb_admin_body_class = ' bb-admin-plugins'; 139 140 bb_get_admin_header(); 141 ?> 142 143 <div class="wrap"> 144 145 <h2><?php _e( 'Manage Plugins' ); ?></h2> 146 <?php do_action( 'bb_admin_notices' ); ?> 147 148 <?php 149 if ( bb_verify_nonce( $_GET['_scrape_nonce'], 'scrape-plugin_' . $plugin ) ) { 150 $scrape_src = esc_attr( 151 bb_nonce_url( 152 bb_get_uri( 153 'bb-admin/plugins.php', 154 array( 155 'action' => 'scrape', 156 'plugin' => urlencode( $plugin ) 157 ), 158 BB_URI_CONTEXT_IFRAME_SRC + BB_URI_CONTEXT_BB_ADMIN 159 ), 160 'scrape-plugin_' . $plugin 161 ) 162 ); 163 ?> 164 165 <div class="plugin-error"><iframe src="<?php echo $scrape_src; ?>"></iframe></div> 166 167 <?php 168 } 169 ?> 170 171 <div class="table-filter"> 172 <a<?php echo $plugin_nav_class['all']; ?> href="<?php bb_uri( 'bb-admin/plugins.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ); ?>"><?php printf( __( 'All <span class="count">(%d)</span>' ), $plugin_count_all ); ?></a> | 173 <a<?php echo $plugin_nav_class['active']; ?> href="<?php bb_uri( 'bb-admin/plugins.php', array( 'plugin_request' => 'active' ), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ); ?>"><?php printf( __( 'Active <span class="count">(%d)</span>' ), $plugin_count_active ); ?></a> | 174 <a<?php echo $plugin_nav_class['inactive']; ?> href="<?php bb_uri( 'bb-admin/plugins.php', array( 'plugin_request' => 'inactive' ), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ); ?>"><?php printf( __( 'Inactive <span class="count">(%d)</span>' ), $plugin_count_inactive ); ?></a> | 175 <a<?php echo $plugin_nav_class['autoload']; ?> href="<?php bb_uri( 'bb-admin/plugins.php', array( 'plugin_request' => 'autoload' ), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN ); ?>"><?php printf( __( 'Autoloaded <span class="count">(%d)</span>' ), $plugin_count_autoload ); ?></a> 176 </div> 177 178 <?php 179 if ( $requested_plugins ) : 180 ?> 181 182 <table id="plugins-list" class="widefat"> 183 <thead> 184 <tr> 185 <th><?php _e( 'Plugin' ); ?></th> 186 <th><?php _e( 'Description' ); ?></th> 187 </tr> 188 </thead> 189 <tfoot> 190 <tr> 191 <th><?php _e( 'Plugin' ); ?></th> 192 <th><?php _e( 'Description' ); ?></th> 193 </tr> 194 </tfoot> 195 <tbody> 196 197 <?php 198 foreach ( $requested_plugins as $plugin => $plugin_data ) : 199 $class = ' class="inactive"'; 200 $action = 'activate'; 201 $action_class = 'edit'; 202 $action_text = __( 'Activate' ); 203 if ( $plugin_data['autoload'] ) { 204 $class = ' class="autoload"'; 205 } elseif ( in_array( $plugin, $active_plugins ) ) { 206 $class = ' class="active"'; 207 $action = 'deactivate'; 208 $action_class = 'delete'; 209 $action_text = __( 'Deactivate' ); 210 } 211 $href = esc_attr( 212 bb_nonce_url( 213 bb_get_uri( 214 'bb-admin/plugins.php', 215 array( 216 'plugin_request' => $plugin_request, 217 'action' => $action, 218 'plugin' => urlencode($plugin) 219 ), 220 BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN 221 ), 222 $action . '-plugin_' . $plugin 223 ) 224 ); 225 $meta = array(); 226 if ( $plugin_data['version'] ) $meta[] = sprintf( __( 'Version %s' ), $plugin_data['version'] ); 227 if ( $plugin_data['author_link'] ) $meta[] = sprintf( __( 'By %s' ), $plugin_data['author_link'] ); 228 if ( $plugin_data['uri'] ) $meta[] = '<a href="' . $plugin_data['uri'] . '">' . esc_html__( 'Visit plugin site' ) . '</a>'; 229 if ( count( $meta ) ) { 230 $meta = '<p class="meta">' . join( ' | ', $meta ) . '</p>'; 231 } else { 232 $meta = ''; 233 } 234 ?> 235 236 <tr<?php echo $class; ?>> 237 <td class="plugin-name"> 238 <span class="row-title"><?php echo $plugin_data['name']; ?></span> 239 <div><span class="row-actions"><?php if ( !$plugin_data['autoload'] ) : ?><a class="<?php echo $action_class; ?>" href="<?php echo $href; ?>"><?php echo $action_text; ?></a><?php else : ?><span class="note"><?php _e( 'Autoloaded' ); ?></span><?php endif; ?></span> </div> 240 </td> 241 <td class="plugin-description"> 242 <?php echo $plugin_data['description']; ?> 243 <?php echo $meta; ?> 244 </td> 245 </tr> 246 247 <?php 248 endforeach; 249 ?> 250 251 </tbody> 252 </table> 253 254 <?php 255 else : 256 ?> 257 258 <p class="no-results"><?php _e( 'No plugins found.' ); ?></p> 259 260 <?php 261 endif; 262 ?> 263 264 </div> 265 266 <?php 267 bb_get_admin_footer(); 268 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Dec 7 01:01:35 2017 | Cross-referenced by PHPXref 0.7.1 |