WD Instagram Feed – Instagram Gallery - Version 1.2.0

Version Description

New: Default feed Fixed: Infinite scroll triggering (PRO) Fixed: "No media in feed" message on mobile masonry feed Fixed: Minor style conflicts with some themes

Download this release

Release Info

Developer webdorado
Plugin Icon 128x128 WD Instagram Feed – Instagram Gallery
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.30 to 1.2.0

admin-functions.php CHANGED
@@ -1,112 +1,108 @@
1
- <?php
2
  /**
3
- * Checks if username and access_token exist, if not redirects to settings page
4
- */
5
 
6
- function wdi_check_necessary_params(){
7
- global $wdi_options;
8
- if(!isset($wdi_options['wdi_access_token']) || !isset($wdi_options['wdi_user_name']) || $wdi_options['wdi_access_token']=='' || $wdi_options['wdi_user_name'] ==''){
9
- ?>
10
- <script>
11
- window.location = "<?php echo admin_url( 'admin.php?page=wdi_settings');?>";
12
- </script>
13
- <?php
14
- }
15
-
16
- }
17
-
18
- function wdi_get_create_feeds_cap(){
19
  global $wdi_options;
20
- $min_feeds_capability = isset($wdi_options['wdi_feeds_min_capability']) ? $wdi_options['wdi_feeds_min_capability'] : "manage_options";
21
- $min_feeds_capability = $min_feeds_capability == 'publish_posts' ? 'publish_posts' : "manage_options";
 
 
 
 
 
22
 
23
- return $min_feeds_capability;
24
  }
25
 
26
 
27
-
28
  /**
29
- * checks if argument is 1 it displays success message on settings page after uninstalling plugin
30
- * else it displays error message already uninstalled
31
- */
32
 
33
- function wdi_uninstall_notice($arg) {
34
- if($arg == 1){
 
35
  ?>
36
  <div class="updated">
37
- <p><?php _e( 'Succesfully Uninstalled!', "wd-instagram-feed"); ?></p>
38
  </div>
39
  <?php
40
- }else{
41
- ?>
42
- <div class="error">
43
- <p><?php _e( 'Already Unistalled', "wd-instagram-feed"); ?></p>
44
- </div>
 
45
  <?php
46
  }
47
  }
48
 
49
  /**
50
- * checks if plugin is uninstalled it displays to all users uninstalled screen
51
- */
52
- function wdi_check_uninstalled(){
53
- global $wdi_options;
54
- if(isset($wdi_options['wdi_plugin_uninstalled']) && $wdi_options['wdi_plugin_uninstalled']=='true') {
 
55
  require_once(WDI_DIR . '/templates/plugin-uninstalled.php');
56
  die();
57
  };
58
  }
59
 
60
  /**
61
- * triggered on plugin activation
62
- *
63
- * adds some plugin related options like plugin version and database version
64
- * also adds uninstalled option
65
- * after adding this basic options,creates tables for plugin in wordpress database
66
- */
67
 
68
- function wdi_install(){
 
69
 
70
 
71
- wdi_get_options();
72
- global $wdi_options;
73
 
74
- // if(isset($wdi_options['wdi_plugin_uninstalled']) && $wdi_options['wdi_plugin_uninstalled'] == 'false'){
75
- // return;
76
- // }
77
- $current_version = WDI_VERSION;
78
- $saved_version = get_option('wdi_version');
79
- if( $saved_version){
80
-
81
- if(substr($saved_version, 0, 1) =='2' && substr($current_version, 0, 1) == '1'){
82
  wdi_set_options_defaults();
83
  return;
84
- }
85
-
86
- $old_version = substr($saved_version, 2);
87
- $new_version = substr(WDI_VERSION, 2);
88
- $newer = version_compare($new_version, $old_version, '>');
89
-
90
- if($newer){
91
- require_once WDI_DIR . '/update/wdi_update.php';
92
- /*adds new params for new versions*/
93
- wdi_update_diff($new_version, $old_version);
94
-
95
- if(!update_option('wdi_version',WDI_VERSION )){
96
- add_option('wdi_version', WDI_VERSION);
97
- }
98
  }
99
- wdi_set_options_defaults();
100
- return;
 
101
 
102
- }
103
 
104
 
105
  wdi_set_options_defaults();
106
  //add_option( WDI_VAR.'_version',$version, '', 'yes' );
107
- // update_option( WDI_VAR.'_version',$version, '', 'yes' );
 
108
 
109
-
110
  global $wpdb;
111
  $table_name = $wpdb->prefix . WDI_FEED_TABLE;
112
  $charset_collate = 'COLLATE utf8_general_ci';
@@ -180,12 +176,12 @@ function wdi_install(){
180
 
181
  UNIQUE KEY id (id)
182
  ) $charset_collate;";
183
-
184
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
185
  //table is not created. you may create the table here.
186
- $wpdb->query($sql);
187
  }
188
-
189
  //dbDelta( $sql );
190
  $charset_collate2 = 'COLLATE latin1_general_ci';
191
  $table_name = $wpdb->prefix . WDI_THEME_TABLE;
@@ -445,78 +441,121 @@ function wdi_install(){
445
 
446
  UNIQUE KEY id (id)
447
  ) $charset_collate2;";
448
- // dbDelta( $sql );
449
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
450
  //table is not created. you may create the table here.
451
- $wpdb->query($sql);
452
- wdi_install_default_themes();
453
  }
454
-
455
- if(!update_option('wdi_version',WDI_VERSION )){
456
  add_option('wdi_version', WDI_VERSION);
457
  }
458
 
459
- /**
460
- * add api update notice
461
- * @since 1.1.0
462
- */
463
-
464
  $admin_notices_option = get_option('wdi_admin_notice', array());
465
  $admin_notices_option['api_update_token_reset'] = array(
466
- 'start' => current_time("n/j/Y"),
467
- 'int' => 0,
468
- 'dismissed' => 1, // dismissed on activate
469
- );
470
  update_option('wdi_admin_notice', $admin_notices_option);
471
 
472
 
473
-
474
  }
475
 
476
  //Callback function for Settings Configure Section
477
  function wdi_configure_section_callback(){
478
  $new_url = urlencode(admin_url('admin.php?page=wdi_settings')) . '&response_type=token';
479
- ?>
480
- <div id="login_with_instagram">
481
- <a onclick="document.cookie = 'wdi_autofill=true'" href="https://api.instagram.com/oauth/authorize/?client_id=54da896cf80343ecb0e356ac5479d9ec&scope=basic+public_content&redirect_uri=http://api.web-dorado.com/instagram/?return_url=<?php echo $new_url;?>" style="display:inline-block;"><img src="<?php echo plugins_url('/images/sign_in_with_instagram.png',__FILE__)?>" alt=""></a>
482
- </div>
483
- <div class="wdi_access_token_missing"><?php
484
- $options = get_option(WDI_OPT);
485
- if(!isset($options['wdi_access_token']) || $options['wdi_access_token'] == '' || !isset($options['wdi_user_name']) || $options['wdi_user_name'] == '')
486
- _e('You need Access Token for using Instagram API. Click sign in with Instagram button above to get yours. This will not show your Instagram media. After that you may create feed with desired user or hashtag media.', "wd-instagram-feed");
487
- ?></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
  <?php
 
 
 
 
 
 
489
  }
490
 
 
491
  //Callback function for Settings Customize Section
492
- function wdi_customize_section_callback(){
493
-
 
494
  }
495
 
496
  //Settings field callback:
497
  //receives settings element as parameter and checks it's type and displays proper form element
