Skip to:
Content

BuddyPress.org

Changeset 13193


Ignore:
Timestamp:
12/18/2021 07:25:13 PM (3 years ago)
Author:
imath
Message:

Inject Group's Invites & Manage Members JS templates into footer

To make sure JS Templates are injected without being altered in WordPress themes supporting the Full Site Editing feature, we are now doing it inside the page's footer.

HTML placeholders for both UI have been moved out of the JS Templates and a backward compatibility for potential plugins still expecting these placeholders into these templates has been put in place.

See #8474

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-admin.php

    r13106 r13193  
    937937        );
    938938
    939         bp_get_template_part( 'common/js-templates/group-members/index' );
     939        // Inject the Group Manage Members interface.
     940        bp_groups_manage_group_members_interface( 'admin_footer' );
    940941
    941942        /**
  • trunk/src/bp-groups/bp-groups-template.php

    r13185 r13193  
    65816581    return file_exists( bp_locate_template( 'common/js-templates/group-members/index.php' ) );
    65826582}
     6583
     6584/**
     6585 * Prints the JS Templates to manage the Group's members.
     6586 *
     6587 * @since 10.0.0
     6588 */
     6589function bp_groups_print_manage_group_members_templates() {
     6590    bp_get_template_part( 'common/js-templates/group-members/index' );
     6591}
     6592
     6593/**
     6594 * Prints the HTML placeholders to manage the Group's members.
     6595 *
     6596 * @since 10.0.0
     6597 */
     6598function bp_groups_print_manage_group_members_placeholders() {
     6599    ?>
     6600    <div id="group-manage-members-ui" class="standard-form">
     6601        <ul class="subnav-filters">
     6602            <li id="group-roles-filter" class="last filter"><?php // Placeholder for the Group Role Tabs ?></li>
     6603            <li id="group-members-pagination" class="left-menu"><?php // Placeholder for paginate links ?></li>
     6604            <li id="group-members-search-form" class="bp-search"><?php // Placeholder for search form ?></li>
     6605        </ul>
     6606        <table id="group-members-list-table" class="<?php echo is_admin() ? 'widefat bp-group-members' : 'bp-list'; ?>"><?php // Placeholder to list members ?></table>
     6607    </div>
     6608    <?php
     6609}
     6610
     6611/**
     6612 * Outputs the Manage Group Members Backbone UI.
     6613 *
     6614 * @since 10.0.0
     6615 *
     6616 * @param string $hook The hook to use to inject the JS Templates.
     6617 */
     6618function bp_groups_manage_group_members_interface( $hook = 'wp_footer' ) {
     6619    /**
     6620     * Get the templates to manage Group Members using the BP REST API.
     6621     *
     6622     * @since 5.0.0
     6623     * @since 10.0.0 Hook to the `wp_footer` action to print the JS templates.
     6624     */
     6625    add_action( $hook, 'bp_groups_print_manage_group_members_templates' );
     6626    bp_groups_print_manage_group_members_placeholders();
     6627
     6628    /**
     6629     * Private hook to preserve backward compatibility with plugins needing the above placeholders to be located
     6630     * into: `bp-templates/bp-nouveau/buddypress/common/js-templates/group-members/index.php`.
     6631     *
     6632     * @since 10.0.0
     6633     */
     6634    do_action( '_bp_groups_print_manage_group_members_placeholders' );
     6635}
  • trunk/src/bp-templates/bp-nouveau/buddypress/common/js-templates/group-members/index.php

    r12405 r13193  
    77 *
    88 * @since 5.0.0
    9  * @version 5.0.0
     9 * @version 10.0.0
    1010 */
     11
     12// Backward Compatibility for plugins still needing the placeholders to be located into this file.
     13if ( ! did_action( '_bp_groups_print_manage_group_members_placeholders' ) ) {
     14    /**
     15     * Placeholders to inject elements of the UI
     16     * to manage Group members.
     17     *
     18     * @since 5.0.0
     19     */
     20    bp_groups_print_manage_group_members_placeholders();
     21}
    1122?>
    12 
    13 <?php
    14 /**
    15  * Placeholder to inject elements of the UI
    16  * to manage Group members.
    17  *
    18  * @since 5.0.0
    19  * @version 5.0.0
    20  */
    21 ?>
    22 <div id="group-manage-members-ui" class="standard-form">
    23     <ul class="subnav-filters">
    24         <li id="group-roles-filter" class="last filter"><?php // Placeholder for the Group Role Tabs ?></li>
    25         <li id="group-members-pagination" class="left-menu"><?php // Placeholder for paginate links ?></li>
    26         <li id="group-members-search-form" class="bp-search"><?php // Placeholder for search form ?></li>
    27     </ul>
    28     <table id="group-members-list-table" class="<?php echo is_admin() ? 'widefat bp-group-members' : 'bp-list'; ?>"><?php // Placeholder to list members ?></table>
    29 </div>
    3023
    3124<script type="text/html" id="tmpl-bp-manage-members-updating">
  • trunk/src/bp-templates/bp-nouveau/buddypress/common/js-templates/invites/index.php

    r13192 r13193  
    99 * @version 10.0.0
    1010 */
     11
     12// Backward Compatibility for plugins still needing the placeholders to be located into this file.
     13if ( ! did_action( '_bp_nouveau_group_print_invites_placeholders' ) ) {
     14    /**
     15     * Placeholders to inject elements of the UI
     16     * to manage Group members.
     17     *
     18     * @since 5.0.0
     19     */
     20    bp_nouveau_group_print_invites_placeholders();
     21}
    1122?>
    12 
    13 <?php if ( bp_is_group_create() ) : ?>
    14 
    15     <h3 class="bp-screen-title creation-step-name">
    16         <?php esc_html_e( 'Invite Members', 'buddypress' ); ?>
    17     </h3>
    18 
    19 <?php else : ?>
    20 
    21     <h2 class="bp-screen-title">
    22         <?php esc_html_e( 'Invite Members', 'buddypress' ); ?>
    23     </h2>
    24 
    25 <?php endif; ?>
    26 
    27 <div id="group-invites-container">
    28 
    29     <nav class="<?php bp_nouveau_single_item_subnav_classes(); ?>" id="subnav" role="navigation" aria-label="<?php esc_attr_e( 'Group invitations menu', 'buddypress' ); ?>"></nav>
    30 
    31     <div class="group-invites-column">
    32         <div class="subnav-filters group-subnav-filters bp-invites-filters"></div>
    33         <div class="bp-invites-feedback"></div>
    34         <div class="members bp-invites-content"></div>
    35     </div>
    36 
    37 </div>
    3823
    3924<script type="text/html" id="tmpl-bp-group-invites-feedback">
  • trunk/src/bp-templates/bp-nouveau/buddypress/groups/single/admin/manage-members.php

    r12405 r13193  
    44 *
    55 * @since 3.0.0
    6  * @version 5.0.0
     6 * @version 10.0.0
    77 */
    88?>
     
    1515
    1616<?php if ( bp_rest_api_is_available() ) :
    17     /**
    18      * Get the templates to manage Group Members using the BP REST API.
    19      *
    20      * @since 5.0.0
    21      */
    22     bp_get_template_part( 'common/js-templates/group-members/index' );
     17
     18    bp_groups_manage_group_members_interface();
    2319
    2420else : ?>
  • trunk/src/bp-templates/bp-nouveau/includes/groups/template-tags.php

    r13108 r13193  
    44 *
    55 * @since 3.0.0
    6  * @version 9.0.0
     6 * @version 10.0.0
    77 */
    88
     
    158158
    159159/**
     160 * Prints the JS Templates to invite new members to join the Group.
     161 *
     162 * @since 10.0.0
     163 */
     164function bp_nouveau_group_print_invites_templates() {
     165    bp_get_template_part( 'common/js-templates/invites/index' );
     166}
     167
     168/**
     169 * Prints the HTML placeholders to invite new members to join the Group.
     170 *
     171 * @since 10.0.0
     172 */
     173function bp_nouveau_group_print_invites_placeholders() {
     174    if ( bp_is_group_create() ) : ?>
     175
     176        <h3 class="bp-screen-title creation-step-name">
     177            <?php esc_html_e( 'Invite Members', 'buddypress' ); ?>
     178        </h3>
     179
     180    <?php else : ?>
     181
     182        <h2 class="bp-screen-title">
     183            <?php esc_html_e( 'Invite Members', 'buddypress' ); ?>
     184        </h2>
     185
     186    <?php endif; ?>
     187
     188    <div id="group-invites-container">
     189        <nav class="<?php bp_nouveau_single_item_subnav_classes(); ?>" id="subnav" role="navigation" aria-label="<?php esc_attr_e( 'Group invitations menu', 'buddypress' ); ?>"></nav>
     190        <div class="group-invites-column">
     191            <div class="subnav-filters group-subnav-filters bp-invites-filters"></div>
     192            <div class="bp-invites-feedback"></div>
     193            <div class="members bp-invites-content"></div>
     194        </div>
     195    </div>
     196    <?php
     197}
     198
     199/**
    160200 * Load the Group Invites UI.
    161201 *
     
    172212    do_action( 'bp_before_group_send_invites_content' );
    173213
    174     bp_get_template_part( 'common/js-templates/invites/index' );
     214    /**
     215     * Get the templates to manage Group Members using the BP REST API.
     216     *
     217     * @since 10.0.0 Hook to the `wp_footer` action to print the JS templates.
     218     */
     219    add_action( 'wp_footer', 'bp_nouveau_group_print_invites_templates' );
     220    bp_nouveau_group_print_invites_placeholders();
     221
     222    /**
     223     * Private hook to preserve backward compatibility with plugins needing the above placeholders to be located
     224     * into: `bp-templates/bp-nouveau/buddypress/common/js-templates/invites/index.php`.
     225     *
     226     * @since 10.0.0
     227     */
     228    do_action( '_bp_nouveau_group_print_invites_placeholders' );
    175229
    176230    /**
Note: See TracChangeset for help on using the changeset viewer.