Blog2Social: Social Media Auto Post & Scheduler - Version 6.9.13

Version Description

Optimize Social Media Metrics & Usability Optimization

Download this release

Release Info

Developer PR-Gateway
Plugin Icon 128x128 Blog2Social: Social Media Auto Post & Scheduler
Version 6.9.13
Comparing to
See all releases

Code changes from version 6.9.12 to 6.9.13

blog2social.php CHANGED
@@ -6,7 +6,7 @@
6
  * Author: Blog2Social, Adenion
7
  * Text Domain: blog2social
8
  * Domain Path: /languages
9
- * Version: 6.9.12
10
  * Author URI: https://www.blog2social.com
11
  * License: GPL2+
12
  */
6
  * Author: Blog2Social, Adenion
7
  * Text Domain: blog2social
8
  * Domain Path: /languages
9
+ * Version: 6.9.13
10
  * Author URI: https://www.blog2social.com
11
  * License: GPL2+
12
  */
includes/Ajax/Get.php CHANGED
@@ -133,7 +133,7 @@ class Ajax_Get {
133
  $optionPostFilters['searchSharedToNetwork'] = $b2sSortSharedToNetwork;
134
  $optionPostFilters['searchSharedAtDateStart'] = $b2sSortSharedAtDateStart;
135
  $optionPostFilters['searchSharedAtDateEnd'] = $b2sSortSharedAtDateEnd;
136
- $optionPostFilters = $options->_setOption('post_filters', $optionPostFilters);
137
 
138
  if (!empty($b2sType) && in_array($b2sType, array('all', 'sched', 'publish', 'notice', 'approve', 'draft', 'draft-post', 'favorites'))) {
139
  $postItem = new B2S_Post_Item($b2sType, $b2sSortPostTitle, $b2sSortPostAuthor, $b2sSortPostStatus, $b2sSortPostShareStatus, $b2sSortPostPublishDate, $b2sSortPostSchedDate, $b2sShowByDate, $b2sShowByNetwork, $b2sUserAuthId, $b2sPostBlogId, $b2sPagination, $b2sSortPostCat, $b2sSortPostType, $b2sUserLang, $b2sResultsPerPage, $b2sSortPostSharedBy, $b2sSortSharedToNetwork, $b2sSortSharedAtDateStart, $b2sSortSharedAtDateEnd);
133
  $optionPostFilters['searchSharedToNetwork'] = $b2sSortSharedToNetwork;
134
  $optionPostFilters['searchSharedAtDateStart'] = $b2sSortSharedAtDateStart;
135
  $optionPostFilters['searchSharedAtDateEnd'] = $b2sSortSharedAtDateEnd;
136
+ $options->_setOption('post_filters', $optionPostFilters);
137
 
138
  if (!empty($b2sType) && in_array($b2sType, array('all', 'sched', 'publish', 'notice', 'approve', 'draft', 'draft-post', 'favorites'))) {
139
  $postItem = new B2S_Post_Item($b2sType, $b2sSortPostTitle, $b2sSortPostAuthor, $b2sSortPostStatus, $b2sSortPostShareStatus, $b2sSortPostPublishDate, $b2sSortPostSchedDate, $b2sShowByDate, $b2sShowByNetwork, $b2sUserAuthId, $b2sPostBlogId, $b2sPagination, $b2sSortPostCat, $b2sSortPostType, $b2sUserLang, $b2sResultsPerPage, $b2sSortPostSharedBy, $b2sSortSharedToNetwork, $b2sSortSharedAtDateStart, $b2sSortSharedAtDateEnd);
includes/B2S/AutoPost.php CHANGED
@@ -280,7 +280,7 @@ class B2S_AutoPost {
280
  $hashTags = substr($hashTags, 0, $pos - 1);
281
  }
282
  }
283
- return (!empty($hashTags) ? (!empty($add) ? $add . $hashTags : $hashTags) : '');
284
  } else {
285
  return '';
286
  }
@@ -300,6 +300,15 @@ class B2S_AutoPost {
300
  }
301
  }
302
 
 
 
 
 
 
 
 
 
 
303
  if (isset($shareData['image_url']) && !empty($shareData['image_url']) && function_exists('wp_check_filetype') && defined('B2S_PLUGIN_NETWORK_NOT_ALLOW_GIF')) {
304
  $image_data = wp_check_filetype($shareData['image_url']);
305
  $not_allow_gif = json_decode(B2S_PLUGIN_NETWORK_NOT_ALLOW_GIF, true);
280
  $hashTags = substr($hashTags, 0, $pos - 1);
281
  }
282
  }
283
+ return (!empty($hashTags) ? (!empty($add) ? $add . trim($hashTags) : trim($hashTags)) : '');
284
  } else {
285
  return '';
286
  }
300
  }
301
  }
302
 
