widget_cssclass = 'widget_blogmarks_social_menu'; $this->widget_description = __( 'Displays social menu if you have set it.', 'blogmarks' ); $this->widget_id = 'blogmarks_social_menu'; $this->widget_name = __( 'Blogmarks: Social Menu', 'blogmarks' ); $this->settings = array( 'title' => array( 'type' => 'text', 'label' => __( 'Title', 'blogmarks' ), ), 'color' => array( 'type' => 'select', 'label' => __( 'Social Links Color', 'blogmarks' ), 'options' => array( 'theme_color' => __( 'Use Theme Color', 'blogmarks' ), 'brand_color' => __( 'Use Brand Color', 'blogmarks' ), ), 'std' => 'theme_color', ), 'style' => array( 'type' => 'select', 'label' => __( 'Style', 'blogmarks' ), 'options' => blogmarks_get_social_links_styles(), 'std' => 'style_1', ), 'show_label' => array( 'type' => 'checkbox', 'label' => __( 'Show Label', 'blogmarks' ), 'std' => false, ), 'column' => array( 'type' => 'select', 'label' => __( 'Column', 'blogmarks' ), 'desc' => __( 'Will only work when label is enabled from above and there is enough space to display the columns.', 'blogmarks' ), 'options' => array( 'one' => __( 'One', 'blogmarks' ), 'two' => __( 'Two', 'blogmarks' ), 'three' => __( 'Three', 'blogmarks' ), ), 'std' => 'two', ), 'align' => array( 'type' => 'select', 'label' => __( 'Alignment', 'blogmarks' ), 'options' => array( 'left' => __( 'Left', 'blogmarks' ), 'center' => __( 'Center', 'blogmarks' ), 'right' => __( 'Right', 'blogmarks' ), ), 'std' => 'left', ), ); parent::__construct(); add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_assets' ) ); } /** * Output widget. * * @see WP_Widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { ob_start(); $this->widget_start( $args, $instance ); do_action( 'blogmarks_before_social_menu' ); $wrapper_class = isset( $instance['align'] ) ? $instance['align'] : $this->settings['align']['std']; ?> widget_end( $args ); echo ob_get_clean(); } public function enqueue_assets() { if ( is_active_widget( false, false, $this->id_base ) ) { $file_prefix = is_rtl() ? '-rtl' : ''; $css_file = get_template_directory() . '/include/widgets/assets/social-menu' . $file_prefix . '.css'; if ( file_exists( $css_file ) ) { $styles = wp_strip_all_tags( file_get_contents( $css_file ) ); wp_add_inline_style( 'blogmarks-style', $styles ); } } } }