Ultimate Posts Widget - Version 2.2.3

Version Description

  • Added try it out module
Download this release

Release Info

Developer iclyde
Plugin Icon wp plugin Ultimate Posts Widget
Version 2.2.3
Comparing to
See all releases

Code changes from version 2.2.2 to 2.2.3

modules/tryOutPlugins/tryOutPlugins.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * File for our cool review ask in the header
5
+ *
6
+ * @category Child Plugin
7
+ * @version v0.1.0
8
+ * @since v0.1.0
9
+ * @author iClyde <kontakt@iclyde.pl>
10
+ */
11
+
12
+ // Namespace
13
+ namespace Inisev\Subs;
14
+
15
+ // Disallow direct access
16
+ if (defined('ABSPATH')) {
17
+
18
+ /**
19
+ * Main class for handling the Review
20
+ */
21
+ if (!class_exists('Inisev\Subs\Inisev_Try_Out_Plugins')) {
22
+ class Inisev_Try_Out_Plugins {
23
+
24
+ function __construct($plugin_file, $plugin_dir, $plugin_name, $plugin_menu_page) {
25
+
26
+ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
27
+ add_action('wp_ajax_tifm_notice_actions', [&$this, 'noticeAjax']);
28
+ }
29
+
30
+ global $pagenow;
31
+ if (!($pagenow == 'plugin-install.php' || $pagenow == 'admin-ajax.php')) return;
32
+ if (!is_admin() || !current_user_can('install_plugins')) return;
33
+ if (get_option('_tifm_disable_feature_forever', false) != false) return;
34
+
35
+ $this->pluginDir = $plugin_dir;
36
+ $this->pluginFile = $plugin_file;
37
+ $this->pluginName = $plugin_name;
38
+ $this->pluginPageURL = admin_url($plugin_menu_page) . '&scrollToSection=testPlugins';
39
+
40
+ $this->showInformativeNotice();
41
+ $this->insertActionButton();
42
+
43
+ }
44
+
45
+ public function showInformativeNotice() {
46
+
47
+ add_action('in_admin_footer', [&$this, 'tryItOutScript']);
48
+
49
+ if (get_option('_tifm_hide_notice_forever', false) != false) return;
50
+
51
+ add_action('admin_notices', [&$this, 'informativeAdminNoticeHandler']);
52
+ add_action('admin_head', [&$this, 'noticeStyles']);
53
+ add_action('in_admin_footer', [&$this, 'noticeScripts']);
54
+
55
+ }
56
+
57
+ public function noticeStyles() {
58
+ ?>
59
+
60
+ <style media="screen">
61
+ #tifm_paragraph_notice {
62
+ display: flex;
63
+ flex-direction: row;
64
+ justify-content: space-between;
65
+ }
66
+
67
+ #tifm_paragraph_notice span {
68
+ line-height: 30px;
69
+ }
70
+
71
+ #tifm_paragraph_notice .tifm_darker_a {
72
+ color: #555;
73
+ }
74
+
75
+ #tifm_paragraph_notice .tifm_darker_a_muted {
76
+ color: #999;
77
+ }
78
+
79
+ #tifm_paragraph_notice .tifm_brought_url {
80
+ color: #00a32a;
81
+ text-decoration: none;
82
+ }
83
+
84
+ #tifm_paragraph_notice .tifm-grow-1 {
85
+ flex-grow: 1;
86
+ }
87
+
88
+ #tifm_paragraph_notice .tifm-grow-5 {
89
+ flex-grow: 5;
90
+ }
91
+
92
+ @media screen and (max-width: 1400px) {
93
+ #tifm_paragraph_notice {
94
+ flex-direction: column;
95
+ }
96
+ }
97
+ </style>
98
+
99
+ <?php
100
+ }
101
+
102
+ public function noticeScripts() {
103
+ ?>
104
+ <script type="text/javascript">
105
+ jQuery(document).ready(function($) {
106
+
107
+ $('#tifm_new_feature_notice').on('click', '.notice-dismiss', hideAndDismissNotice);
108
+
109
+ $('#tifm_new_feature_notice').on('click', '.tifm_darker_a', hideAndDismissNotice);
110
+
111
+ $('#tifm_new_feature_notice').on('click', '.tifm_darker_a_muted', disableFeatureAndDismiss);
112
+
113
+ let nonce = "<?php echo wp_create_nonce('tifm_notice_nonce') ?>";
114
+
115
+ function hideAndDismissNotice(e) {
116
+
117
+ let dismiss = false;
118
+ if (typeof e != 'string') {
119
+ e.preventDefault();
120
+ } else if (e = 'dismiss') {
121
+ dismiss = true;
122
+ }
123
+
124
+ $('#tifm_new_feature_notice').hide(300);
125
+ setTimeout(function () {
126
+ $('#tifm_new_feature_notice').remove();
127
+ }, 350);
128
+
129
+ let method = 'dismiss_notice';
130
+ if (dismiss == true) {
131
+ method = 'dismiss_notice_and_disable';
132
+ }
133
+
134
+ $.post(ajaxurl, { action: 'tifm_notice_actions', nonce: nonce, method: method }).done(function () {
135
+ if (method == 'dismiss_notice_and_disable') {
136
+ window.location.reload();
137
+ }
138
+ }).fail(function (e) {
139
+ alert('Error occurred, please refresh and try again.' + JSON.stringify(e));
140
+ });
141
+
142
+ }
143
+
144
+ function disableFeatureAndDismiss(e) {
145
+
146
+ e.preventDefault();
147
+ hideAndDismissNotice('dismiss');
148
+
149
+ }
150
+
151
+ });
152
+ </script>
153
+ <?php
154
+ }
155
+
156
+ public function tryItOutScript() {
157
+ ?>
158
+ <script type="text/javascript">
159
+ jQuery(document).ready(function($) {
160
+ function makeButton(slug) {
161
+
162
+ let a = document.createElement('A');
163
+ a.classList.add('button');
164
+ a.classList.add('button-primary');
165
+ a.classList.add('tifm-btn-iframe');
166
+ a.classList.add('right');
167
+ a.style.color = '#fff';
168
+ a.style.background = '#2d9418';
169
+ a.style.borderColor = '#2d9418';
170
+ a.style.boxShadow = 'none';
171
+ a.style.marginRight = '15px';
172
+ a.setAttribute('href', 'https://tastewp.com/plugins/' + slug);
173
+ a.setAttribute('target', '_blank');
174
+ a.innerText = 'Try it first';
175
+
176
+ return a;
177
+
178
+ }
179
+
180
+ const observer = new MutationObserver(function (mutations_list) {
181
+ mutations_list.forEach(function (mutation) {
182
+ mutation.addedNodes.forEach(function (added_node) {
183
+ if (added_node.id == 'TB_window') {
184
+ $('#TB_window #TB_iframeContent')[0].onload = function () {
185
+ let iframe = $('#TB_iframeContent').contents();
186
+ let footer = iframe.find('#plugin-information-footer');
187
+ let slug = footer.find('#plugin_install_from_iframe').data('slug');
188
+ let btn = makeButton(slug);
189
+ footer.append(btn);
190
+ }
191
+ }
192
+ });
193
+ });
194
+ });
195
+
196
+ observer.observe(document.querySelector('body'), { subtree: false, childList: true });
197
+ });
198
+ </script>
199
+ <?php
200
+ }
201
+
202
+ public function informativeAdminNoticeHandler() {
203
+
204
+ ?>
205
+
206
+ <div class="notice notice-success is-dismissible" id="tifm_new_feature_notice">
207
+ <p id="tifm_paragraph_notice">
208
+ <span class="tifm-grow-1">
209
+ <b>New: </b> Click on the&nbsp;
210
+ <a class="button" style="color:#2d9418;border-color:#2d9418;text-align:center;width:88px" href="#!">Try it first</a>
211
+ &nbsp;button to first test a plugin on a new WP instance.
212
+ </span>
213
+
214
+ <span class="tifm-grow-5">
215
+ <a class="tifm_darker_a" href="#">Got it, close this notice</a>
216
+ </span>
217
+
218
+ <span class="tifm-grow-1">
219
+ <a class="tifm_darker_a_muted" href="#">Disable this feature</a>
220
+ </span>
221
+
222
+ <span>
223
+ Brought to you by <a class="tifm_brought_url" href="<?php echo esc_html($this->pluginPageURL); ?>"><?php echo esc_html($this->pluginName); ?></a>
224
+ </span>
225
+ </p>
226
+ </div>
227
+
228
+ <?php
229
+
230
+ }
231
+
232
+ public function insertActionButton() {
233
+
234
+ add_filter('plugin_install_action_links', [&$this, 'actionButtonHandler'], 10, 2);
235
+
236
+ }
237
+
238
+ public static function noticeAjax() {
239
+
240
+ // Nonce verification
241
+ if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field($_POST['nonce']), 'tifm_notice_nonce')) {
242
+ wp_send_json_error();
243
+ return;
244
+ }
245
+
246
+ $method = '';
247
+ if (isset($_POST['method'])) {
248
+
249
+ $method = sanitize_text_field($_POST['method']);
250
+
251
+ }
252
+
253
+ if ($method == 'dismiss_notice') {
254
+
255
+ update_option('_tifm_hide_notice_forever', true);
256
+ wp_send_json_success();
257
+ exit;
258
+
259
+ } else if ($method == 'dismiss_notice_and_disable') {
260
+
261
+ update_option('_tifm_hide_notice_forever', true);
262
+ update_option('_tifm_disable_feature_forever', true);
263
+ update_option('_tifm_feature_enabled', 'disabled');
264
+ wp_send_json_success();
265
+ exit;
266
+
267
+ } else {
268
+
269
+ wp_send_json_error();
270
+ exit;
271
+
272
+ }
273
+
274
+ }
275
+
276
+ public function actionButtonHandler($links, $plugin) {
277
+
278
+ $url = 'https://tastewp.com/plugins/' . $plugin['slug'] . '/?anchor=wpsite';
279
+ $button = ['<a class="button" style="color:#2d9418;border-color:#2d9418;text-align:center;width:88px" target="_blank" href="' . $url . '">Try it first</a>'];
280
+ array_splice($links, 1, 0, $button);
281
+
282
+ return $links;
283
+
284
+ }
285
+
286
+ }
287
+ }
288
+
289
+ }
readme.txt CHANGED
@@ -6,7 +6,7 @@ License URI: http://opensource.org/licenses/MIT
6
  Tags: widget, recent posts, custom post types, sticky posts, featured image, post thumbnail, excerpts, category, custom fields, list pages, widget query, microformats, customizable widget, categories widget, tags widget, excerpt, widget templates, post author, post date, custom query, ultimate posts, comments, orderby, comment count
