Skip to:
Content

BuddyPress.org

Opened 7 years ago

Closed 7 years ago

#5853 closed defect (bug) (fixed)

WP Edit button on BuddyPress pages

Reported by: SGr33n Owned by: r-a-y
Milestone: 2.1 Priority: normal
Severity: normal Version:
Component: Core Keywords: has-patch
Cc:

Description

Hi,

On same BuddyPress pages, the WP edit button is present. Now, if you click on that button, since that no post is given, you will redirect to the list of posts. I suggest to hide via css that button until it will not be possible to give it the right action. E.g. on the profile page, it should direct to the edit profile in the admin area.

Attachments (3)

5853.01.patch (466 bytes) - added by r-a-y 7 years ago.
5853.02.patch (1005 bytes) - added by r-a-y 7 years ago.
5853.03.patch (1.4 KB) - added by imath 7 years ago.

Download all attachments as: .zip

Change History (24)

#1 @r-a-y
7 years ago

  • Milestone changed from Awaiting Review to 2.1
  • Owner set to r-a-y
  • Status changed from new to assigned
  • Type changed from enhancement to defect (bug)

Thanks for testing, SGr33n.

I have a feeling it has to do with the patch I made for #5810. Should be easy to fix though.

@r-a-y
7 years ago

#2 @r-a-y
7 years ago

  • Keywords has-patch added

#3 @boonebgorges
7 years ago

This looks right to me. Would like verification from SGr33n that it addresses the problem.

This ticket was mentioned in IRC in #buddypress-dev by jjj. View the logs.


7 years ago

#5 @DJPaul
7 years ago

I don't think this is a new issue; I think I've seen it around for a long time, and vaguely recall asking JJJ about it, around the time theme compat. was introduced.

Looks like a nice way to address this, though if BP ever uses theme compat. templates for something like a widget sidebar (like bbPress does) on a non-BP page, this might end up removing the link on the WordPress content.

#6 @DJPaul
7 years ago

Just tested; the Edit link doesn't show in 2.0.2, so I must have been remembering from when we've broken/fixed this before.

#7 @DJPaul
7 years ago

Confirmed that r-a-y's patch fixes the Edit link that appears at (for example) the bottom of the default WordPress themes, but that it also breaks (not removes) the "Edit Page" button's link in the toolbar. Unhooking at least one item from the toolbar is beginning to make this look super messy.

As the "Edit Page" links only appear if you have the appropriate WP role/cap, I'm kinda tempted to suggest we leave this as-is for now and send a patch upstream for this line: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/admin-bar.php?rev=29695#L530

Last edited 7 years ago by DJPaul (previous) (diff)

#8 @boonebgorges
7 years ago

Just tested; the Edit link doesn't show in 2.0.2, so I must have been remembering from when we've broken/fixed this before.

See #5241 and r8821, and https://buddypress.trac.wordpress.org/ticket/5241#comment:14 :)

As the "Edit Page" links only appear if you have the appropriate WP role/cap, I'm kinda tempted to suggest we leave this as-is for now and send a patch upstream for this line: https://core.trac.wordpress.org/browser/trunk/src/wp-includes/admin-bar.php?rev=29695#L530

If r-a-y's proposed patch is producing side effects, then I agree with DJPaul that it's better to leave the (harmless) Edit button in place for now and to push for a more general solution. (Not sure what that would be - a filter?)

#9 @DJPaul
7 years ago

