dynamic_sidebar_params
最后更新于:2021-11-26 09:01:14
apply_filters( ‘dynamic_sidebar_params’, array $params )
Filters the parameters passed to a widget’s display callback.
参数
- $params
-
(array)
-
‘args’
(array) An array of widget display arguments.-
‘name’
(string) Name of the sidebar the widget is assigned to. -
‘id’
(string) ID of the sidebar the widget is assigned to. -
‘description’
(string) The sidebar description. -
‘class’
(string) CSS class applied to the sidebar container. -
‘before_widget’
(string) HTML markup to prepend to each widget in the sidebar. -
‘after_widget’
(string) HTML markup to append to each widget in the sidebar. -
‘before_title’
(string) HTML markup to prepend to the widget title when displayed. -
‘after_title’
(string) HTML markup to append to the widget title when displayed. -
‘widget_id’
(string) ID of the widget. -
‘widget_name’
(string) Name of the widget.
-
‘name’
-
‘widget_args’
(array) An array of multi-widget arguments.-
‘number’
(int) Number increment used for multiples of the same widget.
-
‘number’
-
‘args’
源文件
文件: gc-includes/widgets.php
if ( ! function_exists( 'gcdocs_display_custom_field_in_widget_form' ) ) { add_action( 'in_widget_form', 'gcdocs_display_custom_field_in_widget_form', 10, 3 ); /** * Append custom field end of the widgets control form * Fires at the end of the widget control form. */ function gcdocs_display_custom_field_in_widget_form( $widget, $return, $instance ) { $column = isset( $instance['column'] ) ? $instance['column'] : ''; ob_start(); ?> <p> <label for="<?php echo esc_attr( $widget->get_field_id( 'itclan_bs_grid_class' ) ) ?>"><?php _e( 'Column Label', 'text_domain' ) ?> <input class="widefat" value="<?php echo esc_attr( $column ) ?>" id="<?php echo esc_attr( $widget->get_field_id( 'column' ) ) ?>" name="<?php echo esc_attr( $widget->get_field_name( 'column' ) ) ?>" type="text" /> <small><?php _e( 'Some additional description.', 'text_domain' ) ?></small> </label> </p> <?php echo ob_get_clean(); } }
if ( ! function_exists( 'gcdocs_filter_dynamic_sidebar_params' ) ) { add_action( 'dynamic_sidebar_params', 'gcdocs_filter_dynamic_sidebar_params' ); /** * Update widget fields * Filters the parameters passed to a widget’s display callback. */ function gcdocs_filter_dynamic_sidebar_params( $params ) { global $gc_registered_widgets; $widget_id = $params[0]['widget_id']; $widget_obj = $gc_registered_widgets[ $widget_id ]; $widget_opt = get_option( $widget_obj['callback'][0]->option_name ); $widget_num = $widget_obj['params'][0]['number']; $grid_class = isset( $widget_opt[ $widget_num ]['column'] ) ? $widget_opt[ $widget_num ]['column'] : ''; if ( preg_match( '/class="/', $params[0]['before_widget'] ) && $grid_class ) { $params[0]['before_widget'] = preg_replace( '/class="/', "class="{$grid_class} ", $params[0]['before_widget'], 1 ); } return $params; } }