'anderson_frontpage_services', 'description' => __('Displays your Services with a Icon.', 'anderson-lite') ); $this->WP_Widget('anderson_frontpage_services', 'Front Page Services (Anderson)', $widget_ops); add_action( 'load-widgets.php', array(&$this, 'enqueue_dashicons_picker') ); if ( is_active_widget(false, false, $this->id_base) ) add_action( 'wp_enqueue_scripts', array(&$this, 'enqueue_dashicons') ); } function enqueue_dashicons() { wp_enqueue_style( 'dashicons' ); } function enqueue_dashicons_picker( $hook ) { // Enqueuing Dashicons Picker JS and CSS wp_enqueue_script( 'anderson-lite-dashicons-picker-js', get_template_directory_uri() . '/js/dashicons-picker.js', array( 'jquery' ), '20140604', true ); wp_enqueue_style( 'anderson-lite-dashicons-picker-css', get_template_directory_uri() . '/css/dashicons-picker.css', array(), '20140604' ); // Enqueuing the underscore.js library. wp_enqueue_script( 'underscore' ); } function excerpt_length($length) { return 18; } function widget($args, $instance) { $cache = wp_cache_get('widget_anderson_frontpage_services', 'widget'); if ( !is_array($cache) ) $cache = array(); if ( ! isset( $args['widget_id'] ) ) $args['widget_id'] = $this->id; if ( isset( $cache[ $args['widget_id'] ] ) ) { echo $cache[ $args['widget_id'] ]; return; } ob_start(); extract($args); // Get Widget Settings $title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base); $icon = empty( $instance['icon'] ) ? 'dashicons-admin-home' : esc_attr($instance['icon']); $page_id = empty( $instance['page_id'] ) ? 0 : (int)$instance['page_id']; $read_more = empty( $instance['read_more'] ) ? __('Read more', 'anderson-lite') : esc_attr($instance['read_more']); // Get Page Content global $post; $post = get_post($page_id); // Setup Post Data setup_postdata( $post ); // Limit the number of words in slideshow page excerpts add_filter('excerpt_length', array(&$this, 'excerpt_length') ); // Output echo $before_widget; ?>