Most themes' templates use edit_post_link which creates the "Edit" link in the template; internally, it uses get_edit_post_link to get the link. If get_edit_post_link returns a falsey value, then edit_post_link bails out and doesn't do anything (this is how r-a-y's patch work).

The toolbar uses get_edit_post_link directly and doesn't check the return value from it in the same way that edit_post_link does.

@r-a-y
7 years ago

#11 @r-a-y
7 years ago

Confirmed that r-a-y's patch fixes the Edit link that appears at (for example) the bottom of the default WordPress themes, but that it also breaks (not removes) the "Edit Page" button's link in the toolbar. Unhooking at least one item from the toolbar is beginning to make this look super messy.

Thanks for the spot, DJPaul.

02.patch adds a workaround for the WP Toolbar.

I'll leave it to the consensus if it should be put in for 2.1. Though, I'll note that since it wasn't showing up in 2.0.x, then it's a regression. (Also, when we move to rewrite rules without this patch, this problem will also occur.)

Last edited 7 years ago by r-a-y (previous) (diff)

#12 @DJPaul
7 years ago

Thanks for posting to WP trac, Boone.

#13 @boonebgorges
7 years ago

r-a-y - .02.patch looks fine for me. Agreed that it's a regression, and your patch looks simple enough. +1 from me.

#14 @r-a-y
7 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 8994:

Remove 'Edit' post link on BuddyPress pages.

Changes in bp_core_load_template() (r8932) to set the post to the current
BP directory page and #5418 to set the post type to 'page' resulted in
showing the "Edit" post link at the bottom of BuddyPress pages and in
the WP Toolbar for users with the 'edit_post' capability.

Since the "Edit" post link does not make sense on BuddyPress pages, this
commit manually removes the 'Edit' post link from rendering on BuddyPress
pages and in the WP Toolbar.

Fixes #5853.

#15 @imath
7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I think there's a potential issue with filtering get_edit_post_link using '__return_false'.

If a plugin is using custom post types and is displaying one of its post type entry into a group, it won't be able to use get_edit_post_link(). For instance one of my plugin is failing since this commit.

Would it be possible to create a function a plugin could temporarly neutralize ?
Or best (from my point of view) : check if the post_id is empty and if so return false ?

@imath
7 years ago

#16 @imath
7 years ago

For instance 5853.03.patch is not displaying the edit link on BuddyPress pages but allows a plugin to get the edit link if one of it's post type ID is set (inside a group).

#17 follow-up: @r-a-y
7 years ago

Would it be possible to create a function a plugin could temporarly neutralize ?
Or best (from my point of view) : check if the post_id is empty and if so return false ?

I'm fine with this. Maybe add a filter in the new function as well for devs that need more control?

If a plugin is using custom post types and is displaying one of its post type entry into a group, it won't be able to use get_edit_post_link(). For instance one of my plugin is failing since this commit.

Got a link to the plugin so I can test?

Last edited 7 years ago by r-a-y (previous) (diff)

#18 in reply to: ↑ 17 @imath
7 years ago

Replying to r-a-y:

Maybe add a filter in the new function as well for devs that need more control?

I agree, i think it's a very good idea

Got a link to the plugin so I can test?

Unfortunately, the plugin is still in "work in progress". But i've quicky made a new branch on another plugin so that you can test :
https://github.com/imath/altctrl-public-group/tree/r-a-y_tests

Once activated, if you go in the Group's Manage area, "control" subnav, you'll see an editor to create the group's home page. Once created, there will be a new button "Edit in WP Administration". The edit link is empty (unless you apply 5853.03.patch)

#19 follow-up: @r-a-y
7 years ago

Very neat plugin, imath!

03.patch works for me. Make sure to add phpDoc for the filter function and it should be good to go.

#20 in reply to: ↑ 19 @imath
7 years ago

Replying to r-a-y:

Very neat plugin, imath!

Thanks r-a-y :)

03.patch works for me. Make sure to add phpDoc for the filter function and it should be good to go.

Ok will do.

#21 @imath
7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 9001:

On BuddyPress pages, make sure the edit link is not displayed if the corresponding post ID is not set

This prevents the edit link to show at the bottom of BuddyPress pages and allow plugins to get an edit link in case they are using it (providing a post ID) in a BuddyPress page.

Fixes #5853

Note: See TracTickets for help on using tickets.