WordPress.org

Make WordPress Core

Changeset 11909


Ignore:
Timestamp:
09/10/09 14:43:45 (5 years ago)
Author:
ryan
Message:

More add/delete/update actions. Props Demitrious Kelly. see #10750

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/plugin.php

    r11856 r11909  
    315315        $current[] = $plugin; 
    316316        sort($current); 
     317        do_action( 'activate_plugin', trim( $plugin) ); 
    317318        update_option('active_plugins', $current); 
    318         do_action('activate_' . $plugin); 
     319        do_action( 'activate_' . trim( $plugin ) ); 
     320        do_action( 'activated_plugin', trim( $plugin) ); 
    319321        ob_end_clean(); 
    320322    } 
     
    344346        if( ! is_plugin_active($plugin) ) 
    345347            continue; 
     348        if ( ! $silent ) 
     349            do_action( 'deactivate_plugin', trim( $plugin ) ); 
    346350        array_splice($current, array_search( $plugin, $current), 1 ); // Fixed Array-fu! 
    347         if ( ! $silent ) //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. 
    348             do_action('deactivate_' . trim( $plugin )); 
     351        //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. 
     352        if ( ! $silent ) { 
     353            do_action( 'deactivate_' . trim( $plugin ) ); 
     354            do_action( 'deactivated_plugin', trim( $plugin ) ); 
     355        } 
    349356    } 
    350357 
  • trunk/wp-includes/post.php

    r11880 r11909  
    533533    wp_cache_delete($post_id, 'post_meta'); 
    534534 
     535    do_action( 'added_post_meta', $wpdb->insert_id, $post_id, $meta_key, $meta_value ); 
     536 
    535537    return true; 
    536538} 
     
    574576        return false; 
    575577 
     578    do_action( 'delete_post_meta', $meta_id, $post_id, $meta_key, $meta_value ); 
     579 
    576580    if ( empty( $meta_value ) ) 
    577581        $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = %s", $post_id, $meta_key ) ); 
     
    580584 
    581585    wp_cache_delete($post_id, 'post_meta'); 
     586     
     587    do_action( 'deleted_post_meta', $meta_id, $post_id, $meta_key, $meta_value ); 
    582588 
    583589    return true; 
     
    652658        return false; 
    653659 
    654     if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post_id ) ) ) { 
     660    $meta_id = $wpdb->get_var( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post_id ) ); 
     661    if ( ! $meta_id ) 
    655662        return add_post_meta($post_id, $meta_key, $meta_value); 
    656     } 
    657663 
    658664    $meta_value = maybe_serialize( stripslashes_deep($meta_value) ); 
     
    666672    } 
    667673 
     674    do_action( 'update_post_meta', $meta_id, $post_id, $meta_key, $meta_value ); 
     675     
    668676    $wpdb->update( $wpdb->postmeta, $data, $where ); 
    669677    wp_cache_delete($post_id, 'post_meta'); 
     678     
     679    do_action( 'updated_post_meta', $meta_id, $post_id, $meta_key, $meta_value ); 
     680     
    670681    return true; 
    671682} 
  • trunk/wp-includes/user.php

    r11397 r11909  
    308308    $meta_value = trim( $meta_value ); 
    309309 
     310    $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 
     311 
     312    if ( $cur && $cur->umeta_id ) 
     313        do_action( 'delete_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 
     314 
    310315    if ( ! empty($meta_value) ) 
    311316        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s AND meta_value = %s", $user_id, $meta_key, $meta_value) ); 
     
    314319 
    315320    wp_cache_delete($user_id, 'users'); 
     321 
     322    if ( $cur && $cur->umeta_id ) 
     323        do_action( 'deleted_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 
    316324 
    317325    return true; 
     
    400408 
    401409    $cur = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $meta_key) ); 
     410 
     411    if ( $cur ) 
     412        do_action( 'update_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 
     413 
    402414    if ( !$cur ) 
    403415        $wpdb->insert($wpdb->usermeta, compact('user_id', 'meta_key', 'meta_value') ); 
     
    408420 
    409421    wp_cache_delete($user_id, 'users'); 
     422 
     423    if ( !$cur )  
     424        do_action( 'added_usermeta', $wpdb->insert_id, $user_id, $meta_key, $meta_value ); 
     425    else 
     426        do_action( 'updated_usermeta', $cur->umeta_id, $user_id, $meta_key, $meta_value ); 
    410427 
    411428    return true; 
Note: See TracChangeset for help on using the changeset viewer.