498
- function wdi_field_callback($element){
 
499
  $setting = $element[0];
500
  $wdi_formBuilder = new WDI_admin_view();
501
- switch($setting['type'])
502
- {
503
- case 'input':{
504
  $wdi_formBuilder->input($setting);
505
  break;
506
  }
507
- case 'checkbox':{
508
  $wdi_formBuilder->checkbox($setting);
509
  break;
510
  }
511
- case 'color':{
512
  $wdi_formBuilder->color($setting);
513
  break;
514
  }
515
- case 'textarea':{
516
  $wdi_formBuilder->textarea($setting);
517
  break;
518
  }
519
- case 'select':{
520
  $wdi_formBuilder->select($setting);
521
  break;
522
  }
@@ -524,112 +563,123 @@ function wdi_field_callback($element){
524
  }
525
 
526
  //Validatates input form submit forms
527
- function wdi_validate_options($input){
 
528
  global $wdi_options;
529
- foreach( $input as $key => $value ) {
530
- if( isset( $input[$key] ) ) {
531
- $wdi_options[$key] = strip_tags( stripslashes( $input[ $key ] ) );
532
- }
533
- }
534
 
535
- return apply_filters( 'wdi_validate_options', $wdi_options, $input );
536
  }
537
 
538
- function wdi_sanitize_options($input){
 
539
  $output = array();
540
  $elements = wdi_get_settings();
541
- foreach( $input as $key => $value ) {
542
- switch($elements[$key]['sanitize_type']){
543
- case 'text':{
544
- if( isset( $input[$key] ) ) {
545
- $output[$key] = strip_tags( stripslashes( $input[ $key ] ) );
546
- }
547
- break;
548
- }
549
- case 'css':{
550
- $output[$key] = esc_js( str_replace(array("\n", "\r"), "",$input[ $key ]) );
551
- break;
552
- }
553
- default:{
554
- if( isset( $input[$key] ) ) {
555
- $output[$key] = strip_tags( stripslashes( $input[ $key ] ) );
556
- }
557
- break;
558
- }
559
  }
560
- }
561
- return apply_filters( 'wdi_sanitize_options', $output, $input );
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  }
 
563
  //Sets all settings for admin pages and returns associative array of settings
564
- function wdi_get_settings(){
 
565
  $settings = array(
566
- 'wdi_access_token' => array('name' => 'wdi_access_token','sanitize_type'=>'text', 'required' =>'required','input_size'=>'55','type'=>'input','readonly'=>'readonly','default'=>'','field_or_not'=>'field','section'=>'wdi_configure_section','title'=>__('Access Token',"wd-instagram-feed")),
567
- 'wdi_user_name' => array('name' => 'wdi_user_name','sanitize_type'=>'text','required' =>'required','type'=>'input','section'=>'wdi_configure_section','readonly'=>'readonly','field_or_not'=>'field','default'=>'','title'=>__('Username',"wd-instagram-feed")),
568
- 'wdi_feeds_min_capability' => array('name'=>'wdi_feeds_min_capability',"sanitize_type"=> "text",'title'=>__('Minimal role to add and manage Feeds or Themes',"wd-instagram-feed"),'type'=>'select','field_or_not'=>'field',"default"=>"manage_options",'section'=>'wdi_configure_section','valid_options'=>array('manage_options'=>__('Administrator', 'wd-instagram-feed'),'publish_posts'=>__('Author', 'wd-instagram-feed'))),
569
-
570
- 'wdi_user_id' => array('name' => 'wdi_user_id','sanitize_type'=>'text','type'=>'input','section'=>'wdi_configure_section','readonly'=>'readonly','default'=>'','field_or_not'=>'no_field'),
571
- 'wdi_custom_css'=>array('name'=>'wdi_custom_css','sanitize_type'=>'css','type'=>'textarea','section'=>'wdi_customize_section','field_or_not'=>'field','default'=>'','title'=>__('Custom CSS',"wd-instagram-feed")),
572
- //'wdi_preserve_settings_when_remove'=>array('name'=>'wdi_preserve_settings_when_remove','field_or_not'=>'field','type'=>'checkbox','default'=>'1', 'section'=>'wdi_configure_section','title'=>__('Preserve Settings When Remove',"wd-instagram-feed")),
573
- 'wdi_plugin_uninstalled' => array('name'=>'wdi_plugin_uninstalled','sanitize_type'=>'bool','field_or_not'=>'field','type'=>'input','input_type'=>'hidden','section'=>'wdi_customize_section','title'=>'','default'=>'false','value'=>'false'),
574
- //'wdi_version' => array('name'=>'wdi_version','field_or_not'=>'no_field','default'=>WDI_VERSION),
575
- //'wdi_first_time'=>array('name'=>'wdi_first_time','field_or_not'=>'no_field','default'=>'1')
576
- 'wdi_custom_js'=>array('name'=>'wdi_custom_js','sanitize_type'=>'css','type'=>'textarea','section'=>'wdi_customize_section','field_or_not'=>'field','default'=>'','title'=>__('Custom JavaScript',"wd-instagram-feed")),
577
- );
578
  return $settings;
579
  }
580
 
581
  //Sets plugin default settings
582
- function wdi_set_options_defaults(){
 
583
  $db_options = array();
584
  $options = get_option(WDI_OPT);
585
-
586
-
587
-
588
 
589
  $settings = wdi_get_settings();
590
  foreach ($settings as $setting) {
591
- $settingDefault = isset($setting['default'])? $setting['default'] : '';
592
- $db_options[$setting['name']]=$setting['default'];
593
  }
594
 
595
 
596
- $options = wp_parse_args( $options, $db_options );
597
- if(isset($options['wdi_plugin_uninstalled']) && $options['wdi_plugin_uninstalled'] == 'true'){
598
- $options['wdi_plugin_uninstalled'] = 'false';
599
  }
600
-
601
- add_option(WDI_OPT,$options,'','yes');
602
- update_option(WDI_OPT,$options,'yes');
603
- wdi_get_options();
604
 
605
  }
606
 
607
- function wdi_get_options() {
 
608
  global $wdi_options;
609
  $wdi_options = get_option(WDI_OPT);
610
  return apply_filters('wdi_get_options', $wdi_options);
611
  }
612
 
613
 
 
 
 
 
614
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
615
 
616
 
617
- function wdi_install_default_themes(){
 
618
  global $wdi_options;
619
- global $wpdb;
620
-
621
- require_once WDI_DIR . "/templates/default-themes.php";
622
- $default_themes = wdi_get_default_themes();
623
- foreach ($default_themes as $theme) {
624
- $table_name = $wpdb->prefix. WDI_THEME_TABLE;
625
- if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
626
- require_once(WDI_DIR . '/framework/WDILibrary.php');
627
- echo WDILibrary::message(__('Database error, please uninstall the plugin and install again', "wd-instagram-feed"), 'error');
628
- }else{
629
- $wpdb->insert($table_name, $theme);
630
- }
631
- }
632
-
633
- }
634
 
635
- ?>
 
1
+ <?php
2
  /**
3
+ * Checks if username and access_token exist, if not redirects to settings page
4
+ */
5
 
6
+ function wdi_check_necessary_params()
7
+ {
 
 
 
 
 
 
 
 
 
 
 
8
  global $wdi_options;
9
+ if (!isset($wdi_options['wdi_access_token']) || !isset($wdi_options['wdi_user_name']) || $wdi_options['wdi_access_token'] == '' || $wdi_options['wdi_user_name'] == '') {
10
+ ?>
11
+ <script>
12
+ window.location = "<?php echo admin_url('admin.php?page=wdi_settings');?>";
13
+ </script>
14
+ <?php
15
+ }
16
 
 
17
  }
18
 
19
 
 
20
  /**
21
+ * checks if argument is 1 it displays success message on settings page after uninstalling plugin
22
+ * else it displays error message already uninstalled
23
+ */
24
 
25
+ function wdi_uninstall_notice($arg)
26
+ {
27
+ if ($arg == 1) {
28
  ?>
29
  <div class="updated">
30
+ <p><?php _e('Succesfully Uninstalled!', "wd-instagram-feed"); ?></p>
31
  </div>
32
  <?php
33
+ }
34
+ else {
35
+ ?>
36
+ <div class="error">
37
+ <p><?php _e('Already Unistalled', "wd-instagram-feed"); ?></p>
38
+ </div>
39
  <?php
40
  }
41
  }
42
 
43
  /**
44
+ * checks if plugin is uninstalled it displays to all users uninstalled screen
45
+ */
46
+ function wdi_check_uninstalled()
47
+ {
48
+ global $wdi_options;
49
+ if (isset($wdi_options['wdi_plugin_uninstalled']) && $wdi_options['wdi_plugin_uninstalled'] == 'true') {
50
  require_once(WDI_DIR . '/templates/plugin-uninstalled.php');
51
  die();
52
  };
53
  }
54
 
55
  /**
56
+ * triggered on plugin activation
57
+ *
58
+ * adds some plugin related options like plugin version and database version
59
+ * also adds uninstalled option
60
+ * after adding this basic options,creates tables for plugin in wordpress database
61
+ */
62
 
63
+ function wdi_install()
64
+ {
65
 
66
 
67
+ wdi_get_options();
68
+ global $wdi_options;
69
 
70
+ // if(isset($wdi_options['wdi_plugin_uninstalled']) && $wdi_options['wdi_plugin_uninstalled'] == 'false'){
71
+ // return;
72
+ // }
73
+ $current_version = WDI_VERSION;
74
+ $saved_version = get_option('wdi_version');
75
+ if ($saved_version) {
76
+
77
+ if (substr($saved_version, 0, 1) == '2' && substr($current_version, 0, 1) == '1') {
78
  wdi_set_options_defaults();
79
  return;
80
+ }
81
+
82
+ $old_version = substr($saved_version, 2);
83
+ $new_version = substr(WDI_VERSION, 2);
84
+ $newer = version_compare($new_version, $old_version, '>');
85
+
86
+ if ($newer) {
87
+ require_once WDI_DIR . '/update/wdi_update.php';
88
+ /*adds new params for new versions*/
89
+ wdi_update_diff($new_version, $old_version);
90
+
91
+ if (!update_option('wdi_version', WDI_VERSION)) {
92
+ add_option('wdi_version', WDI_VERSION);
 
93
  }
94
+ }
95
+ wdi_set_options_defaults();
96
+ return;
97
 
98
+ }
99
 
100
 
101
  wdi_set_options_defaults();
102
  //add_option( WDI_VAR.'_version',$version, '', 'yes' );
103
+ // update_option( WDI_VAR.'_version',$version, '', 'yes' );
104
+
105
 
 
106
  global $wpdb;
107
  $table_name = $wpdb->prefix . WDI_FEED_TABLE;
108
  $charset_collate = 'COLLATE utf8_general_ci';
176
 
177
  UNIQUE KEY id (id)
178
  ) $charset_collate;";
179
+
180
+ if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
181
  //table is not created. you may create the table here.
182
+ $wpdb->query($sql);
183
  }
