The Subscription Options Add-on Pack! * Version: 0.9.1 * Author: Tom Saunter * Author URI: http://digitalcortex.net * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * Add functions that will load the widget. */ add_action( 'widgets_init', 'suboptions_load_widgets' ); /** * Register the widget. * 'suboptions_widget' is the widget class used below. */ function suboptions_load_widgets() { register_widget( 'suboptions_widget' ); } /** * Extends the widget class. * This class handles everything that needs to be handled with the widget: * the settings, form, display, and update. Nice! */ class suboptions_widget extends WP_Widget { /** * Widget setup. */ function suboptions_widget() { /* Widget settings. */ $widget_ops = array( 'classname' => 'suboptions', 'description' => __('Add subscription options for your readers with related feed icons', 'suboptions') ); /* Widget control settings. */ $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'suboptions-widget' ); /* Create the widget. */ $this->WP_Widget( 'suboptions-widget', __('Subscription Options', 'suboptions'), $widget_ops, $control_ops ); } /** * Display the widget on the screen. */ function widget( $args, $instance ) { extract( $args ); /* Variables for the standard widget. */ $title = apply_filters('widget_title', $instance['title'] ); $size = $instance['size']; $rss_url = $instance['rss_url']; $rss_col = $instance['rss_col']; $email_url = $instance['email_url']; $email_col = $instance['email_col']; $twitter_url = $instance['twitter_url']; $twitter_col = $instance['twitter_col']; $facebook_url = $instance['facebook_url']; $facebook_col = $instance['facebook_col']; /* Variables for the add-on pack. */ $linkedin_url = $instance['linkedin_url']; $linkedin_col = $instance['linkedin_col']; $flickr_url = $instance['flickr_url']; $flickr_col = $instance['flickr_col']; $google_url = $instance['google_url']; $google_col = $instance['google_col']; $podcast_url = $instance['podcast_url']; $podcast_col = $instance['podcast_col']; $youtube_url = $instance['youtube_url']; $youtube_col = $instance['youtube_col']; $pinterest_url = $instance['pinterest_url']; $pinterest_col = $instance['pinterest_col']; $spotify_url = $instance['spotify_url']; $spotify_col = $instance['spotify_col']; $tumblr_url = $instance['tumblr_url']; $tumblr_col = $instance['tumblr_col']; /* Before widget (defined by themes). */ echo $before_widget; /* Display the widget title if one was input (before and after defined by themes). */ if ( $title ) echo $before_title . $title . $after_title; /* If an RSS Feed URL was entered, display the RSS icon. */ if ( $rss_url ) echo 'Subscribe via RSS'; /* If a FeedBurner Email Service URL was entered, display the email icon. */ if ( $email_url ) echo ''; /* If a Twitter Stream URL was entered, display the Twitter icon. */ if ( $twitter_url ) echo ''; /* If a Facebook Page URL was entered, display the Facebook icon. */ if ( $facebook_url ) echo ''; /* If a LinkedIn Profile URL was entered, display the LinkedIn icon. */ if ( $linkedin_url ) echo 'Subscribe via LinkedIn'; /* If a Flickr Page URL was entered, display the Flickr icon. */ if ( $flickr_url ) echo 'Subscribe via Flickr'; /* If a Google+ URL was entered, display the Google+ icon. */ if ( $google_url ) echo 'Subscribe via Google+'; /* If a Podcasting Service URL was entered, display the Podcast icon. */ if ( $podcast_url ) echo 'Subscribe via Podcast'; /* If a YouTube Channel URL was entered, display the YouTube icon. */ if ( $youtube_url ) echo 'Subscribe via YouTube'; /* If a Pinterest Page URL was entered, display the Pinterest icon. */ if ( $pinterest_url ) echo 'Subscribe via Pinterest'; /* If a Spotify URL was entered, display the Spotify icon. */ if ( $spotify_url ) echo 'Subscribe via Spotify'; /* If a Tumblr Service URL was entered, display the Tumblr icon. */ if ( $tumblr_url ) echo 'Subscribe via Tumblr'; /* After widget (defined by themes). */ echo $after_widget; } /** * Update the widget settings. */ function update( $new_instance, $old_instance ) { $instance = $old_instance; /* Strip HTML tags for the standard widget: */ $instance['title'] = strip_tags( $new_instance['title'] ); $instance['size'] = strip_tags( $new_instance['size'] ); $instance['rss_url'] = strip_tags( $new_instance['rss_url'] ); $instance['rss_col'] = strip_tags( $new_instance['rss_col'] ); $instance['email_url'] = strip_tags( $new_instance['email_url'] ); $instance['email_col'] = strip_tags( $new_instance['email_col'] ); $instance['twitter_url'] = strip_tags( $new_instance['twitter_url'] ); $instance['twitter_col'] = strip_tags( $new_instance['twitter_col'] ); $instance['facebook_url'] = strip_tags( $new_instance['facebook_url'] ); $instance['facebook_col'] = strip_tags( $new_instance['facebook_col'] ); /* Strip HTML tags for the add-on pack: */ $instance['linkedin_url'] = strip_tags( $new_instance['linkedin_url'] ); $instance['linkedin_col'] = strip_tags( $new_instance['linkedin_col'] ); $instance['flickr_url'] = strip_tags( $new_instance['flickr_url'] ); $instance['flickr_col'] = strip_tags( $new_instance['flickr_col'] ); $instance['google_url'] = strip_tags( $new_instance['google_url'] ); $instance['google_col'] = strip_tags( $new_instance['google_col'] ); $instance['podcast_url'] = strip_tags( $new_instance['podcast_url'] ); $instance['podcast_col'] = strip_tags( $new_instance['podcast_col'] ); $instance['youtube_url'] = strip_tags( $new_instance['youtube_url'] ); $instance['youtube_col'] = strip_tags( $new_instance['youtube_col'] ); $instance['pinterest_url'] = strip_tags( $new_instance['pinterest_url'] ); $instance['pinterest_col'] = strip_tags( $new_instance['pinterest_col'] ); $instance['spotify_url'] = strip_tags( $new_instance['spotify_url'] ); $instance['spotify_col'] = strip_tags( $new_instance['spotify_col'] ); $instance['tumblr_url'] = strip_tags( $new_instance['tumblr_url'] ); $instance['tumblr_col'] = strip_tags( $new_instance['tumblr_col'] ); return $instance; } /** * Displays the widget settings controls on the widget panel. * Makes use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form( $instance ) { $defaults = array( /* Set up some default standard widget settings. */ 'title' => 'Subscription Options:', 'size' => '70', 'rss_url' => '', 'rss_col' => '#FF9831', 'email_url' => '', 'email_col' => '#7AFD32', 'twitter_url' => '', 'twitter_col' => '#00ACEE', 'facebook_url' => '', 'facebook_col' => '#3B5998', /* Set up some default add-on pack settings. */ 'linkedin_url' => '', 'linkedin_col' => '#007FB1', 'flickr_url' => '', 'flickr_col' => '#FE0883', 'google_url' => '', 'google_col' => '#C63D2D', 'podcast_url' => '', 'podcast_col' => '#B474E6', 'youtube_url' => '', 'youtube_col' => '#FF3333', 'pinterest_url' => '', 'pinterest_col' => '#C92228', 'spotify_url' => '', 'spotify_col' => '#7FB718', 'tunblr_url' => '', 'tumblr_col' => '#2B4964', ); $instance = wp_parse_args( (array) $instance, $defaults ); ?>

'; } else { echo '

Need more icons? Install the Add-on Pack!

'; echo '
'; } ?>

\n"; } add_action( 'wp_head', 'suboptions_style' ); add_action( 'admin_head', 'suboptions_style' ); ?>