303
+ if ((int) $this->userVersion < 1 || !isset($this->optionPostFormat[$network_id][$network_type])) {
304
+ $tempOptionPostFormat = $this->default_template;
305
+ } else {
306
+ $tempOptionPostFormat = $this->optionPostFormat;
307
+ }
308
+ if(isset($tempOptionPostFormat[$network_id][$network_type]['addLink']) && $tempOptionPostFormat[$network_id][$network_type]['addLink'] == false) {
309
+ $shareData['url'] = '';
310
+ }
311
+
312
  if (isset($shareData['image_url']) && !empty($shareData['image_url']) && function_exists('wp_check_filetype') && defined('B2S_PLUGIN_NETWORK_NOT_ALLOW_GIF')) {
313
  $image_data = wp_check_filetype($shareData['image_url']);
314
  $not_allow_gif = json_decode(B2S_PLUGIN_NETWORK_NOT_ALLOW_GIF, true);
includes/B2S/Heartbeat.php CHANGED
@@ -14,7 +14,7 @@ class B2S_Heartbeat {
14
  public function init($response, $data) {
15
 
16
  if (isset($data['b2s_heartbeat']) && $data['b2s_heartbeat'] == 'b2s_listener') {
17
- if (isset($data['b2s_heartbeat_action']) && ($data['b2s_heartbeat_action'] == 'b2s_auto_posting' || $data['b2s_heartbeat_action'] == 'b2s_repost') ) {
18
  $this->postSchedToServer();
19
  } if (isset($data['b2s_heartbeat_action']) && $data['b2s_heartbeat_action'] == 'b2s_delete_sched_post') {
20
  $this->deleteUserSchedPost();
@@ -39,11 +39,11 @@ class B2S_Heartbeat {
39
  public function deleteSchedPost() {
40
  $this->deleteUserSchedPost();
41
  }
42
-
43
- public function updateSchedTimePost(){
44
  $this->updateUserSchedTimePost();
45
- }
46
-
47
  private function postSchedToServer() {
48
  global $wpdb;
49
  $sendData = array();
@@ -58,7 +58,7 @@ class B2S_Heartbeat {
58
  foreach ($postData as $k => $value) {
59
  $data = array('hook_action' => '0');
60
  $where = array('id' => $value['id']);
61
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
62
  $value['sched_data'] = ((isset($value['sched_data']) && !empty($value['sched_data'])) ? unserialize($value['sched_data']) : '');
63
  $value['image_url'] = ((isset($value['image_url']) && !empty($value['image_url'])) ? $value['image_url'] : '');
64
  $sendData[] = $value;
@@ -72,17 +72,17 @@ class B2S_Heartbeat {
72
  if (!isset($result->content) || !isset($result->content->{$value['id']})) {
73
  $data = array('hook_action' => '1');
74
  $where = array('id' => $value['id']);
75
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
76
  }
77
  if (isset($result->fail) && isset($result->fail->{$value['id']})) {
78
  $failData = $wpdb->get_results($wpdb->prepare("SELECT id,sched_details_id,network_details_id FROM {$wpdb->prefix}b2s_posts WHERE id= %d", $value['id']), ARRAY_A);
79
  if (isset($failData[0]) && (int) $failData[0]['id'] > 0) {
80
- $wpdb->delete($wpdb->prefix.'b2s_posts', array('id' => $failData[0]['id']), array('%d'));
81
  if (isset($failData[0]['sched_details_id']) && (int) $failData[0]['sched_details_id'] > 0) {
82
- $wpdb->delete($wpdb->prefix.'b2s_posts_sched_details', array('id' => $failData[0]['sched_details_id']), array('%d'));
83
  }
84
  if (isset($failData[0]['sched_details_id']) && (int) $failData[0]['network_details_id'] > 0) {
85
- $wpdb->delete($wpdb->prefix.'b2s_posts_network_details', array('id' => $failData[0]['network_details_id']), array('%d'));
86
  }
87
  }
88
  }
@@ -123,13 +123,13 @@ class B2S_Heartbeat {
123
  $post_id = $vdv2->post_id;
124
  $blog_user_id = $vdv2->blog_user_id;
125
  if ((int) $vdv2->id > 0) {
126
- $wpdb->delete($wpdb->prefix.'b2s_posts', array('id' => $vdv2->id), array('%d'));
127
  }
128
  if ((int) $vdv2->network_details_id > 0) {
129
- $wpdb->delete($wpdb->prefix.'b2s_posts_network_details', array('id' => $vdv2->network_details_id), array('%d'));
130
  }
131
  if ((int) $vdv2->sched_details_id > 0) {
132
- $wpdb->delete($wpdb->prefix.'b2s_posts_sched_details', array('id' => $vdv2->sched_details_id), array('%d'));
133
  }
134
  }
135
 
@@ -144,7 +144,7 @@ class B2S_Heartbeat {
144
  'network_auth_id' => 0,
145
  'network_display_name' => ''
146
  );
147
- $wpdb->insert($wpdb->prefix.'b2s_posts_network_details', $networkDetails, array('%d', '%d', '%d', '%s'));
148
  $networkDetailsId = $wpdb->insert_id;
149
  $timezone = get_option('gmt_offset');
150
  $b2sPost = array(
@@ -162,8 +162,8 @@ class B2S_Heartbeat {
162
  'hook_action' => '0',
163
  'hide' => '0',
164
  'v2_id' => '0');
165
- $wpdb->insert($wpdb->prefix.'b2s_posts', $b2sPost, array('%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d'));
166
-
167
  if (isset($vpv2['external_post_id']) && !empty($vpv2['external_post_id'])) {
168
  $insightData = array(
169
  'network_post_id' => $vpv2['external_post_id'],
@@ -174,10 +174,10 @@ class B2S_Heartbeat {
174
  'last_update' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -1 day')),
175
  'active' => 1
176
  );
177
- $wpdb->insert($wpdb->prefix.'b2s_posts_insights', $insightData, array('%s', '%s', '%d', '%d', '%d', '%s', '%d'));
178
  }
179
-
180
-
181
  B2S_Rating::trigger();
182
  }
183
  }
@@ -193,7 +193,7 @@ class B2S_Heartbeat {
193
  'publish_link' => sanitize_text_field($v->publish_link),
194
  'publish_error_code' => sanitize_text_field($v->publish_error_code),
195
  'hook_action' => 0);
196
- $wpdb->update($wpdb->prefix.'b2s_posts', $updateData, array('id' => $v->id, 'v2_id' => $v->v2_id), array('%s', '%s', '%s', '%s', '%s', '%d'), array('%d', '%d'));
197
  }
198
  }
199
  } else {
@@ -224,8 +224,8 @@ class B2S_Heartbeat {
224
  'publish_error_code' => (($shareApprove == 0) ? sanitize_text_field($v->publish_error_code) : ''),
225
  'post_for_approve' => (int) $shareApprove,
226
  'hook_action' => 0);
227
- $wpdb->update($wpdb->prefix.'b2s_posts', $updateData, array('id' => $v->id), array('%s', '%s', '%s', '%s', '%s', '%d', '%d'), array('%d'));
228
-
229
  if (isset($v->external_post_id) && !empty($v->external_post_id)) {
230
  $netowkDetailsData = $wpdb->get_results($wpdb->prepare("SELECT network_details_id, blog_user_id FROM {$wpdb->prefix}b2s_posts WHERE id= %d", $v->id), ARRAY_A);
231
  if (isset($netowkDetailsData[0]) && isset($netowkDetailsData[0]['network_details_id']) && (int) $netowkDetailsData[0]['network_details_id'] > 0 && isset($netowkDetailsData[0]['blog_user_id']) && (int) $netowkDetailsData[0]['blog_user_id'] > 0) {
@@ -238,7 +238,7 @@ class B2S_Heartbeat {
238
  'last_update' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -1 day')),
239
  'active' => 1
240
  );
241
- $wpdb->insert($wpdb->prefix.'b2s_posts_insights', $insightData, array('%s', '%s', '%d', '%d', '%d', '%s', '%d'));
242
  }
243
  }
244
  }
@@ -259,7 +259,7 @@ class B2S_Heartbeat {
259
  foreach ($sendData as $k => $value) {
260
  $data = array('hook_action' => '0');
261
  $where = array('id' => $value['id']);
262
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
263
  }
264
  $tempData = array('action' => 'updateUserSchedTimePost', 'data' => serialize($sendData));
265
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
@@ -269,7 +269,7 @@ class B2S_Heartbeat {
269
  if (!isset($result->content) || !isset($result->content->{$id})) {
270
  $data = array('hook_action' => '2');
271
  $where = array('id' => $id);
272
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
273
  }
274
  }
275
  }
@@ -286,7 +286,7 @@ class B2S_Heartbeat {
286
  foreach ($sendData as $k => $value) {
287
  $data = array('hook_action' => '0');
288
  $where = array('id' => $value['id']);
289
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
290
  }
291
  $tempData = array('action' => 'updateUserSchedPost', 'data' => serialize($sendData));
292
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
@@ -296,7 +296,7 @@ class B2S_Heartbeat {
296
  if (!isset($result->content) || !isset($result->content->{$id})) {
297
  $data = array('hook_action' => '5');
298
  $where = array('id' => $id);
299
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
300
  }
301
  }
302
  }
@@ -310,7 +310,7 @@ class B2S_Heartbeat {
310
  foreach ($sendData as $k => $value) {
311
  $data = array('hook_action' => '0');
312
  $where = array('id' => $value['id']);
313
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
314
  }
315
  $tempData = array('action' => 'deleteUserSchedPost', 'data' => serialize($sendData));
316
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
@@ -320,7 +320,7 @@ class B2S_Heartbeat {
320
  if (!isset($result->content) || !isset($result->content->{$id})) {
321
  $data = array('hook_action' => '3');
322
  $where = array('id' => $id);
323
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
324
  }
325
  }
326
  }
@@ -334,7 +334,7 @@ class B2S_Heartbeat {
334
  foreach ($sendData as $k => $value) {
335
  $data = array('hook_action' => '0');
336
  $where = array('id' => $value['id']);
337
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
338
  }
339
  $tempData = array('action' => 'deleteUserPublishPost', 'data' => serialize($sendData));
340
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
@@ -344,12 +344,12 @@ class B2S_Heartbeat {
344
  if (!isset($result->content) || !isset($result->content->{$id})) {
345
  $data = array('hook_action' => '4');
346
  $where = array('id' => $id);
347
- $wpdb->update($wpdb->prefix.'b2s_posts', $data, $where, array('%d'), array('%d'));
348
  }
349
  }
350
  }
351
  }
352
-
353
  private function updateInsights() {
354
  global $wpdb;
355
  $sql = "SELECT user.token, insights.network_post_id, insights.insight, network_details.network_auth_id, network_details.network_id, network_details.network_type FROM {$wpdb->prefix}b2s_posts_insights as insights LEFT JOIN {$wpdb->prefix}b2s_user AS user on insights.blog_user_id = user.blog_user_id LEFT JOIN {$wpdb->prefix}b2s_posts_network_details AS network_details on insights.b2s_posts_network_details_id = network_details.id WHERE insights.active = %d AND insights.last_update < %s LIMIT 50";
@@ -357,136 +357,138 @@ class B2S_Heartbeat {
357
  if (is_array($sendData) && !empty($sendData) && isset($sendData[0])) {
358
  $tempData = array('action' => 'updateInsights', 'data' => $sendData);
359
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90), true);
360
- if(isset($result['data']) && !empty($result['data'])) {
361
  foreach ($result['data'] as $k => $value) {
362
  $insights = $value;
363
- if($insights !== false && is_array($insights) && !empty($insights) && isset($insights['extern_post_id']) && !empty($insights['extern_post_id']) && isset($insights['insights']) && !empty($insights['insights'])) {
364
- $sql = "SELECT insights.insight, insights.b2s_posts_network_details_id, networkDetails.network_auth_id, networkDetails.id as b2sNetworkDetailsId FROM {$wpdb->prefix}b2s_posts_insights as insights LEFT JOIN {$wpdb->prefix}b2s_posts_network_details as networkDetails ON insights.b2s_posts_network_details_id = networkDetails.id WHERE insights.network_post_id = %s";
365
- $externPostData = $wpdb->get_results($wpdb->prepare($sql, $insights['extern_post_id']), ARRAY_A);
366
- if(strlen($externPostData[0]['insight']) > $insights) {
367
- continue;//neue Insights Werte weniger als bereits existierende
368
- }
369
- $wpdb->update($wpdb->prefix.'b2s_posts_insights', array('insight' => json_encode($insights), 'last_update' => date('Y-m-d H:i:s')), array('network_post_id' => $insights['extern_post_id']), array('%s', '%s'), array('%s'));
370
-
371
- if (is_array($externPostData) && !empty($externPostData) && isset($externPostData[0])) {
372
- //vergleichen
373
- $currentInsights = json_decode($externPostData[0]['insight'], true);
374
- if(isset($currentInsights['insights']['data']['likes']) && !empty($currentInsights['insights']['data']['likes'])) {
375
- if(isset($insights['insights']['data']['likes']) && !empty($insights['insights']['data']['likes'])) {
376
- foreach($insights['insights']['data']['likes'] as $newDate => $newCount) {
377
- $dataForDateExist = false;
378
- $dataForDateIsSame = false;
379
- $newTotalData = array(
380
- 'likes' => $newCount,
381
- 'comments' => ((isset($insights['insights']['data']['comments'][$newDate])) ? (int) $insights['insights']['data']['comments'][$newDate] : 0),
382
- 'reshares' => ((isset($insights['insights']['data']['reshares'][$newDate])) ? (int) $insights['insights']['data']['reshares'][$newDate] : 0),
383
- 'impressions' => ((isset($insights['insights']['data']['impressions'][$newDate])) ? (int) $insights['insights']['data']['impressions'][$newDate] : 0)
384
- );
385
- foreach($currentInsights['insights']['data']['likes'] as $currDate => $currCount) {
386
- if(substr($newDate, 0, 10) == substr($currDate, 0, 10)) {
387
- $dataForDateExist = true;
388
- if($newCount == $currCount) {
389
- $dataForDateIsSame = true;
 
 
390
  }
391
  }
392
- }
393
-
394
- if(!$dataForDateExist || ($dataForDateExist && !$dataForDateIsSame)) {
395
- $sql = "SELECT insight FROM {$wpdb->prefix}b2s_posts_insights WHERE b2s_posts_network_details_id = %d";
396
- $postInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData[0]['b2sNetworkDetailsId']), ARRAY_A);
397
-
398
- $totalData = array('likes' => 0, 'comments' => 0, 'reshares' => 0, 'impressions' => 0);
399
- if(is_array($postInsightsData) && !empty($postInsightsData)) {
400
- foreach($postInsightsData as $entry) {
401
- if(isset($entry['insight']) && !empty($entry['insight'])) {
402
- $entryData = json_decode($entry['insight'], true);
403
- if($entryData !== false && is_array($entryData) && !empty($entryData) && isset($entryData['insights']['data']['likes']) && is_array($entryData['insights']['data']['likes']) && !empty($entryData['insights']['data']['likes'])) {
404
- end($entryData['insights']['data']['likes']);
405
- $entryKey = key($entryData['insights']['data']['likes']);
406
- $totalData['likes'] += $entryData['insights']['data']['likes'][$entryKey];
407
- $totalData['comments'] += $entryData['insights']['data']['comments'][$entryKey];
408
- $totalData['reshares'] += $entryData['insights']['data']['reshares'][$entryKey];
409
- $totalData['impressions'] += $entryData['insights']['data']['impressions'][$entryKey];
410
  }
411
  }
412
  }
413
- }
414
- $sql = "SELECT id, insight FROM {$wpdb->prefix}b2s_network_insights WHERE b2s_posts_network_details_id = %d AND create_date = %s";
415
- $networkInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData[0]['b2sNetworkDetailsId'], substr($newDate, 0, 10)), ARRAY_A);
416
-
417
- if (is_array($networkInsightsData) && !empty($networkInsightsData) && isset($networkInsightsData[0])) {
418
- //update
419
- $wpdb->update($wpdb->prefix.'b2s_network_insights', array('insight' => json_encode($totalData)), array('id' => $networkInsightsData[0]['id']), array('%s'), array('%d'));
420
- } else {
421
- //insert
422
- $wpdb->insert($wpdb->prefix.'b2s_network_insights', array(
423
- 'b2s_posts_network_details_id' => $externPostData[0]['b2sNetworkDetailsId'],
424
- 'create_date' => substr($newDate, 0, 10),
425
- 'insight' => json_encode($totalData)
426
- ), array('%d', '%s', '%s'));
427
- }
428
- } else {
429
- $sql = "SELECT id, insight FROM {$wpdb->prefix}b2s_network_insights WHERE b2s_posts_network_details_id = %d AND create_date = %s";
430
- $networkInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData[0]['b2sNetworkDetailsId'], substr($newDate, 0, 10)), ARRAY_A);
431
- if (is_array($networkInsightsData) && !empty($networkInsightsData) && isset($networkInsightsData[0])) {
432
- //update
433
- $wpdb->update($wpdb->prefix.'b2s_network_insights', array('insight' => json_encode($newTotalData)), array('id' => $networkInsightsData[0]['id']), array('%s'), array('%d'));
434
  } else {
435
- //insert
436
- $wpdb->insert($wpdb->prefix.'b2s_network_insights', array(
437
- 'b2s_posts_network_details_id' => $externPostData[0]['b2sNetworkDetailsId'],
438
- 'create_date' => substr($newDate, 0, 10),
439
- 'insight' => json_encode($newTotalData)
440
- ), array('%d', '%s', '%s'));
 
 
 
 
 
 
 
441
  }
442
  }
443
  }
444
  }
445
- }
446
- } else {
447
- //neu anlegen
448
- if(isset($insights['data']['insights']['likes']) && !empty($insights['data']['insights']['likes'])) {
449
- foreach($insights['data']['insights']['likes'] as $newDate => $newCount) {
450
- $sql = "SELECT insight FROM {$wpdb->prefix}b2s_posts_insights WHERE b2s_posts_network_details_id = %d";
451
- $postInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData['b2s_posts_network_details_id']), ARRAY_A);
452
-
453
- $totalData = array('likes' => 0, 'comments' => 0, 'reshares' => 0, 'impressions' => 0);
454
- if(is_array($postInsightsData) && !empty($postInsightsData)) {
455
- foreach($postInsightsData as $entry) {
456
- if(isset($entry['insight']) && !empty($entry['insight'])) {
457
- $entryData = json_decode($entry['insight'], true);
458
- if($entryData !== false && is_array($entryData) && !empty($entryData)) {
459
- end($entryData['insights']['data']['likes']);
460
- $entryKey = key($entryData['insights']['data']['likes']);
461
- $totalData['likes'] += $entryData['insights']['data']['likes'][$entryKey];
462
- $totalData['comments'] += $entryData['insights']['data']['comments'][$entryKey];
463
- $totalData['reshares'] += $entryData['insights']['data']['reshares'][$entryKey];
464
- $totalData['impressions'] += $entryData['insights']['data']['impressions'][$entryKey];
465
  }
466
  }
467
  }
468
- }
469
 
470
- $sql = "SELECT id, insight FROM {$wpdb->prefix}b2s_network_insights WHERE b2s_posts_network_details_id = %d AND create_date = %s";
471
- $networkInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData['b2s_posts_network_details_id'], substr($newDate, 0, 10)), ARRAY_A);
472
-
473
- if (is_array($networkInsightsData) && !empty($networkInsightsData) && isset($networkInsightsData[0])) {
474
- //update
475
- $wpdb->update($wpdb->prefix.'b2s_network_insights', array('insight' => json_encode($totalData)), array('id' => $networkInsightsData[0]['id']), array('%s'), array('%d'));
476
- } else {
477
- //insert
478
- $wpdb->insert($wpdb->prefix.'b2s_network_insights', array(
479
- 'b2s_posts_network_details_id' => $externPostData['b2s_posts_network_details_id'],
480
- 'create_date' => substr($newDate, 0, 10),
481
- 'insight' => json_encode($totalData)
482
- ), array('%d', '%s', '%s'));
 
483
  }
484
  }
485
  }
 
 
 
486
  }
