Blog2Social: Social Media Auto Post & Scheduler - Version 6.5.1

Version Description

Usability Optimization

Download this release

Release Info

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

Code changes from version 6.5.0 to 6.5.1

blog2social.php CHANGED
@@ -6,12 +6,12 @@
6
  * Author: Blog2Social, Adenion
7
  * Text Domain: blog2social
8
  * Domain Path: /languages
9
- * Version: 6.5.0
10
  * Author URI: https://www.blog2social.com
11
  * License: GPL2+
12
  */
13
 
14
- define('B2S_PLUGIN_VERSION', '650');
15
  define('B2S_PLUGIN_LANGUAGE', serialize(array('de_DE', 'en_US')));
16
  define('B2S_PLUGIN_DIR', plugin_dir_path(__FILE__));
17
  define('B2S_PLUGIN_URL', plugin_dir_url(__FILE__));
6
  * Author: Blog2Social, Adenion
7
  * Text Domain: blog2social
8
  * Domain Path: /languages
9
+ * Version: 6.5.1
10
  * Author URI: https://www.blog2social.com
11
  * License: GPL2+
12
  */
13
 
14
+ define('B2S_PLUGIN_VERSION', '651');
15
  define('B2S_PLUGIN_LANGUAGE', serialize(array('de_DE', 'en_US')));
16
  define('B2S_PLUGIN_DIR', plugin_dir_path(__FILE__));
17
  define('B2S_PLUGIN_URL', plugin_dir_url(__FILE__));
includes/Ajax/Get.php CHANGED
@@ -469,7 +469,7 @@ class Ajax_Get {
469
  } else {
470
  $metaInfo = B2S_Util::getMetaTags(0, esc_url($_POST['url']), (int) $_POST['networkId']);
471
  }
472
- echo json_encode(array('result' => true, 'networkId' => (int) $_POST['networkId'], 'networkAuthId' => (int) $_POST['networkAuthId'], 'title' => isset($metaInfo['title']) ? $metaInfo['title'] : '', 'description' => isset($metaInfo['description']) ? $metaInfo['description'] : '', 'image' => isset($metaInfo['image']) ? esc_attr($metaInfo['image']) : ''));
473
  wp_die();
474
  }
475
  echo json_encode(array('result' => false));
469
  } else {
470
  $metaInfo = B2S_Util::getMetaTags(0, esc_url($_POST['url']), (int) $_POST['networkId']);
471
  }
472
+ echo json_encode(array('result' => true, 'networkId' => (int) $_POST['networkId'], 'networkAuthId' => (int) $_POST['networkAuthId'], 'title' => isset($metaInfo['title']) ? (function_exists('htmlspecialchars_decode') ? htmlspecialchars_decode($metaInfo['title']) : $metaInfo['title']) : '', 'description' => isset($metaInfo['description']) ? (function_exists('htmlspecialchars_decode') ? htmlspecialchars_decode($metaInfo['description']): $metaInfo['description']) : '', 'image' => isset($metaInfo['image']) ? esc_attr($metaInfo['image']) : ''));
473
  wp_die();
474
  }
475
  echo json_encode(array('result' => false));
includes/Ajax/Post.php CHANGED
@@ -590,7 +590,7 @@ class Ajax_Post {
590
  $options = new B2S_Options(0, 'B2S_PLUGIN_TOS_XING_GROUP_CROSSPOSTING');
591
  $options->_setOption((int) $post['post_id'], $data['network_tos_group_id'], true);
592
  }
