Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

#6077 closed defect (bug) (fixed)

bp_modify_page_title can only be used before wp_head

Reported by: DJPaul Owned by: djpaul
Milestone: 2.2 Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch
Cc:

Description

bp_modify_page_title can only be used before the wp_head action fires because bp_core_sort_subnav_items re-keys the $bp->bp_options_nav variable.

(From https://gist.github.com/paulgibbs/b679bb55843bf6840704 to https://gist.github.com/paulgibbs/0bfb25fe7d49013707d4)

Given that I believe all this has been in place for at least four years, updating how bp_options_nav is handled seems an arduous and risky task. We can re-implement part of the logic using other data in the existing array so that bp_modify_page_title works whenever and wherever you call it, regardless of the state of the global.

Attachments (1)

6077.01.patch (1.0 KB) - added by DJPaul 5 years ago.

Download all attachments as: .zip

Change History (4)

@DJPaul
5 years ago

#1 @DJPaul
5 years ago

Attached a patch which works for me.

This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.


5 years ago

#3 @djpaul
5 years ago

  • Owner set to djpaul
  • Resolution set to fixed
  • Status changed from new to closed

In 9261:

Core: adjust bp_modify_page_title() so that it can be used safely after the wp_head action.

The function is used to set the value for the page's <title> element, but it currently throws a PHP Notice if it's used after the wp_head action is triggered.
This is because bp_core_sort_subnav_items() (hooked to wp_head) re-keys the global $bp->bp_options_nav array; the keys are changed from strings to integers representing the desired order of the menu items.

Fixes #6077

Note: See TracTickets for help on using tickets.