Switch language

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




wp_convert_widget_settings [ WordPress Function ]

wp_convert_widget_settings ( $base_name, $option_name, $settings )
Returns:
  • (array)
Defined at:



Convert the widget settings from single to multi-widget format.

Source


<?php
function wp_convert_widget_settings($base_name$option_name$settings) {
    
// This test may need expanding.
    
$single $changed false;
    if ( empty(
$settings) ) {
        
$single true;
    } else {
        foreach ( 
array_keys($settings) as $number ) {
            if ( 
'number' == $number )
                continue;
            if ( !
is_numeric($number) ) {
                
$single true;
                break;
            }
        }
    }

    if ( 
$single ) {
        
$settings = array( => $settings );

        
// If loading from the front page, update sidebar in memory but don't save to options
        
if ( is_admin() ) {
            
$sidebars_widgets get_option('sidebars_widgets');
        } else {
            if ( empty(
$GLOBALS['_wp_sidebars_widgets']) )
                
$GLOBALS['_wp_sidebars_widgets'] = get_option('sidebars_widgets', array());
            
$sidebars_widgets = &$GLOBALS['_wp_sidebars_widgets'];
        }

        foreach ( (array) 
$sidebars_widgets as $index => $sidebar ) {
            if ( 
is_array($sidebar) ) {
                foreach ( 
$sidebar as $i => $name ) {
                    if ( 
$base_name == $name ) {
                        
$sidebars_widgets[$index][$i] = "$name-2";
                        
$changed true;
                        break 
2;
                    }
                }
            }
        }

        if ( 
is_admin() && $changed )
            
update_option('sidebars_widgets'$sidebars_widgets);
    }

    
$settings['_multiwidget'] = 1;
    if ( 
is_admin() )
        
update_option$option_name$settings );

    return 
$settings;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



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