Instagram Slider Widget - Version 1.0.1

Version Description

  • Removed preg_match
  • Using exact array index
  • Bug Fixes
Download this release

Release Info

Developer jetonr
Plugin Icon 128x128 Instagram Slider Widget
Version 1.0.1
Comparing to
See all releases

Code changes from version 1.0.0 to 1.0.1

css/instag-slider.css CHANGED
@@ -1,31 +1,31 @@
1
- /* Flexislider Default Settings */
2
- .pllexislider { margin: 0; padding: 0; }
3
- .pllexislider .slides > li {display: none; -webkit-backface-visibility: hidden;} /* Hide the slides before the JS is loaded. Avoids image jumping */
4
- .pllexislider .slides img {width: 100%; display: block;}
5
- .pllexislider .slides:after { display: block; clear: both; visibility: hidden; line-height: 0; height: 0;}
6
- .flex-pauseplay span {text-transform: capitalize;}
7
- .pllexislider, .pllexislider .slides li, .pllexislider .slides > li > a { height: 100%; }
8
-
9
- /* no list style */
10
- .no-bullet { list-style:none; margin:0; }
11
-
12
- /* Flexi Slider Template */
13
- .pllexislider { margin: 0; position: relative; }
14
- .flex-viewport { max-height: 2000px; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; }
15
- .loading .flex-viewport { max-height: 300px; }
16
- .pllexislider .slides { zoom: 1; }
17
-
18
- /* Thumbnails Template */
19
- .thumbnails > li { margin:0 auto; display: inline-block; *display:inline; float: none; width:24%;}
20
-
21
- /* Control Nav */
22
- .pllexislider .flex-control-nav { z-index:2; position: absolute; top: 0.8em; right:0.8em; text-align: center;}
23
- .pllexislider .flex-control-nav li {margin: 0 3px; display: inline-block; zoom: 1; *display: inline;}
24
- .pllexislider .flex-control-paging li a {width: 13px; border: none; height: 13px; display: block; background: #fff; background: rgba(255,255,255,255,0.5); cursor: pointer; text-indent: -9999px; -webkit-border-radius: 20px; -moz-border-radius: 20px; -o-border-radius: 20px; border-radius: 20px; -webkit-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); -moz-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); -o-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); box-shadow: inset 0 0 2px rgba(0,0,0,0.3); }
25
- .pllexislider .flex-control-paging li a:hover { background: #fff; background: rgba(255,255,255,0.7); }
26
- .pllexislider .flex-control-paging li a.flex-active { background: #fff; background: rgba(255,255,255,0.9); cursor: default; }
27
-
28
- /* Description and Time */
29
- .instadescription p { margin-top:5px; margin-bottom: 5px; display: block;}
30
- .instatime { margin-top:5px; width: 40%; float:right; text-align: right; }
31
-
1
+ /* Flexislider Default Settings */
2
+ .pllexislider { margin: 0; padding: 0; }
3
+ .pllexislider .slides > li {display: none; -webkit-backface-visibility: hidden;} /* Hide the slides before the JS is loaded. Avoids image jumping */
4
+ .pllexislider .slides img {width: 100%; display: block;}
5
+ .pllexislider .slides:after { display: block; clear: both; visibility: hidden; line-height: 0; height: 0;}
6
+ .flex-pauseplay span {text-transform: capitalize;}
7
+ .pllexislider, .pllexislider .slides li, .pllexislider .slides > li > a { height: 100%; }
8
+
9
+ /* no list style */
10
+ .no-bullet { list-style:none; margin:0; }
11
+
12
+ /* Flexi Slider Template */
13
+ .pllexislider { margin: 0; position: relative; }
14
+ .flex-viewport { max-height: 2000px; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; -o-transition: all 1s ease; transition: all 1s ease; }
15
+ .loading .flex-viewport { max-height: 300px; }
16
+ .pllexislider .slides { zoom: 1; }
17
+
18
+ /* Thumbnails Template */
19
+ .thumbnails > li { margin:0 auto; display: inline-block; *display:inline; float: none; width:24%;}
20
+
21
+ /* Control Nav */
22
+ .pllexislider .flex-control-nav { z-index:2; position: absolute; top: 0.8em; right:0.8em; text-align: center;}
23
+ .pllexislider .flex-control-nav li {margin: 0 3px; display: inline-block; zoom: 1; *display: inline;}
24
+ .pllexislider .flex-control-paging li a {width: 13px; border: none; height: 13px; display: block; background: #fff; background: rgba(255,255,255,255,0.5); cursor: pointer; text-indent: -9999px; -webkit-border-radius: 20px; -moz-border-radius: 20px; -o-border-radius: 20px; border-radius: 20px; -webkit-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); -moz-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); -o-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); box-shadow: inset 0 0 2px rgba(0,0,0,0.3); }
25
+ .pllexislider .flex-control-paging li a:hover { background: #fff; background: rgba(255,255,255,0.7); }
26
+ .pllexislider .flex-control-paging li a.flex-active { background: #fff; background: rgba(255,255,255,0.9); cursor: default; }
27
+
28
+ /* Description and Time */
29
+ .instadescription p { margin-top:5px; margin-bottom: 5px; display: block;}
30
+ .instatime { margin-top:5px; width: 40%; float:right; text-align: right; }
31
+
inc/functions.php CHANGED
@@ -1,180 +1,177 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- if ( ! function_exists( 'instag_images_data' ) ) :
5
- /**
6
- * Stores the fetched data from instagram in WordPress DB using transients
7
- *
8
- * @return array of localy saved instagram data
9
- */
10
- function instag_images_data( $username, $cache_hours, $nr_images ) {
11
-
12
- $opt_name = 'jr_insta_'.md5( $username );
13
- $instaData = get_transient( $opt_name );
14
- $user_opt = get_option( $opt_name );
15
-
16
- if (
17
- false === $instaData
18
- || $user_opt['username'] != $username
19
- || $user_opt['cache_hours'] != $cache_hours
20
- || $user_opt['nr_images'] != $nr_images
21
- )
22
- {
23
- $instaData = array();
24
- $insta_url = 'http://instagram.com/';
25
- $user_profile = $insta_url.$username;
26
- $json = wp_remote_get( $user_profile, array( 'sslverify' => false, 'timeout'=> 60 ) );
27
- $user_options = compact('username', 'cache_hours', 'nr_images');
28
- update_option($opt_name, $user_options);
29
- if ( $json['response']['code'] == 200 ) {
30
-
31
- $json = $json['body'];
32
- $json = strstr( $json, '{"entry_data"' );
33
- $json = strstr( $json, '</script>', true );
34
- $json = rtrim( $json, ';' );
35
- preg_match_all( "#(\"userMedia\"\:)(\[)(.*?)(\]\,\"prerelease\")#isU", $json, $matches );
36
- $json = isset($matches[3][0]) ? $matches[3][0] : null;
37
- $json = "[".$json."]";
38
- ( $results = json_decode( $json, true ) ) && json_last_error() == JSON_ERROR_NONE;
39
-
40
- if ( ( $results ) && is_array( $results ) ) {
41
- foreach( $results as $current => $result ) {
42
-
43
- if( $current <= $nr_images ) break;
44
- $caption = $result['caption'];
45
- $image = $result['images']['standard_resolution'];
46
- $id = $result['id'];
47
- $image = $image['url'];
48
- $link = $result['link'];
49
- $created_time = $caption['created_time'];
50
- $text = utf8_4byte_to_3byte($caption['text']);
51
-
52
- $filename_data= explode('.',$image);
53
-
54
- if ( is_array( $filename_data ) ) {
55
-
56
- $fileformat = end( $filename_data );
57
-
58
- if ( $fileformat !== false ){
59
-
60
- $image = download_insta_image( $image, md5( $id ) . '.' . $fileformat );
61
- array_push( $instaData, array(
62
- 'id' => $id,
63
- 'user_name' => $username,
64
- 'user_url' => $user_profile,
65
- 'created_time'=> $created_time,
66
- 'text' => $text,
67
- 'image' => $image,
68
- 'link' => $link
69
- ));
70
-
71
- } // end -> if $fileformat !== false
72
-
73
- } // end -> is_array( $filename_data )
74
-
75
- } // end -> foreach
76
-
77
- } // end -> ( $results ) && is_array( $results ) )
78
-
79
- } // end -> $json['response']['code'] === 200 )
80
-
81
- if ( $instaData ) {
82
- set_transient( $opt_name, $instaData, $cache_hours * 60 * 60 );
83
- } // end -> true $instaData
84
-
85
- } // end -> false === $instaData
86
-
87
- return $instaData;
88
- }
89
- endif; // insta_images
90
-
91
- if ( ! function_exists( 'download_insta_image' ) ) :
92
- /**
93
- * Save Instagram images to upload folder and ads to media.
94
- * If the upload fails it returns the remote image url.
95
- *
96
- * @return url to image
97
- */
98
- function download_insta_image( $url , $file ){
99
-
100
- $local_file = JR_INSTAGWP_UPLOAD_PATH . $file;
101
-
102
- if ( file_exists( $local_file ) ) {
103
- return JR_INSTAGWP_UPLODAD_URL . $file;
104
- }
105
-
106
- $get = wp_remote_get( $url, array( 'sslverify' => false ) );
107
- $body = wp_remote_retrieve_body( $get );
108
- $upload = wp_upload_bits( $file, '', $body );
109
-
110
- if ( $upload ) {
111
- return $upload['url'];
112
- }
113
-
114
- return $url;
115
- }
116
- endif; // download_insta_image
117
-
118
- if ( ! function_exists( 'utf8_4byte_to_3byte' ) ) :
119
- /**
120
- * Sanitize 4-byte UTF8 chars; no full utf8mb4 support in drupal7+mysql stack.
121
- * This solution runs in O(n) time BUT assumes that all incoming input is
122
- * strictly UTF8.
123
- *
124
- * @return the sanitized input
125
- */
126
- function utf8_4byte_to_3byte($input) {
127
-
128
- if (!empty($input)) {
129
- $utf8_2byte = 0xC0 /*1100 0000*/; $utf8_2byte_bmask = 0xE0 /*1110 0000*/;
130
- $utf8_3byte = 0xE0 /*1110 0000*/; $utf8_3byte_bmask = 0XF0 /*1111 0000*/;
131
- $utf8_4byte = 0xF0 /*1111 0000*/; $utf8_4byte_bmask = 0xF8 /*1111 1000*/;
132
-
133
- $sanitized = "";
134
- $len = strlen($input);
135
- for ($i = 0; $i < $len; ++$i) {
136
- $mb_char = $input[$i]; // Potentially a multibyte sequence
137
- $byte = ord($mb_char);
138
- if (($byte & $utf8_2byte_bmask) == $utf8_2byte) {
139
- $mb_char .= $input[++$i];
140
- }
141
- else if (($byte & $utf8_3byte_bmask) == $utf8_3byte) {
142
- $mb_char .= $input[++$i];
143
- $mb_char .= $input[++$i];
144
- }
145
- else if (($byte & $utf8_4byte_bmask) == $utf8_4byte) {
146
- // Replace with ? to avoid MySQL exception
147
- $mb_char = '?';
148
- $i += 3;
149
- }
150
-
151
- $sanitized .= $mb_char;
152
- }
153
-
154
- $input= $sanitized;
155
- }
156
-
157
- return $input;
158
- }
159
- endif; // utf8_4byte_to_3byte
160
-
161
- if ( ! function_exists( 'instag_templates' ) ) :
162
- /**
163
- * Helper Function to insert Templates for widget
164
- *
165
- * @include file templates
166
- */
167
- function instag_templates( $template, $data_arr ){
168
-
169
- $filename = JR_INSTAGWP_PATH_TEMPLATE . $template . '.php';
170
-
171
- if(file_exists( $filename )){
172
-
173
- include $filename;
174
-
175
- } else {
176
-
177
- echo __( sprintf('Template not found<br>%s' , $filename), 'example' );
178
- }
179
- }
180
  endif; // instag_templates
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
+
4
+ if ( ! function_exists( 'instag_images_data' ) ) :
5
+ /**
6
+ * Stores the fetched data from instagram in WordPress DB using transients
7
+ *
8
+ * @return array of localy saved instagram data
9
+ */
10
+ function instag_images_data( $username, $cache_hours, $nr_images ) {
11
+
12
+ $opt_name = 'jr_insta_'.md5( $username );
13
+ $instaData = get_transient( $opt_name );
14
+ $user_opt = get_option( $opt_name );
15
+
16
+ if (
17
+ false === $instaData
18
+ || $user_opt['username'] != $username
19
+ || $user_opt['cache_hours'] != $cache_hours
20
+ || $user_opt['nr_images'] != $nr_images
21
+ )
22
+ {
23
+ $instaData = array();
24
+ $insta_url = 'http://instagram.com/';
25
+ $user_profile = $insta_url.$username;
26
+ $json = wp_remote_get( $user_profile, array( 'sslverify' => false, 'timeout'=> 60 ) );
27
+ $user_options = compact('username', 'cache_hours', 'nr_images');
28
+ update_option($opt_name, $user_options);
29
+ if ( $json['response']['code'] == 200 ) {
30
+
31
+ $json = $json['body'];
32
+ $json = strstr( $json, '{"entry_data"' );
33
+ $json = strstr( $json, '</script>', true );
34
+ $json = rtrim( $json, ';' );
35
+ ( $results = json_decode( $json, true ) ) && json_last_error() == JSON_ERROR_NONE;
36
+
37
+ if ( ( $results ) && is_array( $results ) ) {
38
+ foreach( $results['entry_data']['UserProfile'][0]['userMedia'] as $current => $result ) {
39
+
40
+ if( $current >= $nr_images ) break;
41
+ $caption = $result['caption'];
42
+ $image = $result['images']['standard_resolution'];
43
+ $id = $result['id'];
44
+ $image = $image['url'];
45
+ $link = $result['link'];
46
+ $created_time = $caption['created_time'];
47
+ $text = utf8_4byte_to_3byte($caption['text']);
48
+
49
+ $filename_data= explode('.',$image);
50
+
51
+ if ( is_array( $filename_data ) ) {
52
+
53
+ $fileformat = end( $filename_data );
54
+
55
+ if ( $fileformat !== false ){
56
+
57
+ $image = download_insta_image( $image, md5( $id ) . '.' . $fileformat );
58
+ array_push( $instaData, array(
59
+ 'id' => $id,
60
+ 'user_name' => $username,
61
+ 'user_url' => $user_profile,
62
+ 'created_time'=> $created_time,
63
+ 'text' => $text,
64
+ 'image' => $image,
65
+ 'link' => $link
66
+ ));
67
+
68
+ } // end -> if $fileformat !== false
69
+
70
+ } // end -> is_array( $filename_data )
71
+
72
+ } // end -> foreach
73
+
74
+ } // end -> ( $results ) && is_array( $results ) )
75
+
76
+ } // end -> $json['response']['code'] === 200 )
77
+
78
+ if ( $instaData ) {
79
+ set_transient( $opt_name, $instaData, $cache_hours * 60 * 60 );
80
+ } // end -> true $instaData
81
+
82
+ } // end -> false === $instaData
83
+
84
+ return $instaData;
85
+ }
86
+ endif; // insta_images
87
+
88
+ if ( ! function_exists( 'download_insta_image' ) ) :
89
+ /**
90
+ * Save Instagram images to upload folder and ads to media.
91
+ * If the upload fails it returns the remote image url.
92
+ *
93
+ * @return url to image
94
+ */
95
+ function download_insta_image( $url , $file ){
96
+
97
+ $local_file = JR_INSTAGWP_UPLOAD_PATH . $file;
98
+
99
+ if ( file_exists( $local_file ) ) {
100
+ return JR_INSTAGWP_UPLODAD_URL . $file;
101
+ }
102
+
103
+ $get = wp_remote_get( $url, array( 'sslverify' => false ) );
104
+ $body = wp_remote_retrieve_body( $get );
105
+ $upload = wp_upload_bits( $file, '', $body );
106
+
107
+ if ( $upload ) {
108
+ return $upload['url'];
109
+ }
110
+
111
+ return $url;
112
+ }
113
+ endif; // download_insta_image
114
+
115
+ if ( ! function_exists( 'utf8_4byte_to_3byte' ) ) :
116
+ /**
117
+ * Sanitize 4-byte UTF8 chars; no full utf8mb4 support in drupal7+mysql stack.
118
+ * This solution runs in O(n) time BUT assumes that all incoming input is
119
+ * strictly UTF8.
120
+ *
121
+ * @return the sanitized input
122
+ */
123
+ function utf8_4byte_to_3byte($input) {
124
+
125
+ if (!empty($input)) {
126
+ $utf8_2byte = 0xC0 /*1100 0000*/; $utf8_2byte_bmask = 0xE0 /*1110 0000*/;
127
+ $utf8_3byte = 0xE0 /*1110 0000*/; $utf8_3byte_bmask = 0XF0 /*1111 0000*/;
128
+ $utf8_4byte = 0xF0 /*1111 0000*/; $utf8_4byte_bmask = 0xF8 /*1111 1000*/;
129
+
130
+ $sanitized = "";
131
+ $len = strlen($input);
132
+ for ($i = 0; $i < $len; ++$i) {
133
+ $mb_char = $input[$i]; // Potentially a multibyte sequence
134
+ $byte = ord($mb_char);
135
+ if (($byte & $utf8_2byte_bmask) == $utf8_2byte) {
136
+ $mb_char .= $input[++$i];
137
+ }
138
+ else if (($byte & $utf8_3byte_bmask) == $utf8_3byte) {
139
+ $mb_char .= $input[++$i];
140
+ $mb_char .= $input[++$i];
141
+ }
142
+ else if (($byte & $utf8_4byte_bmask) == $utf8_4byte) {
143
+ // Replace with ? to avoid MySQL exception
144
+ $mb_char = '?';
145
+ $i += 3;
146
+ }
147
+
148
+ $sanitized .= $mb_char;
149
+ }
150
+
151
+ $input= $sanitized;
152
+ }
153
+
154
+ return $input;
155
+ }
156
+ endif; // utf8_4byte_to_3byte
157
+
158
+ if ( ! function_exists( 'instag_templates' ) ) :
159
+ /**
160
+ * Helper Function to insert Templates for widget
161
+ *
162
+ * @include file templates
163
+ */
164
+ function instag_templates( $template, $data_arr ){
165
+
166
+ $filename = JR_INSTAGWP_PATH_TEMPLATE . $template . '.php';
167
+
168
+ if(file_exists( $filename )){
169
+
170
+ include $filename;
171
+
172
+ } else {
173
+
174
+ echo __( sprintf('Template not found<br>%s' , $filename), 'example' );
175
+ }
176
+ }
 
 
 
177
  endif; // instag_templates
instaram_slider.php CHANGED
@@ -1,141 +1,146 @@
1
- <?php
2
- /*
3
- Plugin Name: Instagram Slider Widget
4
- Plugin URI: http://jrwebstudio.com/instagram-slider/
5
- Description: Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
6
- Author: jetonr
7
- Author URI: http://jrwebstudio.com/
8
- License: GPLv2 or later
9
- */
10
-
11
- /* Define Constants for this widget */
12
- define('JR_INSTAGWP_PATH_BASE' , dirname(__FILE__) . DIRECTORY_SEPARATOR);
13
- define('JR_INSTAGWP_PATH_TEMPLATE' , JR_INSTAGWP_PATH_BASE . 'templates/');
14
- define('JR_INSTAGWP_PATH_INC' , JR_INSTAGWP_PATH_BASE . 'inc/');
15
- define('JR_INSTAGWP_URL' , plugins_url( '/' , __FILE__ ));
16
- define('JR_INSTAGWP_WP_VERSION' , get_bloginfo('version'));
17
- define('JR_INSTAGWP_WP_MIN_VERSION' , 3.5);
18
-
19
- $upload_dir = wp_upload_dir();
20
- define('JR_INSTAGWP_UPLOAD_PATH' , $upload_dir['path'] . '/');
21
- define('JR_INSTAGWP_UPLODAD_URL' , $upload_dir['baseurl'] . $upload_dir['subdir'] . '/');
22
-
23
- // Require functions need for this widget
24
- require_once ( JR_INSTAGWP_PATH_INC . 'functions.php' );
25
-
26
- /* Enqueue Frontend Plugin Styles & Scripts */
27
- function jr_insta_slider_enqueue() {
28
-
29
- // Register and enqueue Styles
30
- wp_enqueue_style( 'instag-slider', JR_INSTAGWP_URL . 'css/instag-slider.css' );
31
-
32
- // Register and enqueue Scripts
33
- wp_enqueue_script(
34
- 'jquery-flexi-slider',
35
- JR_INSTAGWP_URL . 'js/jquery.flexslider-min.js',
36
- array( 'jquery' ),
37
- false,
38
- true
39
- );
40
-
41
- }
42
- add_action( 'wp_enqueue_scripts', 'jr_insta_slider_enqueue' );
43
-
44
- /* Register widget on windgets init */
45
- add_action( 'widgets_init', 'jr_insta_slider_register' );
46
- function jr_insta_slider_register() {
47
- register_widget( 'JR_InstagramSlider' );
48
- }
49
-
50
- class JR_InstagramSlider extends WP_Widget {
51
-
52
- public function __construct() {
53
- parent::__construct( 'jr_insta_slider', __( 'Instagram Slider', 'jrinstaslider' ), array(
54
- 'classname' => 'jr-insta-slider',
55
- 'description' => __( 'A widget that displays a slider with instagram images ', 'jrinstaslider', 'jrinstaslider' ),
56
- ) );
57
- }
58
-
59
- function widget( $args, $instance ) {
60
- extract( $args );
61
-
62
- //Our variables from the widget settings.
63
- $title = apply_filters('widget_title', $instance['title'] );
64
- $username = $instance['username'];
65
- $images_nr = $instance['images_number'];
66
- $refresh_hour = $instance['refresh_hour'];
67
- $template = $instance['template'];
68
-
69
- echo $before_widget;
70
-
71
- // Display the widget title
72
- if ( $title ) {
73
- echo $before_title . $title . $after_title;
74
- }
75
- // Get instagram data
76
- $insta_data = instag_images_data($username, $refresh_hour, $images_nr );
77
-
78
- //include the template based on user choice
79
- instag_templates( $template, $insta_data );
80
-
81
- echo $after_widget;
82
- }
83
-
84
- //Update the widget
85
-
86
- function update( $new_instance, $old_instance ) {
87
- $instance = $old_instance;
88
-
89
- //Strip tags from title and name to remove HTML
90
- $instance['title'] = strip_tags( $new_instance['title'] );
91
- $instance['username'] = $new_instance['username'];
92
- $instance['images_number'] = $new_instance['images_number'];
93
- $instance['refresh_hour'] = $new_instance['refresh_hour'];
94
- $instance['template'] = $new_instance['template'];
95
-
96
- return $instance;
97
- }
98
-
99
-
100
- function form( $instance ) {
101
-
102
- //Set up some default widget settings.
103
- $defaults = array( 'title' => __('Instagram Slider', 'jrinstaslider'), 'username' => __('', 'jrinstaslider'), 'images_number' => 5, 'refresh_hour' => 5, 'template' => 'slider' );
104
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
105
-
106
- <p>
107
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'jrinstaslider'); ?></label>
108
- <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
109
- </p>
110
-
111
- <p>
112
- <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e('Instagram Username:', 'jrinstaslider'); ?></label>
113
- <input class="widefat" id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" />
114
- </p>
115
-
116
- <p>
117
- <label for="<?php echo $this->get_field_id( 'template' ); ?>"><?php _e( 'Images Layout', 'jrinstaslider' ); ?>
118
- <select class="widefat" name="<?php echo $this->get_field_name( 'template' ); ?>">
119
- <option value="slider" <?php ($instance['template'] == 'slider') ? ' selected="selected"' : ''; ?>><?php _e('Slider', 'jrinstaslider'); ?></option>
120
- <option value="thumbs" <?php ($instance['template'] == 'thumbs') ? ' selected="selected"' : ''; ?>><?php _e('Thumbnails', 'jrinstaslider'); ?></option>
121
- </select>
122
- </label>
123
- </p>
124
-
125
- <p>
126
- <label for="<?php echo $this->get_field_id( 'images_number' ); ?>"><?php _e('Number of Images to Show:', 'jrinstaslider'); ?>
127
- <input class="small-text" id="<?php echo $this->get_field_id( 'images_number' ); ?>" name="<?php echo $this->get_field_name( 'images_number' ); ?>" value="<?php echo $instance['images_number']; ?>" />
128
- <small><?php _e('( max 20 )', 'jrinstaslider'); ?></small>
129
- </label>
130
- </p>
131
-
132
- <p>
133
- <label for="<?php echo $this->get_field_id( 'refresh_hour' ); ?>"><?php _e('Check for new images every:', 'jrinstaslider'); ?>
134
- <input class="small-text" id="<?php echo $this->get_field_id( 'refresh_hour' ); ?>" name="<?php echo $this->get_field_name( 'refresh_hour' ); ?>" value="<?php echo $instance['refresh_hour']; ?>" />
135
- <small><?php _e('hours', 'jrinstaslider'); ?></small>
136
- </label>
137
- </p>
138
-
139
- <?php
140
- }
141
- }
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Instagram Slider Widget
4
+ Plugin URI: http://jrwebstudio.com/instagram-slider/
5
+ Version: 1.0.1
6
+ Description: Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
7
+ Author: jetonr
8
+ Author URI: http://jrwebstudio.com/
9
+ License: GPLv2 or later
10
+ */
11
+
12
+ /* Define Constants for this widget */
13
+ define('JR_INSTAGWP_PATH_BASE' , dirname(__FILE__) . DIRECTORY_SEPARATOR);
14
+ define('JR_INSTAGWP_PATH_TEMPLATE' , JR_INSTAGWP_PATH_BASE . 'templates/');
15
+ define('JR_INSTAGWP_PATH_INC' , JR_INSTAGWP_PATH_BASE . 'inc/');
16
+ define('JR_INSTAGWP_URL' , plugins_url( '/' , __FILE__ ));
17
+ define('JR_INSTAGWP_WP_VERSION' , get_bloginfo('version'));
18
+ define('JR_INSTAGWP_WP_MIN_VERSION' , 3.5);
19
+
20
+ $upload_dir = wp_upload_dir();
21
+ define('JR_INSTAGWP_UPLOAD_PATH' , $upload_dir['path'] . '/');
22
+ define('JR_INSTAGWP_UPLODAD_URL' , $upload_dir['baseurl'] . $upload_dir['subdir'] . '/');
23
+
24
+ // Require functions need for this widget
25
+ require_once ( JR_INSTAGWP_PATH_INC . 'functions.php' );
26
+
27
+ /* Enqueue Frontend Plugin Styles & Scripts */
28
+ function jr_insta_slider_enqueue() {
29
+
30
+ // Register and enqueue Styles
31
+ wp_enqueue_style( 'instag-slider', JR_INSTAGWP_URL . 'css/instag-slider.css' );
32
+
33
+ // Register and enqueue Scripts
34
+ wp_enqueue_script(
35
+ 'jquery-flexi-slider',
36
+ JR_INSTAGWP_URL . 'js/jquery.flexslider-min.js',
37
+ array( 'jquery' ),
38
+ false,
39
+ true
40
+ );
41
+
42
+ }
43
+ add_action( 'wp_enqueue_scripts', 'jr_insta_slider_enqueue' );
44
+
45
+ /* Register widget on windgets init */
46
+ add_action( 'widgets_init', 'jr_insta_slider_register' );
47
+ function jr_insta_slider_register() {
48
+ register_widget( 'JR_InstagramSlider' );
49
+ }
50
+
51
+ class JR_InstagramSlider extends WP_Widget {
52
+
53
+ public function __construct() {
54
+ parent::__construct(
55
+ 'jr_insta_slider', //-----> Widget ID
56
+ __( 'Instagram Slider', 'jrinstaslider' ), //--> Widget Name
57
+ array( //-----> Widget Options Array
58
+ 'classname' => 'jr-insta-slider',
59
+ 'description' => __( 'A widget that displays a slider with instagram images ', 'jrinstaslider' ),
60
+ )
61
+ );
62
+ }
63
+
64
+ function widget( $args, $instance ) {
65
+ extract( $args );
66
+
67
+ //Our variables from the widget settings.
68
+ $title = apply_filters('widget_title', $instance['title'] );
69
+ $username = $instance['username'];
70
+ $images_nr = $instance['images_number'];
71
+ $refresh_hour = $instance['refresh_hour'];
72
+ $template = $instance['template'];
73
+
74
+ echo $before_widget;
75
+
76
+ // Display the widget title
77
+ if ( $title ) {
78
+ echo $before_title . $title . $after_title;
79
+ }
80
+ // Get instagram data
81
+ $insta_data = instag_images_data($username, $refresh_hour, $images_nr );
82
+
83
+ //include the template based on user choice
84
+ instag_templates( $template, $insta_data );
85
+
86
+ echo $after_widget;
87
+ }
88
+
89
+ //Update the widget
90
+
91
+ function update( $new_instance, $old_instance ) {
92
+ $instance = $old_instance;
93
+
94
+ //Strip tags from title and name to remove HTML
95
+ $instance['title'] = strip_tags( $new_instance['title'] );
96
+ $instance['username'] = $new_instance['username'];
97
+ $instance['images_number'] = $new_instance['images_number'];
98
+ $instance['refresh_hour'] = $new_instance['refresh_hour'];
99
+ $instance['template'] = $new_instance['template'];
100
+
101
+ return $instance;
102
+ }
103
+
104
+
105
+ function form( $instance ) {
106
+
107
+ //Set up some default widget settings.
108
+ $defaults = array( 'title' => __('Instagram Slider', 'jrinstaslider'), 'username' => __('', 'jrinstaslider'), 'images_number' => 5, 'refresh_hour' => 5, 'template' => 'slider' );
109
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
110
+
111
+ <p>
112
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'jrinstaslider'); ?></label>
113
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
114
+ </p>
115
+
116
+ <p>
117
+ <label for="<?php echo $this->get_field_id( 'username' ); ?>"><?php _e('Instagram Username:', 'jrinstaslider'); ?></label>
118
+ <input class="widefat" id="<?php echo $this->get_field_id( 'username' ); ?>" name="<?php echo $this->get_field_name( 'username' ); ?>" value="<?php echo $instance['username']; ?>" />
119
+ </p>
120
+
121
+ <p>
122
+ <label for="<?php echo $this->get_field_id( 'template' ); ?>"><?php _e( 'Images Layout', 'jrinstaslider' ); ?>
123
+ <select class="widefat" name="<?php echo $this->get_field_name( 'template' ); ?>">
124
+ <option value="slider" <?php echo ($instance['template'] == 'slider') ? ' selected="selected"' : ''; ?>><?php _e('Slider', 'jrinstaslider'); ?></option>
125
+ <option value="thumbs" <?php echo ($instance['template'] == 'thumbs') ? ' selected="selected"' : ''; ?>><?php _e('Thumbnails', 'jrinstaslider'); ?></option>
126
+ </select>
127
+ </label>
128
+ </p>
129
+
130
+ <p>
131
+ <label for="<?php echo $this->get_field_id( 'images_number' ); ?>"><?php _e('Number of Images to Show:', 'jrinstaslider'); ?>
132
+ <input class="small-text" id="<?php echo $this->get_field_id( 'images_number' ); ?>" name="<?php echo $this->get_field_name( 'images_number' ); ?>" value="<?php echo $instance['images_number']; ?>" />
133
+ <small><?php _e('( max 20 )', 'jrinstaslider'); ?></small>
134
+ </label>
135
+ </p>
136
+
137
+ <p>
138
+ <label for="<?php echo $this->get_field_id( 'refresh_hour' ); ?>"><?php _e('Check for new images every:', 'jrinstaslider'); ?>
139
+ <input class="small-text" id="<?php echo $this->get_field_id( 'refresh_hour' ); ?>" name="<?php echo $this->get_field_name( 'refresh_hour' ); ?>" value="<?php echo $instance['refresh_hour']; ?>" />
140
+ <small><?php _e('hours', 'jrinstaslider'); ?></small>
141
+ </label>
142
+ </p>
143
+
144
+ <?php
145
+ }
146
+ }
js/jquery.flexslider-min.js CHANGED
@@ -1,6 +1,6 @@
1
- /*
2
- * jQuery FlexSlider v2.2
3
- * Copyright 2012 WooThemes
4
- * Contributing Author: Tyler Smith
5
- */
6
  (function(e){e.pllexislider=function(t,n){var r=e(t);r.vars=e.extend({},e.pllexislider.defaults,n);var i=r.vars.namespace,s=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,o=("ontouchstart"in window||s||window.DocumentTouch&&document instanceof DocumentTouch)&&r.vars.touch,u="click touchend MSPointerUp",a="",f,l=r.vars.direction==="vertical",c=r.vars.reverse,h=r.vars.itemWidth>0,p=r.vars.animation==="fade",d=r.vars.asNavFor!=="",v={},m=true;e.data(t,"pllexislider",r);v={init:function(){r.animating=false;r.currentSlide=parseInt(r.vars.startAt?r.vars.startAt:0);if(isNaN(r.currentSlide))r.currentSlide=0;r.animatingTo=r.currentSlide;r.atEnd=r.currentSlide===0||r.currentSlide===r.last;r.containerSelector=r.vars.selector.substr(0,r.vars.selector.search(" "));r.slides=e(r.vars.selector,r);r.container=e(r.containerSelector,r);r.count=r.slides.length;r.syncExists=e(r.vars.sync).length>0;if(r.vars.animation==="slide")r.vars.animation="swing";r.prop=l?"top":"marginLeft";r.args={};r.manualPause=false;r.stopped=false;r.started=false;r.startTimeout=null;r.transitions=!r.vars.video&&!p&&r.vars.useCSS&&function(){var e=document.createElement("div"),t=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var n in t){if(e.style[t[n]]!==undefined){r.pfx=t[n].replace("Perspective","").toLowerCase();r.prop="-"+r.pfx+"-transform";return true}}return false}();if(r.vars.controlsContainer!=="")r.controlsContainer=e(r.vars.controlsContainer).length>0&&e(r.vars.controlsContainer);if(r.vars.manualControls!=="")r.manualControls=e(r.vars.manualControls).length>0&&e(r.vars.manualControls);if(r.vars.randomize){r.slides.sort(function(){return Math.round(Math.random())-.5});r.container.empty().append(r.slides)}r.doMath();r.setup("init");if(r.vars.controlNav)v.controlNav.setup();if(r.vars.directionNav)v.directionNav.setup();if(r.vars.keyboard&&(e(r.containerSelector).length===1||r.vars.multipleKeyboard)){e(document).bind("keyup",function(e){var t=e.keyCode;if(!r.animating&&(t===39||t===37)){var n=t===39?r.getTarget("next"):t===37?r.getTarget("prev"):false;r.flexAnimate(n,r.vars.pauseOnAction)}})}if(r.vars.mousewheel){r.bind("mousewheel",function(e,t,n,i){e.preventDefault();var s=t<0?r.getTarget("next"):r.getTarget("prev");r.flexAnimate(s,r.vars.pauseOnAction)})}if(r.vars.pausePlay)v.pausePlay.setup();if(r.vars.slideshow&&r.vars.pauseInvisible)v.pauseInvisible.init();if(r.vars.slideshow){if(r.vars.pauseOnHover){r.hover(function(){if(!r.manualPlay&&!r.manualPause)r.pause()},function(){if(!r.manualPause&&!r.manualPlay&&!r.stopped)r.play()})}if(!r.vars.pauseInvisible||!v.pauseInvisible.isHidden()){r.vars.initDelay>0?r.startTimeout=setTimeout(r.play,r.vars.initDelay):r.play()}}if(d)v.asNav.setup();if(o&&r.vars.touch)v.touch();if(!p||p&&r.vars.smoothHeight)e(window).bind("resize orientationchange focus",v.resize);r.find("img").attr("draggable","false");setTimeout(function(){r.vars.start(r)},200)},asNav:{setup:function(){r.asNav=true;r.animatingTo=Math.floor(r.currentSlide/r.move);r.currentItem=r.currentSlide;r.slides.removeClass(i+"active-slide").eq(r.currentItem).addClass(i+"active-slide");if(!s){r.slides.click(function(t){t.preventDefault();var n=e(this),s=n.index();var o=n.offset().left-e(r).scrollLeft();if(o<=0&&n.hasClass(i+"active-slide")){r.flexAnimate(r.getTarget("prev"),true)}else if(!e(r.vars.asNavFor).data("pllexislider").animating&&!n.hasClass(i+"active-slide")){r.direction=r.currentItem<s?"next":"prev";r.flexAnimate(s,r.vars.pauseOnAction,false,true,true)}})}else{t._slider=r;r.slides.each(function(){var t=this;t._gesture=new MSGesture;t._gesture.target=t;t.addEventListener("MSPointerDown",function(e){e.preventDefault();if(e.currentTarget._gesture)e.currentTarget._gesture.addPointer(e.pointerId)},false);t.addEventListener("MSGestureTap",function(t){t.preventDefault();var n=e(this),i=n.index();if(!e(r.vars.asNavFor).data("pllexislider").animating&&!n.hasClass("active")){r.direction=r.currentItem<i?"next":"prev";r.flexAnimate(i,r.vars.pauseOnAction,false,true,true)}})})}}},controlNav:{setup:function(){if(!r.manualControls){v.controlNav.setupPaging()}else{v.controlNav.setupManual()}},setupPaging:function(){var t=r.vars.controlNav==="thumbnails"?"control-thumbs":"control-paging",n=1,s,o;r.controlNavScaffold=e('<ol class="'+i+"control-nav "+i+t+'"></ol>');if(r.pagingCount>1){for(var f=0;f<r.pagingCount;f++){o=r.slides.eq(f);s=r.vars.controlNav==="thumbnails"?'<img src="'+o.attr("data-thumb")+'"/>':"<a>"+n+"</a>";if("thumbnails"===r.vars.controlNav&&true===r.vars.thumbCaptions){var l=o.attr("data-thumbcaption");if(""!=l&&undefined!=l)s+='<span class="'+i+'caption">'+l+"</span>"}r.controlNavScaffold.append("<li>"+s+"</li>");n++}}r.controlsContainer?e(r.controlsContainer).append(r.controlNavScaffold):r.append(r.controlNavScaffold);v.controlNav.set();v.controlNav.active();r.controlNavScaffold.delegate("a, img",u,function(t){t.preventDefault();if(a===""||a===t.type){var n=e(this),s=r.controlNav.index(n);if(!n.hasClass(i+"active")){r.direction=s>r.currentSlide?"next":"prev";r.flexAnimate(s,r.vars.pauseOnAction)}}if(a===""){a=t.type}v.setToClearWatchedEvent()})},setupManual:function(){r.controlNav=r.manualControls;v.controlNav.active();r.controlNav.bind(u,function(t){t.preventDefault();if(a===""||a===t.type){var n=e(this),s=r.controlNav.index(n);if(!n.hasClass(i+"active")){s>r.currentSlide?r.direction="next":r.direction="prev";r.flexAnimate(s,r.vars.pauseOnAction)}}if(a===""){a=t.type}v.setToClearWatchedEvent()})},set:function(){var t=r.vars.controlNav==="thumbnails"?"img":"a";r.controlNav=e("."+i+"control-nav li "+t,r.controlsContainer?r.controlsContainer:r)},active:function(){r.controlNav.removeClass(i+"active").eq(r.animatingTo).addClass(i+"active")},update:function(t,n){if(r.pagingCount>1&&t==="add"){r.controlNavScaffold.append(e("<li><a>"+r.count+"</a></li>"))}else if(r.pagingCount===1){r.controlNavScaffold.find("li").remove()}else{r.controlNav.eq(n).closest("li").remove()}v.controlNav.set();r.pagingCount>1&&r.pagingCount!==r.controlNav.length?r.update(n,t):v.controlNav.active()}},directionNav:{setup:function(){var t=e('<ul class="'+i+'direction-nav"><li><a class="'+i+'prev" href="#">'+r.vars.prevText+'</a></li><li><a class="'+i+'next" href="#">'+r.vars.nextText+"</a></li></ul>");if(r.controlsContainer){e(r.controlsContainer).append(t);r.directionNav=e("."+i+"direction-nav li a",r.controlsContainer)}else{r.append(t);r.directionNav=e("."+i+"direction-nav li a",r)}v.directionNav.update();r.directionNav.bind(u,function(t){t.preventDefault();var n;if(a===""||a===t.type){n=e(this).hasClass(i+"next")?r.getTarget("next"):r.getTarget("prev");r.flexAnimate(n,r.vars.pauseOnAction)}if(a===""){a=t.type}v.setToClearWatchedEvent()})},update:function(){var e=i+"disabled";if(r.pagingCount===1){r.directionNav.addClass(e).attr("tabindex","-1")}else if(!r.vars.animationLoop){if(r.animatingTo===0){r.directionNav.removeClass(e).filter("."+i+"prev").addClass(e).attr("tabindex","-1")}else if(r.animatingTo===r.last){r.directionNav.removeClass(e).filter("."+i+"next").addClass(e).attr("tabindex","-1")}else{r.directionNav.removeClass(e).removeAttr("tabindex")}}else{r.directionNav.removeClass(e).removeAttr("tabindex")}}},pausePlay:{setup:function(){var t=e('<div class="'+i+'pauseplay"><a></a></div>');if(r.controlsContainer){r.controlsContainer.append(t);r.pausePlay=e("."+i+"pauseplay a",r.controlsContainer)}else{r.append(t);r.pausePlay=e("."+i+"pauseplay a",r)}v.pausePlay.update(r.vars.slideshow?i+"pause":i+"play");r.pausePlay.bind(u,function(t){t.preventDefault();if(a===""||a===t.type){if(e(this).hasClass(i+"pause")){r.manualPause=true;r.manualPlay=false;r.pause()}else{r.manualPause=false;r.manualPlay=true;r.play()}}if(a===""){a=t.type}v.setToClearWatchedEvent()})},update:function(e){e==="play"?r.pausePlay.removeClass(i+"pause").addClass(i+"play").html(r.vars.playText):r.pausePlay.removeClass(i+"play").addClass(i+"pause").html(r.vars.pauseText)}},touch:function(){var e,n,i,o,u,a,f=false,d=0,v=0,m=0;if(!s){t.addEventListener("touchstart",g,false);function g(s){if(r.animating){s.preventDefault()}else if(window.navigator.msPointerEnabled||s.touches.length===1){r.pause();o=l?r.h:r.w;a=Number(new Date);d=s.touches[0].pageX;v=s.touches[0].pageY;i=h&&c&&r.animatingTo===r.last?0:h&&c?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:h&&r.currentSlide===r.last?r.limit:h?(r.itemW+r.vars.itemMargin)*r.move*r.currentSlide:c?(r.last-r.currentSlide+r.cloneOffset)*o:(r.currentSlide+r.cloneOffset)*o;e=l?v:d;n=l?d:v;t.addEventListener("touchmove",y,false);t.addEventListener("touchend",b,false)}}function y(t){d=t.touches[0].pageX;v=t.touches[0].pageY;u=l?e-v:e-d;f=l?Math.abs(u)<Math.abs(d-n):Math.abs(u)<Math.abs(v-n);var s=500;if(!f||Number(new Date)-a>s){t.preventDefault();if(!p&&r.transitions){if(!r.vars.animationLoop){u=u/(r.currentSlide===0&&u<0||r.currentSlide===r.last&&u>0?Math.abs(u)/o+2:1)}r.setProps(i+u,"setTouch")}}}function b(s){t.removeEventListener("touchmove",y,false);if(r.animatingTo===r.currentSlide&&!f&&!(u===null)){var l=c?-u:u,h=l>0?r.getTarget("next"):r.getTarget("prev");if(r.canAdvance(h)&&(Number(new Date)-a<550&&Math.abs(l)>50||Math.abs(l)>o/2)){r.flexAnimate(h,r.vars.pauseOnAction)}else{if(!p)r.flexAnimate(r.currentSlide,r.vars.pauseOnAction,true)}}t.removeEventListener("touchend",b,false);e=null;n=null;u=null;i=null}}else{t.style.msTouchAction="none";t._gesture=new MSGesture;t._gesture.target=t;t.addEventListener("MSPointerDown",w,false);t._slider=r;t.addEventListener("MSGestureChange",E,false);t.addEventListener("MSGestureEnd",S,false);function w(e){e.stopPropagation();if(r.animating){e.preventDefault()}else{r.pause();t._gesture.addPointer(e.pointerId);m=0;o=l?r.h:r.w;a=Number(new Date);i=h&&c&&r.animatingTo===r.last?0:h&&c?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:h&&r.currentSlide===r.last?r.limit:h?(r.itemW+r.vars.itemMargin)*r.move*r.currentSlide:c?(r.last-r.currentSlide+r.cloneOffset)*o:(r.currentSlide+r.cloneOffset)*o}}function E(e){e.stopPropagation();var n=e.target._slider;if(!n){return}var r=-e.translationX,s=-e.translationY;m=m+(l?s:r);u=m;f=l?Math.abs(m)<Math.abs(-r):Math.abs(m)<Math.abs(-s);if(e.detail===e.MSGESTURE_FLAG_INERTIA){setImmediate(function(){t._gesture.stop()});return}if(!f||Number(new Date)-a>500){e.preventDefault();if(!p&&n.transitions){if(!n.vars.animationLoop){u=m/(n.currentSlide===0&&m<0||n.currentSlide===n.last&&m>0?Math.abs(m)/o+2:1)}n.setProps(i+u,"setTouch")}}}function S(t){t.stopPropagation();var r=t.target._slider;if(!r){return}if(r.animatingTo===r.currentSlide&&!f&&!(u===null)){var s=c?-u:u,l=s>0?r.getTarget("next"):r.getTarget("prev");if(r.canAdvance(l)&&(Number(new Date)-a<550&&Math.abs(s)>50||Math.abs(s)>o/2)){r.flexAnimate(l,r.vars.pauseOnAction)}else{if(!p)r.flexAnimate(r.currentSlide,r.vars.pauseOnAction,true)}}e=null;n=null;u=null;i=null;m=0}}},resize:function(){if(!r.animating&&r.is(":visible")){if(!h)r.doMath();if(p){v.smoothHeight()}else if(h){r.slides.width(r.computedW);r.update(r.pagingCount);r.setProps()}else if(l){r.viewport.height(r.h);r.setProps(r.h,"setTotal")}else{if(r.vars.smoothHeight)v.smoothHeight();r.newSlides.width(r.computedW);r.setProps(r.computedW,"setTotal")}}},smoothHeight:function(e){if(!l||p){var t=p?r:r.viewport;e?t.animate({height:r.slides.eq(r.animatingTo).height()},e):t.height(r.slides.eq(r.animatingTo).height())}},sync:function(t){var n=e(r.vars.sync).data("pllexislider"),i=r.animatingTo;switch(t){case"animate":n.flexAnimate(i,r.vars.pauseOnAction,false,true);break;case"play":if(!n.playing&&!n.asNav){n.play()}break;case"pause":n.pause();break}},pauseInvisible:{visProp:null,init:function(){var e=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var t=0;t<e.length;t++){if(e[t]+"Hidden"in document)v.pauseInvisible.visProp=e[t]+"Hidden"}if(v.pauseInvisible.visProp){var n=v.pauseInvisible.visProp.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(n,function(){if(v.pauseInvisible.isHidden()){if(r.startTimeout)clearTimeout(r.startTimeout);else r.pause()}else{if(r.started)r.play();else r.vars.initDelay>0?setTimeout(r.play,r.vars.initDelay):r.play()}})}},isHidden:function(){return document[v.pauseInvisible.visProp]||false}},setToClearWatchedEvent:function(){clearTimeout(f);f=setTimeout(function(){a=""},3e3)}};r.flexAnimate=function(t,n,s,u,a){if(!r.vars.animationLoop&&t!==r.currentSlide){r.direction=t>r.currentSlide?"next":"prev"}if(d&&r.pagingCount===1)r.direction=r.currentItem<t?"next":"prev";if(!r.animating&&(r.canAdvance(t,a)||s)&&r.is(":visible")){if(d&&u){var f=e(r.vars.asNavFor).data("pllexislider");r.atEnd=t===0||t===r.count-1;f.flexAnimate(t,true,false,true,a);r.direction=r.currentItem<t?"next":"prev";f.direction=r.direction;if(Math.ceil((t+1)/r.visible)-1!==r.currentSlide&&t!==0){r.currentItem=t;r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");t=Math.floor(t/r.visible)}else{r.currentItem=t;r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");return false}}r.animating=true;r.animatingTo=t;if(n)r.pause();r.vars.before(r);if(r.syncExists&&!a)v.sync("animate");if(r.vars.controlNav)v.controlNav.active();if(!h)r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");r.atEnd=t===0||t===r.last;if(r.vars.directionNav)v.directionNav.update();if(t===r.last){r.vars.end(r);if(!r.vars.animationLoop)r.pause()}if(!p){var m=l?r.slides.filter(":first").height():r.computedW,g,y,b;if(h){g=r.vars.itemMargin;b=(r.itemW+g)*r.move*r.animatingTo;y=b>r.limit&&r.visible!==1?r.limit:b}else if(r.currentSlide===0&&t===r.count-1&&r.vars.animationLoop&&r.direction!=="next"){y=c?(r.count+r.cloneOffset)*m:0}else if(r.currentSlide===r.last&&t===0&&r.vars.animationLoop&&r.direction!=="prev"){y=c?0:(r.count+1)*m}else{y=c?(r.count-1-t+r.cloneOffset)*m:(t+r.cloneOffset)*m}r.setProps(y,"",r.vars.animationSpeed);if(r.transitions){if(!r.vars.animationLoop||!r.atEnd){r.animating=false;r.currentSlide=r.animatingTo}r.container.unbind("webkitTransitionEnd transitionend");r.container.bind("webkitTransitionEnd transitionend",function(){r.wrapup(m)})}else{r.container.animate(r.args,r.vars.animationSpeed,r.vars.easing,function(){r.wrapup(m)})}}else{if(!o){r.slides.eq(r.currentSlide).css({zIndex:1}).animate({opacity:0},r.vars.animationSpeed,r.vars.easing);r.slides.eq(t).css({zIndex:2}).animate({opacity:1},r.vars.animationSpeed,r.vars.easing,r.wrapup)}else{r.slides.eq(r.currentSlide).css({opacity:0,zIndex:1});r.slides.eq(t).css({opacity:1,zIndex:2});r.wrapup(m)}}if(r.vars.smoothHeight)v.smoothHeight(r.vars.animationSpeed)}};r.wrapup=function(e){if(!p&&!h){if(r.currentSlide===0&&r.animatingTo===r.last&&r.vars.animationLoop){r.setProps(e,"jumpEnd")}else if(r.currentSlide===r.last&&r.animatingTo===0&&r.vars.animationLoop){r.setProps(e,"jumpStart")}}r.animating=false;r.currentSlide=r.animatingTo;r.vars.after(r)};r.animateSlides=function(){if(!r.animating&&m)r.flexAnimate(r.getTarget("next"))};r.pause=function(){clearInterval(r.animatedSlides);r.animatedSlides=null;r.playing=false;if(r.vars.pausePlay)v.pausePlay.update("play");if(r.syncExists)v.sync("pause")};r.play=function(){if(r.playing)clearInterval(r.animatedSlides);r.animatedSlides=r.animatedSlides||setInterval(r.animateSlides,r.vars.slideshowSpeed);r.started=r.playing=true;if(r.vars.pausePlay)v.pausePlay.update("pause");if(r.syncExists)v.sync("play")};r.stop=function(){r.pause();r.stopped=true};r.canAdvance=function(e,t){var n=d?r.pagingCount-1:r.last;return t?true:d&&r.currentItem===r.count-1&&e===0&&r.direction==="prev"?true:d&&r.currentItem===0&&e===r.pagingCount-1&&r.direction!=="next"?false:e===r.currentSlide&&!d?false:r.vars.animationLoop?true:r.atEnd&&r.currentSlide===0&&e===n&&r.direction!=="next"?false:r.atEnd&&r.currentSlide===n&&e===0&&r.direction==="next"?false:true};r.getTarget=function(e){r.direction=e;if(e==="next"){return r.currentSlide===r.last?0:r.currentSlide+1}else{return r.currentSlide===0?r.last:r.currentSlide-1}};r.setProps=function(e,t,n){var i=function(){var n=e?e:(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo,i=function(){if(h){return t==="setTouch"?e:c&&r.animatingTo===r.last?0:c?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:r.animatingTo===r.last?r.limit:n}else{switch(t){case"setTotal":return c?(r.count-1-r.currentSlide+r.cloneOffset)*e:(r.currentSlide+r.cloneOffset)*e;case"setTouch":return c?e:e;case"jumpEnd":return c?e:r.count*e;case"jumpStart":return c?r.count*e:e;default:return e}}}();return i*-1+"px"}();if(r.transitions){i=l?"translate3d(0,"+i+",0)":"translate3d("+i+",0,0)";n=n!==undefined?n/1e3+"s":"0s";r.container.css("-"+r.pfx+"-transition-duration",n)}r.args[r.prop]=i;if(r.transitions||n===undefined)r.container.css(r.args)};r.setup=function(t){if(!p){var n,s;if(t==="init"){r.viewport=e('<div class="'+i+'viewport"></div>').css({overflow:"hidden",position:"relative"}).appendTo(r).append(r.container);r.cloneCount=0;r.cloneOffset=0;if(c){s=e.makeArray(r.slides).reverse();r.slides=e(s);r.container.empty().append(r.slides)}}if(r.vars.animationLoop&&!h){r.cloneCount=2;r.cloneOffset=1;if(t!=="init")r.container.find(".clone").remove();r.container.append(r.slides.first().clone().addClass("clone").attr("aria-hidden","true")).prepend(r.slides.last().clone().addClass("clone").attr("aria-hidden","true"))}r.newSlides=e(r.vars.selector,r);n=c?r.count-1-r.currentSlide+r.cloneOffset:r.currentSlide+r.cloneOffset;if(l&&!h){r.container.height((r.count+r.cloneCount)*200+"%").css("position","absolute").width("100%");setTimeout(function(){r.newSlides.css({display:"block"});r.doMath();r.viewport.height(r.h);r.setProps(n*r.h,"init")},t==="init"?100:0)}else{r.container.width((r.count+r.cloneCount)*200+"%");r.setProps(n*r.computedW,"init");setTimeout(function(){r.doMath();r.newSlides.css({width:r.computedW,"float":"left",display:"block"});if(r.vars.smoothHeight)v.smoothHeight()},t==="init"?100:0)}}else{r.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"});if(t==="init"){if(!o){r.slides.css({opacity:0,display:"block",zIndex:1}).eq(r.currentSlide).css({zIndex:2}).animate({opacity:1},r.vars.animationSpeed,r.vars.easing)}else{r.slides.css({opacity:0,display:"block",webkitTransition:"opacity "+r.vars.animationSpeed/1e3+"s ease",zIndex:1}).eq(r.currentSlide).css({opacity:1,zIndex:2})}}if(r.vars.smoothHeight)v.smoothHeight()}if(!h)r.slides.removeClass(i+"active-slide").eq(r.currentSlide).addClass(i+"active-slide")};r.doMath=function(){var e=r.slides.first(),t=r.vars.itemMargin,n=r.vars.minItems,i=r.vars.maxItems;r.w=r.viewport===undefined?r.width():r.viewport.width();r.h=e.height();r.boxPadding=e.outerWidth()-e.width();if(h){r.itemT=r.vars.itemWidth+t;r.minW=n?n*r.itemT:r.w;r.maxW=i?i*r.itemT-t:r.w;r.itemW=r.minW>r.w?(r.w-t*(n-1))/n:r.maxW<r.w?(r.w-t*(i-1))/i:r.vars.itemWidth>r.w?r.w:r.vars.itemWidth;r.visible=Math.floor(r.w/r.itemW);r.move=r.vars.move>0&&r.vars.move<r.visible?r.vars.move:r.visible;r.pagingCount=Math.ceil((r.count-r.visible)/r.move+1);r.last=r.pagingCount-1;r.limit=r.pagingCount===1?0:r.vars.itemWidth>r.w?r.itemW*(r.count-1)+t*(r.count-1):(r.itemW+t)*r.count-r.w-t}else{r.itemW=r.w;r.pagingCount=r.count;r.last=r.count-1}r.computedW=r.itemW-r.boxPadding};r.update=function(e,t){r.doMath();if(!h){if(e<r.currentSlide){r.currentSlide+=1}else if(e<=r.currentSlide&&e!==0){r.currentSlide-=1}r.animatingTo=r.currentSlide}if(r.vars.controlNav&&!r.manualControls){if(t==="add"&&!h||r.pagingCount>r.controlNav.length){v.controlNav.update("add")}else if(t==="remove"&&!h||r.pagingCount<r.controlNav.length){if(h&&r.currentSlide>r.last){r.currentSlide-=1;r.animatingTo-=1}v.controlNav.update("remove",r.last)}}if(r.vars.directionNav)v.directionNav.update()};r.addSlide=function(t,n){var i=e(t);r.count+=1;r.last=r.count-1;if(l&&c){n!==undefined?r.slides.eq(r.count-n).after(i):r.container.prepend(i)}else{n!==undefined?r.slides.eq(n).before(i):r.container.append(i)}r.update(n,"add");r.slides=e(r.vars.selector+":not(.clone)",r);r.setup();r.vars.added(r)};r.removeSlide=function(t){var n=isNaN(t)?r.slides.index(e(t)):t;r.count-=1;r.last=r.count-1;if(isNaN(t)){e(t,r.slides).remove()}else{l&&c?r.slides.eq(r.last).remove():r.slides.eq(t).remove()}r.doMath();r.update(n,"remove");r.slides=e(r.vars.selector+":not(.clone)",r);r.setup();r.vars.removed(r)};v.init()};e(window).blur(function(e){focused=false}).focus(function(e){focused=true});e.pllexislider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:false,animationLoop:true,smoothHeight:false,startAt:0,slideshow:true,slideshowSpeed:7e3,animationSpeed:600,initDelay:0,randomize:false,thumbCaptions:false,pauseOnAction:true,pauseOnHover:false,pauseInvisible:true,useCSS:true,touch:true,video:false,controlNav:true,directionNav:true,prevText:"Previous",nextText:"Next",keyboard:true,multipleKeyboard:false,mousewheel:false,pausePlay:false,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:1,maxItems:0,move:0,allowOneSlide:true,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};e.fn.pllexislider=function(t){if(t===undefined)t={};if(typeof t==="object"){return this.each(function(){var n=e(this),r=t.selector?t.selector:".slides > li",i=n.find(r);if(i.length===1&&t.allowOneSlide===true||i.length===0){i.fadeIn(400);if(t.start)t.start(n)}else if(n.data("pllexislider")===undefined){new e.pllexislider(this,t)}})}else{var n=e(this).data("pllexislider");switch(t){case"play":n.play();break;case"pause":n.pause();break;case"stop":n.stop();break;case"next":n.flexAnimate(n.getTarget("next"),true);break;case"prev":case"previous":n.flexAnimate(n.getTarget("prev"),true);break;default:if(typeof t==="number")n.flexAnimate(t,true)}}}})(jQuery)
