Instagram Slider Widget - Version 2.1.0

Version Description

  • Fix instagram and facebook feed. Need to reconnect all accounts!
Download this release

Release Info

Developer webtemyk
Plugin Icon 128x128 Instagram Slider Widget
Version 2.1.0
Comparing to
See all releases

Code changes from version 2.0.6 to 2.1.0

admin/pages/feeds.php CHANGED
@@ -60,8 +60,8 @@ class WIS_FeedsPage extends WIS_Page {
60
  */
61
  public function __construct( $plugin ) {
62
  $this->id = 'feeds';
63
- $this->page_title = __( 'Social Slider Feeds', 'instagram-slider-widget' );
64
- $this->menu_title = __( 'Social Slider Feeds', 'instagram-slider-widget' );
65
  $this->menu_sub_title = __( 'Feeds', 'instagram-slider-widget' );
66
  $this->menu_tab_title = __( 'Feeds', 'instagram-slider-widget' );
67
  $this->menu_icon = '~/admin/assets/img/wis.png';
@@ -257,7 +257,7 @@ class WIS_FeedsPage extends WIS_Page {
257
  public function delete_action( $social, $feed_id = 0 ) {
258
  $feeds = new WIS_Feeds( $social );
259
 
260
- check_admin_referer( 'wis_edit_feed', 'csrf_check' );
261
 
262
  if ( $feed_id ) {
263
  $feeds->delete_feed( $feed_id );
60
  */
61
  public function __construct( $plugin ) {
62
  $this->id = 'feeds';
63
+ $this->page_title = __( 'Social Slider Feed', 'instagram-slider-widget' );
64
+ $this->menu_title = __( 'Social Slider Feed', 'instagram-slider-widget' );
65
  $this->menu_sub_title = __( 'Feeds', 'instagram-slider-widget' );
66
  $this->menu_tab_title = __( 'Feeds', 'instagram-slider-widget' );
67
  $this->menu_icon = '~/admin/assets/img/wis.png';
257
  public function delete_action( $social, $feed_id = 0 ) {
258
  $feeds = new WIS_Feeds( $social );
259
 
260
+ check_admin_referer( 'wis_delete_feed', 'nonce' );
261
 
262
  if ( $feed_id ) {
263
  $feeds->delete_feed( $feed_id );
admin/pages/profiles.php CHANGED
@@ -83,9 +83,9 @@ class WIS_ProfilesPage extends WIS_Page {
83
 
84
  $this->plugin = $plugin;
85
 
86
- $this->instagram = new WIS_Instagram_Profiles( $this );
87
- $this->facebook = new WIS_Facebook_Profiles( $this );
88
- $this->youtube = new WIS_Youtube_Profiles( $this );
89
 
90
  }
91
 
@@ -177,17 +177,17 @@ class WIS_ProfilesPage extends WIS_Page {
177
  'instagram' => [
178
  'title' => __( 'Instagram', 'instagram-slider-widget' ),
179
  'description' => __( 'Manage Instagram accounts', 'instagram-slider-widget' ),
180
- 'content' => $this->instagram->content(),
181
  ],
182
  'facebook' => [
183
  'title' => __( 'Facebook', 'instagram-slider-widget' ),
184
  'description' => __( 'Manage Facebook accounts', 'instagram-slider-widget' ),
185
- 'content' => $this->facebook->content(),
186
  ],
187
  'youtube' => [
188
  'title' => __( 'Youtube', 'instagram-slider-widget' ),
189
  'description' => __( 'Manage Youtube accounts', 'instagram-slider-widget' ),
190
- 'content' => $this->youtube->content(),
191
  ],
192
  ];
193
 
83
 
84
  $this->plugin = $plugin;
85
 
86
+ $this->instagram = class_exists( 'WIS_Instagram_Profiles' ) ? new WIS_Instagram_Profiles( $this ) : null;
87
+ $this->facebook = class_exists( 'WIS_Facebook_Profiles' ) ? new WIS_Facebook_Profiles( $this ) : null;
88
+ $this->youtube = class_exists( 'WIS_Youtube_Profiles' ) ? new WIS_Youtube_Profiles( $this ) : null;
89
 
90
  }
91
 
177
  'instagram' => [
178
  'title' => __( 'Instagram', 'instagram-slider-widget' ),
179
  'description' => __( 'Manage Instagram accounts', 'instagram-slider-widget' ),
180
+ 'content' => isset( $this->instagram ) ? $this->instagram->content() : '',
181
  ],
182
  'facebook' => [
183
  'title' => __( 'Facebook', 'instagram-slider-widget' ),
184
  'description' => __( 'Manage Facebook accounts', 'instagram-slider-widget' ),
185
+ 'content' => isset( $this->facebook ) ? $this->facebook->content() : '',
186
  ],
187
  'youtube' => [
188
  'title' => __( 'Youtube', 'instagram-slider-widget' ),
189
  'description' => __( 'Manage Youtube accounts', 'instagram-slider-widget' ),
190
+ 'content' => isset( $this->youtube ) ? $this->youtube->content() : '',
191
  ],
192
  ];
193
 
admin/pages/widgets.php CHANGED
@@ -93,8 +93,8 @@ class WIS_WidgetsPage extends WIS_Page {
93
  */
94
  public function __construct( $plugin ) {
95
  $this->id = "widgets";
96
- $this->page_title = __( 'Social Slider Feeds', 'instagram-slider-widget' );
97
- $this->menu_title = __( 'Social Slider Feeds', 'instagram-slider-widget' );
98
  $this->menu_sub_title = __( 'Widgets', 'instagram-slider-widget' );
99
  $this->menu_tab_title = __( 'Widgets', 'instagram-slider-widget' );
100
  $this->menu_icon = '~/admin/assets/img/wis.png';
93
  */
94
  public function __construct( $plugin ) {
95
  $this->id = "widgets";
96
+ $this->page_title = __( 'Social Slider Feed', 'instagram-slider-widget' );
97
+ $this->menu_title = __( 'Social Slider Feed', 'instagram-slider-widget' );
98
  $this->menu_sub_title = __( 'Widgets', 'instagram-slider-widget' );
99
  $this->menu_tab_title = __( 'Widgets', 'instagram-slider-widget' );
100
  $this->menu_icon = '~/admin/assets/img/wis.png';
components/facebook/assets/admin/js/wfacebook-admin.js CHANGED
@@ -9,14 +9,14 @@
9
  var modalOverlay = jQuery('#wis_modal_overlay');
10
  var spinOverlay = jQuery('.wis-overlay-spinner');
11
 
12
- modalOverlay.on("click", function () {
13
  var conf = confirm("You haven't finished adding an account. Are you sure you want to close the window?");
14
  if (conf) {
15
  modal.toggleClass("wis_closed");
16
  modalOverlay.toggleClass("wis_closed");
17
  spinOverlay.toggleClass("is-active");
18
  }
19
- });
20
 
21
  jQuery('.wis_modal_content #wis-facebook-row').on('click', function (e) {
22
  modal.toggleClass("wis_closed");
9
  var modalOverlay = jQuery('#wis_modal_overlay');
10
  var spinOverlay = jQuery('.wis-overlay-spinner');
11
 
12
+ /*modalOverlay.on("click", function () {
13
  var conf = confirm("You haven't finished adding an account. Are you sure you want to close the window?");
14
  if (conf) {
15
  modal.toggleClass("wis_closed");
16
  modalOverlay.toggleClass("wis_closed");
17
  spinOverlay.toggleClass("is-active");
18
  }
19
+ });*/
20
 
21
  jQuery('.wis_modal_content #wis-facebook-row').on('click', function (e) {
22
  modal.toggleClass("wis_closed");
components/facebook/html_templates/accounts.php CHANGED
@@ -11,65 +11,69 @@ $social = $args['social'];
11
  <div id="wis-add-account-button" class="">
12
  <?php
13
  if ( count( $accounts ) && ! $is_premium ) : ?>
14
- <span class="wis-btn-facebook-account btn-instagram-account-disabled">
15
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?></span>
16
- <span class="instagram-account-pro"><?php echo sprintf( __( "More accounts in <a href='%s'>PRO version</a>", 'instagram-slider-widget' ), WIS_Plugin::app()->get_support()->get_pricing_url( true, "wis_settings" ) ); ?></span>
17
  <?php else: ?>
18
- <a class="wis-btn-facebook-account" target="_self" href="<?php echo $authorize_url; ?>"
19
- title="Add Account">
20
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?>
21
- </a>
22
- <span style="float: none; margin-top: 0;" class="spinner" id="wis-spinner"> </span>
23
  <?php endif; ?>
24
  </div>
25
  <?php
26
  if ( ! empty( $accounts ) ) :
27
  ?>
28
- <br>
29
- <table class="widefat wis-table">
30
- <thead>
31
- <tr>
32
- <th class="wis-profile-picture"><?php echo __( 'Image', 'instagram-slider-widget' ); ?></th>
33
- <th class="wis-profile-id"><?php echo __( 'ID', 'instagram-slider-widget' ); ?></th>
34
- <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
35
- <th class="wis-profile-token"><?php echo __( 'Token', 'instagram-slider-widget' ); ?></th>
36
- <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
37
- </tr>
38
- </thead>
39
- <tbody>
40
  <?php
41
  foreach ( $accounts as $key => $profile_info ) {
42
- $delete_link = $this->getActionUrl( 'delete', [ 'social' => $social, 'account' => $key ] );
43
- $image = $profile_info['avatar'];
44
- $fullname = $profile_info['name'];
 
 
 
 
45
  ?>
46
- <tr>
47
- <td class="wis-profile-picture">
48
- <img src="<?php echo esc_url( $image ); ?>"
49
- width="30" alt=""/>
50
- </td>
51
- <td class="wis-profile-id"><?php echo esc_attr( $profile_info['id'] ); ?></td>
52
- <td class="wis-profile-name">
53
- <a href="https://www.facebook.com/<?php echo esc_html( $profile_info['id'] ); ?>"><?php echo esc_html( $profile_info['name'] ); ?></a>
54
- </td>
55
- <td class="wis-profile-token">
56
- <input id="<?php echo esc_attr( $profile_info['id'] ); ?>-facebook-access-token"
57
- type="text"
58
- value="<?php echo esc_attr( $profile_info['token'] ); ?>"
59
- class="wis-text-token" readonly/>
60
- </td>
61
- <td class="wis-profile-actions">
62
- <a href="<?php echo $delete_link; ?>" class="btn btn-danger wfb-delete-account">
63
- <span class="dashicons dashicons-trash"></span><?php echo __( 'Delete', 'instagram-slider-widget' ); ?>
64
- </a>
65
- <span class="spinner"
66
- id="wis-delete-spinner-<?php echo esc_attr( $profile_info['id'] ); ?>"></span>
67
- </td>
68
- </tr>
69
  <?php
70
  }
71
  ?>
72
- </tbody>
73
- </table>
74
  <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
75
  <?php endif; ?>
11
  <div id="wis-add-account-button" class="">
12
  <?php
13
  if ( count( $accounts ) && ! $is_premium ) : ?>
14
+ <span class="wis-btn-facebook-account btn-instagram-account-disabled">
15
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?></span>
16
+ <span class="instagram-account-pro"><?php echo sprintf( __( "More accounts in <a href='%s'>PRO version</a>", 'instagram-slider-widget' ), WIS_Plugin::app()->get_support()->get_pricing_url( true, "wis_settings" ) ); ?></span>
17
  <?php else: ?>
18
+ <a class="wis-btn-facebook-account" target="_self" href="<?php echo $authorize_url; ?>"
19
+ title="Add Account">
20
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?>
21
+ </a>
22
+ <span style="float: none; margin-top: 0;" class="spinner" id="wis-spinner"> </span>
23
  <?php endif; ?>
24
  </div>
25
  <?php
26
  if ( ! empty( $accounts ) ) :
27
  ?>
28
+ <br>
29
+ <table class="widefat wis-table">
30
+ <thead>
31
+ <tr>
32
+ <th class="wis-profile-picture"><?php echo __( 'Image', 'instagram-slider-widget' ); ?></th>
33
+ <th class="wis-profile-id"><?php echo __( 'ID', 'instagram-slider-widget' ); ?></th>
34
+ <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
35
+ <th class="wis-profile-token"><?php echo __( 'Token', 'instagram-slider-widget' ); ?></th>
36
+ <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
37
+ </tr>
38
+ </thead>
39
+ <tbody>
40
  <?php
41
  foreach ( $accounts as $key => $profile_info ) {
42
+ $delete_link = wp_nonce_url( $this->getActionUrl( 'delete', [
43
+ 'social' => $social,
44
+ 'account' => $key,
45
+ ] ), 'wis_delete_profile', 'nonce' );
46
+
47
+ $image = $profile_info['avatar'];
48
+ $fullname = $profile_info['name'];
49
  ?>
50
+ <tr>
51
+ <td class="wis-profile-picture">
52
+ <img src="<?php echo esc_url( $image ); ?>"
53
+ width="30" alt=""/>
54
+ </td>
55
+ <td class="wis-profile-id"><?php echo esc_attr( $profile_info['id'] ); ?></td>
56
+ <td class="wis-profile-name">
57
+ <a href="https://www.facebook.com/<?php echo esc_html( $profile_info['id'] ); ?>"><?php echo esc_html( $profile_info['name'] ); ?></a>
58
+ </td>
59
+ <td class="wis-profile-token">
60
+ <input id="<?php echo esc_attr( $profile_info['id'] ); ?>-facebook-access-token"
61
+ type="text"
62
+ value="<?php echo esc_attr( $profile_info['token'] ); ?>"
63
+ class="wis-text-token" readonly/>
64
+ </td>
65
+ <td class="wis-profile-actions">
66
+ <a href="<?php echo $delete_link; ?>" class="btn btn-danger wfb-delete-account">
67
+ <span class="dashicons dashicons-trash"></span><?php echo __( 'Delete', 'instagram-slider-widget' ); ?>
68
+ </a>
69
+ <span class="spinner"
70
+ id="wis-delete-spinner-<?php echo esc_attr( $profile_info['id'] ); ?>"></span>
71
+ </td>
72
+ </tr>
73
  <?php
74
  }
75
  ?>
76
+ </tbody>
77
+ </table>
78
  <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
79
  <?php endif; ?>
components/facebook/html_templates/feeds.php CHANGED
@@ -7,55 +7,62 @@
7
  */
8
  ?>
9
  <div class="wisw-social-content">
10
- <div class="wisw-container-row">
11
- <a href="<?php echo $this->getActionUrl( 'add', [ 'social' => $social ] ); ?>"
12
- class="button action wis-add-feed-button"><?php _e( 'Add feed', 'instagram-slider-widget' ); ?></a>
13
- </div>
14
 
15
- <div class="wisw-container-row">
16
- <table class="widefat wis-table wis-personal-status">
17
- <thead>
18
- <tr>
19
- <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
20
- <th class="wis-profile-shortcode"><label for="wis_facebook_shortcode"><?php echo __( 'Shortcode', 'instagram-slider-widget' ); ?></label></th>
21
- <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
22
- </tr>
23
- </thead>
24
- <tbody>
 
 
25
  <?php
26
  if ( count( $feeds ) ) :
27
  foreach ( $feeds as $feed_id => $feed ) {
28
  $edit_link = $this->getActionUrl( 'edit', [ 'social' => $social, 'feed' => $feed_id ] );
29
- $delete_link = $this->getActionUrl( 'delete', [ 'social' => $social, 'feed' => $feed_id ] );
 
 
 
30
  ?>
31
- <tr>
32
- <td class="wis-profile-name">
33
- <a href="<?php echo $edit_link; ?>">
34
  <?php echo $feed->title; ?>
35
- </a>
36
- </td>
37
- <td class="wis-profile-shortcode">
38
- <input id="wis_facebook_shortcode" onclick="this.setSelectionRange(0, this.value.length)" type="text" class="form-input wis-shortcode-input"
39
- value="[cm_facebook_feed id=&quot;<?php echo $feed_id ?>&quot;]" readonly="readonly">
40
- </td>
41
- <td class="wis-profile-actions">
42
- <a href="<?php echo $edit_link; ?>" class="btn btn-primary">
43
- <span class="dashicons dashicons-edit"></span>
44
- </a>
45
- <a href="<?php echo $delete_link; ?>" class="btn btn-danger">
46
- <span class="dashicons dashicons-trash"></span>
47
- </a>
48
- </td>
49
- </tr>
 
50
  <?php
51
  }
52
  ?>
53
  <?php else: ?>
54
- <tr>
55
- <td class="wis-profile-nofeed" colspan="3"><?php echo __( 'No feeds', 'instagram-slider-widget' ); ?></td>
56
- </tr>
 
57
  <?php endif; ?>
58
- </tbody>
59
- </table>
60
- </div>
61
  </div>
7
  */
8
  ?>
9
  <div class="wisw-social-content">
10
+ <div class="wisw-container-row">
11
+ <a href="<?php echo $this->getActionUrl( 'add', [ 'social' => $social ] ); ?>"
12
+ class="button action wis-add-feed-button"><?php _e( 'Add feed', 'instagram-slider-widget' ); ?></a>
13
+ </div>
14
 
15
+ <div class="wisw-container-row">
16
+ <table class="widefat wis-table wis-personal-status">
17
+ <thead>
18
+ <tr>
19
+ <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
20
+ <th class="wis-profile-shortcode"><label
21
+ for="wis_facebook_shortcode"><?php echo __( 'Shortcode', 'instagram-slider-widget' ); ?></label>
22
+ </th>
23
+ <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
  <?php
28
  if ( count( $feeds ) ) :
29
  foreach ( $feeds as $feed_id => $feed ) {
30
  $edit_link = $this->getActionUrl( 'edit', [ 'social' => $social, 'feed' => $feed_id ] );
31
+ $delete_link = wp_nonce_url( $this->getActionUrl( 'delete', [
32
+ 'social' => $social,
33
+ 'feed' => $feed_id,
34
+ ] ), 'wis_delete_feed', 'nonce' );
35
  ?>
36
+ <tr>
37
+ <td class="wis-profile-name">
38
+ <a href="<?php echo $edit_link; ?>">
39
  <?php echo $feed->title; ?>
40
+ </a>
41
+ </td>
42
+ <td class="wis-profile-shortcode">
43
+ <input id="wis_facebook_shortcode" onclick="this.setSelectionRange(0, this.value.length)"
44
+ type="text" class="form-input wis-shortcode-input"
45
+ value="[cm_facebook_feed id=&quot;<?php echo $feed_id ?>&quot;]" readonly="readonly">
46
+ </td>
47
+ <td class="wis-profile-actions">
48
+ <a href="<?php echo $edit_link; ?>" class="btn btn-primary">
49
+ <span class="dashicons dashicons-edit"></span>
50
+ </a>
51
+ <a href="<?php echo $delete_link; ?>" class="btn btn-danger">
52
+ <span class="dashicons dashicons-trash"></span>
53
+ </a>
54
+ </td>
55
+ </tr>
56
  <?php
57
  }
58
  ?>
59
  <?php else: ?>
60
+ <tr>
61
+ <td class="wis-profile-nofeed"
62
+ colspan="3"><?php echo __( 'No feeds', 'instagram-slider-widget' ); ?></td>
63
+ </tr>
64
  <?php endif; ?>
65
+ </tbody>
66
+ </table>
67
+ </div>
68
  </div>
components/facebook/html_templates/masonry.php CHANGED
@@ -27,12 +27,6 @@ $i = 1;
27
  </div>
28
  <?php endif; ?>
29
  <div class="wbfb_masonry_post_body">
30
- <div class="wbfb_masonry_post_text">
31
- <a <?php echo 'fb_link' == $args['fbimages_link'] ? "href='https://facebook.com/$post->id' target='_blank'" : '' ?>
32
- data-remodal-target="<?php echo $post->id ?>" class="wbfb_popup_link">
33
- <?php echo $post->message ?>
34
- </a>
35
- </div>
36
  <?php if ( ! empty( $post->attachments ) ) : ?>
37
  <?php foreach ( $post->attachments as $attachment ) : ?>
38
  <a <?php echo 'fb_link' == $args['fbimages_link'] ? "href='https://facebook.com/$post->id' target='_blank'" : '' ?>
@@ -64,6 +58,14 @@ $i = 1;
64
  </a>
65
  <?php endforeach; ?>
66
  <?php endif; ?>
 
 
 
 
 
 
 
 
67
  </div>
68
  <div class="wbfb_masonry_post_footer">
69
  <div class="wbfb_masonry_post_share">
27
  </div>
28
  <?php endif; ?>
29
  <div class="wbfb_masonry_post_body">
 
 
 
 
 
 
30
  <?php if ( ! empty( $post->attachments ) ) : ?>
31
  <?php foreach ( $post->attachments as $attachment ) : ?>
32
  <a <?php echo 'fb_link' == $args['fbimages_link'] ? "href='https://facebook.com/$post->id' target='_blank'" : '' ?>
58
  </a>
59
  <?php endforeach; ?>
60
  <?php endif; ?>
61
+ <!--
62
+ <div class="wbfb_masonry_post_text">
63
+ <a <?php echo 'fb_link' == $args['fbimages_link'] ? "href='https://facebook.com/$post->id' target='_blank'" : '' ?>
64
+ data-remodal-target="<?php echo $post->id ?>" class="wbfb_popup_link">
65
+ <?php echo $post->message ?>
66
+ </a>
67
+ </div>-->
68
+
69
  </div>
70
  <div class="wbfb_masonry_post_footer">
71
  <div class="wbfb_masonry_post_share">
components/facebook/includes/Api/facebook-api.php CHANGED
@@ -1,94 +1,94 @@
1
- <?php
2
-
3
- namespace WIS\Facebook\Includes\Api;
4
-
5
- use PHPMailer\PHPMailer\Exception;
6
- use WIS\Facebook\Includes\Api\FacebookAccount;
7
-
8
- class WFB_Facebook_API {
9
-
10
- const FACEBOOK_SELF_URL = 'https://graph.facebook.com/';
11
-
12
-
13
- /**
14
- * Stores the fetched data from Facebook in WordPress DB using transients
15
- *
16
- * @param FacebookAccount $account Facebook page name to fetch
17
- * @param string $cache_hours Cache hours for transient
18
- * @param string $nr_images Nr of images to fetch
19
- * @param \WIS_Facebook_Feed $widget
20
- *
21
- * @return string|array of localy saved facebook data
22
- */
23
- public function get_data( $account, $cache_hours, $nr_images, $feed ) {
24
-
25
- $opt_name = 'jr_facebook_' . md5( $account->id );
26
- $fbData = get_transient( $opt_name );
27
- $old_opts = (array) get_option( $opt_name );
28
- $new_opts = [
29
- 'search_string' => $account->id,
30
- 'cache_hours' => $cache_hours,
31
- 'nr_images' => $nr_images,
32
- ];
33
-
34
- if ( true === $feed->trigger_refresh_data( $fbData, $old_opts, $new_opts ) ) {
35
- //if ( true ) {
36
- $old_opts['search_string'] = $account->id;
37
- $old_opts['cache_hours'] = $cache_hours;
38
- $old_opts['nr_images'] = $nr_images;
39
- $nr_images = ! \WIS_Plugin::app()->is_premium() && $nr_images > 20 ? 20 : $nr_images;
40
-
41
- $fields = "id,created_time,child_attachments,shares,sharedposts{message,full_picture,created_time},comments{comments_count},message,full_picture,picture,attachments{media_type,media,title,type,url}"; //,comments.summary(true)
42
-
43
- if ( ! $account->is_me ) {
44
- $fields .= ",likes.summary(true)";
45
- }
46
-
47
- $args = [
48
- 'access_token' => $account->token,
49
- 'fields' => $fields,
50
- 'limit' => $nr_images,
51
- ];
52
-
53
- $url = WFB_FACEBOOK_SELF_URL . $account->id . "/feed";
54
- $response = wp_remote_get( add_query_arg( $args, $url ) );
55
- if ( is_wp_error( $response ) ) {
56
- return [ 'error' => __( 'Something went wrong', 'instagram-slider-widget' ) ];
57
- }
58
- if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
59
- try {
60
- $entry_data = $this->get_posts_from_json( $response['body'] );
61
- } catch ( Exception $exception ) {
62
- error_log( "SSW ERROR: " . $exception->getTraceAsString() );
63
-
64
- return [ 'error' => __( 'API ERROR: Failed to parse data.', 'instagram-slider-widget' ) ];
65
- }
66
-
67
- update_option( $opt_name, $old_opts );
68
- set_transient( $opt_name, $entry_data, $cache_hours * 60 * 60 );
69
- } else {
70
- return [ 'error' => __( 'Something went wrong. API error', 'instagram-slider-widget' ) ];
71
- }
72
- }
73
-
74
- return $entry_data;
75
- }
76
-
77
- /**
78
- * @param string $json
79
- *
80
- * @return \WIS\Facebook\Includes\Api\WFB_Facebook_Post[]
81
- */
82
- public function get_posts_from_json( $json ) {
83
- $posts = [];
84
-
85
- $json_posts = json_decode( $json );
86
-
87
- foreach ( $json_posts->data as $json_post ) {
88
- $post = ( new WFB_Facebook_Post() )->get_facebook_post_from_object( $json_post );
89
- $posts[ $post->id ] = $post;
90
- }
91
-
92
- return $posts;
93
- }
94
- }
1
+ <?php
2
+
3
+ namespace WIS\Facebook\Includes\Api;
4
+
5
+ use PHPMailer\PHPMailer\Exception;
6
+ use WIS\Facebook\Includes\Api\FacebookAccount;
7
+
8
+ class WFB_Facebook_API {
9
+
10
+ const FACEBOOK_SELF_URL = 'https://graph.facebook.com/';
11
+
12
+
13
+ /**
14
+ * Stores the fetched data from Facebook in WordPress DB using transients
15
+ *
16
+ * @param FacebookAccount $account Facebook page name to fetch
17
+ * @param string $cache_hours Cache hours for transient
18
+ * @param string $nr_images Nr of images to fetch
19
+ * @param \WIS_Facebook_Feed $widget
20
+ *
21
+ * @return string|array of localy saved facebook data
22
+ */
23
+ public function get_data( $account, $cache_hours, $nr_images, $feed ) {
24
+
25
+ $opt_name = 'jr_facebook_' . md5( $account->id );
26
+ $fbData = get_transient( $opt_name );
27
+ $old_opts = (array) get_option( $opt_name );
28
+ $new_opts = [
29
+ 'search_string' => $account->id,
30
+ 'cache_hours' => $cache_hours,
31
+ 'nr_images' => $nr_images,
32
+ ];
33
+
34
+ if ( true === $feed->trigger_refresh_data( $fbData, $old_opts, $new_opts ) ) {
35
+ //if ( true ) {
36
+ $old_opts['search_string'] = $account->id;
37
+ $old_opts['cache_hours'] = $cache_hours;
38
+ $old_opts['nr_images'] = $nr_images;
39
+ $nr_images = ! \WIS_Plugin::app()->is_premium() && $nr_images > 20 ? 20 : $nr_images;
40
+
41
+ $fields = 'id,created_time,child_attachments,shares,sharedposts{message,full_picture,created_time},comments{comments_count},message,full_picture,picture,attachments{media_type,media,title,type,url}'; //,comments.summary(true)
42
+
43
+ if ( ! $account->is_me ) {
44
+ $fields .= ',likes.summary(true)';
45
+ }
46
+
47
+ $args = [
48
+ 'access_token' => $account->token,
49
+ 'fields' => $fields,
50
+ 'limit' => $nr_images,
51
+ ];
52
+
53
+ $url = WFB_FACEBOOK_SELF_URL . $account->id . '/feed';
54
+ $response = wp_remote_get( add_query_arg( $args, $url ) );
55
+ if ( is_wp_error( $response ) ) {
56
+ return [ 'error' => __( 'Something went wrong', 'instagram-slider-widget' ) ];
57
+ }
58
+ if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
59
+ try {
60
+ $entry_data = $this->get_posts_from_json( $response['body'] );
61
+ } catch ( Exception $exception ) {
62
+ error_log( 'SSW ERROR: ' . $exception->getTraceAsString() );
63
+
64
+ return [ 'error' => __( 'API ERROR: Failed to parse data.', 'instagram-slider-widget' ) ];
65
+ }
66
+
67
+ update_option( $opt_name, $old_opts );
68
+ set_transient( $opt_name, $entry_data, $cache_hours * 60 * 60 );
69
+ } else {
70
+ return [ 'error' => __( 'Something went wrong. API error', 'instagram-slider-widget' ) ];
71
+ }
72
+ }
73
+
74
+ return $entry_data;
75
+ }
76
+
77
+ /**
78
+ * @param string $json
79
+ *
80
+ * @return \WIS\Facebook\Includes\Api\WFB_Facebook_Post[]
81
+ */
82
+ public function get_posts_from_json( $json ) {
83
+ $posts = [];
84
+
85
+ $json_posts = json_decode( $json );
86
+
87
+ foreach ( $json_posts->data as $json_post ) {
88
+ $post = ( new WFB_Facebook_Post() )->get_facebook_post_from_object( $json_post );
89
+ $posts[ $post->id ] = $post;
90
+ }
91
+
92
+ return $posts;
93
+ }
94
+ }
components/facebook/includes/class-facebook-profiles.php CHANGED
@@ -46,11 +46,11 @@ class WIS_Facebook_Profiles extends WIS_Profiles {
46
 
47
  $connected_profiles = WIS_Plugin::app()->getOption( $this->profiles_option_name, [] );
48
  $connected_profiles[ $account['name'] ] = [
49
- 'name' => $account['name'],
50
- 'avatar' => $account['picture']['data']['url'],
51
- 'id' => $account['id'],
52
- 'token' => $account['access_token'],
53
- 'is_me' => $account['is_me'],
54
  ];
55
  WIS_Plugin::app()->updateOption( $this->profiles_option_name, $connected_profiles );
56
 
@@ -69,19 +69,18 @@ class WIS_Facebook_Profiles extends WIS_Profiles {
69
  $html = '';
70
  if ( $access_token ) {
71
  $args = [
72
- 'access_token' => $access_token,
73
- 'fields' => 'name,picture',
74
- 'limit' => 200,
75
  ];
76
 
77
  $connected_profiles = [];
78
 
79
  $url = WFB_FACEBOOK_SELF_URL . "me/accounts";
80
- $response = wp_remote_get( esc_url_raw(add_query_arg( $args, $url )) );
81
  if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
82
  $pages = json_decode( wp_remote_retrieve_body( $response ), true );
83
  foreach ( $pages['data'] as $profile ) {
84
- $profile['access_token'] = $access_token;
85
  $profile['is_me'] = false;
86
  $connected_profiles[ $profile['name'] ] = $profile;
87
  }
@@ -106,23 +105,23 @@ class WIS_Facebook_Profiles extends WIS_Profiles {
106
  public function content() {
107
  if ( isset( $_GET['tab'] ) && 'facebook' === $_GET['tab'] ) {
108
  if ( isset( $_GET['token_error'] ) ) {
109
- $_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url(remove_query_arg( 'token_error' )) );
110
  } else {
111
  if ( isset( $_GET['access_token'] ) ) {
112
  $token = $_GET['access_token'];
113
  $choose_account_html = $this->update_profiles( $token );
114
- $_SERVER['REQUEST_URI'] = esc_url(remove_query_arg( 'access_token' ));
115
  ?>
116
- <div id="wis_accounts_modal" class="wis_accounts_modal">
117
- <div class="wis_modal_header">
118
- Choose Account:
119
- </div>
120
- <div class="wis_modal_content">
121
  <?php echo $choose_account_html; ?>
122
- </div>
123
- </div>
124
- <div id="wis_modal_overlay" class="wis_modal_overlay"></div>
125
- <span class="wis-overlay-spinner is-active">&nbsp;</span>
126
  <?php
127
  }
128
  }
@@ -131,13 +130,13 @@ class WIS_Facebook_Profiles extends WIS_Profiles {
131
  $accounts = WIS_Plugin::app()->getPopulateOption( WIS_FACEBOOK_ACCOUNT_PROFILES_OPTION_NAME, [] );
132
 
133
  $data = [
134
- 'is_premium' => WIS_Plugin::app()->is_premium(),
135
- 'authorize_url' => "https://instagram.cm-wp.com/facebook?" . http_build_query( [
136
- "app_id" => WIS_FACEBOOK_CLIENT_ID,
137
- "state" => $this->getSocialUrl(),
138
- ] ),
139
- 'accounts' => $accounts,
140
- 'social' => $this->social,
141
  ];
142
 
143
  $result = $this->page->render( WFB_COMPONENT_VIEWS_DIR . '/accounts', $data );
@@ -146,6 +145,8 @@ class WIS_Facebook_Profiles extends WIS_Profiles {
146
  }
147
 
148
  public function delete_account( $name ) {
 
 
149
  $accounts = WIS_Plugin::app()->getOption( $this->profiles_option_name, [] );
150
  if ( isset( $accounts[ $name ] ) ) {
151
  unset( $accounts[ $name ] );
46
 
47
  $connected_profiles = WIS_Plugin::app()->getOption( $this->profiles_option_name, [] );
48
  $connected_profiles[ $account['name'] ] = [
49
+ 'name' => $account['name'],
50
+ 'avatar' => $account['picture']['data']['url'],
51
+ 'id' => $account['id'],
52
+ 'token' => $account['access_token'],
53
+ 'is_me' => $account['is_me'],
54
  ];
55
  WIS_Plugin::app()->updateOption( $this->profiles_option_name, $connected_profiles );
56
 
69
  $html = '';
70
  if ( $access_token ) {
71
  $args = [
72
+ 'access_token' => $access_token,
73
+ 'fields' => 'name,picture,access_token',
74
+ 'limit' => 200,
75
  ];
76
 
77
  $connected_profiles = [];
78
 
79
  $url = WFB_FACEBOOK_SELF_URL . "me/accounts";
80
+ $response = wp_remote_get( esc_url_raw( add_query_arg( $args, $url ) ) );
81
  if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
82
  $pages = json_decode( wp_remote_retrieve_body( $response ), true );
83
  foreach ( $pages['data'] as $profile ) {
 
84
  $profile['is_me'] = false;
85
  $connected_profiles[ $profile['name'] ] = $profile;
86
  }
105
  public function content() {
106
  if ( isset( $_GET['tab'] ) && 'facebook' === $_GET['tab'] ) {
107
  if ( isset( $_GET['token_error'] ) ) {
108
+ $_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url( remove_query_arg( 'token_error' ) ) );
109
  } else {
110
  if ( isset( $_GET['access_token'] ) ) {
111
  $token = $_GET['access_token'];
112
  $choose_account_html = $this->update_profiles( $token );
113
+ $_SERVER['REQUEST_URI'] = esc_url( remove_query_arg( 'access_token' ) );
114
  ?>
115
+ <div id="wis_accounts_modal" class="wis_accounts_modal">
116
+ <div class="wis_modal_header">
117
+ Choose Account:
118
+ </div>
119
+ <div class="wis_modal_content">
120
  <?php echo $choose_account_html; ?>
121
+ </div>
122
+ </div>
123
+ <div id="wis_modal_overlay" class="wis_modal_overlay"></div>
124
+ <span class="wis-overlay-spinner is-active">&nbsp;</span>
125
  <?php
126
  }
127
  }
130
  $accounts = WIS_Plugin::app()->getPopulateOption( WIS_FACEBOOK_ACCOUNT_PROFILES_OPTION_NAME, [] );
131
 
132
  $data = [
133
+ 'is_premium' => WIS_Plugin::app()->is_premium(),
134
+ 'authorize_url' => "https://instagram.cm-wp.com/facebook?" . http_build_query( [
135
+ "app_id" => WIS_FACEBOOK_CLIENT_ID,
136
+ "state" => $this->getSocialUrl(),
137
+ ] ),
138
+ 'accounts' => $accounts,
139
+ 'social' => $this->social,
140
  ];
141
 
142
  $result = $this->page->render( WFB_COMPONENT_VIEWS_DIR . '/accounts', $data );
145
  }
146
 
147
  public function delete_account( $name ) {
148
+ check_admin_referer( 'wis_delete_profile', 'nonce' );
149
+
150
  $accounts = WIS_Plugin::app()->getOption( $this->profiles_option_name, [] );
151
  if ( isset( $accounts[ $name ] ) ) {
152
  unset( $accounts[ $name ] );
components/facebook/load.php CHANGED
@@ -8,7 +8,7 @@ define( 'WFB_COMPONENT_VIEWS_DIR', WFB_COMPONENT_DIR . '/html_templates' );
8
 
9
  define( 'WIS_FACEBOOK_ACCOUNT_PROFILES_OPTION_NAME', 'facebook_account_profiles' );
10
 
11
- define( 'WFB_FACEBOOK_SELF_URL', 'https://graph.facebook.com/v7.0/' );
12
 
13
  require_once WFB_COMPONENT_DIR . "/includes/functions.php";
14
  require_once WFB_COMPONENT_DIR . "/includes/Api/facebook-account.php";
8
 
9
  define( 'WIS_FACEBOOK_ACCOUNT_PROFILES_OPTION_NAME', 'facebook_account_profiles' );
10
 
11
+ define( 'WFB_FACEBOOK_SELF_URL', 'https://graph.facebook.com/v15.0/' );
12
 
13
  require_once WFB_COMPONENT_DIR . "/includes/functions.php";
14
  require_once WFB_COMPONENT_DIR . "/includes/Api/facebook-account.php";
components/instagram/assets/admin/js/instagram-scripts.js CHANGED
@@ -1,49 +1,46 @@
1
  (function ($) {
2
- $(document).ready(function ($) {
3
- var modal = jQuery('#wis_accounts_modal');
4
- var modalOverlay = jQuery('#wis_modal_overlay');
5
- var spinOverlay = jQuery('.wis-overlay-spinner');
6
 
7
- modalOverlay.on("click", function () {
8
- var conf = confirm("You haven't finished adding an account. Are you sure you want to close the window?");
9
- if (conf) {
10
- modal.toggleClass("wis_closed");
11
- modalOverlay.toggleClass("wis_closed");
12
- spinOverlay.toggleClass("is-active");
13
- }
14
- });
15
 
16
- jQuery('.wis_modal_content #wis-instagram-row').on('click', function (e) {
17
- modal.toggleClass("wis_closed");
18
- spinOverlay.addClass('is-active');
19
- wis_account = $(this).attr('data-account');
20
- jQuery.post(ajaxurl, {
21
- action: 'wis_add_account_by_token',
22
- account: wis_account,
23
- _ajax_nonce: wig.nonce
24
- }).done(function (html) {
25
- //console.log(html);
26
- window.location.reload();
27
- });
28
- });
29
 
30
- /*
31
- * Chose API to add account
32
- * */
33
- var modal2 = jQuery('#wis_add_account_modal');
34
- var modal2Overlay = jQuery('#wis_add_account_modal_overlay');
35
- modal2Overlay.on("click", function () {
36
- var conf = confirm("You haven't finished adding an account. Are you sure you want to close the window?");
37
- if (conf) {
38
- modal2.toggleClass("wis_closed");
39
- modal2Overlay.toggleClass("wis_closed");
40
- }
41
- });
42
 
43
- jQuery('#wis-add-account-button .wis-btn-instagram-account').on('click', function (e) {
44
- e.preventDefault();
45
- modal2.removeClass('wis_closed');
46
- modal2Overlay.removeClass('wis_closed');
47
- });
48
- }); // Document Ready
49
  })(jQuery);
1
  (function ($) {
2
+ $(document).ready(function ($) {
3
+ var modal = jQuery('#wis_accounts_modal');
4
+ var modalOverlay = jQuery('#wis_modal_overlay');
5
+ var spinOverlay = jQuery('.wis-overlay-spinner');
6
 
7
+ modalOverlay.on("click", function () {
8
+ var conf = confirm("You haven't finished adding an account. Are you sure you want to close the window?");
9
+ if (conf) {
10
+ modal.toggleClass("wis_closed");
11
+ modalOverlay.toggleClass("wis_closed");
12
+ spinOverlay.toggleClass("is-active");
13
+ }
14
+ });
15
 
16
+ jQuery('.wis_modal_content #wis-instagram-row').on('click', function (e) {
17
+ modal.toggleClass("wis_closed");
18
+ spinOverlay.addClass('is-active');
19
+ wis_account = $(this).attr('data-account');
20
+ jQuery.post(ajaxurl, {
21
+ action: 'wis_add_account_by_token',
22
+ account: wis_account,
23
+ _ajax_nonce: wig.nonce
24
+ }).done(function (html) {
25
+ //console.log(html);
26
+ window.location.reload();
27
+ });
28
+ });
29
 
30
+ /*
31
+ * Chose API to add account
32
+ * */
33
+ var modal2 = jQuery('#wis_add_account_modal');
34
+ var modal2Overlay = jQuery('#wis_add_account_modal_overlay');
35
+ modal2Overlay.on("click", function () {
36
+ modal2.toggleClass("wis_closed");
37
+ modal2Overlay.toggleClass("wis_closed");
38
+ });
 
 
 
39
 
40
+ jQuery('#wis-add-account-button .wis-btn-instagram-account').on('click', function (e) {
41
+ e.preventDefault();
42
+ modal2.removeClass('wis_closed');
43
+ modal2Overlay.removeClass('wis_closed');
44
+ });
45
+ }); // Document Ready
46
  })(jQuery);
components/instagram/html_templates/accounts.php CHANGED
@@ -9,139 +9,151 @@
9
  */
10
 
11
  $social = $args['social'];
 
12
  $count_accounts = count( $accounts ) + count( $accounts_business );
13
  ?>
 
14
  <div id="wis-add-account-button" class="">
15
  <?php
16
  if ( $count_accounts >= 1 && ! $is_premium ) : ?>
17
- <span class="wis-btn-instagram-account-disabled btn-instagram-account-disabled">
18
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?></span>
19
- <span class="instagram-account-pro"><?php echo sprintf( __( "More accounts in <a href='%s'>PRO version</a>", 'instagram-slider-widget' ), WIS_Plugin::app()->get_support()->get_pricing_url( true, "wis_settings" ) ); ?></span>
20
  <?php else: ?>
21
- <a class="wis-btn-instagram-account" target="_self" href="#" title="Add Account">
22
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?>
23
- </a>
24
- <span style="float: none; margin-top: 0;" class="spinner" id="wis-spinner"> </span>
25
  <?php endif; ?>
26
  </div>
27
  <!-- Personal accounts -->
28
  <?php
29
  if ( count( $accounts ) ) :
30
  ?>
31
- <div class="wis-social-group"><?php echo __( 'Personal Accounts', 'instagram-slider-widget' ); ?></div>
32
- <table class="widefat wis-table wis-personal-status">
33
- <thead>
34
- <tr>
35
- <th class="wis-profile-picture"><?php echo __( 'Image', 'instagram-slider-widget' ); ?></th>
36
- <th class="wis-profile-id"><?php echo __( 'ID', 'instagram-slider-widget' ); ?></th>
37
- <th class="wis-profile-name"><?php echo __( 'User', 'instagram-slider-widget' ); ?></th>
38
- <th class="wis-profile-token"><?php echo __( 'Token', 'instagram-slider-widget' ); ?></th>
39
- <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
40
- </tr>
41
- </thead>
42
- <tbody>
43
  <?php
44
  foreach ( $accounts as $key => $profile_info ) {
45
- $delete_link = $this->getActionUrl( 'delete', [ 'social' => $social, 'business' => false, 'account' => $key ] );
 
 
 
 
46
  ?>
47
- <tr>
48
- <td class="wis-profile-picture"></td>
49
- <td class="wis-profile-id"><?php echo esc_attr( $profile_info['id'] ); ?></td>
50
- <td class="wis-profile-name">
51
- <a href="https://www.instagram.com/<?php echo esc_html( $profile_info['username'] ); ?>">@<?php echo esc_html( $profile_info['username'] ); ?></a>
52
- </td>
53
- <td class="wis-profile-token">
54
- <input id="<?php echo esc_attr( $profile_info['id'] ); ?>-account-access-token" type="text" value="<?php echo esc_attr( $profile_info['token'] ); ?>"
55
- class="wis-text-token" readonly/>
56
- </td>
57
- <td class="wis-profile-actions">
58
- <a href="<?php echo $delete_link; ?>" class="btn btn-danger wis-delete-account">
59
- <span class="dashicons dashicons-trash"></span><?php echo __( 'Delete', 'instagram-slider-widget' ); ?>
60
- </a>
 
61
  <?php
62
  if ( isset( $_GET['access_token'] ) && $_GET['access_token'] === $profile_info['token'] ) {
63
  ?><span class="wis-div-added">Successfully connected</span><?php
64
  }
65
  ?>
66
- </td>
67
- </tr>
68
  <?php
69
  }
70
  ?>
71
- </tbody>
72
- </table>
73
  <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
74
  <?php endif; ?>
75
  <!-- Business accounts -->
76
  <?php
77
  if ( count( $accounts_business ) ) :
78
  ?>
79
- <div class="wis-social-group"><?php echo __( 'Business Accounts', 'instagram-slider-widget' ); ?></div>
80
- <table class="widefat wis-table wis-business-status">
81
- <thead>
82
- <tr>
83
- <th class="wis-profile-picture"><?php echo __( 'Image', 'instagram-slider-widget' ); ?></th>
84
- <th class="wis-profile-id"><?php echo __( 'ID', 'instagram-slider-widget' ); ?></th>
85
- <th class="wis-profile-name"><?php echo __( 'User', 'instagram-slider-widget' ); ?></th>
86
- <th class="wis-profile-token"><?php echo __( 'Token', 'instagram-slider-widget' ); ?></th>
87
- <th class="wis-profile-action"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
88
- </tr>
89
- </thead>
90
- <tbody>
91
  <?php
92
  foreach ( $accounts_business as $key => $profile_info ) {
93
- $delete_link = $this->getActionUrl( 'delete', [ 'social' => $social, 'business' => true, 'account' => $key ] );
94
- $image = $profile_info['profile_picture_url'];
95
- $fullname = $profile_info['name'];
 
 
 
 
 
96
  ?>
97
- <tr>
98
- <td class="wis-profile-picture">
99
- <img src="<?php echo esc_url( $image ); ?>"
100
- width="30"/>
101
- </td>
102
- <td class="wis-profile-id"><?php echo esc_attr( $profile_info['id'] ); ?></td>
103
- <td class="wis-profile-name">
104
  <?php echo esc_html( $fullname ); ?> <a
105
- href="https://www.instagram.com/<?php echo esc_html( $profile_info['username'] ); ?>">@<?php echo esc_html( $profile_info['username'] ); ?></a>
106
- </td>
107
- <td class="wis-profile-token">
108
- <input id="<?php echo esc_attr( $profile_info['id'] ); ?>-business-account-access-token"
109
- type="text"
110
- value="<?php echo esc_attr( $profile_info['token'] ); ?>"
111
- class="wis-text-token" readonly/>
112
- </td>
113
- <td class="wis-profile-actions">
114
- <a href="<?php echo $delete_link; ?>" class="btn btn-danger wis-delete-account">
115
- <span class="dashicons dashicons-trash"></span><?php echo __( 'Delete', 'instagram-slider-widget' ); ?>
116
- </a>
117
- <span class="spinner"
118
- id="wis-delete-spinner-<?php echo esc_attr( $profile_info['id'] ); ?>"></span>
119
- <span class="wis-div-added"
120
- style="display: none;"><?php _e( 'Successfully connected', 'instagram-slider-widget' ); ?></span>
121
- </td>
122
- </tr>
123
  <?php
124
  }
125
  ?>
126
- </tbody>
127
- </table>
128
  <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
129
  <?php endif; ?>
130
 
131
  <div id="wis_add_account_modal" class="wis_accounts_modal wis_closed">
132
- <div class="wis_modal_header">
133
- Select type of account
134
- </div>
135
- <div class="wis_modal_content">
136
 
137
- <div class='wis-row-style'>
138
- <a href="<?php echo $authorize_url_instagram; ?>" class='wis-btn-instagram-account'>Personal
139
- account</a>
140
- </div>
141
- <div class='wis-row-style'>
142
- <a href="<?php echo $authorize_url_business; ?>" class='wis-btn-facebook-account'>Business
143
- account</a>
144
- </div>
145
- </div>
146
  </div>
147
  <div id="wis_add_account_modal_overlay" class="wis_modal_overlay wis_closed"></div>
9
  */
10
 
11
  $social = $args['social'];
12
+ $errors = $args['errors'];
13
  $count_accounts = count( $accounts ) + count( $accounts_business );
14
  ?>
15
+ <div><?php echo implode( '', $errors ); ?></div>
16
  <div id="wis-add-account-button" class="">
17
  <?php
18
  if ( $count_accounts >= 1 && ! $is_premium ) : ?>
19
+ <span class="wis-btn-instagram-account-disabled btn-instagram-account-disabled">
20
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?></span>
21
+ <span class="instagram-account-pro"><?php echo sprintf( __( "More accounts in <a href='%s'>PRO version</a>", 'instagram-slider-widget' ), WIS_Plugin::app()->get_support()->get_pricing_url( true, "wis_settings" ) ); ?></span>
22
  <?php else: ?>
23
+ <a class="wis-btn-instagram-account" target="_self" href="#" title="Add Account">
24
  <?php _e( 'Add Account', 'instagram-slider-widget' ) ?>
25
+ </a>
26
+ <span style="float: none; margin-top: 0;" class="spinner" id="wis-spinner"> </span>
27
  <?php endif; ?>
28
  </div>
29
  <!-- Personal accounts -->
30
  <?php
31
  if ( count( $accounts ) ) :
32
  ?>
33
+ <div class="wis-social-group"><?php echo __( 'Personal Accounts', 'instagram-slider-widget' ); ?></div>
34
+ <table class="widefat wis-table wis-personal-status">
35
+ <thead>
36
+ <tr>
37
+ <th class="wis-profile-picture"><?php echo __( 'Image', 'instagram-slider-widget' ); ?></th>
38
+ <th class="wis-profile-id"><?php echo __( 'ID', 'instagram-slider-widget' ); ?></th>
39
+ <th class="wis-profile-name"><?php echo __( 'User', 'instagram-slider-widget' ); ?></th>
40
+ <th class="wis-profile-token"><?php echo __( 'Token', 'instagram-slider-widget' ); ?></th>
41
+ <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
42
+ </tr>
43
+ </thead>
44
+ <tbody>
45
  <?php
46
  foreach ( $accounts as $key => $profile_info ) {
47
+ $delete_link = wp_nonce_url( $this->getActionUrl( 'delete', [
48
+ 'social' => $social,
49
+ 'business' => false,
50
+ 'account' => $key,
51
+ ] ), 'wis_delete_profile', 'nonce' );
52
  ?>
53
+ <tr>
54
+ <td class="wis-profile-picture"></td>
55
+ <td class="wis-profile-id"><?php echo esc_attr( $profile_info['id'] ); ?></td>
56
+ <td class="wis-profile-name">
57
+ <a href="https://www.instagram.com/<?php echo esc_html( $profile_info['username'] ); ?>">@<?php echo esc_html( $profile_info['username'] ); ?></a>
58
+ </td>
59
+ <td class="wis-profile-token">
60
+ <input id="<?php echo esc_attr( $profile_info['id'] ); ?>-account-access-token" type="text"
61
+ value="<?php echo esc_attr( $profile_info['token'] ); ?>"
62
+ class="wis-text-token" readonly/>
63
+ </td>
64
+ <td class="wis-profile-actions">
65
+ <a href="<?php echo $delete_link; ?>" class="btn btn-danger wis-delete-account">
66
+ <span class="dashicons dashicons-trash"></span><?php echo __( 'Delete', 'instagram-slider-widget' ); ?>
67
+ </a>
68
  <?php
69
  if ( isset( $_GET['access_token'] ) && $_GET['access_token'] === $profile_info['token'] ) {
70
  ?><span class="wis-div-added">Successfully connected</span><?php
71
  }
72
  ?>
73
+ </td>
74
+ </tr>
75
  <?php
76
  }
77
  ?>
78
+ </tbody>
79
+ </table>
80
  <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
81
  <?php endif; ?>
82
  <!-- Business accounts -->
83
  <?php
84
  if ( count( $accounts_business ) ) :
85
  ?>
86
+ <div class="wis-social-group"><?php echo __( 'Business Accounts', 'instagram-slider-widget' ); ?></div>
87
+ <table class="widefat wis-table wis-business-status">
88
+ <thead>
89
+ <tr>
90
+ <th class="wis-profile-picture"><?php echo __( 'Image', 'instagram-slider-widget' ); ?></th>
91
+ <th class="wis-profile-id"><?php echo __( 'ID', 'instagram-slider-widget' ); ?></th>
92
+ <th class="wis-profile-name"><?php echo __( 'User', 'instagram-slider-widget' ); ?></th>
93
+ <th class="wis-profile-token"><?php echo __( 'Token', 'instagram-slider-widget' ); ?></th>
94
+ <th class="wis-profile-action"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
95
+ </tr>
96
+ </thead>
97
+ <tbody>
98
  <?php
99
  foreach ( $accounts_business as $key => $profile_info ) {
100
+ $delete_link = wp_nonce_url( $this->getActionUrl( 'delete', [
101
+ 'social' => $social,
102
+ 'business' => true,
103
+ 'account' => $key,
104
+ ] ), 'wis_delete_profile', 'nonce' );
105
+
106
+ $image = $profile_info['profile_picture_url'];
107
+ $fullname = $profile_info['name'];
108
  ?>
109
+ <tr>
110
+ <td class="wis-profile-picture">
111
+ <img src="<?php echo esc_url( $image ); ?>"
112
+ width="30"/>
113
+ </td>
114
+ <td class="wis-profile-id"><?php echo esc_attr( $profile_info['id'] ); ?></td>
115
+ <td class="wis-profile-name">
116
  <?php echo esc_html( $fullname ); ?> <a
117
+ href="https://www.instagram.com/<?php echo esc_html( $profile_info['username'] ); ?>">@<?php echo esc_html( $profile_info['username'] ); ?></a>
118
+ </td>
119
+ <td class="wis-profile-token">
120
+ <input id="<?php echo esc_attr( $profile_info['id'] ); ?>-business-account-access-token"
121
+ type="text"
122
+ value="<?php echo esc_attr( $profile_info['token'] ); ?>"
123
+ class="wis-text-token" readonly/>
124
+ </td>
125
+ <td class="wis-profile-actions">
126
+ <a href="<?php echo $delete_link; ?>" class="btn btn-danger wis-delete-account">
127
+ <span class="dashicons dashicons-trash"></span><?php echo __( 'Delete', 'instagram-slider-widget' ); ?>
128
+ </a>
129
+ <span class="spinner"
130
+ id="wis-delete-spinner-<?php echo esc_attr( $profile_info['id'] ); ?>"></span>
131
+ <span class="wis-div-added"
132
+ style="display: none;"><?php _e( 'Successfully connected', 'instagram-slider-widget' ); ?></span>
133
+ </td>
134
+ </tr>
135
  <?php
136
  }
137
  ?>
138
+ </tbody>
139
+ </table>
140
  <?php wp_nonce_field( $this->plugin->getPrefix() . 'settings_form', $this->plugin->getPrefix() . 'nonce' ); ?>
141
  <?php endif; ?>
142
 
143
  <div id="wis_add_account_modal" class="wis_accounts_modal wis_closed">
144
+ <div class="wis_modal_header">
145
+ Select type of account
146
+ </div>
147
+ <div class="wis_modal_content">
148
 
149
+ <div class='wis-row-style'>
150
+ <a href="<?php echo $authorize_url_instagram; ?>" class='wis-btn-instagram-account'>Personal
151
+ account</a>
152
+ </div>
153
+ <div class='wis-row-style'>
154
+ <a href="<?php echo $authorize_url_business; ?>" class='wis-btn-facebook-account'>Business
155
+ account</a>
156
+ </div>
157
+ </div>
158
  </div>
159
  <div id="wis_add_account_modal_overlay" class="wis_modal_overlay wis_closed"></div>
components/instagram/html_templates/feeds.php CHANGED
@@ -7,55 +7,62 @@
7
  */
8
  ?>
9
  <div class="wisw-social-content">
10
- <div class="wisw-container-row">
11
- <a href="<?php echo $this->getActionUrl( 'add', [ 'social' => $social ] ); ?>"
12
- class="button action wis-add-feed-button"><?php _e( 'Add feed', 'instagram-slider-widget' ); ?></a>
13
- </div>
14
 
15
- <div class="wisw-container-row">
16
- <table class="widefat wis-table wis-personal-status">
17
- <thead>
18
- <tr>
19
- <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
20
- <th class="wis-profile-shortcode"><label for="jr_insta_shortcode"><?php echo __( 'Shortcode', 'instagram-slider-widget' ); ?></label></th>
21
- <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
22
- </tr>
23
- </thead>
24
- <tbody>
 
 
25
  <?php
26
  if ( count( $feeds ) ) :
27
  foreach ( $feeds as $feed_id => $feed ) {
28
  $edit_link = $this->getActionUrl( 'edit', [ 'social' => $social, 'feed' => $feed_id ] );
29
- $delete_link = $this->getActionUrl( 'delete', [ 'social' => $social, 'feed' => $feed_id ] );
 
 
 
30
  ?>
31
- <tr>
32
- <td class="wis-profile-name">
33
- <a href="<?php echo $edit_link; ?>">
34
  <?php echo $feed->title; ?>
35
- </a>
36
- </td>
37
- <td class="wis-profile-shortcode">
38
- <input id="jr_insta_shortcode" onclick="this.setSelectionRange(0, this.value.length)" type="text" class="form-input wis-shortcode-input"
39
- value="[jr_instagram id=&quot;<?php echo $feed_id ?>&quot;]" readonly="readonly">
40
- </td>
41
- <td class="wis-profile-actions">
42
- <a href="<?php echo $edit_link; ?>" class="btn btn-primary">
43
- <span class="dashicons dashicons-edit"></span>
44
- </a>
45
- <a href="<?php echo $delete_link; ?>" class="btn btn-danger">
46
- <span class="dashicons dashicons-trash"></span>
47
- </a>
48
- </td>
49
- </tr>
 
50
  <?php
51
  }
52
  ?>
53
  <?php else: ?>
54
- <tr>
55
- <td class="wis-profile-nofeed" colspan="3"><?php echo __( 'No feeds', 'instagram-slider-widget' ); ?></td>
56
- </tr>
 
57
  <?php endif; ?>
58
- </tbody>
59
- </table>
60
- </div>
61
  </div>
7
  */
8
  ?>
9
  <div class="wisw-social-content">
10
+ <div class="wisw-container-row">
11
+ <a href="<?php echo $this->getActionUrl( 'add', [ 'social' => $social ] ); ?>"
12
+ class="button action wis-add-feed-button"><?php _e( 'Add feed', 'instagram-slider-widget' ); ?></a>
13
+ </div>
14
 
15
+ <div class="wisw-container-row">
16
+ <table class="widefat wis-table wis-personal-status">
17
+ <thead>
18
+ <tr>
19
+ <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
20
+ <th class="wis-profile-shortcode"><label
21
+ for="jr_insta_shortcode"><?php echo __( 'Shortcode', 'instagram-slider-widget' ); ?></label>
22
+ </th>
23
+ <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
  <?php
28
  if ( count( $feeds ) ) :
29
  foreach ( $feeds as $feed_id => $feed ) {
30
  $edit_link = $this->getActionUrl( 'edit', [ 'social' => $social, 'feed' => $feed_id ] );
31
+ $delete_link = wp_nonce_url( $this->getActionUrl( 'delete', [
32
+ 'social' => $social,
33
+ 'feed' => $feed_id,
34
+ ] ), 'wis_delete_feed', 'nonce' );
35
  ?>
36
+ <tr>
37
+ <td class="wis-profile-name">
38
+ <a href="<?php echo $edit_link; ?>">
39
  <?php echo $feed->title; ?>
40
+ </a>
41
+ </td>
42
+ <td class="wis-profile-shortcode">
43
+ <input id="jr_insta_shortcode" onclick="this.setSelectionRange(0, this.value.length)"
44
+ type="text" class="form-input wis-shortcode-input"
45
+ value="[jr_instagram id=&quot;<?php echo $feed_id ?>&quot;]" readonly="readonly">
46
+ </td>
47
+ <td class="wis-profile-actions">
48
+ <a href="<?php echo $edit_link; ?>" class="btn btn-primary">
49
+ <span class="dashicons dashicons-edit"></span>
50
+ </a>
51
+ <a href="<?php echo $delete_link; ?>" class="btn btn-danger">
52
+ <span class="dashicons dashicons-trash"></span>
53
+ </a>
54
+ </td>
55
+ </tr>
56
  <?php
57
  }
58
  ?>
59
  <?php else: ?>
60
+ <tr>
61
+ <td class="wis-profile-nofeed"
62
+ colspan="3"><?php echo __( 'No feeds', 'instagram-slider-widget' ); ?></td>
63
+ </tr>
64
  <?php endif; ?>
65
+ </tbody>
66
+ </table>
67
+ </div>
68
  </div>
components/instagram/html_templates/form-feed.php CHANGED
@@ -119,7 +119,7 @@ $search_for = $instance['search_for'] ?? '';
119
  <div class="input-group">
120
  <span class="input-group-addon">#</span>
121
  <input id="hashtag" class="form-input" name="hashtag"
122
- value="<?php echo $instance['hashtag']; ?>"/>
123
  </div>
124
 
125
  <div class="jr-description hashtag-problem-info <?php echo 'hashtag' !== $search_for ? 'hidden' : ''; ?>">
119
  <div class="input-group">
120
  <span class="input-group-addon">#</span>
121
  <input id="hashtag" class="form-input" name="hashtag"
122
+ value="<?php echo esc_attr( $instance['hashtag'] ); ?>"/>
123
  </div>
124
 
125
  <div class="jr-description hashtag-problem-info <?php echo 'hashtag' !== $search_for ? 'hidden' : ''; ?>">
components/instagram/includes/class-instagram-feed.php CHANGED
@@ -646,7 +646,7 @@ class WIS_Instagram_Feed extends WIS_Feed {
646
  }
647
 
648
  $output = '';
649
- //WIS_Plugin::app()->logger->info( "Feed query: " . json_encode( [ $search_for, $refresh_hour, $images_number ] ) );
650
  $images_data = $this->feed_query( $search_for, $refresh_hour, $images_number );
651
  //WIS_Plugin::app()->logger->info( "Feed images: " . json_encode( $images_data ) );
652
 
646
  }
647
 
648
  $output = '';
649
+ WIS_Plugin::app()->logger->info( "Feed query: " . json_encode( [ $search_for, $refresh_hour, $images_number ] ) );
650
  $images_data = $this->feed_query( $search_for, $refresh_hour, $images_number );
651
  //WIS_Plugin::app()->logger->info( "Feed images: " . json_encode( $images_data ) );
652
 
components/instagram/includes/class-instagram-profiles.php CHANGED
@@ -1,307 +1,302 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) {
3
- exit;
4
- }
5
-
6
- class WIS_Instagram_Profiles extends WIS_Profiles {
7
- /**
8
- * @var string
9
- */
10
- public $social = 'instagram';
11
-
12
- /**
13
- * @var string
14
- */
15
- public $profiles_option_name = WIG_PROFILES_OPTION;
16
-
17
- /**
18
- * @var string
19
- */
20
- public $profiles_business_option_name = WIG_BUSINESS_PROFILES_OPTION;
21
-
22
- /**
23
- * WIS_Facebook_Profiles constructor.
24
- *
25
- * @param $page WIS_ProfilesPage
26
- */
27
- public function __construct( $page = null ) {
28
- if ( $page ) {
29
- parent::__construct( $page );
30
- }
31
-
32
- add_action( 'wp_ajax_wis_add_account_by_token', [ $this, 'add_account_by_token' ] );
33
- }
34
-
35
- /**
36
- * Ajax Call to add BUSINESS account by token
37
- *
38
- * @return void
39
- * @throws \Exception
40
- */
41
- public function add_account_by_token() {
42
- if ( isset( $_POST['account'] ) && ! empty( $_POST['account'] ) && isset( $_POST['_ajax_nonce'] ) ) {
43
- if ( ! current_user_can( 'manage_options' ) ) {
44
- wp_die( - 2 );
45
- } else {
46
- wp_verify_nonce( $_POST['_ajax_nonce'], 'addAccountByToken' );
47
-
48
- $account = json_decode( stripslashes( $_POST['account'] ), true );
49
- $user_profile = [];
50
- $user_profile = apply_filters( 'wis/account/profiles', $user_profile, true );
51
-
52
- if ( ! WIS_Plugin::app()->is_premium() && $this->count_accounts() >= 1 ) {
53
- wp_die( 'No premium' );
54
- }
55
-
56
- $user_profile[ $account['username'] ] = $account;
57
- WIS_Plugin::app()->updateOption( 'account_profiles_new', $user_profile );
58
-
59
- wp_die( 'Ok' );
60
- }
61
- } elseif ( isset( $_POST['token'] ) && ! empty( $_POST['token'] ) && isset( $_POST['_ajax_nonce'] ) ) {
62
- if ( ! current_user_can( 'manage_options' ) ) {
63
- wp_die( - 2 );
64
- } else {
65
- wp_verify_nonce( $_POST['_ajax_nonce'], 'addAccountByToken' );
66
-
67
- $token = $_POST['token'];
68
- $this->update_account_profiles( $token );
69
-
70
- wp_die( '1' );
71
- }
72
- }
73
- }
74
-
75
- /**
76
- * @param string $token
77
- * @param string $is_business
78
- * @param string $username
79
- *
80
- * @return bool|array
81
- */
82
- public function update_account_profiles( $token, $is_business = false, $username = "" ) {
83
- if ( $is_business ) {
84
- //Получаем аккаунты привязанные к фейсбуку
85
- $args = [
86
- 'access_token' => $token,
87
- 'fields' => 'instagram_business_account',
88
- 'limit' => 200,
89
- ];
90
- $url = WFB_FACEBOOK_SELF_URL . "me/accounts";
91
- $response = wp_remote_get( esc_url_raw( add_query_arg( $args, $url ) ) );
92
- if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
93
- $pages = json_decode( wp_remote_retrieve_body( $response ), true );
94
- //$username = $result['data'][0]['name'];
95
- $html = "";
96
- $users = [];
97
- foreach ( $pages['data'] as $key => $r ) {
98
- $args = [
99
- 'access_token' => $token,
100
- 'fields' => 'instagram_business_account',
101
- ];
102
- $url = WFB_FACEBOOK_SELF_URL . $r['id'];
103
- $response = wp_remote_get( esc_url_raw( add_query_arg( $args, $url ) ) );
104
- if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
105
- $ig_account = json_decode( wp_remote_retrieve_body( $response ), true );
106
- if ( isset( $ig_account['instagram_business_account']['id'] ) ) {
107
- $args = [
108
- 'fields' => 'username,id,followers_count,follows_count,media_count,name,profile_picture_url',
109
- 'access_token' => $token,
110
- ];
111
- $url = add_query_arg( $args, WFB_FACEBOOK_SELF_URL . $ig_account['instagram_business_account']['id'] );
112
- $response = wp_remote_get( esc_url_raw( $url ) );
113
- if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
114
- $result = json_decode( wp_remote_retrieve_body( $response ), true );
115
- $result['token'] = $token;
116
- $users[] = $result;
117
- $html .= "<div class='wis-row wis-row-style' id='wis-instagram-row' data-account='" . json_encode( $result ) . "'>";
118
- $html .= "<div class='wis-col-1 wis-col1-style'><img src='{$result['profile_picture_url']}' width='50' alt='{$result['username']}'></div>";
119
- $html .= "<div class='wis-col-2 wis-col2-style'>{$result['name']}<br>@{$result['username']}</div>";
120
- $html .= "</div>";
121
- }
122
- if ( "" !== $username && $username == $result['username'] ?? '' ) {
123
- $user_profile = [];
124
- $user_profile = apply_filters( 'wis/account/profiles', $user_profile, true );
125
-
126
- $user_profile[ $result['username'] ] = $result;
127
- WIS_Plugin::app()->updateOption( WIG_BUSINESS_PROFILES_OPTION, $user_profile );
128
- }
129
- }
130
- }
131
- }
132
-
133
- return [ $html, $users ];
134
- }
135
- } else {
136
- $expires = 0;
137
- $profiles = WIS_Plugin::app()->getOption( WIG_PROFILES_OPTION, [] );
138
- foreach ( $profiles as $profile ) {
139
- if ( $profile['token'] == $token ) {
140
- if ( $profile['expires'] <= time() ) {
141
- $new = $this->refresh_token( $token );
142
- $token = $new['access_token'];
143
- $expires = $new['expires_in']; //5183944 sec
144
- }
145
- break;
146
- }
147
- }
148
-
149
- $args = [
150
- 'fields' => 'id,media_count,username',
151
- 'access_token' => $token,
152
- ];
153
-
154
- $url = WIG_USERS_SELF_URL;
155
- $url = esc_url_raw( add_query_arg( $args, $url ) );
156
- $response = wp_remote_get( $url );
157
- if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
158
- $user = json_decode( wp_remote_retrieve_body( $response ), true );
159
- if ( ! isset( $user['id'] ) || empty( $user['id'] ) ) {
160
- return false;
161
- }
162
-
163
- $user['token'] = $token;
164
- if ( $expires > 0 ) {
165
- $user['expires'] = time() + ( $expires - 86344 );
166
- } //= 5097600 sec = 59 days
167
- else {
168
- $user['expires'] = isset( $profiles[ $user['username'] ]['expires'] ) ? $profiles[ $user['username'] ]['expires'] : time() + 5097600;
169
- }
170
- $user_profile = [];
171
- $user_profile = apply_filters( 'wis/account/profiles', $user_profile );
172
-
173
- if ( ! WIS_Plugin::app()->is_premium() && $this->count_accounts() >= 1 ) {
174
- return [];
175
- }
176
-
177
- $user_profile[ $user['username'] ] = $user;
178
- WIS_Plugin::app()->updateOption( WIG_PROFILES_OPTION, $user_profile );
179
-
180
- return $user;
181
- }
182
- }
183
-
184
- return false;
185
- }
186
-
187
- /**
188
- * @param string $token
189
- *
190
- * @return array
191
- */
192
- public function refresh_token( $token ) {
193
- $args = [
194
- 'grant_type' => 'ig_refresh_token',
195
- 'access_token' => $token,
196
- ];
197
-
198
- $url = WIG_USERS_SELF_MEDIA_URL . 'refresh_access_token';
199
- $url = esc_url_raw( add_query_arg( $args, $url ) );
200
- $response = wp_remote_get( $url );
201
- if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
202
- $new = json_decode( wp_remote_retrieve_body( $response ), true );
203
- if ( is_array( $new ) ) {
204
- return $new;
205
- }
206
- }
207
-
208
- return [];
209
- }
210
-
211
- /**
212
- * Логика на вкладке facebook
213
- *
214
- * @return string
215
- */
216
- public function content() {
217
- if ( isset( $_GET['tab'] ) && 'instagram' === $_GET['tab'] ) {
218
- if ( isset( $_GET['type'] ) && 'business' === $_GET['type'] ) {
219
- if ( isset( $_GET['token_error'] ) ) {
220
- $token_error = wp_strip_all_tags( $_GET['token_error'] );
221
- echo '<div class="notice notice-error"><p>' . $token_error . '</p></div>';
222
- $_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url_raw( remove_query_arg( 'token_error' ) ) );
223
- } else {
224
- if ( isset( $_GET['access_token'] ) ) {
225
- $token = $_GET['access_token'];
226
- $result = $this->update_account_profiles( $token, true );
227
- $_SERVER['REQUEST_URI'] = esc_url_raw( remove_query_arg( 'access_token' ) );
228
- ?>
229
- <div id="wis_accounts_modal" class="wis_accounts_modal">
230
- <div class="wis_modal_header">
231
- Choose Account:
232
- </div>
233
- <div class="wis_modal_content">
234
- <?php echo $result[0]; ?>
235
- </div>
236
- </div>
237
- <div id="wis_modal_overlay" class="wis_modal_overlay"></div>
238
- <span class="wis-overlay-spinner is-active">&nbsp;</span>
239
- <?php
240
- }
241
- }
242
- } else {
243
- if ( isset( $_GET['token_error'] ) ) {
244
- $token_error = wp_strip_all_tags( $_GET['token_error'] );
245
- echo '<div class="notice notice-error"><p>' . $token_error . '</p></div>';
246
- $_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url_raw( remove_query_arg( 'token_error' ) ) );
247
- } else {
248
- if ( isset( $_GET['access_token'] ) ) {
249
- $token = $_GET['access_token'];
250
- $result = $this->update_account_profiles( $token );
251
- $_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url_raw( remove_query_arg( 'access_token' ) ) );
252
- }
253
- }
254
- }
255
- }
256
- $authorize_url_instagram = "https://api.instagram.com/oauth/authorize?" . http_build_query( [
257
- "client_id" => WIS_INSTAGRAM_CLIENT_ID,
258
- "redirect_uri" => "https://instagram.cm-wp.com/basic-api",
259
- "scope" => "user_profile,user_media",
260
- "response_type" => "code",
261
- "state" => $this->getSocialUrl(),
262
- ] );
263
-
264
- $authorize_url_business = "https://instagram.cm-wp.com/api/?" . http_build_query( [
265
- "app_id" => WIS_FACEBOOK_CLIENT_ID,
266
- "state" => $this->getSocialUrl() . '&type=business',
267
- ] );
268
-
269
- $accounts = WIS_Plugin::app()->getPopulateOption( WIG_PROFILES_OPTION, [] );
270
- $accounts_business = WIS_Plugin::app()->getPopulateOption( WIG_BUSINESS_PROFILES_OPTION, [] );
271
-
272
-
273
- $data = [
274
- 'is_premium' => WIS_Plugin::app()->is_premium(),
275
- 'authorize_url_instagram' => $authorize_url_instagram,
276
- 'authorize_url_business' => $authorize_url_business,
277
- 'accounts' => $accounts,
278
- 'accounts_business' => $accounts_business,
279
- 'social' => $this->social,
280
- ];
281
- $result = $this->page->render( WIG_COMPONENT_VIEWS_DIR . '/accounts', $data );
282
-
283
- return $result;
284
- }
285
-
286
- /**
287
- * Get count of accounts
288
- *
289
- * @return int
290
- */
291
- public function count_accounts() {
292
- $account = WIS_Plugin::app()->getOption( $this->profiles_option_name, [] );
293
- $account_business = WIS_Plugin::app()->getOption( $this->profiles_business_option_name, [] );
294
-
295
- return count( $account + $account_business );
296
- }
297
-
298
- public function delete_account( $name, $is_business ) {
299
- $option_name = $is_business ? $this->profiles_business_option_name : $this->profiles_option_name;
300
-
301
- $accounts = WIS_Plugin::app()->getOption( $option_name, [] );
302
- if ( isset( $accounts[ $name ] ) ) {
303
- unset( $accounts[ $name ] );
304
- }
305
- WIS_Plugin::app()->updateOption( $option_name, $accounts );
306
- }
307
- }
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class WIS_Instagram_Profiles extends WIS_Profiles {
7
+ /**
8
+ * @var string
9
+ */
10
+ public $social = 'instagram';
11
+
12
+ /**
13
+ * @var string
14
+ */
15
+ public $profiles_option_name = WIG_PROFILES_OPTION;
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ public $profiles_business_option_name = WIG_BUSINESS_PROFILES_OPTION;
21
+
22
+ /**
23
+ * WIS_Facebook_Profiles constructor.
24
+ *
25
+ * @param $page WIS_ProfilesPage
26
+ */
27
+ public function __construct( $page = null ) {
28
+ if ( $page ) {
29
+ parent::__construct( $page );
30
+ }
31
+
32
+ add_action( 'wp_ajax_wis_add_account_by_token', [ $this, 'add_account_by_token' ] );
33
+ }
34
+
35
+ /**
36
+ * Ajax Call to add BUSINESS account by token
37
+ *
38
+ * @return void
39
+ * @throws \Exception
40
+ */
41
+ public function add_account_by_token() {
42
+ if ( isset( $_POST['account'] ) && ! empty( $_POST['account'] ) && isset( $_POST['_ajax_nonce'] ) ) {
43
+ if ( ! current_user_can( 'manage_options' ) ) {
44
+ wp_die( - 2 );
45
+ } else {
46
+ wp_verify_nonce( $_POST['_ajax_nonce'], 'addAccountByToken' );
47
+
48
+ $account = json_decode( stripslashes( $_POST['account'] ), true );
49
+ $user_profile = [];
50
+ $user_profile = apply_filters( 'wis/account/profiles', $user_profile, true );
51
+
52
+ if ( ! WIS_Plugin::app()->is_premium() && $this->count_accounts() >= 1 ) {
53
+ wp_die( 'No premium' );
54
+ }
55
+
56
+ $user_profile[ $account['username'] ] = $account;
57
+ WIS_Plugin::app()->updateOption( 'account_profiles_new', $user_profile );
58
+
59
+ wp_die( 'Ok' );
60
+ }
61
+ } elseif ( isset( $_POST['token'] ) && ! empty( $_POST['token'] ) && isset( $_POST['_ajax_nonce'] ) ) {
62
+ if ( ! current_user_can( 'manage_options' ) ) {
63
+ wp_die( - 2 );
64
+ } else {
65
+ wp_verify_nonce( $_POST['_ajax_nonce'], 'addAccountByToken' );
66
+
67
+ $token = $_POST['token'];
68
+ $this->update_account_profiles( $token );
69
+
70
+ wp_die( '1' );
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @param string $token
77
+ * @param string $is_business
78
+ * @param string $username
79
+ *
80
+ * @return bool|array
81
+ */
82
+ public function update_account_profiles( $token, $is_business = false, $username = '' ) {
83
+ if ( $is_business ) {
84
+ //Получаем аккаунты привязанные к фейсбуку
85
+ $args = [
86
+ 'access_token' => $token,
87
+ 'fields' => 'instagram_business_account',
88
+ 'limit' => 200,
89
+ ];
90
+ $url = WFB_FACEBOOK_SELF_URL . 'me/accounts';
91
+ $response = wp_remote_get( esc_url_raw( add_query_arg( $args, $url ) ) );
92
+ if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
93
+ $pages = json_decode( wp_remote_retrieve_body( $response ), true );
94
+ //$username = $result['data'][0]['name'];
95
+ $html = '';
96
+ $users = [];
97
+ foreach ( $pages['data'] as $key => $r ) {
98
+ $args = [
99
+ 'access_token' => $token,
100
+ 'fields' => 'instagram_business_account',
101
+ ];
102
+ $url = WFB_FACEBOOK_SELF_URL . $r['id'];
103
+ $response = wp_remote_get( esc_url_raw( add_query_arg( $args, $url ) ) );
104
+ if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
105
+ $ig_account = json_decode( wp_remote_retrieve_body( $response ), true );
106
+ if ( isset( $ig_account['instagram_business_account']['id'] ) ) {
107
+ $args = [
108
+ 'fields' => 'username,id,followers_count,follows_count,media_count,name,profile_picture_url',
109
+ 'access_token' => $token,
110
+ ];
111
+ $url = add_query_arg( $args, WFB_FACEBOOK_SELF_URL . $ig_account['instagram_business_account']['id'] );
112
+ $response = wp_remote_get( esc_url_raw( $url ) );
113
+ if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
114
+ $result = json_decode( wp_remote_retrieve_body( $response ), true );
115
+ $result['token'] = $token;
116
+ $result['profile_picture_url'] = $result['profile_picture_url'] ?? '';
117
+ $users[] = $result;
118
+ $html .= "<div class='wis-row wis-row-style' id='wis-instagram-row' data-account='" . json_encode( $result ) . "'>";
119
+ $html .= "<div class='wis-col-1 wis-col1-style'><img src='{$result['profile_picture_url']}' width='50' alt='{$result['username']}'></div>";
120
+ $html .= "<div class='wis-col-2 wis-col2-style'>{$result['name']}<br>@{$result['username']}</div>";
121
+ $html .= '</div>';
122
+ }
123
+ if ( '' !== $username && $username == $result['username'] ?? '' ) {
124
+ $user_profile = [];
125
+ $user_profile = apply_filters( 'wis/account/profiles', $user_profile, true );
126
+
127
+ $user_profile[ $result['username'] ] = $result;
128
+ WIS_Plugin::app()->updateOption( WIG_BUSINESS_PROFILES_OPTION, $user_profile );
129
+ }
130
+ }
131
+ }
132
+ }
133
+
134
+ return $users ? [ $html, $users ] : [];
135
+ }
136
+ } else {
137
+ $expires = 0;
138
+ $profiles = WIS_Plugin::app()->getOption( WIG_PROFILES_OPTION, [] );
139
+ foreach ( $profiles as $profile ) {
140
+ if ( $profile['token'] == $token ) {
141
+ if ( $profile['expires'] <= time() ) {
142
+ $new = $this->refresh_token( $token );
143
+ $token = $new['access_token'];
144
+ $expires = $new['expires_in']; //5183944 sec
145
+ }
146
+ break;
147
+ }
148
+ }
149
+
150
+ $args = [
151
+ 'fields' => 'id,media_count,username',
152
+ 'access_token' => $token,
153
+ ];
154
+
155
+ $url = WIG_USERS_SELF_URL;
156
+ $url = esc_url_raw( add_query_arg( $args, $url ) );
157
+ $response = wp_remote_get( $url );
158
+ if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
159
+ $user = json_decode( wp_remote_retrieve_body( $response ), true );
160
+ if ( ! isset( $user['id'] ) || empty( $user['id'] ) ) {
161
+ return false;
162
+ }
163
+
164
+ $user['token'] = $token;
165
+ if ( $expires > 0 ) {
166
+ $user['expires'] = time() + ( $expires - 86344 );
167
+ } //= 5097600 sec = 59 days
168
+ else {
169
+ $user['expires'] = isset( $profiles[ $user['username'] ]['expires'] ) ? $profiles[ $user['username'] ]['expires'] : time() + 5097600;
170
+ }
171
+ $user_profile = [];
172
+ $user_profile = apply_filters( 'wis/account/profiles', $user_profile );
173
+
174
+ if ( ! WIS_Plugin::app()->is_premium() && $this->count_accounts() >= 1 ) {
175
+ return [];
176
+ }
177
+
178
+ $user_profile[ $user['username'] ] = $user;
179
+ WIS_Plugin::app()->updateOption( WIG_PROFILES_OPTION, $user_profile );
180
+
181
+ return $user;
182
+ }
183
+ }
184
+
185
+ return false;
186
+ }
187
+
188
+ /**
189
+ * @param string $token
190
+ *
191
+ * @return array
192
+ */
193
+ public function refresh_token( $token ) {
194
+ $args = [
195
+ 'grant_type' => 'ig_refresh_token',
196
+ 'access_token' => $token,
197
+ ];
198
+
199
+ $url = WIG_USERS_SELF_MEDIA_URL . 'refresh_access_token';
200
+ $url = esc_url_raw( add_query_arg( $args, $url ) );
201
+ $response = wp_remote_get( $url );
202
+ if ( 200 == wp_remote_retrieve_response_code( $response ) ) {
203
+ $new = json_decode( wp_remote_retrieve_body( $response ), true );
204
+ if ( is_array( $new ) ) {
205
+ return $new;
206
+ }
207
+ }
208
+
209
+ return [];
210
+ }
211
+
212
+ /**
213
+ * Логика на вкладке facebook
214
+ *
215
+ * @return string
216
+ */
217
+ public function content() {
218
+ if ( isset( $_GET['tab'] ) && 'instagram' === $_GET['tab'] ) {
219
+ if ( isset( $_GET['type'] ) && 'business' === $_GET['type'] ) {
220
+ if ( isset( $_GET['access_token'] ) ) {
221
+ $token = $_GET['access_token'];
222
+ $result = $this->update_account_profiles( $token, true );
223
+ $_SERVER['REQUEST_URI'] = esc_url_raw( remove_query_arg( 'access_token' ) );
224
+ ?>
225
+ <div id="wis_accounts_modal" class="wis_accounts_modal">
226
+ <div class="wis_modal_header">
227
+ Choose Account:
228
+ </div>
229
+ <div class="wis_modal_content">
230
+ <?php echo $result[0] ?? ''; ?>
231
+ </div>
232
+ </div>
233
+ <div id="wis_modal_overlay" class="wis_modal_overlay"></div>
234
+ <span class="wis-overlay-spinner is-active">&nbsp;</span>
235
+ <?php
236
+ }
237
+ } else {
238
+ if ( isset( $_GET['access_token'] ) ) {
239
+ $token = $_GET['access_token'];
240
+ $result = $this->update_account_profiles( $token );
241
+ $_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url_raw( remove_query_arg( 'access_token' ) ) );
242
+ }
243
+ }
244
+ } elseif ( isset( $_GET['token_error'] ) ) {
245
+ $token_error = wp_strip_all_tags( $_GET['token_error'] );
246
+ $errors[] = $token_error;
247
+ //$_SERVER['REQUEST_URI'] = str_replace( '#_', '', esc_url_raw( remove_query_arg( 'token_error' ) ) );
248
+ }
249
+ $authorize_url_instagram = 'https://api.instagram.com/oauth/authorize?' . http_build_query( [
250
+ 'client_id' => WIS_INSTAGRAM_CLIENT_ID,
251
+ 'redirect_uri' => 'https://instagram.cm-wp.com/basic-api',
252
+ 'scope' => 'user_profile,user_media',
253
+ 'response_type' => 'code',
254
+ 'state' => $this->getSocialUrl() . '&app_id=' . WIS_INSTAGRAM_CLIENT_ID,
255
+ ] );
256
+
257
+ $authorize_url_business = 'https://instagram.cm-wp.com/api/?' . http_build_query( [
258
+ 'app_id' => WIS_FACEBOOK_CLIENT_ID,
259
+ 'state' => $this->getSocialUrl() . '&type=business&app_id=' . WIS_FACEBOOK_CLIENT_ID,
260
+ ] );
261
+
262
+ $accounts = WIS_Plugin::app()->getPopulateOption( WIG_PROFILES_OPTION, [] );
263
+ $accounts_business = WIS_Plugin::app()->getPopulateOption( WIG_BUSINESS_PROFILES_OPTION, [] );
264
+
265
+ $data = [
266
+ 'is_premium' => WIS_Plugin::app()->is_premium(),
267
+ 'authorize_url_instagram' => $authorize_url_instagram,
268
+ 'authorize_url_business' => $authorize_url_business,
269
+ 'accounts' => $accounts,
270
+ 'accounts_business' => $accounts_business,
271
+ 'social' => $this->social,
272
+ 'errors' => $errors ?? [],
273
+ ];
274
+ $result = $this->page->render( WIG_COMPONENT_VIEWS_DIR . '/accounts', $data );
275
+
276
+ return $result;
277
+ }
278
+
279
+ /**
280
+ * Get count of accounts
281
+ *
282
+ * @return int
283
+ */
284
+ public function count_accounts() {
285
+ $account = WIS_Plugin::app()->getOption( $this->profiles_option_name, [] );
286
+ $account_business = WIS_Plugin::app()->getOption( $this->profiles_business_option_name, [] );
287
+
288
+ return count( $account + $account_business );
289
+ }
290
+
291
+ public function delete_account( $name, $is_business ) {
292
+ check_admin_referer( 'wis_delete_profile', 'nonce' );
293
+
294
+ $option_name = $is_business ? $this->profiles_business_option_name : $this->profiles_option_name;
295
+
296
+ $accounts = WIS_Plugin::app()->getOption( $option_name, [] );
297
+ if ( isset( $accounts[ $name ] ) ) {
298
+ unset( $accounts[ $name ] );
299
+ }
300
+ WIS_Plugin::app()->updateOption( $option_name, $accounts );
301
+ }
302
+ }
 
 
 
 
 
components/instagram/load.php CHANGED
@@ -1,22 +1,23 @@
1
- <?php
2
- global $wis_compatibility;
3
-
4
- define( 'WIG_COMPONENT_VERSION', $wis_compatibility->get_plugin_version() );
5
- define( 'WIG_COMPONENT_URL', WIS_COMPONENTS_URL . '/instagram' );
6
- define( 'WIG_COMPONENT_DIR', WIS_COMPONENTS_DIR . '/instagram' );
7
- define( 'WIG_COMPONENT_VIEWS_DIR', WIG_COMPONENT_DIR . '/html_templates' );
8
-
9
- define( 'WIS_INSTAGRAM_CLIENT_ID', '2555361627845349' );
10
- define( 'WIS_FACEBOOK_CLIENT_ID', '776212986124330' );
11
- //define( 'WIS_FACEBOOK_CLIENT_ID', '572623036624544' ); // test APP ID
12
-
13
- define( 'WIG_PROFILES_OPTION', 'account_profiles' );
14
- define( 'WIG_BUSINESS_PROFILES_OPTION', 'account_profiles_new' );
15
-
16
- define( 'WIG_USERS_SELF_URL', 'https://graph.instagram.com/me' );
17
- define( 'WIG_USERS_SELF_MEDIA_URL', 'https://graph.instagram.com/' );
18
-
19
- require_once WIG_COMPONENT_DIR . "/includes/functions.php";
20
- require_once WIG_COMPONENT_DIR . "/includes/class-instagram-feed.php";
21
- require_once WIG_COMPONENT_DIR . "/includes/class-instagram-profiles.php";
22
- require_once WIG_COMPONENT_DIR . "/includes/class-instagram-widget.php";
 
1
+ <?php
2
+ global $wis_compatibility;
3
+
4
+ define( 'WIG_COMPONENT_VERSION', $wis_compatibility->get_plugin_version() );
5
+ define( 'WIG_COMPONENT_URL', WIS_COMPONENTS_URL . '/instagram' );
6
+ define( 'WIG_COMPONENT_DIR', WIS_COMPONENTS_DIR . '/instagram' );
7
+ define( 'WIG_COMPONENT_VIEWS_DIR', WIG_COMPONENT_DIR . '/html_templates' );
8
+
9
+ define( 'WIS_INSTAGRAM_CLIENT_ID', '2758407337627658' );
10
+ define( 'WIS_FACEBOOK_CLIENT_ID', '8542636415777224' );
11
+ //define( 'WIS_INSTAGRAM_CLIENT_ID', '1883092561894221' ); // test APP ID
12
+ //define( 'WIS_FACEBOOK_CLIENT_ID', '852118372457929' ); // test APP ID
13
+
14
+ define( 'WIG_PROFILES_OPTION', 'account_profiles' );
15
+ define( 'WIG_BUSINESS_PROFILES_OPTION', 'account_profiles_new' );
16
+
17
+ define( 'WIG_USERS_SELF_URL', 'https://graph.instagram.com/me' );
18
+ define( 'WIG_USERS_SELF_MEDIA_URL', 'https://graph.instagram.com/' );
19
+
20
+ require_once WIG_COMPONENT_DIR . '/includes/functions.php';
21
+ require_once WIG_COMPONENT_DIR . '/includes/class-instagram-feed.php';
22
+ require_once WIG_COMPONENT_DIR . '/includes/class-instagram-profiles.php';
23
+ require_once WIG_COMPONENT_DIR . '/includes/class-instagram-widget.php';
components/youtube/html_templates/feeds.php CHANGED
@@ -7,55 +7,62 @@
7
  */
8
  ?>
9
  <div class="wisw-social-content">
10
- <div class="wisw-container-row">
11
- <a href="<?php echo $this->getActionUrl( 'add', [ 'social' => $social ] ); ?>"
12
- class="button action wis-add-feed-button"><?php _e( 'Add feed', 'instagram-slider-widget' ); ?></a>
13
- </div>
14
 
15
- <div class="wisw-container-row">
16
- <table class="widefat wis-table wis-personal-status">
17
- <thead>
18
- <tr>
19
- <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
20
- <th class="wis-profile-shortcode"><label for="wis_youtube_shortcode"><?php echo __( 'Shortcode', 'instagram-slider-widget' ); ?></label></th>
21
- <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
22
- </tr>
23
- </thead>
24
- <tbody>
 
 
25
  <?php
26
  if ( count( $feeds ) ) :
27
  foreach ( $feeds as $feed_id => $feed ) {
28
  $edit_link = $this->getActionUrl( 'edit', [ 'social' => $social, 'feed' => $feed_id ] );
29
- $delete_link = $this->getActionUrl( 'delete', [ 'social' => $social, 'feed' => $feed_id ] );
 
 
 
30
  ?>
31
- <tr>
32
- <td class="wis-profile-name">
33
- <a href="<?php echo $edit_link; ?>">
34
  <?php echo $feed->title; ?>
35
- </a>
36
- </td>
37
- <td class="wis-profile-shortcode">
38
- <input id="wis_youtube_shortcode" onclick="this.setSelectionRange(0, this.value.length)" type="text" class="form-input wis-shortcode-input"
39
- value="[cm_youtube_feed id=&quot;<?php echo $feed_id ?>&quot;]" readonly="readonly">
40
- </td>
41
- <td class="wis-profile-actions">
42
- <a href="<?php echo $edit_link; ?>" class="btn btn-primary">
43
- <span class="dashicons dashicons-edit"></span>
44
- </a>
45
- <a href="<?php echo $delete_link; ?>" class="btn btn-danger">
46
- <span class="dashicons dashicons-trash"></span>
47
- </a>
48
- </td>
49
- </tr>
 
50
  <?php
51
  }
52
  ?>
53
  <?php else: ?>
54
- <tr>
55
- <td class="wis-profile-nofeed" colspan="3"><?php echo __( 'No feeds', 'instagram-slider-widget' ); ?></td>
56
- </tr>
 
57
  <?php endif; ?>
58
- </tbody>
59
- </table>
60
- </div>
61
  </div>
7
  */
8
  ?>
9
  <div class="wisw-social-content">
10
+ <div class="wisw-container-row">
11
+ <a href="<?php echo $this->getActionUrl( 'add', [ 'social' => $social ] ); ?>"
12
+ class="button action wis-add-feed-button"><?php _e( 'Add feed', 'instagram-slider-widget' ); ?></a>
13
+ </div>
14
 
15
+ <div class="wisw-container-row">
16
+ <table class="widefat wis-table wis-personal-status">
17
+ <thead>
18
+ <tr>
19
+ <th class="wis-profile-name"><?php echo __( 'Name', 'instagram-slider-widget' ); ?></th>
20
+ <th class="wis-profile-shortcode"><label
21
+ for="wis_youtube_shortcode"><?php echo __( 'Shortcode', 'instagram-slider-widget' ); ?></label>
22
+ </th>
23
+ <th class="wis-profile-actions"><?php echo __( 'Action', 'instagram-slider-widget' ); ?></th>
24
+ </tr>
25
+ </thead>
26
+ <tbody>
27
  <?php
28
  if ( count( $feeds ) ) :
29
  foreach ( $feeds as $feed_id => $feed ) {
30
  $edit_link = $this->getActionUrl( 'edit', [ 'social' => $social, 'feed' => $feed_id ] );
31
+ $delete_link = wp_nonce_url( $this->getActionUrl( 'delete', [
32
+ 'social' => $social,
33
+ 'feed' => $feed_id,
34
+ ] ), 'wis_delete_feed', 'nonce' );
35
  ?>
36
+ <tr>
37
+ <td class="wis-profile-name">
38
+ <a href="<?php echo $edit_link; ?>">
39
  <?php echo $feed->title; ?>
40
+ </a>
41
+ </td>
42
+ <td class="wis-profile-shortcode">
43
+ <input id="wis_youtube_shortcode" onclick="this.setSelectionRange(0, this.value.length)"
44
+ type="text" class="form-input wis-shortcode-input"
45
+ value="[cm_youtube_feed id=&quot;<?php echo $feed_id ?>&quot;]" readonly="readonly">
46
+ </td>
47
+ <td class="wis-profile-actions">
48
+ <a href="<?php echo $edit_link; ?>" class="btn btn-primary">
49
+ <span class="dashicons dashicons-edit"></span>
50
+ </a>
51
+ <a href="<?php echo $delete_link; ?>" class="btn btn-danger">
52
+ <span class="dashicons dashicons-trash"></span>
53
+ </a>
54
+ </td>
55
+ </tr>
56
  <?php
57
  }
58
  ?>
59
  <?php else: ?>
60
+ <tr>
61
+ <td class="wis-profile-nofeed"
62
+ colspan="3"><?php echo __( 'No feeds', 'instagram-slider-widget' ); ?></td>
63
+ </tr>
64
  <?php endif; ?>
65
+ </tbody>
66
+ </table>
67
+ </div>
68
  </div>
includes/class-plugin.php CHANGED
@@ -1,273 +1,271 @@
1
- <?php
2
-
3
- // Exit if accessed directly
4
-
5
- if ( ! defined( 'ABSPATH' ) ) {
6
- exit;
7
- }
8
-
9
- /**
10
- * Основной класс плагина Social Slider Feed
11
- *
12
- * @author Artem Prihodko <webtemyk@yandex.ru>
13
- * @copyright (c) 2019 Webraftic Ltd
14
- * @version 1.0
15
- */
16
- class WIS_Plugin extends \Wbcr_Factory458_Plugin {
17
-
18
- /**
19
- * @see self::app()
20
- * @var \Wbcr_Factory458_Plugin
21
- */
22
- private static $app;
23
-
24
- /**
25
- * @var array Список слайдеров
26
- */
27
- public $sliders = [];
28
-
29
- /**
30
- * Статический метод для быстрого доступа к интерфейсу плагина.
31
- *
32
- * Позволяет разработчику глобально получить доступ к экземпляру класса плагина в любом месте
33
- * плагина, но при этом разработчик не может вносить изменения в основной класс плагина.
34
- *
35
- * Используется для получения настроек плагина, информации о плагине, для доступа к вспомогательным
36
- * классам.
37
- *
38
- * @return \Wbcr_Factory458_Plugin
39
- */
40
- public static function app() {
41
- return self::$app;
42
- }
43
-
44
- /**
45
- * Статический метод для быстрого доступа к классу соцсети.
46
- *
47
- * @param string $class
48
- *
49
- * @return $class
50
- */
51
- public static function social( $class ) {
52
- return new $class;
53
- }
54
-
55
- /**
56
- * Конструктор
57
- *
58
- * Подробнее о свойстве $app см. self::app()
59
- *
60
- * @param string $plugin_path
61
- * @param array $data
62
- *
63
- * @throws \Exception
64
- */
65
- public function __construct( $plugin_path, $data ) {
66
- $this->load_components();
67
-
68
- parent::__construct( $plugin_path, $data );
69
- self::$app = $this;
70
-
71
- if ( is_admin() ) {
72
- // Регистрации класса активации/деактивации плагина
73
- $this->init_activation();
74
-
75
- // Инициализация скриптов для бэкенда
76
- $this->admin_scripts();
77
-
78
- //Подключение файла проверки лицензии
79
- require( WIS_PLUGIN_DIR . '/admin/ajax/check-license.php' );
80
- } else {
81
- $this->front_scripts();
82
- }
83
-
84
- $this->global_scripts();
85
- }
86
-
87
- protected function init_activation() {
88
- include_once( WIS_PLUGIN_DIR . '/admin/class-wis-activation.php' );
89
- $this->registerActivation( 'WIS_Activation' );
90
- }
91
-
92
- public function load_components() {
93
- $components = scandir( WIS_COMPONENTS_DIR );
94
- foreach ( $components as $key => $value ) {
95
- if ( ! in_array( $value, [ ".", ".." ] ) ) {
96
- $comp = WIS_COMPONENTS_DIR . "/" . $value;
97
- if ( is_dir( $comp ) ) {
98
- if ( file_exists( $comp . "/load.php" ) ) {
99
- require_once $comp . "/load.php";
100
- }
101
- }
102
- }
103
- }
104
- }
105
-
106
- /**
107
- * Регистрирует классы страниц в плагине
108
- */
109
- private function register_pages() {
110
- require_once WIS_PLUGIN_DIR . '/admin/class-page.php';
111
-
112
- self::app()->registerPage( 'WIS_FeedsPage', WIS_PLUGIN_DIR . '/admin/pages/feeds.php' );
113
- self::app()->registerPage( 'WIS_ProfilesPage', WIS_PLUGIN_DIR . '/admin/pages/profiles.php' );
114
- self::app()->registerPage( 'WIS_LicensePage', WIS_PLUGIN_DIR . '/admin/pages/license.php' );
115
- self::app()->registerPage( 'WIS_LogPage', WIS_PLUGIN_DIR . '/admin/pages/log.php' );
116
- self::app()->registerPage( 'Manual', WIS_PLUGIN_DIR . '/admin/pages/manual.php' );
117
-
118
- self::app()->registerPage( 'WIS_AboutPage', WIS_PLUGIN_DIR . '/admin/pages/about.php' );
119
-
120
- }
121
-
122
- /**
123
- * Выполняет php сценарии, когда все Wordpress плагины будут загружены
124
- *
125
- * @throws \Exception
126
- * @since 1.0.0
127
- * @author Alexander Kovalev <alex.kovalevv@gmail.com>
128
- */
129
- public function plugins_loaded() {
130
- if ( is_admin() ) {
131
- $this->register_pages();
132
- }
133
- }
134
-
135
- /**
136
- * Код для админки
137
- */
138
- private function admin_scripts() {
139
- add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
140
-
141
- add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_assets' ] );
142
- add_action( 'admin_notices', [ $this, 'new_api_admin_notice' ] );
143
- add_action( 'admin_notices', [ $this, 'check_token_admin_notice' ] );
144
- }
145
-
146
- /**
147
- * Код для админки и фронтенда
148
- */
149
- private function global_scripts() {
150
- /**
151
- * On widgets Init register Widget
152
- */
153
- add_action( 'plugins_loaded', function () {
154
- add_action( 'widgets_init', [ 'WIG_Widget', 'register_widget' ] );
155
- add_action( 'widgets_init', [ 'WFB_Widget', 'register_widget' ] );
156
- add_action( 'widgets_init', [ 'WYT_Widget', 'register_widget' ] );
157
- } );
158
- }
159
-
160
- /**
161
- * Код для фронтенда
162
- */
163
- private function front_scripts() {
164
- add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_assets' ] );
165
- }
166
-
167
- public function admin_enqueue_assets( $hook ) {
168
- if ( 'widgets.php' == $hook || 'post.php' == $hook ) {
169
- //wp_enqueue_style( 'jr-insta-admin-styles', WIS_PLUGIN_URL . '/admin/assets/css/jr-insta-admin.css', array(), WIS_PLUGIN_VERSION );
170
- //wp_enqueue_script( 'jr-insta-admin-script', WIS_PLUGIN_URL . '/admin/assets/js/jr-insta-admin.js', array( 'jquery' ), WIS_PLUGIN_VERSION, true );
171
- wp_enqueue_script( 'jr-tinymce-button', WIS_PLUGIN_URL . '/admin/assets/js/tinymce_button.js', [ 'jquery' ], WIS_PLUGIN_VERSION, false );
172
-
173
- $wis_shortcodes = json_encode( $this->get_isw_widgets() );
174
- wp_add_inline_script( 'jr-tinymce-button', "var wis_shortcodes = $wis_shortcodes;" );
175
-
176
- /*
177
- $account_nonce = json_encode( [ 'nonce' => wp_create_nonce( "addAccountByToken" ) ] );
178
- $wis_nonce = json_encode( [
179
- 'nonce' => wp_create_nonce( 'wis_nonce' ),
180
- 'remove_account' => __( 'Are you sure want to delete this account?', 'instagram-slider-widget' ),
181
- ] );
182
- wp_add_inline_script( 'jr-insta-admin-script', "var add_account_nonce = $account_nonce; var wis = $wis_nonce;" );
183
- */
184
- }
185
-
186
- }
187
-
188
- public function enqueue_assets() {
189
-
190
- }
191
-
192
- /**
193
- * Метод проверяет активацию премиум плагина и наличие действующего лицензионного ключа
194
- *
195
- * @return bool
196
- */
197
- public function is_premium() {
198
- if ( $this->premium->is_active() && $this->premium->is_activate() //&& is_plugin_active( "{$this->premium->get_setting('slug')}/{$this->premium->get_setting('slug')}.php" )
199
- ) {
200
- return true;
201
- } else {
202
- return false;
203
- }
204
- }
205
-
206
- /**
207
- * Получает все виджеты этого плагина
208
- *
209
- * @return array
210
- */
211
- public function get_isw_widgets() {
212
- $settings = WIG_Widget::app()->get_settings();
213
- $result = [];
214
- foreach ( $settings as $key => $widget ) {
215
- $result[] = [
216
- 'title' => $widget['title'],
217
- 'id' => $key,
218
- ];
219
- }
220
-
221
- return $result;
222
- }
223
-
224
- /**
225
- * Выводит нотис о том, что изменилось в новой версии
226
- *
227
- */
228
- public function new_api_admin_notice() {
229
- $text = "";
230
- $accounts = $this->getOption( WIG_PROFILES_OPTION, [] );
231
- if ( count( $accounts ) ) {
232
- foreach ( $accounts as $account ) {
233
- if ( strlen( $account['token'] ) < 55 ) {
234
- $text .= "<p><b>@" . $account['username'] . "</b></p>";
235
- }
236
- }
237
- }
238
- if ( ! empty( $text ) ) {
239
- ?>
240
- <div class="notice notice-info is-dismissible">
241
- <p>
242
- <b>Social Slider Feed:</b><br>
243
- The plugin has moved to the new Instagram Basic Display API.<br>
244
- To make your widgets work again, reconnect your instagram accounts in the plugin settings.
245
- <a href="https://cm-wp.com/important-update-social-slider-widget/" class="">Read more about the
246
- changes</a>
247
- </p>
248
- </div>
249
- <?php
250
- }
251
- }
252
-
253
- /**
254
- * Выводит нотис о том, что нужно обновить токены
255
- *
256
- */
257
- public function check_token_admin_notice() {
258
- $text = "";
259
- $accounts = $this->getOption( WIG_PROFILES_OPTION, [] );
260
- if ( count( $accounts ) ) {
261
- foreach ( $accounts as $account ) {
262
- if ( strlen( $account['token'] ) < 55 ) {
263
- $text .= "<p><b>@" . $account['username'] . "</b></p>";
264
- }
265
- }
266
- }
267
- if ( ! empty( $text ) ) {
268
- echo '<div class="notice notice-warning">
269
- <p><b>Social Slider Feed:</b><br>You need to reconnect this accounts in the <a href="' . admin_url( "admin.php?page=settings-wisw&tab=instagram" ) . '">plugin settings</a>' . $text . '</p>
270
- </div>';
271
- }
272
- }
273
- }
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ /**
10
+ * Основной класс плагина Social Slider Feed
11
+ *
12
+ * @author Artem Prihodko <webtemyk@yandex.ru>
13
+ * @copyright (c) 2019 Webraftic Ltd
14
+ * @version 1.0
15
+ */
16
+ class WIS_Plugin extends \Wbcr_Factory458_Plugin {
17
+
18
+ /**
19
+ * @see self::app()
20
+ * @var \Wbcr_Factory458_Plugin
21
+ */
22
+ private static $app;
23
+
24
+ /**
25
+ * @var array Список слайдеров
26
+ */
27
+ public $sliders = [];
28
+
29
+ /**
30
+ * Статический метод для быстрого доступа к интерфейсу плагина.
31
+ *
32
+ * Позволяет разработчику глобально получить доступ к экземпляру класса плагина в любом месте
33
+ * плагина, но при этом разработчик не может вносить изменения в основной класс плагина.
34
+ *
35
+ * Используется для получения настроек плагина, информации о плагине, для доступа к вспомогательным
36
+ * классам.
37
+ *
38
+ * @return \Wbcr_Factory458_Plugin
39
+ */
40
+ public static function app() {
41
+ return self::$app;
42
+ }
43
+
44
+ /**
45
+ * Статический метод для быстрого доступа к классу соцсети.
46
+ *
47
+ * @param string $class
48
+ *
49
+ * @return $class
50
+ */
51
+ public static function social( $class ) {
52
+ return new $class();
53
+ }
54
+
55
+ /**
56
+ * Конструктор
57
+ *
58
+ * Подробнее о свойстве $app см. self::app()
59
+ *
60
+ * @param string $plugin_path
61
+ * @param array $data
62
+ *
63
+ * @throws \Exception
64
+ */
65
+ public function __construct( $plugin_path, $data ) {
66
+ $this->load_components();
67
+
68
+ parent::__construct( $plugin_path, $data );
69
+ self::$app = $this;
70
+
71
+ if ( is_admin() ) {
72
+ // Регистрации класса активации/деактивации плагина
73
+ $this->init_activation();
74
+
75
+ // Инициализация скриптов для бэкенда
76
+ $this->admin_scripts();
77
+
78
+ //Подключение файла проверки лицензии
79
+ require WIS_PLUGIN_DIR . '/admin/ajax/check-license.php';
80
+ } else {
81
+ $this->front_scripts();
82
+ }
83
+
84
+ $this->global_scripts();
85
+ }
86
+
87
+ protected function init_activation() {
88
+ include_once WIS_PLUGIN_DIR . '/admin/class-wis-activation.php';
89
+ $this->registerActivation( 'WIS_Activation' );
90
+ }
91
+
92
+ public function load_components() {
93
+ $components = scandir( WIS_COMPONENTS_DIR );
94
+ foreach ( $components as $key => $value ) {
95
+ if ( ! in_array( $value, [ '.', '..' ] ) ) {
96
+ $comp = WIS_COMPONENTS_DIR . '/' . $value;
97
+ if ( is_dir( $comp ) ) {
98
+ if ( file_exists( $comp . '/load.php' ) ) {
99
+ require_once $comp . '/load.php';
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Регистрирует классы страниц в плагине
108
+ */
109
+ private function register_pages() {
110
+ require_once WIS_PLUGIN_DIR . '/admin/class-page.php';
111
+
112
+ self::app()->registerPage( 'WIS_FeedsPage', WIS_PLUGIN_DIR . '/admin/pages/feeds.php' );
113
+ self::app()->registerPage( 'WIS_ProfilesPage', WIS_PLUGIN_DIR . '/admin/pages/profiles.php' );
114
+ self::app()->registerPage( 'WIS_LicensePage', WIS_PLUGIN_DIR . '/admin/pages/license.php' );
115
+ self::app()->registerPage( 'WIS_LogPage', WIS_PLUGIN_DIR . '/admin/pages/log.php' );
116
+ self::app()->registerPage( 'Manual', WIS_PLUGIN_DIR . '/admin/pages/manual.php' );
117
+
118
+ self::app()->registerPage( 'WIS_AboutPage', WIS_PLUGIN_DIR . '/admin/pages/about.php' );
119
+
120
+ }
121
+
122
+ /**
123
+ * Выполняет php сценарии, когда все WordPress плагины будут загружены
124
+ *
125
+ * @throws \Exception
126
+ * @since 1.0.0
127
+ * @author Alexander Kovalev <alex.kovalevv@gmail.com>
128
+ */
129
+ public function plugins_loaded() {
130
+ if ( is_admin() ) {
131
+ $this->register_pages();
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Код для админки
137
+ */
138
+ private function admin_scripts() {
139
+ add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
140
+
141
+ add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_assets' ] );
142
+ add_action( 'admin_notices', [ $this, 'new_api_admin_notice' ] );
143
+ add_action( 'admin_notices', [ $this, 'check_token_admin_notice' ] );
144
+ }
145
+
146
+ /**
147
+ * Код для админки и фронтенда
148
+ */
149
+ private function global_scripts() {
150
+ /**
151
+ * On widgets Init register Widget
152
+ */
153
+ add_action( 'plugins_loaded', function () {
154
+ add_action( 'widgets_init', [ 'WIG_Widget', 'register_widget' ] );
155
+ add_action( 'widgets_init', [ 'WFB_Widget', 'register_widget' ] );
156
+ add_action( 'widgets_init', [ 'WYT_Widget', 'register_widget' ] );
157
+ } );
158
+ }
159
+
160
+ /**
161
+ * Код для фронтенда
162
+ */
163
+ private function front_scripts() {
164
+ add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_assets' ] );
165
+ }
166
+
167
+ public function admin_enqueue_assets( $hook ) {
168
+ if ( 'widgets.php' == $hook || 'post.php' == $hook ) {
169
+ //wp_enqueue_style( 'jr-insta-admin-styles', WIS_PLUGIN_URL . '/admin/assets/css/jr-insta-admin.css', array(), WIS_PLUGIN_VERSION );
170
+ //wp_enqueue_script( 'jr-insta-admin-script', WIS_PLUGIN_URL . '/admin/assets/js/jr-insta-admin.js', array( 'jquery' ), WIS_PLUGIN_VERSION, true );
171
+ wp_enqueue_script( 'jr-tinymce-button', WIS_PLUGIN_URL . '/admin/assets/js/tinymce_button.js', [ 'jquery' ], WIS_PLUGIN_VERSION, false );
172
+
173
+ $wis_shortcodes = json_encode( $this->get_isw_widgets() );
174
+ wp_add_inline_script( 'jr-tinymce-button', "var wis_shortcodes = $wis_shortcodes;" );
175
+
176
+ /*
177
+ $account_nonce = json_encode( [ 'nonce' => wp_create_nonce( "addAccountByToken" ) ] );
178
+ $wis_nonce = json_encode( [
179
+ 'nonce' => wp_create_nonce( 'wis_nonce' ),
180
+ 'remove_account' => __( 'Are you sure want to delete this account?', 'instagram-slider-widget' ),
181
+ ] );
182
+ wp_add_inline_script( 'jr-insta-admin-script', "var add_account_nonce = $account_nonce; var wis = $wis_nonce;" );
183
+ */
184
+ }
185
+
186
+ }
187
+
188
+ public function enqueue_assets() {
189
+
190
+ }
191
+
192
+ /**
193
+ * Метод проверяет активацию премиум плагина и наличие действующего лицензионного ключа
194
+ *
195
+ * @return bool
196
+ */
197
+ public function is_premium() {
198
+ if ( $this->premium->is_active() && $this->premium->is_activate() //&& is_plugin_active( "{$this->premium->get_setting('slug')}/{$this->premium->get_setting('slug')}.php" )
199
+ ) {
200
+ return true;
201
+ } else {
202
+ return false;
203
+ }
204
+ }
205
+
206
+ /**
207
+ * Получает все виджеты этого плагина
208
+ *
209
+ * @return array
210
+ */
211
+ public function get_isw_widgets() {
212
+ $settings = WIG_Widget::app()->get_settings();
213
+ $result = [];
214
+ foreach ( $settings as $key => $widget ) {
215
+ $result[] = [
216
+ 'title' => $widget['title'],
217
+ 'id' => $key,
218
+ ];
219
+ }
220
+
221
+ return $result;
222
+ }
223
+
224
+ /**
225
+ * Выводит нотис о том, что изменилось в новой версии
226
+ */
227
+ public function new_api_admin_notice() {
228
+ $text = '';
229
+ $accounts = $this->getOption( WIG_PROFILES_OPTION, [] );
230
+ if ( count( $accounts ) ) {
231
+ foreach ( $accounts as $account ) {
232
+ if ( strlen( $account['token'] ) < 55 ) {
233
+ $text .= '<p><b>@' . $account['username'] . '</b></p>';
234
+ }
235
+ }
236
+ }
237
+ if ( ! empty( $text ) ) {
238
+ ?>
239
+ <div class="notice notice-info is-dismissible">
240
+ <p>
241
+ <b>Social Slider Feed:</b><br>
242
+ The plugin has moved to the new Instagram Basic Display API.<br>
243
+ To make your widgets work again, reconnect your instagram accounts in the plugin settings.
244
+ <a href="https://cm-wp.com/important-update-social-slider-widget/" class="">Read more about the
245
+ changes</a>
246
+ </p>
247
+ </div>
248
+ <?php
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Выводит нотис о том, что нужно обновить токены
254
+ */
255
+ public function check_token_admin_notice() {
256
+ $text = '';
257
+ $accounts = $this->getOption( WIG_PROFILES_OPTION, [] );
258
+ if ( count( $accounts ) ) {
259
+ foreach ( $accounts as $account ) {
260
+ if ( strlen( $account['token'] ) < 55 ) {
261
+ $text .= '<p><b>@' . $account['username'] . '</b></p>';
262
+ }
263
+ }
264
+ }
265
+ if ( ! empty( $text ) ) {
266
+ echo '<div class="notice notice-warning">
267
+ <p><b>Social Slider Feed:</b><br>You need to reconnect this accounts in the <a href="' . admin_url( 'admin.php?page=settings-wisw&tab=instagram' ) . '">plugin settings</a>' . $text . '</p>
268
+ </div>';
269
+ }
270
+ }
271
+ }
 
 
instaram_slider.php CHANGED
@@ -1,156 +1,156 @@
1
- <?php
2
- /*
3
- Plugin Name: Social Slider Feed
4
- Plugin URI: https://cm-wp.com/instagram-slider-widget
5
- Version: 2.0.6
6
- Description: Shows Instagram, Facebook and YouTube responsive feeds in widgets, posts, pages, or anywhere else using shortcodes
7
- Author: creativemotion
8
- Author URI: https://cm-wp.com/
9
- Requires PHP: 7.0
10
- Text Domain: instagram-slider-widget
11
- Domain Path: /languages
12
- License: GPL2
13
- License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
- */
15
-
16
- // Exit if accessed directly
17
- if ( ! defined( 'ABSPATH' ) ) {
18
- exit;
19
- }
20
-
21
- // Подключаем класс проверки совместимости
22
- require_once dirname( __FILE__ ) . '/libs/factory/core/includes/class-factory-requirements.php';
23
- //require_once( dirname( __FILE__ ) . '/vendor/autoload.php' );
24
-
25
- $plugin_info = [
26
- 'prefix' => 'wis_',
27
- 'plugin_name' => 'wisw',
28
- 'plugin_title' => __( 'Social Slider Feed', 'instagram-slider-widget' ),
29
- 'plugin_text_domain' => 'instagram-slider-widget',
30
-
31
- // Служба поддержки
32
- 'support_details' => [
33
- 'url' => 'https://cm-wp.com/instagram-slider-widget',// Ссылка на сайт плагина
34
- 'pages_map' => [
35
- 'features' => 'premium-features', // {site}/premium-features "страница возможности"
36
- 'pricing' => 'pricing', // {site}/prices страница "цены"
37
- 'support' => 'support', // {site}/support страница "служба поддержки"
38
- 'docs' => 'docs' // {site}/docs страница "документация"
39
- ],
40
- ],
41
-
42
- // Настройка обновлений плагина
43
- 'has_updates' => true,
44
- 'updates_settings' => [
45
- 'repository' => 'wordpress',
46
- 'slug' => 'instagram-slider-widget',
47
- 'maybe_rollback' => true,
48
- 'rollback_settings' => [
49
- 'prev_stable_version' => '0.0.0',
50
- ],
51
- ],
52
-
53
- // Настройка премиум плагина
54
- 'has_premium' => true,
55
- 'license_settings' => [
56
- 'has_updates' => true,
57
- 'provider' => 'freemius',
58
- 'slug' => 'instagram-slider-widget-premium',
59
- 'plugin_id' => '4272',
60
- 'public_key' => 'pk_5152229a4aba03187267a8bc88874',
61
- 'price' => 39,
62
- 'updates_settings' => [
63
- 'maybe_rollback' => true, // Можно ли делать откат к предыдущей версии плагина?
64
- 'rollback_settings' => [
65
- 'prev_stable_version' => '0.0.0',
66
- ],
67
- ],
68
- ],
69
-
70
- // Настройки рекламы от CreativeMotion
71
- 'render_adverts' => true,
72
- 'adverts_settings' => [
73
- 'dashboard_widget' => true,
74
- 'right_sidebar' => true,
75
- 'notice' => true,
76
- ],
77
-
78
- // PLUGIN SUBSCRIBE FORM
79
- 'subscribe_widget' => true,
80
- 'subscribe_settings' => [ 'group_id' => '105407119' ],
81
-
82
- 'load_factory_modules' => [
83
- [ 'libs/factory/bootstrap', 'factory_bootstrap_459', 'admin' ],
84
- [ 'libs/factory/forms', 'factory_forms_455', 'admin' ],
85
- [ 'libs/factory/pages', 'factory_pages_457', 'admin' ],
86
- [ 'libs/factory/freemius', 'factory_freemius_145', 'all' ],
87
- [ 'libs/factory/adverts', 'factory_adverts_135', 'admin' ],
88
- [ 'libs/factory/templates', 'factory_templates_110', 'admin' ],
89
- [ 'libs/factory/logger', 'factory_logger_123', 'all' ],
90
- ],
91
- ];
92
-
93
- global $wis_compatibility;
94
-
95
- $wis_compatibility = new Wbcr_Factory458_Requirements( __FILE__, array_merge( $plugin_info, [
96
- 'plugin_already_activate' => defined( 'WIS_PLUGIN_ACTIVE' ),
97
- 'required_php_version' => '7.0',
98
- 'required_wp_version' => '4.8.0',
99
- 'required_clearfy_check_component' => false,
100
- ] ) );
101
-
102
- /**
103
- * If the plugin is compatible, then it will continue its work, otherwise it will be stopped,
104
- * and the user will throw a warning.
105
- */
106
- if ( ! $wis_compatibility->check() ) {
107
- return;
108
- }
109
- /********************************************/
110
- define( 'WIS_PLUGIN_ACTIVE', true );
111
- define( 'WIS_PLUGIN_VERSION', $wis_compatibility->get_plugin_version() );
112
- define( 'WIS_PLUGIN_FILE', __FILE__ );
113
- define( 'WIS_ABSPATH', dirname( __FILE__ ) );
114
- define( 'WIS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
115
- define( 'WIS_PLUGIN_SLUG', dirname( plugin_basename( __FILE__ ) ) );
116
- define( 'WIS_PLUGIN_URL', plugins_url( null, __FILE__ ) );
117
- define( 'WIS_PLUGIN_DIR', dirname( __FILE__ ) );
118
-
119
- define( 'WIS_COMPONENTS_URL', WIS_PLUGIN_URL . "/components" );
120
- define( 'WIS_COMPONENTS_DIR', WIS_PLUGIN_DIR . "/components" );
121
-
122
- define( 'WIS_FEEDS_OPTION', 'feeds' );
123
-
124
- /********************************************/
125
-
126
-
127
-
128
- /**
129
- * -----------------------------------------------------------------------------
130
- * PLUGIN INIT
131
- * -----------------------------------------------------------------------------
132
- */
133
- require_once WIS_PLUGIN_DIR . '/libs/factory/core/boot.php';
134
- require_once WIS_PLUGIN_DIR . '/includes/class-helper.php';
135
- require_once WIS_PLUGIN_DIR . '/includes/class-feed.php';
136
- require_once WIS_PLUGIN_DIR . '/includes/class-feeds.php';
137
- require_once WIS_PLUGIN_DIR . '/includes/class-profiles.php';
138
- require_once WIS_PLUGIN_DIR . '/includes/class-plugin.php';
139
- require_once WIS_PLUGIN_DIR . '/includes/class-wis-plugin-temp.php';
140
-
141
- try {
142
- new WIS_Plugin( __FILE__, array_merge( $plugin_info, [
143
- 'plugin_version' => WIS_PLUGIN_VERSION,
144
- ] ) );
145
- } catch ( Exception $e ) {
146
- // Plugin wasn't initialized due to an error
147
- define( 'WIS_PLUGIN_THROW_ERROR', true );
148
-
149
- $wis_plugin_error_func = function () use ( $e ) {
150
- $error = sprintf( "The %s plugin has stopped. <b>Error:</b> %s Code: %s", 'Social Slider Feed', $e->getMessage(), $e->getCode() );
151
- echo '<div class="notice notice-error"><p>' . $error . '</p></div>';
152
- };
153
-
154
- add_action( 'admin_notices', $wis_plugin_error_func );
155
- add_action( 'network_admin_notices', $wis_plugin_error_func );
156
- }
1
+ <?php
2
+ /*
3
+ Plugin Name: Social Slider Feed
4
+ Plugin URI: https://cm-wp.com/instagram-slider-widget
5
+ Version: 2.1.0
6
+ Description: Shows Instagram, Facebook and YouTube responsive feeds in widgets, posts, pages, or anywhere else using shortcodes
7
+ Author: creativemotion
8
+ Author URI: https://cm-wp.com/
9
+ Requires PHP: 7.0
10
+ Text Domain: instagram-slider-widget
11
+ Domain Path: /languages
12
+ License: GPL2
13
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
14
+ */
15
+
16
+ // Exit if accessed directly
17
+ if ( ! defined( 'ABSPATH' ) ) {
18
+ exit;
19
+ }
20
+
21
+ // Подключаем класс проверки совместимости
22
+ require_once dirname( __FILE__ ) . '/libs/factory/core/includes/class-factory-requirements.php';
23
+ //require_once( dirname( __FILE__ ) . '/vendor/autoload.php' );
24
+
25
+ $plugin_info = [
26
+ 'prefix' => 'wis_',
27
+ 'plugin_name' => 'wisw',
28
+ 'plugin_title' => __( 'Social Slider Feed', 'instagram-slider-widget' ),
29
+ 'plugin_text_domain' => 'instagram-slider-widget',
30
+
31
+ // Служба поддержки
32
+ 'support_details' => [
33
+ 'url' => 'https://cm-wp.com/instagram-slider-widget', // Ссылка на сайт плагина
34
+ 'pages_map' => [
35
+ 'features' => 'premium-features', // {site}/premium-features "страница возможности"
36
+ 'pricing' => 'pricing', // {site}/prices страница "цены"
37
+ 'support' => 'support', // {site}/support страница "служба поддержки"
38
+ 'docs' => 'docs', // {site}/docs страница "документация"
39
+ ],
40
+ ],
41
+
42
+ // Настройка обновлений плагина
43
+ 'has_updates' => true,
44
+ 'updates_settings' => [
45
+ 'repository' => 'wordpress',
46
+ 'slug' => 'instagram-slider-widget',
47
+ 'maybe_rollback' => true,
48
+ 'rollback_settings' => [
49
+ 'prev_stable_version' => '0.0.0',
50
+ ],
51
+ ],
52
+
53
+ // Настройка премиум плагина
54
+ 'has_premium' => true,
55
+ 'license_settings' => [
56
+ 'has_updates' => true,
57
+ 'provider' => 'freemius',
58
+ 'slug' => 'instagram-slider-widget-premium',
59
+ 'plugin_id' => '4272',
60
+ 'public_key' => 'pk_5152229a4aba03187267a8bc88874',
61
+ 'price' => 39,
62
+ 'updates_settings' => [
63
+ 'maybe_rollback' => true, // Можно ли делать откат к предыдущей версии плагина?
64
+ 'rollback_settings' => [
65
+ 'prev_stable_version' => '0.0.0',
66
+ ],
67
+ ],
68
+ ],
69
+
70
+ // Настройки рекламы от CreativeMotion
71
+ 'render_adverts' => true,
72
+ 'adverts_settings' => [
73
+ 'dashboard_widget' => true,
74
+ 'right_sidebar' => true,
75
+ 'notice' => true,
76
+ ],
77
+
78
+ // PLUGIN SUBSCRIBE FORM
79
+ 'subscribe_widget' => true,
80
+ 'subscribe_settings' => [ 'group_id' => '105407119' ],
81
+
82
+ 'load_factory_modules' => [
83
+ [ 'libs/factory/bootstrap', 'factory_bootstrap_459', 'admin' ],
84
+ [ 'libs/factory/forms', 'factory_forms_455', 'admin' ],
85
+ [ 'libs/factory/pages', 'factory_pages_457', 'admin' ],
86
+ [ 'libs/factory/freemius', 'factory_freemius_145', 'all' ],
87
+ [ 'libs/factory/adverts', 'factory_adverts_135', 'admin' ],
88
+ [ 'libs/factory/templates', 'factory_templates_110', 'admin' ],
89
+ [ 'libs/factory/logger', 'factory_logger_123', 'all' ],
90
+ ],
91
+ ];
92
+
93
+ global $wis_compatibility;
94
+
95
+ $wis_compatibility = new Wbcr_Factory458_Requirements( __FILE__, array_merge( $plugin_info, [
96
+ 'plugin_already_activate' => defined( 'WIS_PLUGIN_ACTIVE' ),
97
+ 'required_php_version' => '7.0',
98
+ 'required_wp_version' => '4.8.0',
99
+ 'required_clearfy_check_component' => false,
100
+ ] ) );
101
+
102
+ /**
103
+ * If the plugin is compatible, then it will continue its work, otherwise it will be stopped,
104
+ * and the user will throw a warning.
105
+ */
106
+ if ( ! $wis_compatibility->check() ) {
107
+ return;
108
+ }
109
+ /********************************************/
110
+ define( 'WIS_PLUGIN_ACTIVE', true );
111
+ define( 'WIS_PLUGIN_VERSION', $wis_compatibility->get_plugin_version() );
112
+ define( 'WIS_PLUGIN_FILE', __FILE__ );
113
+ define( 'WIS_ABSPATH', dirname( __FILE__ ) );
114
+ define( 'WIS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
115
+ define( 'WIS_PLUGIN_SLUG', dirname( plugin_basename( __FILE__ ) ) );
116
+ define( 'WIS_PLUGIN_URL', plugins_url( null, __FILE__ ) );
117
+ define( 'WIS_PLUGIN_DIR', dirname( __FILE__ ) );
118
+
119
+ define( 'WIS_COMPONENTS_URL', WIS_PLUGIN_URL . '/components' );
120
+ define( 'WIS_COMPONENTS_DIR', WIS_PLUGIN_DIR . '/components' );
121
+
122
+ define( 'WIS_FEEDS_OPTION', 'feeds' );
123
+
124
+ /********************************************/
125
+
126
+
127
+
128
+ /**
129
+ * -----------------------------------------------------------------------------
130
+ * PLUGIN INIT
131
+ * -----------------------------------------------------------------------------
132
+ */
133
+ require_once WIS_PLUGIN_DIR . '/libs/factory/core/boot.php';
134
+ require_once WIS_PLUGIN_DIR . '/includes/class-helper.php';
135
+ require_once WIS_PLUGIN_DIR . '/includes/class-feed.php';
136
+ require_once WIS_PLUGIN_DIR . '/includes/class-feeds.php';
137
+ require_once WIS_PLUGIN_DIR . '/includes/class-profiles.php';
138
+ require_once WIS_PLUGIN_DIR . '/includes/class-plugin.php';
139
+ require_once WIS_PLUGIN_DIR . '/includes/class-wis-plugin-temp.php';
140
+
141
+ try {
142
+ new WIS_Plugin( __FILE__, array_merge( $plugin_info, [
143
+ 'plugin_version' => WIS_PLUGIN_VERSION,
144
+ ] ) );
145
+ } catch ( Exception $e ) {
146
+ // Plugin wasn't initialized due to an error
147
+ define( 'WIS_PLUGIN_THROW_ERROR', true );
148
+
149
+ $wis_plugin_error_func = function () use ( $e ) {
150
+ $error = sprintf( 'The %s plugin has stopped. <b>Error:</b> %s Code: %s', 'Social Slider Feed', $e->getMessage(), $e->getCode() );
151
+ echo '<div class="notice notice-error"><p>' . $error . '</p></div>';
152
+ };
153
+
154
+ add_action( 'admin_notices', $wis_plugin_error_func );
155
+ add_action( 'network_admin_notices', $wis_plugin_error_func );
156
+ }
readme.txt CHANGED
@@ -2,8 +2,9 @@
2
  Contributors: creativemotion
3
  Tags: instagram, instagram feed, instagram gallery, instagram photos, Instagram widget
4
  Requires at least: 5.0
5
- Tested up to: 6.0
6
  Requires PHP: 7.0
 
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -109,6 +110,12 @@ If you don't use an account in the widget, go to the plugin settings and add an
109
 
110
  == Changelog ==
111
 
 
 
 
 
 
 
112
  = 2.0.6 =
113
  * Fix security issues
114
 
2
  Contributors: creativemotion
3
  Tags: instagram, instagram feed, instagram gallery, instagram photos, Instagram widget
4
  Requires at least: 5.0
5
+ Tested up to: 6.1
6
  Requires PHP: 7.0
7
+ Stable tag: 2.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
110
 
111
  == Changelog ==
112
 
113
+ = 2.1.0 =
114
+ * Fix instagram and facebook feed. Need to reconnect all accounts!
115
+
116
+ = 2.0.7 =
117
+ * Fix security issues
118
+
119
  = 2.0.6 =
120
  * Fix security issues
121