184
+
185
  //dbDelta( $sql );
186
  $charset_collate2 = 'COLLATE latin1_general_ci';
187
  $table_name = $wpdb->prefix . WDI_THEME_TABLE;
441
 
442
  UNIQUE KEY id (id)
443
  ) $charset_collate2;";
444
+ // dbDelta( $sql );
445
+ if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
446
  //table is not created. you may create the table here.
447
+ $wpdb->query($sql);
448
+ wdi_install_default_themes();
449
  }
450
+
451
+ if (!update_option('wdi_version', WDI_VERSION)) {
452
  add_option('wdi_version', WDI_VERSION);
453
  }
454
 
455
+ /**
456
+ * add api update notice
457
+ * @since 1.1.0
458
+ */
459
+
460
  $admin_notices_option = get_option('wdi_admin_notice', array());
461
  $admin_notices_option['api_update_token_reset'] = array(
462
+ 'start' => current_time("n/j/Y"),
463
+ 'int' => 0,
464
+ 'dismissed' => 1, // dismissed on activate
465
+ );
466
  update_option('wdi_admin_notice', $admin_notices_option);
467
 
468
 
 
469
  }
470
 
471
  //Callback function for Settings Configure Section
472
  function wdi_configure_section_callback(){
473
  $new_url = urlencode(admin_url('admin.php?page=wdi_settings')) . '&response_type=token';
474
+ $wdi_sample_feed_post_url = get_option('wdi_sample_feed_post_url');
475
+ $default_feed_permalink = null;
476
+ $options = get_option(WDI_OPT);
477
+
478
+ if ($wdi_sample_feed_post_url == '1') {
479
+
480
+ $wdi_sample_feed_post_id = get_option('wdi_sample_feed_post_id');
481
+ $wdi_sample_feed_id = get_option('wdi_sample_feed_id');
482
+ require_once(WDI_DIR . '/admin/models/WDIModelFeeds_wdi.php');
483
+ $feed_model = new WDIModelFeeds_wdi();
484
+ //getting all feed information from db
485
+ $feed_row = WDILibrary::objectToArray($feed_model->get_feed_row($wdi_sample_feed_id));
486
+ $demo_page_status = get_post_status($wdi_sample_feed_post_id);
487
+
488
+
489
+ if ($wdi_sample_feed_post_id !== false && $demo_page_status != false && $demo_page_status != 'trash') {
490
+ $default_feed_permalink = get_post_permalink($wdi_sample_feed_post_id);
491
+ if (!is_string($default_feed_permalink)) {
492
+ $default_feed_permalink = null;
493
+ }
494
+ }
495
+ }
496
+
497
+ ?>
498
+ <div id="login_with_instagram">
499
+
500
+ <?php if (!isset($options['wdi_access_token']) || $options['wdi_access_token'] == ''){ ?>
501
+ <a onclick="document.cookie = 'wdi_autofill=true'" class="wdi_sign_in_button"
502
+ href="https://api.instagram.com/oauth/authorize/?client_id=54da896cf80343ecb0e356ac5479d9ec&scope=basic+public_content&redirect_uri=http://api.web-dorado.com/instagram/?return_url=<?php echo $new_url; ?>"></a>
503
+ <?php }
504
+ if (isset($options['wdi_access_token']) && $options['wdi_access_token'] != '' && $default_feed_permalink !== null) { ?>
505
+ <a target="_blank" href="<?php echo $default_feed_permalink; ?>" class="wdi_default_feed_button"></a>
506
+ <?php }
507
+
508
+ if(isset($options['wdi_access_token']) && $options['wdi_access_token'] != '' && isset($feed_row)){
509
+ ?>
510
+ <a target="_blank" href="<?php echo esc_url(add_query_arg(array('page'=>'wdi_feeds',
511
+ 'task'=>'edit',
512
+ 'current_id' => $wdi_sample_feed_id,
513
+ 'nonce_wd' => wp_create_nonce('nonce_wd')
514
+ ), admin_url('admin.php'))); ?>" class="wdi_edit_default_feed_button"></a>
515
+ <?php } ?>
516
+ </div>
517
+
518
+ <div class="wdi_access_token_missing">
519
  <?php
520
+
521
+ if (!isset($options['wdi_access_token']) || $options['wdi_access_token'] == '' || !isset($options['wdi_user_name']) || $options['wdi_user_name'] == '')
522
+ _e('You need Access Token for using Instagram API. Click sign in with Instagram button above to get yours. This will not show your Instagram media. After that you may create feed with desired user or hashtag media.', "wd-instagram-feed");
523
+ ?>
524
+ </div>
525
+ <?php
526
  }
527
 
528
+
529
  //Callback function for Settings Customize Section
530
+ function wdi_customize_section_callback()
531
+ {
532
+
533
  }
534
 
535
  //Settings field callback:
536
  //receives settings element as parameter and checks it's type and displays proper form element