1
+ /*
2
+ * jQuery FlexSlider v2.2
3
+ * Copyright 2012 WooThemes
4
+ * Contributing Author: Tyler Smith
5
+ */
6
  (function(e){e.pllexislider=function(t,n){var r=e(t);r.vars=e.extend({},e.pllexislider.defaults,n);var i=r.vars.namespace,s=window.navigator&&window.navigator.msPointerEnabled&&window.MSGesture,o=("ontouchstart"in window||s||window.DocumentTouch&&document instanceof DocumentTouch)&&r.vars.touch,u="click touchend MSPointerUp",a="",f,l=r.vars.direction==="vertical",c=r.vars.reverse,h=r.vars.itemWidth>0,p=r.vars.animation==="fade",d=r.vars.asNavFor!=="",v={},m=true;e.data(t,"pllexislider",r);v={init:function(){r.animating=false;r.currentSlide=parseInt(r.vars.startAt?r.vars.startAt:0);if(isNaN(r.currentSlide))r.currentSlide=0;r.animatingTo=r.currentSlide;r.atEnd=r.currentSlide===0||r.currentSlide===r.last;r.containerSelector=r.vars.selector.substr(0,r.vars.selector.search(" "));r.slides=e(r.vars.selector,r);r.container=e(r.containerSelector,r);r.count=r.slides.length;r.syncExists=e(r.vars.sync).length>0;if(r.vars.animation==="slide")r.vars.animation="swing";r.prop=l?"top":"marginLeft";r.args={};r.manualPause=false;r.stopped=false;r.started=false;r.startTimeout=null;r.transitions=!r.vars.video&&!p&&r.vars.useCSS&&function(){var e=document.createElement("div"),t=["perspectiveProperty","WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var n in t){if(e.style[t[n]]!==undefined){r.pfx=t[n].replace("Perspective","").toLowerCase();r.prop="-"+r.pfx+"-transform";return true}}return false}();if(r.vars.controlsContainer!=="")r.controlsContainer=e(r.vars.controlsContainer).length>0&&e(r.vars.controlsContainer);if(r.vars.manualControls!=="")r.manualControls=e(r.vars.manualControls).length>0&&e(r.vars.manualControls);if(r.vars.randomize){r.slides.sort(function(){return Math.round(Math.random())-.5});r.container.empty().append(r.slides)}r.doMath();r.setup("init");if(r.vars.controlNav)v.controlNav.setup();if(r.vars.directionNav)v.directionNav.setup();if(r.vars.keyboard&&(e(r.containerSelector).length===1||r.vars.multipleKeyboard)){e(document).bind("keyup",function(e){var t=e.keyCode;if(!r.animating&&(t===39||t===37)){var n=t===39?r.getTarget("next"):t===37?r.getTarget("prev"):false;r.flexAnimate(n,r.vars.pauseOnAction)}})}if(r.vars.mousewheel){r.bind("mousewheel",function(e,t,n,i){e.preventDefault();var s=t<0?r.getTarget("next"):r.getTarget("prev");r.flexAnimate(s,r.vars.pauseOnAction)})}if(r.vars.pausePlay)v.pausePlay.setup();if(r.vars.slideshow&&r.vars.pauseInvisible)v.pauseInvisible.init();if(r.vars.slideshow){if(r.vars.pauseOnHover){r.hover(function(){if(!r.manualPlay&&!r.manualPause)r.pause()},function(){if(!r.manualPause&&!r.manualPlay&&!r.stopped)r.play()})}if(!r.vars.pauseInvisible||!v.pauseInvisible.isHidden()){r.vars.initDelay>0?r.startTimeout=setTimeout(r.play,r.vars.initDelay):r.play()}}if(d)v.asNav.setup();if(o&&r.vars.touch)v.touch();if(!p||p&&r.vars.smoothHeight)e(window).bind("resize orientationchange focus",v.resize);r.find("img").attr("draggable","false");setTimeout(function(){r.vars.start(r)},200)},asNav:{setup:function(){r.asNav=true;r.animatingTo=Math.floor(r.currentSlide/r.move);r.currentItem=r.currentSlide;r.slides.removeClass(i+"active-slide").eq(r.currentItem).addClass(i+"active-slide");if(!s){r.slides.click(function(t){t.preventDefault();var n=e(this),s=n.index();var o=n.offset().left-e(r).scrollLeft();if(o<=0&&n.hasClass(i+"active-slide")){r.flexAnimate(r.getTarget("prev"),true)}else if(!e(r.vars.asNavFor).data("pllexislider").animating&&!n.hasClass(i+"active-slide")){r.direction=r.currentItem<s?"next":"prev";r.flexAnimate(s,r.vars.pauseOnAction,false,true,true)}})}else{t._slider=r;r.slides.each(function(){var t=this;t._gesture=new MSGesture;t._gesture.target=t;t.addEventListener("MSPointerDown",function(e){e.preventDefault();if(e.currentTarget._gesture)e.currentTarget._gesture.addPointer(e.pointerId)},false);t.addEventListener("MSGestureTap",function(t){t.preventDefault();var n=e(this),i=n.index();if(!e(r.vars.asNavFor).data("pllexislider").animating&&!n.hasClass("active")){r.direction=r.currentItem<i?"next":"prev";r.flexAnimate(i,r.vars.pauseOnAction,false,true,true)}})})}}},controlNav:{setup:function(){if(!r.manualControls){v.controlNav.setupPaging()}else{v.controlNav.setupManual()}},setupPaging:function(){var t=r.vars.controlNav==="thumbnails"?"control-thumbs":"control-paging",n=1,s,o;r.controlNavScaffold=e('<ol class="'+i+"control-nav "+i+t+'"></ol>');if(r.pagingCount>1){for(var f=0;f<r.pagingCount;f++){o=r.slides.eq(f);s=r.vars.controlNav==="thumbnails"?'<img src="'+o.attr("data-thumb")+'"/>':"<a>"+n+"</a>";if("thumbnails"===r.vars.controlNav&&true===r.vars.thumbCaptions){var l=o.attr("data-thumbcaption");if(""!=l&&undefined!=l)s+='<span class="'+i+'caption">'+l+"</span>"}r.controlNavScaffold.append("<li>"+s+"</li>");n++}}r.controlsContainer?e(r.controlsContainer).append(r.controlNavScaffold):r.append(r.controlNavScaffold);v.controlNav.set();v.controlNav.active();r.controlNavScaffold.delegate("a, img",u,function(t){t.preventDefault();if(a===""||a===t.type){var n=e(this),s=r.controlNav.index(n);if(!n.hasClass(i+"active")){r.direction=s>r.currentSlide?"next":"prev";r.flexAnimate(s,r.vars.pauseOnAction)}}if(a===""){a=t.type}v.setToClearWatchedEvent()})},setupManual:function(){r.controlNav=r.manualControls;v.controlNav.active();r.controlNav.bind(u,function(t){t.preventDefault();if(a===""||a===t.type){var n=e(this),s=r.controlNav.index(n);if(!n.hasClass(i+"active")){s>r.currentSlide?r.direction="next":r.direction="prev";r.flexAnimate(s,r.vars.pauseOnAction)}}if(a===""){a=t.type}v.setToClearWatchedEvent()})},set:function(){var t=r.vars.controlNav==="thumbnails"?"img":"a";r.controlNav=e("."+i+"control-nav li "+t,r.controlsContainer?r.controlsContainer:r)},active:function(){r.controlNav.removeClass(i+"active").eq(r.animatingTo).addClass(i+"active")},update:function(t,n){if(r.pagingCount>1&&t==="add"){r.controlNavScaffold.append(e("<li><a>"+r.count+"</a></li>"))}else if(r.pagingCount===1){r.controlNavScaffold.find("li").remove()}else{r.controlNav.eq(n).closest("li").remove()}v.controlNav.set();r.pagingCount>1&&r.pagingCount!==r.controlNav.length?r.update(n,t):v.controlNav.active()}},directionNav:{setup:function(){var t=e('<ul class="'+i+'direction-nav"><li><a class="'+i+'prev" href="#">'+r.vars.prevText+'</a></li><li><a class="'+i+'next" href="#">'+r.vars.nextText+"</a></li></ul>");if(r.controlsContainer){e(r.controlsContainer).append(t);r.directionNav=e("."+i+"direction-nav li a",r.controlsContainer)}else{r.append(t);r.directionNav=e("."+i+"direction-nav li a",r)}v.directionNav.update();r.directionNav.bind(u,function(t){t.preventDefault();var n;if(a===""||a===t.type){n=e(this).hasClass(i+"next")?r.getTarget("next"):r.getTarget("prev");r.flexAnimate(n,r.vars.pauseOnAction)}if(a===""){a=t.type}v.setToClearWatchedEvent()})},update:function(){var e=i+"disabled";if(r.pagingCount===1){r.directionNav.addClass(e).attr("tabindex","-1")}else if(!r.vars.animationLoop){if(r.animatingTo===0){r.directionNav.removeClass(e).filter("."+i+"prev").addClass(e).attr("tabindex","-1")}else if(r.animatingTo===r.last){r.directionNav.removeClass(e).filter("."+i+"next").addClass(e).attr("tabindex","-1")}else{r.directionNav.removeClass(e).removeAttr("tabindex")}}else{r.directionNav.removeClass(e).removeAttr("tabindex")}}},pausePlay:{setup:function(){var t=e('<div class="'+i+'pauseplay"><a></a></div>');if(r.controlsContainer){r.controlsContainer.append(t);r.pausePlay=e("."+i+"pauseplay a",r.controlsContainer)}else{r.append(t);r.pausePlay=e("."+i+"pauseplay a",r)}v.pausePlay.update(r.vars.slideshow?i+"pause":i+"play");r.pausePlay.bind(u,function(t){t.preventDefault();if(a===""||a===t.type){if(e(this).hasClass(i+"pause")){r.manualPause=true;r.manualPlay=false;r.pause()}else{r.manualPause=false;r.manualPlay=true;r.play()}}if(a===""){a=t.type}v.setToClearWatchedEvent()})},update:function(e){e==="play"?r.pausePlay.removeClass(i+"pause").addClass(i+"play").html(r.vars.playText):r.pausePlay.removeClass(i+"play").addClass(i+"pause").html(r.vars.pauseText)}},touch:function(){var e,n,i,o,u,a,f=false,d=0,v=0,m=0;if(!s){t.addEventListener("touchstart",g,false);function g(s){if(r.animating){s.preventDefault()}else if(window.navigator.msPointerEnabled||s.touches.length===1){r.pause();o=l?r.h:r.w;a=Number(new Date);d=s.touches[0].pageX;v=s.touches[0].pageY;i=h&&c&&r.animatingTo===r.last?0:h&&c?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:h&&r.currentSlide===r.last?r.limit:h?(r.itemW+r.vars.itemMargin)*r.move*r.currentSlide:c?(r.last-r.currentSlide+r.cloneOffset)*o:(r.currentSlide+r.cloneOffset)*o;e=l?v:d;n=l?d:v;t.addEventListener("touchmove",y,false);t.addEventListener("touchend",b,false)}}function y(t){d=t.touches[0].pageX;v=t.touches[0].pageY;u=l?e-v:e-d;f=l?Math.abs(u)<Math.abs(d-n):Math.abs(u)<Math.abs(v-n);var s=500;if(!f||Number(new Date)-a>s){t.preventDefault();if(!p&&r.transitions){if(!r.vars.animationLoop){u=u/(r.currentSlide===0&&u<0||r.currentSlide===r.last&&u>0?Math.abs(u)/o+2:1)}r.setProps(i+u,"setTouch")}}}function b(s){t.removeEventListener("touchmove",y,false);if(r.animatingTo===r.currentSlide&&!f&&!(u===null)){var l=c?-u:u,h=l>0?r.getTarget("next"):r.getTarget("prev");if(r.canAdvance(h)&&(Number(new Date)-a<550&&Math.abs(l)>50||Math.abs(l)>o/2)){r.flexAnimate(h,r.vars.pauseOnAction)}else{if(!p)r.flexAnimate(r.currentSlide,r.vars.pauseOnAction,true)}}t.removeEventListener("touchend",b,false);e=null;n=null;u=null;i=null}}else{t.style.msTouchAction="none";t._gesture=new MSGesture;t._gesture.target=t;t.addEventListener("MSPointerDown",w,false);t._slider=r;t.addEventListener("MSGestureChange",E,false);t.addEventListener("MSGestureEnd",S,false);function w(e){e.stopPropagation();if(r.animating){e.preventDefault()}else{r.pause();t._gesture.addPointer(e.pointerId);m=0;o=l?r.h:r.w;a=Number(new Date);i=h&&c&&r.animatingTo===r.last?0:h&&c?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:h&&r.currentSlide===r.last?r.limit:h?(r.itemW+r.vars.itemMargin)*r.move*r.currentSlide:c?(r.last-r.currentSlide+r.cloneOffset)*o:(r.currentSlide+r.cloneOffset)*o}}function E(e){e.stopPropagation();var n=e.target._slider;if(!n){return}var r=-e.translationX,s=-e.translationY;m=m+(l?s:r);u=m;f=l?Math.abs(m)<Math.abs(-r):Math.abs(m)<Math.abs(-s);if(e.detail===e.MSGESTURE_FLAG_INERTIA){setImmediate(function(){t._gesture.stop()});return}if(!f||Number(new Date)-a>500){e.preventDefault();if(!p&&n.transitions){if(!n.vars.animationLoop){u=m/(n.currentSlide===0&&m<0||n.currentSlide===n.last&&m>0?Math.abs(m)/o+2:1)}n.setProps(i+u,"setTouch")}}}function S(t){t.stopPropagation();var r=t.target._slider;if(!r){return}if(r.animatingTo===r.currentSlide&&!f&&!(u===null)){var s=c?-u:u,l=s>0?r.getTarget("next"):r.getTarget("prev");if(r.canAdvance(l)&&(Number(new Date)-a<550&&Math.abs(s)>50||Math.abs(s)>o/2)){r.flexAnimate(l,r.vars.pauseOnAction)}else{if(!p)r.flexAnimate(r.currentSlide,r.vars.pauseOnAction,true)}}e=null;n=null;u=null;i=null;m=0}}},resize:function(){if(!r.animating&&r.is(":visible")){if(!h)r.doMath();if(p){v.smoothHeight()}else if(h){r.slides.width(r.computedW);r.update(r.pagingCount);r.setProps()}else if(l){r.viewport.height(r.h);r.setProps(r.h,"setTotal")}else{if(r.vars.smoothHeight)v.smoothHeight();r.newSlides.width(r.computedW);r.setProps(r.computedW,"setTotal")}}},smoothHeight:function(e){if(!l||p){var t=p?r:r.viewport;e?t.animate({height:r.slides.eq(r.animatingTo).height()},e):t.height(r.slides.eq(r.animatingTo).height())}},sync:function(t){var n=e(r.vars.sync).data("pllexislider"),i=r.animatingTo;switch(t){case"animate":n.flexAnimate(i,r.vars.pauseOnAction,false,true);break;case"play":if(!n.playing&&!n.asNav){n.play()}break;case"pause":n.pause();break}},pauseInvisible:{visProp:null,init:function(){var e=["webkit","moz","ms","o"];if("hidden"in document)return"hidden";for(var t=0;t<e.length;t++){if(e[t]+"Hidden"in document)v.pauseInvisible.visProp=e[t]+"Hidden"}if(v.pauseInvisible.visProp){var n=v.pauseInvisible.visProp.replace(/[H|h]idden/,"")+"visibilitychange";document.addEventListener(n,function(){if(v.pauseInvisible.isHidden()){if(r.startTimeout)clearTimeout(r.startTimeout);else r.pause()}else{if(r.started)r.play();else r.vars.initDelay>0?setTimeout(r.play,r.vars.initDelay):r.play()}})}},isHidden:function(){return document[v.pauseInvisible.visProp]||false}},setToClearWatchedEvent:function(){clearTimeout(f);f=setTimeout(function(){a=""},3e3)}};r.flexAnimate=function(t,n,s,u,a){if(!r.vars.animationLoop&&t!==r.currentSlide){r.direction=t>r.currentSlide?"next":"prev"}if(d&&r.pagingCount===1)r.direction=r.currentItem<t?"next":"prev";if(!r.animating&&(r.canAdvance(t,a)||s)&&r.is(":visible")){if(d&&u){var f=e(r.vars.asNavFor).data("pllexislider");r.atEnd=t===0||t===r.count-1;f.flexAnimate(t,true,false,true,a);r.direction=r.currentItem<t?"next":"prev";f.direction=r.direction;if(Math.ceil((t+1)/r.visible)-1!==r.currentSlide&&t!==0){r.currentItem=t;r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");t=Math.floor(t/r.visible)}else{r.currentItem=t;r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");return false}}r.animating=true;r.animatingTo=t;if(n)r.pause();r.vars.before(r);if(r.syncExists&&!a)v.sync("animate");if(r.vars.controlNav)v.controlNav.active();if(!h)r.slides.removeClass(i+"active-slide").eq(t).addClass(i+"active-slide");r.atEnd=t===0||t===r.last;if(r.vars.directionNav)v.directionNav.update();if(t===r.last){r.vars.end(r);if(!r.vars.animationLoop)r.pause()}if(!p){var m=l?r.slides.filter(":first").height():r.computedW,g,y,b;if(h){g=r.vars.itemMargin;b=(r.itemW+g)*r.move*r.animatingTo;y=b>r.limit&&r.visible!==1?r.limit:b}else if(r.currentSlide===0&&t===r.count-1&&r.vars.animationLoop&&r.direction!=="next"){y=c?(r.count+r.cloneOffset)*m:0}else if(r.currentSlide===r.last&&t===0&&r.vars.animationLoop&&r.direction!=="prev"){y=c?0:(r.count+1)*m}else{y=c?(r.count-1-t+r.cloneOffset)*m:(t+r.cloneOffset)*m}r.setProps(y,"",r.vars.animationSpeed);if(r.transitions){if(!r.vars.animationLoop||!r.atEnd){r.animating=false;r.currentSlide=r.animatingTo}r.container.unbind("webkitTransitionEnd transitionend");r.container.bind("webkitTransitionEnd transitionend",function(){r.wrapup(m)})}else{r.container.animate(r.args,r.vars.animationSpeed,r.vars.easing,function(){r.wrapup(m)})}}else{if(!o){r.slides.eq(r.currentSlide).css({zIndex:1}).animate({opacity:0},r.vars.animationSpeed,r.vars.easing);r.slides.eq(t).css({zIndex:2}).animate({opacity:1},r.vars.animationSpeed,r.vars.easing,r.wrapup)}else{r.slides.eq(r.currentSlide).css({opacity:0,zIndex:1});r.slides.eq(t).css({opacity:1,zIndex:2});r.wrapup(m)}}if(r.vars.smoothHeight)v.smoothHeight(r.vars.animationSpeed)}};r.wrapup=function(e){if(!p&&!h){if(r.currentSlide===0&&r.animatingTo===r.last&&r.vars.animationLoop){r.setProps(e,"jumpEnd")}else if(r.currentSlide===r.last&&r.animatingTo===0&&r.vars.animationLoop){r.setProps(e,"jumpStart")}}r.animating=false;r.currentSlide=r.animatingTo;r.vars.after(r)};r.animateSlides=function(){if(!r.animating&&m)r.flexAnimate(r.getTarget("next"))};r.pause=function(){clearInterval(r.animatedSlides);r.animatedSlides=null;r.playing=false;if(r.vars.pausePlay)v.pausePlay.update("play");if(r.syncExists)v.sync("pause")};r.play=function(){if(r.playing)clearInterval(r.animatedSlides);r.animatedSlides=r.animatedSlides||setInterval(r.animateSlides,r.vars.slideshowSpeed);r.started=r.playing=true;if(r.vars.pausePlay)v.pausePlay.update("pause");if(r.syncExists)v.sync("play")};r.stop=function(){r.pause();r.stopped=true};r.canAdvance=function(e,t){var n=d?r.pagingCount-1:r.last;return t?true:d&&r.currentItem===r.count-1&&e===0&&r.direction==="prev"?true:d&&r.currentItem===0&&e===r.pagingCount-1&&r.direction!=="next"?false:e===r.currentSlide&&!d?false:r.vars.animationLoop?true:r.atEnd&&r.currentSlide===0&&e===n&&r.direction!=="next"?false:r.atEnd&&r.currentSlide===n&&e===0&&r.direction==="next"?false:true};r.getTarget=function(e){r.direction=e;if(e==="next"){return r.currentSlide===r.last?0:r.currentSlide+1}else{return r.currentSlide===0?r.last:r.currentSlide-1}};r.setProps=function(e,t,n){var i=function(){var n=e?e:(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo,i=function(){if(h){return t==="setTouch"?e:c&&r.animatingTo===r.last?0:c?r.limit-(r.itemW+r.vars.itemMargin)*r.move*r.animatingTo:r.animatingTo===r.last?r.limit:n}else{switch(t){case"setTotal":return c?(r.count-1-r.currentSlide+r.cloneOffset)*e:(r.currentSlide+r.cloneOffset)*e;case"setTouch":return c?e:e;case"jumpEnd":return c?e:r.count*e;case"jumpStart":return c?r.count*e:e;default:return e}}}();return i*-1+"px"}();if(r.transitions){i=l?"translate3d(0,"+i+",0)":"translate3d("+i+",0,0)";n=n!==undefined?n/1e3+"s":"0s";r.container.css("-"+r.pfx+"-transition-duration",n)}r.args[r.prop]=i;if(r.transitions||n===undefined)r.container.css(r.args)};r.setup=function(t){if(!p){var n,s;if(t==="init"){r.viewport=e('<div class="'+i+'viewport"></div>').css({overflow:"hidden",position:"relative"}).appendTo(r).append(r.container);r.cloneCount=0;r.cloneOffset=0;if(c){s=e.makeArray(r.slides).reverse();r.slides=e(s);r.container.empty().append(r.slides)}}if(r.vars.animationLoop&&!h){r.cloneCount=2;r.cloneOffset=1;if(t!=="init")r.container.find(".clone").remove();r.container.append(r.slides.first().clone().addClass("clone").attr("aria-hidden","true")).prepend(r.slides.last().clone().addClass("clone").attr("aria-hidden","true"))}r.newSlides=e(r.vars.selector,r);n=c?r.count-1-r.currentSlide+r.cloneOffset:r.currentSlide+r.cloneOffset;if(l&&!h){r.container.height((r.count+r.cloneCount)*200+"%").css("position","absolute").width("100%");setTimeout(function(){r.newSlides.css({display:"block"});r.doMath();r.viewport.height(r.h);r.setProps(n*r.h,"init")},t==="init"?100:0)}else{r.container.width((r.count+r.cloneCount)*200+"%");r.setProps(n*r.computedW,"init");setTimeout(function(){r.doMath();r.newSlides.css({width:r.computedW,"float":"left",display:"block"});if(r.vars.smoothHeight)v.smoothHeight()},t==="init"?100:0)}}else{r.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"});if(t==="init"){if(!o){r.slides.css({opacity:0,display:"block",zIndex:1}).eq(r.currentSlide).css({zIndex:2}).animate({opacity:1},r.vars.animationSpeed,r.vars.easing)}else{r.slides.css({opacity:0,display:"block",webkitTransition:"opacity "+r.vars.animationSpeed/1e3+"s ease",zIndex:1}).eq(r.currentSlide).css({opacity:1,zIndex:2})}}if(r.vars.smoothHeight)v.smoothHeight()}if(!h)r.slides.removeClass(i+"active-slide").eq(r.currentSlide).addClass(i+"active-slide")};r.doMath=function(){var e=r.slides.first(),t=r.vars.itemMargin,n=r.vars.minItems,i=r.vars.maxItems;r.w=r.viewport===undefined?r.width():r.viewport.width();r.h=e.height();r.boxPadding=e.outerWidth()-e.width();if(h){r.itemT=r.vars.itemWidth+t;r.minW=n?n*r.itemT:r.w;r.maxW=i?i*r.itemT-t:r.w;r.itemW=r.minW>r.w?(r.w-t*(n-1))/n:r.maxW<r.w?(r.w-t*(i-1))/i:r.vars.itemWidth>r.w?r.w:r.vars.itemWidth;r.visible=Math.floor(r.w/r.itemW);r.move=r.vars.move>0&&r.vars.move<r.visible?r.vars.move:r.visible;r.pagingCount=Math.ceil((r.count-r.visible)/r.move+1);r.last=r.pagingCount-1;r.limit=r.pagingCount===1?0:r.vars.itemWidth>r.w?r.itemW*(r.count-1)+t*(r.count-1):(r.itemW+t)*r.count-r.w-t}else{r.itemW=r.w;r.pagingCount=r.count;r.last=r.count-1}r.computedW=r.itemW-r.boxPadding};r.update=function(e,t){r.doMath();if(!h){if(e<r.currentSlide){r.currentSlide+=1}else if(e<=r.currentSlide&&e!==0){r.currentSlide-=1}r.animatingTo=r.currentSlide}if(r.vars.controlNav&&!r.manualControls){if(t==="add"&&!h||r.pagingCount>r.controlNav.length){v.controlNav.update("add")}else if(t==="remove"&&!h||r.pagingCount<r.controlNav.length){if(h&&r.currentSlide>r.last){r.currentSlide-=1;r.animatingTo-=1}v.controlNav.update("remove",r.last)}}if(r.vars.directionNav)v.directionNav.update()};r.addSlide=function(t,n){var i=e(t);r.count+=1;r.last=r.count-1;if(l&&c){n!==undefined?r.slides.eq(r.count-n).after(i):r.container.prepend(i)}else{n!==undefined?r.slides.eq(n).before(i):r.container.append(i)}r.update(n,"add");r.slides=e(r.vars.selector+":not(.clone)",r);r.setup();r.vars.added(r)};r.removeSlide=function(t){var n=isNaN(t)?r.slides.index(e(t)):t;r.count-=1;r.last=r.count-1;if(isNaN(t)){e(t,r.slides).remove()}else{l&&c?r.slides.eq(r.last).remove():r.slides.eq(t).remove()}r.doMath();r.update(n,"remove");r.slides=e(r.vars.selector+":not(.clone)",r);r.setup();r.vars.removed(r)};v.init()};e(window).blur(function(e){focused=false}).focus(function(e){focused=true});e.pllexislider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:false,animationLoop:true,smoothHeight:false,startAt:0,slideshow:true,slideshowSpeed:7e3,animationSpeed:600,initDelay:0,randomize:false,thumbCaptions:false,pauseOnAction:true,pauseOnHover:false,pauseInvisible:true,useCSS:true,touch:true,video:false,controlNav:true,directionNav:true,prevText:"Previous",nextText:"Next",keyboard:true,multipleKeyboard:false,mousewheel:false,pausePlay:false,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:1,maxItems:0,move:0,allowOneSlide:true,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};e.fn.pllexislider=function(t){if(t===undefined)t={};if(typeof t==="object"){return this.each(function(){var n=e(this),r=t.selector?t.selector:".slides > li",i=n.find(r);if(i.length===1&&t.allowOneSlide===true||i.length===0){i.fadeIn(400);if(t.start)t.start(n)}else if(n.data("pllexislider")===undefined){new e.pllexislider(this,t)}})}else{var n=e(this).data("pllexislider");switch(t){case"play":n.play();break;case"pause":n.pause();break;case"stop":n.stop();break;case"next":n.flexAnimate(n.getTarget("next"),true);break;case"prev":case"previous":n.flexAnimate(n.getTarget("prev"),true);break;default:if(typeof t==="number")n.flexAnimate(t,true)}}}})(jQuery)
readme.txt CHANGED
@@ -1,28 +1,41 @@
1
- === Instagram Slider Widget ===
2
- Contributors: jetonr
3
- Tags: instagram, slider, widget, images
4
- Donate link: http://goo.gl/RZiu34
5
- Requires at least: 3.5
6
- Tested up to: 3.8.1
7
- License: GPLv2 or later
8
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
-
10
- Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
11
-
12
- == Description ==
13
- Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user. The images are download into your upload folder. The widget can display images in slider and thumbnails.
14
-
15
- == Installation ==
16
- 1. Upload `instagram-slider-widget` to the `/wp-content/plugins/` directory
17
- 2. Activate the plugin through the \'Plugins\' menu in WordPress
18
- 3. Go to Appearance > Widgets and drag \'Instagram Slider Widget\' to your sidebar
19
- 4. Update the settings in the widget: Instagram Username, Images Layout, Number of Images to show, Check for new images hours
20
-
21
- == Screenshots ==
22
- 1. Frontend Widget Slider
23
- 2. Frontend Widget Thumbs
24
- 3. Backend Configuration
25
-
26
- == Changelog ==
27
- = 1.0 =
28
- First Realease
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Instagram Slider Widget ===
2
+ Contributors: jetonr
3
+ Tags: instagram, slider, widget, images
4
+ Donate link: http://goo.gl/RZiu34
5
+ Requires at least: 3.5
6
+ Tested up to: 3.8.1
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
11
+
12
+ == Description ==
13
+ * Instagram Slider Widget is a responsive slider widget that shows 20 latest images from a public instagram user.
14
+ = Features =
15
+ * Images are stored in your wordpress upload folder.
16
+ * Display Images in Slider or Thumbnails
17
+ * No Api Key Needed
18
+ * For more info visit http://jrwebstudio.com/
19
+
20
+ == Installation ==
21
+ 1. Upload `instagram-slider-widget` to the `/wp-content/plugins/` directory
22
+ 2. Activate the plugin through the \'Plugins\' menu in WordPress
23
+ 3. Go to Appearance > Widgets and drag \'Instagram Slider Widget\' to your sidebar
24
+ 4. Update the settings in the widget: Instagram Username, Images Layout, Number of Images to show, Check for new images hours
25
+
26
+ == Screenshots ==
27
+ 1. Frontend Widget Slider
28
+ 2. Frontend Widget Thumbs
29
+ 3. Backend Configuration
30
+
31
+ == Changelog ==
32
+ = 1.0.1 =
33
+ * Removed preg_match
34
+ * Using exact array index
35
+ * Bug Fixes
36
+
37
+ = 1.0 =
38
+ * First Realease
39
+
40
+ == Rate the Plugin ==
41
+ * If you liked this plugin. Please rate it
templates/slider.php CHANGED
@@ -1,34 +1,34 @@
1
- <script type="text/javascript">
2
- jQuery(document).ready(function($) {
3
- $('.pllexislider').pllexislider({
4
- animation: "slide",
5
- directionNav: false,
6
- });
7
- });
8
- </script>
9
- <div class="pllexislider">
10
- <ul class="no-bullet slides">
11
- <?php
12
- if ( isset($data_arr) && is_array($data_arr) ) {
13
- foreach ($data_arr as $data) {
14
- foreach ( $data as $k => $v) {
15
- $$k = $v;
16
- }
17
- echo '<li>'. "\n";
18
- echo '<a target="_blank" href="'.$link.'"><img src="'.$image.'" alt="'.$text.'"></a>' . "\n";
19
- if ( $created_time ) {
20
- echo '<div class="instatime">'. human_time_diff( $created_time ) . ' ago</div>' . "\n";
21
- }
22
- echo '<div class="instadescription">' . "\n";
23
- echo '<p>by <a href="'. $user_url .'">'. $user_name .'</a></p>' . "\n";
24
- if ($text) {
25
- echo '<p>'.$text.'</p>' . "\n";
26
- }
27
- echo '</div>' . "\n";
28
- echo '</li>' . "\n";
29
-
30
- }
31
- }
32
- ?>
33
- </ul>
34
- </div>
1
+ <script type="text/javascript">
2
+ jQuery(document).ready(function($) {
3
+ $('.pllexislider').pllexislider({
4
+ animation: "slide",
5
+ directionNav: false,
6
+ });
7
+ });
8
+ </script>
9
+ <div class="pllexislider">
10
+ <ul class="no-bullet slides">
11
+ <?php
12
+ if ( isset($data_arr) && is_array($data_arr) ) {
13
+ foreach ($data_arr as $data) {
14
+ foreach ( $data as $k => $v) {
15
+ $$k = $v;
16
+ }
17
+ echo '<li>'. "\n";
18
+ echo '<a target="_blank" href="'.$link.'"><img src="'.$image.'" alt="'.$text.'"></a>' . "\n";
19
+ if ( $created_time ) {
20
+ echo '<div class="instatime">'. human_time_diff( $created_time ) . ' ago</div>' . "\n";
21
+ }
22
+ echo '<div class="instadescription">' . "\n";
23
+ echo '<p>by <a href="'. $user_url .'">'. $user_name .'</a></p>' . "\n";
24
+ if ($text) {
25
+ echo '<p>'.$text.'</p>' . "\n";
26
+ }
27
+ echo '</div>' . "\n";
28
+ echo '</li>' . "\n";
29
+
30
+ }
31
+ }
32
+ ?>
33
+ </ul>
34
+ </div>
templates/thumbs.php CHANGED
@@ -1,17 +1,17 @@
1
-
2
- <div class="instag">
3
- <ul class="thumbnails no-bullet">
4
- <?php
5
- if ( isset($data_arr) && is_array($data_arr) ) {
6
- foreach ($data_arr as $data) {
7
- foreach ( $data as $k => $v) {
8
- $$k = $v;
9
- }
10
- echo '<li>'. "\n";
11
- echo '<a target="_blank" href="'.$link.'"><img src="'.$image.'" alt="'.$text.'"></a>' . "\n";
12
- echo '</li>' . "\n";
13
- }
14
- }
15
- ?>
16
- </ul>
17
  </div>
1
+
2
+ <div class="instag">
3
+ <ul class="thumbnails no-bullet">
4
+ <?php
5
+ if ( isset($data_arr) && is_array($data_arr) ) {
6
+ foreach ($data_arr as $data) {
7
+ foreach ( $data as $k => $v) {
8
+ $$k = $v;
9
+ }
10
+ echo '<li>'. "\n";
11
+ echo '<a target="_blank" href="'.$link.'"><img src="'.$image.'" alt="'.$text.'"></a>' . "\n";
12
+ echo '</li>' . "\n";
13
+ }
14
+ }
15
+ ?>
16
+ </ul>
17
  </div>