487
-
488
-
489
-
490
  }
491
  }
492
  }
14
  public function init($response, $data) {
15
 
16
  if (isset($data['b2s_heartbeat']) && $data['b2s_heartbeat'] == 'b2s_listener') {
17
+ if (isset($data['b2s_heartbeat_action']) && ($data['b2s_heartbeat_action'] == 'b2s_auto_posting' || $data['b2s_heartbeat_action'] == 'b2s_repost')) {
18
  $this->postSchedToServer();
19
  } if (isset($data['b2s_heartbeat_action']) && $data['b2s_heartbeat_action'] == 'b2s_delete_sched_post') {
20
  $this->deleteUserSchedPost();
39
  public function deleteSchedPost() {
40
  $this->deleteUserSchedPost();
41
  }
42
+
43
+ public function updateSchedTimePost() {
44
  $this->updateUserSchedTimePost();
45
+ }
46
+
47
  private function postSchedToServer() {
48
  global $wpdb;
49
  $sendData = array();
58
  foreach ($postData as $k => $value) {
59
  $data = array('hook_action' => '0');
60
  $where = array('id' => $value['id']);
61
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
62
  $value['sched_data'] = ((isset($value['sched_data']) && !empty($value['sched_data'])) ? unserialize($value['sched_data']) : '');
63
  $value['image_url'] = ((isset($value['image_url']) && !empty($value['image_url'])) ? $value['image_url'] : '');
64
  $sendData[] = $value;
72
  if (!isset($result->content) || !isset($result->content->{$value['id']})) {
73
  $data = array('hook_action' => '1');
74
  $where = array('id' => $value['id']);
75
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
76
  }
77
  if (isset($result->fail) && isset($result->fail->{$value['id']})) {
78
  $failData = $wpdb->get_results($wpdb->prepare("SELECT id,sched_details_id,network_details_id FROM {$wpdb->prefix}b2s_posts WHERE id= %d", $value['id']), ARRAY_A);
79
  if (isset($failData[0]) && (int) $failData[0]['id'] > 0) {
80
+ $wpdb->delete($wpdb->prefix . 'b2s_posts', array('id' => $failData[0]['id']), array('%d'));
81
  if (isset($failData[0]['sched_details_id']) && (int) $failData[0]['sched_details_id'] > 0) {
82
+ $wpdb->delete($wpdb->prefix . 'b2s_posts_sched_details', array('id' => $failData[0]['sched_details_id']), array('%d'));
83
  }
84
  if (isset($failData[0]['sched_details_id']) && (int) $failData[0]['network_details_id'] > 0) {
85
+ $wpdb->delete($wpdb->prefix . 'b2s_posts_network_details', array('id' => $failData[0]['network_details_id']), array('%d'));
86
  }
87
  }
88
  }
123
  $post_id = $vdv2->post_id;
124
  $blog_user_id = $vdv2->blog_user_id;
125
  if ((int) $vdv2->id > 0) {
126
+ $wpdb->delete($wpdb->prefix . 'b2s_posts', array('id' => $vdv2->id), array('%d'));
127
  }
128
  if ((int) $vdv2->network_details_id > 0) {
129
+ $wpdb->delete($wpdb->prefix . 'b2s_posts_network_details', array('id' => $vdv2->network_details_id), array('%d'));
130
  }
131
  if ((int) $vdv2->sched_details_id > 0) {
132
+ $wpdb->delete($wpdb->prefix . 'b2s_posts_sched_details', array('id' => $vdv2->sched_details_id), array('%d'));
133
  }
134
  }
135
 
144
  'network_auth_id' => 0,
145
  'network_display_name' => ''
146
  );
147
+ $wpdb->insert($wpdb->prefix . 'b2s_posts_network_details', $networkDetails, array('%d', '%d', '%d', '%s'));
148
  $networkDetailsId = $wpdb->insert_id;
149
  $timezone = get_option('gmt_offset');
150
  $b2sPost = array(
162
  'hook_action' => '0',
163
  'hide' => '0',
164
  'v2_id' => '0');
165
+ $wpdb->insert($wpdb->prefix . 'b2s_posts', $b2sPost, array('%d', '%d', '%d', '%d', '%d', '%s', '%s', '%s', '%s', '%s', '%d', '%d', '%d', '%d'));
166
+
167
  if (isset($vpv2['external_post_id']) && !empty($vpv2['external_post_id'])) {
168
  $insightData = array(
169
  'network_post_id' => $vpv2['external_post_id'],
174
  'last_update' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -1 day')),
175
  'active' => 1
176
  );
177
+ $wpdb->insert($wpdb->prefix . 'b2s_posts_insights', $insightData, array('%s', '%s', '%d', '%d', '%d', '%s', '%d'));
178
  }
179
+
180
+
181
  B2S_Rating::trigger();
182
  }
183
  }
193
  'publish_link' => sanitize_text_field($v->publish_link),
194
  'publish_error_code' => sanitize_text_field($v->publish_error_code),
195
  'hook_action' => 0);