537
+ function wdi_field_callback($element)
538
+ {
539
  $setting = $element[0];
540
  $wdi_formBuilder = new WDI_admin_view();
541
+ switch ($setting['type']) {
542
+ case 'input': {
 
543
  $wdi_formBuilder->input($setting);
544
  break;
545
  }
546
+ case 'checkbox': {
547
  $wdi_formBuilder->checkbox($setting);
548
  break;
549
  }
550
+ case 'color': {
551
  $wdi_formBuilder->color($setting);
552
  break;
553
  }
554
+ case 'textarea': {
555
  $wdi_formBuilder->textarea($setting);
556
  break;
557
  }
558
+ case 'select': {
559
  $wdi_formBuilder->select($setting);
560
  break;
561
  }
563
  }
564
 
565
  //Validatates input form submit forms
566
+ function wdi_validate_options($input)
567
+ {
568
  global $wdi_options;
569
+ foreach ($input as $key => $value) {
570
+ if (isset($input[$key])) {
571
+ $wdi_options[$key] = strip_tags(stripslashes($input[$key]));
572
+ }
573
+ }
574
 
575
+ return apply_filters('wdi_validate_options', $wdi_options, $input);
576
  }
577
 
578
+ function wdi_sanitize_options($input)
579
+ {
580
  $output = array();
581
  $elements = wdi_get_settings();
582
+ foreach ($input as $key => $value) {
583
+ switch ($elements[$key]['sanitize_type']) {
584
+ case 'text': {
585
+ if (isset($input[$key])) {
586
+ $output[$key] = strip_tags(stripslashes($input[$key]));
 
 
 
 
 
 
 
 
 
 
 
 
 
587
  }
588
+ break;
589
+ }
590
+ case 'css': {
591
+ $output[$key] = esc_js(str_replace(array("\n", "\r"), "", $input[$key]));
592
+ break;
593
+ }
594
+ default: {
595
+ if (isset($input[$key])) {
596
+ $output[$key] = strip_tags(stripslashes($input[$key]));
597
+ }
598
+ break;
599
+ }
600
+ }
601
+ }
602
+ return apply_filters('wdi_sanitize_options', $output, $input);
603
  }
604
+
605
  //Sets all settings for admin pages and returns associative array of settings
606
+ function wdi_get_settings()
607
+ {
608
  $settings = array(
609
+ 'wdi_access_token' => array('name' => 'wdi_access_token', 'sanitize_type' => 'text', 'required' => 'required', 'input_size' => '53', 'type' => 'input', 'readonly' => 'readonly', 'default' => '', 'field_or_not' => 'field', 'section' => 'wdi_configure_section', 'title' => __('Access Token', "wd-instagram-feed")),
610
+ 'wdi_user_name' => array('name' => 'wdi_user_name', 'sanitize_type' => 'text', 'required' => 'required', 'type' => 'input', 'input_size' => '53', 'section' => 'wdi_configure_section', 'readonly' => 'readonly', 'field_or_not' => 'field', 'default' => '', 'title' => __('Username', "wd-instagram-feed")),
611
+ 'wdi_user_id' => array('name' => 'wdi_user_id', 'sanitize_type' => 'text', 'type' => 'input', 'section' => 'wdi_configure_section', 'readonly' => 'readonly', 'default' => '', 'field_or_not' => 'no_field'),
612
+ 'wdi_feeds_min_capability' => array('name' => 'wdi_feeds_min_capability', "sanitize_type" => "text", 'title' => __('Minimal role to add and manage Feeds or Themes', "wd-instagram-feed"), 'type' => 'select', 'field_or_not' => 'field', "default" => "manage_options", 'section' => 'wdi_customize_section', 'valid_options' => array('manage_options' => __('Administrator', 'wd-instagram-feed'), 'publish_posts' => __('Author', 'wd-instagram-feed'))),
613
+ 'wdi_custom_css' => array('name' => 'wdi_custom_css', 'sanitize_type' => 'css', 'type' => 'textarea', 'section' => 'wdi_customize_section', 'field_or_not' => 'field', 'default' => '', 'title' => __('Custom CSS', "wd-instagram-feed")),
614
+ 'wdi_custom_js' => array('name' => 'wdi_custom_js', 'sanitize_type' => 'css', 'type' => 'textarea', 'section' => 'wdi_customize_section', 'field_or_not' => 'field', 'default' => '', 'title' => __('Custom JavaScript', "wd-instagram-feed")),
615
+ //'wdi_preserve_settings_when_remove'=>array('name'=>'wdi_preserve_settings_when_remove','field_or_not'=>'field','type'=>'checkbox','default'=>'1', 'section'=>'wdi_configure_section','title'=>__('Preserve Settings When Remove',"wd-instagram-feed")),
616
+ 'wdi_plugin_uninstalled' => array('name' => 'wdi_plugin_uninstalled', 'sanitize_type' => 'bool', 'field_or_not' => 'field', 'type' => 'input', 'input_type' => 'hidden', 'section' => 'wdi_customize_section', 'title' => '', 'default' => 'false', 'value' => 'false'),
617
+ //'wdi_version' => array('name'=>'wdi_version','field_or_not'=>'no_field','default'=>WDI_VERSION),
618
+ //'wdi_first_time'=>array('name'=>'wdi_first_time','field_or_not'=>'no_field','default'=>'1')
619
+
620
+ );
621
  return $settings;
622
  }
623
 
624
  //Sets plugin default settings
625
+ function wdi_set_options_defaults()
626
+ {
627
  $db_options = array();
628
  $options = get_option(WDI_OPT);
629
+
 
 
630
 
631
  $settings = wdi_get_settings();
632
  foreach ($settings as $setting) {
633
+ $settingDefault = isset($setting['default']) ? $setting['default'] : '';
634
+ $db_options[$setting['name']] = $setting['default'];
635
  }
636
 
637
 
638
+ $options = wp_parse_args($options, $db_options);
639
+ if (isset($options['wdi_plugin_uninstalled']) && $options['wdi_plugin_uninstalled'] == 'true') {
640
+ $options['wdi_plugin_uninstalled'] = 'false';
641
  }
642
+
643
+ add_option(WDI_OPT, $options, '', 'yes');
644
+ update_option(WDI_OPT, $options, 'yes');
645
+ wdi_get_options();
646
 
647
  }
648
 
649
+ function wdi_get_options()
650
+ {
651
  global $wdi_options;
652
  $wdi_options = get_option(WDI_OPT);
653
  return apply_filters('wdi_get_options', $wdi_options);
654
  }
655
 
656
 
657
+ function wdi_install_default_themes()
658
+ {
659
+ global $wdi_options;
660
+ global $wpdb;
661
 
662
+ require_once WDI_DIR . "/templates/default-themes.php";
663
+ $default_themes = wdi_get_default_themes();
664
+ foreach ($default_themes as $theme) {
665
+ $table_name = $wpdb->prefix . WDI_THEME_TABLE;
666
+ if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
667
+ require_once(WDI_DIR . '/framework/WDILibrary.php');
668
+ echo WDILibrary::message(__('Database error, please uninstall the plugin and install again', "wd-instagram-feed"), 'error');
669
+ }
670
+ else {
671
+ $wpdb->insert($table_name, $theme);
672
+ }
673
+ }
674
+
675
+ }
676
 
677
 
678
+ function wdi_get_create_feeds_cap()
679
+ {
680
  global $wdi_options;
681
+ $min_feeds_capability = isset($wdi_options['wdi_feeds_min_capability']) ? $wdi_options['wdi_feeds_min_capability'] : "manage_options";
682
+ $min_feeds_capability = $min_feeds_capability == 'publish_posts' ? 'publish_posts' : "manage_options";
 
 
 
 
 
 
 
 
 
 
 
 
 
683
 
684
+ return $min_feeds_capability;
685
+ }
admin/controllers/WDIControllerFeeds_wdi.php CHANGED
@@ -32,6 +32,28 @@ class WDIControllerFeeds_wdi {
32
  $this->display();
33
  }
34
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ////////////////////////////////////////////////////////////////////////////////////////
36
  // Private Methods //
37
  ////////////////////////////////////////////////////////////////////////////////////////
