first commit
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
die( 'Direct access forbidden.' );
|
||||
}
|
||||
|
||||
if ( class_exists( 'Solarify_Widget_Flickr' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
class Solarify_Widget_Flickr extends WP_Widget {
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
function __construct() {
|
||||
$widget_ops = array(
|
||||
'classname' => 'widget_flickr',
|
||||
'description' => esc_html__( 'Add linked image with text', 'solarify' ),
|
||||
);
|
||||
parent::__construct( false, esc_html__( 'Theme - Flickr', 'solarify' ), $widget_ops );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $args
|
||||
* @param array $instance
|
||||
*/
|
||||
function widget( $args, $instance ) {
|
||||
extract( $args );
|
||||
|
||||
$flickr_id = esc_attr( $instance['flickr_id'] );
|
||||
$title = esc_attr( $instance['title'] );
|
||||
$number = ( (int) ( esc_attr( $instance['number'] ) ) > 0 ) ? esc_attr( $instance['number'] ) : 8;
|
||||
$title = $before_title . $title . $after_title;
|
||||
|
||||
wp_enqueue_script(
|
||||
'solarify-flickr-widget',
|
||||
SOLARIFY_THEME_URI . '/inc/widgets/flickr/static/js/jflickrfeed.min.js',
|
||||
array( 'jquery' ),
|
||||
'1.0'
|
||||
);
|
||||
|
||||
$filepath = SOLARIFY_THEME_PATH . '/inc/widgets/flickr/views/widget.php';
|
||||
|
||||
if ( file_exists( $filepath ) ) {
|
||||
include( $filepath );
|
||||
} else {
|
||||
esc_html_e( 'View not found', 'solarify' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update( $new_instance, $old_instance ) {
|
||||
return $new_instance;
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'flickr_id' => '', 'number' => '', 'title' => '' ) );
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title', 'solarify' ); ?> </label>
|
||||
<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"
|
||||
value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat"
|
||||
id="<?php $this->get_field_id( 'title' ); ?>"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'flickr_id' ) ); ?>"><?php esc_html_e( 'Flickr ID', 'solarify' ); ?> (<a
|
||||
href="http://www.idgettr.com" target="_blank">idGettr</a>):</label>
|
||||
<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'flickr_id' ) ); ?>"
|
||||
value="<?php echo esc_attr( $instance['flickr_id'] ); ?>" class="widefat"
|
||||
id="<?php $this->get_field_id( 'flickr_id' ); ?>"/>
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"><?php esc_html_e( 'Number of photos', 'solarify' ); ?>
|
||||
:</label>
|
||||
<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'number' ) ); ?>"
|
||||
value="<?php echo esc_attr( $instance['number'] ); ?>" class="widefat"
|
||||
id="<?php echo esc_attr( $this->get_field_id( 'number' ) ); ?>"/>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
16
wp-content/themes/solarify/inc/widgets/flickr/static/js/jflickrfeed.min.js
vendored
Normal file
16
wp-content/themes/solarify/inc/widgets/flickr/static/js/jflickrfeed.min.js
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Joel Sutherland
|
||||
* Licenced under the MIT license
|
||||
* http://www.newmediacampaigns.com/page/jquery-flickr-plugin
|
||||
*
|
||||
* Available tags for templates:
|
||||
* title, link, date_taken, description, published, author, author_id, tags, image*
|
||||
*/
|
||||
(function($){$.fn.jflickrfeed=function(settings,callback){settings=$.extend(true,{flickrbase:'http://api.flickr.com/services/feeds/',feedapi:'photos_public.gne',limit:20,qstrings:{lang:'en-us',format:'json',jsoncallback:'?'},cleanDescription:true,useTemplate:true,itemTemplate:'',itemCallback:function(){}},settings);var url=settings.flickrbase+settings.feedapi+'?';var first=true;for(var key in settings.qstrings){if(!first)
|
||||
url+='&';url+=key+'='+settings.qstrings[key];first=false;}
|
||||
return $(this).each(function(){var $container=$(this);var container=this;$.getJSON(url,function(data){$.each(data.items,function(i,item){if(i<settings.limit){if(settings.cleanDescription){var regex=/<p>(.*?)<\/p>/g;var input=item.description;if(regex.test(input)){item.description=input.match(regex)[2]
|
||||
if(item.description!=undefined)
|
||||
item.description=item.description.replace('<p>','').replace('</p>','');}}
|
||||
item['image_s']=item.media.m.replace('_m','_s');item['image_t']=item.media.m.replace('_m','_t');item['image_m']=item.media.m.replace('_m','_m');item['image']=item.media.m.replace('_m','');item['image_b']=item.media.m.replace('_m','_b');delete item.media;if(settings.useTemplate){var template=settings.itemTemplate;for(var key in item){var rgx=new RegExp('{{'+key+'}}','g');template=template.replace(rgx,item[key]);}
|
||||
$container.append(template)}
|
||||
settings.itemCallback.call(container,item);}});if($.isFunction(callback)){callback.call(container,data);}});});}})(jQuery);
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) { die( 'Direct access forbidden.' ); }
|
||||
|
||||
/**
|
||||
* @var $number
|
||||
* @var $before_widget
|
||||
* @var $after_widget
|
||||
* @var $title
|
||||
* @var $flickr_id
|
||||
*/
|
||||
|
||||
echo wp_kses_post( $before_widget );
|
||||
echo wp_kses_post( $title );
|
||||
?>
|
||||
<div class="wrap-flickr">
|
||||
<ul class="flickr_ul" data-flickr-number="<?php echo esc_attr( $number ); ?>" data-flickr-id="<?php echo esc_attr( $flickr_id ); ?>"></ul>
|
||||
</div>
|
||||
<?php echo wp_kses_post ( $after_widget );
|
||||
Reference in New Issue
Block a user