Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/15/2023 08:16:46 AM (13 months ago)
Author:
imath
Message:

Make more BuddyPress generated links ready for BP Rewrites

  • Improve the Members component adding permastructs and custom rewrite

rules for registration and activation pages.

  • Improve the Blogs component adding custom rewrite rule to handle the

Blogs create page.

  • Make a huge progress about replacing all occurrences of

bp_get_root_domain() (45 replacements were performed).

  • Deprecate bp_groups_directory_permalink(),

bp_get_groups_directory_permalink(), bp_blogs_directory_permalink() &
bp_get_blogs_directory_permalink() and replace them with these new
functions: bp_groups_directory_url(), bp_get_groups_directory_url(),
bp_blogs_directory_url() & bp_get_blogs_directory_url().

  • Although bp_loggedin_user_domain() & bp_displayed_user_domain()

should also be deprecated, we're leaving them as aliases of the right
functions to use. Plugin authors shouldn't use them to build other links
than member's profile home url.

NB: these deprecations are required because these functions were used
to build BuddyPress URLs concatenating URL chunks. Once the BP Classic
plugin will be built we will adapt the code to remove these deprecation
notices.

Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/73
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/classes/class-bp-akismet.php

    r12694 r13436  
    192192     */
    193193    public function add_activity_spam_button() {
    194         if ( !bp_activity_user_can_mark_spam() )
    195             return;
     194        if ( ! bp_activity_user_can_mark_spam() ) {
     195            return;
     196        }
    196197
    197198        // By default, only handle activity updates and activity comments.
    198         if ( !in_array( bp_get_activity_type(), BP_Akismet::get_activity_types() ) )
    199             return;
     199        if ( ! in_array( bp_get_activity_type(), BP_Akismet::get_activity_types(), true ) ) {
     200            return;
     201        }
     202
     203        $spam_link = bp_rewrites_get_url(
     204            array(
     205                'component_id'                 => 'activity',
     206                'single_item_action'           => 'spam',
     207                'single_item_action_variables' => array( bp_get_activity_id() ),
     208            )
     209        );
    200210
    201211        bp_button(
     
    205215                'id'         => 'activity_make_spam_' . bp_get_activity_id(),
    206216                'link_class' => 'bp-secondary-action spam-activity confirm button item-button',
    207                 'link_href'  => wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/spam/' . bp_get_activity_id() . '/', 'bp_activity_akismet_spam_' . bp_get_activity_id() ),
     217                'link_href'  => wp_nonce_url( $spam_link, 'bp_activity_akismet_spam_' . bp_get_activity_id() ),
    208218                'link_text'  => __( 'Spam', 'buddypress' ),
    209219                'wrapper'    => false,
     
    220230     */
    221231    public function add_activity_comment_spam_button() {
    222         if ( !bp_activity_user_can_mark_spam() )
    223             return;
     232        if ( ! bp_activity_user_can_mark_spam() ) {
     233            return;
     234        }
    224235
    225236        // By default, only handle activity updates and activity comments.
    226237        $current_comment = bp_activity_current_comment();
    227         if ( empty( $current_comment ) || !in_array( $current_comment->type, BP_Akismet::get_activity_types() ) )
    228             return;
     238        if ( empty( $current_comment ) || ! in_array( $current_comment->type, BP_Akismet::get_activity_types(), true ) ) {
     239            return;
     240        }
     241
     242        $spam_link = add_query_arg(
     243            'cid',
     244            bp_get_activity_comment_id(),
     245            bp_rewrites_get_url(
     246                array(
     247                    'component_id'                 => 'activity',
     248                    'single_item_action'           => 'spam',
     249                    'single_item_action_variables' => array( bp_get_activity_comment_id() ),
     250                )
     251            )
     252        );
    229253
    230254        bp_button(
     
    234258                'id'         => 'activity_make_spam_' . bp_get_activity_comment_id(),
    235259                'link_class' => 'bp-secondary-action spam-activity-comment confirm',
    236                 'link_href'  => wp_nonce_url( bp_get_root_domain() . '/' . bp_get_activity_slug() . '/spam/' . bp_get_activity_comment_id() . '/?cid=' . bp_get_activity_comment_id(), 'bp_activity_akismet_spam_' . bp_get_activity_comment_id() ),
     260                'link_href'  => wp_nonce_url( $spam_link, 'bp_activity_akismet_spam_' . bp_get_activity_comment_id() ),
    237261                'link_text'  => __( 'Spam', 'buddypress' ),
    238262                'wrapper'    => false,
Note: See TracChangeset for help on using the changeset viewer.