@@ -191,6 +213,9 @@ class WDIControllerFeeds_wdi {
191
  $this->display();
192
  }
193
 
 
 
 
194
  private function apply_changes(){
195
  require_once WDI_DIR . "/admin/models/WDIModelFeeds_wdi.php";
196
  $model = new WDIModelFeeds_wdi();
32
  $this->display();
33
  }
34
  }
35
+
36
+ public function create_feed($settings = array()) {
37
+ require_once WDI_DIR . "/admin/models/WDIModelFeeds_wdi.php";
38
+ $model = new WDIModelFeeds_wdi();
39
+
40
+ $defaults = $model->wdi_get_feed_defaults();
41
+
42
+ if (!empty($settings)) {
43
+ $settings = $this->sanitize_input($settings, $defaults);
44
+ $settings = wp_parse_args($settings, $defaults);
45
+ } else {
46
+ $settings = $defaults;
47
+ }
48
+
49
+ global $wpdb;
50
+
51
+ $wpdb->insert($wpdb->prefix . WDI_FEED_TABLE, $settings, $this->dataFormat);
52
+ return $wpdb->insert_id;
53
+ //if ($wpdb->insert_id == false) {
54
+ //$this->message(__('Cannot Write on database. Check database permissions.', "wd-instagram-feed"), 'error');
55
+ //}
56
+ }
57
  ////////////////////////////////////////////////////////////////////////////////////////
58
  // Private Methods //
59
  ////////////////////////////////////////////////////////////////////////////////////////
213
  $this->display();
214
  }
215
 
216
+
217
+
218
+
219
  private function apply_changes(){
220
  require_once WDI_DIR . "/admin/models/WDIModelFeeds_wdi.php";
221
  $model = new WDIModelFeeds_wdi();
admin/controllers/WDIControllerUninstall_wdi.php CHANGED
@@ -100,8 +100,19 @@ class WDIControllerUninstall_wdi{
100
  };
101
 
102
  delete_option(WDI_OPT);
103
-
104
- $default_option=array();
 
 
 
 
 
 
 
 
 
 
 
105
  $default_option['wdi_plugin_uninstalled'] = 'true';
106
 
107
  add_option(WDI_OPT,$default_option);
100
  };
101
 
102
  delete_option(WDI_OPT);
103
+
104
+ $sample_post_id = get_option('wdi_sample_feed_post_id');
105
+ if($sample_post_id !== false){
106
+ wp_delete_post( $sample_post_id, true );
107
+ }
108
+
109
+ delete_option('wdi_sample_feed_id');
110
+ delete_option('wdi_sample_feed_post_id');
111
+ delete_option('wdi_sample_feed_post_url');
112
+ delete_option('wdi_first_user_username');
113
+
114
+
115
+ $default_option=array();
116
  $default_option['wdi_plugin_uninstalled'] = 'true';
117
 
118
  add_option(WDI_OPT,$default_option);
admin/views/WDIViewSettings_wdi.php CHANGED
@@ -14,6 +14,7 @@ private $model;
14
  // Public Methods //
15
  ////////////////////////////////////////////////////////////////////////////////////////
16
  public function display(){
 
17
  require_once(WDI_DIR . '/framework/WDI_admin_view.php');
18
  if(isset($_GET['access_token'])) {
19
 
@@ -63,17 +64,17 @@ private $model;
63
  <input type="hidden"id="wdi_user_id" name="<?php echo WDI_OPT.'[wdi_user_id]' ?>">
64
  <?php settings_fields('wdi_all_settings'); ?>
65
  <?php do_settings_sections('settings_wdi'); ?>
66
- <div id="wdi_reset_access_token" class="button button-secondary"><?php _e("Reset Access Token and Username","wd-instagram-feed")?></div>
67
- <?php submit_button(); ?>
 
 
 
68
  <style>
69
- p.submit{
70
- display: inline;
71
- padding-left: 10px;
72
- }
73
- #wdi_reset_access_token{
74
- margin-top: 0;
75
- float: left;
76
- }
77
  </style>
78
  <script>
79
  jQuery(document).ready(function(){
@@ -87,7 +88,7 @@ private $model;
87
  });
88
  });
89
  </script>
90
- </form>
91
  <?php
92
  }
93
  }
14
  // Public Methods //
15
  ////////////////////////////////////////////////////////////////////////////////////////
16
  public function display(){
17
+ global $wdi_options;
18
  require_once(WDI_DIR . '/framework/WDI_admin_view.php');
19
  if(isset($_GET['access_token'])) {
20
 
64
  <input type="hidden"id="wdi_user_id" name="<?php echo WDI_OPT.'[wdi_user_id]' ?>">
65
  <?php settings_fields('wdi_all_settings'); ?>
66
  <?php do_settings_sections('settings_wdi'); ?>
67
+ <div id="wdi_options_page_buttons_wrapper">
68
+ <div id="wdi_reset_access_token" class="button button-secondary"><?php _e("Reset Access Token and Username","wd-instagram-feed")?></div>
69
+ <?php submit_button(); ?>
70
+ </div>
71
+ </form>
72
  <style>
73
+ <?php if(!isset($wdi_options['wdi_access_token']) || empty($wdi_options['wdi_access_token'])){ ?>
74
+ body.instagram-feed-wd_page_wdi_settings table:nth-of-type(2){
75
+ display:none;
76
+ }
77
+ <?php } ?>
 
 
 
78
  </style>
79
  <script>
80
  jQuery(document).ready(function(){
88
  });
89
  });
90
  </script>
91
+
92
  <?php
93
  }
94
  }
css/wdi_backend.css CHANGED
@@ -213,10 +213,157 @@ padding: 5px;
213
  }
214
 
215
  .wdi_access_token_missing{
216
- font-size: 16px;
217
- color: #ff4444;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  }
219
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  .wdi_hide{
221
  display: none;
222
  }
@@ -345,6 +492,7 @@ padding: 5px;
345
  }
346
 
347
 
 
348
  .wdi_help_bar_wrap {
349
  background-color: #ffffff;
350
  border: none;
213
  }
214
 
215
  .wdi_access_token_missing{
216
+ font-size: 14px;
217
+ color: #000000;
218
+ clear: both;
219
+ }
220
+
221
+ .instagram-feed-wd_page_wdi_settings form{
222
+ width: 65%;
223
+ }
224
+
225
+ .instagram-feed-wd_page_wdi_settings table td{
226
+ padding-left: 0;
227
+ padding-right: 0;
228
+ }
229
+
230
+ .instagram-feed-wd_page_wdi_settings table th{
231
+ padding-left: 4px;
232
  }
233
 
