Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




delete_option [ WordPress Function ]

delete_option ( $option )
Parameters:
  • (string) $option Name of option to remove. Expected to not be SQL-escaped.
Uses:
Returns:
  • (bool) True, if option is successfully deleted. False on failure.
Defined at:



Removes option by name. Prevents removal of protected WordPress options.

Source


<?php
function delete_option$option ) {
    global 
$wpdb;

    
wp_protect_special_option$option );

    
// Get the ID, if no ID then return
    
$row $wpdb->get_row$wpdb->prepare"SELECT autoload FROM $wpdb->options WHERE option_name = %s"$option ) );
    if ( 
is_null$row ) )
        return 
false;
    
do_action'delete_option'$option );
    
$result $wpdb->delete$wpdb->options, array( 'option_name' => $option ) );
    if ( ! 
defined'WP_INSTALLING' ) ) {
        if ( 
'yes' == $row->autoload ) {
            
$alloptions wp_load_alloptions();
            if ( 
is_array$alloptions ) && isset( $alloptions[$option] ) ) {
                unset( 
$alloptions[$option] );
                
wp_cache_set'alloptions'$alloptions'options' );
            }
        } else {
            
wp_cache_delete$option'options' );
        }
    }
    if ( 
$result ) {
        
do_action"delete_option_$option"$option );
        
do_action'deleted_option'$option );
        return 
true;
    }
    return 
false;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics