Related Posts Thumbnails Plugin for WordPress - Version 2.0.1

Version Description

  • 2022-04-18 =
  • BugFix: The image wasn't displaying with {custom field name} setting.
  • Enhancement: Code refactoring.
Download this release

Release Info

Developer hiddenpearls
Plugin Icon 128x128 Related Posts Thumbnails Plugin for WordPress
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0.0 to 2.0.1

inc/rpt-deactivate-form.php DELETED
@@ -1,256 +0,0 @@
1
- <style>
2
- .wp-rpt-hidden{
3
- overflow: hidden;
4
- }
5
- .wp-rpt-popup-overlay .wp-rpt-internal-message{
6
- margin: 3px 0 3px 22px;
7
- display: none;
8
- }
9
- .wp-rpt-reason-input{
10
- margin: 3px 0 3px 22px;
11
- display: none;
12
- }
13
- .wp-rpt-reason-input input[type="text"]{
14
- width: 100%;
15
- display: block;
16
- }
17
- .wp-rpt-popup-overlay{
18
- background: rgba(0,0,0, .8);
19
- position: fixed;
20
- top:0;
21
- left: 0;
22
- height: 100%;
23
- width: 100%;
24
- z-index: 1000;
25
- overflow: auto;
26
- visibility: hidden;
27
- opacity: 0;
28
- transition: opacity 0.3s ease-in-out:
29
- }
30
- .wp-rpt-popup-overlay.wp-rpt-active{
31
- opacity: 1;
32
- visibility: visible;
33
- }
34
- .wp-rpt-serveypanel{
35
- width: 600px;
36
- background: #fff;
37
- margin: 65px auto 0;
38
- }
39
- .wp-rpt-popup-header{
40
- background: #f1f1f1;
41
- padding: 20px;
42
- border-bottom: 1px solid #ccc;
43
- }
44
- .wp-rpt-popup-header h2{
45
- margin: 0;
46
- }
47
- .wp-rpt-popup-body{
48
- padding: 10px 20px;
49
- }
50
- .wp-rpt-popup-footer{
51
- background: #f9f3f3;
52
- padding: 10px 20px;
53
- border-top: 1px solid #ccc;
54
- }
55
- .wp-rpt-popup-footer:after{
56
- content:"";
57
- display: table;
58
- clear: both;
59
- }
60
- .action-btns{
61
- float: right;
62
- }
63
- .wp-rpt-anonymous{
64
- display: none;
65
- }
66
- .attention, .error-message {
67
- color: red;
68
- font-weight: 600;
69
- display: none;
70
- }
71
- .wp-rpt-spinner{
72
- display: none;
73
- }
74
- .wp-rpt-spinner img{
75
- margin-top: 3px;
76
- }
77
-
78
- </style>
79
-
80
- <div class="wp-rpt-popup-overlay">
81
- <div class="wp-rpt-serveypanel">
82
- <form action="#" method="post" id="wp-rpt-deactivate-form">
83
- <div class="wp-rpt-popup-header">
84
- <h2><?php _e( 'Quick feedback about Related Posts Thumbnails', 'related-posts-thumbnails' ); ?></h2>
85
- </div>
86
- <div class="wp-rpt-popup-body">
87
- <h3><?php _e( 'If you have a moment, please let us know why you are deactivating:', 'related-posts-thumbnails' ); ?></h3>
88
- <ul id="wp-rpt-reason-list">
89
- <li class="wp-rpt-reason" data-input-type="" data-input-placeholder="">
90
- <label>
91
- <span>
92
- <input type="radio" name="wp-rpt-selected-reason" value="1">
93
- </span>
94
- <span><?php _e( 'I only needed the plugin for a short period', 'related-posts-thumbnails' ); ?></span>
95
- </label>
96
- <div class="wp-rpt-internal-message"></div>
97
- </li>
98
- <li class="wp-rpt-reason has-input" data-input-type="textfield">
99
- <label>
100
- <span>
101
- <input type="radio" name="wp-rpt-selected-reason" value="2">
102
- </span>
103
- <span><?php _e( 'I found a better plugin', 'related-posts-thumbnails' ); ?></span>
104
- </label>
105
- <div class="wp-rpt-internal-message"></div>
106
- <div class="wp-rpt-reason-input"><span class="message error-message"><?php _e( 'Kindly tell us the name of plugin', 'related-posts-thumbnails' ); ?></span><input type="text" name="better_plugin" placeholder="What's the plugin's name?"></div>
107
- </li>
108
- <li class="wp-rpt-reason" data-input-type="" data-input-placeholder="">
109
- <label>
110
- <span>
111
- <input type="radio" name="wp-rpt-selected-reason" value="3">
112
- </span>
113
- <span><?php _e( 'The plugin broke my site', 'related-posts-thumbnails' ); ?></span>
114
- </label>
115
- <div class="wp-rpt-internal-message"></div>
116
- </li>
117
- <li class="wp-rpt-reason" data-input-type="" data-input-placeholder="">
118
- <label>
119
- <span>
120
- <input type="radio" name="wp-rpt-selected-reason" value="4">
121
- </span>
122
- <span><?php _e( 'The plugin suddenly stopped working', 'related-posts-thumbnails' ); ?></span>
123
- </label>
124
- <div class="wp-rpt-internal-message"></div>
125
- </li>
126
- <li class="wp-rpt-reason" data-input-type="" data-input-placeholder="">
127
- <label>
128
- <span>
129
- <input type="radio" name="wp-rpt-selected-reason" value="5">
130
- </span>
131
- <span><?php _e( 'I no longer need the plugin', 'related-posts-thumbnails' ); ?></span>
132
- </label>
133
- <div class="wp-rpt-internal-message"></div>
134
- </li>
135
- <li class="wp-rpt-reason" data-input-type="" data-input-placeholder="">
136
- <label>
137
- <span>
138
- <input type="radio" name="wp-rpt-selected-reason" value="6">
139
- </span>
140
- <span><?php _e( "It's a temporary deactivation. I'm just debugging an issue.", 'related-posts-thumbnails' ); ?></span>
141
- </label>
142
- <div class="wp-rpt-internal-message"></div>
143
- </li>
144
- <li class="wp-rpt-reason has-input" data-input-type="textfield" >
145
- <label>
146
- <span>
147
- <input type="radio" name="wp-rpt-selected-reason" value="7">
148
- </span>
149
- <span><?php _e( 'Other', 'related-posts-thumbnails' ); ?></span>
150
- </label>
151
- <div class="wp-rpt-internal-message"></div>
152
- <div class="wp-rpt-reason-input"><span class="message error-message "><?php _e( 'Kindly tell us the reason so we can improve.', 'related-posts-thumbnails' ); ?></span><input type="text" name="other_reason" placeholder="Would you like to share what's other reason ?"></div>
153
- </li>
154
- </ul>
155
- </div>
156
- <div class="wp-rpt-popup-footer">
157
- <label class="wp-rpt-anonymous"><input type="checkbox" /><?php _e( 'Anonymous feedback', 'related-posts-thumbnails' ); ?></label>
158
- <input type="button" class="button button-secondary button-skip wp-rpt-popup-skip-feedback" value="Skip &amp; Deactivate" >
159
- <div class="action-btns">
160
- <span class="wp-rpt-spinner"><img src="<?php echo admin_url( '/images/spinner.gif' ); ?>" alt=""></span>
161
- <input type="submit" class="button button-secondary button-deactivate wp-rpt-popup-allow-deactivate" value="Submit &amp; Deactivate" disabled="disabled">
162
- <a href="#" class="button button-primary wp-rpt-popup-button-close"><?php _e( 'Cancel', 'related-posts-thumbnails' ); ?></a>
163
-
164
- </div>
165
- </div>
166
- </form>
167
- </div>
168
- </div>
169
-
170
-
171
- <script>
172
- (function( $ ) {
173
-
174
- $(function() {
175
-
176
- var pluginSlug = 'related-posts-thumbnails';
177
- // Code to fire when the DOM is ready.
178
-
179
- $(document).on('click', 'tr[data-slug="' + pluginSlug + '"] .deactivate', function(e){
180
- e.preventDefault();
181
-
182
- $('.wp-rpt-popup-overlay').addClass('wp-rpt-active');
183
- $('body').addClass('wp-rpt-hidden');
184
- });
185
- $(document).on('click', '.wp-rpt-popup-button-close', function () {
186
- close_popup();
187
- });
188
- $(document).on('click', ".wp-rpt-serveypanel,tr[data-slug='" + pluginSlug + "'] .deactivate",function(e){
189
- e.stopPropagation();
190
- });
191
-
192
- $(document).click(function(){
193
- close_popup();
194
- });
195
- $('.wp-rpt-reason label').on('click', function(){
196
- if($(this).find('input[type="radio"]').is(':checked')){
197
- //$('.wp-rpt-anonymous').show();
198
- $(this).next().next('.wp-rpt-reason-input').show().end().end().parent().siblings().find('.wp-rpt-reason-input').hide();
199
- }
200
- });
201
- $('input[type="radio"][name="wp-rpt-selected-reason"]').on('click', function(event) {
202
- $(".wp-rpt-popup-allow-deactivate").removeAttr('disabled');
203
- });
204
- $(document).on('submit', '#wp-rpt-deactivate-form', function(event) {
205
- event.preventDefault();
206
-
207
- var _reason = $(this).find('input[type="radio"][name="wp-rpt-selected-reason"]:checked').val();
208
- var _reason_details = '';
209
- if ( _reason == 2 ) {
210
- _reason_details = $(this).find("input[type='text'][name='better_plugin']").val();
211
- } else if ( _reason == 7 ) {
212
- _reason_details = $(this).find("input[type='text'][name='other_reason']").val();
213
- }
214
-
215
- if ( ( _reason == 7 || _reason == 2 ) && _reason_details == '' ) {
216
- $('.message.error-message').show();
217
- return ;
218
- }
219
-
220
- $.ajax({
221
- url: ajaxurl,
222
- type: 'POST',
223
- data: {
224
- action : 'rpt_deactivate',
225
- reason : _reason,
226
- reason_detail : _reason_details,
227
- },
228
- beforeSend: function(){
229
- $(".wp-rpt-spinner").show();
230
- $(".wp-rpt-popup-allow-deactivate").attr("disabled", "disabled");
231
- }
232
- })
233
- .done(function() {
234
- $(".wp-rpt-spinner").hide();
235
- // $(".wp-rpt-popup-allow-deactivate").removeAttr("disabled");
236
- window.location.href = $("tr[data-slug='"+ pluginSlug +"'] .deactivate a").attr('href');
237
- });
238
-
239
- });
240
-
241
- $('.wp-rpt-popup-skip-feedback').on('click', function(e){
242
- window.location.href = $("tr[data-slug='"+ pluginSlug +"'] .deactivate a").attr('href');
243
- })
244
-
245
- function close_popup() {
246
- $('.wp-rpt-popup-overlay').removeClass('wp-rpt-active');
247
- $('#wp-rpt-deactivate-form').trigger("reset");
248
- $(".wp-rpt-popup-allow-deactivate").attr('disabled', 'disabled');
249
- $(".wp-rpt-reason-input").hide();
250
- $('body').removeClass('wp-rpt-hidden');
251
- $('.message.error-message').hide();
252
- }
253
- });
254
-
255
- })( jQuery ); // This invokes the function above and allows us to use '$' in place of 'jQuery' in our code.
256
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/rpt-settings.php CHANGED
@@ -686,6 +686,7 @@ if ( $this->wp_version >= 3 ) {
686
 
687
  <td>
688
  <input type="text" name="relpoststh_customfield" value="<?php echo get_option( 'relpoststh_customfield', $this->custom_field ); ?>" size="50"/>
 
689
  </td>
690
  </tr>
691
 
686
 
687
  <td>
688
  <input type="text" name="relpoststh_customfield" value="<?php echo get_option( 'relpoststh_customfield', $this->custom_field ); ?>" size="50"/>
689
+ <?php _e( 'ACF/Custom field name for thumbnails that should have image field type.', 'related-posts-thumbnails' ); ?>
690
  </td>
691
  </tr>
692
 
lib/wpb-sdk/includes/wpb-sdk-logger.php ADDED
@@ -0,0 +1,395 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Logger responsible for gathering user logs and send.
4
+ * In effort to provide better customer experience.
5
+ *
6
+ * @package RPT_WPB_SDK
7
+ * @since 2.0.1
8
+ */
9
+
10
+ namespace RPT_WPB_SDK;
11
+
12
+ /**
13
+ * Class responsible for logs data collection.
14
+ */
15
+ class Logger {
16
+
17
+ /**
18
+ * Contains products data for logging.
19
+ *
20
+ * @var array
21
+ */
22
+ private static $product_data;
23
+
24
+ /**
25
+ * Contains products that have a Pro version.
26
+ *
27
+ * @var array
28
+ */
29
+ private static $has_pro_version = array( 'wp-analytify', 'loginpress', 'simple-social-buttons' );
30
+
31
+ /**
32
+ * Class constructor.
33
+ *
34
+ * @param array $product_data variable.
35
+ * @return void
36
+ */
37
+ public function __construct( $product_data ) {
38
+
39
+ self::$product_data = $product_data;
40
+ $this->hooks();
41
+ }
42
+
43
+ /**
44
+ * Call wp hooks to initialize logger actions.
45
+ *
46
+ * @return void
47
+ */
48
+ public function hooks() {
49
+
50
+ add_action( 'init', array( $this, 'set_logs_schedule' ) );
51
+ add_action( 'wpb_logger_cron_' . self::$product_data['slug'], array( $this, 'log_plugin' ) );
52
+ add_action( 'admin_footer', array( $this, 'deactivation_model' ) );
53
+ add_action( 'wp_ajax_wpb_sdk_' . self::$product_data['slug'] . '_deactivation', array( $this, 'ajax_deactivation' ) );
54
+
55
+ register_activation_hook( self::$product_data['path'], array( __CLASS__, 'log_activation' ) );
56
+ register_deactivation_hook( self::$product_data['path'], array( __CLASS__, 'product_deactivation' ) );
57
+ register_uninstall_hook( self::$product_data['path'], array( __CLASS__, 'log_uninstallation' ) );
58
+ }
59
+
60
+ /**
61
+ * Set logs schedule.
62
+ */
63
+ public function set_logs_schedule() {
64
+
65
+ if ( ! wp_next_scheduled( 'wpb_logger_cron_' . self::$product_data['slug'] ) ) {
66
+ wp_schedule_event( time(), 'weekly', 'wpb_logger_cron_' . self::$product_data['slug'] );
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Add deactivation model.
72
+ *
73
+ * @return void
74
+ */
75
+ public function deactivation_model() {
76
+
77
+ if ( function_exists( 'get_current_screen' ) ) {
78
+
79
+ $screen = get_current_screen();
80
+
81
+ if ( 'plugins.php' === $screen->parent_file ) {
82
+
83
+ $product_slug = self::$product_data['slug'];
84
+ $product_name = self::$product_data['name'];
85
+
86
+ $has_pro_version = ( in_array( $product_slug, self::$has_pro_version ) ) ? true : false;
87
+
88
+ include dirname( __DIR__ ) . '/views/wpb-sdk-deactivate-form.php';
89
+ }
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Ajax callback when product deactivated.
95
+ * Shows deactivation model.
96
+ *
97
+ * @return void
98
+ */
99
+ public function ajax_deactivation() {
100
+
101
+ if ( isset( $_POST['nonce'] ) && empty( $_POST['nonce'] ) ) {
102
+ return;
103
+ }
104
+
105
+ $nonce = sanitize_text_field( wp_unslash( $_POST['nonce'] ) );
106
+ $verify_nonce = wp_verify_nonce( $nonce, 'deactivate-plugin_' . plugin_basename( self::$product_data['path'] ) );
107
+
108
+ if ( ! $verify_nonce ) {
109
+ return;
110
+ }
111
+
112
+ $this->log_deactivation();
113
+
114
+ wp_die();
115
+ }
116
+
117
+ /**
118
+ * Send plugin logs on cron.
119
+ *
120
+ * @return $wpb_sdk_track SDK track record.
121
+ */
122
+ public function log_plugin() {
123
+
124
+ /**
125
+ * Adding a activation check to prevent 2 hits from getting send on activation
126
+ */
127
+ if ( get_transient( 'wpb_logger_cron_' . self::$product_data['slug'] ) ) {
128
+ return;
129
+ }
130
+
131
+ $logs_data = array_merge(
132
+ self::get_logs_data(),
133
+ array(
134
+ 'explicit_logs' => array(
135
+ 'action' => 'weekly',
136
+ ),
137
+ )
138
+ );
139
+
140
+ $wpb_sdk_track = new Track( $logs_data );
141
+ $wpb_sdk_track->send();
142
+ }
143
+
144
+ /**
145
+ * Send logs when plugin is activated.
146
+ */
147
+ public static function log_activation() {
148
+
149
+ /**
150
+ * Setting a transient to add a check in the weekly track report
151
+ */
152
+ set_transient( 'wpb_logger_cron_' . self::$product_data['slug'], true, 60 );
153
+
154
+ $logs_data = array_merge(
155
+ self::get_logs_data(),
156
+ array(
157
+ 'explicit_logs' => array(
158
+ 'action' => 'activate',
159
+ ),
160
+ )
161
+ );
162
+
163
+ $wpb_sdk_track = new Track( $logs_data );
164
+ $wpb_sdk_track->send();
165
+ }
166
+
167
+ /**
168
+ * Send logs when plugin is deactivated.
169
+ */
170
+ public function log_deactivation() {
171
+ $reason = isset( $_POST['reason'] ) ? $_POST['reason'] : '';
172
+ $reason_detail = isset( $_POST['reason_detail'] ) ? $_POST['reason_detail'] : '';
173
+
174
+ $logs_data = array_merge(
175
+ self::get_logs_data(),
176
+ array(
177
+ 'explicit_logs' => array(
178
+ 'action' => 'deactivate',
179
+ 'reason' => sanitize_text_field( wp_unslash( $reason ) ),
180
+ 'reason_detail' => sanitize_text_field( wp_unslash( $reason_detail ) ),
181
+ ),
182
+ )
183
+ );
184
+
185
+ $wpb_sdk_track = new Track( $logs_data );
186
+ $wpb_sdk_track->send();
187
+ }
188
+
189
+ /**
190
+ * Remove cron schedules on deactivation.
191
+ */
192
+ public static function product_deactivation() {
193
+
194
+ wp_clear_scheduled_hook( 'wpb_logger_cron_' . self::$product_data['slug'] );
195
+ }
196
+
197
+ /**
198
+ * Send logs when plugin is uninstalled.
199
+ */
200
+ public static function log_uninstallation() {
201
+
202
+ $logs_data = array_merge(
203
+ self::get_logs_data(),
204
+ array(
205
+ 'explicit_logs' => array(
206
+ 'action' => 'uninstall',
207
+ ),
208
+ )
209
+ );
210
+
211
+ $wpb_sdk_track = new Track( $logs_data );
212
+ $wpb_sdk_track->send();
213
+ }
214
+
215
+ /**
216
+ * Collect all data for logging.
217
+ *
218
+ * @return array
219
+ */
220
+ private static function get_logs_data() {
221
+
222
+ global $wpdb;
223
+
224
+ $data = array();
225
+ $theme_data = wp_get_theme();
226
+ $curl_version = '';
227
+ $external_http_blocked = '';
228
+ $users_count = '';
229
+
230
+ $admin_users = get_users( array( 'role' => 'Administrator' ) );
231
+ $admin = isset( $admin_users[0] ) ? $admin_users[0]->data : '';
232
+ $admin_meta = ! empty( $admin ) ? get_user_meta( $admin->ID ) : '';
233
+
234
+ if ( ! function_exists( 'get_plugins' ) ) {
235
+ include ABSPATH . '/wp-admin/includes/plugin.php';
236
+ }
237
+
238
+ if ( function_exists( 'count_users' ) ) {
239
+ $users_count = count_users();
240
+ $users_count = isset( $users_count['total_users'] ) ? intval( $users_count['total_users'] ) : '';
241
+ }
242
+
243
+ // Check external http request blocked.
244
+ if ( ! defined( 'WP_HTTP_BLOCK_EXTERNAL' ) || ! WP_HTTP_BLOCK_EXTERNAL ) {
245
+ $external_http_blocked = 'none';
246
+ } else {
247
+ $external_http_blocked = defined( 'WP_ACCESSIBLE_HOSTS' ) ? 'partially (accessible hosts: ' . esc_html( WP_ACCESSIBLE_HOSTS ) . ')' : 'all';
248
+ }
249
+
250
+ // Curl version.
251
+ if ( function_exists( 'curl_init' ) ) {
252
+ $curl = curl_version();
253
+ $curl_version = '(' . $curl['version'] . ' ' . $curl['ssl_version'] . ')';
254
+ }
255
+
256
+ $data['site_info'] = array(
257
+ 'site_url' => site_url(),
258
+ 'home_url' => home_url(),
259
+ );
260
+ $data['site_meta_info'] = array(
261
+ 'is_multisite' => is_multisite(),
262
+ 'multisites' => self::get_multisites(),
263
+ 'php_version' => phpversion(),
264
+ 'wp_version' => get_bloginfo( 'version' ),
265
+ 'server' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '',
266
+ 'timezoneoffset' => date('P'),
267
+ 'ext/mysqli' => ! empty( $wpdb->use_mysqli ) ? true : false,
268
+ 'mysql_version' => empty( $wpdb->use_mysqli ) ? mysql_get_server_info() : mysqli_get_server_info( $wpdb->dbh ),
269
+ 'memory_limit' => ( defined( WP_MEMORY_LIMIT ) ? WP_MEMORY_LIMIT : ini_get( 'memory_limit' ) ) ? ini_get( 'memory_limit' ) : '',
270
+ 'external_http_blocked' => $external_http_blocked,
271
+ 'wp_locale' => get_locale(),
272
+ 'db_charset' => defined( 'DB_CHARSET' ) ? DB_CHARSET : '',
273
+ 'debug_mode' => defined( 'WP_DEBUG' ) && WP_DEBUG ? true : false,
274
+ 'wp_max_upload' => size_format( wp_max_upload_size() ),
275
+ 'php_time_limit' => function_exists( 'ini_get' ) ? ini_get( 'max_execution_time' ) : '',
276
+ 'php_error_log' => function_exists( 'ini_get' ) ? ini_get( 'error_log' ) : '',
277
+ 'fsockopen' => function_exists( 'fsockopen' ) ? true : false,
278
+ 'open_ssl' => defined( 'OPENSSL_VERSION_TEXT' ) ? OPENSSL_VERSION_TEXT : '',
279
+ 'curl' => $curl_version,
280
+ 'ip' => self::get_ip(),
281
+ 'user_count' => $users_count,
282
+ 'admin_email' => sanitize_email( get_bloginfo( 'admin_email' ) ),
283
+ 'theme_name' => sanitize_text_field( $theme_data->Name ),
284
+ 'theme_version' => sanitize_text_field( $theme_data->Version ),
285
+ );
286
+ $data['site_plugins_info'] = self::get_plugins();
287
+ $data['user_info'] = array(
288
+ 'user_email' => ! empty( $admin ) ? sanitize_email( $admin->user_email ) : '',
289
+ 'user_nickname' => ! empty( $admin ) ? sanitize_text_field( $admin->user_nicename ) : '',
290
+ 'user_firstname' => isset( $admin_meta['first_name'][0] ) ? sanitize_text_field( $admin_meta['first_name'][0] ) : '',
291
+ 'user_lastname' => isset( $admin_meta['last_name'][0] ) ? sanitize_text_field( $admin_meta['last_name'][0] ) : ''
292
+ );
293
+ $data['product_info'] = self::get_product_data();
294
+ $data['sdk_version'] = '1.0.0';
295
+
296
+ return $data;
297
+ }
298
+
299
+ /**
300
+ * Collect multisite data.
301
+ *
302
+ * @return array
303
+ */
304
+ private static function get_multisites() {
305
+
306
+ if ( ! is_multisite() ) {
307
+ return false;
308
+ }
309
+
310
+ $sites_info = array();
311
+ $sites = get_sites();
312
+
313
+ foreach ( $sites as $site ) {
314
+ $sites_info[ $site->blog_id ] = array(
315
+ 'name' => get_blog_details( $site->blog_id )->blogname,
316
+ 'domain' => $site->domain,
317
+ 'path' => $site->path,
318
+ );
319
+ }
320
+
321
+ return $sites_info;
322
+ }
323
+
324
+ /**
325
+ * Collect plugins information: Active/Inactive plugins.
326
+ *
327
+ * @return string
328
+ */
329
+ private static function get_plugins() {
330
+
331
+ $plugins = array_keys( get_plugins() );
332
+ $active_plugins = get_option( 'active_plugins', array() );
333
+
334
+ foreach ( $plugins as $key => $plugin ) {
335
+ if ( in_array( $plugin, $active_plugins ) ) {
336
+ // Remove active plugins from list.
337
+ unset( $plugins[ $key ] );
338
+ }
339
+ }
340
+
341
+ return wp_json_encode(
342
+ array(
343
+ 'active' => $active_plugins,
344
+ 'inactive' => $plugins,
345
+ )
346
+ );
347
+ }
348
+
349
+ /**
350
+ * Get user IP information.
351
+ *
352
+ * @return string|null
353
+ */
354
+ private static function get_ip() {
355
+
356
+ $fields = array(
357
+ 'HTTP_CF_CONNECTING_IP',
358
+ 'HTTP_CLIENT_IP',
359
+ 'HTTP_X_FORWARDED_FOR',
360
+ 'HTTP_X_FORWARDED',
361
+ 'HTTP_FORWARDED_FOR',
362
+ 'HTTP_FORWARDED',
363
+ 'REMOTE_ADDR',
364
+ );
365
+
366
+ foreach ( $fields as $ip_field ) {
367
+ if ( ! empty( $_SERVER[ $ip_field ] ) ) {
368
+ return $_SERVER[ $ip_field ];
369
+ }
370
+ }
371
+
372
+ return null;
373
+ }
374
+
375
+ /**
376
+ * Get product data.
377
+ *
378
+ * @return array
379
+ */
380
+ private static function get_product_data() {
381
+
382
+ $product_data = self::$product_data;
383
+ $product_settings = array();
384
+
385
+ // Pull settings data from db.
386
+ foreach ( $product_data['settings'] as $option_name => $default_value ) {
387
+ $get_option = get_option( $option_name );
388
+ $product_settings[ $option_name ] = ! empty( $get_option ) ? $get_option : $default_value;
389
+ }
390
+
391
+ $product_data['settings'] = wp_json_encode( $product_settings );
392
+
393
+ return $product_data;
394
+ }
395
+ }
lib/wpb-sdk/includes/wpb-sdk-track.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Send tracking data (logs) to WPB server.
4
+ *
5
+ * @package RPT_WPB_SDK
6
+ * @since 2.0.1
7
+ */
8
+
9
+ namespace RPT_WPB_SDK;
10
+
11
+ /**
12
+ * Class responsible for sending logs data.
13
+ */
14
+ class Track {
15
+
16
+ /**
17
+ * The logger data to be send.
18
+ *
19
+ * @var array
20
+ */
21
+ private $payload = array();
22
+
23
+ /**
24
+ * Logger tracking endpoint.
25
+ *
26
+ * @var string
27
+ */
28
+ private $tracking_endpoint = 'https://app.telemetry.wpbrigade.com/api/logger';
29
+
30
+ /**
31
+ * Class constructor.
32
+ *
33
+ * @param Obj $payload variable.
34
+ *
35
+ * @return void
36
+ */
37
+ public function __construct( $payload ) {
38
+
39
+ $this->payload = $payload;
40
+ }
41
+
42
+ /**
43
+ * Send the logs to the api endpoint.
44
+ *
45
+ * @return object
46
+ */
47
+ public function send() {
48
+
49
+ wp_remote_post(
50
+ $this->tracking_endpoint,
51
+ array(
52
+ 'method' => 'POST',
53
+ 'body' => $this->payload,
54
+ 'timeout' => 5,
55
+ 'headers' => array(),
56
+ )
57
+ );
58
+ }
59
+ }
60
+
lib/wpb-sdk/init.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WPBrigade SDK
4
+ *
5
+ * @package WPB_SDK
6
+ * @since 2.0.1
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ require_once dirname( __FILE__ ) . '/includes/wpb-sdk-track.php';
14
+ require_once dirname( __FILE__ ) . '/includes/wpb-sdk-logger.php';
lib/wpb-sdk/views/wpb-sdk-deactivate-form.php ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ .wpb-sdk_deactivation-frm-hidden {
3
+ overflow: hidden;
4
+ }
5
+
6
+ .wpb-sdk_deactivation-frm-popup-overlay .wpb-sdk_deactivation-frm-internal-message {
7
+ margin: 3px 0 3px 22px;
8
+ display: none;
9
+ }
10
+
11
+ .wpb-sdk_deactivation-frm-reason-input {
12
+ margin: 3px 0 3px 22px;
13
+ display: none;
14
+ }
15
+
16
+ .wpb-sdk_deactivation-frm-pro-message {
17
+ margin: 3px 0 3px 22px;
18
+ display: none;
19
+ color: #ed1515;
20
+ font-size: 14px;
21
+ font-weight: 600;
22
+ }
23
+
24
+ .wpb-sdk_deactivation-frm-reason-input input[type="text"] {
25
+ width: 100%;
26
+ display: block;
27
+ }
28
+
29
+ .wpb-sdk_deactivation-frm-popup-overlay {
30
+ background: rgba(0, 0, 0, .8);
31
+ position: fixed;
32
+ top: 0;
33
+ left: 0;
34
+ height: 100%;
35
+ width: 100%;
36
+ z-index: 1000;
37
+ overflow: auto;
38
+ visibility: hidden;
39
+ opacity: 0;
40
+ transition: opacity 0.3s ease-in-out:
41
+ }
42
+
43
+ .wpb-sdk_deactivation-frm-popup-overlay.wpb-sdk_deactivation-frm-active {
44
+ opacity: 1;
45
+ visibility: visible;
46
+ }
47
+
48
+ .wpb-sdk_deactivation-frm-serveypanel {
49
+ width: 600px;
50
+ background: #fff;
51
+ margin: 65px auto 0;
52
+ }
53
+
54
+ .wpb-sdk_deactivation-frm-popup-header {
55
+ background: #f1f1f1;
56
+ padding: 20px;
57
+ border-bottom: 1px solid #ccc;
58
+ }
59
+
60
+ .wpb-sdk_deactivation-frm-popup-header h2 {
61
+ margin: 0;
62
+ }
63
+
64
+ .wpb-sdk_deactivation-frm-popup-body {
65
+ padding: 10px 20px;
66
+ }
67
+
68
+ .wpb-sdk_deactivation-frm-popup-footer {
69
+ background: #f9f3f3;
70
+ padding: 10px 20px;
71
+ border-top: 1px solid #ccc;
72
+ }
73
+
74
+ .wpb-sdk_deactivation-frm-popup-footer:after {
75
+ content: "";
76
+ display: table;
77
+ clear: both;
78
+ }
79
+
80
+ .action-btns {
81
+ float: right;
82
+ }
83
+
84
+ .wpb-sdk_deactivation-frm-anonymous {
85
+ display: none;
86
+ }
87
+
88
+ .attention,
89
+ .error-message {
90
+ color: red;
91
+ font-weight: 600;
92
+ display: none;
93
+ }
94
+
95
+ .wpb-sdk_deactivation-frm-spinner {
96
+ display: none;
97
+ }
98
+
99
+ .wpb-sdk_deactivation-frm-spinner img {
100
+ margin-top: 3px;
101
+ }
102
+ </style>
103
+ <div class="<?php echo $product_slug ?>-deactivate-wrapper">
104
+ <div class="wpb-sdk_deactivation-frm-popup-overlay">
105
+ <div class="wpb-sdk_deactivation-frm-serveypanel">
106
+ <form action="#" method="post" class="wpb-sdk_deactivation-frm-deactivate-form">
107
+
108
+ <div class="wpb-sdk_deactivation-frm-popup-header">
109
+ <h2><?php _e( 'Quick feedback about ' . $product_name, 'ucmm-wpbrigade' ); ?></h2>
110
+ </div>
111
+
112
+ <div class="wpb-sdk_deactivation-frm-popup-body">
113
+
114
+ <h3><?php _e( 'If you have a moment, please let us know why you are deactivating:', 'ucmm-wpbrigade' ); ?></h3>
115
+
116
+ <ul id="wpb-sdk_deactivation-frm-reason-list">
117
+ <?php if ( $has_pro_version ) { ?>
118
+ <li class="wpb-sdk_deactivation-frm-reason wpb-sdk_deactivation-frm-reason-pro" data-input-type="" data-input-placeholder="">
119
+ <label>
120
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="pro">
121
+ </span><span><?php _e( 'I upgraded to ' . $product_name . ' Pro', 'ucmm-wpbrigade' ); ?></span>
122
+ </label>
123
+ <div class="wpb-sdk_deactivation-frm-pro-message">
124
+ <?php _e( 'No need to deactivate this ' . $product_name . ' Core version. Pro version works as an add-on with Core version.', 'ucmm-wpbrigade' ); ?>
125
+ </div>
126
+ </li>
127
+ <?php } ?>
128
+ <li class="wpb-sdk_deactivation-frm-reason" data-input-type="" data-input-placeholder="">
129
+ <label>
130
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="1"></span>
131
+ <span><?php _e( 'I only needed the plugin for a short period', 'ucmm-wpbrigade' ); ?></span>
132
+ </label>
133
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
134
+ </li>
135
+ <li class="wpb-sdk_deactivation-frm-reason has-input" data-input-type="textfield">
136
+ <label>
137
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="2"></span>
138
+ <span><?php _e( 'I found a better plugin', 'ucmm-wpbrigade' ); ?></span>
139
+ </label>
140
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
141
+ <div class="wpb-sdk_deactivation-frm-reason-input">
142
+ <span class="message error-message"><?php _e( 'Kindly tell us the name of plugin', 'ucmm-wpbrigade' ); ?></span>
143
+ <input type="text" name="better_plugin" placeholder="<?php _e( "What's the plugin's name?", 'ucmm-wpbrigade' ); ?>">
144
+ </div>
145
+ </li>
146
+ <li class="wpb-sdk_deactivation-frm-reason" data-input-type="" data-input-placeholder="">
147
+ <label>
148
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="3"></span>
149
+ <span><?php _e( 'The plugin broke my site', 'ucmm-wpbrigade' ); ?></span>
150
+ </label>
151
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
152
+ </li>
153
+ <li class="wpb-sdk_deactivation-frm-reason" data-input-type="" data-input-placeholder="">
154
+ <label>
155
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="4"></span>
156
+ <span><?php _e( 'The plugin suddenly stopped working', 'ucmm-wpbrigade' ); ?></span>
157
+ </label>
158
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
159
+ </li>
160
+ <li class="wpb-sdk_deactivation-frm-reason" data-input-type="" data-input-placeholder="">
161
+ <label>
162
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="5"></span>
163
+ <span><?php _e( 'I no longer need the plugin', 'ucmm-wpbrigade' ); ?></span>
164
+ </label>
165
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
166
+ </li>
167
+ <li class="wpb-sdk_deactivation-frm-reason" data-input-type="" data-input-placeholder="">
168
+ <label>
169
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="6"></span>
170
+ <span><?php _e( "It's a temporary deactivation. I'm just debugging an issue.", 'ucmm-wpbrigade' ); ?></span>
171
+ </label>
172
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
173
+ </li>
174
+ <li class="wpb-sdk_deactivation-frm-reason has-input" data-input-type="textfield">
175
+ <label>
176
+ <span><input type="radio" name="wpb-sdk_deactivation-frm-selected-reason" value="7"></span>
177
+ <span><?php _e( 'Other', 'ucmm-wpbrigade' ); ?></span>
178
+ </label>
179
+ <div class="wpb-sdk_deactivation-frm-internal-message"></div>
180
+ <div class="wpb-sdk_deactivation-frm-reason-input"><span class="message error-message "><?php _e( 'Kindly tell us the reason so we can improve.', 'ucmm-wpbrigade' ); ?></span>
181
+ <input type="text" name="other_reason" placeholder="<?php _e( "Would you like to share what's other reason ?", 'ucmm-wpbrigade' ); ?>">
182
+ </div>
183
+ </li>
184
+ </ul>
185
+ </div>
186
+
187
+ <div class="wpb-sdk_deactivation-frm-popup-footer">
188
+ <label class="wpb-sdk_deactivation-frm-anonymous">
189
+ <input type="checkbox" />
190
+ <?php _e( 'Anonymous feedback', 'ucmm-wpbrigade' ); ?>
191
+ </label>
192
+ <input type="button" class="button button-secondary button-skip wpb-sdk_deactivation-frm-popup-skip-feedback" value="Skip &amp; Deactivate">
193
+ <div class="action-btns">
194
+ <span class="wpb-sdk_deactivation-frm-spinner"><img src="<?php echo admin_url( '/images/spinner.gif' ); ?>" alt=""></span>
195
+ <input type="submit" class="button button-secondary button-deactivate wpb-sdk_deactivation-frm-popup-allow-deactivate" value="Submit &amp; Deactivate" disabled="disabled">
196
+ <a href="#" class="button button-primary wpb-sdk_deactivation-frm-popup-button-close">
197
+ <?php _e( 'Cancel', 'ucmm-wpbrigade' ); ?>
198
+ </a>
199
+ </div>
200
+ </div>
201
+
202
+ </form>
203
+ </div>
204
+ </div>
205
+ </div>
206
+ <script>
207
+ document.addEventListener("DOMContentLoaded", function(event) {
208
+ (function($) {
209
+ $(function() {
210
+
211
+ var pluginSlug = "<?php echo $product_slug; ?>";
212
+ var pluginName = "<?php echo $product_name; ?>";
213
+
214
+ var loggerDeactiveNonce;
215
+
216
+ $(document).on('click', 'tr[data-slug="' + pluginSlug + '"] .deactivate', function(e) {
217
+ e.preventDefault();
218
+ loggerDeactiveNonce = $(this).find('a').attr('href').split("wpnonce=")[1];
219
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-overlay').addClass('wpb-sdk_deactivation-frm-active');
220
+ $('body').addClass('wpb-sdk_deactivation-frm-hidden');
221
+ });
222
+
223
+ $(document).on('click', '.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-button-close', function() {
224
+ close_popup();
225
+ });
226
+
227
+ $(document).on('click', ".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-serveypanel,tr[data-slug='" + pluginSlug + "'] .deactivate", function(e) {
228
+ e.stopPropagation();
229
+ });
230
+
231
+ $(document).on('click', function() {
232
+ close_popup();
233
+ });
234
+
235
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-reason label').on('click', function() {
236
+ if($(this).find('input[type="radio"]').is(':checked')) {
237
+ //$('.wpb-sdk_deactivation-frm-anonymous').show();
238
+ $(this).next().next('.wpb-sdk_deactivation-frm-reason-input').show().end().end().parent().siblings().find('.wpb-sdk_deactivation-frm-reason-input').hide();
239
+ }
240
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-pro-message').hide();
241
+ });
242
+
243
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-reason-pro label').on('click', function() {
244
+ if($(this).find('input[type="radio"]').is(':checked')) {
245
+ $(this).next('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-pro-message').show().end().end().parent().siblings().find('.wpb-sdk_deactivation-frm-reason-input').hide();
246
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-allow-deactivate').attr('disabled', 'disabled');
247
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-skip-feedback').attr('disabled', 'disabled');
248
+ }
249
+ });
250
+
251
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper input[type="radio"][name="wpb-sdk_deactivation-frm-selected-reason"]').on('click', function(event) {
252
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-allow-deactivate").removeAttr('disabled');
253
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-skip-feedback").removeAttr('disabled');
254
+ });
255
+
256
+ $(document).on('submit', '.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-deactivate-form', function(event) {
257
+ event.preventDefault();
258
+ var reason = $(this).find('input[type="radio"][name="wpb-sdk_deactivation-frm-selected-reason"]:checked').val();
259
+ var reasonDetails = '';
260
+ if(reason == '2') {
261
+ reasonDetails = $(this).find("input[type='text'][name='better_plugin']").val();
262
+ } else if(reason == '7') {
263
+ reasonDetails = $(this).find("input[type='text'][name='other_reason']").val();
264
+ }
265
+ if((reason == '7' || reason == '2') && reasonDetails == '') {
266
+ $('.message.error-message').show();
267
+ return;
268
+ }
269
+
270
+ let returnURL = $("tr[data-slug='" + pluginSlug + "'] .deactivate a").attr('href');
271
+
272
+ send_log(
273
+ 'wpb_sdk_' + pluginSlug + '_deactivation',
274
+ reason,
275
+ reasonDetails,
276
+ loggerDeactiveNonce,
277
+ returnURL
278
+ );
279
+
280
+ });
281
+
282
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-skip-feedback').on('click', function(e) {
283
+ send_log(
284
+ 'wpb_sdk_' + pluginSlug + '_deactivation',
285
+ 9,
286
+ '',
287
+ loggerDeactiveNonce,
288
+ $("tr[data-slug='" + pluginSlug + "'] .deactivate a").attr('href')
289
+ );
290
+ });
291
+
292
+ function close_popup() {
293
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-overlay').removeClass('wpb-sdk_deactivation-frm-active');
294
+ $('.<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-deactivate-form').trigger("reset");
295
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-allow-deactivate").attr('disabled', 'disabled');
296
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-reason-input").hide();
297
+ $('body').removeClass('wpb-sdk_deactivation-frm-hidden');
298
+ $('.message.error-message').hide();
299
+ }
300
+
301
+ function send_log( _action, _reason, _reasonDetails, _nonce, returnURL ) {
302
+ $.ajax({
303
+ url: ajaxurl,
304
+ type: 'POST',
305
+ data: {
306
+ action: _action,
307
+ reason: _reason,
308
+ reason_detail: _reasonDetails,
309
+ nonce: _nonce
310
+ },
311
+ beforeSend: function() {
312
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-spinner").show();
313
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-allow-deactivate").attr("disabled", "disabled");
314
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-skip-feedback").attr("disabled", "disabled");
315
+ }
316
+ }).done(function(res) {
317
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-spinner").hide();
318
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-allow-deactivate").removeAttr("disabled");
319
+ $(".<?php echo $product_slug; ?>-deactivate-wrapper .wpb-sdk_deactivation-frm-popup-skip-feedback").removeAttr("disabled");
320
+ window.location.href = returnURL;
321
+ });
322
+ }
323
+
324
+ });
325
+ })(jQuery);
326
+ });
327
+ </script>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://wpbrigade.com/
4
  Tags: easy related posts, Related Posts thumbnails, Free Related Posts, related posts, similar related posts
5
  Requires at least: 3.6
6
  Tested up to: 5.9
7
- Stable tag: 2.0.0
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -76,6 +76,10 @@ If there are no images of the specified size in the post, or file does not exist
76
 
77
  == Changelog ==
78
 
 
 
 
 
79
  = 2.0.0 - 2022-03-22 =
80
  * New Feature: Introducing date feature with 7 type of date format.
81
  * Enhancement: Added a filter `rpt_custom_relationship` to get posts from multiple custom post types with same term slug.
4
  Tags: easy related posts, Related Posts thumbnails, Free Related Posts, related posts, similar related posts
5
  Requires at least: 3.6
6
  Tested up to: 5.9
7
+ Stable tag: 2.0.1
8
  License: GPLv3 or later
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
76
 
77
  == Changelog ==
78
 
79
+ = 2.0.1 - 2022-04-18 =
80
+ * BugFix: The image wasn't displaying with {custom field name} setting.
81
+ * Enhancement: Code refactoring.
82
+
83
  = 2.0.0 - 2022-03-22 =
84
  * New Feature: Introducing date feature with 7 type of date format.
85
  * Enhancement: Added a filter `rpt_custom_relationship` to get posts from multiple custom post types with same term slug.
related-posts-thumbnails.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WordPress Related Posts Thumbnails
4
  * Plugin URI: https://wpbrigade.com/wordpress/plugins/related-posts/?utm_source=related-posts-lite&utm_medium=plugin-uri&utm_campaign=pro-upgrade-rp