196
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $updateData, array('id' => $v->id, 'v2_id' => $v->v2_id), array('%s', '%s', '%s', '%s', '%s', '%d'), array('%d', '%d'));
197
  }
198
  }
199
  } else {
224
  'publish_error_code' => (($shareApprove == 0) ? sanitize_text_field($v->publish_error_code) : ''),
225
  'post_for_approve' => (int) $shareApprove,
226
  'hook_action' => 0);
227
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $updateData, array('id' => $v->id), array('%s', '%s', '%s', '%s', '%s', '%d', '%d'), array('%d'));
228
+
229
  if (isset($v->external_post_id) && !empty($v->external_post_id)) {
230
  $netowkDetailsData = $wpdb->get_results($wpdb->prepare("SELECT network_details_id, blog_user_id FROM {$wpdb->prefix}b2s_posts WHERE id= %d", $v->id), ARRAY_A);
231
  if (isset($netowkDetailsData[0]) && isset($netowkDetailsData[0]['network_details_id']) && (int) $netowkDetailsData[0]['network_details_id'] > 0 && isset($netowkDetailsData[0]['blog_user_id']) && (int) $netowkDetailsData[0]['blog_user_id'] > 0) {
238
  'last_update' => date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' -1 day')),
239
  'active' => 1
240
  );
241
+ $wpdb->insert($wpdb->prefix . 'b2s_posts_insights', $insightData, array('%s', '%s', '%d', '%d', '%d', '%s', '%d'));
242
  }
243
  }
244
  }
259
  foreach ($sendData as $k => $value) {
260
  $data = array('hook_action' => '0');
261
  $where = array('id' => $value['id']);
262
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
263
  }
264
  $tempData = array('action' => 'updateUserSchedTimePost', 'data' => serialize($sendData));
265
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
269
  if (!isset($result->content) || !isset($result->content->{$id})) {
270
  $data = array('hook_action' => '2');
271
  $where = array('id' => $id);
272
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
273
  }
274
  }
275
  }
286
  foreach ($sendData as $k => $value) {
287
  $data = array('hook_action' => '0');
288
  $where = array('id' => $value['id']);
289
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
290
  }
291
  $tempData = array('action' => 'updateUserSchedPost', 'data' => serialize($sendData));
292
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
296
  if (!isset($result->content) || !isset($result->content->{$id})) {
297
  $data = array('hook_action' => '5');
298
  $where = array('id' => $id);
299
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
300
  }
301
  }
302
  }
310
  foreach ($sendData as $k => $value) {
311
  $data = array('hook_action' => '0');
312
  $where = array('id' => $value['id']);
313
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
314
  }
315
  $tempData = array('action' => 'deleteUserSchedPost', 'data' => serialize($sendData));
316
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
320
  if (!isset($result->content) || !isset($result->content->{$id})) {
321
  $data = array('hook_action' => '3');
322
  $where = array('id' => $id);
323
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
324
  }
325
  }
326
  }
334
  foreach ($sendData as $k => $value) {
335
  $data = array('hook_action' => '0');
336
  $where = array('id' => $value['id']);
337
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
338
  }
339
  $tempData = array('action' => 'deleteUserPublishPost', 'data' => serialize($sendData));
340
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90));
344
  if (!isset($result->content) || !isset($result->content->{$id})) {
345
  $data = array('hook_action' => '4');
346
  $where = array('id' => $id);
347
+ $wpdb->update($wpdb->prefix . 'b2s_posts', $data, $where, array('%d'), array('%d'));
348
  }
349
  }
350
  }
351
  }