234
+ .instagram-feed-wd_page_wdi_settings table input
235
+ /*.instagram-feed-wd_page_wdi_settings table textarea,*/
236
+ /*.instagram-feed-wd_page_wdi_settings table select*/
237
+ {
238
+ float: right;
239
+ }
240
+
241
+ #login_with_instagram {
242
+ height: 43px;
243
+ }
244
+
245
+ #login_with_instagram .wdi_sign_in_button{
246
+ background-image: url('../images/sign_in_with_instagram.png');
247
+ background-repeat: no-repeat;
248
+ background-position: left top;
249
+ width: 234px;
250
+ height: 43px;
251
+ display:inline-block;
252
+ float: left;
253
+ }
254
+
255
+ #login_with_instagram .wdi_sign_in_button:hover {
256
+ /*background-image: url('../images/sign_in_with_instagram_hover.png');*/
257
+ }
258
+
259
+
260
+ #login_with_instagram .wdi_default_feed_button,
261
+ #login_with_instagram .wdi_edit_default_feed_button{
262
+
263
+ width: 234px;
264
+ height: 43px;
265
+ background-repeat: no-repeat;
266
+ background-position: center top;
267
+ display:inline-block;
268
+
269
+ }
270
+ #login_with_instagram .wdi_default_feed_button{
271
+ background-image: url('../images/default_feed_button.png');
272
+ float: left;
273
+ margin-right: 10px;
274
+ }
275
+ #login_with_instagram .wdi_edit_default_feed_button{
276
+ background-image: url('../images/edit_feed_button.png');
277
+ float: left;
278
+ }
279
+
280
+ #wdi_options_page_buttons_wrapper .submit {
281
+ display: inline;
282
+ margin-left: 15px;
283
+ }
284
+
285
+ #wdi_reset_access_token {
286
+ margin-top: 0;
287
+ float: left;
288
+ width: 232px;
289
+ text-align: center;
290
+ }
291
+
292
+ .wdi_advanced_option {
293
+ width: 100%;
294
+ position: relative;
295
+ font-weight: 600;
296
+ }
297
+
298
+ .wdi_advanced_option {
299
+ background-color: #f9f9f9;
300
+ cursor: pointer;
301
+ border: 1px solid rgb(227, 227, 227);
302
+ border-radius: 10px;
303
+ border-collapse: separate;
304
+ border-spacing: 0;
305
+ }
306
+
307
+ .wdi_advanced_option .wdi_advanced_option_head {
308
+ border-bottom: 1px solid rgb(227, 227, 227);
309
+ }
310
+
311
+ .wdi_advanced_option .wdi_advanced_option_head th {
312
+ padding-top: 10px;
313
+ padding-bottom: 10px;
314
+ }
315
+
316
+ .wdi_advanced_option.wdi_advanced_option_open .wdi_advanced_option_head th {
317
+ border-bottom: 1px solid rgb(227, 227, 227);
318
+ border-bottom-left-radius: 10px;
319
+ }
320
+
321
+ .wdi_advanced_option.wdi_advanced_option_open .wdi_advanced_option_head td {
322
+ border-bottom: 1px solid rgb(227, 227, 227);
323
+ border-bottom-right-radius: 10px;
324
+ }
325
+
326
+ .instagram-feed-wd_page_wdi_settings table.wdi_advanced_option th {
327
+ padding-left: 12px;
328
+ }
329
+
330
+ .instagram-feed-wd_page_wdi_settings table.wdi_advanced_option td .wdwt_param{
331
+ margin-left: 15px;
332
+ }
333
+
334
+ .wdi_advanced_option .wdi_advanced_option_icon {
335
+ background-repeat: no-repeat;
336
+ background-position: left top;
337
+ width: 20px;
338
+ height: 20px;
339
+ display: inline-block;
340
+ position: absolute;
341
+ top: 16px;
342
+ right: 10px;
343
+ }
344
+
345
+ .wdi_advanced_option.wdi_advanced_option_close .wdi_advanced_option_icon {
346
+ background-image: url('../images/arrow_1.png');
347
+ }
348
+
349
+ .wdi_advanced_option.wdi_advanced_option_open .wdi_advanced_option_icon {
350
+ background-image: url('../images/arrow_2.png');
351
+ }
352
+
353
+ .wdi_advanced_option.wdi_advanced_option_close tbody tr:not(.wdi_advanced_option_head) {
354
+ display: none;
355
+ }
356
+
357
+ .instagram-feed-wd_page_wdi_settings form h2 {
358
+ display: none;
359
+ }
360
+
361
+ #wdi_options_page_buttons_wrapper{
362
+ margin-top: 10px;
363
+ width: 700px;
364
+ }
365
+
366
+
367
  .wdi_hide{
368
  display: none;
369
  }
492
  }
493
 
494
 
