wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_assign_widget_to_sidebar › WordPress Function
Seit5.8.0
Veraltetn/v
› wp_assign_widget_to_sidebar ( $widget_id, $sidebar_id )
Parameter: (2) |
|
Definiert in: |
|
Codex: |
Assigns a widget to the given sidebar.
Ähnliche Funktionen: wp_find_widgets_sidebar, wp_get_sidebar, wp_parse_widget_id, wp_list_widget_controls_dynamic_sidebar, wp_ajax_widgets_order
Quellcode
function wp_assign_widget_to_sidebar( $widget_id, $sidebar_id ) { $sidebars = wp_get_sidebars_widgets(); foreach ( $sidebars as $maybe_sidebar_id => $widgets ) { foreach ( $widgets as $i => $maybe_widget_id ) { if ( $widget_id === $maybe_widget_id && $sidebar_id !== $maybe_sidebar_id ) { unset( $sidebars[ $maybe_sidebar_id ][ $i ] ); // We could technically break 2 here, but continue looping in case the ID is duplicated. continue 2; } } } if ( $sidebar_id ) { $sidebars[ $sidebar_id ][] = $widget_id; } wp_set_sidebars_widgets( $sidebars ); }