Changeset 2825896
- Timestamp:
- 11/29/2022 12:21:57 PM (3 years ago)
- Location:
- crowdaa-sync
- Files:
-
- 6 edited
- 74 copied
-
tags/1.7.0 (copied) (copied from crowdaa-sync/trunk)
-
tags/1.7.0/CHANGELOG (copied) (copied from crowdaa-sync/trunk/CHANGELOG) (1 diff)
-
tags/1.7.0/LICENSE.txt (copied) (copied from crowdaa-sync/trunk/LICENSE.txt)
-
tags/1.7.0/README.txt (copied) (copied from crowdaa-sync/trunk/README.txt) (1 diff)
-
tags/1.7.0/admin (copied) (copied from crowdaa-sync/trunk/admin)
-
tags/1.7.0/admin/class-crowdaa-sync-add-info-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-api.php) (7 diffs)
-
tags/1.7.0/admin/class-crowdaa-sync-add-info-wp.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-wp.php) (4 diffs)
-
tags/1.7.0/admin/class-crowdaa-sync-admin-display.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-admin-display.php)
-
tags/1.7.0/admin/class-crowdaa-sync-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-api.php) (8 diffs)
-
tags/1.7.0/admin/class-crowdaa-sync-ext-hooks.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-ext-hooks.php)
-
tags/1.7.0/admin/class-crowdaa-sync-meta-box.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-meta-box.php)
-
tags/1.7.0/admin/class-crowdaa-sync-rest-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-rest-api.php)
-
tags/1.7.0/admin/class-crowdaa-sync-wp-hooks.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-wp-hooks.php)
-
tags/1.7.0/admin/css/crowdaa-sync-admin.css (copied) (copied from crowdaa-sync/trunk/admin/css/crowdaa-sync-admin.css)
-
tags/1.7.0/admin/js/crowdaa-sync-admin.js (copied) (copied from crowdaa-sync/trunk/admin/js/crowdaa-sync-admin.js)
-
tags/1.7.0/admin/partials/crowdaa-sync-admin-display.php (copied) (copied from crowdaa-sync/trunk/admin/partials/crowdaa-sync-admin-display.php)
-
tags/1.7.0/cacert.pem (copied) (copied from crowdaa-sync/trunk/cacert.pem)
-
tags/1.7.0/composer.json (copied) (copied from crowdaa-sync/trunk/composer.json)
-
tags/1.7.0/crowdaa-sync.php (copied) (copied from crowdaa-sync/trunk/crowdaa-sync.php) (2 diffs)
-
tags/1.7.0/includes (copied) (copied from crowdaa-sync/trunk/includes)
-
tags/1.7.0/includes/class-crowdaa-sync-exception.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-exception.php)
-
tags/1.7.0/includes/class-crowdaa-sync-permissions.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-permissions.php)
-
tags/1.7.0/includes/class-crowdaa-sync-syncdb.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-syncdb.php)
-
tags/1.7.0/includes/class-crowdaa-sync-timer.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-timer.php)
-
tags/1.7.0/includes/class-crowdaa-sync-utils.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-utils.php)
-
tags/1.7.0/includes/class-crowdaa-sync-versions.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-versions.php)
-
tags/1.7.0/includes/class-crowdaa-sync.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync.php)
-
tags/1.7.0/index.php (copied) (copied from crowdaa-sync/trunk/index.php)
-
tags/1.7.0/languages (copied) (copied from crowdaa-sync/trunk/languages)
-
tags/1.7.0/public (copied) (copied from crowdaa-sync/trunk/public)
-
tags/1.7.0/uninstall.php (copied) (copied from crowdaa-sync/trunk/uninstall.php)
-
tags/1.7.0/vendor (copied) (copied from crowdaa-sync/trunk/vendor)
-
tags/1.7.0/vendor/bin (copied) (copied from crowdaa-sync/trunk/vendor/bin)
-
tags/1.7.0/vendor/composer/autoload_psr4.php (copied) (copied from crowdaa-sync/trunk/vendor/composer/autoload_psr4.php)
-
tags/1.7.0/vendor/composer/autoload_static.php (copied) (copied from crowdaa-sync/trunk/vendor/composer/autoload_static.php)
-
tags/1.7.0/vendor/composer/installed.json (copied) (copied from crowdaa-sync/trunk/vendor/composer/installed.json)
-
tags/1.7.0/vendor/firebase (copied) (copied from crowdaa-sync/trunk/vendor/firebase)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/CHANGELOG.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/CHANGELOG.md)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/README.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/README.md)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/composer.json (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/composer.json)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Cookie/CookieJar.php)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/Handler/StreamHandler.php)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/MessageFormatter.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/MessageFormatter.php)
-
tags/1.7.0/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php)
-
tags/1.7.0/vendor/guzzlehttp/promises/CHANGELOG.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/CHANGELOG.md)
-
tags/1.7.0/vendor/guzzlehttp/promises/src/EachPromise.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/src/EachPromise.php)
-
tags/1.7.0/vendor/guzzlehttp/promises/src/FulfilledPromise.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/src/FulfilledPromise.php)
-
tags/1.7.0/vendor/guzzlehttp/promises/src/RejectedPromise.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/promises/src/RejectedPromise.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/CHANGELOG.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/CHANGELOG.md)
-
tags/1.7.0/vendor/guzzlehttp/psr7/README.md (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/README.md)
-
tags/1.7.0/vendor/guzzlehttp/psr7/composer.json (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/composer.json)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/CachingStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/CachingStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/DroppingStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/DroppingStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/FnStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/FnStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/Header.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Header.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/InflateStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/InflateStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/LazyOpenStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/LazyOpenStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/LimitStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/LimitStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/Message.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Message.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/MessageTrait.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/MessageTrait.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/MimeType.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/MimeType.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/MultipartStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/MultipartStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/NoSeekStream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/NoSeekStream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/Query.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Query.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/ServerRequest.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/ServerRequest.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/Stream.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Stream.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/Uri.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Uri.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/UriComparator.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/UriComparator.php)
-
tags/1.7.0/vendor/guzzlehttp/psr7/src/Utils.php (copied) (copied from crowdaa-sync/trunk/vendor/guzzlehttp/psr7/src/Utils.php)
-
tags/1.7.0/vendor/symfony/deprecation-contracts/LICENSE (copied) (copied from crowdaa-sync/trunk/vendor/symfony/deprecation-contracts/LICENSE)
-
tags/1.7.0/vendor/symfony/deprecation-contracts/composer.json (copied) (copied from crowdaa-sync/trunk/vendor/symfony/deprecation-contracts/composer.json)
-
trunk/CHANGELOG (modified) (1 diff)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/class-crowdaa-sync-add-info-api.php (modified) (7 diffs)
-
trunk/admin/class-crowdaa-sync-add-info-wp.php (modified) (4 diffs)
-
trunk/admin/class-crowdaa-sync-api.php (modified) (8 diffs)
-
trunk/crowdaa-sync.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
crowdaa-sync/tags/1.7.0/CHANGELOG
r2818151 r2825896 6 6 7 7 ## [Unreleased] 8 9 ## [1.7.0] - 2022-11-29 10 11 ### Added 12 13 - Support for multi-categories synchronization 14 15 ### Changed 16 17 - Fixed issues/typos in medias synchronizations 18 - Fixed a typo when creating a checksum of a category 8 19 9 20 ## [1.6.3] - 2022-11-15 -
crowdaa-sync/tags/1.7.0/README.txt
r2818151 r2825896 6 6 Requires PHP: 7.3 7 7 Tested up to: 5.9 8 Stable tag: 1. 6.38 Stable tag: 1.7.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crowdaa-sync/tags/1.7.0/admin/class-crowdaa-sync-add-info-api.php
r2805875 r2825896 147 147 148 148 if (Crowdaa_Sync_Utils::have_plugin('custom-category-image')) { 149 if ( $category->picture) {149 if (isset($category->picture) && $category->picture) { 150 150 if (is_object($category->picture[0]) && isset($category->picture[0]->pictureUrl)) { 151 151 $data['picture'] = $category->picture[0]->_id; … … 1197 1197 } 1198 1198 1199 $args = array(1200 'hide_empty' => false,1201 'taxonomy' => 'category',1202 'childless' => true,1203 );1204 $all_child_terms = get_terms($args);1205 $child_terms = [];1206 foreach ($all_child_terms as $child_term) {1207 $child_terms[] = $child_term->term_id;1208 }1209 1210 1199 $feed_categories = get_option('crowdaa_sync_feed_categories', 'all'); 1211 1200 if ($feed_categories !== 'all') { … … 1228 1217 $child_term = false; 1229 1218 $post_terms = get_the_terms($post['post_id'], 'category'); 1230 $post_term = null;1231 1219 if(empty($post_terms)) { 1232 1220 Crowdaa_Sync_Logs::log('No categories for this post, skipping...'); … … 1236 1224 $whitelisted = ($sync_categories_mode !== 'whitelist'); 1237 1225 $blacklisted = false; 1226 $allowed_term_ids = []; 1238 1227 foreach ($post_terms as $term) { 1239 1228 if (in_array($term->term_id, $sync_categories_list)) { 1240 1229 if ($sync_categories_mode === 'blacklist') { 1241 1230 $blacklisted = $term->term_id; 1231 break; 1242 1232 } else { 1243 1233 $whitelisted = $term->term_id; 1244 if (!$post_term) { 1245 $post_term = [ 1246 'id' => $term->term_id, 1247 'child' => in_array($term->term_id, $child_terms), 1248 ]; 1249 } else if (!$post_term['child'] && in_array($term->term_id, $child_terms)) { 1250 $post_term = [ 1251 'id' => $term->term_id, 1252 'child' => true, 1253 ]; 1254 } 1234 $allowed_term_ids[] = $term->term_id; 1255 1235 } 1256 1236 } else if ( … … 1258 1238 !$blacklisted 1259 1239 ) { 1260 if (!$post_term) { 1261 $post_term = [ 1262 'id' => $term->term_id, 1263 'child' => in_array($term->term_id, $child_terms), 1264 ]; 1265 } else if (!$post_term['child'] && in_array($term->term_id, $child_terms)) { 1266 $post_term = [ 1267 'id' => $term->term_id, 1268 'child' => true, 1269 ]; 1270 } 1240 $allowed_term_ids[] = $term->term_id; 1271 1241 } 1272 1242 } … … 1305 1275 } 1306 1276 1307 // Get category API ID 1308 $api_term_id = $cat_wp_to_api_id[$post_term['id']]; 1309 if (!$api_term_id) { 1277 // Get categories API IDs 1278 $api_term_ids = []; 1279 foreach ($allowed_term_ids as $ids) { 1280 $api_term_id = @$cat_wp_to_api_id[$ids]; 1281 if ($api_term_id) { 1282 $api_term_ids[] = $api_term_id; 1283 } 1284 } 1285 if (!$api_term_ids) { 1310 1286 throw new Crowdaa_Sync_Post_Error('Could not find synced category for term '.$post_term['id'].'. This should not happen, aborting sync.'); 1311 1287 … … 1326 1302 // Update post 1327 1303 if(in_array($post, $only_wp, true)) { 1328 $sync_api->create_post_api($api_term_id , $post['post_id'], $feed_display);1304 $sync_api->create_post_api($api_term_ids, $post['post_id'], $feed_display); 1329 1305 } else { 1330 $sync_api->update_draft_post_api($api_term_id , $post['post_id'], $post['api_id'], $feed_display);1306 $sync_api->update_draft_post_api($api_term_ids, $post['post_id'], $post['api_id'], $feed_display); 1331 1307 } 1332 1308 } catch (Crowdaa_Sync_Post_Skip_Error $e) { -
crowdaa-sync/tags/1.7.0/admin/class-crowdaa-sync-add-info-wp.php
r2776976 r2825896 248 248 $cat_sync_db = new Crowdaa_Sync_Syncdb('categories'); 249 249 250 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 251 $term = (int) $term->wp_id; 250 if (isset($api_data->categories)) { 251 $api_ids = []; 252 foreach ($api_data->categories as $category) { 253 $api_ids[] = $category->_id; 254 } 255 $terms = $cat_sync_db->get_entries_with_api_ids($api_ids, 'wp_id'); 256 $terms = Crowdaa_Sync_Utils::object_array_extract_field('wp_id', $terms); 257 } else { 258 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 259 $terms = [(int) $term->wp_id]; 260 } 252 261 253 262 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); … … 274 283 update_post_meta($wp_post_id, 'display_option_fullscreen', ($fullscreen ? 'yes' : 'no')); 275 284 276 wp_set_post_terms($wp_post_id, [$term], 'category');285 wp_set_post_terms($wp_post_id, $terms, 'category'); 277 286 278 287 $sync_errors = $this->post_sync_api_medias($api_data, $wp_post_id); … … 307 316 $cat_sync_db = new Crowdaa_Sync_Syncdb('categories'); 308 317 309 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 310 $term = (int) $term->wp_id; 318 if (isset($api_data->categories)) { 319 $api_ids = []; 320 foreach ($api_data->categories as $category) { 321 $api_ids[] = $category->_id; 322 } 323 $terms = $cat_sync_db->get_entries_with_api_ids($api_ids, 'wp_id'); 324 $terms = Crowdaa_Sync_Utils::object_array_extract_field('wp_id', $terms); 325 } else { 326 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 327 $terms = [(int) $term->wp_id]; 328 } 311 329 312 330 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); … … 322 340 // } 323 341 324 wp_set_post_terms($wp_post_id, [$term], 'category');342 wp_set_post_terms($wp_post_id, $terms, 'category'); 325 343 wp_update_post($data); 326 344 update_post_meta($wp_post_id, 'api_post_id', $api_data->_id); -
crowdaa-sync/tags/1.7.0/admin/class-crowdaa-sync-api.php
r2762188 r2825896 201 201 'actions' => [], 202 202 'authorName' => $post_author, 203 'categoryId' => $category_id,204 203 'feedPicture' => $api_feedpicture_id, 205 204 'md' => $post_content ?: __('Without content', CROWDAA_SYNC_PLUGIN_NAME), … … 215 214 ], 216 215 ]; 216 if (is_array($category_id)) { 217 $data['categoriesId'] = $category_id; 218 } else { 219 $data['categoryId'] = $category_id; 220 } 217 221 $data = apply_filters('crowdaa_sync_api_update_article_payload', $data, $wp_post_id); 218 222 … … 314 318 } 315 319 316 if(!$article_data['categoryId'] ) {320 if(!$article_data['categoryId'] && !$article_data['categoriesId']) { 317 321 throw new Crowdaa_Sync_Post_Skip_Error(__('Unable to create article without Category', CROWDAA_SYNC_PLUGIN_NAME)); 318 322 } … … 375 379 } 376 380 377 if(!$article_data['categoryId'] ) {381 if(!$article_data['categoryId'] && !$article_data['categoriesId']) { 378 382 throw new Crowdaa_Sync_Post_Skip_Error(__('Unable to update article without Category', CROWDAA_SYNC_PLUGIN_NAME)); 379 383 } … … 465 469 'actions' => [], 466 470 'authorName' => $post_author, 467 'categoryId' => $category_id,468 471 'feedPicture' => $api_feedpicture_id, 469 472 'md' => $post_content ?: __('Without content', CROWDAA_SYNC_PLUGIN_NAME), … … 479 482 ], 480 483 ]; 484 if (is_array($category_id)) { 485 $data['categoriesId'] = $category_id; 486 } else { 487 $data['categoryId'] = $category_id; 488 } 481 489 $data = apply_filters('crowdaa_sync_api_create_article_payload', $data, $wp_post_id); 482 490 … … 591 599 } else if ($gallery_ids === ''.$default_image['attachment_id'] && $thumbnail_id !== null) { 592 600 $gallery_ids = ''.$thumbnail_id; 593 $api_media_map[$api_feedpicture_id ] = [594 'attachment_id' => $ attachment_id,601 $api_media_map[$api_feedpicture_id['api_id']] = [ 602 'attachment_id' => $thumbnail_id, 595 603 'image' => true, 596 604 ]; … … 615 623 update_post_meta($wp_post_id, 'api_media_map', serialize($api_media_map)); 616 624 } else if ($thumbnail_id && $attachment_id == $thumbnail_id) { 617 $api_media_map[$api_feedpicture_id ] = [625 $api_media_map[$api_feedpicture_id['api_id']] = [ 618 626 'attachment_id' => $attachment_id, 619 627 'image' => true, -
crowdaa-sync/tags/1.7.0/crowdaa-sync.php
r2818151 r2825896 14 14 * Plugin URI: 15 15 * Description: Plugin for synchronizing WordPress site and Crowdaa CMS 16 * Version: 1. 6.316 * Version: 1.7.0 17 17 * Requires at least: 5.5 18 18 * Requires PHP: 7.2 … … 34 34 * Uses SemVer - https://semver.org 35 35 */ 36 define('CROWDAA_SYNC_VERSION', '1. 6.3');36 define('CROWDAA_SYNC_VERSION', '1.7.0'); 37 37 define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__); 38 38 define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync'); -
crowdaa-sync/trunk/CHANGELOG
r2818151 r2825896 6 6 7 7 ## [Unreleased] 8 9 ## [1.7.0] - 2022-11-29 10 11 ### Added 12 13 - Support for multi-categories synchronization 14 15 ### Changed 16 17 - Fixed issues/typos in medias synchronizations 18 - Fixed a typo when creating a checksum of a category 8 19 9 20 ## [1.6.3] - 2022-11-15 -
crowdaa-sync/trunk/README.txt
r2818151 r2825896 6 6 Requires PHP: 7.3 7 7 Tested up to: 5.9 8 Stable tag: 1. 6.38 Stable tag: 1.7.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-api.php
r2805875 r2825896 147 147 148 148 if (Crowdaa_Sync_Utils::have_plugin('custom-category-image')) { 149 if ( $category->picture) {149 if (isset($category->picture) && $category->picture) { 150 150 if (is_object($category->picture[0]) && isset($category->picture[0]->pictureUrl)) { 151 151 $data['picture'] = $category->picture[0]->_id; … … 1197 1197 } 1198 1198 1199 $args = array(1200 'hide_empty' => false,1201 'taxonomy' => 'category',1202 'childless' => true,1203 );1204 $all_child_terms = get_terms($args);1205 $child_terms = [];1206 foreach ($all_child_terms as $child_term) {1207 $child_terms[] = $child_term->term_id;1208 }1209 1210 1199 $feed_categories = get_option('crowdaa_sync_feed_categories', 'all'); 1211 1200 if ($feed_categories !== 'all') { … … 1228 1217 $child_term = false; 1229 1218 $post_terms = get_the_terms($post['post_id'], 'category'); 1230 $post_term = null;1231 1219 if(empty($post_terms)) { 1232 1220 Crowdaa_Sync_Logs::log('No categories for this post, skipping...'); … … 1236 1224 $whitelisted = ($sync_categories_mode !== 'whitelist'); 1237 1225 $blacklisted = false; 1226 $allowed_term_ids = []; 1238 1227 foreach ($post_terms as $term) { 1239 1228 if (in_array($term->term_id, $sync_categories_list)) { 1240 1229 if ($sync_categories_mode === 'blacklist') { 1241 1230 $blacklisted = $term->term_id; 1231 break; 1242 1232 } else { 1243 1233 $whitelisted = $term->term_id; 1244 if (!$post_term) { 1245 $post_term = [ 1246 'id' => $term->term_id, 1247 'child' => in_array($term->term_id, $child_terms), 1248 ]; 1249 } else if (!$post_term['child'] && in_array($term->term_id, $child_terms)) { 1250 $post_term = [ 1251 'id' => $term->term_id, 1252 'child' => true, 1253 ]; 1254 } 1234 $allowed_term_ids[] = $term->term_id; 1255 1235 } 1256 1236 } else if ( … … 1258 1238 !$blacklisted 1259 1239 ) { 1260 if (!$post_term) { 1261 $post_term = [ 1262 'id' => $term->term_id, 1263 'child' => in_array($term->term_id, $child_terms), 1264 ]; 1265 } else if (!$post_term['child'] && in_array($term->term_id, $child_terms)) { 1266 $post_term = [ 1267 'id' => $term->term_id, 1268 'child' => true, 1269 ]; 1270 } 1240 $allowed_term_ids[] = $term->term_id; 1271 1241 } 1272 1242 } … … 1305 1275 } 1306 1276 1307 // Get category API ID 1308 $api_term_id = $cat_wp_to_api_id[$post_term['id']]; 1309 if (!$api_term_id) { 1277 // Get categories API IDs 1278 $api_term_ids = []; 1279 foreach ($allowed_term_ids as $ids) { 1280 $api_term_id = @$cat_wp_to_api_id[$ids]; 1281 if ($api_term_id) { 1282 $api_term_ids[] = $api_term_id; 1283 } 1284 } 1285 if (!$api_term_ids) { 1310 1286 throw new Crowdaa_Sync_Post_Error('Could not find synced category for term '.$post_term['id'].'. This should not happen, aborting sync.'); 1311 1287 … … 1326 1302 // Update post 1327 1303 if(in_array($post, $only_wp, true)) { 1328 $sync_api->create_post_api($api_term_id , $post['post_id'], $feed_display);1304 $sync_api->create_post_api($api_term_ids, $post['post_id'], $feed_display); 1329 1305 } else { 1330 $sync_api->update_draft_post_api($api_term_id , $post['post_id'], $post['api_id'], $feed_display);1306 $sync_api->update_draft_post_api($api_term_ids, $post['post_id'], $post['api_id'], $feed_display); 1331 1307 } 1332 1308 } catch (Crowdaa_Sync_Post_Skip_Error $e) { -
crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-wp.php
r2776976 r2825896 248 248 $cat_sync_db = new Crowdaa_Sync_Syncdb('categories'); 249 249 250 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 251 $term = (int) $term->wp_id; 250 if (isset($api_data->categories)) { 251 $api_ids = []; 252 foreach ($api_data->categories as $category) { 253 $api_ids[] = $category->_id; 254 } 255 $terms = $cat_sync_db->get_entries_with_api_ids($api_ids, 'wp_id'); 256 $terms = Crowdaa_Sync_Utils::object_array_extract_field('wp_id', $terms); 257 } else { 258 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 259 $terms = [(int) $term->wp_id]; 260 } 252 261 253 262 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); … … 274 283 update_post_meta($wp_post_id, 'display_option_fullscreen', ($fullscreen ? 'yes' : 'no')); 275 284 276 wp_set_post_terms($wp_post_id, [$term], 'category');285 wp_set_post_terms($wp_post_id, $terms, 'category'); 277 286 278 287 $sync_errors = $this->post_sync_api_medias($api_data, $wp_post_id); … … 307 316 $cat_sync_db = new Crowdaa_Sync_Syncdb('categories'); 308 317 309 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 310 $term = (int) $term->wp_id; 318 if (isset($api_data->categories)) { 319 $api_ids = []; 320 foreach ($api_data->categories as $category) { 321 $api_ids[] = $category->_id; 322 } 323 $terms = $cat_sync_db->get_entries_with_api_ids($api_ids, 'wp_id'); 324 $terms = Crowdaa_Sync_Utils::object_array_extract_field('wp_id', $terms); 325 } else { 326 $term = $cat_sync_db->get_entry_with_api_id($api_data->category->_id, 'wp_id'); 327 $terms = [(int) $term->wp_id]; 328 } 311 329 312 330 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); … … 322 340 // } 323 341 324 wp_set_post_terms($wp_post_id, [$term], 'category');342 wp_set_post_terms($wp_post_id, $terms, 'category'); 325 343 wp_update_post($data); 326 344 update_post_meta($wp_post_id, 'api_post_id', $api_data->_id); -
crowdaa-sync/trunk/admin/class-crowdaa-sync-api.php
r2762188 r2825896 201 201 'actions' => [], 202 202 'authorName' => $post_author, 203 'categoryId' => $category_id,204 203 'feedPicture' => $api_feedpicture_id, 205 204 'md' => $post_content ?: __('Without content', CROWDAA_SYNC_PLUGIN_NAME), … … 215 214 ], 216 215 ]; 216 if (is_array($category_id)) { 217 $data['categoriesId'] = $category_id; 218 } else { 219 $data['categoryId'] = $category_id; 220 } 217 221 $data = apply_filters('crowdaa_sync_api_update_article_payload', $data, $wp_post_id); 218 222 … … 314 318 } 315 319 316 if(!$article_data['categoryId'] ) {320 if(!$article_data['categoryId'] && !$article_data['categoriesId']) { 317 321 throw new Crowdaa_Sync_Post_Skip_Error(__('Unable to create article without Category', CROWDAA_SYNC_PLUGIN_NAME)); 318 322 } … … 375 379 } 376 380 377 if(!$article_data['categoryId'] ) {381 if(!$article_data['categoryId'] && !$article_data['categoriesId']) { 378 382 throw new Crowdaa_Sync_Post_Skip_Error(__('Unable to update article without Category', CROWDAA_SYNC_PLUGIN_NAME)); 379 383 } … … 465 469 'actions' => [], 466 470 'authorName' => $post_author, 467 'categoryId' => $category_id,468 471 'feedPicture' => $api_feedpicture_id, 469 472 'md' => $post_content ?: __('Without content', CROWDAA_SYNC_PLUGIN_NAME), … … 479 482 ], 480 483 ]; 484 if (is_array($category_id)) { 485 $data['categoriesId'] = $category_id; 486 } else { 487 $data['categoryId'] = $category_id; 488 } 481 489 $data = apply_filters('crowdaa_sync_api_create_article_payload', $data, $wp_post_id); 482 490 … … 591 599 } else if ($gallery_ids === ''.$default_image['attachment_id'] && $thumbnail_id !== null) { 592 600 $gallery_ids = ''.$thumbnail_id; 593 $api_media_map[$api_feedpicture_id ] = [594 'attachment_id' => $ attachment_id,601 $api_media_map[$api_feedpicture_id['api_id']] = [ 602 'attachment_id' => $thumbnail_id, 595 603 'image' => true, 596 604 ]; … … 615 623 update_post_meta($wp_post_id, 'api_media_map', serialize($api_media_map)); 616 624 } else if ($thumbnail_id && $attachment_id == $thumbnail_id) { 617 $api_media_map[$api_feedpicture_id ] = [625 $api_media_map[$api_feedpicture_id['api_id']] = [ 618 626 'attachment_id' => $attachment_id, 619 627 'image' => true, -
crowdaa-sync/trunk/crowdaa-sync.php
r2818151 r2825896 14 14 * Plugin URI: 15 15 * Description: Plugin for synchronizing WordPress site and Crowdaa CMS 16 * Version: 1. 6.316 * Version: 1.7.0 17 17 * Requires at least: 5.5 18 18 * Requires PHP: 7.2 … … 34 34 * Uses SemVer - https://semver.org 35 35 */ 36 define('CROWDAA_SYNC_VERSION', '1. 6.3');36 define('CROWDAA_SYNC_VERSION', '1.7.0'); 37 37 define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__); 38 38 define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync');
Note: See TracChangeset
for help on using the changeset viewer.