593
-
594
  $sendData = array("board" => isset($data['board']) ? sanitize_text_field($data['board']) : '',
595
  "group" => isset($data['group']) ? sanitize_text_field($data['group']) : '',
596
  "custom_title" => isset($data['custom_title']) ? sanitize_text_field($data['custom_title']) : '',
@@ -611,23 +611,23 @@ class Ajax_Post {
611
  'user_timezone' => isset($post['user_timezone']) ? (int) $post['user_timezone'] : 0,
612
  'publish_date' => isset($post['publish_date']) ? date('Y-m-d H:i:s', strtotime($post['publish_date'])) : date('Y-m-d H:i:s', current_time('timestamp'))
613
  );
614
-
615
- if(isset($data['post_format']) && (int) $data['post_format'] == 1) {
616
  $multi_images = array();
617
- if(isset($data['multi_image_1']) && !empty($data['multi_image_1'])) {
618
  array_push($multi_images, $data['multi_image_1']);
619
  }
620
- if(isset($data['multi_image_2']) && !empty($data['multi_image_2'])) {
621
  array_push($multi_images, $data['multi_image_2']);
622
  }
623
- if(isset($data['multi_image_3']) && !empty($data['multi_image_3'])) {
624
  array_push($multi_images, $data['multi_image_3']);
625
  }
626
- if(!empty($multi_images)) {
627
  $sendData['multi_images'] = json_encode($multi_images);
628
  }
629
  }
630
-
631
  //since V4.8.0 Check Relay and prepare Data
632
  $relayData = array();
633
  if ((int) $data['network_id'] == 2 && isset($data['post_relay_account'][0]) && !empty($data['post_relay_account'][0]) && isset($data['post_relay_delay'][0]) && !empty($data['post_relay_delay'][0])) {
@@ -718,7 +718,7 @@ class Ajax_Post {
718
  $options->_setOption('card_default_title', ((B2S_PLUGIN_USER_VERSION >= 1) ? sanitize_text_field($_POST['b2s_card_default_title']) : ''));
719
  $options->_setOption('card_default_desc', ((B2S_PLUGIN_USER_VERSION >= 1) ? sanitize_text_field($_POST['b2s_card_default_desc']) : ''));
720
  $options->_setOption('card_default_image', ((B2S_PLUGIN_USER_VERSION >= 1) ? esc_url($_POST['b2s_card_default_image']) : ''));
721
-
722
  $oembed_active = (!isset($_POST['b2s_oembed_active'])) ? 0 : 1;
723
  $options->_setOption('oembed_active', $oembed_active);
724
 
@@ -867,18 +867,19 @@ class Ajax_Post {
867
  $twitter = ((isset($_POST['b2s-auto-post-profil-dropdown-twitter']) && (int) $_POST['b2s-auto-post-profil-dropdown-twitter'] > 0) ? (int) $_POST['b2s-auto-post-profil-dropdown-twitter'] : 0);
868
  $publish = isset($_POST['b2s-settings-auto-post-publish']) && is_array($_POST['b2s-settings-auto-post-publish']) ? $_POST['b2s-settings-auto-post-publish'] : array();
869
  $update = isset($_POST['b2s-settings-auto-post-update']) && is_array($_POST['b2s-settings-auto-post-update']) ? $_POST['b2s-settings-auto-post-update'] : array();
870
-
871
  $assignUser = isset($_POST['b2s-auto-post-assign-user-data']) && is_array($_POST['b2s-auto-post-assign-user-data']) ? $_POST['b2s-auto-post-assign-user-data'] : array();
872
  $oldOptions = $options->_getOption('auto_post');
873
- if(isset($oldOptions['assignUser'])) {
 
874
  foreach ($oldOptions['assignUser'] as $k => $userId) {
875
- if(!in_array($userId, $assignUser)) {
876
  //delete assignment
877
  $assignOptions = new B2S_Options($userId);
878
  $assignAutoPostOptions = $assignOptions->_getOption('auto_post');
879
-
880
  //delete $assignAutoPostOptions['assignProfile']
881
- if(isset($assignAutoPostOptions['assignProfile']) && (int) $assignAutoPostOptions['assignProfile'] > 0) {
882
  $assignToken = B2S_Tools::getTokenById($userId);
883
  $post = array('token' => $assignToken,
884
  'action' => 'deleteUserMandant',
@@ -886,12 +887,11 @@ class Ajax_Post {
886
  'allow_delete' => true);
887
  $deleteResult = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $post));
888
  if ($deleteResult->result == true) {
889
- global $wpdb;
890
  $wpdb->delete($wpdb->prefix . 'b2s_user_network_settings', array('mandant_id' => (int) $assignAutoPostOptions['assignProfile'], 'blog_user_id' => $userId), array('%d', '%d'));
891
  }
892
  }
893
-
894
-
895
  $assignAutoPostOptions['assignBy'] = 0;
896
  $assignAutoPostOptions['assignProfile'] = 0;
897
  $assignAutoPostOptions['assignTwitter'] = 0;
@@ -900,7 +900,7 @@ class Ajax_Post {
900
  }
901
  }
902
  foreach ($assignUser as $k => $userId) {
903
- if(!isset($oldOptions['assignUser']) || !in_array($userId, $oldOptions['assignUser'])) {
904
  //assign Networkollektion and Networks
905
  $assignProfile = 0;
906
  $assignTwitter = 0;
@@ -909,16 +909,16 @@ class Ajax_Post {
909
  $mandant = $getProfileUserAuth->data->mandant;
910
  $auth = $getProfileUserAuth->data->auth;
911
  foreach ($mandant as $k => $m) {
912
- if((int) $m->id == (int) $profile) {
913
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Network/Save.php');
914
  $assignToken = B2S_Tools::getTokenById($userId);
915
  $mandantResult = B2S_Network_Save::saveUserMandant(esc_html((($m->id == 0) ? __($m->name, 'blog2social') : $m->name)), false, $assignToken);
916
- if($mandantResult['result'] == true && (int) $mandantResult['mandantId'] > 0) {
917
  $assignProfile = $mandantResult['mandantId'];
918
  }
919
  $profilData = (isset($auth->{$m->id}) && isset($auth->{$m->id}[0]) && !empty($auth->{$m->id}[0])) ? $auth->{$m->id} : array();
920
  foreach ($profilData as $k => $networkAuth) {
921
- if(isset($networkAuth->networkAuthId) && (int) $networkAuth->networkAuthId > 0) {
922
  $data = array('action' => 'approveUserAuth', 'token' => B2S_PLUGIN_TOKEN, 'networkAuthId' => (int) $networkAuth->networkAuthId, 'assignToken' => $assignToken, 'tokenBlogUserId' => B2S_PLUGIN_BLOG_USER_ID, 'assignTokenBlogUserId' => $userId, 'allow_delete' => false, 'mandantId' => $assignProfile);
923
  $assignUserAuth = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $data, 30), true);
924
  if (isset($assignUserAuth['result']) && $assignUserAuth['result'] == true && isset($assignUserAuth['assign_network_auth_id']) && (int) $assignUserAuth['assign_network_auth_id'] > 0) {
@@ -936,7 +936,7 @@ class Ajax_Post {
936
  }
937
  $wpdb->insert($wpdb->prefix . 'b2s_user_network_settings', array('blog_user_id' => (int) $userId, 'mandant_id' => $assignProfile, 'network_auth_id' => (int) $assignUserAuth['assign_network_auth_id']), array('%d', '%d', '%d'));
938
  }
939
- if((int) $networkAuth->networkAuthId == (int) $twitter && isset($assignUserAuth['assign_network_auth_id']) && (int) $assignUserAuth['assign_network_auth_id'] > 0) {
940
  $assignTwitter = (int) $assignUserAuth['assign_network_auth_id'];
941
  }
942
  }
@@ -944,7 +944,7 @@ class Ajax_Post {
944
  }
945
  }
946
  }
947
-
948
  //save flag in user autopost options
949
  $assignOptions = new B2S_Options($userId);
950
  $assignAutoPostOptions = $assignOptions->_getOption('auto_post');
@@ -954,7 +954,7 @@ class Ajax_Post {
954
  $assignOptions->_setOption('auto_post', $assignAutoPostOptions);
955
  }
956
  }
957
-
958
  $auto_post = array('active' => $active, 'profile' => $profile, 'twitter' => $twitter, 'publish' => $publish, 'update' => $update, 'best_times' => $best_times, 'assignUser' => $assignUser);
959
  $options->_setOption('auto_post', $auto_post);
960
  echo json_encode(array('result' => true));
@@ -964,14 +964,14 @@ class Ajax_Post {
964
  wp_die();
965
  }
966
  }
967
-
968
  public function autoPostAssignByDisconnect() {
969
  if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') > 0) {
970
  $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
971
  $auto_post_options = $options->_getOption('auto_post');
972
-
973
  //delete assignProfile
974
- if(isset($auto_post_options['assignProfile']) && (int) $auto_post_options['assignProfile'] > 0) {
975
  $post = array('token' => B2S_PLUGIN_TOKEN,
976
  'action' => 'deleteUserMandant',
977
  'mandantId' => (int) $auto_post_options['assignProfile'],
@@ -982,18 +982,18 @@ class Ajax_Post {
982
  $wpdb->delete($wpdb->prefix . 'b2s_user_network_settings', array('mandant_id' => (int) $auto_post_options['assignProfile'], 'blog_user_id' => B2S_PLUGIN_BLOG_USER_ID), array('%d', '%d'));
983
  }
984
  }
985
-
986
  $assignById = $auto_post_options['assignBy'];
987
  $auto_post_options['assignBy'] = 0;
988
  $auto_post_options['assignProfile'] = 0;
989
  $auto_post_options['assignTwitter'] = 0;
990
  $options->_setOption('auto_post', $auto_post_options);
991
-
992
  $assignByoptions = new B2S_Options($assignById);
993
  $assign_by_auto_post_options = $assignByoptions->_getOption('auto_post');
994
  $assignUserArray = $assign_by_auto_post_options['assignUser'];
995
  foreach ($assignUserArray as $k => $userId) {
996
- if($userId == B2S_PLUGIN_BLOG_USER_ID) {
997
  unset($assignUserArray[$k]);
998
  }
999
  }
@@ -1919,7 +1919,7 @@ class Ajax_Post {
1919
  'limit' => $limit
1920
  )
1921
  );
1922
- if((int) $_POST['networkId'] == 12 || (int) $_POST['networkId'] == 1) {
1923
  $new_template[$type]['addLink'] = ((isset($data['addLink']) && $data['addLink'] == 'false') ? false : true);
1924
  }
1925
  }
@@ -1930,7 +1930,7 @@ class Ajax_Post {
1930
 
1931
  if (((int) $_POST['networkId'] == 1 || (int) $_POST['networkId'] == 3 || (int) $_POST['networkId'] == 19) && isset($_POST['link_no_cache'])) {
1932
  $linkNoCache = B2S_Tools::getNoCacheData(B2S_PLUGIN_BLOG_USER_ID);
1933
- if(is_array($linkNoCache) && !empty($linkNoCache)) {
1934
  $linkNoCache[(int) $_POST['networkId']] = (int) $_POST['link_no_cache'];
1935
  $options->_setOption('link_no_cache', $linkNoCache);
1936
  $link_no_cache_option = true;
@@ -2191,39 +2191,39 @@ class Ajax_Post {
2191
  if (isset($_POST['b2s-re-post-profil-dropdown']) && (int) $_POST['b2s-re-post-profil-dropdown'] >= 0 && isset($_POST['b2s-re-post-profil-data-' . $_POST['b2s-re-post-profil-dropdown']]) && !empty($_POST['b2s-re-post-profil-data-' . $_POST['b2s-re-post-profil-dropdown']])) {
2192
  $networkData = json_decode(base64_decode($_POST['b2s-re-post-profil-data-' . $_POST['b2s-re-post-profil-dropdown']]));
2193
  if ($networkData !== false && is_array($networkData) && !empty($networkData)) {
2194
-
2195
  //Select Posts for Queue
2196
  $limit = 5;
2197
  $versionLimit = unserialize(B2S_PLUGIN_RE_POST_LIMIT);
2198
- if(isset($_POST['b2s-re-post-limit']) && (int) $_POST['b2s-re-post-limit'] >= 1) {
2199
  $limit = ((int) $_POST['b2s-re-post-limit'] > (int) $versionLimit[B2S_PLUGIN_USER_VERSION]) ? (int) $versionLimit[B2S_PLUGIN_USER_VERSION] : (int) $_POST['b2s-re-post-limit'];
2200
- if(isset($_POST['b2s-re-post-queue-count']) && (int) $_POST['b2s-re-post-queue-count'] >= 1) {
2201
- if((int) $_POST['b2s-re-post-queue-count'] + (int) $_POST['b2s-re-post-limit'] > (int) $versionLimit[B2S_PLUGIN_USER_VERSION]) {
2202
  $limit = (int) $versionLimit[B2S_PLUGIN_USER_VERSION] - (int) $_POST['b2s-re-post-queue-count'];
2203
  }
2204
  }
2205
  }
2206
- if($limit <= 0) {
2207
  echo json_encode(array('result' => false, 'error' => 'limit'));
2208
  wp_die();
2209
  }
2210
  global $wpdb;
2211
  $where = "";
2212
  $join = "";
2213
- if(isset($_POST['b2s-re-post-settings-option']) && (int) $_POST['b2s-re-post-settings-option'] == 1) {
2214
  //custom settings
2215
  //posttypes
2216
- if(isset($_POST['b2s-re-post-type-active']) && (int) $_POST['b2s-re-post-type-active'] == 1 && isset($_POST['b2s-re-post-type-data']) && !empty($_POST['b2s-re-post-type-data']) && is_array($_POST['b2s-re-post-type-data'])) {
2217
  $where .= " AND post_type " . ((isset($_POST['b2s-re-post-type-state']) && !empty($_POST['b2s-re-post-type-state']) && (int) $_POST['b2s-re-post-type-state'] == 1) ? 'NOT' : '') . " IN ('" . implode("','", $_POST['b2s-re-post-type-data']) . "') ";
2218
  }
2219
  //author
2220
- if(isset($_POST['b2s-re-post-author-active']) && (int) $_POST['b2s-re-post-author-active'] == 1 && isset($_POST['b2s-re-post-author-data']) && !empty($_POST['b2s-re-post-author-data']) && is_array($_POST['b2s-re-post-author-data'])) {
2221
  $where .= " AND post_author " . ((isset($_POST['b2s-re-post-author-state']) && !empty($_POST['b2s-re-post-author-state']) && (int) $_POST['b2s-re-post-author-state'] == 1) ? 'NOT' : '') . " IN ('" . implode("','", $_POST['b2s-re-post-author-data']) . "') ";
2222
  }
2223
  //Start/End Date
2224
- if(isset($_POST['b2s-re-post-date-active']) && (int) $_POST['b2s-re-post-date-active'] == 1 && isset($_POST['b2s-re-post-date-start']) && !empty($_POST['b2s-re-post-date-start']) && isset($_POST['b2s-re-post-date-end']) && !empty($_POST['b2s-re-post-date-end'])) {
2225
  //Case Startdate higher then Enddate => Switch Dates
2226
- if($_POST['b2s-re-post-date-start'] > $_POST['b2s-re-post-date-end']) {
2227
  $start = date('Y-m-d', strtotime($_POST['b2s-re-post-date-end']));
2228
  $end = date('Y-m-d', strtotime($_POST['b2s-re-post-date-start']));
2229
  } else {
@@ -2235,12 +2235,12 @@ class Ajax_Post {
2235
  $where .= " post_date " . ((isset($_POST['b2s-re-post-date-state']) && !empty($_POST['b2s-re-post-date-state']) && (int) $_POST['b2s-re-post-date-state'] == 1) ? '>' : '<=') . " '" . $end . " 23:59:59') ";
2236
  }
2237
  //categories
2238
- if(isset($_POST['b2s-re-post-categories-active']) && (int) $_POST['b2s-re-post-categories-active'] == 1 && isset($_POST['b2s-re-post-categories-data']) && !empty($_POST['b2s-re-post-categories-data']) && is_array($_POST['b2s-re-post-categories-data'])) {
2239
  $join .= " LEFT JOIN (SELECT * FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ('" . implode("','", $_POST['b2s-re-post-categories-data']) . "')) AS tr ON tr.object_id = posts.ID";
2240
  $where .= " AND term_taxonomy_id IS " . ((isset($_POST['b2s-re-post-categories-state']) && !empty($_POST['b2s-re-post-categories-state']) && (int) $_POST['b2s-re-post-categories-state'] == 1) ? '' : 'NOT') . " NULL ";
2241
  }
2242
  //include only favorites
2243
- if(isset($_POST['b2s-re-post-favorites-active']) && (int) $_POST['b2s-re-post-favorites-active'] == 1) {
2244
  $join .= " LEFT JOIN (SELECT post_id FROM {$wpdb->prefix}b2s_posts_favorites WHERE blog_user_id = '" . B2S_PLUGIN_BLOG_USER_ID . "')AS favorites ON favorites.post_id = posts.ID ";
2245
  $where .= " AND favorites.post_id IS NOT NULL ";
2246
  }
@@ -2249,7 +2249,7 @@ class Ajax_Post {
2249
  $allowedPostTypes = get_post_types(array('public' => true));
2250
  $postTypeIn = "(";
2251
  foreach ($allowedPostTypes as $k => $v) {
2252
- $postTypeIn .= "'".$v."',";
2253
  }
2254
  $postTypeIn = substr($postTypeIn, 0, -1) . ")";
2255
 
@@ -2258,35 +2258,27 @@ class Ajax_Post {
2258
  $sql .= " ORDER BY post_date ASC ";
2259
  $sql .= " LIMIT " . $limit;
2260
  $result = $wpdb->get_results($sql);
2261
- if(!is_array($result) || empty($result)) {
2262
  echo json_encode(array('result' => false, 'error' => 'no_content'));
2263
  wp_die();
2264
  } else {
2265
  //check if posts already in queue
 
2266
  $postIds = array();
2267
  for ($i = 0; $i < count($result); $i++) {
2268
  array_push($postIds, (int) $result[$i]->ID);
2269
  }
2270
- $sql = "SELECT DISTINCT post_id FROM {$wpdb->prefix}b2s_posts WHERE sched_type = '5' AND hide = '0' AND publish_date = '0000-00-00 00:00:00' AND blog_user_id = ".B2S_PLUGIN_BLOG_USER_ID." AND post_id IN (" . implode(",", $postIds) . ")";
2271
  $result = $wpdb->get_results($sql);
2272
- if(is_array($result) && !empty($result)) {
2273
  foreach ($result as $k => $v) {
2274
  $key = array_search($v->post_id, $postIds);
2275
- if($key !== false) {
2276
  unset($postIds[$key]);
2277
  }
2278
  }
2279
  }
2280
- if(isset($_POST['b2s-re-post-images-active']) && (int) $_POST['b2s-re-post-images-active'] == 1) {
2281
- foreach ($postIds as $k => $postId) {
2282
- $hook_filter = new B2S_Hook_Filter();
2283
- $images = $hook_filter->get_wp_post_image($postId);
2284
- if(empty($images)) {
2285
- unset($postIds[$k]);
2286
- }
2287
- }
2288
- }
2289
- if(empty($postIds)) {
2290
  echo json_encode(array('result' => false, 'error' => 'content_in_queue'));
2291
  wp_die();
2292
  } else {
@@ -2331,6 +2323,7 @@ class Ajax_Post {
2331
  //deprecated setting, removed in V6.5
2332
  $optionUserHashTag = (B2S_PLUGIN_USER_VERSION > 1) ? false : $options->_getOption('user_allow_hashtag');
2333
  $rePost = new B2S_RePost_Save(B2S_PLUGIN_BLOG_USER_ID, $userLang, $userTimeZoneOffset, $optionPostFormat, $optionUserHashTag, $bestTimes);
 
2334
  foreach ($postIds as $k => $postId) {
2335
  //get Postdata
2336
  $postData = get_post((int) $postId);
@@ -2338,41 +2331,48 @@ class Ajax_Post {
2338
  $content = (isset($postData->post_content) && !empty($postData->post_content)) ? trim($postData->post_content) : '';
2339
  $excerpt = (isset($postData->post_excerpt) && !empty($postData->post_excerpt)) ? trim($postData->post_excerpt) : '';
2340
  $url = get_permalink((int) $postId);
2341
- $hook_filter = new B2S_Hook_Filter();
2342
- $postImages = $hook_filter->get_wp_post_image($postId, $content);
2343
  $imageUrl = '';
2344
- if($postImages != false && !empty($postImages)) {
2345
  foreach ($postImages as $key => $value) {
2346
- if(isset($value[0]) && !empty($value[0])) {
2347
  $imageUrl = $value[0];
2348
  break;
2349
  }
2350
  }
2351
  }
 
 
 
2352
  $keywords = $hook_filter->get_wp_post_hashtag((int) $postId, get_post_type((int) $postId));
2353
  $rePost->setPostData($postId, $title, $content, $excerpt, $url, $imageUrl, $keywords);
2354
 
2355
  //calculate Post Start Date
2356
- if($shareOptionType == 0) {
2357
  $date->modify('+' . $interval . ' days');
2358
  } else {
2359
- for($daycount = 0; $daycount < $interval; $daycount++) {
2360
  $date->modify('next ' . $weekday);
2361
  }
2362
  }
2363
  $startDate = $date->format("Y-m-d");
2364
- if($shareOptionType == 0) {
2365
  $settings = array('type' => 0, 'bestTimes' => ((!empty($bestTimes)) ? true : false), 'interval' => $interval, 'weekday' => $weekday, 'time' => $timeInput);
2366
  } else {
2367
  $settings = array('type' => 1, 'bestTimes' => ((!empty($bestTimes)) ? true : false), 'interval' => $interval, 'weekday' => $weekday, 'time' => $timeInput);
2368
  }
2369
  $rePost->generatePosts($startDate, $settings, $networkData, $selectedTwitterProfile);
 
 
 
 
 
2370
  }
2371
  B2S_Heartbeat::getInstance()->postToServer();
2372
  }
2373
  }
2374
  }
2375
-
2376
  require_once(B2S_PLUGIN_DIR . 'includes/B2S/RePost/Item.php');
2377
  $rePostItem = new B2S_RePost_Item();
2378
  $queue = $rePostItem->getRePostQueueHtml();
@@ -2385,7 +2385,7 @@ class Ajax_Post {
2385
  wp_die();
2386
  }
2387
  }
2388
-
2389
  public function deleteRePostSched() {
2390
  if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') > 0) {
2391
  if (isset($_POST['postId']) && !empty($_POST['postId'])) {
@@ -2399,19 +2399,18 @@ class Ajax_Post {
2399
  global $wpdb;
2400
  $sql = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}b2s_posts WHERE sched_type = %d AND hide = %d AND publish_date = %s AND blog_user_id = %d AND post_id IN ($postIdsString)", 5, 0, '0000-00-00 00:00:00', B2S_PLUGIN_BLOG_USER_ID);
2401
  $result = $wpdb->get_results($sql);
2402
- if(is_array($result) && !empty($result)) {
2403
  $b2sPostIds = array();
2404
  foreach ($result as $k => $v) {
2405
  array_push($b2sPostIds, $v->id);
2406
  }
2407
  require_once (B2S_PLUGIN_DIR . '/includes/B2S/Post/Tools.php');
2408
  $delete = B2S_Post_Tools::deleteUserSchedPost($b2sPostIds);
2409
- if($delete['result'] == true) {
2410
  echo json_encode(array('result' => true, 'postIds' => $postIds));
2411
  wp_die();
2412
  }
2413
  }
2414
-
2415
  }
2416
  }
2417
  echo json_encode(array('result' => false));
@@ -2421,13 +2420,13 @@ class Ajax_Post {
2421
  wp_die();
2422
  }
2423
  }
2424
-
2425
  public function communityRegister() {
2426
  if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') > 0) {
2427
  if (isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['email']) && !empty($_POST['email'])) {
2428
  $postData = array('action' => 'registerCommunity', 'token' => B2S_PLUGIN_TOKEN, 'username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_POST['password']);
2429
  $repsonse = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $postData, 15), true);
2430
- if(is_array($repsonse) && !empty($repsonse) && isset($repsonse['result'])) {
2431
  echo json_encode($repsonse);
2432
  wp_die();
2433
  }
590
  $options = new B2S_Options(0, 'B2S_PLUGIN_TOS_XING_GROUP_CROSSPOSTING');
591
  $options->_setOption((int) $post['post_id'], $data['network_tos_group_id'], true);
592
  }
593
+
594
  $sendData = array("board" => isset($data['board']) ? sanitize_text_field($data['board']) : '',
595
  "group" => isset($data['group']) ? sanitize_text_field($data['group']) : '',
596
  "custom_title" => isset($data['custom_title']) ? sanitize_text_field($data['custom_title']) : '',
611
  'user_timezone' => isset($post['user_timezone']) ? (int) $post['user_timezone'] : 0,
612
  'publish_date' => isset($post['publish_date']) ? date('Y-m-d H:i:s', strtotime($post['publish_date'])) : date('Y-m-d H:i:s', current_time('timestamp'))
613
  );
614
+
615
+ if (isset($data['post_format']) && (int) $data['post_format'] == 1) {
616
  $multi_images = array();
617
+ if (isset($data['multi_image_1']) && !empty($data['multi_image_1'])) {
618
  array_push($multi_images, $data['multi_image_1']);
619
  }
620
+ if (isset($data['multi_image_2']) && !empty($data['multi_image_2'])) {
621
  array_push($multi_images, $data['multi_image_2']);
622
  }
623
+ if (isset($data['multi_image_3']) && !empty($data['multi_image_3'])) {
624
  array_push($multi_images, $data['multi_image_3']);
625
  }
626
+ if (!empty($multi_images)) {
627
  $sendData['multi_images'] = json_encode($multi_images);
628
  }
629
  }
630
+
631
  //since V4.8.0 Check Relay and prepare Data
632
  $relayData = array();
633
  if ((int) $data['network_id'] == 2 && isset($data['post_relay_account'][0]) && !empty($data['post_relay_account'][0]) && isset($data['post_relay_delay'][0]) && !empty($data['post_relay_delay'][0])) {
718
  $options->_setOption('card_default_title', ((B2S_PLUGIN_USER_VERSION >= 1) ? sanitize_text_field($_POST['b2s_card_default_title']) : ''));
719
  $options->_setOption('card_default_desc', ((B2S_PLUGIN_USER_VERSION >= 1) ? sanitize_text_field($_POST['b2s_card_default_desc']) : ''));
720
  $options->_setOption('card_default_image', ((B2S_PLUGIN_USER_VERSION >= 1) ? esc_url($_POST['b2s_card_default_image']) : ''));
721
+
722
  $oembed_active = (!isset($_POST['b2s_oembed_active'])) ? 0 : 1;
723
  $options->_setOption('oembed_active', $oembed_active);
724
 
867
  $twitter = ((isset($_POST['b2s-auto-post-profil-dropdown-twitter']) && (int) $_POST['b2s-auto-post-profil-dropdown-twitter'] > 0) ? (int) $_POST['b2s-auto-post-profil-dropdown-twitter'] : 0);
868
  $publish = isset($_POST['b2s-settings-auto-post-publish']) && is_array($_POST['b2s-settings-auto-post-publish']) ? $_POST['b2s-settings-auto-post-publish'] : array();
869
  $update = isset($_POST['b2s-settings-auto-post-update']) && is_array($_POST['b2s-settings-auto-post-update']) ? $_POST['b2s-settings-auto-post-update'] : array();
870
+
871
  $assignUser = isset($_POST['b2s-auto-post-assign-user-data']) && is_array($_POST['b2s-auto-post-assign-user-data']) ? $_POST['b2s-auto-post-assign-user-data'] : array();
872
  $oldOptions = $options->_getOption('auto_post');
873
+ if (isset($oldOptions['assignUser'])) {
874
+ global $wpdb;
875
  foreach ($oldOptions['assignUser'] as $k => $userId) {
876
+ if (!in_array($userId, $assignUser)) {
877
  //delete assignment
878
  $assignOptions = new B2S_Options($userId);
879
  $assignAutoPostOptions = $assignOptions->_getOption('auto_post');
880
+
881
  //delete $assignAutoPostOptions['assignProfile']
882
+ if (isset($assignAutoPostOptions['assignProfile']) && (int) $assignAutoPostOptions['assignProfile'] > 0) {
883
  $assignToken = B2S_Tools::getTokenById($userId);
884
  $post = array('token' => $assignToken,
885
  'action' => 'deleteUserMandant',
887
  'allow_delete' => true);
888
  $deleteResult = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $post));
889
  if ($deleteResult->result == true) {
 
890
  $wpdb->delete($wpdb->prefix . 'b2s_user_network_settings', array('mandant_id' => (int) $assignAutoPostOptions['assignProfile'], 'blog_user_id' => $userId), array('%d', '%d'));
891
  }
892
  }
893
+
894
+
895
  $assignAutoPostOptions['assignBy'] = 0;
896
  $assignAutoPostOptions['assignProfile'] = 0;
897
  $assignAutoPostOptions['assignTwitter'] = 0;
900
  }
901
  }
902
  foreach ($assignUser as $k => $userId) {
903
+ if (!isset($oldOptions['assignUser']) || !in_array($userId, $oldOptions['assignUser'])) {
904
  //assign Networkollektion and Networks
905
  $assignProfile = 0;
906
  $assignTwitter = 0;
909
  $mandant = $getProfileUserAuth->data->mandant;
910
  $auth = $getProfileUserAuth->data->auth;
911
  foreach ($mandant as $k => $m) {
912
+ if ((int) $m->id == (int) $profile) {
913
  require_once (B2S_PLUGIN_DIR . 'includes/B2S/Network/Save.php');
914
  $assignToken = B2S_Tools::getTokenById($userId);
915
  $mandantResult = B2S_Network_Save::saveUserMandant(esc_html((($m->id == 0) ? __($m->name, 'blog2social') : $m->name)), false, $assignToken);
916
+ if ($mandantResult['result'] == true && (int) $mandantResult['mandantId'] > 0) {
917
  $assignProfile = $mandantResult['mandantId'];
918
  }
919
  $profilData = (isset($auth->{$m->id}) && isset($auth->{$m->id}[0]) && !empty($auth->{$m->id}[0])) ? $auth->{$m->id} : array();
920
  foreach ($profilData as $k => $networkAuth) {
921
+ if (isset($networkAuth->networkAuthId) && (int) $networkAuth->networkAuthId > 0) {
922
  $data = array('action' => 'approveUserAuth', 'token' => B2S_PLUGIN_TOKEN, 'networkAuthId' => (int) $networkAuth->networkAuthId, 'assignToken' => $assignToken, 'tokenBlogUserId' => B2S_PLUGIN_BLOG_USER_ID, 'assignTokenBlogUserId' => $userId, 'allow_delete' => false, 'mandantId' => $assignProfile);
923
  $assignUserAuth = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $data, 30), true);
924
  if (isset($assignUserAuth['result']) && $assignUserAuth['result'] == true && isset($assignUserAuth['assign_network_auth_id']) && (int) $assignUserAuth['assign_network_auth_id'] > 0) {
936
  }
937
  $wpdb->insert($wpdb->prefix . 'b2s_user_network_settings', array('blog_user_id' => (int) $userId, 'mandant_id' => $assignProfile, 'network_auth_id' => (int) $assignUserAuth['assign_network_auth_id']), array('%d', '%d', '%d'));
938
  }
939
+ if ((int) $networkAuth->networkAuthId == (int) $twitter && isset($assignUserAuth['assign_network_auth_id']) && (int) $assignUserAuth['assign_network_auth_id'] > 0) {
940
  $assignTwitter = (int) $assignUserAuth['assign_network_auth_id'];
941
  }
942
  }
944
  }
945
  }
946
  }
947
+
948
  //save flag in user autopost options
949
  $assignOptions = new B2S_Options($userId);
950
  $assignAutoPostOptions = $assignOptions->_getOption('auto_post');
954
  $assignOptions->_setOption('auto_post', $assignAutoPostOptions);
955
  }
956
  }
957
+
958
  $auto_post = array('active' => $active, 'profile' => $profile, 'twitter' => $twitter, 'publish' => $publish, 'update' => $update, 'best_times' => $best_times, 'assignUser' => $assignUser);
959
  $options->_setOption('auto_post', $auto_post);
960
  echo json_encode(array('result' => true));
964
  wp_die();
965
  }
966
  }
967
+
968
  public function autoPostAssignByDisconnect() {
969
  if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') > 0) {
970
  $options = new B2S_Options(B2S_PLUGIN_BLOG_USER_ID);
971
  $auto_post_options = $options->_getOption('auto_post');
972
+
973
  //delete assignProfile
974
+ if (isset($auto_post_options['assignProfile']) && (int) $auto_post_options['assignProfile'] > 0) {
975
  $post = array('token' => B2S_PLUGIN_TOKEN,
976
  'action' => 'deleteUserMandant',
977
  'mandantId' => (int) $auto_post_options['assignProfile'],
982
  $wpdb->delete($wpdb->prefix . 'b2s_user_network_settings', array('mandant_id' => (int) $auto_post_options['assignProfile'], 'blog_user_id' => B2S_PLUGIN_BLOG_USER_ID), array('%d', '%d'));
983
  }
984
  }
985
+
986
  $assignById = $auto_post_options['assignBy'];
987
  $auto_post_options['assignBy'] = 0;
988
  $auto_post_options['assignProfile'] = 0;
989
  $auto_post_options['assignTwitter'] = 0;
990
  $options->_setOption('auto_post', $auto_post_options);
991
+
992
  $assignByoptions = new B2S_Options($assignById);
993
  $assign_by_auto_post_options = $assignByoptions->_getOption('auto_post');
994
  $assignUserArray = $assign_by_auto_post_options['assignUser'];
995
  foreach ($assignUserArray as $k => $userId) {
996
+ if ($userId == B2S_PLUGIN_BLOG_USER_ID) {
997
  unset($assignUserArray[$k]);
998
  }
999
  }
1919
  'limit' => $limit
1920
  )
1921
  );
1922
+ if ((int) $_POST['networkId'] == 12 || (int) $_POST['networkId'] == 1) {
1923
  $new_template[$type]['addLink'] = ((isset($data['addLink']) && $data['addLink'] == 'false') ? false : true);
1924
  }
1925
  }
1930
 
1931
  if (((int) $_POST['networkId'] == 1 || (int) $_POST['networkId'] == 3 || (int) $_POST['networkId'] == 19) && isset($_POST['link_no_cache'])) {
1932
  $linkNoCache = B2S_Tools::getNoCacheData(B2S_PLUGIN_BLOG_USER_ID);
1933
+ if (is_array($linkNoCache) && !empty($linkNoCache)) {
1934
  $linkNoCache[(int) $_POST['networkId']] = (int) $_POST['link_no_cache'];
1935
  $options->_setOption('link_no_cache', $linkNoCache);
1936
  $link_no_cache_option = true;
2191
  if (isset($_POST['b2s-re-post-profil-dropdown']) && (int) $_POST['b2s-re-post-profil-dropdown'] >= 0 && isset($_POST['b2s-re-post-profil-data-' . $_POST['b2s-re-post-profil-dropdown']]) && !empty($_POST['b2s-re-post-profil-data-' . $_POST['b2s-re-post-profil-dropdown']])) {
2192
  $networkData = json_decode(base64_decode($_POST['b2s-re-post-profil-data-' . $_POST['b2s-re-post-profil-dropdown']]));
2193
  if ($networkData !== false && is_array($networkData) && !empty($networkData)) {
2194
+
2195
  //Select Posts for Queue
2196
  $limit = 5;
2197
  $versionLimit = unserialize(B2S_PLUGIN_RE_POST_LIMIT);
2198
+ if (isset($_POST['b2s-re-post-limit']) && (int) $_POST['b2s-re-post-limit'] >= 1) {
2199
  $limit = ((int) $_POST['b2s-re-post-limit'] > (int) $versionLimit[B2S_PLUGIN_USER_VERSION]) ? (int) $versionLimit[B2S_PLUGIN_USER_VERSION] : (int) $_POST['b2s-re-post-limit'];
2200
+ if (isset($_POST['b2s-re-post-queue-count']) && (int) $_POST['b2s-re-post-queue-count'] >= 1) {
2201
+ if ((int) $_POST['b2s-re-post-queue-count'] + (int) $_POST['b2s-re-post-limit'] > (int) $versionLimit[B2S_PLUGIN_USER_VERSION]) {
2202
  $limit = (int) $versionLimit[B2S_PLUGIN_USER_VERSION] - (int) $_POST['b2s-re-post-queue-count'];
2203
  }
2204
  }
2205
  }
2206
+ if ($limit <= 0) {
2207
  echo json_encode(array('result' => false, 'error' => 'limit'));
2208
  wp_die();
2209
  }
2210
  global $wpdb;
2211
  $where = "";
2212
  $join = "";
2213
+ if (isset($_POST['b2s-re-post-settings-option']) && (int) $_POST['b2s-re-post-settings-option'] == 1) {
2214
  //custom settings
2215
  //posttypes
2216
+ if (isset($_POST['b2s-re-post-type-active']) && (int) $_POST['b2s-re-post-type-active'] == 1 && isset($_POST['b2s-re-post-type-data']) && !empty($_POST['b2s-re-post-type-data']) && is_array($_POST['b2s-re-post-type-data'])) {
2217
  $where .= " AND post_type " . ((isset($_POST['b2s-re-post-type-state']) && !empty($_POST['b2s-re-post-type-state']) && (int) $_POST['b2s-re-post-type-state'] == 1) ? 'NOT' : '') . " IN ('" . implode("','", $_POST['b2s-re-post-type-data']) . "') ";
2218
  }
2219
  //author
2220
+ if (isset($_POST['b2s-re-post-author-active']) && (int) $_POST['b2s-re-post-author-active'] == 1 && isset($_POST['b2s-re-post-author-data']) && !empty($_POST['b2s-re-post-author-data']) && is_array($_POST['b2s-re-post-author-data'])) {
2221
  $where .= " AND post_author " . ((isset($_POST['b2s-re-post-author-state']) && !empty($_POST['b2s-re-post-author-state']) && (int) $_POST['b2s-re-post-author-state'] == 1) ? 'NOT' : '') . " IN ('" . implode("','", $_POST['b2s-re-post-author-data']) . "') ";
2222
  }
2223
  //Start/End Date
2224
+ if (isset($_POST['b2s-re-post-date-active']) && (int) $_POST['b2s-re-post-date-active'] == 1 && isset($_POST['b2s-re-post-date-start']) && !empty($_POST['b2s-re-post-date-start']) && isset($_POST['b2s-re-post-date-end']) && !empty($_POST['b2s-re-post-date-end'])) {
2225
  //Case Startdate higher then Enddate => Switch Dates
2226
+ if ($_POST['b2s-re-post-date-start'] > $_POST['b2s-re-post-date-end']) {
2227
  $start = date('Y-m-d', strtotime($_POST['b2s-re-post-date-end']));
2228
  $end = date('Y-m-d', strtotime($_POST['b2s-re-post-date-start']));
2229
  } else {
2235
  $where .= " post_date " . ((isset($_POST['b2s-re-post-date-state']) && !empty($_POST['b2s-re-post-date-state']) && (int) $_POST['b2s-re-post-date-state'] == 1) ? '>' : '<=') . " '" . $end . " 23:59:59') ";
2236
  }
2237
  //categories
2238
+ if (isset($_POST['b2s-re-post-categories-active']) && (int) $_POST['b2s-re-post-categories-active'] == 1 && isset($_POST['b2s-re-post-categories-data']) && !empty($_POST['b2s-re-post-categories-data']) && is_array($_POST['b2s-re-post-categories-data'])) {
2239
  $join .= " LEFT JOIN (SELECT * FROM $wpdb->term_relationships WHERE term_taxonomy_id IN ('" . implode("','", $_POST['b2s-re-post-categories-data']) . "')) AS tr ON tr.object_id = posts.ID";
2240
  $where .= " AND term_taxonomy_id IS " . ((isset($_POST['b2s-re-post-categories-state']) && !empty($_POST['b2s-re-post-categories-state']) && (int) $_POST['b2s-re-post-categories-state'] == 1) ? '' : 'NOT') . " NULL ";
2241
  }
2242
  //include only favorites
2243
+ if (isset($_POST['b2s-re-post-favorites-active']) && (int) $_POST['b2s-re-post-favorites-active'] == 1) {
2244
  $join .= " LEFT JOIN (SELECT post_id FROM {$wpdb->prefix}b2s_posts_favorites WHERE blog_user_id = '" . B2S_PLUGIN_BLOG_USER_ID . "')AS favorites ON favorites.post_id = posts.ID ";
2245
  $where .= " AND favorites.post_id IS NOT NULL ";
2246
  }
2249
  $allowedPostTypes = get_post_types(array('public' => true));
2250
  $postTypeIn = "(";
2251
  foreach ($allowedPostTypes as $k => $v) {
2252
+ $postTypeIn .= "'" . $v . "',";
2253
  }
2254
  $postTypeIn = substr($postTypeIn, 0, -1) . ")";
2255
 
2258
  $sql .= " ORDER BY post_date ASC ";
2259
  $sql .= " LIMIT " . $limit;
2260
  $result = $wpdb->get_results($sql);
2261
+ if (!is_array($result) || empty($result)) {
2262
  echo json_encode(array('result' => false, 'error' => 'no_content'));
2263
  wp_die();
2264
  } else {
2265
  //check if posts already in queue
2266
+ $hook_filter = new B2S_Hook_Filter();
2267
  $postIds = array();
2268
  for ($i = 0; $i < count($result); $i++) {
2269
  array_push($postIds, (int) $result[$i]->ID);
2270
  }
2271
+ $sql = "SELECT DISTINCT post_id FROM {$wpdb->prefix}b2s_posts WHERE sched_type = '5' AND hide = '0' AND publish_date = '0000-00-00 00:00:00' AND blog_user_id = " . B2S_PLUGIN_BLOG_USER_ID . " AND post_id IN (" . implode(",", $postIds) . ")";
2272
  $result = $wpdb->get_results($sql);
2273
+ if (is_array($result) && !empty($result)) {
2274
  foreach ($result as $k => $v) {
2275
  $key = array_search($v->post_id, $postIds);
2276
+ if ($key !== false) {
2277
  unset($postIds[$key]);
2278
  }
2279
  }
2280
  }
2281
+ if (empty($postIds)) {
 
 
 
 
 
 
 
 
 
2282
  echo json_encode(array('result' => false, 'error' => 'content_in_queue'));
2283
  wp_die();
2284
  } else {
2323
  //deprecated setting, removed in V6.5
2324
  $optionUserHashTag = (B2S_PLUGIN_USER_VERSION > 1) ? false : $options->_getOption('user_allow_hashtag');
2325
  $rePost = new B2S_RePost_Save(B2S_PLUGIN_BLOG_USER_ID, $userLang, $userTimeZoneOffset, $optionPostFormat, $optionUserHashTag, $bestTimes);
2326
+ $countPosts = 0;
2327
  foreach ($postIds as $k => $postId) {
2328
  //get Postdata
2329
  $postData = get_post((int) $postId);
2331
  $content = (isset($postData->post_content) && !empty($postData->post_content)) ? trim($postData->post_content) : '';
2332
  $excerpt = (isset($postData->post_excerpt) && !empty($postData->post_excerpt)) ? trim($postData->post_excerpt) : '';
2333
  $url = get_permalink((int) $postId);
2334
+ $postImages = $hook_filter->get_wp_post_image($postId, true, $content);
 
2335
  $imageUrl = '';
2336
+ if ($postImages != false && !empty($postImages)) {
2337
  foreach ($postImages as $key => $value) {
2338
+ if (isset($value[0]) && !empty($value[0])) {
2339
  $imageUrl = $value[0];
2340
  break;
2341
  }
2342
  }
2343
  }
2344
+ if (empty($imageUrl) && isset($_POST['b2s-re-post-images-active']) && (int) $_POST['b2s-re-post-images-active'] == 1) {
2345
+ continue;
2346
+ }
2347
  $keywords = $hook_filter->get_wp_post_hashtag((int) $postId, get_post_type((int) $postId));
2348
  $rePost->setPostData($postId, $title, $content, $excerpt, $url, $imageUrl, $keywords);
2349
 
2350
  //calculate Post Start Date
2351
+ if ($shareOptionType == 0) {
2352
  $date->modify('+' . $interval . ' days');
2353
  } else {
2354
+ for ($daycount = 0; $daycount < $interval; $daycount++) {
2355
  $date->modify('next ' . $weekday);
2356
  }
2357
  }
2358
  $startDate = $date->format("Y-m-d");
2359
+ if ($shareOptionType == 0) {
2360
  $settings = array('type' => 0, 'bestTimes' => ((!empty($bestTimes)) ? true : false), 'interval' => $interval, 'weekday' => $weekday, 'time' => $timeInput);
2361
  } else {
2362
  $settings = array('type' => 1, 'bestTimes' => ((!empty($bestTimes)) ? true : false), 'interval' => $interval, 'weekday' => $weekday, 'time' => $timeInput);
2363
  }
2364
  $rePost->generatePosts($startDate, $settings, $networkData, $selectedTwitterProfile);
2365
+ $countPosts++;
2366
+ }
2367
+ if($countPosts == 0) {
2368
+ echo json_encode(array('result' => false, 'error' => 'no_content'));
2369
+ wp_die();
2370
  }
2371
  B2S_Heartbeat::getInstance()->postToServer();
2372
  }
2373
  }
2374
  }
2375
+
2376
  require_once(B2S_PLUGIN_DIR . 'includes/B2S/RePost/Item.php');
2377
  $rePostItem = new B2S_RePost_Item();
2378
  $queue = $rePostItem->getRePostQueueHtml();
2385
  wp_die();
2386
  }
2387
  }
2388
+
2389
  public function deleteRePostSched() {
2390
  if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') > 0) {
2391
  if (isset($_POST['postId']) && !empty($_POST['postId'])) {
2399
  global $wpdb;
2400
  $sql = $wpdb->prepare("SELECT id FROM {$wpdb->prefix}b2s_posts WHERE sched_type = %d AND hide = %d AND publish_date = %s AND blog_user_id = %d AND post_id IN ($postIdsString)", 5, 0, '0000-00-00 00:00:00', B2S_PLUGIN_BLOG_USER_ID);
2401
  $result = $wpdb->get_results($sql);
2402
+ if (is_array($result) && !empty($result)) {
2403
  $b2sPostIds = array();
2404
  foreach ($result as $k => $v) {
2405
  array_push($b2sPostIds, $v->id);
2406
  }
2407
  require_once (B2S_PLUGIN_DIR . '/includes/B2S/Post/Tools.php');
2408
  $delete = B2S_Post_Tools::deleteUserSchedPost($b2sPostIds);
2409
+ if ($delete['result'] == true) {
2410
  echo json_encode(array('result' => true, 'postIds' => $postIds));
2411
  wp_die();
2412
  }
2413
  }
 
2414
  }
2415
  }
2416
  echo json_encode(array('result' => false));
2420
  wp_die();
2421
  }
2422
  }
2423
+
2424
  public function communityRegister() {
2425
  if (isset($_POST['b2s_security_nonce']) && (int) wp_verify_nonce($_POST['b2s_security_nonce'], 'b2s_security_nonce') > 0) {
2426
  if (isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['password']) && !empty($_POST['password']) && isset($_POST['email']) && !empty($_POST['email'])) {
2427
  $postData = array('action' => 'registerCommunity', 'token' => B2S_PLUGIN_TOKEN, 'username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_POST['password']);
2428
  $repsonse = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, $postData, 15), true);
2429
+ if (is_array($repsonse) && !empty($repsonse) && isset($repsonse['result'])) {
2430
  echo json_encode($repsonse);
2431
  wp_die();
2432
  }
includes/B2S/Hook/Filter.php CHANGED
@@ -24,8 +24,8 @@ class B2S_Hook_Filter{
24
  return $wp_hashtags;
25
  }
26
 
27
- function get_wp_post_image($post_id = 0, $postContent = '', $postUrl = '', $network = false, $postLang = 'en') {
28
- $images = B2S_Util::getImagesByPostId((int) $post_id, $postContent, $postUrl, $network, $postLang);
29
  $wp_images = apply_filters('b2s_filter_wp_post_image', $images, $post_id);
30
  return $wp_images;
31
  }
24
  return $wp_hashtags;
25
  }
26
 
27
+ function get_wp_post_image($post_id = 0, $forceFeaturedImage = true, $postContent = '', $postUrl = '', $network = false, $postLang = 'en') {
28
+ $images = B2S_Util::getImagesByPostId((int) $post_id, $forceFeaturedImage, $postContent, $postUrl, $network, $postLang);
29
  $wp_images = apply_filters('b2s_filter_wp_post_image', $images, $post_id);
30
  return $wp_images;
31
  }
includes/B2S/Post/Filter.php CHANGED
@@ -107,46 +107,35 @@ class B2S_Post_Filter {
107
  $taxonomies = get_taxonomies(array('public' => true), "object", "and");
108
  $type = '<div class="form-group"><select id="b2sSortPostCat" name="b2sSortPostCat" class="form-control b2s-select"><option value="">' . esc_html__('all categories & tags', 'blog2social') . '</option>';
109
  foreach ($taxonomies as $tax => $taxValue) {
110
- $cat = get_categories(array('taxonomy' => $taxValue->name, 'number' => 100, 'parent' => 0)); //since 3.7.0 => all too much load
111
- if (!empty($cat)) {
112
- $type.='<optgroup label="' . esc_attr($taxValue->labels->name) . '">';
113
- foreach ($cat as $key => $categorie) {
114
- $selected = (!empty($this->searchPostCat) && $categorie->term_id == $this->searchPostCat) ? 'selected' : '';
115
- $catName = $categorie->name;
116
- //Bug: Converting json + PHP Extension
117
- if (function_exists('mb_strlen') && function_exists('mb_substr')) {
118
- $catName = mb_strlen($categorie->name, 'UTF-8') > 27 ? mb_substr($categorie->name, 0, 27, 'UTF-8') . '...' : $catName;
119
  }
120
- $type .= '<option ' . $selected . ' value="' . esc_attr($categorie->term_id) . '">' . esc_html($catName) . '</option>';
121
-
122
- $type .= $this->getPostSubCatHtml($taxValue,$categorie->term_id, '&nbsp;&nbsp;&nbsp;&nbsp;');
123
  }
124
- $type .='</optgroup>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  }
126
  }
127
  $type .= '</select></div>';
128
  return $type;
129
  }
130
-
131
- private function getPostSubCatHtml($taxValue = false, $catId = false, $add = '') {
132
- $type = '';
133
- //subcategorys
134
- $subCat = get_categories(array('taxonomy' => $taxValue->name, 'number' => 100, 'parent' => $catId));
135
- if(isset($subCat) && !empty($subCat)) {
136
- foreach ($subCat as $subKey => $subCategorie) {
137
- $selected = (!empty($this->searchPostCat) && $subCategorie->term_id == $this->searchPostCat) ? 'selected' : '';
138
- $subCatName = $add.$subCategorie->name;
139
- //Bug: Converting json + PHP Extension
140
- if (function_exists('mb_strlen') && function_exists('mb_substr')) {
141
- $subCatName = mb_strlen($subCategorie->name, 'UTF-8') > 27 ? mb_substr($subCategorie->name, 0, 27, 'UTF-8') . '...' : $subCatName;
142
- }
143
- $type .= '<option ' . $selected . ' value="' . esc_attr($subCategorie->term_id) . '">' . esc_html($subCatName) . '</option>';
144
- $type .= $this->getPostSubCatHtml($taxValue, $subCategorie->term_id, $add.'&nbsp;&nbsp;&nbsp;&nbsp;');
145
- }
146
- }
147
-
148
- return $type;
149
- }
150
 
151
  private function getPostTypeHtml() {
152
  $type = '<div class="form-group"><select id="b2sSortPostType" name="b2sSortPostType" class="form-control b2s-select"><option value="">' . esc_html__('all post types', 'blog2social') . '</option>';
107
  $taxonomies = get_taxonomies(array('public' => true), "object", "and");
108
  $type = '<div class="form-group"><select id="b2sSortPostCat" name="b2sSortPostCat" class="form-control b2s-select"><option value="">' . esc_html__('all categories & tags', 'blog2social') . '</option>';
109
  foreach ($taxonomies as $tax => $taxValue) {
110
+ if($taxValue->name == 'category') {
111
+ if(function_exists('wp_dropdown_categories')) {
112
+ $cat = wp_dropdown_categories(array('hierarchical' => 1, 'echo' => 0, 'taxonomy' => $taxValue->name, 'selected' => (!empty($this->searchPostCat) && (int) $this->searchPostCat > 0) ? (int) $this->searchPostCat : 0));
113
+ if (!empty($cat)) {
114
+ $type .='<optgroup label="' . esc_attr($taxValue->labels->name) . '">';
115
+ $type .= preg_replace('/<(|\/)select.*?>/', '', $cat);
116
+ $type .='</optgroup>';
 
 
117
  }
 
 
 
118
  }
119
+ } else {
120
+ $cat = get_categories(array('taxonomy' => $taxValue->name, 'number' => 100, 'parent' => 0)); //since 3.7.0 => all too much load
121
+ if (!empty($cat)) {
122
+ $type.='<optgroup label="' . esc_attr($taxValue->labels->name) . '">';
123
+ foreach ($cat as $key => $category) {
124
+ $selected = (!empty($this->searchPostCat) && $category->term_id == $this->searchPostCat) ? 'selected' : '';
125
+ $catName = $category->name;
126
+ //Bug: Converting json + PHP Extension
127
+ if (function_exists('mb_strlen') && function_exists('mb_substr')) {
128
+ $catName = mb_strlen($category->name, 'UTF-8') > 27 ? mb_substr($category->name, 0, 27, 'UTF-8') . '...' : $catName;
129
+ }
130
+ $type .= '<option ' . $selected . ' value="' . esc_attr($category->term_id) . '">' . esc_html($catName) . '</option>';
131
+ }
132
+ $type .='</optgroup>';
133
+ }
134
  }
135
  }
136
  $type .= '</select></div>';
137
  return $type;
138
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
  private function getPostTypeHtml() {
141
  $type = '<div class="form-group"><select id="b2sSortPostType" name="b2sSortPostType" class="form-control b2s-select"><option value="">' . esc_html__('all post types', 'blog2social') . '</option>';
includes/B2S/Ship/Image.php CHANGED
@@ -20,7 +20,7 @@ class B2S_Ship_Image {
20
  $imageData = $this->imageData;
21
  } else {
22
  $hook_filter = new B2S_Hook_Filter();
23
- $imageData = $hook_filter->get_wp_post_image($postId, $postContent, $postUrl, true, $userLang);
24
  }
25
 
26
  $isImage = (is_array($imageData) && !empty($imageData)) ? true : false;
20
  $imageData = $this->imageData;
21
  } else {
22
  $hook_filter = new B2S_Hook_Filter();
23
+ $imageData = $hook_filter->get_wp_post_image($postId, false, $postContent, $postUrl, true, $userLang);
24
  }
25
 
26
  $isImage = (is_array($imageData) && !empty($imageData)) ? true : false;
includes/B2S/Ship/Item.php CHANGED
@@ -76,6 +76,7 @@ class B2S_Ship_Item {
76
  private $b2sPostType;
77
  private $options;
78
  private $post_template;
 
79
 
80
  public function __construct($postId, $userLang = 'en', $selSchedDate = "", $b2sPostType = "", $relayCount = 0) {
81
  $this->postId = $postId;
@@ -85,6 +86,8 @@ class B2S_Ship_Item {
85
  $this->b2sPostType = (!empty($b2sPostType) ? $b2sPostType : ( (isset($this->postData->post_type) && $this->postData->post_type == 'b2s_ex_post') ? 'ex' : ''));
86
  $this->postUrl = ($this->b2sPostType == 'ex') ? ((stripos($this->postData->guid, 'b2s_ex_post') != false) ? '' : $this->postData->guid) : (get_permalink($this->postData->ID) !== false ? get_permalink($this->postData->ID) : $this->postData->guid);
87
  $this->userLang = $userLang;
 
 
88
  $this->selSchedDate = $selSchedDate;
89
  $this->setRelayCount = $relayCount;
90
  }
@@ -178,8 +181,7 @@ class B2S_Ship_Item {
178
 
179
  //Feature Image Html-Network
180
  if (in_array($data->networkId, $this->allowHtml)) {
181
- $hook_filter = new B2S_Hook_Filter();
182
- $images_urls = $hook_filter->get_wp_post_image((int) $this->postId);
183
  $featuredImage = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
184
  if ($featuredImage !== false) {
185
  $title = in_array($data->networkId, $this->allowNoEmoji) ? B2S_Util::remove4byte(B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang)) : B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang);
@@ -199,8 +201,7 @@ class B2S_Ship_Item {
199
 
200
  //Feature Image Html-Network
201
  if (in_array($data->networkId, $this->allowHtml)) {
202
- $hook_filter = new B2S_Hook_Filter();
203
- $images_urls = $hook_filter->get_wp_post_image((int) $this->postId);
204
  $featuredImage = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
205
  if ($featuredImage !== false) {
206
  $title = in_array($data->networkId, $this->allowNoEmoji) ? B2S_Util::remove4byte(B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang)) : B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang);
@@ -953,7 +954,7 @@ class B2S_Ship_Item {
953
  }
954
 
955
  $url .= (!$hideInfo) ? '<div class="b2s-post-item-details-url-title hidden-xs">Link ' . $isRequiredText . '</div>' : '';
956
-
957
  if ($networkId == 12 && isset($this->post_template[$networkId][$networkType]['addLink']) && $this->post_template[$networkId][$networkType]['addLink'] == false) {
958
  $urlValue = '';
959
  } else if ($networkId == 1 && isset($this->post_template[$networkId][$networkType]['format']) && (int) $this->post_template[$networkId][$networkType]['format'] == 1 && isset($this->post_template[$networkId][$networkType]['addLink']) && $this->post_template[$networkId][$networkType]['addLink'] == false) {
@@ -994,8 +995,7 @@ class B2S_Ship_Item {
994
  }
995
 
996
  private function getHashTagsString($add = "\n\n", $limit = 0) {
997
- $hook_filter = new B2S_Hook_Filter();
998
- $hashTagsData = $hook_filter->get_wp_post_hashtag((int) $this->postId, $this->postData->post_type);
999
  $hashTags = '';
1000
  if (is_array($hashTagsData) && !empty($hashTagsData)) {
1001
  foreach ($hashTagsData as $tag) {
@@ -1004,7 +1004,7 @@ class B2S_Ship_Item {
1004
  continue;
1005
  }
1006
  }
1007
- $hashTags .= ' #' . str_replace(array(" ", "-", '"', "'", "!", "?", ",", ".", ";", ":"), "", $tag->name);
1008
  }
1009
  }
1010
  return (!empty($hashTags) ? (!empty($add) ? $add . $hashTags : $hashTags) : '');
@@ -1063,8 +1063,7 @@ class B2S_Ship_Item {
1063
  }
1064
  $tags .= '<div class="b2s-post-item-details-tag-title"> ' . esc_html__('Hashtags', 'blog2social') . ' ' . $info . ' </div>';
1065
  $tags .= '<div class="b2s-post-item-details-tag-input form-inline">';
1066
- $hook_filter = new B2S_Hook_Filter();
1067
- $posttags = $hook_filter->get_wp_post_hashtag((int) $this->postId, $this->postData->post_type);
1068
  $countTags = 0;
1069
  $limit = false;
1070
  if ($posttags && $allowTags) {
@@ -1397,8 +1396,7 @@ class B2S_Ship_Item {
1397
  }
1398
 
1399
  if (isset($this->postData->post_author) && (int) $this->postData->post_author > 0) {
1400
- $hook_filter = new B2S_Hook_Filter();
1401
- $author_name = $hook_filter->get_wp_user_post_author_display_name((int) $this->postData->post_author);
1402
  $message = stripslashes(preg_replace("/\{AUTHOR\}/", addcslashes($author_name, "\\$"), $message));
1403
  } else {
1404
  $message = preg_replace("/\{AUTHOR\}/", "", $message);
76
  private $b2sPostType;
77
  private $options;
78
  private $post_template;
79
+ private $hook_filter;
80
 
81
  public function __construct($postId, $userLang = 'en', $selSchedDate = "", $b2sPostType = "", $relayCount = 0) {
82
  $this->postId = $postId;
86
  $this->b2sPostType = (!empty($b2sPostType) ? $b2sPostType : ( (isset($this->postData->post_type) && $this->postData->post_type == 'b2s_ex_post') ? 'ex' : ''));
87
  $this->postUrl = ($this->b2sPostType == 'ex') ? ((stripos($this->postData->guid, 'b2s_ex_post') != false) ? '' : $this->postData->guid) : (get_permalink($this->postData->ID) !== false ? get_permalink($this->postData->ID) : $this->postData->guid);
88
  $this->userLang = $userLang;
89
+ $this->hook_filter = new B2S_Hook_Filter();
90
+
91
  $this->selSchedDate = $selSchedDate;
92
  $this->setRelayCount = $relayCount;
93
  }
181
 
182
  //Feature Image Html-Network
183
  if (in_array($data->networkId, $this->allowHtml)) {
184
+ $images_urls = $this->hook_filter->get_wp_post_image((int) $this->postId);
 
185
  $featuredImage = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
186
  if ($featuredImage !== false) {
187
  $title = in_array($data->networkId, $this->allowNoEmoji) ? B2S_Util::remove4byte(B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang)) : B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang);
201
 
202
  //Feature Image Html-Network
203
  if (in_array($data->networkId, $this->allowHtml)) {
204
+ $images_urls = $this->hook_filter->get_wp_post_image((int) $this->postId);
 
205
  $featuredImage = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
206
  if ($featuredImage !== false) {
207
  $title = in_array($data->networkId, $this->allowNoEmoji) ? B2S_Util::remove4byte(B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang)) : B2S_Util::getTitleByLanguage($this->postData->post_title, $this->userLang);
954
  }
955
 
956
  $url .= (!$hideInfo) ? '<div class="b2s-post-item-details-url-title hidden-xs">Link ' . $isRequiredText . '</div>' : '';
957
+
958
  if ($networkId == 12 && isset($this->post_template[$networkId][$networkType]['addLink']) && $this->post_template[$networkId][$networkType]['addLink'] == false) {
959
  $urlValue = '';
960
  } else if ($networkId == 1 && isset($this->post_template[$networkId][$networkType]['format']) && (int) $this->post_template[$networkId][$networkType]['format'] == 1 && isset($this->post_template[$networkId][$networkType]['addLink']) && $this->post_template[$networkId][$networkType]['addLink'] == false) {
995
  }
996
 
997
  private function getHashTagsString($add = "\n\n", $limit = 0) {
998
+ $hashTagsData = $this->hook_filter->get_wp_post_hashtag((int) $this->postId, $this->postData->post_type);
 
999
  $hashTags = '';
1000
  if (is_array($hashTagsData) && !empty($hashTagsData)) {
1001
  foreach ($hashTagsData as $tag) {
1004
  continue;
1005
  }
1006
  }
1007
+ $hashTags .= ' #' . str_replace(array(" ", "-", '"', "'", "!", "?", ",", ".", ";", ":"), "", (function_exists('htmlspecialchars_decode') ? htmlspecialchars_decode($tag->name) : $tag->name));
1008
  }
1009
  }
1010
  return (!empty($hashTags) ? (!empty($add) ? $add . $hashTags : $hashTags) : '');
1063
  }
1064
  $tags .= '<div class="b2s-post-item-details-tag-title"> ' . esc_html__('Hashtags', 'blog2social') . ' ' . $info . ' </div>';
1065
  $tags .= '<div class="b2s-post-item-details-tag-input form-inline">';
1066
+ $posttags = $this->hook_filter->get_wp_post_hashtag((int) $this->postId, $this->postData->post_type);
 
1067
  $countTags = 0;
1068
  $limit = false;
1069
  if ($posttags && $allowTags) {
1396
  }
1397
 
1398
  if (isset($this->postData->post_author) && (int) $this->postData->post_author > 0) {
1399
+ $author_name = $this->hook_filter->get_wp_user_post_author_display_name((int) $this->postData->post_author);
 
1400
  $message = stripslashes(preg_replace("/\{AUTHOR\}/", addcslashes($author_name, "\\$"), $message));
1401
  } else {
1402
  $message = preg_replace("/\{AUTHOR\}/", "", $message);
includes/B2S/Support/Check/System.php CHANGED
@@ -161,7 +161,6 @@ class B2S_Support_Check_System {
161
  private function getHotlinkProtection() {
162
  $image_uri = B2S_PLUGIN_DIR . '/assets/images/b2s/b2s_logo.png';
163
  $image_url = plugins_url('/assets/images/b2s/b2s_logo.png', B2S_PLUGIN_FILE);
164
- $image_url = "https://app-development.blog2social.com/images/29/post/6906.jpg";
165
  if (file_exists($image_uri)) {
166
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, array(
167
  "action" => 'checkSysReq',
161
  private function getHotlinkProtection() {
162
  $image_uri = B2S_PLUGIN_DIR . '/assets/images/b2s/b2s_logo.png';
163
  $image_url = plugins_url('/assets/images/b2s/b2s_logo.png', B2S_PLUGIN_FILE);
 
164
  if (file_exists($image_uri)) {
165
  $result = json_decode(B2S_Api_Post::post(B2S_PLUGIN_API_ENDPOINT, array(
166
  "action" => 'checkSysReq',
includes/Loader.php CHANGED
@@ -282,17 +282,17 @@ class B2S_Loader {
282
 
283
  if ($limit) {
284
  global $wpdb;
 
285
  $optionPostFormat = $options->_getOption('post_template');
286
  $url = get_permalink($post->ID);
287
  $title = isset($post->post_title) ? B2S_Util::getTitleByLanguage(strip_tags($post->post_title)) : '';
288
- $hook_filter = new B2S_Hook_Filter();
289
  $keywords = $hook_filter->get_wp_post_hashtag((int) $post->ID, $post->post_type);
290
  if(($keywords == false || empty($keywords)) && is_plugin_active('wp-automatic/wp-automatic.php')) {
291
  $keywords = B2S_Tools::extractKeywords($title);
292
  }
293
  $content = (isset($post->post_content) && !empty($post->post_content)) ? trim($post->post_content) : '';
294
  $excerpt = (isset($post->post_excerpt) && !empty($post->post_excerpt)) ? trim($post->post_excerpt) : '';
295
- $images_urls = $hook_filter->get_wp_post_image((int) $post->ID, $content);
296
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
297
  $delay = (isset($autoPostData['ship_state']) && (int) $autoPostData['ship_state'] = 0) ? 0 : (isset($autoPostData['ship_delay_time']) ? (int) $autoPostData['ship_delay_time'] : 0);
298
  $current_user_datetime = date('Y-m-d H:i:s', strtotime(B2S_Util::getUTCForDate($current_utc_datetime, $userTimeZoneOffset)));
@@ -455,7 +455,7 @@ class B2S_Loader {
455
  $_POST['content'] = $content->post_content;
456
  }
457
  }
458
-
459
  $b2sPostLang = (isset($_POST['b2s-user-lang']) && !empty($_POST['b2s-user-lang'])) ? sanitize_text_field($_POST['b2s-user-lang']) : 'en';
460
  //OgMeta
461
  if (isset($_POST['isOgMetaChecked']) && (int) $_POST['isOgMetaChecked'] == 1 && (int) $_POST['post_ID'] > 0 && isset($_POST['content']) && isset($_POST['post_title'])) {
@@ -467,8 +467,7 @@ class B2S_Loader {
467
  } else {
468
  $desc = str_replace("\r\n", ' ', substr(sanitize_textarea_field(strip_shortcodes($_POST['content'])), 0, 160));
469
  }
470
- $hook_filter = new B2S_Hook_Filter();
471
- $images_urls = $hook_filter->get_wp_post_image((int) $_POST['post_ID'], ((isset($_POST['content']) && !empty($_POST['content'])) ? trim($_POST['content']) : ''));
472
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
473
  $meta->setMeta('og_title', $title);
474
  $meta->setMeta('og_desc', $desc);
@@ -486,8 +485,7 @@ class B2S_Loader {
486
  } else {
487
  $desc = str_replace("\r\n", ' ', substr(sanitize_textarea_field(strip_shortcodes($_POST['content'])), 0, 160));
488
  }
489
- $hook_filter = new B2S_Hook_Filter();
490
- $images_urls = $hook_filter->get_wp_post_image((int) $_POST['post_ID'], ((isset($_POST['content']) && !empty($_POST['content'])) ? trim($_POST['content']) : ''));
491
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
492
  $meta->setMeta('card_title', $title);
493
  $meta->setMeta('card_desc', $desc);
@@ -573,8 +571,7 @@ class B2S_Loader {
573
  $title = isset($_POST['post_title']) ? B2S_Util::getTitleByLanguage(strip_tags($_POST['post_title']), strtolower($b2sPostLang)) : '';
574
  $content = (isset($_POST['content']) && !empty($_POST['content'])) ? trim($_POST['content']) : '';
575
  $excerpt = (isset($_POST['excerpt']) && !empty($_POST['excerpt'])) ? trim($_POST['excerpt']) : get_the_excerpt((int) $_POST['post_ID']);
576
- $hook_filter = new B2S_Hook_Filter();
577
- $images_urls = $hook_filter->get_wp_post_image((int) $_POST['post_ID'], $content);
578
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
579
 
580
  $options = new B2S_Options((int) $_POST['user_ID']);
282
 
283
  if ($limit) {
284
  global $wpdb;
285
+ $hook_filter = new B2S_Hook_Filter();
286
  $optionPostFormat = $options->_getOption('post_template');
287
  $url = get_permalink($post->ID);
288
  $title = isset($post->post_title) ? B2S_Util::getTitleByLanguage(strip_tags($post->post_title)) : '';
 
289
  $keywords = $hook_filter->get_wp_post_hashtag((int) $post->ID, $post->post_type);
290
  if(($keywords == false || empty($keywords)) && is_plugin_active('wp-automatic/wp-automatic.php')) {
291
  $keywords = B2S_Tools::extractKeywords($title);
292
  }
293
  $content = (isset($post->post_content) && !empty($post->post_content)) ? trim($post->post_content) : '';
294
  $excerpt = (isset($post->post_excerpt) && !empty($post->post_excerpt)) ? trim($post->post_excerpt) : '';
295
+ $images_urls = $hook_filter->get_wp_post_image((int) $post->ID, true, $content);
296
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
297
  $delay = (isset($autoPostData['ship_state']) && (int) $autoPostData['ship_state'] = 0) ? 0 : (isset($autoPostData['ship_delay_time']) ? (int) $autoPostData['ship_delay_time'] : 0);
298
  $current_user_datetime = date('Y-m-d H:i:s', strtotime(B2S_Util::getUTCForDate($current_utc_datetime, $userTimeZoneOffset)));
455
  $_POST['content'] = $content->post_content;
456
  }
457
  }
458
+ $hook_filter = new B2S_Hook_Filter();
459
  $b2sPostLang = (isset($_POST['b2s-user-lang']) && !empty($_POST['b2s-user-lang'])) ? sanitize_text_field($_POST['b2s-user-lang']) : 'en';
460
  //OgMeta
461
  if (isset($_POST['isOgMetaChecked']) && (int) $_POST['isOgMetaChecked'] == 1 && (int) $_POST['post_ID'] > 0 && isset($_POST['content']) && isset($_POST['post_title'])) {
467
  } else {
468
  $desc = str_replace("\r\n", ' ', substr(sanitize_textarea_field(strip_shortcodes($_POST['content'])), 0, 160));
469
  }
470
+ $images_urls = $hook_filter->get_wp_post_image((int) $_POST['post_ID'], true, ((isset($_POST['content']) && !empty($_POST['content'])) ? trim($_POST['content']) : ''));
 
471
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
472
  $meta->setMeta('og_title', $title);
473
  $meta->setMeta('og_desc', $desc);
485
  } else {
486
  $desc = str_replace("\r\n", ' ', substr(sanitize_textarea_field(strip_shortcodes($_POST['content'])), 0, 160));
487
  }
488
+ $images_urls = $hook_filter->get_wp_post_image((int) $_POST['post_ID'], true, ((isset($_POST['content']) && !empty($_POST['content'])) ? trim($_POST['content']) : ''));
 
489
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
490
  $meta->setMeta('card_title', $title);
491
  $meta->setMeta('card_desc', $desc);
571
  $title = isset($_POST['post_title']) ? B2S_Util::getTitleByLanguage(strip_tags($_POST['post_title']), strtolower($b2sPostLang)) : '';
572
  $content = (isset($_POST['content']) && !empty($_POST['content'])) ? trim($_POST['content']) : '';
573
  $excerpt = (isset($_POST['excerpt']) && !empty($_POST['excerpt'])) ? trim($_POST['excerpt']) : get_the_excerpt((int) $_POST['post_ID']);
574
+ $images_urls = $hook_filter->get_wp_post_image((int) $_POST['post_ID'], true, $content);
 
575
  $image_url = ((!empty($images_urls) && isset(array_values($images_urls)[0][0])) ? array_values($images_urls)[0][0] : false);
576
 
577
  $options = new B2S_Options((int) $_POST['user_ID']);
includes/Meta.php CHANGED
@@ -181,6 +181,7 @@ class B2S_Meta {
181
  private function getImage($type = 'og') {
182
 
183
  $image = '';
 
184
  if (!is_home()) {
185
  if (isset($this->metaData[$type . '_image']) && !empty($this->metaData[$type . '_image'])) {
186
  $image = $this->metaData[$type . '_image'];
@@ -189,6 +190,10 @@ class B2S_Meta {
189
  if (isset($this->post->ID)) {
190
  if ($id_attachment = get_post_thumbnail_id($this->post->ID)) {
191
  $image = wp_get_attachment_url($id_attachment, false);
 
 
 
 
192
  if (!preg_match('/^https?:\/\//', $image)) {
193
  // Remove any starting slash with ltrim() and add one to the end of site_url()
194
  $image = site_url('/') . ltrim($image, '/');
@@ -212,9 +217,11 @@ class B2S_Meta {
212
  if (!empty($image)) {
213
  if ($this->print) {
214
  if ($type == 'og') {
215
- $image_size = getimagesize($image);
 
 
216
  $size = "";
217
- if(isset($image_size[0]) && (int) $image_size[0] > 0 && isset($image_size[1]) && (int) $image_size[1] > 0) {
218
  $size = '<meta property="og:image:width" content="' . $image_size[0] . '"/>' . "\n";
219
  $size .= '<meta property="og:image:height" content="' . $image_size[1] . '"/>' . "\n";
220
  }
181
  private function getImage($type = 'og') {
182
 
183
  $image = '';
184
+ $image_size = array();
185
  if (!is_home()) {
186
  if (isset($this->metaData[$type . '_image']) && !empty($this->metaData[$type . '_image'])) {
187
  $image = $this->metaData[$type . '_image'];
190
  if (isset($this->post->ID)) {
191
  if ($id_attachment = get_post_thumbnail_id($this->post->ID)) {
192
  $image = wp_get_attachment_url($id_attachment, false);
193
+ $imageMetaData = wp_get_attachment_metadata($id_attachment);
194
+ if (isset($imageMetaData['width']) && isset($imageMetaData['height'])) {
195
+ $image_size = array($imageMetaData['width'], $imageMetaData['height']);
196
+ }
197
  if (!preg_match('/^https?:\/\//', $image)) {
198
  // Remove any starting slash with ltrim() and add one to the end of site_url()
199
  $image = site_url('/') . ltrim($image, '/');
217
  if (!empty($image)) {
218
  if ($this->print) {
219
  if ($type == 'og') {
220
+ if (empty($image_size)) {
221
+ $image_size = @getimagesize($image);
222
+ }
223
  $size = "";
224
+ if (isset($image_size[0]) && (int) $image_size[0] > 0 && isset($image_size[1]) && (int) $image_size[1] > 0) {
225
  $size = '<meta property="og:image:width" content="' . $image_size[0] . '"/>' . "\n";
226
  $size .= '<meta property="og:image:height" content="' . $image_size[1] . '"/>' . "\n";
227
  }
includes/PRG/Ship/Image.php CHANGED
@@ -9,7 +9,7 @@ class PRG_Ship_Image {
9
  public function getItemHtml($postId,$postContent,$postUrl,$userLang='en') {
10
  $content = '';
11
  $hook_filter = new B2S_Hook_Filter();
12
- $imageData = $hook_filter->get_wp_post_image($postId,$postContent,$postUrl, true,$userLang);
13
  $isImage = (is_array($imageData) && !empty($imageData)) ? true : false;
14
 
15
  if ($isImage) {
9
  public function getItemHtml($postId,$postContent,$postUrl,$userLang='en') {
10
  $content = '';
11
  $hook_filter = new B2S_Hook_Filter();
12
+ $imageData = $hook_filter->get_wp_post_image($postId, false, $postContent,$postUrl, true,$userLang);
13
  $isImage = (is_array($imageData) && !empty($imageData)) ? true : false;
14
 
15
  if ($isImage) {
includes/Util.php CHANGED
@@ -219,28 +219,29 @@ class B2S_Util {
219
  return $list;
220
  }
221
 
222
- public static function getImagesByPostId($postId = 0, $postContent = '', $postUrl = '', $network = false, $postLang = 'en') {
 
223
  $homeUrl = get_site_url();
224
  $scheme = parse_url($homeUrl, PHP_URL_SCHEME);
225
  $featuredImage = wp_get_attachment_url(get_post_thumbnail_id($postId));
226
- $content = self::getFullContent($postId, $postContent, $postUrl, $postLang);
227
-
228
- $matches = array();
229
- if (!preg_match_all('%<img.*?src=[\"\'](.*?)[\"\'].*?>%', $content, $matches) && !$featuredImage) {
230
- return false;
 
 
 
231
  }
232
- array_unshift($matches[1], $featuredImage);
233
  $rtrnArray = array();
234
  foreach ($matches[1] as $key => $imgUrl) {
235
  if ($imgUrl == false) {
236
  continue;
237
  }
238
-
239
  //AllowedExtensions?
240
  if (!$network && !in_array(substr($imgUrl, strrpos($imgUrl, '.')), array('.jpg', '.png'))) {
241
  continue;
242
  }
243
-
244
  //isRelativ?
245
  if (!preg_match('/((http|https):\/\/|(www.))/', $imgUrl)) {
246
  //StartWith //
@@ -256,12 +257,10 @@ class B2S_Util {
256
  }
257
  }
258
  }
259
-
260
  /* $file_headers = @get_headers($imgUrl);
261
  if ((!is_array($file_headers)) || (is_array($file_headers) && !preg_match('/200/', $file_headers[0]))) {
262
  continue;
263
  } */
264
-
265
  $rtrnArray[$key][0] = urldecode($imgUrl);
266
  }
267
  return $rtrnArray;
219
  return $list;
220
  }
221
 
222
+ public static function getImagesByPostId($postId = 0, $forceFeaturedImage = true, $postContent = '', $postUrl = '', $network = false, $postLang = 'en') {
223
+ $matches = array();
224
  $homeUrl = get_site_url();
225
  $scheme = parse_url($homeUrl, PHP_URL_SCHEME);
226
  $featuredImage = wp_get_attachment_url(get_post_thumbnail_id($postId));
227
+ if($forceFeaturedImage && $featuredImage != false && !empty($featuredImage)) {
228
+ $matches = array(1 => array(0 => $featuredImage));
229
+ } else {
230
+ $content = self::getFullContent($postId, $postContent, $postUrl, $postLang);
231
+ if (!preg_match_all('%<img.*?src=[\"\'](.*?)[\"\'].*?>%', $content, $matches) && !$featuredImage) {
232
+ return false;
233
+ }
234
+ array_unshift($matches[1], $featuredImage);
235
  }
 
236
  $rtrnArray = array();
237
  foreach ($matches[1] as $key => $imgUrl) {
238
  if ($imgUrl == false) {
239
  continue;
240
  }
 
241
  //AllowedExtensions?
242
  if (!$network && !in_array(substr($imgUrl, strrpos($imgUrl, '.')), array('.jpg', '.png'))) {
243
  continue;
244
  }
 
245
  //isRelativ?
246
  if (!preg_match('/((http|https):\/\/|(www.))/', $imgUrl)) {
247
  //StartWith //
257
  }
258
  }
259
  }
 
260
  /* $file_headers = @get_headers($imgUrl);
261
  if ((!is_array($file_headers)) || (is_array($file_headers) && !preg_match('/200/', $file_headers[0]))) {
262
  continue;
263
  } */
 
264
  $rtrnArray[$key][0] = urldecode($imgUrl);
265
  }
266
  return $rtrnArray;
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: 5.5
8
- Stable tag: 6.5.0
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -218,6 +218,8 @@ To get started with the basics of Blog2Social and maybe find some useful tips an
218
  7. Keep track of your shared posts and scheduling plan with the Social Media Calendar.
219
 
220
  == Changelog ==
 
 
221
  = 6.5.0 =
222
  Multiple image post & Telegram Network
223
  = 6.4.2 =
@@ -288,6 +290,8 @@ Usability Optimization
288
  Content Curation with links, WooCommerce compatibility, gutenberg editor compatibility
289
 
290
  == Upgrade Notice ==
 
 
291
  = 6.5.0 =
292
  Multiple image post & Telegram Network
293
  = 6.4.2 =
5
  Donate link: https://paypal.me/adenion
6
  Requires at least: 4.7.0
7
  Tested up to: 5.5
8
+ Stable tag: 6.5.1
9
  License: GPLv3
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
218
  7. Keep track of your shared posts and scheduling plan with the Social Media Calendar.
219
 
220
  == Changelog ==
221
+ = 6.5.1 =
222
+ Usability Optimization
223
  = 6.5.0 =
224
  Multiple image post & Telegram Network
225
  = 6.4.2 =
290
  Content Curation with links, WooCommerce compatibility, gutenberg editor compatibility
291
 
292
  == Upgrade Notice ==
293
+ = 6.5.1 =
294
+ Usability Optimization
295
  = 6.5.0 =
296
  Multiple image post & Telegram Network
297
  = 6.4.2 =