/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: 1.9 
  6. Author: PhiloPress 
  7. Author URI: http://philopress.com/ 
  8. */ 
  9.  
  10. // Exit if accessed directly 
  11. if ( !defined( 'ABSPATH' ) ) exit; 
  12.  
  13. function pp_local_avatars_bp_check() { 
  14. if ( !class_exists('BuddyPress') ) { 
  15. add_action( 'admin_notices', 'pp_local_avatars_install_buddypress_notice' ); 
  16. add_action('plugins_loaded', 'pp_local_avatars_bp_check', 999); 
  17.  
  18. function pp_local_avatars_install_buddypress_notice() { 
  19. echo '<div id="message" class="error fade"><p style="line-height: 150%">'; 
  20. _e('<strong>BP Local Avatars</strong></a> requires the BuddyPress plugin. Please <a href="http://buddypress.org/download">install BuddyPress</a> first, or <a href="plugins.php">deactivate BP Local Avatars</a>.'); 
  21. echo '</p></div>'; 
  22.  
  23.  
  24. function pp_local_avatars_init() { 
  25. require( dirname( __FILE__ ) . '/pp-local-avatars.php' ); 
  26. add_action( 'bp_include', 'pp_local_avatars_init' ); 
  27.  
  28.  
  29. // if Default Avatar was set to BuddyPress Identicon, reset default avatar to Mystery to prevent broken avatar icons 
  30. function pp_local_avatars_deactivation () { 
  31.  
  32. $default_avatar = get_option('avatar_default'); 
  33.  
  34. if( $default_avatar == 'identicon_local' ) 
  35. update_option( 'avatar_default', 'mystery' ); 
  36.  
  37. register_deactivation_hook(__FILE__, 'pp_local_avatars_deactivation'); 
.