[ Index ] |
PHP Cross Reference of BuddyPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * BP Nouveau Blogs 4 * 5 * @since 3.0.0 6 */ 7 8 // Exit if accessed directly. 9 defined( 'ABSPATH' ) || exit; 10 11 /** 12 * Blogs Loader class 13 * 14 * @since 3.0.0 15 */ 16 class BP_Nouveau_Blogs { 17 /** 18 * Constructor 19 * 20 * @since 3.0.0 21 */ 22 public function __construct() { 23 $this->setup_globals(); 24 $this->includes(); 25 $this->setup_actions(); 26 $this->setup_filters(); 27 } 28 29 /** 30 * Globals 31 * 32 * @since 3.0.0 33 */ 34 protected function setup_globals() { 35 $this->dir = trailingslashit( dirname( __FILE__ ) ); 36 } 37 38 /** 39 * Include needed files 40 * 41 * @since 3.0.0 42 */ 43 protected function includes() { 44 require $this->dir . 'functions.php'; 45 require $this->dir . 'template-tags.php'; 46 47 // Test suite requires the AJAX functions early. 48 if ( function_exists( 'tests_add_filter' ) ) { 49 require $this->dir . 'ajax.php'; 50 51 // Load AJAX code only on AJAX requests. 52 } else { 53 add_action( 'admin_init', function() { 54 if ( defined( 'DOING_AJAX' ) && true === DOING_AJAX && 0 === strpos( $_REQUEST['action'], 'blogs_' ) ) { 55 require bp_nouveau()->blogs->dir . 'ajax.php'; 56 } 57 } ); 58 } 59 } 60 61 /** 62 * Register do_action() hooks 63 * 64 * @since 3.0.0 65 */ 66 protected function setup_actions() { 67 if ( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 68 // Avoid Notices for BuddyPress Legacy Backcompat 69 remove_action( 'bp_blogs_directory_blog_types', 'bp_blog_backcompat_create_nav_item', 1000 ); 70 } 71 72 add_action( 'bp_nouveau_enqueue_scripts', function() { 73 if ( bp_get_blog_signup_allowed() && bp_is_register_page() ) { 74 wp_add_inline_script( 'bp-nouveau', bp_nouveau_get_blog_signup_inline_script() ); 75 } 76 } ); 77 } 78 79 /** 80 * Register add_filter() hooks 81 * 82 * @since 3.0.0 83 */ 84 protected function setup_filters() { 85 if ( is_multisite() ) { 86 // Add settings into the Blogs sections of the customizer. 87 add_filter( 'bp_nouveau_customizer_settings', 'bp_nouveau_blogs_customizer_settings', 11, 1 ); 88 89 // Add controls into the Blogs sections of the customizer. 90 add_filter( 'bp_nouveau_customizer_controls', 'bp_nouveau_blogs_customizer_controls', 11, 1 ); 91 } 92 } 93 } 94 95 /** 96 * Launch the Blogs loader class. 97 * 98 * @since 3.0.0 99 */ 100 function bp_nouveau_blogs( $bp_nouveau = null ) { 101 if ( is_null( $bp_nouveau ) ) { 102 return; 103 } 104 105 $bp_nouveau->blogs = new BP_Nouveau_Blogs(); 106 } 107 add_action( 'bp_nouveau_includes', 'bp_nouveau_blogs', 10, 1 );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Dec 11 01:01:37 2019 | Cross-referenced by PHPXref 0.7.1 |