352
+
353
  private function updateInsights() {
354
  global $wpdb;
355
  $sql = "SELECT user.token, insights.network_post_id, insights.insight, network_details.network_auth_id, network_details.network_id, network_details.network_type FROM {$wpdb->prefix}b2s_posts_insights as insights LEFT JOIN {$wpdb->prefix}b2s_user AS user on insights.blog_user_id = user.blog_user_id LEFT JOIN {$wpdb->prefix}b2s_posts_network_details AS network_details on insights.b2s_posts_network_details_id = network_details.id WHERE insights.active = %d AND insights.last_update < %s LIMIT 50";
357
  if (is_array($sendData) && !empty($sendData) && isset($sendData[0])) {
358
  $tempData = array('action' => 'updateInsights', 'data' => $sendData);
359
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $tempData, 90), true);
360
+ if (isset($result['data']) && !empty($result['data'])) {
361
  foreach ($result['data'] as $k => $value) {
362
  $insights = $value;
363
+ if ($insights !== false && is_array($insights) && !empty($insights) && isset($insights['extern_post_id']) && !empty($insights['extern_post_id'])) {
364
+ if (isset($insights['insights']) && !empty($insights['insights'])) {
365
+ $sql = "SELECT insights.insight, insights.b2s_posts_network_details_id, networkDetails.network_auth_id, networkDetails.id as b2sNetworkDetailsId FROM {$wpdb->prefix}b2s_posts_insights as insights LEFT JOIN {$wpdb->prefix}b2s_posts_network_details as networkDetails ON insights.b2s_posts_network_details_id = networkDetails.id WHERE insights.network_post_id = %s";
366
+ $externPostData = $wpdb->get_results($wpdb->prepare($sql, $insights['extern_post_id']), ARRAY_A);
367
+ if (strlen($externPostData[0]['insight']) > $insights) {
368
+ continue; // no new insights data
369
+ }
370
+ $wpdb->update($wpdb->prefix . 'b2s_posts_insights', array('insight' => json_encode($insights), 'last_update' => date('Y-m-d H:i:s')), array('network_post_id' => $insights['extern_post_id']), array('%s', '%s'), array('%s'));
371
+
372
+ if (is_array($externPostData) && !empty($externPostData) && isset($externPostData[0])) {
373
+ //update & compare
374
+ $currentInsights = json_decode($externPostData[0]['insight'], true);
375
+ if (isset($currentInsights['insights']['data']['likes']) && !empty($currentInsights['insights']['data']['likes'])) {
376
+ if (isset($insights['insights']['data']['likes']) && !empty($insights['insights']['data']['likes'])) {
377
+ foreach ($insights['insights']['data']['likes'] as $newDate => $newCount) {
378
+ $dataForDateExist = false;
379
+ $dataForDateIsSame = false;
380
+ $newTotalData = array(
381
+ 'likes' => $newCount,
382
+ 'comments' => ((isset($insights['insights']['data']['comments'][$newDate])) ? (int) $insights['insights']['data']['comments'][$newDate] : 0),
383
+ 'reshares' => ((isset($insights['insights']['data']['reshares'][$newDate])) ? (int) $insights['insights']['data']['reshares'][$newDate] : 0),
384
+ 'impressions' => ((isset($insights['insights']['data']['impressions'][$newDate])) ? (int) $insights['insights']['data']['impressions'][$newDate] : 0)
385
+ );
386
+ foreach ($currentInsights['insights']['data']['likes'] as $currDate => $currCount) {
387
+ if (substr($newDate, 0, 10) == substr($currDate, 0, 10)) {
388
+ $dataForDateExist = true;
389
+ if ($newCount == $currCount) {
390
+ $dataForDateIsSame = true;
391
+ }
392
  }
393
  }
394
+
395
+ if (!$dataForDateExist || ($dataForDateExist && !$dataForDateIsSame)) {
396
+ $sql = "SELECT insight FROM {$wpdb->prefix}b2s_posts_insights WHERE b2s_posts_network_details_id = %d";
397
+ $postInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData[0]['b2sNetworkDetailsId']), ARRAY_A);
398
+
399
+ $totalData = array('likes' => 0, 'comments' => 0, 'reshares' => 0, 'impressions' => 0);
400
+ if (is_array($postInsightsData) && !empty($postInsightsData)) {
401
+ foreach ($postInsightsData as $entry) {
402
+ if (isset($entry['insight']) && !empty($entry['insight'])) {
403
+ $entryData = json_decode($entry['insight'], true);
404
+ if ($entryData !== false && is_array($entryData) && !empty($entryData) && isset($entryData['insights']['data']['likes']) && is_array($entryData['insights']['data']['likes']) && !empty($entryData['insights']['data']['likes'])) {
405
+ end($entryData['insights']['data']['likes']);
406
+ $entryKey = key($entryData['insights']['data']['likes']);
407
+ $totalData['likes'] += $entryData['insights']['data']['likes'][$entryKey];
408
+ $totalData['comments'] += $entryData['insights']['data']['comments'][$entryKey];
409
+ $totalData['reshares'] += $entryData['insights']['data']['reshares'][$entryKey];
410
+ $totalData['impressions'] += $entryData['insights']['data']['impressions'][$entryKey];
411
+ }
412
  }
413
  }
414
  }
415
+ $sql = "SELECT id, insight FROM {$wpdb->prefix}b2s_network_insights WHERE b2s_posts_network_details_id = %d AND create_date = %s";
416
+ $networkInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData[0]['b2sNetworkDetailsId'], substr($newDate, 0, 10)), ARRAY_A);
417
+
418
+ if (is_array($networkInsightsData) && !empty($networkInsightsData) && isset($networkInsightsData[0])) {
419
+ //update
420
+ $wpdb->update($wpdb->prefix . 'b2s_network_insights', array('insight' => json_encode($totalData)), array('id' => $networkInsightsData[0]['id']), array('%s'), array('%d'));
421
+ } else {
422
+ //insert
423
+ $wpdb->insert($wpdb->prefix . 'b2s_network_insights', array(
424
+ 'b2s_posts_network_details_id' => $externPostData[0]['b2sNetworkDetailsId'],
425
+ 'create_date' => substr($newDate, 0, 10),
426
+ 'insight' => json_encode($totalData)
427
+ ), array('%d', '%s', '%s'));
428
+ }
 
 
 
 
 
 
 
429
  } else {
430
+ $sql = "SELECT id, insight FROM {$wpdb->prefix}b2s_network_insights WHERE b2s_posts_network_details_id = %d AND create_date = %s";
431
+ $networkInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData[0]['b2sNetworkDetailsId'], substr($newDate, 0, 10)), ARRAY_A);
432
+ if (is_array($networkInsightsData) && !empty($networkInsightsData) && isset($networkInsightsData[0])) {
433
+ //update
434
+ $wpdb->update($wpdb->prefix . 'b2s_network_insights', array('insight' => json_encode($newTotalData)), array('id' => $networkInsightsData[0]['id']), array('%s'), array('%d'));
435
+ } else {
436
+ //insert
437
+ $wpdb->insert($wpdb->prefix . 'b2s_network_insights', array(
438
+ 'b2s_posts_network_details_id' => $externPostData[0]['b2sNetworkDetailsId'],
439
+ 'create_date' => substr($newDate, 0, 10),
440
+ 'insight' => json_encode($newTotalData)
441
+ ), array('%d', '%s', '%s'));
442
+ }
443
  }
444
  }
445
  }
446
  }
447
+ } else {
448
+ //new entry
449
+ if (isset($insights['data']['insights']['likes']) && !empty($insights['data']['insights']['likes'])) {
450
+ foreach ($insights['data']['insights']['likes'] as $newDate => $newCount) {
451
+ $sql = "SELECT insight FROM {$wpdb->prefix}b2s_posts_insights WHERE b2s_posts_network_details_id = %d";
452
+ $postInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData['b2s_posts_network_details_id']), ARRAY_A);
453
+
454
+ $totalData = array('likes' => 0, 'comments' => 0, 'reshares' => 0, 'impressions' => 0);
455
+ if (is_array($postInsightsData) && !empty($postInsightsData)) {
456
+ foreach ($postInsightsData as $entry) {
457
+ if (isset($entry['insight']) && !empty($entry['insight'])) {
458
+ $entryData = json_decode($entry['insight'], true);
459
+ if ($entryData !== false && is_array($entryData) && !empty($entryData)) {
460
+ end($entryData['insights']['data']['likes']);
461
+ $entryKey = key($entryData['insights']['data']['likes']);
462
+ $totalData['likes'] += $entryData['insights']['data']['likes'][$entryKey];
463
+ $totalData['comments'] += $entryData['insights']['data']['comments'][$entryKey];
464
+ $totalData['reshares'] += $entryData['insights']['data']['reshares'][$entryKey];
465
+ $totalData['impressions'] += $entryData['insights']['data']['impressions'][$entryKey];
466
+ }
467
  }
468
  }
469
  }
 
470
 
471
+ $sql = "SELECT id, insight FROM {$wpdb->prefix}b2s_network_insights WHERE b2s_posts_network_details_id = %d AND create_date = %s";
472
+ $networkInsightsData = $wpdb->get_results($wpdb->prepare($sql, (int) $externPostData['b2s_posts_network_details_id'], substr($newDate, 0, 10)), ARRAY_A);
473
+
474
+ if (is_array($networkInsightsData) && !empty($networkInsightsData) && isset($networkInsightsData[0])) {
475
+ //update
476
+ $wpdb->update($wpdb->prefix . 'b2s_network_insights', array('insight' => json_encode($totalData)), array('id' => $networkInsightsData[0]['id']), array('%s'), array('%d'));
477
+ } else {
478
+ //insert
479
+ $wpdb->insert($wpdb->prefix . 'b2s_network_insights', array(
480
+ 'b2s_posts_network_details_id' => $externPostData['b2s_posts_network_details_id'],
481
+ 'create_date' => substr($newDate, 0, 10),
482
+ 'insight' => json_encode($totalData)
483
+ ), array('%d', '%s', '%s'));
484
+ }
485
  }
