The Post Grid - Version 2.3.2

Version Description

  • Full Content view
Download this release

Release Info

Developer techlabpro1
Plugin Icon 128x128 The Post Grid
Version 2.3.2
Comparing to
See all releases

Code changes from version 2.3.1 to 2.3.2

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: techlabpro1
3
  Donate link:
4
  Tags: post grid, content grid, post display, post format, post view, blog display, news display, post
5
  Requires at least: 4.5
6
- Tested up to: 5.2
7
- Stable tag: 2.3.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -139,6 +139,9 @@ For any bug or suggestion please mail support@radiustheme.com
139
 
140
  == Changelog ==
141
 
 
 
 
142
  = 2.3.1 =
143
  * Bug fix for limit
144
  * Fix Some CSS issue
3
  Donate link:
4
  Tags: post grid, content grid, post display, post format, post view, blog display, news display, post
5
  Requires at least: 4.5
6
+ Tested up to: 5.3
7
+ Stable tag: 2.3.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
139
 
140
  == Changelog ==
141
 
142
+ = 2.3.2 =
143
+ * Full Content view
144
+
145
  = 2.3.1 =
146
  * Bug fix for limit
147
  * Fix Some CSS issue
assets/js/rttpg.js CHANGED
@@ -1,52 +1,65 @@
1
  (function ($) {
2
  'use strict';
3
 
4
- window.tpgFixLazyLoad = function () {
5
  $('.rt-tpg-container').each(function () {
6
  // jetpack Lazy load
7
  $(this).find('img.jetpack-lazy-image:not(.jetpack-lazy-image--handled)').each(function () {
8
  $(this).addClass('jetpack-lazy-image--handled').removeAttr('srcset').removeAttr('data-lazy-src').attr('data-lazy-loaded', 1);
9
  });
 
 
 
 
 
 
 
 
10
  });
11
  };
12
 
13
  window.initTpg = function () {
14
  $(".rt-tpg-container").each(function () {
 
15
  var $isotopeHolder = $(this).find('.tpg-isotope');
16
  var $isotope = $isotopeHolder.find('.rt-tpg-isotope');
17
- if ($isotope.length) {
18
- $isotopeHolder.trigger('tpg_item_before_load');
19
- tpgFixLazyLoad();
20
- var isotope = $isotope.imagesLoaded(function () {
21
- $.when(tgpHeightResize()).done(function () {
22
- isotope.isotope({
 
 
 
23
  itemSelector: '.isotope-item',
24
  });
 
25
  setTimeout(function () {
26
- isotope.isotope();
27
- $isotopeHolder.trigger('tpg_item_after_load');
28
- }, 100);
29
- });
30
- });
31
- var $isotopeButtonGroup = $isotopeHolder.find('.rt-tpg-isotope-buttons');
32
- $isotopeButtonGroup.on('click', 'button', function (e) {
33
- e.preventDefault();
34
- var filterValue = $(this).attr('data-filter');
35
- isotope.isotope({filter: filterValue});
36
- $(this).parent().find('.selected').removeClass('selected');
37
- $(this).addClass('selected');
38
  });
39
- }
40
- tgpHeightResize();
41
- overlayIconResizeTpg();
42
- $isotopeHolder.trigger("tpg_loaded");
43
  });
44
  };
45
  initTpg();
46
- $(window).on('load resize', function () {
 
 
 
 
47
  tgpHeightResize();
48
  overlayIconResizeTpg();
49
- $(".rt-tpg-container").trigger("tpg_loaded");
50
  });
51
 
52
  function tgpHeightResize() {
@@ -73,16 +86,18 @@
73
  }
74
 
75
  function overlayIconResizeTpg() {
76
- $('.overlay').each(function () {
77
- var holder_height = $(this).height();
78
- var target = $(this).children('.link-holder');
79
- var targetd = $(this).children('.view-details');
80
- var a_height = target.height();
81
- var ad_height = targetd.height();
82
- var h = (holder_height - a_height) / 2;
83
- var hd = (holder_height - ad_height) / 2;
84
- target.css('top', h + 'px');
85
- targetd.css('margin-top', hd + 'px');
 
 
86
  });
87
  }
88
 
1
  (function ($) {
2
  'use strict';
3
 
4
+ window.tpgFixLazyLoad = function ($item) {
5
  $('.rt-tpg-container').each(function () {
6
  // jetpack Lazy load
7
  $(this).find('img.jetpack-lazy-image:not(.jetpack-lazy-image--handled)').each(function () {
8
  $(this).addClass('jetpack-lazy-image--handled').removeAttr('srcset').removeAttr('data-lazy-src').attr('data-lazy-loaded', 1);
9
  });
10
+
11
+ //
12
+ $(this).find('img.lazyload').each(function () {
13
+ var src = $(this).attr('data-src') || '';
14
+ if (src) {
15
+ $(this).attr('src', src).removeClass('lazyload').addClass('lazyloaded');
16
+ }
17
+ });
18
  });
19
  };
20
 
21
  window.initTpg = function () {
22
  $(".rt-tpg-container").each(function () {
23
+ var _item = $(this);
24
  var $isotopeHolder = $(this).find('.tpg-isotope');
25
  var $isotope = $isotopeHolder.find('.rt-tpg-isotope');
26
+ $isotopeHolder.trigger('tpg_item_before_load');
27
+ tpgFixLazyLoad();
28
+ setTimeout(function () {
29
+ _item.imagesLoaded().progress(function (instance, image) {
30
+ _item.trigger('tpg_image_loading');
31
+ }).done(function (instance) {
32
+ _item.trigger('tpg_item_before_load');
33
+ if ($isotope.length) {
34
+ $isotope.isotope({
35
  itemSelector: '.isotope-item',
36
  });
37
+ _item.trigger('tpg_item_after_load');
38
  setTimeout(function () {
39
+ $isotope.isotope();
40
+ }, 10);
41
+ var $isotopeButtonGroup = $isotopeHolder.find('.rt-tpg-isotope-buttons');
42
+ $isotopeButtonGroup.on('click', 'button', function (e) {
43
+ e.preventDefault();
44
+ var filterValue = $(this).attr('data-filter');
45
+ $isotope.isotope({filter: filterValue});
46
+ $(this).parent().find('.selected').removeClass('selected');
47
+ $(this).addClass('selected');
48
+ });
49
+ }
50
+ _item.trigger("tpg_loaded");
51
  });
52
+ }, 10);
 
 
 
53
  });
54
  };
55
  initTpg();
56
+ $(window).on('resize', function () {
57
+ $(".rt-tpg-container").trigger("tpg_loaded");
58
+ });
59
+
60
+ $('.rt-tpg-container').on('tpg_loaded tpg_item_after_load', function () {
61
  tgpHeightResize();
62
  overlayIconResizeTpg();
 
63
  });
64
 
65
  function tgpHeightResize() {
86
  }
87
 
88
  function overlayIconResizeTpg() {
89
+ $(".rt-tpg-container").each(function () {
90
+ $(this).find('.overlay').each(function () {
91
+ var holder_height = $(this).height();
92
+ var target = $(this).children('.link-holder');
93
+ var targetd = $(this).children('.view-details');
94
+ var a_height = target.height();
95
+ var ad_height = targetd.height();
96
+ var h = (holder_height - a_height) / 2;
97
+ var hd = (holder_height - ad_height) / 2;
98
+ target.css('top', h + 'px');
99
+ targetd.css('margin-top', hd + 'px');
100
+ });
101
  });
102
  }
103
 
languages/the-post-grid.pot CHANGED
@@ -3,14 +3,14 @@ msgid ""
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: The Post Grid\n"
6
- "POT-Creation-Date: 2017-01-05 16:56+0600\n"
7
- "PO-Revision-Date: 2017-01-05 16:55+0600\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.5\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-WPHeader: the-post-grid.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
@@ -20,243 +20,295 @@ msgstr ""
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
- #: lib/classes/rtTPGAjaxResponse.php:27
24
  msgid "Settings successfully updated"
25
  msgstr ""
26
 
27
- #: lib/classes/rtTPGAjaxResponse.php:32
28
  msgid "Security Error !!"
29
  msgstr ""
30
 
31
- #: lib/classes/rtTPGAjaxResponse.php:58
32
  msgid "<div class=\"field-holder\">No Taxonomy found</div>"
33
  msgstr ""
34
 
35
- #: lib/classes/rtTPGAjaxResponse.php:62 lib/classes/rtTPGAjaxResponse.php:81
36
- #: lib/classes/rtTPGAjaxResponse.php:120
37
  msgid "Security error"
38
  msgstr ""
39
 
40
- #: lib/classes/rtTPGAjaxResponse.php:134
41
  msgid "Select Short code"
42
  msgstr ""
43
 
44
- #: lib/classes/rtTPGAjaxResponse.php:136
45
  msgid "Default"
46
  msgstr ""
47
 
48
- #: lib/classes/rtTPGAjaxResponse.php:145
49
  msgid "No shortCode found."
50
  msgstr ""
51
 
52
  #. Plugin Name of the plugin/theme
53
- #: lib/classes/rtTPGInit.php:21 lib/classes/rtTPGInit.php:22
 
 
54
  msgid "The Post Grid"
55
  msgstr ""
56
 
57
- #: lib/classes/rtTPGInit.php:23
58
  msgid "Add New Grid"
59
  msgstr ""
60
 
61
- #: lib/classes/rtTPGInit.php:24
62
  msgid "All Grids"
63
  msgstr ""
64
 
65
- #: lib/classes/rtTPGInit.php:25
66
  msgid "Add New Post Grid"
67
  msgstr ""
68
 
69
- #: lib/classes/rtTPGInit.php:26
70
  msgid "Edit Post Grid"
71
  msgstr ""
72
 
73
- #: lib/classes/rtTPGInit.php:27
74
  msgid "New Post Grid"
75
  msgstr ""
76
 
77
- #: lib/classes/rtTPGInit.php:28
78
  msgid "View Post Grid"
79
  msgstr ""
80
 
81
- #: lib/classes/rtTPGInit.php:29
82
  msgid "Search Post Grids"
83
  msgstr ""
84
 
85
- #: lib/classes/rtTPGInit.php:30
86
  msgid "No Post Grids found"
87
  msgstr ""
88
 
89
- #: lib/classes/rtTPGInit.php:31
90
  msgid "No Post Grids found in Trash"
91
  msgstr ""
92
 
93
- #: lib/classes/rtTPGInit.php:143
94
  msgid "Settings"
95
  msgstr ""
96
 
97
- #: lib/classes/rtTPGInit.php:156 lib/classes/rtTPGInit.php:159
98
- msgid "Field group updated."
99
- msgstr ""
100
-
101
- #: lib/classes/rtTPGInit.php:157
102
- msgid "Custom field updated."
103
  msgstr ""
104
 
105
- #: lib/classes/rtTPGInit.php:158
106
- msgid "Custom field deleted."
107
  msgstr ""
108
 
109
- #: lib/classes/rtTPGInit.php:161
110
- #, php-format
111
- msgid "Field group restored to revision from %s"
112
  msgstr ""
113
 
114
- #: lib/classes/rtTPGInit.php:162
115
- msgid "Field group published."
116
  msgstr ""
117
 
118
- #: lib/classes/rtTPGInit.php:163
119
- msgid "Field group saved."
120
  msgstr ""
121
 
122
- #: lib/classes/rtTPGInit.php:164
123
- msgid "Field group submitted."
124
  msgstr ""
125
 
126
- #: lib/classes/rtTPGInit.php:165
127
- msgid "Field group scheduled for."
128
  msgstr ""
129
 
130
- #: lib/classes/rtTPGInit.php:166
131
- msgid "Field group draft updated."
132
  msgstr ""
133
 
134
- #: lib/classes/rtTPGMeta.php:26
135
- msgid "Shortcode"
136
  msgstr ""
137
 
138
- #: lib/classes/rtTPGMeta.php:76
139
- msgid "Short Code Generator"
140
  msgstr ""
141
 
142
- #: lib/classes/rtTPGMeta.php:108
143
- msgid "Post Source"
144
  msgstr ""
145
 
146
- #: lib/classes/rtTPGMeta.php:109
147
- msgid "Layout Settings"
148
  msgstr ""
149
 
150
- #: lib/classes/rtTPGMeta.php:110
151
- msgid "Field Selection"
152
  msgstr ""
153
 
154
- #: lib/classes/rtTPGMeta.php:111
155
- msgid "Style"
156
  msgstr ""
157
 
158
- #: lib/classes/rtTPGOptions.php:73
159
- msgid "List of post IDs to show (comma-separated values, for example: 1,2,3)"
160
  msgstr ""
161
 
162
- #: lib/classes/rtTPGOptions.php:80
163
- msgid "List of post IDs to hide (comma-separated values, for example: 1,2,3)"
 
164
  msgstr ""
165
 
166
- #: lib/classes/rtTPGOptions.php:87
167
- msgid "The number of posts to show. Set empty to show all found posts."
168
  msgstr ""
169
 
170
- #: lib/classes/rtTPGOptions.php:178
171
  msgid ""
172
  "If value of Limit setting is not blank (empty), this value should be smaller "
173
  "than Limit value."
174
  msgstr ""
175
 
176
- #: lib/classes/rtTPGOptions.php:202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  msgid ""
178
  "Excerpt limit only integer number is allowed, Leave it blank for full "
179
  "excerpt. Note: This will remove all html tag"
180
  msgstr ""
181
 
182
- #: lib/classes/rtTPGOptions.php:265
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  msgid "Feature Image"
184
  msgstr ""
185
 
186
- #: lib/classes/rtTPGOptions.php:266
187
  msgid "First Image from content"
188
  msgstr ""
189
 
190
- #: lib/classes/rtTPGOptions.php:289
191
  msgid "Title"
192
  msgstr ""
193
 
194
- #: lib/classes/rtTPGOptions.php:290
195
  msgid "Excerpt"
196
  msgstr ""
197
 
198
- #: lib/classes/rtTPGOptions.php:291 lib/views/layouts/layout1.php:53
 
199
  msgid "Read More"
200
  msgstr ""
201
 
202
- #: lib/classes/rtTPGOptions.php:292
203
  msgid "Post Date"
204
  msgstr ""
205
 
206
- #: lib/classes/rtTPGOptions.php:293
207
  msgid "Author"
208
  msgstr ""
209
 
210
- #: lib/classes/rtTPGOptions.php:294
211
  msgid "Categories"
212
  msgstr ""
213
 
214
- #: lib/classes/rtTPGOptions.php:295
215
  msgid "Tags"
216
  msgstr ""
217
 
218
- #: lib/classes/rtTPGOptions.php:296
219
  msgid "Comment Count"
220
  msgstr ""
221
 
222
- #: lib/classes/rtTPGShortCode.php:242
223
- msgid "Show all"
224
  msgstr ""
225
 
226
- #: lib/classes/rtTPGShortCode.php:305
227
- msgid "No post found"
 
 
 
 
228
  msgstr ""
229
 
230
- #: lib/views/layouts/layout2.php:48 lib/views/layouts/layout3.php:44
231
- msgid "Read More .."
232
  msgstr ""
233
 
234
- #: lib/views/settings/settings.php:8
235
  msgid "The Post Grid Settings"
236
  msgstr ""
237
 
238
- #: lib/views/settings/settings.php:9
239
  msgid "General settings"
240
  msgstr ""
241
 
242
- #: lib/views/settings/settings.php:10 lib/views/settings/settings.php:56
243
  msgid "Documentation"
244
  msgstr ""
245
 
246
- #: lib/views/settings/settings.php:52
247
- msgid "Short Code"
248
- msgstr ""
249
-
250
- #: lib/views/settings/settings.php:54
251
- msgid "id = short code id (1,2,3,4)"
252
  msgstr ""
253
 
254
- #: lib/views/settings/settings.php:55
255
- msgid "title = Shot code title (Not recommended)"
256
  msgstr ""
257
 
258
- #: lib/views/settings/settings.php:56
259
- msgid "Demo"
260
  msgstr ""
261
 
262
  #. Plugin URI of the plugin/theme
3
  msgstr ""
4
  "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
5
  "Project-Id-Version: The Post Grid\n"
6
+ "POT-Creation-Date: 2019-08-26 12:13+0600\n"
7
+ "PO-Revision-Date: 2019-08-26 12:12+0600\n"
8
  "Last-Translator: \n"
9
  "Language-Team: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 1.8.7\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "X-Poedit-WPHeader: the-post-grid.php\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: *.js\n"
22
 
23
+ #: lib/classes/rtTPGAjaxResponse.php:26
24
  msgid "Settings successfully updated"
25
  msgstr ""
26
 
27
+ #: lib/classes/rtTPGAjaxResponse.php:28
28
  msgid "Security Error !!"
29
  msgstr ""
30
 
31
+ #: lib/classes/rtTPGAjaxResponse.php:56
32
  msgid "<div class=\"field-holder\">No Taxonomy found</div>"
33
  msgstr ""
34
 
35
+ #: lib/classes/rtTPGAjaxResponse.php:60 lib/classes/rtTPGAjaxResponse.php:79
36
+ #: lib/classes/rtTPGAjaxResponse.php:118
37
  msgid "Security error"
38
  msgstr ""
39
 
40
+ #: lib/classes/rtTPGAjaxResponse.php:137
41
  msgid "Select Short code"
42
  msgstr ""
43
 
44
+ #: lib/classes/rtTPGAjaxResponse.php:139
45
  msgid "Default"
46
  msgstr ""
47
 
48
+ #: lib/classes/rtTPGAjaxResponse.php:148
49
  msgid "No shortCode found."
50
  msgstr ""
51
 
52
  #. Plugin Name of the plugin/theme
53
+ #: lib/classes/rtTPGInit.php:22 lib/classes/rtTPGInit.php:23
54
+ #: lib/vendor/RtElementorWidget.php:10 lib/vendor/RtElementorWidget.php:26
55
+ #: lib/widgets/RT_TPGWidget.php:15
56
  msgid "The Post Grid"
57
  msgstr ""
58
 
59
+ #: lib/classes/rtTPGInit.php:24
60
  msgid "Add New Grid"
61
  msgstr ""
62
 
63
+ #: lib/classes/rtTPGInit.php:25
64
  msgid "All Grids"
65
  msgstr ""
66
 
67
+ #: lib/classes/rtTPGInit.php:26
68
  msgid "Add New Post Grid"
69
  msgstr ""
70
 
71
+ #: lib/classes/rtTPGInit.php:27
72
  msgid "Edit Post Grid"
73
  msgstr ""
74
 
75
+ #: lib/classes/rtTPGInit.php:28
76
  msgid "New Post Grid"
77
  msgstr ""
78
 
79
+ #: lib/classes/rtTPGInit.php:29
80
  msgid "View Post Grid"
81
  msgstr ""
82
 
83
+ #: lib/classes/rtTPGInit.php:30
84
  msgid "Search Post Grids"
85
  msgstr ""
86
 
87
+ #: lib/classes/rtTPGInit.php:31
88
  msgid "No Post Grids found"
89
  msgstr ""
90
 
91
+ #: lib/classes/rtTPGInit.php:32
92
  msgid "No Post Grids found in Trash"
93
  msgstr ""
94
 
95
+ #: lib/classes/rtTPGInit.php:112
96
  msgid "Settings"
97
  msgstr ""
98
 
99
+ #: lib/classes/rtTPGMeta.php:27
100
+ msgid "Shortcode"
 
 
 
 
101
  msgstr ""
102
 
103
+ #: lib/classes/rtTPGMeta.php:85
104
+ msgid "Short Code Generator"
105
  msgstr ""
106
 
107
+ #: lib/classes/rtTPGMeta.php:92
108
+ msgid "Pro Features"
 
109
  msgstr ""
110
 
111
+ #: lib/classes/rtTPGMeta.php:99
112
+ msgid "Layout Preview"
113
  msgstr ""
114
 
115
+ #: lib/classes/rtTPGMeta.php:141
116
+ msgid "Post Source"
117
  msgstr ""
118
 
119
+ #: lib/classes/rtTPGMeta.php:142
120
+ msgid "Layout Settings"
121
  msgstr ""
122
 
123
+ #: lib/classes/rtTPGMeta.php:143
124
+ msgid "Field Selection"
125
  msgstr ""
126
 
127
+ #: lib/classes/rtTPGMeta.php:144
128
+ msgid "Style"
129
  msgstr ""
130
 
131
+ #: lib/classes/rtTPGOptions.php:69
132
+ msgid "Script before item load"
133
  msgstr ""
134
 
135
+ #: lib/classes/rtTPGOptions.php:77
136
+ msgid "Script After item load"
137
  msgstr ""
138
 
139
+ #: lib/classes/rtTPGOptions.php:85
140
+ msgid "After Loaded Script"
141
  msgstr ""
142
 
143
+ #: lib/classes/rtTPGOptions.php:101
144
+ msgid "List of post IDs to show (comma-separated values, for example: 1,2,3)"
145
  msgstr ""
146
 
147
+ #: lib/classes/rtTPGOptions.php:109
148
+ msgid "List of post IDs to hide (comma-separated values, for example: 1,2,3)"
149
  msgstr ""
150
 
151
+ #: lib/classes/rtTPGOptions.php:117
152
+ msgid "The number of posts to show. Set empty to show all found posts."
153
  msgstr ""
154
 
155
+ #: lib/classes/rtTPGOptions.php:190
156
+ msgid "Show all text"
157
  msgstr ""
158
 
159
+ #: lib/classes/rtTPGOptions.php:191 lib/classes/rtTPGShortCode.php:71
160
+ #: lib/classes/rtTPGShortCode.php:100
161
+ msgid "Show all"
162
  msgstr ""
163
 
164
+ #: lib/classes/rtTPGOptions.php:197
165
+ msgid "Image column"
166
  msgstr ""
167
 
168
+ #: lib/classes/rtTPGOptions.php:228
169
  msgid ""
170
  "If value of Limit setting is not blank (empty), this value should be smaller "
171
  "than Limit value."
172
  msgstr ""
173
 
174
+ #: lib/classes/rtTPGOptions.php:261
175
+ msgid "Title limit"
176
+ msgstr ""
177
+
178
+ #: lib/classes/rtTPGOptions.php:262
179
+ msgid ""
180
+ "Title limit only integer number is allowed, Leave it blank for full title."
181
+ msgstr ""
182
+
183
+ #: lib/classes/rtTPGOptions.php:268
184
+ msgid "Title limit type"
185
+ msgstr ""
186
+
187
+ #: lib/classes/rtTPGOptions.php:276
188
+ msgid "Excerpt limit"
189
+ msgstr ""
190
+
191
+ #: lib/classes/rtTPGOptions.php:278
192
  msgid ""
193
  "Excerpt limit only integer number is allowed, Leave it blank for full "
194
  "excerpt. Note: This will remove all html tag"
195
  msgstr ""
196
 
197
+ #: lib/classes/rtTPGOptions.php:283
198
+ msgid "Excerpt Type"
199
+ msgstr ""
200
+
201
+ #: lib/classes/rtTPGOptions.php:292
202
+ msgid "Excerpt more text"
203
+ msgstr ""
204
+
205
+ #: lib/classes/rtTPGOptions.php:299
206
+ msgid "Read more text"
207
+ msgstr ""
208
+
209
+ #: lib/classes/rtTPGOptions.php:306
210
+ msgid "Overlay"
211
+ msgstr ""
212
+
213
+ #: lib/classes/rtTPGOptions.php:313
214
+ msgid "Title tag"
215
+ msgstr ""
216
+
217
+ #: lib/classes/rtTPGOptions.php:380
218
+ msgid "Title color"
219
+ msgstr ""
220
+
221
+ #: lib/classes/rtTPGOptions.php:387
222
+ msgid "Title hover color"
223
+ msgstr ""
224
+
225
+ #: lib/classes/rtTPGOptions.php:396
226
+ msgid "Read more button border radius"
227
+ msgstr ""
228
+
229
+ #: lib/classes/rtTPGOptions.php:397
230
+ msgid "Leave it blank for default"
231
+ msgstr ""
232
+
233
+ #: lib/classes/rtTPGOptions.php:426
234
  msgid "Feature Image"
235
  msgstr ""
236
 
237
+ #: lib/classes/rtTPGOptions.php:427
238
  msgid "First Image from content"
239
  msgstr ""
240
 
241
+ #: lib/classes/rtTPGOptions.php:455
242
  msgid "Title"
243
  msgstr ""
244
 
245
+ #: lib/classes/rtTPGOptions.php:456
246
  msgid "Excerpt"
247
  msgstr ""
248
 
249
+ #: lib/classes/rtTPGOptions.php:457 lib/classes/rtTPGShortCode.php:69
250
+ #: lib/classes/rtTPGShortCode.php:98
251
  msgid "Read More"
252
  msgstr ""
253
 
254
+ #: lib/classes/rtTPGOptions.php:458
255
  msgid "Post Date"
256
  msgstr ""
257
 
258
+ #: lib/classes/rtTPGOptions.php:459
259
  msgid "Author"
260
  msgstr ""
261
 
262
+ #: lib/classes/rtTPGOptions.php:460
263
  msgid "Categories"
264
  msgstr ""
265
 
266
+ #: lib/classes/rtTPGOptions.php:461
267
  msgid "Tags"
268
  msgstr ""
269
 
270
+ #: lib/classes/rtTPGOptions.php:462
271
  msgid "Comment Count"
272
  msgstr ""
273
 
274
+ #: lib/classes/rtTPGShortCode.php:342
275
+ msgid "No post found"
276
  msgstr ""
277
 
278
+ #: lib/classes/rtTPGShortCode.php:370
279
+ msgid "Session Error !!"
280
+ msgstr ""
281
+
282
+ #: lib/classes/rtTPGShortCode.php:372
283
+ msgid "No shortCode found"
284
  msgstr ""
285
 
286
+ #: lib/vendor/RtElementorWidget.php:36
287
+ msgid "Post Grid"
288
  msgstr ""
289
 
290
+ #: lib/views/settings/settings.php:5
291
  msgid "The Post Grid Settings"
292
  msgstr ""
293
 
294
+ #: lib/views/settings/settings.php:6
295
  msgid "General settings"
296
  msgstr ""
297
 
298
+ #: lib/views/settings/settings.php:9
299
  msgid "Documentation"
300
  msgstr ""
301
 
302
+ #: lib/widgets/RT_TPGWidget.php:14
303
+ msgid "Display the post grid."
 
 
 
 
304
  msgstr ""
305
 
306
+ #: lib/widgets/RT_TPGWidget.php:46
307
+ msgid "Title:"
308
  msgstr ""
309
 
310
+ #: lib/widgets/RT_TPGWidget.php:52
311
+ msgid "Select post grid"
312
  msgstr ""
313
 
314
  #. Plugin URI of the plugin/theme
lib/classes/rtTPGHelper.php CHANGED
@@ -226,48 +226,57 @@ if ( ! class_exists( 'rtTPGHelper' ) ):
226
  }
227
 
228
  function get_the_excerpt( $post_id, $data = array() ) {
229
- $limit = isset( $data['excerpt_limit'] ) ? abs( $data['excerpt_limit'] ) : 0;
230
- $defaultExcerpt = get_the_excerpt( $post_id );
231
- $type = $data['excerpt_type'];
232
- $more = $data['excerpt_more_text'];
233
- $excerpt = preg_replace( '`\[[^\]]*\]`', '', $defaultExcerpt );
234
- $excerpt = strip_shortcodes( $excerpt );
235
- $excerpt = preg_replace( '`[[^]]*]`', '', $excerpt );
236
- $excerpt = str_replace( '…', '', $excerpt );
237
- if ( $limit ) {
238
- $excerpt = wp_filter_nohtml_kses( $excerpt );
239
- if ( $type == "word" ) {
240
- $limit = $limit + 1;
241
- $rawExcerpt = $excerpt;
242
- $excerpt = explode( ' ', $excerpt, $limit );
243
- if ( count( $excerpt ) >= $limit ) {
244
- array_pop( $excerpt );
245
- $excerpt = implode( " ", $excerpt );
 
 
 
 
 
 
 
 
 
 
 
246
  } else {
247
- $excerpt = $rawExcerpt;
 
 
 
248
  }
249
  } else {
250
- if ( $limit > 0 && strlen( $excerpt ) > $limit ) {
251
- $excerpt = mb_substr( $excerpt, 0, $limit, "utf-8" );
252
- $excerpt = preg_replace( '/\W\w+\s*(\W*)$/', '$1', $excerpt );
253
- }
 
 
 
 
 
 
254
  }
255
- } else {
256
- $allowed_html = array(
257
- 'a' => array(
258
- 'href' => array(),
259
- 'title' => array()
260
- ),
261
- 'strong' => array(),
262
- 'b' => array(),
263
- 'br' => array( array() ),
264
- );
265
- $excerpt = nl2br( wp_kses( $excerpt, $allowed_html ) );
266
- }
267
- $excerpt = ( $more ? $excerpt . " " . $more : $excerpt );
268
 
269
 
270
- return apply_filters( 'tpg_get_the_excerpt', $excerpt, $post_id, $data, $defaultExcerpt );
 
271
  }
272
 
273
 
226
  }
227
 
228
  function get_the_excerpt( $post_id, $data = array() ) {
229
+ $type = $data['excerpt_type'];
230
+ if ( $type == 'full' ) {
231
+ ob_start();
232
+ the_content();
233
+ $content = ob_get_clean();
234
+
235
+ return apply_filters( 'tpg_content_full', $content, $post_id, $data );
236
+ } else {
237
+
238
+ $limit = isset( $data['excerpt_limit'] ) ? abs( $data['excerpt_limit'] ) : 0;
239
+ $defaultExcerpt = get_the_excerpt( $post_id );
240
+ $more = $data['excerpt_more_text'];
241
+ $excerpt = preg_replace( '`\[[^\]]*\]`', '', $defaultExcerpt );
242
+ $excerpt = strip_shortcodes( $excerpt );
243
+ $excerpt = preg_replace( '`[[^]]*]`', '', $excerpt );
244
+ $excerpt = str_replace( '…', '', $excerpt );
245
+ if ( $limit ) {
246
+ $excerpt = wp_filter_nohtml_kses( $excerpt );
247
+ if ( $type == "word" ) {
248
+ $limit = $limit + 1;
249
+ $rawExcerpt = $excerpt;
250
+ $excerpt = explode( ' ', $excerpt, $limit );
251
+ if ( count( $excerpt ) >= $limit ) {
252
+ array_pop( $excerpt );
253
+ $excerpt = implode( " ", $excerpt );
254
+ } else {
255
+ $excerpt = $rawExcerpt;
256
+ }
257
  } else {
258
+ if ( $limit > 0 && strlen( $excerpt ) > $limit ) {
259
+ $excerpt = mb_substr( $excerpt, 0, $limit, "utf-8" );
260
+ $excerpt = preg_replace( '/\W\w+\s*(\W*)$/', '$1', $excerpt );
261
+ }
262
  }
263
  } else {
264
+ $allowed_html = array(
265
+ 'a' => array(
266
+ 'href' => array(),
267
+ 'title' => array()
268
+ ),
269
+ 'strong' => array(),
270
+ 'b' => array(),
271
+ 'br' => array( array() ),
272
+ );
273
+ $excerpt = nl2br( wp_kses( $excerpt, $allowed_html ) );
274
  }
275
+ $excerpt = ( $more ? $excerpt . " " . $more : $excerpt );
 
 
 
 
 
 
 
 
 
 
 
 
276
 
277
 
278
+ return apply_filters( 'tpg_get_the_excerpt', $excerpt, $post_id, $data, $defaultExcerpt );
279
+ }
280
  }
281
 
282
 
lib/classes/rtTPGOptions.php CHANGED
@@ -1,468 +1,470 @@
1
  <?php
2
 
3
- if (!class_exists('rtTPGOptions')):
4
 
5
- class rtTPGOptions
6
- {
7
 
8
- function rtPostTypes() {
9
- $post_types = get_post_types(
10
- array(
11
- '_builtin' => true
12
- )
13
- );
14
- $exclude = array('attachment', 'revision', 'nav_menu_item');
15
- foreach ($exclude as $ex) {
16
- unset($post_types[$ex]);
17
- }
18
 
19
- return $post_types;
20
- }
21
 
22
- function rtPostOrders() {
23
- return array(
24
- "ASC" => "Ascending",
25
- "DESC" => "Descending",
26
- );
27
- }
28
 
29
- function rtTermOperators() {
30
- return array(
31
- 'IN' => "IN — show posts which associate with one or more of selected terms",
32
- 'NOT IN' => "NOT IN — show posts which do not associate with any of selected terms",
33
- 'AND' => "AND — show posts which associate with all of selected terms",
34
- );
35
- }
36
 
37
- function rtTermRelations() {
38
- return array(
39
- 'AND' => "AND — show posts which match all settings",
40
- 'OR' => "OR — show posts which match one or more settings",
41
- );
42
- }
43
 
44
- function rtPostOrderBy() {
45
- return array(
46
- "ID" => "ID",
47
- "title" => "Title",
48
- "date" => "Created date",
49
- "modified" => "Modified date",
50
- "menu_order" => "Menu Order"
51
- );
52
- }
53
 
54
- function rtTPGSettingFields() {
55
- global $rtTPG;
56
- $settings = get_option($rtTPG->options['settings']);
57
 
58
- return array(
59
- 'custom_css' => array(
60
- 'type' => 'textarea',
61
- 'name' => 'custom_css',
62
- 'label' => 'Custom Css',
63
- 'holderClass' => 'rt-script-wrapper full',
64
- 'id' => 'custom-css',
65
- 'value' => isset($settings['custom_css']) ? stripslashes($settings['custom_css']) : null,
66
- ),
67
- "script_before_item_load" => array(
68
- 'name' => 'script_before_item_load',
69
- "label" => __("Script before item load", 'the-post-grid'),
70
- 'type' => 'textarea',
71
- 'holderClass' => 'rt-script-wrapper full',
72
- 'id' => 'script-before-item-load',
73
- 'value' => isset($settings['script_before_item_load']) ? stripslashes($settings['script_before_item_load']) : null
74
- ),
75
- "script_after_item_load" => array(
76
- 'name' => 'script_after_item_load',
77
- "label" => __("Script After item load", 'the-post-grid'),
78
- 'type' => 'textarea',
79
- 'holderClass' => 'rt-script-wrapper full',
80
- 'id' => 'script-after-item-load',
81
- 'value' => isset($settings['script_after_item_load']) ? stripslashes($settings['script_after_item_load']) : null
82
- ),
83
- "script_loaded" => array(
84
- 'name' => 'script_loaded',
85
- "label" => __("After Loaded Script", 'the-post-grid'),
86
- 'type' => 'textarea',
87
- 'holderClass' => 'rt-script-wrapper full',
88
- 'id' => 'script-loaded',
89
- 'value' => isset($settings['script_loaded']) ? stripslashes($settings['script_loaded']) : null
90
- )
91
- );
92
- }
93
 
94
- function rtTPGCommonFilterFields() {
95
- return array(
96
- 'post__in' => array(
97
- "name" => "post__in",
98
- "label" => "Include only",
99
- "type" => "text",
100
- "class" => "full",
101
- "description" => __('List of post IDs to show (comma-separated values, for example: 1,2,3)',
102
- 'the-post-grid')
103
- ),
104
- 'post__not_in' => array(
105
- "name" => "post__not_in",
106
- "label" => "Exclude",
107
- "type" => "text",
108
- "class" => "full",
109
- "description" => __('List of post IDs to hide (comma-separated values, for example: 1,2,3)',
110
- 'the-post-grid')
111
- ),
112
- 'limit' => array(
113
- "name" => "limit",
114
- "label" => "Limit",
115
- "type" => "number",
116
- "class" => "full",
117
- "description" => __('The number of posts to show. Set empty to show all found posts.',
118
- 'the-post-grid')
119
- )
120
- );
121
- }
122
 
123
- function rtTPGPostType() {
124
- return array(
125
- "name" => "tpg_post_type",
126
- "label" => "Post Type",
127
- "type" => "select",
128
- "id" => "rc-sc-post-type",
129
- "class" => "rt-select2",
130
- "options" => $this->rtPostTypes()
131
- );
132
- }
133
 
134
- function rtTPAdvanceFilters() {
135
- return array(
136
- 'type' => "checkbox",
137
- 'name' => "post_filter",
138
- 'label' => "Advanced filters",
139
- 'id' => "post_filter",
140
- "alignment" => "vertical",
141
- "multiple" => true,
142
- "options" => array(
143
- 'tpg_taxonomy' => "Taxonomy",
144
- 'order' => "Order",
145
- 'author' => "Author",
146
- 'tpg_post_status' => "Status",
147
- 's' => "Search"
148
- ),
149
- );
150
- }
151
 
152
- function rtTPGPostStatus() {
153
- return array(
154
- 'publish' => 'Publish',
155
- 'pending' => 'Pending',
156
- 'draft' => 'Draft',
157
- 'auto-draft' => 'Auto draft',
158
- 'future' => 'Future',
159
- 'private' => 'Private',
160
- 'inherit' => 'Inherit',
161
- 'trash' => 'Trash',
162
- );
163
- }
164
 
165
- function rtTPGLayoutSettingFields() {
166
- global $rtTPG;
167
 
168
- return array(
169
- 'layout' => array(
170
- "type" => "select",
171
- "name" => "layout",
172
- "label" => "Layout",
173
- "id" => "rt-tpg-sc-layout",
174
- "class" => "rt-select2",
175
- "options" => $this->rtTPGLayouts()
176
- ),
177
- 'isotope-filtering' => array(
178
- "type" => "select",
179
- "name" => "isotope_filter",
180
- "label" => "Isotope Filter",
181
- 'holderClass' => "sc-isotope-filter tpg-hidden",
182
- "id" => "rt-tpg-sc-isotope-filter",
183
- "class" => "rt-select2",
184
- "options" => $rtTPG->rt_get_taxonomy_for_isotope_filter()
185
- ),
186
- 'tpg_show_all_text' => array(
187
- "type" => "text",
188
- "name" => "tpg_show_all_text",
189
- 'holderClass' => "sc-isotope-filter tpg-hidden",
190
- "label" => esc_html__("Show all text", 'the-post-grid'),
191
- "default" => esc_html__("Show all", 'the-post-grid')
192
- ),
193
- 'tgp_layout2_image_column' => array(
194
- 'type' => 'select',
195
- "name" => "tgp_layout2_image_column",
196
- "id" => "tgp_layout2_image_column",
197
- 'label' => __('Image column', 'the-post-grid'),
198
- 'class' => 'rt-select2',
199
- 'holderClass' => "holder-layout2-image-column tpg-hidden",
200
- 'default' => 4,
201
- 'options' => $this->rtTPGColumns(),
202
- "description" => "Content column will calculate automatically"
203
- ),
204
- 'column' => array(
205
- "type" => "select",
206
- "name" => "column",
207
- "label" => "Column",
208
- "id" => "rt-column",
209
- "class" => "rt-select2",
210
- "default" => 4,
211
- "options" => $this->rtTPGColumns()
212
- ),
213
- 'pagination' => array(
214
- "type" => "checkbox",
215
- "name" => "pagination",
216
- "label" => "Pagination",
217
- 'holderClass' => "pagination",
218
- "id" => "rt-tpg-pagination",
219
- "option" => 'Enable'
220
- ),
221
- 'posts_per_page' => array(
222
- "type" => "number",
223
- "name" => "posts_per_page",
224
- "label" => "Display per page",
225
- 'holderClass' => "posts-per-page tpg-hidden",
226
- "id" => "posts-per-page",
227
- "default" => 5,
228
- "description" => __("If value of Limit setting is not blank (empty), this value should be smaller than Limit value.",
229
- 'the-post-grid')
230
- ),
231
- 'featured_image' => array(
232
- "type" => "checkbox",
233
- "name" => "featured_image",
234
- "label" => "Feature Image",
235
- "id" => "rt-feature-image",
236
- "option" => 'Disable'
237
- ),
238
- 'featured_image_size' => array(
239
- "type" => "select",
240
- "name" => "featured_image_size",
241
- "label" => "Feature Image Size",
242
- "id" => "featured-image-size",
243
- 'holderClass' => "feature-image-options tpg-hidden",
244
- "class" => "rt-select2",
245
- "options" => $rtTPG->get_image_sizes()
246
- ),
247
- 'media_source' => array(
248
- "type" => "radio",
249
- "name" => "media_source",
250
- "label" => "Media Source",
251
- "id" => "media-source",
252
- 'holderClass' => "feature-image-options tpg-hidden",
253
- "default" => 'feature_image',
254
- "alignment" => "vertical",
255
- "options" => $this->rtMediaSource()
256
- ),
257
- 'tpg_title_limit' => array(
258
- "name" => "tpg_title_limit",
259
- "id" => "tpg-title-limit",
260
- "type" => "number",
261
- "label" => esc_html__("Title limit", 'the-post-grid'),
262
- "description" => esc_html__("Title limit only integer number is allowed, Leave it blank for full title.", 'the-post-grid')
263
- ),
264
- 'tpg_title_limit_type' => array(
265
- "name" => "tpg_title_limit_type",
266
- "id" => "tpg-title-limit-type",
267
- "type" => "radio",
268
- "label" => esc_html__("Title limit type", 'the-post-grid'),
269
- "alignment" => "vertical",
270
- "default" => 'character',
271
- "options" => $this->get_limit_type(),
272
- ),
273
- 'excerpt_limit' => array(
274
- "type" => "number",
275
- "name" => "excerpt_limit",
276
- "label" => esc_html__("Excerpt limit", 'the-post-grid'),
277
- "id" => "excerpt-limit",
278
- "description" => __("Excerpt limit only integer number is allowed, Leave it blank for full excerpt. Note: This will remove all html tag",
279
- 'the-post-grid')
280
- ),
281
- 'tgp_excerpt_type' => array(
282
- "type" => "radio",
283
- "label" => esc_html__("Excerpt Type", 'the-post-grid'),
284
- "name" => "tgp_excerpt_type",
285
- "id" => "tgp_excerpt_type",
286
- "alignment" => "vertical",
287
- "default" => 'character',
288
- "options" => $this->get_limit_type(),
289
- ),
290
- 'tgp_excerpt_more_text' => array(
291
- "type" => "text",
292
- "label" => esc_html__("Excerpt more text", 'the-post-grid'),
293
- "name" => "tgp_excerpt_more_text",
294
- "id" => "tgp_excerpt_more_text",
295
- "default" => "..."
296
- ),
297
- 'tgp_read_more_text' => array(
298
- "type" => "text",
299
- "label" => esc_html__("Read more text", 'the-post-grid'),
300
- "name" => "tgp_read_more_text",
301
- "id" => "tgp_read_more_text",
302
- ),
303
- 'tpg_overlay' => array(
304
- "type" => "checkbox",
305
- "name" => "tpg_overlay",
306
- "label" => esc_html__("Overlay", 'the-post-grid'),
307
- "id" => "tpg_overlay",
308
- "option" => 'Enable'
309
- ),
310
- 'title_tag' => array(
311
- 'type' => 'select',
312
- 'name' => 'title_tag',
313
- 'label' => esc_html__('Title tag', 'the-post-grid'),
314
- 'class' => 'rt-select2',
315
- 'id' => 'title-tag',
316
- 'options' => $this->getTitleTags(),
317
- 'default' => 'h2'
318
- ),
319
- );
320
- }
321
 
322
- function get_limit_type() {
323
- $types = array(
324
- 'character' => "Character",
325
- 'word' => "Word"
326
- );
 
 
 
327
 
328
- return apply_filters('tpg_limit_type', $types);
329
- }
330
 
331
- function rtTPGStyleFields() {
332
 
333
- return array(
334
- 'parent_class' => array(
335
- "name" => "parent_class",
336
- "type" => "text",
337
- "label" => "Parent class",
338
- "class" => "medium-text",
339
- "description" => "Parent class for adding custom css"
340
- ),
341
- 'primary_color' => array(
342
- "type" => "text",
343
- "name" => "primary_color",
344
- "label" => "Primary Color",
345
- "id" => "primary-color",
346
- "class" => "rt-color",
347
- "default" => "#0367bf"
348
- ),
349
- 'button_bg_color' => array(
350
- "type" => "text",
351
- "name" => "button_bg_color",
352
- "label" => "Button background color",
353
- "id" => "button-bg-color",
354
- "class" => "rt-color"
355
- ),
356
- 'button_hover_bg_color' => array(
357
- "type" => "text",
358
- "name" => "button_hover_bg_color",
359
- "label" => "Button hover background color",
360
- "id" => "button-hover-bg-color",
361
- "class" => "rt-color"
362
- ),
363
- 'button_active_bg_color' => array(
364
- "type" => "text",
365
- "name" => "button_active_bg_color",
366
- "label" => "Button active background color",
367
- "id" => "button-active-bg-color",
368
- "class" => "rt-color"
369
- ),
370
- 'button_text_bg_color' => array(
371
- "type" => "text",
372
- "name" => "button_text_color",
373
- "label" => "Button text color",
374
- "id" => "button-text-color",
375
- "class" => "rt-color"
376
- ),
377
- 'title_color' => array(
378
- "type" => "text",
379
- "name" => "title_color",
380
- "label" => esc_html__("Title color", "the-post-grid"),
381
- "id" => "title_color",
382
- "class" => "rt-color"
383
- ),
384
- 'title_hover_color' => array(
385
- "type" => "text",
386
- "name" => "title_hover_color",
387
- "label" => esc_html__("Title hover color", "the-post-grid"),
388
- "id" => "title_hover_color",
389
- "class" => "rt-color"
390
- ),
391
- 'tpg_read_more_button_border_radius' => array(
392
- "type" => "number",
393
- "name" => "tpg_read_more_button_border_radius",
394
- "id" => "tpg-read-more-button-border-radius",
395
- "class" => "small-text",
396
- "label" => esc_html__("Read more button border radius", "the-post-grid"),
397
- "description" => esc_html__("Leave it blank for default", 'the-post-grid')
398
- )
399
- );
400
 
401
- }
402
 
403
- function getTitleTags() {
404
- return array(
405
- 'h2' => "H2",
406
- 'h3' => "H3",
407
- 'h4' => "H4"
408
- );
409
- }
410
 
411
- function itemFields() {
412
- return array(
413
- "type" => "checkbox",
414
- "name" => "item_fields",
415
- "label" => "Field selection",
416
- "id" => "item-fields",
417
- "multiple" => true,
418
- "alignment" => "vertical",
419
- "default" => array_keys($this->rtTPGItemFields()),
420
- "options" => $this->rtTPGItemFields()
421
- );
422
- }
423
 
424
- function rtMediaSource() {
425
- return array(
426
- "feature_image" => __("Feature Image", 'the-post-grid'),
427
- "first_image" => __("First Image from content", 'the-post-grid')
428
- );
429
- }
430
 
431
- function rtTPGColumns() {
432
- return array(
433
- 1 => "Column 1",
434
- 2 => "Column 2",
435
- 3 => "Column 3",
436
- 4 => "Column 4",
437
- 5 => "Column 5",
438
- 6 => "Column 6"
439
- );
440
- }
441
 
442
- function rtTPGLayouts() {
443
- $layouts = array(
444
- 'layout1' => "Layout 1",
445
- 'layout2' => "Layout 2",
446
- 'layout3' => "Layout 3",
447
- 'isotope1' => "Isotope Layout"
448
- );
449
 
450
- return apply_filters('tpg_layouts', $layouts);
451
- }
452
 
453
- function rtTPGItemFields() {
454
- return array(
455
- 'title' => __("Title", 'the-post-grid'),
456
- 'excerpt' => __("Excerpt", 'the-post-grid'),
457
- 'read_more' => __("Read More", 'the-post-grid'),
458
- 'post_date' => __("Post Date", 'the-post-grid'),
459
- 'author' => __("Author", 'the-post-grid'),
460
- 'categories' => __("Categories", 'the-post-grid'),
461
- 'tags' => __("Tags", 'the-post-grid'),
462
- 'comment_count' => __("Comment Count", 'the-post-grid')
463
- );
464
- }
465
 
466
- }
467
 
468
  endif;
1
  <?php
2
 
3
+ if ( ! class_exists( 'rtTPGOptions' ) ):
4
 
5
+ class rtTPGOptions {
 
6
 
7
+ function rtPostTypes() {
8
+ $post_types = get_post_types(
9
+ array(
10
+ '_builtin' => true
11
+ )
12
+ );
13
+ $exclude = array( 'attachment', 'revision', 'nav_menu_item' );
14
+ foreach ( $exclude as $ex ) {
15
+ unset( $post_types[ $ex ] );
16
+ }
17
 
18
+ return $post_types;
19
+ }
20
 
21
+ function rtPostOrders() {
22
+ return array(
23
+ "ASC" => "Ascending",
24
+ "DESC" => "Descending",
25
+ );
26
+ }
27
 
28
+ function rtTermOperators() {
29
+ return array(
30
+ 'IN' => "IN — show posts which associate with one or more of selected terms",
31
+ 'NOT IN' => "NOT IN — show posts which do not associate with any of selected terms",
32
+ 'AND' => "AND — show posts which associate with all of selected terms",
33
+ );
34
+ }
35
 
36
+ function rtTermRelations() {
37
+ return array(
38
+ 'AND' => "AND — show posts which match all settings",
39
+ 'OR' => "OR — show posts which match one or more settings",
40
+ );
41
+ }
42
 
43
+ function rtPostOrderBy() {
44
+ return array(
45
+ "ID" => "ID",
46
+ "title" => "Title",
47
+ "date" => "Created date",
48
+ "modified" => "Modified date",
49
+ "menu_order" => "Menu Order"
50
+ );
51
+ }
52
 
53
+ function rtTPGSettingFields() {
54
+ global $rtTPG;
55
+ $settings = get_option( $rtTPG->options['settings'] );
56
 
57
+ return array(
58
+ 'custom_css' => array(
59
+ 'type' => 'textarea',
60
+ 'name' => 'custom_css',
61
+ 'label' => 'Custom Css',
62
+ 'holderClass' => 'rt-script-wrapper full',
63
+ 'id' => 'custom-css',
64
+ 'value' => isset( $settings['custom_css'] ) ? stripslashes( $settings['custom_css'] ) : null,
65
+ ),
66
+ "script_before_item_load" => array(
67
+ 'name' => 'script_before_item_load',
68
+ "label" => __( "Script before item load", 'the-post-grid' ),
69
+ 'type' => 'textarea',
70
+ 'holderClass' => 'rt-script-wrapper full',
71
+ 'id' => 'script-before-item-load',
72
+ 'value' => isset( $settings['script_before_item_load'] ) ? stripslashes( $settings['script_before_item_load'] ) : null
73
+ ),
74
+ "script_after_item_load" => array(
75
+ 'name' => 'script_after_item_load',
76
+ "label" => __( "Script After item load", 'the-post-grid' ),
77
+ 'type' => 'textarea',
78
+ 'holderClass' => 'rt-script-wrapper full',
79
+ 'id' => 'script-after-item-load',
80
+ 'value' => isset( $settings['script_after_item_load'] ) ? stripslashes( $settings['script_after_item_load'] ) : null
81
+ ),
82
+ "script_loaded" => array(
83
+ 'name' => 'script_loaded',
84
+ "label" => __( "After Loaded Script", 'the-post-grid' ),
85
+ 'type' => 'textarea',
86
+ 'holderClass' => 'rt-script-wrapper full',
87
+ 'id' => 'script-loaded',
88
+ 'value' => isset( $settings['script_loaded'] ) ? stripslashes( $settings['script_loaded'] ) : null
89
+ )
90
+ );
91
+ }
92
 
93
+ function rtTPGCommonFilterFields() {
94
+ return array(
95
+ 'post__in' => array(
96
+ "name" => "post__in",
97
+ "label" => "Include only",
98
+ "type" => "text",
99
+ "class" => "full",
100
+ "description" => __( 'List of post IDs to show (comma-separated values, for example: 1,2,3)',
101
+ 'the-post-grid' )
102
+ ),
103
+ 'post__not_in' => array(
104
+ "name" => "post__not_in",
105
+ "label" => "Exclude",
106
+ "type" => "text",
107
+ "class" => "full",
108
+ "description" => __( 'List of post IDs to hide (comma-separated values, for example: 1,2,3)',
109
+ 'the-post-grid' )
110
+ ),
111
+ 'limit' => array(
112
+ "name" => "limit",
113
+ "label" => "Limit",
114
+ "type" => "number",
115
+ "class" => "full",
116
+ "description" => __( 'The number of posts to show. Set empty to show all found posts.',
117
+ 'the-post-grid' )
118
+ )
119
+ );
120
+ }
121
 
122
+ function rtTPGPostType() {
123
+ return array(
124
+ "name" => "tpg_post_type",
125
+ "label" => "Post Type",
126
+ "type" => "select",
127
+ "id" => "rc-sc-post-type",
128
+ "class" => "rt-select2",
129
+ "options" => $this->rtPostTypes()
130
+ );
131
+ }
132
 
133
+ function rtTPAdvanceFilters() {
134
+ return array(
135
+ 'type' => "checkbox",
136
+ 'name' => "post_filter",
137
+ 'label' => "Advanced filters",
138
+ 'id' => "post_filter",
139
+ "alignment" => "vertical",
140
+ "multiple" => true,
141
+ "options" => array(
142
+ 'tpg_taxonomy' => "Taxonomy",
143
+ 'order' => "Order",
144
+ 'author' => "Author",
145
+ 'tpg_post_status' => "Status",
146
+ 's' => "Search"
147
+ ),
148
+ );
149
+ }
150
 
151
+ function rtTPGPostStatus() {
152
+ return array(
153
+ 'publish' => 'Publish',
154
+ 'pending' => 'Pending',
155
+ 'draft' => 'Draft',
156
+ 'auto-draft' => 'Auto draft',
157
+ 'future' => 'Future',
158
+ 'private' => 'Private',
159
+ 'inherit' => 'Inherit',
160
+ 'trash' => 'Trash',
161
+ );
162
+ }
163
 
164
+ function rtTPGLayoutSettingFields() {
165
+ global $rtTPG;
166
 
167
+ return array(
168
+ 'layout' => array(
169
+ "type" => "select",
170
+ "name" => "layout",
171
+ "label" => "Layout",
172
+ "id" => "rt-tpg-sc-layout",
173
+ "class" => "rt-select2",
174
+ "options" => $this->rtTPGLayouts()
175
+ ),
176
+ 'isotope-filtering' => array(
177
+ "type" => "select",
178
+ "name" => "isotope_filter",
179
+ "label" => "Isotope Filter",
180
+ 'holderClass' => "sc-isotope-filter tpg-hidden",
181
+ "id" => "rt-tpg-sc-isotope-filter",
182
+ "class" => "rt-select2",
183
+ "options" => $rtTPG->rt_get_taxonomy_for_isotope_filter()
184
+ ),
185
+ 'tpg_show_all_text' => array(
186
+ "type" => "text",
187
+ "name" => "tpg_show_all_text",
188
+ 'holderClass' => "sc-isotope-filter tpg-hidden",
189
+ "label" => esc_html__( "Show all text", 'the-post-grid' ),
190
+ "default" => esc_html__( "Show all", 'the-post-grid' )
191
+ ),
192
+ 'tgp_layout2_image_column' => array(
193
+ 'type' => 'select',
194
+ "name" => "tgp_layout2_image_column",
195
+ "id" => "tgp_layout2_image_column",
196
+ 'label' => __( 'Image column', 'the-post-grid' ),
197
+ 'class' => 'rt-select2',
198
+ 'holderClass' => "holder-layout2-image-column tpg-hidden",
199
+ 'default' => 4,
200
+ 'options' => $this->rtTPGColumns(),
201
+ "description" => "Content column will calculate automatically"
202
+ ),
203
+ 'column' => array(
204
+ "type" => "select",
205
+ "name" => "column",
206
+ "label" => "Column",
207
+ "id" => "rt-column",
208
+ "class" => "rt-select2",
209
+ "default" => 4,
210
+ "options" => $this->rtTPGColumns()
211
+ ),
212
+ 'pagination' => array(
213
+ "type" => "checkbox",
214
+ "name" => "pagination",
215
+ "label" => "Pagination",
216
+ 'holderClass' => "pagination",
217
+ "id" => "rt-tpg-pagination",
218
+ "option" => 'Enable'
219
+ ),
220
+ 'posts_per_page' => array(
221
+ "type" => "number",
222
+ "name" => "posts_per_page",
223
+ "label" => "Display per page",
224
+ 'holderClass' => "posts-per-page tpg-hidden",
225
+ "id" => "posts-per-page",
226
+ "default" => 5,
227
+ "description" => __( "If value of Limit setting is not blank (empty), this value should be smaller than Limit value.",
228
+ 'the-post-grid' )
229
+ ),
230
+ 'featured_image' => array(
231
+ "type" => "checkbox",
232
+ "name" => "featured_image",
233
+ "label" => "Feature Image",
234
+ "id" => "rt-feature-image",
235
+ "option" => 'Disable'
236
+ ),
237
+ 'featured_image_size' => array(
238
+ "type" => "select",
239
+ "name" => "featured_image_size",
240
+ "label" => "Feature Image Size",
241
+ "id" => "featured-image-size",
242
+ 'holderClass' => "feature-image-options tpg-hidden",
243
+ "class" => "rt-select2",
244
+ "options" => $rtTPG->get_image_sizes()
245
+ ),
246
+ 'media_source' => array(
247
+ "type" => "radio",
248
+ "name" => "media_source",
249
+ "label" => "Media Source",
250
+ "id" => "media-source",
251
+ 'holderClass' => "feature-image-options tpg-hidden",
252
+ "default" => 'feature_image',
253
+ "alignment" => "vertical",
254
+ "options" => $this->rtMediaSource()
255
+ ),
256
+ 'tpg_title_limit' => array(
257
+ "name" => "tpg_title_limit",
258
+ "id" => "tpg-title-limit",
259
+ "type" => "number",
260
+ "label" => esc_html__( "Title limit", 'the-post-grid' ),
261
+ "description" => esc_html__( "Title limit only integer number is allowed, Leave it blank for full title.", 'the-post-grid' )
262
+ ),
263
+ 'tpg_title_limit_type' => array(
264
+ "name" => "tpg_title_limit_type",
265
+ "id" => "tpg-title-limit-type",
266
+ "type" => "radio",
267
+ "label" => esc_html__( "Title limit type", 'the-post-grid' ),
268
+ "alignment" => "vertical",
269
+ "default" => 'character',
270
+ "options" => $this->get_limit_type(),
271
+ ),
272
+ 'excerpt_limit' => array(
273
+ "type" => "number",
274
+ "name" => "excerpt_limit",
275
+ "label" => esc_html__( "Excerpt limit", 'the-post-grid' ),
276
+ "id" => "excerpt-limit",
277
+ "description" => __( "Excerpt limit only integer number is allowed, Leave it blank for full excerpt. Note: This will remove all html tag",
278
+ 'the-post-grid' )
279
+ ),
280
+ 'tgp_excerpt_type' => array(
281
+ "type" => "radio",
282
+ "label" => esc_html__( "Excerpt Type", 'the-post-grid' ),
283
+ "name" => "tgp_excerpt_type",
284
+ "id" => "tgp_excerpt_type",
285
+ "alignment" => "vertical",
286
+ "default" => 'character',
287
+ "options" => $this->get_limit_type( 'content' ),
288
+ ),
289
+ 'tgp_excerpt_more_text' => array(
290
+ "type" => "text",
291
+ "label" => esc_html__( "Excerpt more text", 'the-post-grid' ),
292
+ "name" => "tgp_excerpt_more_text",
293
+ "id" => "tgp_excerpt_more_text",
294
+ "default" => "..."
295
+ ),
296
+ 'tgp_read_more_text' => array(
297
+ "type" => "text",
298
+ "label" => esc_html__( "Read more text", 'the-post-grid' ),
299
+ "name" => "tgp_read_more_text",
300
+ "id" => "tgp_read_more_text",
301
+ ),
302
+ 'tpg_overlay' => array(
303
+ "type" => "checkbox",
304
+ "name" => "tpg_overlay",
305
+ "label" => esc_html__( "Overlay", 'the-post-grid' ),
306
+ "id" => "tpg_overlay",
307
+ "option" => 'Enable'
308
+ ),
309
+ 'title_tag' => array(
310
+ 'type' => 'select',
311
+ 'name' => 'title_tag',
312
+ 'label' => esc_html__( 'Title tag', 'the-post-grid' ),
313
+ 'class' => 'rt-select2',
314
+ 'id' => 'title-tag',
315
+ 'options' => $this->getTitleTags(),
316
+ 'default' => 'h2'
317
+ ),
318
+ );
319
+ }
320
 
321
+ function get_limit_type( $content = null ) {
322
+ $types = array(
323
+ 'character' => __( "Character", "the-post-grid" ),
324
+ 'word' => __( "Word", "the-post-grid" )
325
+ );
326
+ if ( $content === 'content' ) {
327
+ $types['full'] = __( "Full Content", "the-post-grid" );
328
+ }
329
 
330
+ return apply_filters( 'tpg_limit_type', $types, $content );
331
+ }
332
 
333
+ function rtTPGStyleFields() {
334
 
335
+ return array(
336
+ 'parent_class' => array(
337
+ "name" => "parent_class",
338
+ "type" => "text",
339
+ "label" => "Parent class",
340
+ "class" => "medium-text",
341
+ "description" => "Parent class for adding custom css"
342
+ ),
343
+ 'primary_color' => array(
344
+ "type" => "text",
345
+ "name" => "primary_color",
346
+ "label" => "Primary Color",
347
+ "id" => "primary-color",
348
+ "class" => "rt-color",
349
+ "default" => "#0367bf"
350
+ ),
351
+ 'button_bg_color' => array(
352
+ "type" => "text",
353
+ "name" => "button_bg_color",
354
+ "label" => "Button background color",
355
+ "id" => "button-bg-color",
356
+ "class" => "rt-color"
357
+ ),
358
+ 'button_hover_bg_color' => array(
359
+ "type" => "text",
360
+ "name" => "button_hover_bg_color",
361
+ "label" => "Button hover background color",
362
+ "id" => "button-hover-bg-color",
363
+ "class" => "rt-color"
364
+ ),
365
+ 'button_active_bg_color' => array(
366
+ "type" => "text",
367
+ "name" => "button_active_bg_color",
368
+ "label" => "Button active background color",
369
+ "id" => "button-active-bg-color",
370
+ "class" => "rt-color"
371
+ ),
372
+ 'button_text_bg_color' => array(
373
+ "type" => "text",
374
+ "name" => "button_text_color",
375
+ "label" => "Button text color",
376
+ "id" => "button-text-color",
377
+ "class" => "rt-color"
378
+ ),
379
+ 'title_color' => array(
380
+ "type" => "text",
381
+ "name" => "title_color",
382
+ "label" => esc_html__( "Title color", "the-post-grid" ),
383
+ "id" => "title_color",
384
+ "class" => "rt-color"
385
+ ),
386
+ 'title_hover_color' => array(
387
+ "type" => "text",
388
+ "name" => "title_hover_color",
389
+ "label" => esc_html__( "Title hover color", "the-post-grid" ),
390
+ "id" => "title_hover_color",
391
+ "class" => "rt-color"
392
+ ),
393
+ 'tpg_read_more_button_border_radius' => array(
394
+ "type" => "number",
395
+ "name" => "tpg_read_more_button_border_radius",
396
+ "id" => "tpg-read-more-button-border-radius",
397
+ "class" => "small-text",
398
+ "label" => esc_html__( "Read more button border radius", "the-post-grid" ),
399
+ "description" => esc_html__( "Leave it blank for default", 'the-post-grid' )
400
+ )
401
+ );
402
 
403
+ }
404
 
405
+ function getTitleTags() {
406
+ return array(
407
+ 'h2' => "H2",
408
+ 'h3' => "H3",
409
+ 'h4' => "H4"
410
+ );
411
+ }
412
 
413
+ function itemFields() {
414
+ return array(
415
+ "type" => "checkbox",
416
+ "name" => "item_fields",
417
+ "label" => "Field selection",
418
+ "id" => "item-fields",
419
+ "multiple" => true,
420
+ "alignment" => "vertical",
421
+ "default" => array_keys( $this->rtTPGItemFields() ),
422
+ "options" => $this->rtTPGItemFields()
423
+ );
424
+ }
425
 
426
+ function rtMediaSource() {
427
+ return array(
428
+ "feature_image" => __( "Feature Image", 'the-post-grid' ),
429
+ "first_image" => __( "First Image from content", 'the-post-grid' )
430
+ );
431
+ }
432
 
433
+ function rtTPGColumns() {
434
+ return array(
435
+ 1 => "Column 1",
436
+ 2 => "Column 2",
437
+ 3 => "Column 3",
438
+ 4 => "Column 4",
439
+ 5 => "Column 5",
440
+ 6 => "Column 6"
441
+ );
442
+ }
443
 
444
+ function rtTPGLayouts() {
445
+ $layouts = array(
446
+ 'layout1' => "Layout 1",
447
+ 'layout2' => "Layout 2",
448
+ 'layout3' => "Layout 3",
449
+ 'isotope1' => "Isotope Layout"
450
+ );
451
 
452
+ return apply_filters( 'tpg_layouts', $layouts );
453
+ }
454
 
455
+ function rtTPGItemFields() {
456
+ return array(
457
+ 'title' => __( "Title", 'the-post-grid' ),
458
+ 'excerpt' => __( "Excerpt", 'the-post-grid' ),
459
+ 'read_more' => __( "Read More", 'the-post-grid' ),
460
+ 'post_date' => __( "Post Date", 'the-post-grid' ),
461
+ 'author' => __( "Author", 'the-post-grid' ),
462
+ 'categories' => __( "Categories", 'the-post-grid' ),
463
+ 'tags' => __( "Tags", 'the-post-grid' ),
464
+ 'comment_count' => __( "Comment Count", 'the-post-grid' )
465
+ );
466
+ }
467
 
468
+ }
469
 
470
  endif;
lib/classes/rtTPGShortCode.php CHANGED
@@ -1,476 +1,481 @@
1
  <?php
2
 
3
- if (!class_exists('rtTPGShortCode')):
4
-
5
- class rtTPGShortCode
6
- {
7
-
8
- private $scA = array();
9
-
10
- function __construct() {
11
- add_shortcode('the-post-grid', array($this, 'the_post_grid_short_code'));
12
- add_action('wp_ajax_tpgPreviewAjaxCall', array($this, 'the_post_grid_short_code'));
13
- }
14
-
15
- function register_sc_scripts() {
16
- $iso = false;
17
- foreach ($this->scA as $sc) {
18
- if (isset($sc) && is_array($sc)) {
19
- if ($sc['isIsotope']) {
20
- $iso = true;
21
- }
22
- }
23
- }
24
- if (count($this->scA)) {
25
- if ($iso) {
26
- wp_enqueue_script('rt-isotope-js');
27
- }
28
- wp_enqueue_style('rt-fontawsome');
29
- wp_enqueue_script('rt-actual-height-js');
30
- wp_enqueue_script('rt-tpg');
31
- $nonce = wp_create_nonce(rtTPG()->nonceText());
32
- wp_localize_script('rt-tpg', 'rttpg',
33
- array(
34
- 'nonceID' => rtTPG()->nonceId(),
35
- 'nonce' => $nonce,
36
- 'ajaxurl' => admin_url('admin-ajax.php')
37
- ));
38
- }
39
- }
40
-
41
- function the_post_grid_short_code($atts = array(), $content = null) {
42
- $error = true;
43
- $html = $msg = null;
44
- $preview = isset($_REQUEST['sc_id']) ? absint($_REQUEST['sc_id']) : 0;
45
- $arg = array();
46
- $atts = shortcode_atts(array(
47
- 'id' => null
48
- ), $atts, 'the-post-grid');
49
- $scID = $atts['id'];
50
- if ((!$preview && $scID && !is_null(get_post($scID))) || ($preview && rtTPG()->verifyNonce())) {
51
- $rand = mt_rand();
52
- $layoutID = "rt-tpg-container-" . $rand;
53
- $pagination = false;
54
-
55
- if ($preview) {
56
- $error = false;
57
- $scMeta = $_REQUEST;
58
- $layout = isset($scMeta['layout']) ? $scMeta['layout'] : 'layout1';
59
- $col = isset($scMeta['column']) ? intval($scMeta['column']) : 4;
60
-
61
- $fImg = isset($scMeta['featured_image']) ? true : false;
62
- $fImgSize = isset($scMeta['featured_image_size']) ? $scMeta['featured_image_size'] : "medium";
63
- $mediaSource = isset($scMeta['media_source']) ? $scMeta['media_source'] : "feature_image";
64
- $arg['excerpt_type'] = isset($scMeta['tgp_excerpt_type']) ? $scMeta['tgp_excerpt_type'] : 'character';
65
- $arg['excerpt_limit'] = isset($scMeta['excerpt_limit']) ? absint($scMeta['excerpt_limit']) : 0;
66
- $arg['excerpt_more_text'] = isset($scMeta['tgp_excerpt_more_text']) ? $scMeta['tgp_excerpt_more_text'] : null;
67
- $arg['title_limit_type'] = isset($scMeta['tpg_title_limit_type']) ? $scMeta['tpg_title_limit_type'] : 'character';
68
- $arg['title_limit'] = isset($scMeta['tpg_title_limit']) ? absint($scMeta['tpg_title_limit']) : 0;
69
- $arg['read_more_text'] = isset($scMeta['tgp_read_more_text']) && !empty($scMeta['tgp_read_more_text']) ? $scMeta['tgp_read_more_text'] : __('Read More',
70
- 'the-post-grid');
71
- $arg['show_all_text'] = isset($scMeta['tpg_show_all_text']) && !empty($scMeta['tpg_show_all_text']) ? $scMeta['tpg_show_all_text'] : __('Show all',
72
- 'the-post-grid-pro');
73
- $postType = isset($scMeta['tpg_post_type']) ? $scMeta['tpg_post_type'] : null;
74
- $post__in = isset($scMeta['post__in']) ? $scMeta['post__in'] : null;
75
- $post__not_in = isset($scMeta['post__not_in']) ? $scMeta['post__not_in'] : null;
76
- $limit = isset($scMeta['limit']) && !empty($scMeta['limit']) ? ($scMeta['limit'] == -1 ? 10000000 : (int)$scMeta['limit']) : 10000000;
77
- $pagination = isset($scMeta['pagination']) ? $scMeta['pagination'] : false;
78
- $posts_per_page = isset($scMeta['posts_per_page']) ? intval($scMeta['posts_per_page']) : $limit;
79
- $order_by = isset($scMeta['order_by']) ? $scMeta['order_by'] : null;
80
- $order = isset($scMeta['order']) ? $scMeta['order'] : null;
81
- $s = isset($scMeta['s']) ? $scMeta['s'] : null;
82
- $isotope_filter = isset($scMeta['isotope_filter']) ? $scMeta['isotope_filter'] : null;
83
-
84
- } else {
85
- $scMeta = get_post_meta($scID);
86
- $scMeta['sc_id'] = $scID;
87
- $layout = isset($scMeta['layout'][0]) ? $scMeta['layout'][0] : 'layout1';
88
- $col = isset($scMeta['column'][0]) ? intval($scMeta['column'][0]) : 4;
89
-
90
- $fImg = isset($scMeta['featured_image'][0]) ? true : false;
91
- $fImgSize = isset($scMeta['featured_image_size'][0]) ? $scMeta['featured_image_size'][0] : "medium";
92
- $mediaSource = isset($scMeta['media_source'][0]) ? $scMeta['media_source'][0] : "feature_image";
93
- $arg['excerpt_type'] = isset($scMeta['tgp_excerpt_type'][0]) ? $scMeta['tgp_excerpt_type'][0] : 'character';
94
- $arg['excerpt_limit'] = isset($scMeta['excerpt_limit'][0]) ? absint($scMeta['excerpt_limit'][0]) : 0;
95
- $arg['excerpt_more_text'] = isset($scMeta['tgp_excerpt_more_text'][0]) ? $scMeta['tgp_excerpt_more_text'][0] : null;
96
- $arg['title_limit_type'] = isset($scMeta['tpg_title_limit_type'][0]) ? $scMeta['tpg_title_limit_type'][0] : 'character';
97
- $arg['title_limit'] = isset($scMeta['tpg_title_limit'][0]) ? absint($scMeta['tpg_title_limit'][0]) : 0;
98
- $arg['read_more_text'] = isset($scMeta['tgp_read_more_text'][0]) && !empty($scMeta['tgp_read_more_text'][0]) ? $scMeta['tgp_read_more_text'][0] : __('Read More',
99
- 'the-post-grid');
100
- $arg['show_all_text'] = (!empty($scMeta['tpg_show_all_text'][0]) ? $scMeta['tpg_show_all_text'][0] : __('Show all',
101
- 'the-post-grid-pro'));
102
-
103
- $postType = isset($scMeta['tpg_post_type'][0]) ? $scMeta['tpg_post_type'][0] : null;
104
- $post__in = isset($scMeta['post__in'][0]) ? $scMeta['post__in'][0] : null;
105
- $post__not_in = isset($scMeta['post__not_in'][0]) ? $scMeta['post__not_in'][0] : null;
106
- $limit = isset($scMeta['limit'][0]) && !empty($scMeta['limit'][0])? ($scMeta['limit'][0] == -1 ? 10000000 : (int)$scMeta['limit'][0]) : 10000000;
107
- $pagination = isset($scMeta['pagination'][0]) ? $scMeta['pagination'][0] : false;
108
- $posts_per_page = isset($scMeta['posts_per_page'][0]) ? intval($scMeta['posts_per_page'][0]) : $limit;
109
- $order_by = isset($scMeta['order_by'][0]) ? $scMeta['order_by'][0] : null;
110
- $order = isset($scMeta['order'][0]) ? $scMeta['order'][0] : null;
111
- $s = isset($scMeta['s'][0]) ? $scMeta['s'][0] : null;
112
- $isotope_filter = isset($scMeta['isotope_filter'][0]) ? $scMeta['isotope_filter'][0] : null;
113
-
114
- }
115
- if (!in_array($layout, array_keys(rtTPG()->rtTPGLayouts()))) {
116
- $layout = 'layout1';
117
- }
118
- if (!in_array($col, array_keys(rtTPG()->rtTPGColumns()))) {
119
- $col = 4;
120
- }
121
-
122
- $isIsotope = preg_match('/isotope/', $layout);
123
-
124
- /* Argument create */
125
- $args = array();
126
- $itemIdsArgs = array();
127
- if ($postType) {
128
- $args['post_type'] = $itemIdsArgs['post_type'] = $postType;
129
- }
130
-
131
- // Common filter
132
- /* post__in */
133
- if ($post__in) {
134
- $post__in = explode(',', $post__in);
135
- $args['post__in'] = $itemIdsArgs['post__in'] = $post__in;
136
- }
137
- /* post__not_in */
138
- if ($post__not_in) {
139
- $post__not_in = explode(',', $post__not_in);
140
- $args['post__not_in'] = $itemIdsArgs['post__not_in'] = $post__not_in;
141
- }
142
-
143
- /* LIMIT */
144
- $args['posts_per_page'] = $itemIdsArgs['posts_per_page'] = $limit;
145
- if (!$isIsotope && $pagination) {
146
- if ($posts_per_page > $limit) {
147
- $posts_per_page = $limit;
148
- }
149
- // Set 'posts_per_page' parameter
150
- $args['posts_per_page'] = $posts_per_page;
151
- if (get_query_var('paged')) {
152
- $paged = get_query_var('paged');
153
- } elseif (get_query_var('page')) {
154
- $paged = get_query_var('page');
155
- } else {
156
- $paged = 1;
157
- }
158
- $offset = $posts_per_page * ((int)$paged - 1);
159
- $args['paged'] = $paged;
160
-
161
- // Update posts_per_page
162
- if (intval($args['posts_per_page']) > $limit - $offset) {
163
- $args['posts_per_page'] = $limit - $offset;
164
- }
165
-
166
-
167
- }
168
-
169
- // Advance Filter
170
- $adv_filter = isset($scMeta['post_filter']) ? $scMeta['post_filter'] : array();
171
-
172
- // Taxonomy
173
- $taxQ = array();
174
- if (in_array('tpg_taxonomy', $adv_filter) && isset($scMeta['tpg_taxonomy'])) {
175
-
176
- if (is_array($scMeta['tpg_taxonomy']) && !empty($scMeta['tpg_taxonomy'])) {
177
- foreach ($scMeta['tpg_taxonomy'] as $taxonomy) {
178
- $terms = (isset($scMeta['term_' . $taxonomy]) ? $scMeta['term_' . $taxonomy] : array());
179
- if (is_array($terms) && !empty($terms)) {
180
- $operator = isset($scMeta['term_operator_' . $taxonomy][0]) ? $scMeta['term_operator_' . $taxonomy][0] : "IN";
181
- if ($preview) {
182
- $operator = isset($scMeta['term_operator_' . $taxonomy]) ? $scMeta['term_operator_' . $taxonomy] : "IN";
183
- }
184
- $taxQ[] = array(
185
- 'taxonomy' => $taxonomy,
186
- 'field' => 'term_id',
187
- 'terms' => $terms,
188
- 'operator' => $operator,
189
- );
190
- }
191
- }
192
- }
193
- if (count($taxQ) >= 2) {
194
- $relation = isset($scMeta['taxonomy_relation'][0]) ? $scMeta['taxonomy_relation'][0] : "AND";
195
- if ($preview) {
196
- $relation = isset($scMeta['taxonomy_relation']) ? $scMeta['taxonomy_relation'] : "AND";
197
- }
198
- $taxQ['relation'] = $relation;
199
- }
200
- }
201
-
202
- if (!empty($taxQ)) {
203
- $args['tax_query'] = $itemIdsArgs['tax_query'] = $taxQ;
204
- }
205
-
206
- // Order
207
- if (in_array('order', $adv_filter)) {
208
- if ($order) {
209
- $args['order'] = $itemIdsArgs['order'] = $order;
210
- }
211
- if ($order_by) {
212
- $args['orderby'] = $itemIdsArgs['orderby'] = $order_by;
213
- }
214
- }
215
- // Status
216
- if (in_array('tpg_post_status', $adv_filter)) {
217
- $post_status = (isset($scMeta['tpg_post_status']) ? $scMeta['tpg_post_status'] : array());
218
- if (!empty($post_status)) {
219
- $args['post_status'] = $itemIdsArgs['post_status'] = $post_status;
220
- } else {
221
- $args['post_status'] = $itemIdsArgs['post_status'] = 'publish';
222
- }
223
- }
224
- // Author
225
- $author = (isset($scMeta['author']) ? $scMeta['author'] : array());
226
- if (in_array('author', $adv_filter) && !empty($author)) {
227
- $args['author__in'] = $itemIdsArgs['author__in'] = $author;
228
- }
229
- // Search
230
- if (in_array('s', $adv_filter) && $s) {
231
- $args['s'] = $itemIdsArgs['s'] = $s;
232
- }
233
-
234
- // Validation
235
-
236
- if (($layout == 'layout2') || ($layout == 'layout3')) {
237
- $iCol = isset($scMeta['tgp_layout2_image_column'][0]) ? absint($scMeta['tgp_layout2_image_column'][0]) : 4;
238
- if ($preview) {
239
- $iCol = isset($scMeta['tgp_layout2_image_column']) ? absint($scMeta['tgp_layout2_image_column']) : 4;
240
- }
241
- $iCol = $iCol > 12 ? 4 : $iCol;
242
- $cCol = 12 - $iCol;
243
- $arg['image_area'] = "rt-col-sm-{$iCol} rt-col-xs-12 ";
244
- $arg['content_area'] = "rt-col-sm-{$cCol} rt-col-xs-12 ";
245
- }
246
- $col = $col == 5 ? "24" : round(12 / $col);
247
- if (($layout == 'layout2') || ($layout == 'layout3')) {
248
- $arg['grid'] = "rt-col-lg-{$col} rt-col-md-{$col} rt-col-sm-12 rt-col-xs-12";
249
- } else {
250
- $arg['grid'] = "rt-col-lg-{$col} rt-col-md-{$col} rt-col-sm-6 rt-col-xs-12";
251
- }
252
-
253
-
254
- $arg['class'] = 'rt-equal-height';
255
- if ($isIsotope) {
256
- $arg['class'] .= ' isotope-item';
257
- }
258
-
259
- $arg['overlay'] = empty($scMeta['tpg_overlay'][0]) ? false : true;
260
- $parentClass = (!empty($scMeta['parent_class'][0]) ? trim($scMeta['parent_class'][0]) : null);
261
- $arg['items'] = isset($scMeta['item_fields']) ? ($scMeta['item_fields'] ? $scMeta['item_fields'] : array()) : array();
262
- $arg['title_tag'] = (!empty($scMeta['title_tag'][0]) && in_array($scMeta['title_tag'][0], array_keys(rtTPG()->getTitleTags()))) ? esc_attr($scMeta['title_tag'][0]) : 'h2';
263
- $postQuery = new WP_Query(apply_filters('tpg_sc_query_args', $args, $scMeta));
264
- // Start layout
265
- $html .= "<div class='container-fluid rt-tpg-container rt-tpg-container-{$scMeta['sc_id']} {$parentClass}' data-sc-id='{$scMeta['sc_id']}' id='{$layoutID}'>";
266
- $extClass = null;
267
- if ($isIsotope) {
268
- $extClass = ' tpg-isotope';
269
- }
270
- $html .= "<div class='rt-row rt-content-loader {$layout}{$extClass}'>";
271
- if ($postQuery->have_posts()) {
272
- $html .= $this->layoutStyle($layoutID, $scMeta, $preview);
273
-
274
- if ($isIsotope) {
275
- $selectedTerms = (isset($scMeta['term_' . $isotope_filter]) ? $scMeta['term_' . $isotope_filter] : array());
276
- $terms = get_terms($isotope_filter, array(
277
- 'orderby' => 'name',
278
- 'order' => 'ASC',
279
- 'hide_empty' => false,
280
- 'include' => $selectedTerms
281
- ));
282
-
283
- $html .= '<div id="iso-button-' . $rand . '" class="iso-button-' . $scMeta['sc_id'] . ' rt-tpg-isotope-buttons filter-button-group option-set">
 
 
 
 
284
  <button data-filter="*" class="selected">' . $arg['show_all_text'] . '</button>';
285
- if (!empty($terms) && !is_wp_error($terms)) {
286
- foreach ($terms as $term) {
287
- $html .= "<button data-filter='.iso_{$term->term_id}'>" . $term->name . "</button>";
288
- }
289
- }
290
- $html .= '</div>';
291
-
292
- $html .= '<div class="rt-tpg-isotope iso-tpg-' . $scMeta['sc_id'] . '" id="iso-tpg-' . $rand . '">';
293
- }
294
-
295
-
296
- while ($postQuery->have_posts()) {
297
- $postQuery->the_post();
298
- $pID = get_the_ID();
299
- $arg['pID'] = $pID;
300
- $arg['title'] = rtTPG()->get_the_title($pID, $arg);
301
- $arg['pLink'] = get_permalink();
302
- $arg['author'] = '<a href="' . get_author_posts_url(get_the_author_meta('ID')) . '">' . get_the_author() . '</a>';
303
- $cc = wp_count_comments($pID);
304
- $arg['date'] = get_the_date();
305
- $arg['excerpt'] = rtTPG()->get_the_excerpt($pID, $arg);
306
- $arg['categories'] = get_the_term_list($pID, 'category', null, ', ');
307
- $arg['tags'] = get_the_term_list($pID, 'post_tag', null, ', ');
308
- if ($isIsotope) {
309
- $termAs = wp_get_post_terms($pID, $isotope_filter, array("fields" => "all"));
310
- $isoFilter = null;
311
- if (!empty($termAs)) {
312
- foreach ($termAs as $term) {
313
- $isoFilter .= " iso_" . $term->term_id;
314
- }
315
- }
316
- $arg['isoFilter'] = $isoFilter;
317
- }
318
- $deptClass = null;
319
- if (!empty($deptAs)) {
320
- foreach ($deptAs as $dept) {
321
- $deptClass .= " " . $dept->slug;
322
- }
323
- }
324
- if (comments_open()) {
325
- $arg['comment'] = "<a href='" . get_comments_link($pID) . "'>{$cc->total_comments} </a>";
326
- } else {
327
- $arg['comment'] = "{$cc->total_comments}";
328
- }
329
- $imgSrc = null;
330
-
331
- $arg['imgSrc'] = !$fImg ? rtTPG()->getFeatureImageSrc($pID, $fImgSize, $mediaSource) : null;
332
-
333
- $html .= rtTPG()->render('layouts/' . $layout, $arg, true);
334
- }
335
-
336
- if ($isIsotope) {
337
- $html .= '</div>'; // End isotope item holder
338
- }
339
-
340
- } else {
341
- $html .= sprintf('<p>%s</p>',
342
- apply_filters('tpg_not_found_text', __('No post found', 'the-post-grid'), $args, $scMeta)
343
- );
344
- }
345
- $html .= "</div>"; // End row
346
- if ($pagination && !$isIsotope) {
347
- $found = 0;
348
- if ($postQuery->found_posts > $limit) {
349
- $found = $limit;
350
- } else {
351
- $found = $postQuery->found_posts;
352
- }
353
- $max_num_pages = ceil($found / $posts_per_page);
354
- $html .= rtTPG()->rt_pagination($max_num_pages, $args['posts_per_page']);
355
- }
356
- $html .= "</div>"; // container rt-tpg
357
-
358
- wp_reset_postdata();
359
- if (!$preview) {
360
- $scriptGenerator = array();
361
- $scriptGenerator['layout'] = $layoutID;
362
- $scriptGenerator['rand'] = $rand;
363
- $scriptGenerator['scMeta'] = $scMeta;
364
- $scriptGenerator['isIsotope'] = $isIsotope;
365
- $this->scA[] = $scriptGenerator;
366
- add_action('wp_footer', array($this, 'register_sc_scripts'));
367
- }
368
- } else {
369
- if ($preview) {
370
- $msg = __('Session Error !!', 'the-post-grid');
371
- } else {
372
- $html .= "<p>" . __("No shortCode found", 'the-post-grid') . "</p>";
373
- }
374
- }
375
- if ($preview) {
376
- wp_send_json(array(
377
- 'error' => $error,
378
- 'msg' => $msg,
379
- 'data' => $html
380
- ));
381
- die();
382
- }
383
- return $html;
384
- }
385
-
386
- function layoutStyle($layout, $scMeta, $preview = false) {
387
- if ($preview) {
388
- $primaryColor = (!empty($scMeta['primary_color']) ? $scMeta['primary_color'] : null);
389
- $button_bg_color = (!empty($scMeta['button_bg_color']) ? $scMeta['button_bg_color'] : null);
390
- $button_hover_bg_color = (!empty($scMeta['button_hover_bg_color']) ? $scMeta['button_hover_bg_color'] : null);
391
- $button_active_bg_color = (!empty($scMeta['button_active_bg_color']) ? $scMeta['button_active_bg_color'] : null);
392
- $button_text_color = (!empty($scMeta['button_text_color']) ? $scMeta['button_text_color'] : null);
393
- $title_color = isset($scMeta['title_color']) && !empty($scMeta['title_color']) ? $scMeta['title_color'] : null;
394
- $title_hover_color = isset($scMeta['title_hover_color']) && !empty($scMeta['title_hover_color']) ? $scMeta['title_hover_color'] : null;
395
- $read_more_button_border_radius = isset($scMeta['tpg_read_more_button_border_radius']) ? $scMeta['tpg_read_more_button_border_radius'] : '';
396
-
397
- } else {
398
-
399
- $primaryColor = (!empty($scMeta['primary_color'][0]) ? $scMeta['primary_color'][0] : null);
400
- $button_bg_color = (!empty($scMeta['button_bg_color'][0]) ? $scMeta['button_bg_color'][0] : null);
401
- $button_hover_bg_color = (!empty($scMeta['button_hover_bg_color'][0]) ? $scMeta['button_hover_bg_color'][0] : null);
402
- $button_active_bg_color = (!empty($scMeta['button_active_bg_color'][0]) ? $scMeta['button_active_bg_color'][0] : null);
403
- $button_text_color = (!empty($scMeta['button_text_color'][0]) ? $scMeta['button_text_color'][0] : null);
404
- $title_color = isset($scMeta['title_color'][0]) && !empty($scMeta['title_color'][0]) ? $scMeta['title_color'][0] : null;
405
- $title_hover_color = isset($scMeta['title_hover_color'][0]) && !empty($scMeta['title_hover_color'][0]) ? $scMeta['title_hover_color'][0] : null;
406
- $read_more_button_border_radius = isset($scMeta['tpg_read_more_button_border_radius'][0]) ? $scMeta['tpg_read_more_button_border_radius'][0] : '';
407
-
408
- }
409
- $css = null;
410
- $css .= "<style type='text/css' media='all'>";
411
- // Variable
412
- if ($primaryColor) {
413
- $css .= "#{$layout} .rt-detail i,
 
414
  #{$layout} .rt-detail .post-meta-user a,
415
  #{$layout} .rt-detail .post-meta-category a{";
416
- $css .= "color:" . $primaryColor . ";";
417
- $css .= "}";
418
- $css .= "body .rt-tpg-container .rt-tpg-isotope-buttons .selected{";
419
- $css .= "background-color:" . $primaryColor . ";";
420
- $css .= "}";
421
- }
422
- if ($button_bg_color) {
423
- $css .= "#{$layout} .pagination li a,
424
  #{$layout} .rt-tpg-isotope-buttons button,
425
  #{$layout} .rt-detail .read-more a{";
426
- $css .= "background-color:" . $button_bg_color . ";";
427
- $css .= "}";
428
- }
429
- if ($button_hover_bg_color) {
430
- $css .= "#{$layout} .pagination li a:hover,
431
  #{$layout} .rt-tpg-isotope-buttons button:hover,
432
  #{$layout} .rt-detail .read-more a:hover{";
433
- $css .= "background-color:" . $button_hover_bg_color . ";";
434
- $css .= "}";
435
- }
436
- if ($button_active_bg_color) {
437
- $css .= "#{$layout} .pagination li.active span,
438
  #{$layout} .rt-tpg-isotope-buttons button.selected{";
439
- $css .= "background-color:" . $button_active_bg_color . ";";
440
- $css .= "}";
441
- }
442
- if ($button_text_color) {
443
- $css .= "#{$layout} .pagination li a,
444
  #{$layout} .rt-tpg-isotope-buttons button,
445
  #{$layout} .rt-detail .read-more a{";
446
- $css .= "color:" . $button_text_color . ";";
447
- $css .= "}";
448
- }
449
- if ($title_color) {
450
- $css .= "#{$layout} .rt-detail h2.entry-title a,
451
  #{$layout} .rt-detail h3.entry-title a,
452
  #{$layout} .rt-detail h4.entry-title a{";
453
- $css .= "color:" . $title_color . ";";
454
- $css .= "}";
455
- }
456
- if ($title_hover_color) {
457
- $css .= "#{$layout} .rt-detail h2.entry-title a:hover,
458
  #{$layout} .rt-detail h3.entry-title a:hover,
459
  #{$layout} .rt-detail h4.entry-title a:hover{";
460
- $css .= "color:" . $title_hover_color . ";";
461
- $css .= "}";
462
- }
463
-
464
- // Read more button Position
465
- if (isset($read_more_button_border_radius) || trim($read_more_button_border_radius) !== '') {
466
- $css .= "#{$layout} .read-more a{";
467
- $css .= "border-radius:" . $read_more_button_border_radius . "px;";
468
- $css .= "}";
469
- }
470
-
471
- $css .= "</style>";
472
-
473
- return $css;
474
- }
475
- }
476
  endif;
1
  <?php
2
 
3
+ if ( ! class_exists( 'rtTPGShortCode' ) ):
4
+
5
+ class rtTPGShortCode {
6
+
7
+ private $scA = array();
8
+
9
+ function __construct() {
10
+ add_shortcode( 'the-post-grid', array( $this, 'the_post_grid_short_code' ) );
11
+ add_action( 'wp_ajax_tpgPreviewAjaxCall', array( $this, 'the_post_grid_short_code' ) );
12
+ }
13
+
14
+ function register_sc_scripts() {
15
+ $iso = false;
16
+ foreach ( $this->scA as $sc ) {
17
+ if ( isset( $sc ) && is_array( $sc ) ) {
18
+ if ( $sc['isIsotope'] ) {
19
+ $iso = true;
20
+ }
21
+ }
22
+ }
23
+ if ( count( $this->scA ) ) {
24
+ if ( $iso ) {
25
+ wp_enqueue_script( 'rt-isotope-js' );
26
+ }
27
+ wp_enqueue_style( 'rt-fontawsome' );
28
+ wp_enqueue_script( 'rt-actual-height-js' );
29
+ wp_enqueue_script( 'rt-tpg' );
30
+ $nonce = wp_create_nonce( rtTPG()->nonceText() );
31
+ wp_localize_script( 'rt-tpg', 'rttpg',
32
+ array(
33
+ 'nonceID' => rtTPG()->nonceId(),
34
+ 'nonce' => $nonce,
35
+ 'ajaxurl' => admin_url( 'admin-ajax.php' )
36
+ ) );
37
+ }
38
+ }
39
+
40
+ function the_post_grid_short_code( $atts = array(), $content = null ) {
41
+ $error = true;
42
+ $html = $msg = null;
43
+ $preview = isset( $_REQUEST['sc_id'] ) ? absint( $_REQUEST['sc_id'] ) : 0;
44
+ $arg = array();
45
+ $atts = shortcode_atts( array(
46
+ 'id' => null
47
+ ), $atts, 'the-post-grid' );
48
+ $scID = $atts['id'];
49
+ if ( ( ! $preview && $scID && ! is_null( get_post( $scID ) ) ) || ( $preview && rtTPG()->verifyNonce() ) ) {
50
+ $rand = mt_rand();
51
+ $layoutID = "rt-tpg-container-" . $rand;
52
+ $pagination = false;
53
+
54
+ if ( $preview ) {
55
+ $error = false;
56
+ $scMeta = $_REQUEST;
57
+ $layout = isset( $scMeta['layout'] ) ? $scMeta['layout'] : 'layout1';
58
+ $col = isset( $scMeta['column'] ) ? intval( $scMeta['column'] ) : 4;
59
+
60
+ $fImg = isset( $scMeta['featured_image'] ) ? true : false;
61
+ $fImgSize = isset( $scMeta['featured_image_size'] ) ? $scMeta['featured_image_size'] : "medium";
62
+ $mediaSource = isset( $scMeta['media_source'] ) ? $scMeta['media_source'] : "feature_image";
63
+ $arg['excerpt_type'] = isset( $scMeta['tgp_excerpt_type'] ) ? $scMeta['tgp_excerpt_type'] : 'character';
64
+ $arg['excerpt_limit'] = isset( $scMeta['excerpt_limit'] ) ? absint( $scMeta['excerpt_limit'] ) : 0;
65
+ $arg['excerpt_more_text'] = isset( $scMeta['tgp_excerpt_more_text'] ) ? $scMeta['tgp_excerpt_more_text'] : null;
66
+ $arg['title_limit_type'] = isset( $scMeta['tpg_title_limit_type'] ) ? $scMeta['tpg_title_limit_type'] : 'character';
67
+ $arg['title_limit'] = isset( $scMeta['tpg_title_limit'] ) ? absint( $scMeta['tpg_title_limit'] ) : 0;
68
+ $arg['read_more_text'] = isset( $scMeta['tgp_read_more_text'] ) && ! empty( $scMeta['tgp_read_more_text'] ) ? $scMeta['tgp_read_more_text'] : __( 'Read More',
69
+ 'the-post-grid' );
70
+ $arg['show_all_text'] = isset( $scMeta['tpg_show_all_text'] ) && ! empty( $scMeta['tpg_show_all_text'] ) ? $scMeta['tpg_show_all_text'] : __( 'Show all',
71
+ 'the-post-grid-pro' );
72
+ $postType = isset( $scMeta['tpg_post_type'] ) ? $scMeta['tpg_post_type'] : null;
73
+ $post__in = isset( $scMeta['post__in'] ) ? $scMeta['post__in'] : null;
74
+ $post__not_in = isset( $scMeta['post__not_in'] ) ? $scMeta['post__not_in'] : null;
75
+ $limit = isset( $scMeta['limit'] ) && ! empty( $scMeta['limit'] ) ? ( $scMeta['limit'] == - 1 ? 10000000 : (int) $scMeta['limit'] ) : 10000000;
76
+ $pagination = isset( $scMeta['pagination'] ) ? $scMeta['pagination'] : false;
77
+ $posts_per_page = isset( $scMeta['posts_per_page'] ) ? intval( $scMeta['posts_per_page'] ) : $limit;
78
+ $order_by = isset( $scMeta['order_by'] ) ? $scMeta['order_by'] : null;
79
+ $order = isset( $scMeta['order'] ) ? $scMeta['order'] : null;
80
+ $s = isset( $scMeta['s'] ) ? $scMeta['s'] : null;
81
+ $isotope_filter = isset( $scMeta['isotope_filter'] ) ? $scMeta['isotope_filter'] : null;
82
+
83
+ } else {
84
+ $scMeta = get_post_meta( $scID );
85
+ $scMeta['sc_id'] = $scID;
86
+ $layout = isset( $scMeta['layout'][0] ) ? $scMeta['layout'][0] : 'layout1';
87
+ $col = isset( $scMeta['column'][0] ) ? intval( $scMeta['column'][0] ) : 4;
88
+
89
+ $fImg = isset( $scMeta['featured_image'][0] ) ? true : false;
90
+ $fImgSize = isset( $scMeta['featured_image_size'][0] ) ? $scMeta['featured_image_size'][0] : "medium";
91
+ $mediaSource = isset( $scMeta['media_source'][0] ) ? $scMeta['media_source'][0] : "feature_image";
92
+ $arg['excerpt_type'] = isset( $scMeta['tgp_excerpt_type'][0] ) ? $scMeta['tgp_excerpt_type'][0] : 'character';
93
+ $arg['excerpt_limit'] = isset( $scMeta['excerpt_limit'][0] ) ? absint( $scMeta['excerpt_limit'][0] ) : 0;
94
+ $arg['excerpt_more_text'] = isset( $scMeta['tgp_excerpt_more_text'][0] ) ? $scMeta['tgp_excerpt_more_text'][0] : null;
95
+ $arg['title_limit_type'] = isset( $scMeta['tpg_title_limit_type'][0] ) ? $scMeta['tpg_title_limit_type'][0] : 'character';
96
+ $arg['title_limit'] = isset( $scMeta['tpg_title_limit'][0] ) ? absint( $scMeta['tpg_title_limit'][0] ) : 0;
97
+ $arg['read_more_text'] = isset( $scMeta['tgp_read_more_text'][0] ) && ! empty( $scMeta['tgp_read_more_text'][0] ) ? $scMeta['tgp_read_more_text'][0] : __( 'Read More',
98
+ 'the-post-grid' );
99
+ $arg['show_all_text'] = ( ! empty( $scMeta['tpg_show_all_text'][0] ) ? $scMeta['tpg_show_all_text'][0] : __( 'Show all',
100
+ 'the-post-grid-pro' ) );
101
+
102
+ $postType = isset( $scMeta['tpg_post_type'][0] ) ? $scMeta['tpg_post_type'][0] : null;
103
+ $post__in = isset( $scMeta['post__in'][0] ) ? $scMeta['post__in'][0] : null;
104
+ $post__not_in = isset( $scMeta['post__not_in'][0] ) ? $scMeta['post__not_in'][0] : null;
105
+ $limit = isset( $scMeta['limit'][0] ) && ! empty( $scMeta['limit'][0] ) ? ( $scMeta['limit'][0] == - 1 ? 10000000 : (int) $scMeta['limit'][0] ) : 10000000;
106
+ $pagination = isset( $scMeta['pagination'][0] ) ? $scMeta['pagination'][0] : false;
107
+ $posts_per_page = isset( $scMeta['posts_per_page'][0] ) ? intval( $scMeta['posts_per_page'][0] ) : $limit;
108
+ $order_by = isset( $scMeta['order_by'][0] ) ? $scMeta['order_by'][0] : null;
109
+ $order = isset( $scMeta['order'][0] ) ? $scMeta['order'][0] : null;
110
+ $s = isset( $scMeta['s'][0] ) ? $scMeta['s'][0] : null;
111
+ $isotope_filter = isset( $scMeta['isotope_filter'][0] ) ? $scMeta['isotope_filter'][0] : null;
112
+
113
+ }
114
+ if ( ! in_array( $layout, array_keys( rtTPG()->rtTPGLayouts() ) ) ) {
115
+ $layout = 'layout1';
116
+ }
117
+ if ( ! in_array( $col, array_keys( rtTPG()->rtTPGColumns() ) ) ) {
118
+ $col = 4;
119
+ }
120
+
121
+ $isIsotope = preg_match( '/isotope/', $layout );
122
+
123
+ /* Argument create */
124
+ $args = array();
125
+ $itemIdsArgs = array();
126
+ if ( $postType ) {
127
+ $args['post_type'] = $itemIdsArgs['post_type'] = $postType;
128
+ }
129
+
130
+ // Common filter
131
+ /* post__in */
132
+ if ( $post__in ) {
133
+ $post__in = explode( ',', $post__in );
134
+ $args['post__in'] = $itemIdsArgs['post__in'] = $post__in;
135
+ }
136
+ /* post__not_in */
137
+ if ( $post__not_in ) {
138
+ $post__not_in = explode( ',', $post__not_in );
139
+ $args['post__not_in'] = $itemIdsArgs['post__not_in'] = $post__not_in;
140
+ }
141
+
142
+ /* LIMIT */
143
+ $args['posts_per_page'] = $itemIdsArgs['posts_per_page'] = $limit;
144
+ if ( ! $isIsotope && $pagination ) {
145
+ if ( $posts_per_page > $limit ) {
146
+ $posts_per_page = $limit;
147
+ }
148
+ // Set 'posts_per_page' parameter
149
+ $args['posts_per_page'] = $posts_per_page;
150
+ if ( get_query_var( 'paged' ) ) {
151
+ $paged = get_query_var( 'paged' );
152
+ } elseif ( get_query_var( 'page' ) ) {
153
+ $paged = get_query_var( 'page' );
154
+ } else {
155
+ $paged = 1;
156
+ }
157
+ $offset = $posts_per_page * ( (int) $paged - 1 );
158
+ $args['paged'] = $paged;
159
+
160
+ // Update posts_per_page
161
+ if ( intval( $args['posts_per_page'] ) > $limit - $offset ) {
162
+ $args['posts_per_page'] = $limit - $offset;
163
+ }
164
+
165
+
166
+ }
167
+
168
+ // Advance Filter
169
+ $adv_filter = isset( $scMeta['post_filter'] ) ? $scMeta['post_filter'] : array();
170
+
171
+ // Taxonomy
172
+ $taxQ = array();
173
+ if ( in_array( 'tpg_taxonomy', $adv_filter ) && isset( $scMeta['tpg_taxonomy'] ) ) {
174
+
175
+ if ( is_array( $scMeta['tpg_taxonomy'] ) && ! empty( $scMeta['tpg_taxonomy'] ) ) {
176
+ foreach ( $scMeta['tpg_taxonomy'] as $taxonomy ) {
177
+ $terms = ( isset( $scMeta[ 'term_' . $taxonomy ] ) ? $scMeta[ 'term_' . $taxonomy ] : array() );
178
+ if ( is_array( $terms ) && ! empty( $terms ) ) {
179
+ $operator = isset( $scMeta[ 'term_operator_' . $taxonomy ][0] ) ? $scMeta[ 'term_operator_' . $taxonomy ][0] : "IN";
180
+ if ( $preview ) {
181
+ $operator = isset( $scMeta[ 'term_operator_' . $taxonomy ] ) ? $scMeta[ 'term_operator_' . $taxonomy ] : "IN";
182
+ }
183
+ $taxQ[] = array(
184
+ 'taxonomy' => $taxonomy,
185
+ 'field' => 'term_id',
186
+ 'terms' => $terms,
187
+ 'operator' => $operator,
188
+ );
189
+ }
190
+ }
191
+ }
192
+ if ( count( $taxQ ) >= 2 ) {
193
+ $relation = isset( $scMeta['taxonomy_relation'][0] ) ? $scMeta['taxonomy_relation'][0] : "AND";
194
+ if ( $preview ) {
195
+ $relation = isset( $scMeta['taxonomy_relation'] ) ? $scMeta['taxonomy_relation'] : "AND";
196
+ }
197
+ $taxQ['relation'] = $relation;
198
+ }
199
+ }
200
+
201
+ if ( ! empty( $taxQ ) ) {
202
+ $args['tax_query'] = $itemIdsArgs['tax_query'] = $taxQ;
203
+ }
204
+
205
+ // Order
206
+ if ( in_array( 'order', $adv_filter ) ) {
207
+ if ( $order ) {
208
+ $args['order'] = $itemIdsArgs['order'] = $order;
209
+ }
210
+ if ( $order_by ) {
211
+ $args['orderby'] = $itemIdsArgs['orderby'] = $order_by;
212
+ }
213
+ }
214
+ // Status
215
+ if ( in_array( 'tpg_post_status', $adv_filter ) ) {
216
+ $post_status = ( isset( $scMeta['tpg_post_status'] ) ? $scMeta['tpg_post_status'] : array() );
217
+ if ( ! empty( $post_status ) ) {
218
+ $args['post_status'] = $itemIdsArgs['post_status'] = $post_status;
219
+ } else {
220
+ $args['post_status'] = $itemIdsArgs['post_status'] = 'publish';
221
+ }
222
+ }
223
+ // Author
224
+ $author = ( isset( $scMeta['author'] ) ? $scMeta['author'] : array() );
225
+ if ( in_array( 'author', $adv_filter ) && ! empty( $author ) ) {
226
+ $args['author__in'] = $itemIdsArgs['author__in'] = $author;
227
+ }
228
+ // Search
229
+ if ( in_array( 's', $adv_filter ) && $s ) {
230
+ $args['s'] = $itemIdsArgs['s'] = $s;
231
+ }
232
+
233
+ // Validation
234
+
235
+ if ( ( $layout == 'layout2' ) || ( $layout == 'layout3' ) ) {
236
+ $iCol = isset( $scMeta['tgp_layout2_image_column'][0] ) ? absint( $scMeta['tgp_layout2_image_column'][0] ) : 4;
237
+ if ( $preview ) {
238
+ $iCol = isset( $scMeta['tgp_layout2_image_column'] ) ? absint( $scMeta['tgp_layout2_image_column'] ) : 4;
239
+ }
240
+ $iCol = $iCol > 12 ? 4 : $iCol;
241
+ $cCol = 12 - $iCol;
242
+ $arg['image_area'] = "rt-col-sm-{$iCol} rt-col-xs-12 ";
243
+ $arg['content_area'] = "rt-col-sm-{$cCol} rt-col-xs-12 ";
244
+ }
245
+ $col = $col == 5 ? "24" : round( 12 / $col );
246
+ if ( ( $layout == 'layout2' ) || ( $layout == 'layout3' ) ) {
247
+ $arg['grid'] = "rt-col-lg-{$col} rt-col-md-{$col} rt-col-sm-12 rt-col-xs-12";
248
+ } else {
249
+ $arg['grid'] = "rt-col-lg-{$col} rt-col-md-{$col} rt-col-sm-6 rt-col-xs-12";
250
+ }
251
+
252
+
253
+ $arg['class'] = 'rt-equal-height';
254
+ if ( $isIsotope ) {
255
+ $arg['class'] .= ' isotope-item';
256
+ }
257
+
258
+ $arg['overlay'] = empty( $scMeta['tpg_overlay'][0] ) ? false : true;
259
+ $parentClass = ( ! empty( $scMeta['parent_class'][0] ) ? trim( $scMeta['parent_class'][0] ) : null );
260
+ $arg['items'] = isset( $scMeta['item_fields'] ) ? ( $scMeta['item_fields'] ? $scMeta['item_fields'] : array() ) : array();
261
+ $arg['title_tag'] = ( ! empty( $scMeta['title_tag'][0] ) && in_array( $scMeta['title_tag'][0], array_keys( rtTPG()->getTitleTags() ) ) ) ? esc_attr( $scMeta['title_tag'][0] ) : 'h2';
262
+ $postQuery = new WP_Query( apply_filters( 'tpg_sc_query_args', $args, $scMeta ) );
263
+ // Start layout
264
+ $html .= "<div class='container-fluid rt-tpg-container rt-tpg-container-{$scMeta['sc_id']} {$parentClass}' data-sc-id='{$scMeta['sc_id']}' id='{$layoutID}'>";
265
+ $extClass = null;
266
+ if ( $isIsotope ) {
267
+ $extClass = ' tpg-isotope';
268
+ }
269
+ // Set readmore false if excerpt type = full content
270
+ if ( isset( $arg['excerpt_type'] ) && $arg['excerpt_type'] === 'full' && ($key = array_search('read_more', $arg['items'])) !== false ) {
271
+ unset( $arg['items'][$key] );
272
+ }
273
+
274
+ $html .= "<div class='rt-row rt-content-loader {$layout}{$extClass}'>";
275
+ if ( $postQuery->have_posts() ) {
276
+ $html .= $this->layoutStyle( $layoutID, $scMeta, $preview );
277
+
278
+ if ( $isIsotope ) {
279
+ $selectedTerms = ( isset( $scMeta[ 'term_' . $isotope_filter ] ) ? $scMeta[ 'term_' . $isotope_filter ] : array() );
280
+ $terms = get_terms( $isotope_filter, array(
281
+ 'orderby' => 'name',
282
+ 'order' => 'ASC',
283
+ 'hide_empty' => false,
284
+ 'include' => $selectedTerms
285
+ ) );
286
+
287
+ $html .= '<div id="iso-button-' . $rand . '" class="iso-button-' . $scMeta['sc_id'] . ' rt-tpg-isotope-buttons filter-button-group option-set">
288
  <button data-filter="*" class="selected">' . $arg['show_all_text'] . '</button>';
289
+ if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
290
+ foreach ( $terms as $term ) {
291
+ $html .= "<button data-filter='.iso_{$term->term_id}'>" . $term->name . "</button>";
292
+ }
293
+ }
294
+ $html .= '</div>';
295
+
296
+ $html .= '<div class="rt-tpg-isotope iso-tpg-' . $scMeta['sc_id'] . '" id="iso-tpg-' . $rand . '">';
297
+ }
298
+
299
+
300
+ while ( $postQuery->have_posts() ) {
301
+ $postQuery->the_post();
302
+ $pID = get_the_ID();
303
+ $arg['pID'] = $pID;
304
+ $arg['title'] = rtTPG()->get_the_title( $pID, $arg );
305
+ $arg['pLink'] = get_permalink();
306
+ $arg['author'] = '<a href="' . get_author_posts_url( get_the_author_meta( 'ID' ) ) . '">' . get_the_author() . '</a>';
307
+ $cc = wp_count_comments( $pID );
308
+ $arg['date'] = get_the_date();
309
+ $arg['excerpt'] = rtTPG()->get_the_excerpt( $pID, $arg );
310
+ $arg['categories'] = get_the_term_list( $pID, 'category', null, ', ' );
311
+ $arg['tags'] = get_the_term_list( $pID, 'post_tag', null, ', ' );
312
+ if ( $isIsotope ) {
313
+ $termAs = wp_get_post_terms( $pID, $isotope_filter, array( "fields" => "all" ) );
314
+ $isoFilter = null;
315
+ if ( ! empty( $termAs ) ) {
316
+ foreach ( $termAs as $term ) {
317
+ $isoFilter .= " iso_" . $term->term_id;
318
+ }
319
+ }
320
+ $arg['isoFilter'] = $isoFilter;
321
+ }
322
+ $deptClass = null;
323
+ if ( ! empty( $deptAs ) ) {
324
+ foreach ( $deptAs as $dept ) {
325
+ $deptClass .= " " . $dept->slug;
326
+ }
327
+ }
328
+ if ( comments_open() ) {
329
+ $arg['comment'] = "<a href='" . get_comments_link( $pID ) . "'>{$cc->total_comments} </a>";
330
+ } else {
331
+ $arg['comment'] = "{$cc->total_comments}";
332
+ }
333
+ $imgSrc = null;
334
+
335
+ $arg['imgSrc'] = ! $fImg ? rtTPG()->getFeatureImageSrc( $pID, $fImgSize, $mediaSource ) : null;
336
+
337
+ $html .= rtTPG()->render( 'layouts/' . $layout, $arg, true );
338
+ }
339
+
340
+ if ( $isIsotope ) {
341
+ $html .= '</div>'; // End isotope item holder
342
+ }
343
+
344
+ } else {
345
+ $html .= sprintf( '<p>%s</p>',
346
+ apply_filters( 'tpg_not_found_text', __( 'No post found', 'the-post-grid' ), $args, $scMeta )
347
+ );
348
+ }
349
+ $html .= "</div>"; // End row
350
+ if ( $pagination && ! $isIsotope ) {
351
+ $found = 0;
352
+ if ( $postQuery->found_posts > $limit ) {
353
+ $found = $limit;
354
+ } else {
355
+ $found = $postQuery->found_posts;
356
+ }
357
+ $max_num_pages = ceil( $found / $posts_per_page );
358
+ $html .= rtTPG()->rt_pagination( $max_num_pages, $args['posts_per_page'] );
359
+ }
360
+ $html .= "</div>"; // container rt-tpg
361
+
362
+ wp_reset_postdata();
363
+ if ( ! $preview ) {
364
+ $scriptGenerator = array();
365
+ $scriptGenerator['layout'] = $layoutID;
366
+ $scriptGenerator['rand'] = $rand;
367
+ $scriptGenerator['scMeta'] = $scMeta;
368
+ $scriptGenerator['isIsotope'] = $isIsotope;
369
+ $this->scA[] = $scriptGenerator;
370
+ add_action( 'wp_footer', array( $this, 'register_sc_scripts' ) );
371
+ }
372
+ } else {
373
+ if ( $preview ) {
374
+ $msg = __( 'Session Error !!', 'the-post-grid' );
375
+ } else {
376
+ $html .= "<p>" . __( "No shortCode found", 'the-post-grid' ) . "</p>";
377
+ }
378
+ }
379
+ if ( $preview ) {
380
+ wp_send_json( array(
381
+ 'error' => $error,
382
+ 'msg' => $msg,
383
+ 'data' => $html
384
+ ) );
385
+ die();
386
+ }
387
+
388
+ return $html;
389
+ }
390
+
391
+ function layoutStyle( $layout, $scMeta, $preview = false ) {
392
+ if ( $preview ) {
393
+ $primaryColor = ( ! empty( $scMeta['primary_color'] ) ? $scMeta['primary_color'] : null );
394
+ $button_bg_color = ( ! empty( $scMeta['button_bg_color'] ) ? $scMeta['button_bg_color'] : null );
395
+ $button_hover_bg_color = ( ! empty( $scMeta['button_hover_bg_color'] ) ? $scMeta['button_hover_bg_color'] : null );
396
+ $button_active_bg_color = ( ! empty( $scMeta['button_active_bg_color'] ) ? $scMeta['button_active_bg_color'] : null );
397
+ $button_text_color = ( ! empty( $scMeta['button_text_color'] ) ? $scMeta['button_text_color'] : null );
398
+ $title_color = isset( $scMeta['title_color'] ) && ! empty( $scMeta['title_color'] ) ? $scMeta['title_color'] : null;
399
+ $title_hover_color = isset( $scMeta['title_hover_color'] ) && ! empty( $scMeta['title_hover_color'] ) ? $scMeta['title_hover_color'] : null;
400
+ $read_more_button_border_radius = isset( $scMeta['tpg_read_more_button_border_radius'] ) ? $scMeta['tpg_read_more_button_border_radius'] : '';
401
+
402
+ } else {
403
+
404
+ $primaryColor = ( ! empty( $scMeta['primary_color'][0] ) ? $scMeta['primary_color'][0] : null );
405
+ $button_bg_color = ( ! empty( $scMeta['button_bg_color'][0] ) ? $scMeta['button_bg_color'][0] : null );
406
+ $button_hover_bg_color = ( ! empty( $scMeta['button_hover_bg_color'][0] ) ? $scMeta['button_hover_bg_color'][0] : null );
407
+ $button_active_bg_color = ( ! empty( $scMeta['button_active_bg_color'][0] ) ? $scMeta['button_active_bg_color'][0] : null );
408
+ $button_text_color = ( ! empty( $scMeta['button_text_color'][0] ) ? $scMeta['button_text_color'][0] : null );
409
+ $title_color = isset( $scMeta['title_color'][0] ) && ! empty( $scMeta['title_color'][0] ) ? $scMeta['title_color'][0] : null;
410
+ $title_hover_color = isset( $scMeta['title_hover_color'][0] ) && ! empty( $scMeta['title_hover_color'][0] ) ? $scMeta['title_hover_color'][0] : null;
411
+ $read_more_button_border_radius = isset( $scMeta['tpg_read_more_button_border_radius'][0] ) ? $scMeta['tpg_read_more_button_border_radius'][0] : '';
412
+
413
+ }
414
+ $css = null;
415
+ $css .= "<style type='text/css' media='all'>";
416
+ // Variable
417
+ if ( $primaryColor ) {
418
+ $css .= "#{$layout} .rt-detail i,
419
  #{$layout} .rt-detail .post-meta-user a,
420
  #{$layout} .rt-detail .post-meta-category a{";
421
+ $css .= "color:" . $primaryColor . ";";
422
+ $css .= "}";
423
+ $css .= "body .rt-tpg-container .rt-tpg-isotope-buttons .selected{";
424
+ $css .= "background-color:" . $primaryColor . ";";
425
+ $css .= "}";
426
+ }
427
+ if ( $button_bg_color ) {
428
+ $css .= "#{$layout} .pagination li a,
429
  #{$layout} .rt-tpg-isotope-buttons button,
430
  #{$layout} .rt-detail .read-more a{";
431
+ $css .= "background-color:" . $button_bg_color . ";";
432
+ $css .= "}";
433
+ }
434
+ if ( $button_hover_bg_color ) {
435
+ $css .= "#{$layout} .pagination li a:hover,
436
  #{$layout} .rt-tpg-isotope-buttons button:hover,
437
  #{$layout} .rt-detail .read-more a:hover{";
438
+ $css .= "background-color:" . $button_hover_bg_color . ";";
439
+ $css .= "}";
440
+ }
441
+ if ( $button_active_bg_color ) {
442
+ $css .= "#{$layout} .pagination li.active span,
443
  #{$layout} .rt-tpg-isotope-buttons button.selected{";
444
+ $css .= "background-color:" . $button_active_bg_color . ";";
445
+ $css .= "}";
446
+ }
447
+ if ( $button_text_color ) {
448
+ $css .= "#{$layout} .pagination li a,
449
  #{$layout} .rt-tpg-isotope-buttons button,
450
  #{$layout} .rt-detail .read-more a{";
451
+ $css .= "color:" . $button_text_color . ";";
452
+ $css .= "}";
453
+ }
454
+ if ( $title_color ) {
455
+ $css .= "#{$layout} .rt-detail h2.entry-title a,
456
  #{$layout} .rt-detail h3.entry-title a,
457
  #{$layout} .rt-detail h4.entry-title a{";
458
+ $css .= "color:" . $title_color . ";";
459
+ $css .= "}";
460
+ }
461
+ if ( $title_hover_color ) {
462
+ $css .= "#{$layout} .rt-detail h2.entry-title a:hover,
463
  #{$layout} .rt-detail h3.entry-title a:hover,
464
  #{$layout} .rt-detail h4.entry-title a:hover{";
465
+ $css .= "color:" . $title_hover_color . ";";
466
+ $css .= "}";
467
+ }
468
+
469
+ // Read more button Position
470
+ if ( isset( $read_more_button_border_radius ) || trim( $read_more_button_border_radius ) !== '' ) {
471
+ $css .= "#{$layout} .read-more a{";
472
+ $css .= "border-radius:" . $read_more_button_border_radius . "px;";
473
+ $css .= "}";
474
+ }
475
+
476
+ $css .= "</style>";
477
+
478
+ return $css;
479
+ }
480
+ }
481
  endif;
the-post-grid.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://demo.radiustheme.com/wordpress/plugins/the-post-grid/
5
  * Description: Fast & Easy way to display WordPress post in Grid, List & Isotope view ( filter by category, tag, author..) without a single line of coding.
6
  * Author: RadiusTheme
7
- * Version: 2.3.1
8
  * Text Domain: the-post-grid
9
  * Domain Path: /languages
10
  * Author URI: https://radiustheme.com/
4
  * Plugin URI: http://demo.radiustheme.com/wordpress/plugins/the-post-grid/
5
  * Description: Fast & Easy way to display WordPress post in Grid, List & Isotope view ( filter by category, tag, author..) without a single line of coding.
6
  * Author: RadiusTheme
7
+ * Version: 2.3.2
8
  * Text Domain: the-post-grid
9
  * Domain Path: /languages
10
  * Author URI: https://radiustheme.com/