'widget_column clearfix', 'description' => esc_html__( 'Choose your content and put it in each column', 'passport' ) ); parent::__construct( 'passport_column_widget', esc_html__( 'Passport Column', 'passport' ), $widget_ops ); $this->alt_option_name = 'widget_column'; add_action( 'wp_enqueue_scripts', array( $this, 'passport_widget_inline_style' ) ); } /** * Styling the widget */ public function passport_widget_inline_style() { $i = 0; $widget_options = get_option( $this->option_name ); $custom_widget_css = ''; if( is_array( $widget_options ) && count( $widget_options ) > 0 ) { foreach ( $widget_options as $key => $widget_option ) { $widget_bgcolor_option = isset( $widget_option['widget_bgcolor'] ) ? $widget_option['widget_bgcolor'] : ''; if ( isset( $widget_bgcolor_option ) ) { $custom_widget_css .= "#{$this->id_base}-{$key} .card {"; $custom_widget_css .= ! empty( $widget_bgcolor_option ) ? 'background-color:'. $widget_bgcolor_option .';' :'background-color: #f1f1f1;'; $custom_widget_css .= "}"; } $i++; } } wp_add_inline_style( PASSPORT_THEME_SLUG . '-custom-style', $custom_widget_css ); } // Creating widget front-end // This is where the action happens public function widget( $args, $instance ) { global $post; $first_column = ! empty( $instance['first_column'] ) ? $instance['first_column'] : esc_html__( 'News Update', 'passport' ); $second_column = ! empty( $instance['second_column'] ) ? $instance['second_column'] : esc_html__( 'Progress Bar', 'passport' ); $third_column = ! empty( $instance['third_column'] ) ? $instance['third_column'] : esc_html__( 'Event Schdule', 'passport' ); ?>
esc_html__( 'News Update', 'passport' ), 'second_column' => esc_html__( 'Progress Bar', 'passport' ), 'third_column' => esc_html__( 'Event Schedule', 'passport' ), 'widget_bgcolor' => '#f1f1f1' ) ); $first_column = $instance['first_column']; $second_column = $instance['second_column']; $third_column = $instance['third_column']; $widget_bgcolor = $instance['widget_bgcolor']; // Widget admin form ?>