486
  }
487
  }
488
+ //is deactivated
489
+ } else {
490
+ $wpdb->update($wpdb->prefix . 'b2s_posts_insights', array('last_update' => date('Y-m-d H:i:s'), 'active' => 0), array('network_post_id' => $insights['extern_post_id']), array('%s', '%d'), array('%s'));
491
  }
 
 
 
492
  }
493
  }
494
  }
includes/B2S/Post/Filter.php CHANGED
@@ -16,7 +16,7 @@ class B2S_Post_Filter {
16
  protected $searchPostSharedById;
17
  protected $postAuthor;
18
 
19
- function __construct($type, $title = "", $authorId = 0, $postStatus = "", $schedDate = "", $postCat = "", $postType = "", $postShareStatus="", $postsPerPage = 15, $sharedById = 0, $sharedToNetwork = 0) { //type=all,publish,sched
20
  require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
21
  $options = new B2S_Options((int) B2S_PLUGIN_BLOG_USER_ID);
22
  $optionPostFilters = $options->_getOption('post_filters');
@@ -29,7 +29,7 @@ class B2S_Post_Filter {
29
  $this->searchSchedDate = (empty($schedDate) && isset($optionPostFilters['searchSchedDate'])) ? $optionPostFilters['searchSchedDate'] : $schedDate;
30
  $this->searchPostCat = (empty($postCat) && isset($optionPostFilters['searchPostCat'])) ? $optionPostFilters['searchPostCat'] : $postCat;
31
  $this->searchPostType = (empty($postType) && isset($optionPostFilters['searchPostType'])) ? $optionPostFilters['searchPostType'] : $postType;
32
- $this->postsPerPage = ((int)$postsPerPage != 15 && isset($optionPostFilters['postsPerPage']) && (int)$optionPostFilters['postsPerPage'] > 0) ? (int)$optionPostFilters['searchAuthorId'] : (int)$postsPerPage;
33
  $this->searchPostSharedById = ((int)$sharedById == 0 && isset($optionPostFilters['searchPostSharedById']) && (int)$optionPostFilters['searchPostSharedById'] > 0) ? (int)$optionPostFilters['searchPostSharedById'] : (int)$sharedById;
34
  $this->searchSharedToNetwork = ((int)$sharedToNetwork == 0 && isset($optionPostFilters['searchSharedToNetwork']) && (int)$optionPostFilters['searchSharedToNetwork'] > 0) ? (int)$optionPostFilters['searchSharedToNetwork'] : (int)$sharedToNetwork;
35
  }
@@ -161,7 +161,7 @@ class B2S_Post_Filter {
161
  }
162
 
163
  private function getPostPerPageHtml() {
164
- return '<input type="hidden" id="b2sPostsPerPage" name="b2sPostsPerPage" value="25">';
165
  }
166
 
167
  private function getPostSharedByHtml() {
16
  protected $searchPostSharedById;
17
  protected $postAuthor;
18
 
19
+ function __construct($type, $title = "", $authorId = 0, $postStatus = "", $schedDate = "", $postCat = "", $postType = "", $postShareStatus="", $postsPerPage = 25, $sharedById = 0, $sharedToNetwork = 0) { //type=all,publish,sched
20
  require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
21
  $options = new B2S_Options((int) B2S_PLUGIN_BLOG_USER_ID);
22
  $optionPostFilters = $options->_getOption('post_filters');
29
  $this->searchSchedDate = (empty($schedDate) && isset($optionPostFilters['searchSchedDate'])) ? $optionPostFilters['searchSchedDate'] : $schedDate;
30
  $this->searchPostCat = (empty($postCat) && isset($optionPostFilters['searchPostCat'])) ? $optionPostFilters['searchPostCat'] : $postCat;
31
  $this->searchPostType = (empty($postType) && isset($optionPostFilters['searchPostType'])) ? $optionPostFilters['searchPostType'] : $postType;
32
+ $this->postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int)$optionPostFilters['postsPerPage'] > 0) ? (int)$optionPostFilters['postsPerPage'] : (int)$postsPerPage;
33
  $this->searchPostSharedById = ((int)$sharedById == 0 && isset($optionPostFilters['searchPostSharedById']) && (int)$optionPostFilters['searchPostSharedById'] > 0) ? (int)$optionPostFilters['searchPostSharedById'] : (int)$sharedById;
34
  $this->searchSharedToNetwork = ((int)$sharedToNetwork == 0 && isset($optionPostFilters['searchSharedToNetwork']) && (int)$optionPostFilters['searchSharedToNetwork'] > 0) ? (int)$optionPostFilters['searchSharedToNetwork'] : (int)$sharedToNetwork;
35
  }
161
  }
162
 
163
  private function getPostPerPageHtml() {
164
+ return '<input type="hidden" id="b2sPostsPerPage" name="b2sPostsPerPage" value="'.$this->postsPerPage.'">';
165
  }
166
 
167
  private function getPostSharedByHtml() {
includes/B2S/RePost/Save.php CHANGED
@@ -382,7 +382,7 @@ class B2S_RePost_Save {
382
  $hashTags = substr($hashTags, 0, $pos - 1);
383
  }
384
  }
385
- return (!empty($hashTags) ? (!empty($add) ? $add . $hashTags : $hashTags) : '');
386
  } else {
387
  return '';
388
  }
382
  $hashTags = substr($hashTags, 0, $pos - 1);
383
  }
384
  }
385
+ return (!empty($hashTags) ? (!empty($add) ? $add . trim($hashTags) : trim($hashTags)) : '');
386
  } else {
387
  return '';
388
  }
includes/B2S/Ship/Item.php CHANGED
@@ -1238,7 +1238,7 @@ class B2S_Ship_Item {
1238
  $hashTags .= ' #' . str_replace(array(" ", "-", '"', "'", "!", "?", ",", ".", ";", ":"), "", (function_exists('htmlspecialchars_decode') ? htmlspecialchars_decode($tag->name) : $tag->name));
1239
  }
1240
  }
1241
- return (!empty($hashTags) ? (!empty($add) ? $add . $hashTags : $hashTags) : '');
1242
  }
1243
 
1244
  private function getBoardHtml($networkAuthId, $networkId) {
1238
  $hashTags .= ' #' . str_replace(array(" ", "-", '"', "'", "!", "?", ",", ".", ";", ":"), "", (function_exists('htmlspecialchars_decode') ? htmlspecialchars_decode($tag->name) : $tag->name));
1239
  }
1240
  }
1241
+ return (!empty($hashTags) ? (!empty($add) ? $add . trim($hashTags) : trim($hashTags)) : '');
1242
  }
1243
 
