[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-templates/bp-nouveau/includes/notifications/ -> loader.php (source)

   1  <?php
   2  /**
   3   * BP Nouveau Notifications
   4   *
   5   * @since 3.0.0
   6   * @version 6.1.0
   7   */
   8  
   9  // Exit if accessed directly.
  10  defined( 'ABSPATH' ) || exit;
  11  
  12  /**
  13   * Notifications Loader class
  14   *
  15   * @since 3.0.0
  16   */
  17  class BP_Nouveau_Notifications {
  18      /**
  19       * Constructor
  20       *
  21       * @since 3.0.0
  22       */
  23  	public function __construct() {
  24          $this->setup_globals();
  25          $this->includes();
  26          $this->setup_actions();
  27          $this->setup_filters();
  28      }
  29  
  30      /**
  31       * Globals
  32       *
  33       * @since 3.0.0
  34       */
  35  	protected function setup_globals() {
  36          $this->dir = dirname( __FILE__ );
  37      }
  38  
  39      /**
  40       * Include needed files
  41       *
  42       * @since 3.0.0
  43       */
  44  	protected function includes() {
  45          $dir = trailingslashit( $this->dir );
  46  
  47          require "{$dir}functions.php";
  48          require "{$dir}template-tags.php";
  49      }
  50  
  51      /**
  52       * Register do_action() hooks
  53       *
  54       * @since 3.0.0
  55       */
  56  	protected function setup_actions() {
  57          add_action( 'bp_init', 'bp_nouveau_notifications_init_filters', 20 );
  58          add_action( 'bp_nouveau_enqueue_scripts', 'bp_nouveau_notifications_enqueue_scripts' );
  59  
  60          $ajax_actions = array(
  61              array(
  62                  'notifications_filter' => array(
  63                      'function' => 'bp_nouveau_ajax_object_template_loader',
  64                      'nopriv'   => false,
  65                  ),
  66              ),
  67          );
  68  
  69          foreach ( $ajax_actions as $ajax_action ) {
  70              $action = key( $ajax_action );
  71  
  72              add_action( 'wp_ajax_' . $action, $ajax_action[ $action ]['function'] );
  73  
  74              if ( ! empty( $ajax_action[ $action ]['nopriv'] ) ) {
  75                  add_action( 'wp_ajax_nopriv_' . $action, $ajax_action[ $action ]['function'] );
  76              }
  77          }
  78      }
  79  
  80      /**
  81       * Register add_filter() hooks
  82       *
  83       * @since 3.0.0
  84       */
  85  	protected function setup_filters() {
  86          add_filter( 'bp_nouveau_register_scripts', 'bp_nouveau_notifications_register_scripts', 10, 1 );
  87          add_filter( 'bp_get_the_notification_mark_unread_link', 'bp_nouveau_notifications_mark_unread_link', 10, 1 );
  88          add_filter( 'bp_get_the_notification_mark_read_link', 'bp_nouveau_notifications_mark_read_link', 10, 1 );
  89          add_filter( 'bp_get_the_notification_delete_link', 'bp_nouveau_notifications_delete_link', 10, 1 );
  90  
  91          // The number formatting is done into the `bp_nouveau_nav_count()` template tag.
  92          remove_filter( 'bp_notifications_get_total_notification_count', 'bp_core_number_format' );
  93      }
  94  }
  95  
  96  /**
  97   * Launch the Notifications loader class.
  98   *
  99   * @since 3.0.0
 100   */
 101  function bp_nouveau_notifications( $bp_nouveau = null ) {
 102      if ( is_null( $bp_nouveau ) ) {
 103          return;
 104      }
 105  
 106      $bp_nouveau->notifications = new BP_Nouveau_Notifications();
 107  }
 108  add_action( 'bp_nouveau_includes', 'bp_nouveau_notifications', 10, 1 );


Generated: Sun Dec 22 01:00:54 2024 Cross-referenced by PHPXref 0.7.1