495
+
496
  .wdi_help_bar_wrap {
497
  background-color: #ffffff;
498
  border: none;
css/wdi_frontend.css CHANGED
@@ -472,6 +472,7 @@ div[id^="wdi_container"] p {
472
  .wdi_layout_th .wdi_user_img_wrap img {
473
  overflow: hidden;
474
  display: block;
 
475
  }
476
 
477
  .wdi_layout_th .wdi_header_user_text h3 {
@@ -755,6 +756,7 @@ div[id^="wdi_container"] p {
755
  .wdi_layout_ib .wdi_user_img_wrap img {
756
  overflow: hidden;
757
  display: block;
 
758
  }
759
 
760
  .wdi_layout_ib .wdi_header_user_text h3 {
472
  .wdi_layout_th .wdi_user_img_wrap img {
473
  overflow: hidden;
474
  display: block;
475
+ margin:0;
476
  }
477
 
478
  .wdi_layout_th .wdi_header_user_text h3 {
756
  .wdi_layout_ib .wdi_user_img_wrap img {
757
  overflow: hidden;
758
  display: block;
759
+ margin:0;
760
  }
761
 
762
  .wdi_layout_ib .wdi_header_user_text h3 {
images/arrow_1.png ADDED
Binary file
images/arrow_2.png ADDED
Binary file
images/default_feed_button.png ADDED
Binary file
images/edit_feed_button.png ADDED
Binary file
images/sign_in_with_instagram.png CHANGED
Binary file
js/wdi_admin.js CHANGED
@@ -16,8 +16,31 @@ jQuery(document).ready(function() {
16
  jQuery('#wdi_add_user_ajax').after(jQuery("<br><label class='wdi_pro_only' for='wdi_add_user_ajax_input'>" + wdi_messages.username_hashtag_multiple + "</label>"));
17
 
18
 
 
 
 
 
19
  });
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  function wdi_controller() {};
22
 
23
  /**
16
  jQuery('#wdi_add_user_ajax').after(jQuery("<br><label class='wdi_pro_only' for='wdi_add_user_ajax_input'>" + wdi_messages.username_hashtag_multiple + "</label>"));
17
 
18
 
19
+ if(jQuery('body').hasClass('instagram-feed-wd_page_wdi_settings')){
20
+ wdi_advanced_option_controller();
21
+ }
22
+
23
  });
24
 
25
+ function wdi_advanced_option_controller() {
26
+
27
+ var $table = jQuery(jQuery('#wdi_user_id').closest('form').find('.form-table').get(1));
28
+ $table.addClass('wdi_advanced_option wdi_advanced_option_close');
29
+ var tr = "<tr class='wdi_advanced_option_head'><th>ADVANCED OPTIONS</th><td><div class='wdi_advanced_option_icon'></div></td></tr>";
30
+ $tr = jQuery(tr);
31
+ $table.prepend($tr);
32
+
33
+ $tr.on('click', function () {
34
+ if ($table.hasClass('wdi_advanced_option_open')) {
35
+ $table.removeClass('wdi_advanced_option_open');
36
+ $table.addClass('wdi_advanced_option_close');
37
+ } else {
38
+ $table.removeClass('wdi_advanced_option_close');
39
+ $table.addClass('wdi_advanced_option_open');
40
+ }
41
+ });
42
+ }
43
+
44
  function wdi_controller() {};
45
 
46
  /**
js/wdi_frontend.js CHANGED
@@ -129,6 +129,11 @@ wdi_front.globalInit = function ()
129
  */
130
  currentFeed.instagramRequestCounter = 0;
131
 
 
 
 
 
 
132
  /**
133
  * This array stores data from each request,
134
  * it is used to determine and remove duplicate photos caused by multiple hashtags
@@ -285,6 +290,8 @@ wdi_front.instagramRequest = function (id, currentFeed)
285
  currentFeed.instagram.getRecentLikedMedia({
286
  success: function (response)
287
  {
 
 
288
  response = _this.checkMediaResponse(response);
289
  if (response != false) {
290
  _this.saveSelfUserData(response, currentFeed);
@@ -297,6 +304,8 @@ wdi_front.instagramRequest = function (id, currentFeed)
297
  currentFeed.instagram.getTagRecentMedia(this.stripHashtag(feed_users[id]['username']), {
298
  success: function (response)
299
  {
 
 
300
  response = _this.checkMediaResponse(response);
301
  if (response != false) {
302
  _this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
@@ -309,6 +318,8 @@ wdi_front.instagramRequest = function (id, currentFeed)
309
  currentFeed.instagram.getUserRecentMedia(feed_users[id]['id'], {
310
  success: function (response)
311
  {
 
 
312
  response = _this.checkMediaResponse(response);
313
  if (response != false) {
314
  _this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
@@ -317,6 +328,7 @@ wdi_front.instagramRequest = function (id, currentFeed)
317
  });
318
  }
319
 
 
320
  }
321
 
322
  /**
@@ -742,7 +754,7 @@ wdi_front.masonryDisplayFeedItems = function (data, currentFeed)
742
 
743
  });
744
 
745
-
746
  /**
747
  * if feed type is not blog style then after displaying images assign click evetns to their captions
748
  * this part of code is a bit differenet from free version because of image lazy loading feature
@@ -1736,7 +1748,7 @@ wdi_front.bindEvents = function (currentFeed)
1736
  wdi_front.infiniteScroll = function (currentFeed)
1737
  {
1738
 
1739
- if (jQuery(window).scrollTop() <= jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll').offset().top) {
1740
  if (currentFeed.infiniteScrollFlag === false && currentFeed.stopInfiniteScrollFlag == false) {
1741
  currentFeed.infiniteScrollFlag = true;
1742
  wdi_front.loadMore(jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll'), currentFeed);
@@ -1986,13 +1998,23 @@ wdi_front.loadMore = function (button, _currentFeed)
1986
  */
1987
  wdi_front.loadMoreRequest = function (user, next_url, currentFeed, button)
1988
  {
 
 
 
 
 
1989
 
1990
  var usersData = currentFeed['usersData'];
1991
  var errorMessage = '';
 
 
 
1992
 
1993
  currentFeed.instagram.requestByUrl(next_url, {
1994
  success: function (response)
1995
  {
 
 
1996
  if (response === '' || typeof response == 'undefined' || response == null) {
1997
  errorMessage = wdi_front_messages.network_error;
1998
  currentFeed.loadMoreDataCount--;
@@ -2035,7 +2057,9 @@ wdi_front.loadMoreRequest = function (user, next_url, currentFeed, button)
2035
  //checks if load more done then displays feed
2036
  wdi_front.checkForLoadMoreDone(currentFeed, button);
2037
  }
2038
- })
 
 
2039
 
2040
  }
2041
 
@@ -2109,6 +2133,8 @@ wdi_front.checkForLoadMoreDone = function (currentFeed, button)
2109
 
2110
  wdi_front.allDataHasFinished = function (currentFeed)
2111
  {
 
 
2112
  var c = 0;
2113
  for (var j = 0; j < currentFeed.dataStorageRaw.length; j++) {
2114
  if (currentFeed.dataStorageRaw[j].length() == 0 && currentFeed.dataStorageRaw[j].locked == true) {
@@ -2194,11 +2220,15 @@ wdi_front.allImagesLoaded = function (currentFeed)
2194
  //jQuery('#wdi_feed_'+currentFeed.feed_row['wdi_feed_counter']+' .wdi_ajax_loading').remove();
2195
 
2196
  ////////////////////////////////////////////////////
2197
-
2198
  var dataLength = wdi_front.getDataLength(currentFeed);
 
 
 
 
 
2199
  /* display message if feed contains no image at all */
2200
- if (dataLength == 0 && (currentFeed.feed_row.conditional_filters.length == 0 || currentFeed.feed_row.conditional_filter_enable == 0)) {
2201
- jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").append("<p>" + wdi_front_messages.feed_nomedia + "</p>");
2202
  }
2203
 
2204
  //if all images loaded then enable load more button and hide spinner
129
  */
130
  currentFeed.instagramRequestCounter = 0;
131
 
132
+ /**
133
+ * flag: false initially, becomes true after first request, no matter if there is response or not
134
+ * */
135
+ currentFeed.mediaRequestsDone = false;
136
+
137
  /**
138
  * This array stores data from each request,
139
  * it is used to determine and remove duplicate photos caused by multiple hashtags
290
  currentFeed.instagram.getRecentLikedMedia({
291
  success: function (response)
292
  {
293
+ currentFeed.mediaRequestsDone = true;
294
+
295
  response = _this.checkMediaResponse(response);
296
  if (response != false) {
297
  _this.saveSelfUserData(response, currentFeed);
304
  currentFeed.instagram.getTagRecentMedia(this.stripHashtag(feed_users[id]['username']), {
305
  success: function (response)
306
  {
307
+ currentFeed.mediaRequestsDone = true;
308
+
309
  response = _this.checkMediaResponse(response);
310
  if (response != false) {
311
  _this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
318
  currentFeed.instagram.getUserRecentMedia(feed_users[id]['id'], {
319
  success: function (response)
320
  {
321
+ currentFeed.mediaRequestsDone = true;
322
+
323
  response = _this.checkMediaResponse(response);
324
  if (response != false) {
325
  _this.saveUserData(response, currentFeed.feed_users[id], currentFeed);
328
  });
329
  }
330
 
331
+
332
  }
333
 
334
  /**
754
 
755
  });
756
 
757
+ checkLoaded();
758
  /**
759
  * if feed type is not blog style then after displaying images assign click evetns to their captions
760
  * this part of code is a bit differenet from free version because of image lazy loading feature
1748
  wdi_front.infiniteScroll = function (currentFeed)
1749
  {
1750
 
1751
+ if ((jQuery(window).scrollTop() + jQuery(window).height() - 100) >= jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll').offset().top) {
1752
  if (currentFeed.infiniteScrollFlag === false && currentFeed.stopInfiniteScrollFlag == false) {
1753
  currentFeed.infiniteScrollFlag = true;
1754
  wdi_front.loadMore(jQuery('#wdi_feed_' + currentFeed.feed_row['wdi_feed_counter'] + ' #wdi_infinite_scroll'), currentFeed);
1998
  */
1999
  wdi_front.loadMoreRequest = function (user, next_url, currentFeed, button)
2000
  {
2001
+ /*if there was no initial request, do not allow loadmore request */
2002
+ if(!currentFeed.mediaRequestsDone){
2003
+ return;
2004
+ }
2005
+
2006
 
2007
  var usersData = currentFeed['usersData'];
2008
  var errorMessage = '';
2009
+ /*sometimes (infinitescroll) loadMoreRequest is triggered before feed has any user data */
2010
+ /**/
2011
+ ///jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").remove(".wdi_nomedia");
2012
 
2013
  currentFeed.instagram.requestByUrl(next_url, {
2014
  success: function (response)
2015
  {
2016
+
2017
+
2018
  if (response === '' || typeof response == 'undefined' || response == null) {
2019
  errorMessage = wdi_front_messages.network_error;
2020
  currentFeed.loadMoreDataCount--;
2057
  //checks if load more done then displays feed
2058
  wdi_front.checkForLoadMoreDone(currentFeed, button);
2059
  }
2060
+ });
2061
+
2062
+
2063
 
2064
  }
2065
 
2133
 
2134
  wdi_front.allDataHasFinished = function (currentFeed)
2135
  {
2136
+
2137
+
2138
  var c = 0;
2139
  for (var j = 0; j < currentFeed.dataStorageRaw.length; j++) {
2140
  if (currentFeed.dataStorageRaw[j].length() == 0 && currentFeed.dataStorageRaw[j].locked == true) {
2220
  //jQuery('#wdi_feed_'+currentFeed.feed_row['wdi_feed_counter']+' .wdi_ajax_loading').remove();
2221
 
2222
  ////////////////////////////////////////////////////
 
2223
  var dataLength = wdi_front.getDataLength(currentFeed);
2224
+ /*if there was no request for media, we do not know yet of feed data has been finished or not*/
2225
+
2226
+ if(! currentFeed.mediaRequestsDone){
2227
+ jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").remove("wdi_nomedia");
2228
+ }
2229
  /* display message if feed contains no image at all */
2230
+ if (dataLength == 0 && currentFeed.mediaRequestsDone && (currentFeed.feed_row.conditional_filters.length == 0 || currentFeed.feed_row.conditional_filter_enable == 0)) {
2231
+ jQuery('#wdi_feed_' + currentFeed.feed_row.wdi_feed_counter + " .wdi_feed_wrapper").append("<p class='wdi_nomedia'>" + wdi_front_messages.feed_nomedia + "</p>");
2232
  }
2233
 
2234
  //if all images loaded then enable load more button and hide spinner
js/wdi_responsive.js CHANGED
@@ -128,7 +128,7 @@ wdi_responsive.columnControl = function (currentFeed, load, customWidth)
128
  currentFeed.displayedData = [];
129
  wdi_front.masonryDisplayFeedItems(dataToBeDisplayed, currentFeed);
130
  wdi_front.applyFilters(currentFeed);
131
- wdi_front.allImagesLoaded(currentFeed);
132
 
133
 
134
  }
128
  currentFeed.displayedData = [];
129
  wdi_front.masonryDisplayFeedItems(dataToBeDisplayed, currentFeed);
130
  wdi_front.applyFilters(currentFeed);
131
+ ///wdi_front.allImagesLoaded(currentFeed);
132
 
133
 
134
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
4
  Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram gallery, instagram posts, Instagram images, Instagram photos, lightbox, photos,instagram account
5
  Requires at least: 3.9
6
  Tested up to: 4.8
7
- Stable tag: 1.1.30
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -110,6 +110,12 @@ After downloading the ZIP file of the Instagram Feed WD plugin,
110
 
111
  == Changelog ==
112
 
 
 
 
 
 
 
113
  = 1.1.30 =
114
  Changed: Frontend styles optimized, loads faster now
115
 
4
  Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram gallery, instagram posts, Instagram images, Instagram photos, lightbox, photos,instagram account
5
  Requires at least: 3.9
6
  Tested up to: 4.8
7
+ Stable tag: 1.2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
 
111
  == Changelog ==
112
 
113
+ = 1.2.0 =
114
+ New: Default feed
115
+ Fixed: Infinite scroll triggering (PRO)
116
+ Fixed: "No media in feed" message on mobile masonry feed
117
+ Fixed: Minor style conflicts with some themes
118
+
119
  = 1.1.30 =
120
  Changed: Frontend styles optimized, loads faster now
121
 
wd-instagram-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Instagram Feed WD
4
  Plugin URI: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
5
  Description: WD Instagram Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
- Version: 1.1.30
7
  Author: WebDorado
8
  Author URI: https://web-dorado.com
9
  License: GPLv2 or later
@@ -21,7 +21,7 @@ define("WDI_META", "_".WDI_VAR."_meta");
21
  //define("wdi",'wdi');
22
  define('WDI_FEED_TABLE','wdi_feeds');
23
  define('WDI_THEME_TABLE','wdi_themes');
24
- define('WDI_VERSION','1.1.30');
25
  define('WDI_IS_PRO','false');
26
 
27
 
@@ -123,6 +123,82 @@ function wdi_setup_redirect() {
123
  }
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
 
128
 
@@ -138,12 +214,14 @@ function wdi_register_settings(){
138
 
139
  //adding configure section
140
  add_settings_section('wdi_configure_section',__('Configure', "wd-instagram-feed"),'wdi_configure_section_callback','settings_wdi');
141
-
142
  //adding customize section
143
- add_settings_section('wdi_customize_section',__('Customize', "wd-instagram-feed"),'wdi_customize_section_callback','settings_wdi');
 
144
 
145
  //adding settings fileds form getted settings
146
  foreach($settings as $setting_name => $setting){
 
147
  if(isset($setting['field_or_not'])==true && $setting['field_or_not']!='no_field'){
148
  add_settings_field(
149
  $setting_name,
3
  Plugin Name: Instagram Feed WD
4
  Plugin URI: https://web-dorado.com/products/wordpress-instagram-feed-wd.html
5
  Description: WD Instagram Feed is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
+ Version: 1.2.0
7
  Author: WebDorado
8
  Author URI: https://web-dorado.com
9
  License: GPLv2 or later
21
  //define("wdi",'wdi');
22
  define('WDI_FEED_TABLE','wdi_feeds');
23
  define('WDI_THEME_TABLE','wdi_themes');
24
+ define('WDI_VERSION','1.2.0');
25
  define('WDI_IS_PRO','false');
26
 
27
 
123
  }
124
  }
125
 
126
+ add_filter('wdi_sanitize_options', 'wdi_create_sample_feed');
127
+
128
+ function wdi_create_sample_feed($new_options) {
129
+
130
+ //submit wdi options
131
+ if (!isset($_POST['option_page']) || $_POST['option_page'] != 'wdi_all_settings') {
132
+ return $new_options;
133
+ }
134
+
135
+ $wdi_options = wdi_get_options();
136
+
137
+ if(empty($new_options['wdi_user_name'])) {
138
+ return $new_options;
139
+ }
140
+
141
+ $first_user_username = get_option('wdi_first_user_username');
142
+ if($first_user_username !== false && $new_options['wdi_user_name'] !== $first_user_username){
143
+ update_option('wdi_sample_feed_post_url', '0');
144
+ return $new_options;
145
+ }
146
+
147
+
148
+ if (!empty($wdi_options['wdi_access_token']) || empty($new_options['wdi_access_token'])) {
149
+ return $new_options;
150
+ }
151
+
152
+ $wdi_sample_feed_post_id = get_option('wdi_sample_feed_post_id');
153
+ if ($wdi_sample_feed_post_id !== false) {
154
+ return $new_options;
155
+ }
156
+
157
+ require_once(WDI_DIR . '/admin/controllers/WDIControllerFeeds_wdi.php');
158
+ require_once(WDI_DIR . '/framework/WDILibrary.php');
159
+
160
+ $default_user = new stdClass();
161
+ $default_user->username = $new_options['wdi_user_name'];
162
+ $default_user->id = "";
163
+
164
+ $settings = array(
165
+ 'feed_users' => json_encode(array($default_user)),
166
+ );
167
+
168
+ $controller = new WDIControllerFeeds_wdi();
169
+ $feed_id = $controller->create_feed($settings);
170
+
171
+ //db error
172
+ if ($feed_id == false) {
173
+ return $new_options;
174
+ }
175
+
176
+ $post_content = "<p>".__('This is a private page. To make it public, edit it and change the visibility.').
177
+ "</p>".
178
+ '[wdi_feed id="' . $feed_id . '"]';
179
+
180
+ $post_args = array(
181
+ 'post_content' => $post_content,
182
+ 'post_status' => 'private',
183
+ 'post_title' => __('My Instagram Feed', 'wd-instagram-feed'),
184
+ 'post_type' => 'page',
185
+ );
186
+
187
+ $post_id = wp_insert_post($post_args);
188
+
189
+ if ($post_id === 0) {
190
+ return $new_options;
191
+ }
192
+
193
+ update_option('wdi_first_user_username', $new_options['wdi_user_name']);
194
+ update_option('wdi_sample_feed_id', $feed_id);
195
+ update_option('wdi_sample_feed_post_id', $post_id);
196
+ update_option('wdi_sample_feed_post_url', '1');
197
+
198
+
199
+ return $new_options;
200
+ }
201
+
202
 
203
 
204
 
214
 
215
  //adding configure section
216
  add_settings_section('wdi_configure_section',__('Configure', "wd-instagram-feed"),'wdi_configure_section_callback','settings_wdi');
217
+
218
  //adding customize section
219
+
220
+ add_settings_section('wdi_customize_section', __('Customize', "wd-instagram-feed"), 'wdi_customize_section_callback', 'settings_wdi');
221
 
222
  //adding settings fileds form getted settings
223
  foreach($settings as $setting_name => $setting){
224
+
225
  if(isset($setting['field_or_not'])==true && $setting['field_or_not']!='no_field'){
226
  add_settings_field(
227
  $setting_name,