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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user