Commit 8103c1ef authored by Angeles Broullón's avatar Angeles Broullón

Migration from GitHub

parent f9c30f98
This source diff could not be displayed because it is too large. You can view the blob instead.
logo.png

7.65 KB

<?php
/**
* @package Pretty_Pinterest_Pins
* @version 1.3.1
*/
/*
Plugin Name: Pretty Pinterest Pins
Description: Display your latest pins from Pinterest in your sidebar.
Author: Jodi Wilkinson, modified by Angeles Broullon for UNDER magazine
Plugin URI: http://wordpress.org/extend/plugins/pretty-pinterest-pins/
Version: 1.3.1
Author URI: http://jodiwilkinson.com
*/
defined('ABSPATH') or die("Cannot access pages directly.");
defined("DS") or define("DS", DIRECTORY_SEPARATOR);
add_action( 'widgets_init', create_function( '', 'register_widget("Pretty_Pinterest_Pins");' ) );
class Pretty_Pinterest_Pins extends WP_Widget{
function Pretty_Pinterest_Pins(){
parent::WP_Widget( $id = 'Pretty_Pinterest_Pins', $name = get_class($this), $options = array( 'description' => 'Display latest pins from your Pinterest.com Account' ) );
}
function form($instance){
$instance = wp_parse_args( (array) $instance, array( 'title' => 'Latest Pins on Pinterest', 'pinterest_username' => '', 'number_of_pins_to_show' => '3', 'show_pinterest_caption' => '1', 'show_follow_button' => '1', 'specific_board' => '') );
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$number_of_pins_to_show = esc_attr( $instance[ 'number_of_pins_to_show' ] );
$pinterest_username = esc_attr( $instance[ 'pinterest_username' ] );
$specific_board = esc_attr( $instance[ 'specific_board' ] );
$show_pinterest_caption = esc_attr( $instance[ 'show_pinterest_caption' ] );
$show_follow_button = esc_attr( $instance[ 'show_follow_button' ] );
}
?>
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></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 $title; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('pinterest_username'); ?>"><?php _e('Pinterest Username:'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('pinterest_username'); ?>" name="<?php echo $this->get_field_name('pinterest_username'); ?>" type="text" value="<?php echo $pinterest_username; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('specific_board'); ?>"><?php _e('Specific Board (optional):'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('specific_board'); ?>" name="<?php echo $this->get_field_name('specific_board'); ?>" type="text" value="<?php echo $specific_board; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('number_of_pins_to_show'); ?>"><?php _e('Number of Pins To Show:'); ?></label>
<select name="<?php echo $this->get_field_name( 'number_of_pins_to_show' );?>">
<?php
for ( $i = 1; $i <= 25; ++$i ){?>
<option value="<?php echo $i;?>" <?php selected( $number_of_pins_to_show, $i );?>><?php echo $i;?></option>
<?php
}
?>
</select>
</p>
<p>
<label for="<?php echo $this->get_field_id('show_pinterest_caption'); ?>"><?php _e('Show Caption?:'); ?></label>
<input type="checkbox" name="<?php echo $this->get_field_name('show_pinterest_caption')?>" value="1" <?php checked( $show_pinterest_caption, 1 ); ?> />
</p>
<p>
<label for="<?php echo $this->get_field_id('show_follow_button'); ?>"><?php _e('Show "Follow Me" Button?:'); ?></label>
<input type="checkbox" name="<?php echo $this->get_field_name('show_follow_button')?>" value="1" <?php checked( $show_follow_button, 1 ); ?> />
</p>
<?php
}
function update($new_instance, $old_instance){
$instance = wp_parse_args( $old_instance, $new_instance );
$instance['title'] = strip_tags($new_instance['title']);
$instance['number_of_pins_to_show'] = strip_tags($new_instance['number_of_pins_to_show']);
$instance['pinterest_username'] = strip_tags($new_instance['pinterest_username']);
$instance['specific_board'] = strip_tags($new_instance['specific_board']);
$instance['show_pinterest_caption'] = strip_tags($new_instance['show_pinterest_caption']);
$instance['show_follow_button'] = strip_tags($new_instance['show_follow_button']);
return $instance;
}
function widget($args, $instance){
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
echo $before_widget;
$title = ( $title ) ? $title : '';
$logo = '<a href="http://www.pinterest.com/undermagazine/"><img src="http://www.undermgzn.com/wp-content/uploads/2013/11/under-pinterest290.png" alt="banner"/></a><br></br>';
echo $before_title . $title . $after_title . $logo ;
if( !empty( $instance['pinterest_username'] ) ) {
//determine how many pins they want to display and pull from rss feed
if ( !empty( $instance['number_of_pins_to_show'] ) && is_int( $instance['number_of_pins_to_show'] ) ) {
$number_of_pins_to_show = esc_attr ( $instance['number_of_pins_to_show'] );
} else {
$number_of_pins_to_show = 3;
}
if( !empty( $instance['specific_board'] ) ) {
$feed_url = 'https://pinterest.com/'.$instance['pinterest_username'].'/'.$instance['specific_board'].'.rss';
} else {
$feed_url = 'https://pinterest.com/'.$instance['pinterest_username'].'/feed.rss';
}
//fetch rss
$latest_pins = $this->pretty_pinterest_pins_get_rss_feed( $instance['pinterest_username'], $instance['number_of_pins_to_show'], $feed_url );
?>
<style>
ul#pretty-pinterest-pins-widget{
list-style-type: none;
}
ul#pretty-pinterest-pins-widget li.pretty-pinterest-pin, ul#pretty-pinterest-pins-widget li.pretty-pinterest-follow-me{
position: relative;
margin: 0px 0px 10px 0px;
list-style-type: none;
list-style-image: none;
background: none;
}
ul#pretty-pinterest-pins-widget li.pretty-pinterest-pin div.pretty-pinterest-image{
background-color: #FFFFFF;
box-shadow: 0 1px 2px rgba(34, 25, 25, 0.4);
font-size: 11px;
text-align: center;
margin: 0px;
max-width: 100%;
width: 100%;
}
ul#pretty-pinterest-pins-widget li.pretty-pinterest-pin div.pretty-pinterest-image img{
width: 100%;
text-align: left;
margin: 0px;
}
ul#pretty-pinterest-pins-widget li.pretty-pinterest-pin div.pretty-pinterest-image a{
display: block;
background: none;
padding: 15px 15px 13px 15px;
margin: 0px;
}
ul#pretty-pinterest-pins-widget li.pretty-pinterest-pin span{
display: block;
padding: 0px;
margin: 0px;
text-align: left;
line-height: 16px;
background-color: #F2F0F0;
}
ul#pretty-pinterest-pins-widget li.pretty-pinterest-pin span p{
padding: 4px;
margin: 0px;
text-align: center;
line-height: 14px;
background-color: #F2F0F0;
color: #333;
}
</style>
<ul id="pretty-pinterest-pins-widget">
<?php
if(!empty( $latest_pins ) ){
foreach ( $latest_pins as $item ):
$rss_pin_description = $item->get_description();
preg_match('/<img[^>]+>/i', $rss_pin_description, $pin_image);
$pin_caption = $this->trim_text( strip_tags( $rss_pin_description ), 400 );
?>
<li class="pretty-pinterest-pin">
<div class="pretty-pinterest-image">
<a href="<?php echo esc_url( $item->get_permalink() ); ?>" title="<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>"><?php echo $pin_image[0];?></a>
<?php if ( $instance['show_pinterest_caption'] ){?>
<span><p><?php echo strip_tags( $pin_caption ); ?></p></span>
<?php }?>
</div>
</li>
<?php endforeach;
}
if( $instance['show_follow_button'] ){
?>
<li class="pretty-pinterest-follow-me"><a href="https://pinterest.com/<?php echo $instance['pinterest_username'];?>/" target="_blank"><img src="https://passets-cdn.pinterest.com/images/follow-on-pinterest-button.png" width="156" height="26" alt="Follow Me on Pinterest" /></a></li>
<?php
}
?>
</ul>
<?php
}
echo $after_widget;
}
function pretty_pinterest_pins_get_rss_feed( $pinterest_username, $number_of_pins_to_show, $feed_url ){
// Get a SimplePie feed object from the specified feed source.
$rss = fetch_feed( $feed_url );
if (!is_wp_error( $rss ) ) :
// Figure out how many total items there are, but limit it to number specified
$maxitems = $rss->get_item_quantity( $number_of_pins_to_show );
$rss_items = $rss->get_items( 0, $maxitems );
endif;
return $rss_items;
}
function trim_text( $text, $length ) {
//strip html
$text = strip_tags( $text );
//no need to trim if its shorter than length
if (strlen($text) <= $length) {
return $text;
}
$last_space = strrpos( substr( $text, 0, $length ), ' ');
$trimmed_text = substr( $text, 0, $last_space );
$trimmed_text .= '...';
return $trimmed_text;
}
}
add_filter( 'wp_feed_cache_transient_lifetime', create_function('$rssLife', 'return 500;') );
?>
=== Plugin Name ===
Contributors: jowilki
Tags: pinterest, widget, sidebar, plugin
Requires at least: 2.8
Tested up to: 4.1.1
Stable tag: trunk
A plugin to show off images, captions, and links from your latest Pinterest activity.
== Description ==
This plugin allows you to display thumbnails and links to yours (or anyones!) latest Pins from Pinterest in your sidebar. It is styled after Pinterest and offers a clean and modern look to show off your pins.
This widget is fully customizable, you can:
* pull the latest pins from any Pinterest user
* display only pins from specific boards
* choose the number of pins to display
* show or hide the image captions
* display a "Follow me on Pinterest" button under your pins
Features:
* Clean and Modern Look (like Pinterest)
* Looks great on light and dark backgrounds
* Captions scale and look nice with long or short text
* Semantic HTML
* Easy to Install: Simply add a Pinterest username and you're good to go!
More to come when Pinterest opens their API! This project is maintained on github if you'd like to contribute :
https://github.com/jowilki/pretty-pinterest-pins
== Installation ==
1. Copy the pretty-pinterest-pins folder contained in the zip file to your plugins folder, /wp-content/plugins/
2. Activate it through the 'Plugins' menu on the WordPress Administration page
3. Under Appearance > Widgets you will see the "Pretty Pinterest Pins" widget. Drag it to your sidebar and place it where you want it to appear.
4. Add a Pinterest username and change any of the default settings.
5. To show pins only from a specific board, you can enter the name of the board in the Specific Board input box. The correct format for board names is found in the URL after the username. For example, the URL for my board called "Cool Stuff" is http://pinterest.com/jowilki/cool-stuff/. I would enter my username *Jowilki* in the username box and *cool-stuff* in the specific board box to show only pins from that board.
== Frequently Asked Questions ==
= What options can I configure? =
You can configure:
* The username the pins are pulled from
* The title that appears above the pins
* Number of pins to show
* Show / Hide the "Follow me on Pinterest" button
= How do I show pins from specific boards? =
To show pins only from a specific board, you can enter the name of the board in the Specific Board input box. The correct format for board names is found in the URL after the username. For example, the URL for my board called "Cool Stuff" is http://pinterest.com/jowilki/cool-stuff/. I would enter my username *Jowilki* in the username box and *cool-stuff* in the specific board box to show only pins from that board.
== Screenshots ==
1. The widget showing 3 pins and all the options enabled
2. The settings interface is easy to use and straightforward
== Changelog ==
= 1.3 =
* Pinterest feed is now fetched with https
= 1.2 =
* Added ability to show pins from specific boards and increased the maximum number of pins you can show.
= 1.1 =
* Fixes text trim for older versions of Wordpress.
= 1.0 =
* Initial version
== Upgrade Notice ==
= 1.2 =
<?php
/*
Plugin Name: Social circle Widget
Plugin URI: https://github.com/AngelesBroullon/UNDERmagazine/plugins/social-circle-widget
Description: Displays a circle of social icons.
Author: Angeles Broullón
Version: 1.0
Author URI: http://mangelesbroullon.wordpress.com/acerca-de/
/* License
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 <http://www.gnu.org/licenses/>.
*/
add_action('wp_enqueue_scripts', 'add_social_circle_widget_css');
function add_social_circle_widget_css() {
$social_circle_widget_myStyleUrl = plugins_url('style.css', __FILE__); // Respects SSL, Style.css is relative to the current file
$social_circle_widget_myStyleFile = WP_PLUGIN_DIR . '/social-circle-widget/style.css';
if ( file_exists($social_circle_widget_myStyleFile) ) {
wp_register_style('socialcirclewidgetcss', $social_circle_widget_myStyleUrl);
wp_enqueue_style( 'socialcirclewidgetcss');
}
}
function get_social_circle($facebook_url, $twitter_url, $google_plus_url, $instagram_url, $pinterest_url, $rss_url) {
// This is the main function of the plugin.
$fb = '<a class="minifacebook" href="' . $facebook_url . '" title="Facebook" target="_blank">Facebook</a>';
$tw = '<a class="minitwitter" href="' . $twitter_url . '" title="Twitter" target="_blank">Twitter</a>';
$gp = '<a class="minigoogleplus" href="' . $google_plus_url . '" title="Google+" target="_blank">Google+</a>';
$ins = '<a class="miniinstagram" href="' . $instagram_url . '" title="Instagram" target="_blank">Instagram</a>';
$pin = '<a class="minipinterest" href="' . $pinterest_url . '" title="Pinterest" target="_blank">Pinterest</a>';
$rss = '<a class="minirss" href="' . $rss_url . '" title="RSS" target="_blank">RSS</a>';
$content = '<div class="social-circle" align="center">
<table class="socialw_table" style=" width:140px; height:140px">
<tbody>
<tr>
<td></td><td>' . $fb . '</td><td></td><td>' . $tw . '</td><td></td>
</tr>
<tr>
<td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td>' . $ins . '</td><td></td><td></td><td></td><td>' . $pin . '</td>
</tr>
<tr>
<td></td><td></td><td></td><td></td><td></td>
</tr>
<tr>
<td></td><td>' . $gp . '</td><td></td><td>' . $rss . '</td>
</tr>
</tbody>
</table></div>';
return $content;
}
class Social_Circle_Widget extends WP_Widget {
function Social_Circle_Widget() {
$widget_ops = array('classname' => 'social_circle_widget', 'description' => 'A widget that displays a circle of social icons' );
$this->WP_Widget('social_circle_widget', 'Social Circle Widget', $widget_ops);
}
function widget($args, $instance) {
extract($args, EXTR_SKIP);
echo $before_widget;
$title = empty($instance['title']) ? '&nbsp;' : apply_filters('widget_title', $instance['title']);
$facebook_url = empty($instance['facebook_url']) ? '' : $instance['facebook_url'];
$twitter_url = empty($instance['twitter_url']) ? '' : $instance['twitter_url'];
$google_plus_url = empty($instance['google_plus_url']) ? '' : $instance['google_plus_url'];
$instagram_url = empty($instance['instagram_url']) ? '' : $instance['instagram_url'];
$pinterest_url = empty($instance['pinterest_url']) ? '' : $instance['pinterest_url'];
$rss_url = empty($instance['rss_url']) ? '' : $instance['rss_url'];
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
if ( empty( $facebook_url ) ) { $facebook_url = ''; };
if ( empty( $twitter_url ) ) { $twitter_url = ''; };
if ( empty( $google_plus_url ) ) { $google_plus_url = ''; };
if ( empty( $instagram_url ) ) { $instagram_url = ''; };
if ( empty( $pinterest_url ) ) { $pinterest_url = ''; };
if ( empty( $rss_url ) ) { $rss_url = ''; };
echo get_social_circle($facebook_url, $twitter_url, $google_plus_url, $instagram_url, $pinterest_url, $rss_url); ?>
<div style="clear:both;"></div>
<?php
echo $after_widget;
}
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['facebook_url'] = strip_tags($new_instance['facebook_url']);
$instance['twitter_url'] = strip_tags($new_instance['twitter_url']);
$instance['google_plus_url'] = strip_tags($new_instance['google_plus_url']);
$instance['instagram_url'] = strip_tags($new_instance['instagram_url']);
$instance['pinterest_url'] = strip_tags($new_instance['pinterest_url']);
$instance['rss_url'] = strip_tags($new_instance['rss_url']);
return $instance;
}
function form($instance) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'facebook_url' => '', 'twitter_url' => '', 'google_plus_url' => '', 'instagram_url' => '', 'pinterest_url' => '', 'rss_url' => '' ));
$title = strip_tags($instance['title']);
$facebook_url = strip_tags($instance['facebook_url']);
$twitter_url = strip_tags($instance['twitter_url']);
$google_plus_url = strip_tags($instance['google_plus_url']);
$instagram_url = strip_tags($instance['instagram_url']);
$pinterest_url = strip_tags($instance['pinterest_url']);
$rss_url = strip_tags($instance['rss_url']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <br /><input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo attribute_escape($title); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('facebook_url'); ?>">Facebook URL: <br /><input class="widefat" id="<?php echo $this->get_field_id('facebook_url'); ?>" name="<?php echo $this->get_field_name('facebook_url'); ?>" type="text" value="<?php echo attribute_escape($facebook_url); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('twitter_url'); ?>">Twitter URL: <br /><input class="widefat" id="<?php echo $this->get_field_id('twitter_url'); ?>" name="<?php echo $this->get_field_name('twitter_url'); ?>" type="text" value="<?php echo attribute_escape($twitter_url); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('google_plus_url'); ?>">Google+ URL: <br /><input class="widefat" id="<?php echo $this->get_field_id('google_plus_url'); ?>" name="<?php echo $this->get_field_name('google_plus_url'); ?>" type="text" value="<?php echo attribute_escape($google_plus_url); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('instagram_url'); ?>">Instagram URL: <br /><input class="widefat" id="<?php echo $this->get_field_id('instagram_url'); ?>" name="<?php echo $this->get_field_name('instagram_url'); ?>" type="text" value="<?php echo attribute_escape($instagram_url); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('pinterest_url'); ?>">Pinterest URL: <br /><input class="widefat" id="<?php echo $this->get_field_id('pinterest_url'); ?>" name="<?php echo $this->get_field_name('pinterest_url'); ?>" type="text" value="<?php echo attribute_escape($pinterest_url); ?>" /></label></p>
<p><label for="<?php echo $this->get_field_id('rss_url'); ?>">RSS URL: <br /><input class="widefat" id="<?php echo $this->get_field_id('rss_url'); ?>" name="<?php echo $this->get_field_name('rss_url'); ?>" type="text" value="<?php echo attribute_escape($rss_url); ?>" /></label></p>
<?php
}
}
// register_widget('Social_Circle_Widget');
add_action( 'widgets_init', create_function('', 'return register_widget("Social_Circle_Widget");') );
add_filter( 'wp_feed_cache_transient_lifetime', create_function('$a', 'return 600;') );
?>
/* SOCIAL ICONS */
table td{
border: none;
}
.minirss, .minifacebook, .minitwitter, .minigoogleplus, .miniinstagram, .minipinterest {
position: relative;
width: 30px;
height: 30px;
float: right;
display: block;
background-image: url(images/redes-mini.png);
text-indent: -9999px;
margin: 0 5px 0px;
}
.minirss{
background-position: left top;
}
.minifacebook{
background-position: -30px top;
}
.minitwitter {
background-position: -60px top;
}
.minigoogleplus{
background-position: -90px top;
}
.miniinstagram{
background-position: -120px top;
}
.minipinterest {
background-position: right top;
}
.minirss:hover{
background-position: left bottom;
}
.minifacebook:hover{
background-position: -30px bottom;
}
.minitwitter:hover{
background-position: -60px bottom;
}
.minigoogleplus:hover{
background-position: -90px bottom;
}
.miniinstagram:hover{
background-position: -120px bottom;
}
.minipinterest:hover{
background-position: right bottom;
}
=== Spotify Widget ===
Contributors: betzster, AngelesBroullon
Tags: music, widget
Requires at least: 3.4
Tested up to: 3.4.1
Stable tag: 1.0.1
License: GPLv2 or later