Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#25762 closed enhancement (fixed)

Make it easier to customize the install process

Reported by: denis-de-bernardy's profile Denis-de-Bernardy Owned by: nacin's profile nacin
Milestone: 3.9 Priority: normal
Severity: minor Version: 3.7
Component: Upgrade/Install Keywords: has-patch
Focuses: Cc:

Description

It's currently possible to override a couple of functions in a wp-content/install.php file, namely:

  • wp_install() - top level install function
  • wp_install_defaults() - Installs default post, page, links, cat, etc.
  • wp_new_blog_notification() - Sends the new blog email.
  • wp_upgrade() - Top level upgrade function.

However, they severely lack plugin hooks, which would allow developers to simply hack in there accordingly without needing to keep install functions in sync with core when they want to tweak them.

I'd like to suggest adding hooks named after those functions at the end of each of them.

Attachments (11)

25762.diff (772 bytes) - added by Denis-de-Bernardy 11 years ago.
25762.2.diff (681 bytes) - added by Denis-de-Bernardy 11 years ago.
25762.3.diff (999 bytes) - added by Denis-de-Bernardy 11 years ago.
25762.4.diff (1021 bytes) - added by nacin 11 years ago.
25762.5.diff (1016 bytes) - added by nacin 11 years ago.
Pass $user instead of $user_id since we have it.
25762.6.diff (1.4 KB) - added by Denis-de-Bernardy 11 years ago.
25762.7.diff (1.4 KB) - added by Denis-de-Bernardy 11 years ago.
fix space vs tab
25762.8.diff (2.4 KB) - added by Denis-de-Bernardy 11 years ago.
add wp_install_defaults hook, and switch to user_id for wp_install for consistency
25762.9.diff (6.3 KB) - added by Denis-de-Bernardy 11 years ago.
Fix #11210 as well
25762.10.diff (6.2 KB) - added by Denis-de-Bernardy 11 years ago.
Same as the previous one, s/4space/tab/
25762.11.diff (4.0 KB) - added by Denis-de-Bernardy 11 years ago.
Per IRC discussions

Download all attachments as: .zip

Change History (29)

#1 @DrewAPicture
11 years ago

  • Cc xoodrew@… added

+1 for adding these hooks.

#2 @Denis-de-Bernardy
11 years ago

Adding this back link for reference, since the question originating from there:

http://wordpress.stackexchange.com/a/120539/1208

#3 @johnbillion
11 years ago

  • Cc johnbillion added

#4 follow-up: @nacin
11 years ago

  • Component changed from General to Upgrade/Install
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from feature request to enhancement

Would definitely like more hooks here.

#5 in reply to: ↑ 4 ; follow-up: @Denis-de-Bernardy
11 years ago

Replying to nacin:

Would definitely like more hooks here.

Will a patch make it into the next WP version if supplied, or does it need a crazy amount of discussion before getting checked in?

#6 in reply to: ↑ 5 @nacin
11 years ago

  • Milestone changed from Future Release to 3.9

Replying to Denis-de-Bernardy:

Will a patch make it into the next WP version if supplied, or does it need a crazy amount of discussion before getting checked in?

The original suggestion seem straightforward enough to me:

I'd like to suggest adding hooks named after those functions at the end of each of them.

I wouldn't be surprised if there are additional opportunities for well-placed actions or filters, but one per function would certainly be a good start. Would be happy to check in a patch this week.

#7 @Denis-de-Bernardy
11 years ago

  • Keywords has-patch added

Replying to nacin:

I wouldn't be surprised if there are additional opportunities for well-placed actions or filters, but one per function would certainly be a good start. Would be happy to check in a patch this week.

I stuck to two hooks, seeing that those two would have been more than enough for use-cases that I've run into over the years:

  • one at the very end of wp_install, that passes user_id
  • another at the very end of wp_upgrade, that passes the new and old database version

The second patch should be svn-compatible (generated using git diff --noprefix).

Last edited 11 years ago by Denis-de-Bernardy (previous) (diff)

#8 @DrewAPicture
11 years ago

  • Keywords needs-docs added

We'll need docs for these hooks, wherever they land per the Inline Docs standards.

#9 @Denis-de-Bernardy
11 years ago

  • Keywords needs-docs removed

This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.


11 years ago

@nacin
11 years ago

#11 follow-up: @nacin
11 years ago

This looks great. Some little things:

  • These are actual doc blocks, they need /**
  • 3.9.0 versus 3.9

Also, you put the wp_upgrade hook in upgrade_all(), not wp_upgrade(). Intentional? Looks like wp_upgrade() is indeed the right place for it, as your comment above suggested.

@nacin
11 years ago

Pass $user instead of $user_id since we have it.

#12 in reply to: ↑ 11 ; follow-up: @Denis-de-Bernardy
11 years ago

Replying to nacin:

This looks great. Some little things:

  • These are actual doc blocks, they need /**
  • 3.9.0 versus 3.9

Looks like you did that in your amended patch.

Also, you put the wp_upgrade hook in upgrade_all(), not wp_upgrade(). Intentional? Looks like wp_upgrade() is indeed the right place for it, as your comment above suggested.

It was in the wrong function, ya. *tired*… I see you fixed that too.

#13 in reply to: ↑ 12 @nacin
11 years ago

Replying to Denis-de-Bernardy:

It was in the wrong function, ya. *tired*… I see you fixed that too.

All good, just wanted to double-check!

#14 @nacin
11 years ago

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

In 27045:

Add wp_install and wp_upgrade hooks to the respective functions.

props Denis-de-Bernardy.
fixes #25762.

#15 @Denis-de-Bernardy
11 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The wp_install hook never gets called in a multisite environment. Placing it in wp_install_defaults was in fact correct.

@Denis-de-Bernardy
11 years ago

fix space vs tab

@Denis-de-Bernardy
11 years ago

add wp_install_defaults hook, and switch to user_id for wp_install for consistency

#16 @Denis-de-Bernardy
11 years ago

Marked #11210 as related.

@Denis-de-Bernardy
11 years ago

Fix #11210 as well

@Denis-de-Bernardy
11 years ago

Same as the previous one, s/4space/tab/

This ticket was mentioned in IRC in #wordpress-dev by ddebernardy. View the logs.


11 years ago

@Denis-de-Bernardy
11 years ago

Per IRC discussions

#18 @nacin
11 years ago

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

I'm closing this as fixed based on the [27045]. I think the additional proposals are significantly less straightforward and need a new ticket.

Note: See TracTickets for help on using tickets.