5
  * Description: Showing related posts thumbnails under the posts.
6
- * Version: 2.0.0
7
  * Author: WPBrigade
8
  * Author URI: https://WPBrigade.com/?utm_source=related-posts-lite&utm_medium=author-link&utm_campaign=pro-upgrade-rp
9
  */
@@ -53,7 +53,7 @@ class RelatedPostsThumbnails {
53
  public $post_types = array( 'post' );
54
  public $custom_taxonomies = array();
55
  protected $wp_kses_rp_args = array( 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'strong' => array() );
56
-
57
  /**
58
  * Function Constructor
59
  */
@@ -64,6 +64,55 @@ class RelatedPostsThumbnails {
64
  load_plugin_textdomain( 'related-posts-thumbnails', false, basename( dirname( __FILE__ ) ) . '/locale' );
65
  $this->default_image = esc_url( plugins_url( 'img/default.png', __FILE__ ) );
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
68
 
69
  // Compatibility for old default image path.
@@ -89,9 +138,6 @@ class RelatedPostsThumbnails {
89
 
90
  $this->wp_version = get_bloginfo( 'version' );
91
 
92
- add_action( 'admin_footer', array( $this, 'add_deactive_modal' ) );
93
- add_action( 'wp_ajax_rpt_deactivate', array( $this, 'rpt_deactivate' ) );
94
-
95
  add_action( 'admin_init', array( $this, 'review_notice' ) );
96
  add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts' ) );
97
 
@@ -211,73 +257,6 @@ class RelatedPostsThumbnails {
211
  define( 'RELATED_POSTS_THUMBNAILS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
212
  }
213
 
214
- /**
215
- * Show the popup modal on plugin deactivate
216
- *
217
- * @since 1.6.2
218
- */
219
- function add_deactive_modal() {
220
- global $pagenow;
221
-
222
- if ( 'plugins.php' !== $pagenow ) {
223
- return;
224
- }
225
-
226
- include RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . 'inc/rpt-deactivate-form.php';
227
- }
228
-
229
-
230
- /**
231
- * Send the deactivate user response to api.
232
- *
233
- * @since 1.6.2
234
- */
235
- function rpt_deactivate() {
236
- $email = get_option( 'admin_email' );
237
- $_reason = sanitize_text_field( wp_unslash( $_POST[ 'reason' ] ) );
238
- $reason_detail = sanitize_text_field( wp_unslash( $_POST[ 'reason_detail' ] ) );
239
- $reason = '';
240
-
241
- if ( $_reason == '1' ) {
242
- $reason = 'I only needed the plugin for a short period';
243
- } elseif ( $_reason == '2' ) {
244
- $reason = 'I found a better plugin';
245
- } elseif ( $_reason == '3' ) {
246
- $reason = 'The plugin broke my site';
247
- } elseif ( $_reason == '4' ) {
248
- $reason = 'The plugin suddenly stopped working';
249
- } elseif ( $_reason == '5' ) {
250
- $reason = 'I no longer need the plugin';
251
- } elseif ( $_reason == '6' ) {
252
- $reason = 'It\'s a temporary deactivation. I\'m just debugging an issue.';
253
- } elseif ( $_reason == '7' ) {
254
- $reason = 'Other';
255
- }
256
- $fields = array(
257
- 'email' => $email,
258
- 'website' => get_site_url(),
259
- 'action' => 'Deactivate',
260
- 'reason' => $reason,
261
- 'reason_detail' => $reason_detail,
262
- 'blog_language' => get_bloginfo( 'language' ),
263
- 'wordpress_version' => get_bloginfo( 'version' ),
264
- 'php_version' => PHP_VERSION,
265
- 'plugin_version' => RELATED_POSTS_THUMBNAILS_VERSION,
266
- 'plugin_name' => 'Related Post Thumbnails'
267
- );
268
-
269
- $response = wp_remote_post( RELATED_POSTS_THUMBNAILS_FEEDBACK_SERVER, array(
270
- 'method' => 'POST',
271
- 'timeout' => 5,
272
- 'httpversion' => '1.0',
273
- 'blocking' => false,
274
- 'headers' => array(),
275
- 'body' => $fields
276
- ) );
277
-
278
- wp_die();
279
- }
280
-
281
  /**
282
  * Check either to show notice or not.
283
  *
@@ -771,7 +750,6 @@ class RelatedPostsThumbnails {
771
  if ( $thsource == 'custom-field' ) {
772
  $custom_field = get_option( 'relpoststh_customfield', $this->custom_field );
773
  $custom_field_meta = get_post_meta( $post->ID, $custom_field, true );
774
-
775
  if ( empty( $custom_field ) ) {
776
  $debug .= 'No custom field specifield, using default thumbnail image;';
777
  $url = $this->default_image;
@@ -783,7 +761,7 @@ class RelatedPostsThumbnails {
783
  $url = $this->default_image;
784
  } else {
785
  $debug .= 'Using custom field;';
786
- $url = $custom_field_meta;
787
  $theme_resize_url = get_option( 'relpoststh_theme_resize_url', '' );
788
 
789
  if ( strpos( $url, '/wp-content' ) !== false ) {
@@ -1219,21 +1197,40 @@ class RelatedPostsThumbnails {
1219
 
1220
  <?php
1221
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222
  }
1223
 
1224
- //End Class
1225
  /**
1226
- *
1227
- * Create the Object of Related Posts thumbnails.
 
 
1228
  */
1229
- add_action( 'init', 'related_posts_thumbnails' );
1230
-
1231
- function related_posts_thumbnails() {
1232
- define( 'RELATED_POSTS_THUMBNAILS_URI', plugin_dir_url( __FILE__ ) );
 
1233
 
 
1234
  global $related_posts_thumbnails;
1235
- $related_posts_thumbnails = new RelatedPostsThumbnails();
1236
- }
1237
 
1238
  // Include Widget File.
1239
  include_once plugin_dir_path( __FILE__ ) . 'inc/rpt-widget.php';
3
  * Plugin Name: WordPress Related Posts Thumbnails
4
  * Plugin URI: https://wpbrigade.com/wordpress/plugins/related-posts/?utm_source=related-posts-lite&utm_medium=plugin-uri&utm_campaign=pro-upgrade-rp
5
  * Description: Showing related posts thumbnails under the posts.
6
+ * Version: 2.0.1
7
  * Author: WPBrigade
8
  * Author URI: https://WPBrigade.com/?utm_source=related-posts-lite&utm_medium=author-link&utm_campaign=pro-upgrade-rp
9
  */
53
  public $post_types = array( 'post' );
54
  public $custom_taxonomies = array();
55
  protected $wp_kses_rp_args = array( 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), 'strong' => array() );
56
+ protected static $instance = null;
57
  /**
58
  * Function Constructor
59
  */
64
  load_plugin_textdomain( 'related-posts-thumbnails', false, basename( dirname( __FILE__ ) ) . '/locale' );
65
  $this->default_image = esc_url( plugins_url( 'img/default.png', __FILE__ ) );
66
 
67
+ include_once RELATED_POSTS_THUMBNAILS_PLUGIN_DIR . '/lib/wpb-sdk/init.php';
68
+ new RPT_WPB_SDK\Logger( array(
69
+ 'name' => 'Related Posts Thumbnails Plugin for WordPress',
70
+ 'slug' => 'related-posts-thumbnails',
71
+ 'path' => __FILE__,
72
+ 'version' => RELATED_POSTS_THUMBNAILS_VERSION,
73
+ 'license' => '',
74
+ 'settings' => array(
75
+ 'relpoststh_default_image' => false,
76
+ 'rpt_active_time' => false,
77
+ 'relpoststh_single_only' => false,
78
+ 'relpoststh_mobile_view' => false,
79
+ 'relpoststh_post_types' => false,
80
+ 'relpoststh_onlywiththumbs' => false,
81
+ 'relpoststh_output_style' => false,
82
+ 'relpoststh_cleanhtml' => false,
83
+ 'relpoststh_auto' => false,
84
+ 'relpoststh_top_text' => false,
85
+ 'relpoststh_number' => false,
86
+ 'relpoststh_relation' => false,
87
+ 'relpoststh_default_image' => false,
88
+ 'relpoststh_poststhname' => false,
89
+ 'relpoststh_background' => false,
90
+ 'relpoststh_hoverbackground' => false,
91
+ 'relpoststh_bordercolor' => false,
92
+ 'relpoststh_fontcolor' => false,
93
+ 'relpoststh_fontsize' => false,
94
+ 'relpoststh_fontfamily' => false,
95
+ 'relpoststh_textlength' => false,
96
+ 'relpoststh_excerptlength' => false,
97
+ 'relpoststh_thsource' => false,
98
+ 'relpoststh_customfield' => false,
99
+ 'relpoststh_theme_resize_url' => false,
100
+ 'relpoststh_customwidth' => false,
101
+ 'relpoststh_customheight' => false,
102
+ 'relpoststh_textblockheight' => false,
103
+ 'relpoststh_customwidth' => false,
104
+ 'rpt_post_sort' => false,
105
+ 'relpoststh_categories' => false,
106
+ 'relpoststh_categoriesall' => false,
107
+ 'relpoststh_show_categoriesall' => false,
108
+ 'relpoststh_show_categories' => false,
109
+ 'relpoststh_devmode' => false,
110
+ 'relpoststh_startdate' => false,
111
+ 'relpoststh_custom_taxonomies' => false,
112
+
113
+ ),
114
+ ) );
115
+
116
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
117
 
118
  // Compatibility for old default image path.
138
 
139
  $this->wp_version = get_bloginfo( 'version' );
140
 
 
 
 
141
  add_action( 'admin_init', array( $this, 'review_notice' ) );
142
  add_action( 'wp_enqueue_scripts', array( $this, 'front_scripts' ) );
143
 
257
  define( 'RELATED_POSTS_THUMBNAILS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
258
  }
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  /**
261
  * Check either to show notice or not.
262
  *
750
  if ( $thsource == 'custom-field' ) {
751
  $custom_field = get_option( 'relpoststh_customfield', $this->custom_field );
752
  $custom_field_meta = get_post_meta( $post->ID, $custom_field, true );
 
753
  if ( empty( $custom_field ) ) {
754
  $debug .= 'No custom field specifield, using default thumbnail image;';
755
  $url = $this->default_image;
761
  $url = $this->default_image;
762
  } else {
763
  $debug .= 'Using custom field;';
764
+ $url = isset( wp_get_attachment_image_src( $custom_field_meta )[0] ) ? wp_get_attachment_image_src( $custom_field_meta )[0] : $this->default_image;
765
  $theme_resize_url = get_option( 'relpoststh_theme_resize_url', '' );
766
 
767
  if ( strpos( $url, '/wp-content' ) !== false ) {
1197
 
1198
  <?php
1199
  }
1200
+
1201
+ /**
1202
+ * Main Instance
1203
+ *
1204
+ * @since 2.0.1
1205
+ * @static
1206
+ * @see related_posts_thumbnails_loader()
1207
+ * @return Main instance
1208
+ */
1209
+ public static function instance() {
1210
+
1211
+ if ( is_null( self::$instance ) ) {
1212
+ self::$instance = new self();
1213
+ }
1214
+ return self::$instance;
1215
+ }
1216
  }
1217
 
 
1218
  /**
1219
+ * Returns the main instance of WP to prevent the need to use globals.
1220
+ *
1221
+ * @since 2.0.1
1222
+ * @return RelatedPostsThumbnails instance
1223
  */
1224
+ if ( ! function_exists('related_posts_thumbnails_loader') ) {
1225
+ function related_posts_thumbnails_loader() {
1226
+ return RelatedPostsThumbnails::instance();
1227
+ }
1228
+ }
1229
 
1230
+ // Call the function.
1231
  global $related_posts_thumbnails;
1232
+ $related_posts_thumbnails = related_posts_thumbnails_loader();
1233
+
1234
 
1235
  // Include Widget File.
1236
  include_once plugin_dir_path( __FILE__ ) . 'inc/rpt-widget.php';