1244
  private function getBoardHtml($networkAuthId, $networkId) {
includes/B2S/Ship/Portale.php CHANGED
@@ -62,7 +62,7 @@ class B2S_Ship_Portale {
62
  } else if(($portal->id == 25 || $portal->id == 26 || $portal->id == 27) && B2S_PLUGIN_USER_VERSION < 1) {
63
  $html .= '<button type="button" class="btn btn-' . str_replace(' ', '', strtolower(esc_attr($portal->name))) . ' btn-sm b2s-network-list-add-btn b2s-network-list-add-btn-profeature b2s-btn-disabled b2sPreFeatureModalBtn" data-title="' . esc_html__('You want to connect a network profile?', 'blog2social') . '" data-type="auth-network">' . sprintf(esc_html__('Connect %s', 'blog2social'), esc_html($name)) . ' <span class="label label-success">' . esc_html__("SMART", "blog2social") . '</a></button>';
64
  } else {
65
- $html .= ($portal->id != 18 || (B2S_PLUGIN_USER_VERSION >= 2 && $portal->id == 18)) ? ('<a href="#" onclick="wop(\'' . esc_url($b2sAuthUrl) . '&choose=profile\', \'Blog2Social Network\'); return false;" class="btn btn-' . str_replace(' ', '', strtolower(esc_attr($portal->name))) . ' btn-sm b2s-network-list-add-btn">' . sprintf(esc_html__('Connect %s', 'blog2social'), esc_html($name)) . '</a>') : '<button type="button" class="btn btn-' . str_replace(' ', '', strtolower($portal->name)) . ' btn-sm b2s-network-list-add-btn b2s-network-list-add-btn-profeature b2s-btn-disabled b2sProFeatureModalBtn" data-title="' . esc_html__('You want to connect a network profile?', 'blog2social') . '" data-type="auth-network">' . sprintf(esc_html__('Connect %s', 'blog2social'), esc_html($name)) . ' <span class="label label-success">' . esc_html__("PRO", "blog2social") . '</a></button>';
66
  }
67
  }
68
  $html .= '</li>';
62
  } else if(($portal->id == 25 || $portal->id == 26 || $portal->id == 27) && B2S_PLUGIN_USER_VERSION < 1) {
63
  $html .= '<button type="button" class="btn btn-' . str_replace(' ', '', strtolower(esc_attr($portal->name))) . ' btn-sm b2s-network-list-add-btn b2s-network-list-add-btn-profeature b2s-btn-disabled b2sPreFeatureModalBtn" data-title="' . esc_html__('You want to connect a network profile?', 'blog2social') . '" data-type="auth-network">' . sprintf(esc_html__('Connect %s', 'blog2social'), esc_html($name)) . ' <span class="label label-success">' . esc_html__("SMART", "blog2social") . '</a></button>';
64
  } else {
65
+ $html .= ($portal->id != 18 || (B2S_PLUGIN_USER_VERSION >= 2 && $portal->id == 18)) ? ('<button onclick="wop(\'' . esc_url($b2sAuthUrl) . '&choose=profile\', \'Blog2Social Network\'); return false;" class="btn btn-' . str_replace(' ', '', strtolower(esc_attr($portal->name))) . ' btn-sm b2s-network-list-add-btn">' . sprintf(esc_html__('Connect %s', 'blog2social'), esc_html($name)) . '</button>') : '<button type="button" class="btn btn-' . str_replace(' ', '', strtolower($portal->name)) . ' btn-sm b2s-network-list-add-btn b2s-network-list-add-btn-profeature b2s-btn-disabled b2sProFeatureModalBtn" data-title="' . esc_html__('You want to connect a network profile?', 'blog2social') . '" data-type="auth-network">' . sprintf(esc_html__('Connect %s', 'blog2social'), esc_html($name)) . ' <span class="label label-success">' . esc_html__("PRO", "blog2social") . '</a></button>';
66
  }
67
  }
68
  $html .= '</li>';
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: auto post, auto publish, social media scheduling, social media calendar, s
5
  Donate link: https://paypal.me/adenion
6
  Requires at least: 4.7.0
7
  Tested up to: 6.0
8
- Stable tag: 6.9.12
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -234,6 +234,8 @@ To get started with the basics of Blog2Social and maybe find some useful tips an
234
  7. Keep track of your shared posts and scheduling plan with the Social Media Calendar.
235
 
236
  == Changelog ==
 
 
237
  = 6.9.12 =
238
  Additional Security Update
239
  = 6.9.11 =
@@ -332,6 +334,8 @@ Usability Optimization, Rebrandly integration, url parameter settings
332
  New Image Posts, Imgur, Animated Gifs and Emojis
333
 
334
  == Upgrade Notice ==
 
 
335
  = 6.9.12 =
336
  Additional Security Update
337
  = 6.9.11 =
5
  Donate link: https://paypal.me/adenion
6
  Requires at least: 4.7.0
7
  Tested up to: 6.0
8
+ Stable tag: 6.9.13
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
234
  7. Keep track of your shared posts and scheduling plan with the Social Media Calendar.
235
 
236
  == Changelog ==
237
+ = 6.9.13 =
238
+ Optimize Social Media Metrics & Usability Optimization
239
  = 6.9.12 =
240
  Additional Security Update
241
  = 6.9.11 =
334
  New Image Posts, Imgur, Animated Gifs and Emojis
335
 
336
  == Upgrade Notice ==
337
+ = 6.9.13 =
338
+ Optimize Social Media Metrics & Usability Optimization
339
  = 6.9.12 =
340
  Additional Security Update
341
  = 6.9.11 =
views/b2s/post.approve.php CHANGED
@@ -4,9 +4,13 @@ wp_nonce_field('b2s_security_nonce', 'b2s_security_nonce');
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
6
  require_once B2S_PLUGIN_DIR . 'includes/B2S/Settings/Item.php';
 
7
  $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#", trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate'])))) ? trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate']))) : "") : ""; //YYYY-mm-dd
8
  $b2sUserAuthId = isset($_GET['b2sUserAuthId']) ? (int) $_GET['b2sUserAuthId'] : 0;
9
  $b2sPostBlogId = isset($_GET['b2sPostBlogId']) ? (int) $_GET['b2sPostBlogId'] : 0;
 
 
 
10
  ?>
11
 
12
  <div class="b2s-container">
@@ -93,9 +97,9 @@ $b2sPostBlogId = isset($_GET['b2sPostBlogId']) ? (int) $_GET['b2sPostBlogId'] :
93
  <br>
94
  <nav class="b2s-sort-pagination-area text-center">
95
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
96
- <button type="button" class="btn btn-primary b2s-post-per-page" data-post-per-page="25">25</button>
97
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="50">50</button>
98
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="100">100</button>
99
  </div>
100
  <div class="b2s-sort-pagination-content"></div>
101
  </nav>
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
6
  require_once B2S_PLUGIN_DIR . 'includes/B2S/Settings/Item.php';
7
+ require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
8
  $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#", trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate'])))) ? trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate']))) : "") : ""; //YYYY-mm-dd
9
  $b2sUserAuthId = isset($_GET['b2sUserAuthId']) ? (int) $_GET['b2sUserAuthId'] : 0;
10
  $b2sPostBlogId = isset($_GET['b2sPostBlogId']) ? (int) $_GET['b2sPostBlogId'] : 0;
11
+ $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
12
+ $optionPostFilters = $options->_getOption('post_filters');
13
+ $postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int) $optionPostFilters['postsPerPage'] > 0) ? (int) $optionPostFilters['postsPerPage'] : 25;
14
  ?>
15
 
16
  <div class="b2s-container">
97
  <br>
98
  <nav class="b2s-sort-pagination-area text-center">
99
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
100
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 25) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="25">25</button>
101
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 50) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="50">50</button>
102
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 100) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="100">100</button>
103
  </div>
104
  <div class="b2s-sort-pagination-content"></div>
105
  </nav>
views/b2s/post.draft.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
  wp_nonce_field('b2s_security_nonce', 'b2s_security_nonce');
3
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
 
 
 
 
4
  ?>
5
 
6
  <div class="b2s-container">
@@ -84,9 +88,9 @@ require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
84
  <br>
85
  <nav class="b2s-sort-pagination-area text-center">
86
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
87
- <button type="button" class="btn btn-primary b2s-post-per-page" data-post-per-page="25">25</button>
88
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="50">50</button>
89
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="100">100</button>
90
  </div>
91
  <div class="b2s-sort-pagination-content"></div>
92
  </nav>
1
  <?php
2
  wp_nonce_field('b2s_security_nonce', 'b2s_security_nonce');
3
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
4
+ require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
5
+ $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
6
+ $optionPostFilters = $options->_getOption('post_filters');
7
+ $postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int) $optionPostFilters['postsPerPage'] > 0) ? (int) $optionPostFilters['postsPerPage'] : 25;
8
  ?>
9
 
10
  <div class="b2s-container">
88
  <br>
89
  <nav class="b2s-sort-pagination-area text-center">
90
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
91
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 25) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="25">25</button>
92
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 50) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="50">50</button>
93
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 100) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="100">100</button>
94
  </div>
95
  <div class="b2s-sort-pagination-content"></div>
96
  </nav>
views/b2s/post.favorites.php CHANGED
@@ -3,6 +3,10 @@ wp_nonce_field('b2s_security_nonce', 'b2s_security_nonce');
3
  /* Data */
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
 
 
 
 
6
  ?>
