/loader.php

  1. <?php 
  2. /** 
  3. * Plugin Name: BP Local Avatars 
  4. * Description: Requires BuddyPress. Adds an option to create Identicon Avatars and store them locally. 
  5. * Version: 2.2 
  6. * Author: PhiloPress, shanebp 
  7. * Author URI: http://philopress.com/ 
  8. * License: GPLv2 or later 
  9. */ 
  10.  
  11. // Exit if accessed directly 
  12. if ( !defined( 'ABSPATH' ) ) exit; 
  13.  
  14. function pp_local_avatars_bp_check() { 
  15. if ( !class_exists('BuddyPress') ) { 
  16. add_action( 'admin_notices', 'pp_local_avatars_install_buddypress_notice' ); 
  17. add_action('plugins_loaded', 'pp_local_avatars_bp_check', 999); 
  18.  
  19. function pp_local_avatars_install_buddypress_notice() { 
  20. echo '<div id="message" class="error fade"><p style="line-height: 150%">'; 
  21. _e('BP Local Avatars requires the BuddyPress plugin. Please install BuddyPress or deactivate BP Local Avatars.'); 
  22. echo '</p></div>'; 
  23.  
  24.  
  25. function pp_local_avatars_init() { 
  26. require( dirname( __FILE__ ) . '/pp-local-avatars.php' ); 
  27. add_action( 'bp_include', 'pp_local_avatars_init' ); 
  28.  
  29.  
  30. // if Default Avatar was set to BuddyPress Identicon, reset default avatar to Mystery to prevent broken avatar icons 
  31. function pp_local_avatars_deactivation () { 
  32.  
  33. $default_avatar = get_option('avatar_default'); 
  34.  
  35. if( $default_avatar == 'identicon_local' ) 
  36. update_option( 'avatar_default', 'mystery' ); 
  37.  
  38. register_deactivation_hook(__FILE__, 'pp_local_avatars_deactivation'); 
.