'bavotasan_custom_text_widget', 'description' => __( 'Custom Text Widget with Icon', 'arcade-basic' ) ); $control_ops = array('width' => 400, 'height' => 350); parent::__construct( 'bavotasan_custom_text_widget', '(' . BAVOTASAN_THEME_NAME . ') ' . __( 'Icon & Text', 'arcade-basic' ), $widget_ops, $control_ops ); add_action( 'sidebar_admin_setup', array( $this, 'admin_setup' ) ); } function admin_setup() { wp_enqueue_script( 'bavotasan_image_widget', BAVOTASAN_THEME_URL . '/library/js/admin/image-widget.js', array( 'jquery' ), '', true ); wp_enqueue_style( 'bavotasan_image_widget_css', BAVOTASAN_THEME_URL . '/library/css/admin/image-widget.css' ); wp_enqueue_style( 'font-awesome', BAVOTASAN_THEME_URL .'/library/css/font-awesome.css', false, '4.6.3', 'all' ); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'], $instance, $this->id_base ); $icon = ( empty( $instance['icon'] ) ) ? '' : ''; $url = ( empty( $instance['url'] ) ) ? '' : esc_url( $instance['url'] ); $text = apply_filters( 'widget_text', empty( $instance['text'] ) ? '' : $instance['text'], $instance ); $button_text = ( empty( $instance['button_text'] ) ) ? '' : $instance['button_text']; $icon_string = ( $url ) ? ''. $icon . '' : $icon; $title_string = ( $url ) ? ''. $title . '' : $title; // WPML Compatibility if ( function_exists( 'icl_register_string' ) ) { icl_register_string( 'Widgets', 'arcade_widget_text_' . $this->number, $text ); icl_register_string( 'Widgets', 'arcade_widget_button_text_' . $this->number, $button_text ); } if ( function_exists( 'icl_t' ) ) { $text = icl_t( 'Widgets', 'arcade_widget_text_' . $this->number, $text ); $button_text = icl_t( 'Widgets', 'arcade_widget_button_text_' . $this->number, $button_text ); } echo $before_widget; if ( $icon ) echo $icon_string; if ( $title ) echo $before_title . $title_string . $after_title; ?>
' . $button_text . ''; echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = strip_tags( $new_instance['title'] ); $instance['icon'] = strip_tags( $new_instance['icon'] ); $instance['url'] = esc_url( $new_instance['url'] ); $instance['button_color'] = esc_attr( $new_instance['button_color'] ); if ( current_user_can( 'unfiltered_html' ) ) { $instance['text'] = $new_instance['text']; $instance['button_text'] = $new_instance['button_text']; } else { $instance['text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['text'] ) ) ); // wp_filter_post_kses() expects slashed $instance['button_text'] = stripslashes( wp_filter_post_kses( addslashes( $new_instance['button_text'] ) ) ); } $instance['filter'] = isset( $new_instance['filter'] ); return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '', 'icon' => '', 'url' => '', 'button_text' => '', 'button_color' => 'info' ) ); extract( $instance ); $icon_tag = ( $icon ) ? '' : ''; ?>
/>