7
  Requires at least: 3.5
8
  Tested up to: 6.1
9
- Stable tag: 2.2.2
10
 
11
  The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
12
 
@@ -126,6 +126,9 @@ This plugin uses the [timthumb library](http://www.binarymoon.co.uk/projects/tim
126
  5. Order options tab
127
 
128
  == Changelog ==
 
 
 
129
  = 2.2.2 =
130
  * Tested up to WordPress 6.1-RC5
131
  * Adjusted carrousel module
@@ -308,10 +311,11 @@ This plugin uses the [timthumb library](http://www.binarymoon.co.uk/projects/tim
308
  * First release.
309
 
310
  == Upgrade Notice ==
311
- = 2.2.2 =
312
  * Tested up to WordPress 6.1-RC5
313
  * Adjusted carrousel module
314
  * Updated try it out URL in readme to properly setup demo site
 
315
 
316
  == Installation ==
317
 
6
  Tags: widget, recent posts, custom post types, sticky posts, featured image, post thumbnail, excerpts, category, custom fields, list pages, widget query, microformats, customizable widget, categories widget, tags widget, excerpt, widget templates, post author, post date, custom query, ultimate posts, comments, orderby, comment count
7
  Requires at least: 3.5
8
  Tested up to: 6.1
9
+ Stable tag: 2.2.3
10
 
11
  The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
12
 
126
  5. Order options tab
127
 
128
  == Changelog ==
129
+ = 2.2.3 =
130
+ * Added try it out module
131
+
132
  = 2.2.2 =
133
  * Tested up to WordPress 6.1-RC5
134
  * Adjusted carrousel module
311
  * First release.
312
 
313
  == Upgrade Notice ==
314
+ = 2.2.3 =
315
  * Tested up to WordPress 6.1-RC5
316
  * Adjusted carrousel module
317
  * Updated try it out URL in readme to properly setup demo site
318
+ * Added try it out module
319
 
320
  == Installation ==
321
 
ultimate-posts-widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Ultimate Posts Widget
4
  Plugin URI: http://wordpress.org/plugins/ultimate-posts-widget/
5
  Description: The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
6
- Version: 2.2.2
7
  Author: Clever Widgets
8
  Author URI: https://themecheck.info
9
  Text Domain: ultimate-posts-widget
@@ -823,3 +823,83 @@ function upw_hide_admin_notification_callback() {
823
  wp_send_json_success();
824
  die;
825
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  Plugin Name: Ultimate Posts Widget
4
  Plugin URI: http://wordpress.org/plugins/ultimate-posts-widget/
5
  Description: The ultimate widget for displaying posts, custom post types or sticky posts with an array of options.
6
+ Version: 2.2.3
7
  Author: Clever Widgets
8
  Author URI: https://themecheck.info
9
  Text Domain: ultimate-posts-widget
823
  wp_send_json_success();
824
  die;
825
  }
826
+
827
+ // Activation of tryOutPlugins module
828
+ add_action('plugins_loaded', function () {
829
+
830
+ if (!(class_exists('\Inisev\Subs\Inisev_Try_Out_Plugins') || class_exists('Inisev\Subs\Inisev_Try_Out_Plugins') || class_exists('Inisev_Try_Out_Plugins'))) {
831
+ require_once __DIR__ . '/modules/tryOutPlugins/tryOutPlugins.php';
832
+ $try_out_plugins = new \Inisev\Subs\Inisev_Try_Out_Plugins(__FILE__, __DIR__, 'Ultimate Posts Widget', 'plugins.php?s=Ultimate%20Posts%20Widget&plugin_status=all');
833
+ }
834
+
835
+ });
836
+
837
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), function ($links) {
838
+
839
+ $tifm_action = array('<a href="#!" id="upw_tifm_disable">' . __('Disable Plugin Test Feature', 'ultimate-posts-widget') . '</a>');
840
+ if (get_option('_tifm_feature_enabled') === 'disabled') {
841
+ $tifm_action = array('<a href="#!" id="upw_tifm_enable">' . __('Enable Plugin Test Feature', 'ultimate-posts-widget') . '</a>');
842
+ }
843
+
844
+ return array_merge($links, $tifm_action);
845
+
846
+ });
847
+
848
+ add_action('admin_footer', function () {
849
+
850
+ global $pagenow;
851
+ if ($pagenow === 'plugins.php') {
852
+ ?>
853
+ <script type="text/javascript">
854
+ jQuery('#upw_tifm_enable').on('click', (e) => {
855
+ e.preventDefault();
856
+ jQuery.post(ajaxurl, { action: 'tifm_save_decision', decision: 'true' }).done(() => {
857
+ window.location.reload();
858
+ }).fail(() => {
859
+ alert('There was an error and we could not update this option.');
860
+ });
861
+ });
862
+ jQuery('#upw_tifm_disable').on('click', (e) => {
863
+ e.preventDefault();
864
+ jQuery.post(ajaxurl, { action: 'tifm_save_decision', decision: 'false' }).done(() => {
865
+ window.location.reload();
866
+ }).fail(() => {
867
+ alert('There was an error and we could not update this option.');
868
+ });
869
+ });
870
+ </script>
871
+ <?php
872
+ }
873
+
874
+ });
875
+
876
+ if (!has_action('wp_ajax_tifm_save_decision')) {
877
+ add_action('wp_ajax_tifm_save_decision', function () {
878
+
879
+ if (isset($_POST['decision'])) {
880
+
881
+ if ($_POST['decision'] == 'true') {
882
+ update_option('_tifm_feature_enabled', 'enabled');
883
+ delete_option('_tifm_disable_feature_forever', true);
884
+ wp_send_json_success();
885
+ exit;
886
+ } else if ($_POST['decision'] == 'false') {
887
+ update_option('_tifm_feature_enabled', 'disabled');
888
+ update_option('_tifm_disable_feature_forever', true);
889
+ wp_send_json_success();
890
+ exit;
891
+ } else if ($_POST['decision'] == 'reset') {
892
+ delete_option('_tifm_feature_enabled');
893
+ delete_option('_tifm_hide_notice_forever');
894
+ delete_option('_tifm_disable_feature_forever');
895
+ wp_send_json_success();
896
+ exit;
897
+ }
898
+
899
+ wp_send_json_error();
900
+ exit;
901
+
902
+ }
903
+
904
+ });
905
+ }