WD Instagram Feed – Instagram Gallery - Version 1.3.12

Version Description

Fixed: Conflict with Gutenberg.

Download this release

Release Info

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

Code changes from version 1.3.11 to 1.3.12

Files changed (7) hide show
  1. changelog.txt +3 -0
  2. css/block.css +57 -0
  3. css/wdi_block.css +0 -29
  4. js/block.js +200 -0
  5. js/wdi_block.js +0 -189
  6. readme.txt +4 -1
  7. wd-instagram-feed.php +54 -32
changelog.txt CHANGED
@@ -1,3 +1,6 @@
 
 
 
1
  = 1.3.11 =
2
  New: Create hashtag feeds for business profiles using Instagram Graph API
3
 
1
+ = 1.3.12 =
2
+ Fixed: Conflict with Gutenberg.
3
+
4
  = 1.3.11 =
5
  New: Create hashtag feeds for business profiles using Instagram Graph API
6
 
css/block.css ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * 10Web plugins Gutenberg integration
3
+ * version 2.0.3
4
+ */
5
+ .tw-container {
6
+ position: fixed;
7
+ top: 0;
8
+ left: 0;
9
+ right: 0;
10
+ bottom: 0;
11
+ z-index: 9999999;
12
+ background: rgba(0,0,0,0.7);
13
+ }
14
+
15
+ .tw-container .tw-container-wrap {
16
+ background: #fff;
17
+ height: 100%;
18
+ width: 100%;
19
+ position: absolute;
20
+ top: 0;
21
+ bottom: 0;
22
+ margin: auto;
23
+ right: 0;
24
+ left: 0;
25
+ padding-top: 40px;
26
+ }
27
+
28
+ .tw-container .tw-container-wrap-800-540 {
29
+ max-width: 800px;
30
+ max-height: 540px;
31
+ }
32
+
33
+ .tw-container .tw-container-wrap-520-400 {
34
+ max-width: 520px;
35
+ max-height: 400px;
36
+ }
37
+
38
+ .tw-container .tw-container-wrap-420-450 {
39
+ max-width: 420px;
40
+ max-height: 450px;
41
+ }
42
+
43
+ .tw-container .tw-container-wrap .media-modal-close{
44
+ line-height: 34px;
45
+ text-align: center;
46
+ height: 40px;
47
+ top: 10px;
48
+ }
49
+
50
+ .tw-container .tw-container-wrap iframe {
51
+ height: 100%;
52
+ width: 100%;
53
+ }
54
+ .tw-gb-select {
55
+ width: 100%;
56
+ height: auto !important;
57
+ }
css/wdi_block.css DELETED
@@ -1,29 +0,0 @@
1
- .tw-container {
2
- position: fixed;
3
- top: 0;
4
- left: 0;
5
- right: 0;
6
- bottom: 0;
7
- z-index: 9999999;
8
- background: rgba(0,0,0,0.7);
9
- }
10
-
11
- .tw-container .tw-container-wrap {
12
- height: 90%;
13
- background: #fff;
14
- width: 90%;
15
- position: absolute;
16
- top: 5%;
17
- left: 5%;
18
- }
19
-
20
- .tw-container .tw-container-wrap .media-modal-close{
21
- line-height: 34px;
22
- text-align: center;
23
- height: 40px;
24
- }
25
-
26
- .tw-container .tw-container-wrap iframe {
27
- height: 100%;
28
- width: 100%;
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/block.js ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * 10Web plugins Gutenberg integration
3
+ * version 2.0.3
4
+ */
5
+ ( function ( blocks, element ) {
6
+ registerAllPluginBlocks();
7
+
8
+ function registerAllPluginBlocks() {
9
+ var twPluginsData = JSON.parse(tw_obj_translate.blocks);
10
+ for ( var pluginId in window['tw_gb'] ) {
11
+ if ( !window['tw_gb'].hasOwnProperty( pluginId ) ) {
12
+ continue;
13
+ }
14
+ twPluginsData[pluginId] = window['tw_gb'][pluginId];
15
+ }
16
+ if ( !twPluginsData ) {
17
+ return;
18
+ }
19
+
20
+ for ( var pluginId in twPluginsData ) {
21
+ if ( !twPluginsData.hasOwnProperty( pluginId ) ) {
22
+ continue;
23
+ }
24
+
25
+ if ( !twPluginsData[pluginId].inited ) {
26
+ twPluginsData[pluginId].inited = true;
27
+ registerPluginBlock( blocks, element, pluginId, twPluginsData[pluginId] );
28
+ }
29
+ }
30
+ }
31
+
32
+ function registerPluginBlock( blocks, element, pluginId, pluginData ) {
33
+ var el = element.createElement;
34
+
35
+ var isPopup = pluginData.isPopup;
36
+
37
+ var iconEl = el( 'img', {
38
+ width: pluginData.iconSvg.width,
39
+ height: pluginData.iconSvg.height,
40
+ src: pluginData.iconSvg.src
41
+ } );
42
+
43
+ blocks.registerBlockType( pluginId, {
44
+ title: pluginData.title,
45
+ icon: iconEl,
46
+ category: 'common',
47
+ attributes: {
48
+ shortcode: {
49
+ type: 'string'
50
+ },
51
+ popupOpened: {
52
+ type: 'boolean',
53
+ value: true
54
+ },
55
+ notInitial: {
56
+ type: 'boolean'
57
+ },
58
+ shortcode_id: {
59
+ type: 'string'
60
+ }
61
+ },
62
+
63
+ edit: function ( props ) {
64
+ if ( !props.attributes.notInitial ) {
65
+ props.setAttributes( {
66
+ notInitial: true,
67
+ popupOpened: true
68
+ } );
69
+
70
+ return el( 'p' );
71
+ }
72
+
73
+ if ( props.attributes.popupOpened ) {
74
+ if ( isPopup ) {
75
+ return showPopup( props.attributes.shortcode, props.attributes.shortcode_id );
76
+ }
77
+ else {
78
+ return showShortcodeList( props.attributes.shortcode );
79
+ }
80
+ }
81
+
82
+ if ( props.attributes.shortcode ) {
83
+ return showShortcode();
84
+ }
85
+ else {
86
+ return showShortcodePlaceholder();
87
+ }
88
+
89
+ function showPopup( shortcode, shortcode_id ) {
90
+ var shortcodeCbName = generateUniqueCbName( pluginId );
91
+ /* Store shortcode attribute into a global variable to get it from an iframe. */
92
+ window[shortcodeCbName + '_shortcode'] = shortcode ? shortcode : '';
93
+ window[shortcodeCbName] = function ( shortcode, shortcode_id ) {
94
+ delete window[shortcodeCbName];
95
+
96
+ if ( props ) {
97
+ props.setAttributes( { shortcode: shortcode, shortcode_id: shortcode_id, popupOpened: false } );
98
+ }
99
+ };
100
+ props.setAttributes( { popupOpened: true } );
101
+ if (!shortcode_id && undefined != shortcode) {
102
+ var shortcode_extract = shortcode.split(' ');
103
+ for (i = 0; i < shortcode_extract.length; i++) {
104
+ var attributes = shortcode_extract[i].split('=');
105
+ if ('id'== attributes[0]) {
106
+ shortcode_id = attributes[1].replace(/"/g, "");
107
+ }
108
+ }
109
+ }
110
+ var elem = el( 'form', { className: 'tw-container' }, el( 'div', { className: 'tw-container-wrap' + (pluginData.containerClass ? ' ' + pluginData.containerClass : '') }, el( 'span', {
111
+ className: "media-modal-close",
112
+ onClick: close
113
+ }, el( "span", { className: "media-modal-icon" } ) ), el( 'iframe', { src: pluginData.data.shortcodeUrl + '&callback=' + shortcodeCbName + '&edit=' + shortcode_id } ) ) );
114
+ return elem;
115
+ }
116
+
117
+ function showShortcodeList( shortcode ) {
118
+ props.setAttributes( { popupOpened: true } );
119
+ var children = [];
120
+ var shortcodeList = JSON.parse( pluginData.data );
121
+ shortcodeList.inputs.forEach( function ( inputItem ) {
122
+ if ( inputItem.type === 'select' ) {
123
+ children.push( el( 'option', { value: '', dataId: 0 }, tw_obj_translate.empty_item ) );
124
+ if ( inputItem.options.length ) {
125
+ inputItem.options.forEach( function ( optionItem ) {
126
+ var shortcode = '[' + shortcodeList.shortcode_prefix + ' ' + inputItem.shortcode_attibute_name + '="' + optionItem.id + '"]';
127
+ children.push(
128
+ el( 'option', { value: shortcode, dataId: optionItem.id }, optionItem.name )
129
+ );
130
+ } )
131
+ }
132
+ }
133
+ } );
134
+
135
+ if ( shortcodeList.shortcodes ) {
136
+ shortcodeList.shortcodes.forEach( function ( shortcodeItem ) {
137
+ children.push(
138
+ el( 'option', { value: shortcodeItem.shortcode, dataId: shortcodeItem.id }, shortcodeItem.name )
139
+ );
140
+ } );
141
+ }
142
+
143
+ return el( 'form', { onSubmit: chooseFromList }, el( 'div', {}, pluginData.titleSelect ), el( 'select', {
144
+ value: shortcode,
145
+ onChange: chooseFromList,
146
+ class: 'tw-gb-select'
147
+ }, children ) );
148
+ }
149
+
150
+ function showShortcodePlaceholder() {
151
+ props.setAttributes( { popupOpened: false } );
152
+ return el( 'p', {
153
+ style: {
154
+ 'cursor': "pointer"
155
+ },
156
+
157
+ onClick: function () {
158
+ props.setAttributes( { popupOpened: true } );
159
+ }.bind( this )
160
+ }, tw_obj_translate.nothing_selected );
161
+ }
162
+
163
+ function showShortcode() {
164
+ return el( 'img', {
165
+ src: pluginData.iconUrl,
166
+ alt: pluginData.title,
167
+ style: {
168
+ 'height': "36px",
169
+ 'width': "36px"
170
+ },
171
+ onClick: function () {
172
+ props.setAttributes( { popupOpened: true } );
173
+ }.bind( this )
174
+ } );
175
+ }
176
+
177
+ function close() {
178
+ props.setAttributes( { popupOpened: false } );
179
+ }
180
+
181
+ function chooseFromList( event, shortcode_id ) {
182
+ var selected = event.target.querySelector( 'option:checked' );
183
+ props.setAttributes( { shortcode: selected.value, shortcode_id: selected.dataId, popupOpened: false } );
184
+ event.preventDefault();
185
+ }
186
+ },
187
+
188
+ save: function ( props ) {
189
+ return props.attributes.shortcode;
190
+ }
191
+ } );
192
+ }
193
+
194
+ function generateUniqueCbName( pluginId ) {
195
+ return 'wdg_cb_' + pluginId;
196
+ }
197
+ } )(
198
+ window.wp.blocks,
199
+ window.wp.element
200
+ );
js/wdi_block.js DELETED
@@ -1,189 +0,0 @@
1
- (function( blocks, element ) {
2
- var wdi_gutenberg_block = function () {
3
- registerAllPluginBlocks();
4
-
5
- function registerAllPluginBlocks() {
6
- var twPluginsData = window['tw_gb_wdi'];
7
- if (!twPluginsData) {
8
- return;
9
- }
10
-
11
- for (var pluginId in twPluginsData) {
12
- if (!twPluginsData.hasOwnProperty(pluginId)) {
13
- continue;
14
- }
15
-
16
- if (!twPluginsData[pluginId].inited) {
17
- twPluginsData[pluginId].inited = true;
18
- registerPluginBlock(blocks, element, pluginId, twPluginsData[pluginId]);
19
- }
20
- }
21
- }
22
-
23
- function registerPluginBlock(blocks, element, pluginId, pluginData) {
24
- var el = element.createElement;
25
-
26
- var isPopup = pluginData.isPopup;
27
-
28
- var iconEl = el('img', {
29
- width: pluginData.iconSvg.width,
30
- height: pluginData.iconSvg.height,
31
- src: pluginData.iconSvg.src
32
- });
33
-
34
- blocks.registerBlockType(pluginId, {
35
- title: pluginData.title,
36
- icon: iconEl,
37
- category: 'common',
38
- attributes: {
39
- shortcode: {
40
- type: 'string'
41
- },
42
- popupOpened: {
43
- type: 'boolean',
44
- value: true
45
- },
46
- notInitial: {
47
- type: 'boolean'
48
- },
49
- shortcode_id: {
50
- type: 'string'
51
- }
52
- },
53
-
54
- edit: function (props) {
55
- if (!props.attributes.notInitial) {
56
- props.setAttributes({
57
- notInitial: true,
58
- popupOpened: true
59
- });
60
-
61
- return el('p');
62
- }
63
-
64
- if (props.attributes.popupOpened) {
65
- if (isPopup) {
66
- return showPopup(props.attributes.shortcode_id);
67
- }
68
- else {
69
- return showShortcodeList(props.attributes.shortcode);
70
- }
71
- }
72
-
73
- if (props.attributes.shortcode) {
74
- return showShortcode();
75
- }
76
- else {
77
- return showShortcodePlaceholder();
78
- }
79
-
80
-
81
- function showPopup(shortcode_id) {
82
- var shortcodeCbName = generateUniqueCbName(pluginId);
83
- window[shortcodeCbName] = function (shortcode, shortcode_id) {
84
- delete window[shortcodeCbName];
85
-
86
- if (props) {
87
- if (!shortcode_id) {
88
- props.setAttributes({shortcode: shortcode, shortcode_id: shortcode, popupOpened: false});
89
- }
90
- else {
91
- props.setAttributes({shortcode: shortcode, shortcode_id: shortcode_id, popupOpened: false});
92
- }
93
- }
94
- };
95
- props.setAttributes({popupOpened: true});
96
- var elem = el('form', {className: 'tw-container'}, el('div', {className: "tw-container-wrap"}, el('span', {
97
- className: "media-modal-close",
98
- onClick: close
99
- }, el("span", {className: "media-modal-icon"})), el('iframe', {src: pluginData.data.shortcodeUrl + '&callback=' + shortcodeCbName + '&edit=' + shortcode_id})));
100
- return elem;
101
- }
102
-
103
- function showShortcodeList(shortcode) {
104
- props.setAttributes({popupOpened: true});
105
- var children = [];
106
- var shortcodeList = JSON.parse(pluginData.data);
107
- shortcodeList.inputs.forEach(function (inputItem) {
108
- if (inputItem.type === 'select') {
109
- children.push(el('option', null, '- Select -'));
110
- if (inputItem.options.length) {
111
- inputItem.options.forEach(function (optionItem) {
112
- var shortcode = '[' + shortcodeList.shortcode_prefix + ' ' + inputItem.shortcode_attibute_name + '="' + optionItem.id + '"]';
113
- children.push(
114
- el('option', {value: shortcode, dataId: optionItem.id}, optionItem.name)
115
- );
116
- })
117
- }
118
- }
119
- });
120
-
121
- if (shortcodeList.shortcodes) {
122
- shortcodeList.shortcodes.forEach(function (shortcodeItem) {
123
- children.push(
124
- el('option', {value: shortcodeItem.shortcode, dataId: shortcodeItem.id}, shortcodeItem.name)
125
- );
126
- });
127
- }
128
-
129
-
130
- return el('form', {onSubmit: chooseFromList}, el('div', {}, `Select ${pluginData.title}`), el('select', {
131
- value: shortcode,
132
- onChange: chooseFromList
133
- }, children));
134
- }
135
-
136
- function showShortcodePlaceholder() {
137
- props.setAttributes({popupOpened: false});
138
- return el('p', {
139
- style: {
140
- 'cursor': "pointer"
141
- },
142
-
143
- onClick: function () {
144
- props.setAttributes({popupOpened: true});
145
- }.bind(this)
146
- }, "You're not select any instagram. Click to choose instagram");
147
- }
148
-
149
- function showShortcode() {
150
- return el('img', {
151
- src: pluginData.iconUrl,
152
- alt: pluginData.title,
153
- style: {
154
- 'height': "36px",
155
- 'width': "36px"
156
- },
157
- onClick: function () {
158
- props.setAttributes({popupOpened: true});
159
- }.bind(this)
160
- });
161
- }
162
-
163
- function close() {
164
- props.setAttributes({popupOpened: false});
165
- }
166
-
167
- function chooseFromList(shortcode_id) {
168
-
169
- var selected = event.target.querySelector('option:checked');
170
- props.setAttributes({shortcode: selected.value, shortcode_id: selected.dataId, popupOpened: false});
171
- event.preventDefault();
172
- }
173
- },
174
-
175
- save: function (props) {
176
- return props.attributes.shortcode;
177
- }
178
- });
179
- }
180
-
181
- function generateUniqueCbName(pluginId) {
182
- return 'wdg_cb_' + pluginId;
183
- }
184
- }
185
- new wdi_gutenberg_block();
186
- } )(
187
- window.wp.blocks,
188
- window.wp.element
189
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: custom instagram feed, feed, instagram, hashtag, Instagram feed, instagram
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
  Tested up to: 5.0
7
- Stable tag: 1.3.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -502,6 +502,9 @@ Please make sure you don't have any important information before you proceed.
502
 
503
  == Changelog ==
504
 
 
 
 
505
  = 1.3.11 =
506
  New: Create hashtag feeds for business profiles using Instagram Graph API
507
 
4
  Requires at least: 3.9
5
  Requires PHP: 5.2
6
  Tested up to: 5.0
7
+ Stable tag: 1.3.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
502
 
503
  == Changelog ==
504
 
505
+ = 1.3.12 =
506
+ Fixed: Conflict with Gutenberg.
507
+
508
  = 1.3.11 =
509
  New: Create hashtag feeds for business profiles using Instagram Graph API
510
 
wd-instagram-feed.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Instagram Feed by 10Web
4
  Plugin URI: https://10web.io/plugins/wordpress-instagram-feed/
5
  Description: Instagram Feed by 10Web is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
- Version: 1.3.11
7
  Author: 10Web
8
  Author URI: https://10Web.io
9
  License: GPLv2 or later
@@ -20,7 +20,7 @@ define("WDI_META", "_".WDI_VAR."_meta");
20
  //define("wdi",'wdi');
21
  define('WDI_FEED_TABLE','wdi_feeds');
22
  define('WDI_THEME_TABLE','wdi_themes');
23
- define('WDI_VERSION','1.3.11');
24
  define('WDI_IS_PRO','false');
25
  $wdi_minify = ((isset($_GET['wdi_no_minify']) && $_GET['wdi_no_minify'] == "true") ? false : true);
26
  define('WDI_MINIFY', $wdi_minify);
@@ -68,7 +68,7 @@ function wdi_save_user_access_token(){
68
  return;
69
  }
70
 
71
- $business_accounts = [];
72
 
73
  foreach($accounts['data'] as $accounts_data) {
74
 
@@ -101,6 +101,36 @@ add_action('wp_ajax_nopriv_wdi_set_cache_data', 'wdi_set_cache_data');
101
 
102
  add_action('wp_ajax_wdi_set_reset_cache', 'wdi_set_reset_cache');
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  function wdi_set_reset_cache(){
105
  if(wp_verify_nonce($_POST["wdi_nonce"] , 'wdi_cache')) {
106
  global $wpdb;
@@ -619,37 +649,29 @@ function wdi_load_styles() {
619
 
620
  }
621
 
622
- add_action( 'enqueue_block_editor_assets', 'enqueue_block_editor_assets' );
623
 
624
- function enqueue_block_editor_assets() {
625
- $wd_bp_plugin_url = WDI_URL;
626
- $key = 'tw/wdi';
627
- $plugin_name = "Instagram WD";
628
- require_once(WDI_DIR . '/framework/WDILibrary.php');
629
- $data = WDILibrary::get_shortcode_data();
630
- $icon_url = $wd_bp_plugin_url . '/images/insta_2.svg';
631
- $icon_svg = $wd_bp_plugin_url . '/images/insta.svg';
632
- ?>
633
- <script>
634
- if ( !window['tw_gb_wdi'] ) {
635
- window['tw_gb_wdi'] = {};
636
  }
637
- if ( !window['tw_gb_wdi']['<?php echo $key; ?>'] ) {
638
- window['tw_gb_wdi']['<?php echo $key; ?>'] = {
639
- title: '<?php echo $plugin_name; ?>',
640
- iconUrl: '<?php echo $icon_url; ?>',
641
- iconSvg: {
642
- width: '30',
643
- height: '30',
644
- src: '<?php echo $icon_svg; ?>'
645
- },
646
- data: '<?php echo $data; ?>',
647
- };
648
- }
649
- </script>
650
- <?php
651
- wp_enqueue_style('wditw-gb-wdi_block', $wd_bp_plugin_url . '/css/wdi_block.css', array( 'wp-edit-blocks' ), WDI_VERSION );
652
- wp_enqueue_script( 'wditw-gb-wdi_block', $wd_bp_plugin_url . '/js/wdi_block.js', array( 'wp-blocks', 'wp-element' ), WDI_VERSION );
653
  }
654
 
655
  // Instagram WDI Widget.
3
  Plugin Name: Instagram Feed by 10Web
4
  Plugin URI: https://10web.io/plugins/wordpress-instagram-feed/
5
  Description: Instagram Feed by 10Web is a user-friendly tool for displaying user or hashtag-based feeds on your website. You can create feeds with one of the available layouts. It allows displaying image metadata, open up images in lightbox, download them and even share in social networking websites.
6
+ Version: 1.3.12
7
  Author: 10Web
8
  Author URI: https://10Web.io
9
  License: GPLv2 or later
20
  //define("wdi",'wdi');
21
  define('WDI_FEED_TABLE','wdi_feeds');
22
  define('WDI_THEME_TABLE','wdi_themes');
23
+ define('WDI_VERSION','1.3.12');
24
  define('WDI_IS_PRO','false');
25
  $wdi_minify = ((isset($_GET['wdi_no_minify']) && $_GET['wdi_no_minify'] == "true") ? false : true);
26
  define('WDI_MINIFY', $wdi_minify);
68
  return;
69
  }
70
 
71
+ $business_accounts = array();
72
 
73
  foreach($accounts['data'] as $accounts_data) {
74
 
101
 
102
  add_action('wp_ajax_wdi_set_reset_cache', 'wdi_set_reset_cache');
103
 
104
+ // Enqueue block editor assets for Gutenberg.
105
+ add_filter('tw_get_plugin_blocks', 'wdi_register_plugin_block');
106
+ add_filter('tw_get_block_editor_assets', 'wdi_register_block_editor_assets');
107
+ function wdi_register_plugin_block($blocks) {
108
+ require_once(WDI_DIR . '/framework/WDILibrary.php');
109
+ $data = WDILibrary::get_shortcode_data();
110
+ $blocks['tw/' . 'wdi'] = array(
111
+ 'nothing_selected' => __('Nothing selected.', 'wdi'),
112
+ 'title' => "Instagram WD",
113
+ 'titleSelect' => sprintf(__('Select %s', 'wdi'), 'Instagram WD'),
114
+ 'iconUrl' => WDI_URL . '/images/insta_2.svg',
115
+ 'iconSvg' => array('width' => 20, 'height' => 20, 'src' => WDI_URL . '/images/insta.svg'),
116
+ 'isPopup' => false,
117
+ 'data' => $data,
118
+ );
119
+ return $blocks;
120
+ }
121
+ function wdi_register_block_editor_assets($assets) {
122
+ $wd_bp_plugin_url = WDI_URL;
123
+ $version = '2.0.3';
124
+ $js_path = $wd_bp_plugin_url.'/js/block.js';
125
+ $css_path = $wd_bp_plugin_url.'/css/block.css';
126
+ if (!isset($assets['version']) || version_compare($assets['version'], $version) === -1) {
127
+ $assets['version'] = $version;
128
+ $assets['js_path'] = $js_path;
129
+ $assets['css_path'] = $css_path;
130
+ }
131
+ return $assets;
132
+ }
133
+
134
  function wdi_set_reset_cache(){
135
  if(wp_verify_nonce($_POST["wdi_nonce"] , 'wdi_cache')) {
136
  global $wpdb;
649
 
650
  }
651
 
652
+ add_action( 'enqueue_block_editor_assets', 'wdi_enqueue_block_editor_assets' );
653
 
654
+ function wdi_enqueue_block_editor_assets() {
655
+ // Remove previously registered or enqueued versions
656
+ $wp_scripts = wp_scripts();
657
+ foreach ($wp_scripts->registered as $key => $value) {
658
+ // Check for an older versions with prefix.
659
+ if (strpos($key, 'tw-gb-block') > 0) {
660
+ wp_deregister_script( $key );
661
+ wp_deregister_style( $key );
 
 
 
 
662
  }
663
+ }
664
+ // Get the last version from all 10Web plugins.
665
+ $assets = apply_filters('tw_get_block_editor_assets', array());
666
+ $blocks = apply_filters('tw_get_plugin_blocks', array());
667
+ // Not performing unregister or unenqueue as in old versions all are with prefixes.
668
+ wp_enqueue_script('tw-gb-block', $assets['js_path'], array( 'wp-blocks', 'wp-element' ), $assets['version']);
669
+ wp_localize_script('tw-gb-block', 'tw_obj_translate', array(
670
+ 'nothing_selected' => __('Nothing selected.', 'wdi'),
671
+ 'empty_item' => __('- Select -', 'wdi'),
672
+ 'blocks' => json_encode($blocks),
673
+ ));
674
+ wp_enqueue_style('tw-gb-block', $assets['css_path'], array( 'wp-edit-blocks' ), $assets['version']);
 
 
 
 
675
  }
676
 
677
  // Instagram WDI Widget.