[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  /**
   3   * BP Nouveau Blogs
   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   * Blogs Loader class
  14   *
  15   * @since 3.0.0
  16   */
  17  class BP_Nouveau_Blogs {
  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 = trailingslashit( dirname( __FILE__ ) );
  37      }
  38  
  39      /**
  40       * Include needed files
  41       *
  42       * @since 3.0.0
  43       */
  44  	protected function includes() {
  45          require $this->dir . 'functions.php';
  46          require $this->dir . 'template-tags.php';
  47  
  48          // Test suite requires the AJAX functions early.
  49          if ( function_exists( 'tests_add_filter' ) ) {
  50              require $this->dir . 'ajax.php';
  51  
  52          // Load AJAX code only on AJAX requests.
  53          } else {
  54              add_action( 'admin_init', function() {
  55                  if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX && 0 === strpos( $_REQUEST['action'], 'blogs_' ) ) {
  56                      require bp_nouveau()->blogs->dir . 'ajax.php';
  57                  }
  58              } );
  59          }
  60      }
  61  
  62      /**
  63       * Register do_action() hooks
  64       *
  65       * @since 3.0.0
  66       */
  67  	protected function setup_actions() {
  68          if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
  69              // Avoid Notices for BuddyPress Legacy Backcompat
  70              remove_action( 'bp_blogs_directory_blog_types', 'bp_blog_backcompat_create_nav_item', 1000 );
  71          }
  72  
  73          add_action( 'bp_nouveau_enqueue_scripts', function() {
  74              if ( bp_get_blog_signup_allowed() && bp_is_register_page() ) {
  75                  wp_add_inline_script( 'bp-nouveau', bp_nouveau_get_blog_signup_inline_script() );
  76              }
  77          } );
  78      }
  79  
  80      /**
  81       * Register add_filter() hooks
  82       *
  83       * @since 3.0.0
  84       */
  85  	protected function setup_filters() {
  86          if ( is_multisite() ) {
  87              // Add settings into the Blogs sections of the customizer.
  88              add_filter( 'bp_nouveau_customizer_settings', 'bp_nouveau_blogs_customizer_settings', 11, 1 );
  89  
  90              // Add controls into the Blogs sections of the customizer.
  91              add_filter( 'bp_nouveau_customizer_controls', 'bp_nouveau_blogs_customizer_controls', 11, 1 );
  92  
  93              // The number formatting is done into the `bp_nouveau_nav_count()` template tag.
  94              remove_filter( 'bp_get_total_blog_count_for_user', 'bp_core_number_format' );
  95          }
  96      }
  97  }
  98  
  99  /**
 100   * Launch the Blogs loader class.
 101   *
 102   * @since 3.0.0
 103   */
 104  function bp_nouveau_blogs( $bp_nouveau = null ) {
 105      if ( is_null( $bp_nouveau ) ) {
 106          return;
 107      }
 108  
 109      $bp_nouveau->blogs = new BP_Nouveau_Blogs();
 110  }
 111  add_action( 'bp_nouveau_includes', 'bp_nouveau_blogs', 10, 1 );


Generated: Tue Mar 19 01:01:09 2024 Cross-referenced by PHPXref 0.7.1