Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
Josh Guss
ParticipantHey Daron,
Meant to respond earlier but just haven’t had the chance. Prior to seeing your response I ended up working it out by doing it in the functions.php file globally for all widgets and seems to be working well for my purposes so far. For reference, the code i’m using is:
add_filter('dynamic_sidebar_params', 'before_widget_custom_classes'); function before_widget_custom_classes( $params ) { // get widget vars $widget_id = $params[0]['widget_id']; $hide_title = get_field('hide_title', 'widget_' . $widget_id); $border_color = get_field('border_color', 'widget_' . $widget_id); $custom_color = get_field('color', 'widget_' . $widget_id); $no_padding = get_field('remove_padding', 'widget_' . $widget_id); $col_width = get_field('column_width', 'widget_' . $widget_id); if ( $no_padding == 1 ) { $no_padding_class = 'no-padding'; } if ( $hide_title == 1 ) { $hide_title_class = 'no-title'; } if( $col_width || $border_color || $no_padding || $hide_title) { $params[0]['before_widget'] = preg_replace( '/class="widget/', "class=\"widget widget-{$col_width} border-{$border_color} {$no_padding_class} {$hide_title_class}", $params[0]['before_widget'], 1 ); } if( $border_color == 'custom' && $custom_color ) { $params[0]['after_widget'] .= '<style type="text/css">'; $params[0]['after_widget'] .= sprintf('#%s { border-color: %s; }', $widget_id, $custom_color); $params[0]['after_widget'] .= '</style>'; } // return return $params; }
January 24, 2016 at 5:39 PM in reply to: Having an issue with Yoast Analytics outbound link tracking #3402Josh Guss
ParticipantHey Daron,
Thanks! This is exactly what I needed to get this working properly. Take care.
Josh
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)