settings = tt_arkam_lite_settings_array(); $this->renderer = new TT_Arkam_Lite_Renderer( $this->settings ); $this->helper = new TT_Arkam_Lite_Helper(); // Defaults $this->defaults = array( 'title' => '', 'layout' => 'mosaic', 'spacing' => '2', 'size' => 'small', 'color' => 'colored' ); // Loop through all social channels foreach ( $this->settings['profiles'] as $key => $data ) { // All channels are disabled by default $this->defaults[$key] = 0; } parent::__construct( 'arkam_lite_widget', esc_html__( 'Arkam Lite: Social Counters', 'arkam-lite' ), array( 'description' => esc_html__( 'Add social widget with counters.', 'arkam-lite' ) ) ); } /** * WP_Widget form * * @since 1.0.0 */ public function form( $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>


settings['profiles'] as $key => $data ) { ?>
settings['profiles'] as $key => $data ) { // Sanitize channels. $instance[$key] = $this->helper->sanitize_checkbox( $new_instance[$key] ); } return $instance; } /** * WP_Widget widget * * @since 1.0.0 */ public function widget( $args, $instance ) { extract( $args ); // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); $enabled_channels = array(); foreach ( $this->settings['profiles'] as $key => $data ) { if ( $instance[$key] == true ) { $enabled_channels[] = $key; } } $opts = array( 'layout' => $instance['layout'], 'spacing' => $instance['spacing'], 'size' => $instance['size'], 'color' => $instance['color'] ); echo $before_widget; if ( !empty( $instance['title'] ) ) { echo $before_title . apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) . $after_title; } echo $this->renderer->render_counts( $enabled_channels, $opts ); echo $after_widget; } } }