/**
  * Setup the Tweet elements options for the Builder.
  *
  * @since 0.4.0
  */
 public function core_elements($elements)
 {
     $tweeple = Tweeple::get_instance();
     // Before TB framework version 2.2, we're overriding the "Tweet"
     // element, but after that, we're creating a new element.
     $id = 'tweet';
     if (version_compare(TB_FRAMEWORK_VERSION, '2.2.0', '>=')) {
         $id = 'tweeple_tweet';
         unset($elements['tweet']);
     }
     // Start new "Tweet" element.
     $elements[$id] = array();
     // Information
     $elements[$id]['info'] = array('name' => __('Tweet', 'tweeple'), 'id' => $id, 'query' => 'none', 'hook' => null, 'shortcode' => null, 'desc' => __('Shows the most recent tweet from a Tweeple Twitter feed.', 'tweeple'));
     // Options
     $elements[$id]['options'] = array();
     if (version_compare(TB_FRAMEWORK_VERSION, '2.2.0', '>=')) {
         // Info type option not styled in builder prior to framework v2.2
         $elements[$id]['options']['slider_desc'] = array('id' => 'slider_desc', 'desc' => sprintf(__('The "Tweet" element works with the %s plugin you\'ve installed. Use it for a large display of the most recent tweet from one of your Twitter feeds setup at Tools > Tweeple.', 'tweeple'), '<a href="http://wordpress.org/extend/plugins/tweeple" target="_blank">Tweeple</a>'), 'type' => 'info');
     }
     $elements[$id]['options']['feed_id'] = array('id' => 'feed_id', 'name' => __('Twitter Feed', 'tweeple'), 'desc' => __('Select from the Twitter Feeds you\'ve created at <em>Tools > Tweeple</em>.', 'tweeple'), 'type' => 'select', 'std' => '', 'options' => $tweeple->get_feeds());
     if (version_compare(TB_FRAMEWORK_VERSION, '2.2.0', '>=')) {
         $elements[$id]['options']['icon'] = array('id' => 'icon', 'name' => __('Icon', 'tweeple'), 'desc' => __('Enter any Font Awesome icon ID; this icon will then display next to the Tweet. Set this option blank to not use any icon. Examples: twitter, pencil, warning-sign, etc.', 'tweeple'), 'type' => 'text', 'std' => 'twitter');
     } else {
         // Before framework v2.2, there was no FontAwesome.
         $elements[$id]['options']['icon'] = array('id' => 'icon', 'name' => __('Icon', 'tweeple'), 'desc' => __('Select the icon you\'d like shown before the Tweet.', 'tweeple'), 'type' => 'select', 'std' => 'twitter', 'options' => array('twitter' => __('Twitter Icon', 'tweeple'), 'message' => __('Generic Message Bubble', 'tweeple'), 'alert' => __('Alert Symbol', 'tweeple')));
     }
     $elements[$id]['options']['visibility'] = array('id' => 'visibility', 'name' => __('Responsive Visibility ', 'tweeple'), 'desc' => __('Select any resolutions you\'d like to <em>hide</em> this element on. This is optional, but can be utilized to deliver different content to different devices.<br><br><em>Example: Hide an element on tablets and mobile devices & then create a second element that\'s hidden only on standard screen resolutions to take its place.</em>', 'tweeple'), 'type' => 'multicheck', 'options' => array('hide_on_standard' => __('Hide on Standard Resolutions', 'tweeple'), 'hide_on_tablet' => __('Hide on Tablets', 'tweeple'), 'hide_on_mobile' => __('Hide on Mobile Devices', 'tweeple')));
     return $elements;
 }
 /**
  * Creates or returns an instance of this class.
  *
  * @return Tweeple A single instance of this class.
  *
  * @since 0.1.0
  */
 public static function get_instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Settings sanitization
  *
  * @since 0.1.0
  */
 function validate_access($input)
 {
     // Dump Twitter feed caches
     if (!$this->sanitized) {
         $tweeple = Tweeple::get_instance();
         $feeds = $tweeple->get_feeds();
         foreach ($feeds as $key => $value) {
             delete_transient('tweeple_' . $key);
         }
     }
     // Clear options
     if (isset($input['clear'])) {
         // Avoid duplicates
         if (!$this->sanitized) {
             add_settings_error($this->access_id, 'save_options', __('Options cleared.', 'tweeple'), 'error fade');
         }
         return null;
     }
     // Sanitize
     foreach ($input as $key => $value) {
         $clean[$key] = wp_kses($value, array());
     }
     // Add success message, Avoid duplicates
     if (!$this->sanitized) {
         add_settings_error($this->access_id, 'save_options', __('Options saved.', 'tweeple'), 'updated fade');
     }
     // Check for future duplicate passes.
     $this->sanitized = true;
     return $clean;
 }
/**
 * Run Tweeple plugin.
 */
function tweeple_init()
{
    include_once TWEEPLE_PLUGIN_DIR . '/inc/class-tweeple.php';
    Tweeple::get_instance();
}
    /**
     * Widget Options Form
     *
     * @since 0.1.0
     */
    function form($instance)
    {
        // Get twitter feeds created by user
        $tweeple = Tweeple::get_instance();
        $feeds = $tweeple->get_feeds();
        // Set current values for form
        $current_title = isset($instance['title']) ? esc_attr($instance['title']) : '';
        $current_feed_id = isset($instance['feed_id']) ? esc_attr($instance['feed_id']) : '';
        ?>
		<p>
			<label for="<?php 
        echo $this->get_field_name('title');
        ?>
"><?php 
        _e('Title:', 'tweeple');
        ?>
</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($current_title);
        ?>
" />
		</p>
		<p>
			<label for="<?php 
        echo $this->get_field_id('feed_id');
        ?>
"><?php 
        _e('Twitter Feed:', 'tweeple');
        ?>
</label>
			<?php 
        if (count($feeds) > 0) {
            ?>
				<select class="widefat" id="<?php 
            echo $this->get_field_id('feed_id');
            ?>
" name="<?php 
            echo $this->get_field_name('feed_id');
            ?>
">
					<?php 
            foreach ($feeds as $key => $value) {
                printf('<option %s value="%s">%s</option>', selected($key, $current_feed_id), $key, $value);
            }
            ?>
				</select>
			<?php 
        } else {
            ?>
				<em><?php 
            _e('You haven\'t created any Twitter feeds yet. Go to Tools > Tweeple to create one!', 'tweeple');
            ?>
</em>
			<?php 
        }
        ?>
		</p>
		<?php 
    }