Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/25/2018 03:52:08 AM (7 years ago)
Author:
imath
Message:

BP Nouveau: Improve Messages UI extensibility

In BP Nouveau, the Messages UI is a Backbone based one. This means current legacy hooks inserted into the JS templates are a bit more different to use for plugin developers as it requires them to use JavaScript to get the data models. If the current AJAX requests still need a way to be extended to fetch extra data such as specific Messages metas, this commit is a first step to help plugin developers to insert content into the Messages UI without changing their habits about using the PHP Messages template global variables to get data about the Messages loop. This is done by introducing the back compatibility function bp_nouveau_messages_catch_hook_content(). This function is used during the AJAX requests that are fetching messages for a specific thread. As a start, 2 legacy hooks have been moved from the JS Template level to this higher level :

  • bp_before_message_content
  • bp_after_message_content

If actions are attached to these hooks their outputs will be caught using the buffer and will be "transported" as new properties, respectively beforeContent and afterContent, of the JSON reply that is used by the Messages UI. If these 2 properties are set and populated, their content will be output inside the corresponding JS templates.

Props pareshradadiya

Fixes #7847 (Branch 3.0)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.0/src/bp-core/bp-core-functions.php

    r12067 r12122  
    38413841    ) );
    38423842}
     3843
     3844/**
     3845 * Remove script and style tags from a string.
     3846 *
     3847 * @since 3.0.1
     3848 *
     3849 * @param  string $string The string to strip tags from.
     3850 * @return string         The stripped tags string.
     3851 */
     3852function bp_strip_script_and_style_tags( $string ) {
     3853    return preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $string );
     3854}
Note: See TracChangeset for help on using the changeset viewer.