Make WordPress Core


Ignore:
Timestamp:
08/22/2016 06:24:48 PM (8 years ago)
Author:
DrewAPicture
Message:

Hooks: Standardize naming of dynamic hooks to use interpolation vs concatenation.

Benefits gained in discoverability and self-documentation throughout core trump the negligible performance hit in using interpolation in hook names.

Props ramiy.
See #37748.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/option.php

    r37985 r38307  
    5050     * @param string     $option     Option name.
    5151     */
    52     $pre = apply_filters( 'pre_option_' . $option, false, $option );
     52    $pre = apply_filters( "pre_option_{$option}", false, $option );
    5353    if ( false !== $pre )
    5454        return $pre;
     
    7373             * @param string $option  Option name.
    7474             */
    75             return apply_filters( 'default_option_' . $option, $default, $option );
     75            return apply_filters( "default_option_{$option}", $default, $option );
    7676        }
    7777
     
    134134     * @param string $option Option name.
    135135     */
    136     return apply_filters( 'option_' . $option, maybe_unserialize( $value ), $option );
     136    return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
    137137}
    138138
     
    278278     * @param string $option    Option name.
    279279     */
    280     $value = apply_filters( 'pre_update_option_' . $option, $value, $old_value, $option );
     280    $value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
    281281
    282282    /**
     
    535535         * @param string $option Name of the deleted option.
    536536         */
    537         do_action( "delete_option_$option", $option );
     537        do_action( "delete_option_{$option}", $option );
    538538
    539539        /**
     
    569569     * @param string $transient Transient name.
    570570     */
    571     do_action( 'delete_transient_' . $transient, $transient );
     571    do_action( "delete_transient_{$transient}", $transient );
    572572
    573573    if ( wp_using_ext_object_cache() ) {
     
    625625     * @param string $transient     Transient name.
    626626     */
    627     $pre = apply_filters( 'pre_transient_' . $transient, false, $transient );
     627    $pre = apply_filters( "pre_transient_{$transient}", false, $transient );
    628628    if ( false !== $pre )
    629629        return $pre;
     
    662662     * @param string $transient Transient name.
    663663     */
    664     return apply_filters( 'transient_' . $transient, $value, $transient );
     664    return apply_filters( "transient_{$transient}", $value, $transient );
    665665}
    666666
     
    697697     * @param string $transient  Transient name.
    698698     */
    699     $value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
     699    $value = apply_filters( "pre_set_transient_{$transient}", $value, $expiration, $transient );
    700700
    701701    /**
     
    710710     * @param string $transient  Transient name.
    711711     */
    712     $expiration = apply_filters( 'expiration_of_transient_' . $transient, $expiration, $value, $transient );
     712    $expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
    713713
    714714    if ( wp_using_ext_object_cache() ) {
     
    759759         * @param string $transient  The name of the transient.
    760760         */
    761         do_action( 'set_transient_' . $transient, $value, $expiration, $transient );
     761        do_action( "set_transient_{$transient}", $value, $expiration, $transient );
    762762
    763763        /**
     
    11071107     * @param string $option     Option name.
    11081108     */
    1109     $pre = apply_filters( 'pre_site_option_' . $option, false, $option );
     1109    $pre = apply_filters( "pre_site_option_{$option}", false, $option );
    11101110
    11111111    if ( false !== $pre ) {
     
    11311131         * @param string $option  Option name.
    11321132         */
    1133         return apply_filters( 'default_site_option_' . $option, $default, $option );
     1133        return apply_filters( "default_site_option_{$option}", $default, $option );
    11341134    }
    11351135
     
    11751175     * @param string $option Option name.
    11761176     */
    1177     return apply_filters( 'site_option_' . $option, $value, $option );
     1177    return apply_filters( "site_option_{$option}", $value, $option );
    11781178}
    11791179
     
    12231223     * @param string $option Option name.
    12241224     */
    1225     $value = apply_filters( 'pre_add_site_option_' . $option, $value, $option );
     1225    $value = apply_filters( "pre_add_site_option_{$option}", $value, $option );
    12261226
    12271227    $notoptions_key = "$network_id:notoptions";
     
    12721272         * @param mixed  $value  Value of the network option.
    12731273         */
    1274         do_action( 'add_site_option_' . $option, $option, $value );
     1274        do_action( "add_site_option_{$option}", $option, $value );
    12751275
    12761276        /**
     
    13281328     * @param string $option Option name.
    13291329     */
    1330     do_action( 'pre_delete_site_option_' . $option, $option );
     1330    do_action( "pre_delete_site_option_{$option}", $option );
    13311331
    13321332    if ( ! is_multisite() ) {
     
    13551355         * @param string $option Name of the network option.
    13561356         */
    1357         do_action( 'delete_site_option_' . $option, $option );
     1357        do_action( "delete_site_option_{$option}", $option );
    13581358
    13591359        /**
     
    14181418     * @param string $option    Option name.
    14191419     */
    1420     $value = apply_filters( 'pre_update_site_option_' . $option, $value, $old_value, $option );
     1420    $value = apply_filters( "pre_update_site_option_{$option}", $value, $old_value, $option );
    14211421
    14221422    if ( $value === $old_value ) {
     
    14631463         * @param mixed  $old_value Old value of the network option.
    14641464         */
    1465         do_action( 'update_site_option_' . $option, $option, $value, $old_value );
     1465        do_action( "update_site_option_{$option}", $option, $value, $old_value );
    14661466
    14671467        /**
     
    15011501     * @param string $transient Transient name.
    15021502     */
    1503     do_action( 'delete_site_transient_' . $transient, $transient );
     1503    do_action( "delete_site_transient_{$transient}", $transient );
    15041504
    15051505    if ( wp_using_ext_object_cache() ) {
     
    15581558     * @param string $transient          Transient name.
    15591559     */
    1560     $pre = apply_filters( 'pre_site_transient_' . $transient, false, $transient );
     1560    $pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
    15611561
    15621562    if ( false !== $pre )
     
    15941594     * @param string $transient Transient name.
    15951595     */
    1596     return apply_filters( 'site_transient_' . $transient, $value, $transient );
     1596    return apply_filters( "site_transient_{$transient}", $value, $transient );
    15971597}
    15981598
     
    16261626     * @param string $transient Transient name.
    16271627     */
    1628     $value = apply_filters( 'pre_set_site_transient_' . $transient, $value, $transient );
     1628    $value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );
    16291629
    16301630    $expiration = (int) $expiration;
     
    16411641     * @param string $transient  Transient name.
    16421642     */
    1643     $expiration = apply_filters( 'expiration_of_site_transient_' . $transient, $expiration, $value, $transient );
     1643    $expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
    16441644
    16451645    if ( wp_using_ext_object_cache() ) {
     
    16721672         * @param string $transient  Transient name.
    16731673         */
    1674         do_action( 'set_site_transient_' . $transient, $value, $expiration, $transient );
     1674        do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );
    16751675
    16761676        /**
Note: See TracChangeset for help on using the changeset viewer.