7
  <div class="b2s-container">
8
  <div class="b2s-inbox">
@@ -83,9 +87,9 @@ require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
83
  <br>
84
  <nav class="b2s-sort-pagination-area text-center">
85
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
86
- <button type="button" class="btn btn-primary b2s-post-per-page" data-post-per-page="25">25</button>
87
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="50">50</button>
88
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="100">100</button>
89
  </div>
90
  <div class="b2s-sort-pagination-content"></div>
91
  </nav>
3
  /* Data */
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
6
+ require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
7
+ $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
8
+ $optionPostFilters = $options->_getOption('post_filters');
9
+ $postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int) $optionPostFilters['postsPerPage'] > 0) ? (int) $optionPostFilters['postsPerPage'] : 25;
10
  ?>
11
  <div class="b2s-container">
12
  <div class="b2s-inbox">
87
  <br>
88
  <nav class="b2s-sort-pagination-area text-center">
89
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
90
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 25) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="25">25</button>
91
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 50) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="50">50</button>
92
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 100) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="100">100</button>
93
  </div>
94
  <div class="b2s-sort-pagination-content"></div>
95
  </nav>
views/b2s/post.notice.php CHANGED
@@ -7,6 +7,8 @@ require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
7
  $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#", trim(sanitize_text_field($_GET['b2sShowByDate']))) ? trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate']))) : "") : ""; //YYYY-mm-dd
8
  $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
9
  $options->_setOption('lastNotificationUpdate', date('Y-m-d H:i:s'));
 
 
10
  ?>
11
 
12
  <div class="b2s-container">
@@ -90,9 +92,9 @@ $options->_setOption('lastNotificationUpdate', date('Y-m-d H:i:s'));
90
  <br>
91
  <nav class="b2s-sort-pagination-area text-center">
92
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
93
- <button type="button" class="btn btn-primary b2s-post-per-page" data-post-per-page="25">25</button>
94
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="50">50</button>
95
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="100">100</button>
96
  </div>
97
  <div class="b2s-sort-pagination-content"></div>
98
  </nav>
7
  $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#", trim(sanitize_text_field($_GET['b2sShowByDate']))) ? trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate']))) : "") : ""; //YYYY-mm-dd
8
  $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
9
  $options->_setOption('lastNotificationUpdate', date('Y-m-d H:i:s'));
10
+ $optionPostFilters = $options->_getOption('post_filters');
11
+ $postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int) $optionPostFilters['postsPerPage'] > 0) ? (int) $optionPostFilters['postsPerPage'] : 25;
12
  ?>
13
 
14
  <div class="b2s-container">
92
  <br>
93
  <nav class="b2s-sort-pagination-area text-center">
94
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
95
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 25) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="25">25</button>
96
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 50) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="50">50</button>
97
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 100) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="100">100</button>
98
  </div>
99
  <div class="b2s-sort-pagination-content"></div>
100
  </nav>
views/b2s/post.php CHANGED
@@ -3,7 +3,6 @@ wp_nonce_field('b2s_security_nonce', 'b2s_security_nonce');
3
  /* Data */
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
6
-
7
  require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
8
  $options = new B2S_Options((int) B2S_PLUGIN_BLOG_USER_ID);
9
  $optionPostFilters = $options->_getOption('post_filters');
3
  /* Data */
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
 
6
  require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
7
  $options = new B2S_Options((int) B2S_PLUGIN_BLOG_USER_ID);
8
  $optionPostFilters = $options->_getOption('post_filters');
views/b2s/post.publish.php CHANGED
@@ -3,7 +3,11 @@ wp_nonce_field('b2s_security_nonce', 'b2s_security_nonce');
3
  /* Data */
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
 
6
  $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#", trim(sanitize_text_field($_GET['b2sShowByDate']))) ? trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate']))) : "") : ""; //YYYY-mm-dd
 
 
 
7
  ?>
8
 
9
  <div class="b2s-container">
@@ -87,9 +91,9 @@ $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#",
87
  <br>
88
  <nav class="b2s-sort-pagination-area text-center">
89
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
90
- <button type="button" class="btn btn-primary b2s-post-per-page" data-post-per-page="25">25</button>
91
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="50">50</button>
92
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="100">100</button>
93
  </div>
94
  <div class="b2s-sort-pagination-content"></div>
95
  </nav>
3
  /* Data */
4
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Post/Filter.php');
5
  require_once (B2S_PLUGIN_DIR . 'includes/Util.php');
6
+ require_once(B2S_PLUGIN_DIR . 'includes/Options.php');
7
  $b2sShowByDate = isset($_GET['b2sShowByDate']) ? (preg_match("#^[0-9\-.\]]+$#", trim(sanitize_text_field($_GET['b2sShowByDate']))) ? trim(sanitize_text_field(wp_unslash($_GET['b2sShowByDate']))) : "") : ""; //YYYY-mm-dd
8
+ $options = new B2S_Options((int) B2S_PLUGIN_BLOG_USER_ID);
9
+ $optionPostFilters = $options->_getOption('post_filters');
10
+ $postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int) $optionPostFilters['postsPerPage'] > 0) ? (int) $optionPostFilters['postsPerPage'] : 25;
11
  ?>
12
 
13
  <div class="b2s-container">
91
  <br>
92
  <nav class="b2s-sort-pagination-area text-center">
93
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
94
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 25) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="25">25</button>
95
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 50) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="50">50</button>
96
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 100) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="100">100</button>
97
  </div>
98
  <div class="b2s-sort-pagination-content"></div>
99
  </nav>
views/b2s/post.sched.php CHANGED
@@ -13,9 +13,11 @@ $optionUserTimeZone = $options->_getOption('user_time_zone');
13
  $userTimeZone = ($optionUserTimeZone !== false) ? $optionUserTimeZone : get_option('timezone_string');
14
  $userTimeZoneOffset = (empty($userTimeZone)) ? get_option('gmt_offset') : B2S_Util::getOffsetToUtcByTimeZone($userTimeZone);
15
  $optionUserTimeFormat = $options->_getOption('user_time_format');
16
- if($optionUserTimeFormat == false) {
17
  $optionUserTimeFormat = (substr(B2S_LANGUAGE, 0, 2) == 'de') ? 0 : 1;
18
  }
 
 
19
  $metaSettings = get_option('B2S_PLUGIN_GENERAL_OPTIONS');
20
  ?>
21
 
@@ -105,9 +107,9 @@ $metaSettings = get_option('B2S_PLUGIN_GENERAL_OPTIONS');
105
  <br>
106
  <nav class="b2s-sort-pagination-area text-center">
107
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
108
- <button type="button" class="btn btn-primary b2s-post-per-page" data-post-per-page="25">25</button>
109
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="50">50</button>
110
- <button type="button" class="btn btn-default b2s-post-per-page" data-post-per-page="100">100</button>
111
  </div>
112
  <div class="b2s-sort-pagination-content"></div>
113
  </nav>
13
  $userTimeZone = ($optionUserTimeZone !== false) ? $optionUserTimeZone : get_option('timezone_string');
14
  $userTimeZoneOffset = (empty($userTimeZone)) ? get_option('gmt_offset') : B2S_Util::getOffsetToUtcByTimeZone($userTimeZone);
15
  $optionUserTimeFormat = $options->_getOption('user_time_format');
16
+ if ($optionUserTimeFormat == false) {
17
  $optionUserTimeFormat = (substr(B2S_LANGUAGE, 0, 2) == 'de') ? 0 : 1;
18
  }
19
+ $optionPostFilters = $options->_getOption('post_filters');
20
+ $postsPerPage = (isset($optionPostFilters['postsPerPage']) && (int) $optionPostFilters['postsPerPage'] > 0) ? (int) $optionPostFilters['postsPerPage'] : 25;
21
  $metaSettings = get_option('B2S_PLUGIN_GENERAL_OPTIONS');
22
  ?>
23
 
107
  <br>
108
  <nav class="b2s-sort-pagination-area text-center">
109
  <div class="btn-group btn-group-sm pull-right b2s-post-per-page-area hidden-xs" role="group">
110
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 25) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="25">25</button>
111
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 50) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="50">50</button>
112
+ <button type="button" class="btn <?php echo ((int) $postsPerPage == 100) ? "btn-primary" : "btn-default" ?> b2s-post-per-page" data-post-per-page="100">100</button>
113
  </div>
114
  <div class="b2s-sort-pagination-content"></div>
115
  </nav>