Changeset 2756893
- Timestamp:
- 07/15/2022 11:50:20 AM (4 years ago)
- Location:
- crowdaa-sync
- Files:
-
- 5 edited
- 30 copied
-
tags/1.2.3 (copied) (copied from crowdaa-sync/trunk)
-
tags/1.2.3/CHANGELOG (copied) (copied from crowdaa-sync/trunk/CHANGELOG) (1 diff)
-
tags/1.2.3/LICENSE.txt (copied) (copied from crowdaa-sync/trunk/LICENSE.txt)
-
tags/1.2.3/README.txt (copied) (copied from crowdaa-sync/trunk/README.txt) (1 diff)
-
tags/1.2.3/admin (copied) (copied from crowdaa-sync/trunk/admin)
-
tags/1.2.3/admin/class-crowdaa-sync-add-info-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-api.php)
-
tags/1.2.3/admin/class-crowdaa-sync-add-info-wp.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-wp.php) (6 diffs)
-
tags/1.2.3/admin/class-crowdaa-sync-admin-display.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-admin-display.php)
-
tags/1.2.3/admin/class-crowdaa-sync-api.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-api.php)
-
tags/1.2.3/admin/class-crowdaa-sync-ext-hooks.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-ext-hooks.php)
-
tags/1.2.3/admin/class-crowdaa-sync-meta-box.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-meta-box.php)
-
tags/1.2.3/admin/class-crowdaa-sync-wp-hooks.php (copied) (copied from crowdaa-sync/trunk/admin/class-crowdaa-sync-wp-hooks.php) (1 diff)
-
tags/1.2.3/admin/css/crowdaa-sync-admin.css (copied) (copied from crowdaa-sync/trunk/admin/css/crowdaa-sync-admin.css)
-
tags/1.2.3/admin/js/crowdaa-sync-admin.js (copied) (copied from crowdaa-sync/trunk/admin/js/crowdaa-sync-admin.js)
-
tags/1.2.3/admin/partials/crowdaa-sync-admin-display.php (copied) (copied from crowdaa-sync/trunk/admin/partials/crowdaa-sync-admin-display.php)
-
tags/1.2.3/cacert.pem (copied) (copied from crowdaa-sync/trunk/cacert.pem)
-
tags/1.2.3/composer.json (copied) (copied from crowdaa-sync/trunk/composer.json)
-
tags/1.2.3/crowdaa-sync.php (copied) (copied from crowdaa-sync/trunk/crowdaa-sync.php) (2 diffs)
-
tags/1.2.3/includes (copied) (copied from crowdaa-sync/trunk/includes)
-
tags/1.2.3/includes/class-crowdaa-sync-exception.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-exception.php)
-
tags/1.2.3/includes/class-crowdaa-sync-permissions.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-permissions.php)
-
tags/1.2.3/includes/class-crowdaa-sync-syncdb.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-syncdb.php)
-
tags/1.2.3/includes/class-crowdaa-sync-utils.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-utils.php)
-
tags/1.2.3/includes/class-crowdaa-sync-versions.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync-versions.php)
-
tags/1.2.3/includes/class-crowdaa-sync.php (copied) (copied from crowdaa-sync/trunk/includes/class-crowdaa-sync.php)
-
tags/1.2.3/index.php (copied) (copied from crowdaa-sync/trunk/index.php)
-
tags/1.2.3/languages (copied) (copied from crowdaa-sync/trunk/languages)
-
tags/1.2.3/public (copied) (copied from crowdaa-sync/trunk/public)
-
tags/1.2.3/uninstall.php (copied) (copied from crowdaa-sync/trunk/uninstall.php)
-
tags/1.2.3/vendor (copied) (copied from crowdaa-sync/trunk/vendor)
-
trunk/CHANGELOG (modified) (1 diff)
-
trunk/README.txt (modified) (1 diff)
-
trunk/admin/class-crowdaa-sync-add-info-wp.php (modified) (6 diffs)
-
trunk/admin/class-crowdaa-sync-wp-hooks.php (modified) (1 diff)
-
trunk/crowdaa-sync.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
crowdaa-sync/tags/1.2.3/CHANGELOG
r2755426 r2756893 6 6 7 7 ## [Unreleased] 8 9 ## [1.2.3] - 2022-07-13 10 11 ### Changed 12 - When there is a single image/video on the API, it is used as an article thumbnail 13 14 ### Removed 15 - Useless warning message when saving an article without picture 8 16 9 17 ## [1.2.2] - 2022-07-13 -
crowdaa-sync/tags/1.2.3/README.txt
r2755426 r2756893 6 6 Requires PHP: 7.3 7 7 Tested up to: 5.9 8 Stable tag: 1.2. 28 Stable tag: 1.2.3 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
crowdaa-sync/tags/1.2.3/admin/class-crowdaa-sync-add-info-wp.php
r2755426 r2756893 343 343 $term = (int) $term->wp_id; 344 344 345 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); 345 346 $post_data = [ 346 'post_title' => $api_data->title, 347 'post_content' => $api_data->text, 348 'post_status' => 'publish', 349 'post_type' => 'post', 350 'post_author' => get_current_user_id(), 347 'post_title' => $api_data->title, 348 'post_content' => $api_data->text, 349 // 'post_date' => date('Y-m-d H:i:s', $publicationTime), 350 // 'post_date_gmt' => gmdate('Y-m-d H:i:s', $publicationTime), 351 'post_status' => 'publish', 352 'post_type' => 'post', 353 'post_author' => get_current_user_id(), 351 354 ]; 355 // if ($publicationTime > time()) { 356 // $data['post_status'] = 'future'; 357 // } 352 358 353 359 $wp_post_id = wp_insert_post($post_data); … … 369 375 } 370 376 377 // private static function api_date_to_unix($date) { 378 // $matches = []; 379 // preg_match('/^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.\d+Z/', $date, $matches); 380 // $time = gmmktime( 381 // intval($matches[4], 10), 382 // intval($matches[5], 10), 383 // intval($matches[6], 10), 384 // intval($matches[2], 10), 385 // intval($matches[3], 10), 386 // intval($matches[1], 10), 387 // ); 388 // return ($time); 389 // } 390 371 391 private function update_wp_post_from_api($api_data, $wp_post_id) { 372 392 $created_posts = []; … … 376 396 $term = (int) $term->wp_id; 377 397 398 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); 378 399 $data = [ 379 'ID' => $wp_post_id, 380 'post_title' => $api_data->title, 381 'post_content' => $api_data->text, 400 'ID' => $wp_post_id, 401 'post_title' => $api_data->title, 402 'post_content' => $api_data->text, 403 // 'post_date' => date('Y-m-d H:i:s', $publicationTime), 404 // 'post_date_gmt' => gmdate('Y-m-d H:i:s', $publicationTime), 382 405 ]; 406 // if ($publicationTime > time()) { 407 // $data['post_status'] = 'future'; 408 // } 383 409 384 410 wp_set_post_terms($wp_post_id, [$term], 'category'); … … 476 502 } 477 503 504 $article_vid = false; 505 $article_pic = false; 506 if ($api_data->videos) $article_vid = $api_data->videos[0]; 507 else if ($api_data->pictures) $article_pic = $api_data->pictures[0]; 508 509 $have_a_picture = isset($api_data->feedPicture) || $article_vid || $article_pic; 510 if (isset($api_data->feedPicture)) { 511 $feed_pic_url = $api_data->feedPicture->pictureUrl; 512 $feed_pic_id = $api_data->feedPicture->pictur_ideUrl; 513 } else if ($article_vid) { 514 $feed_pic_url = $article_vid->thumbUrl; 515 $feed_pic_id = $article_vid->_id; 516 } else if ($article_pic) { 517 $feed_pic_url = $article_pic->pictureUrl; 518 $feed_pic_id = $article_pic->_id; 519 } 520 478 521 $need_feed_update = false; 479 if( isset($api_data->feedPicture)&& !$api_feedpicture) {522 if($have_a_picture && !$api_feedpicture) { 480 523 $need_feed_update = true; 481 } else if (!isset($api_data->feedPicture) && $api_feedpicture) { 482 $need_feed_update = true; 483 } else if (isset($api_data->feedPicture) && $api_feedpicture) { 484 if ($api_data->feedPicture->_id !== $api_feedpicture_api) { 524 } else if (!$have_a_picture && $api_feedpicture) { 525 if ($article_vid && $article_vid->_id !== $api_feedpicture_api) { 526 $need_feed_update = true; 527 } else if ($article_pic && $article_pic->_id !== $api_feedpicture_api) { 528 $need_feed_update = true; 529 } 530 } else if ($have_a_picture && $api_feedpicture) { 531 if ($feed_pic_id !== $api_feedpicture_api) { 485 532 $need_feed_update = true; 486 533 } else { … … 493 540 494 541 if ($need_feed_update) { 495 if (! isset($api_data->feedPicture)) {542 if (!$have_a_picture) { 496 543 delete_post_thumbnail($wp_post_id); 497 544 update_post_meta($wp_post_id, 'api_feedpicture_id', ''); 498 545 } else { 499 $feed_pic_url = $api_data->feedPicture->pictureUrl;500 546 $ext = pathinfo(parse_url($feed_pic_url, PHP_URL_PATH), PATHINFO_EXTENSION); 501 $feed_pic_name = $ api_data->feedPicture->_id.'.'.$ext;547 $feed_pic_name = $feed_pic_id.'-thumbnail.'.$ext; 502 548 $fetch_err = false; 503 549 if(!$this->check_uploads($feed_pic_name)) { … … 516 562 } 517 563 update_post_meta($wp_post_id, 'api_feedpicture_id', serialize([ 518 'api_id' => $ api_data->feedPicture->_id,564 'api_id' => $feed_pic_id, 519 565 'attachment_id' => $attachment_id, 520 566 ])); -
crowdaa-sync/tags/1.2.3/admin/class-crowdaa-sync-wp-hooks.php
r2744975 r2756893 69 69 $terms = get_the_terms(get_the_ID(), $post_type_taxonomy); 70 70 if (empty($terms)) { 71 Crowdaa_Sync_Admin_Display::admin_notice('error', __('You will not be able to synchronize this post until you add a Sync category', CROWDAA_SYNC_PLUGIN_NAME)); 72 } 73 74 $gallery = get_post_meta(get_the_ID(), 'second_featured_img', true); 75 if (empty($gallery)) { 76 Crowdaa_Sync_Admin_Display::admin_notice('error', __('You will not be able to synchronize this post until you add a Pictures or Videos in the Gallery', CROWDAA_SYNC_PLUGIN_NAME)); 71 Crowdaa_Sync_Admin_Display::admin_notice('error', __('Crowdaa-Sync: You will not be able to synchronize this post until you add a Sync category', CROWDAA_SYNC_PLUGIN_NAME)); 77 72 } 78 73 } -
crowdaa-sync/tags/1.2.3/crowdaa-sync.php
r2755426 r2756893 14 14 * Plugin URI: 15 15 * Description: Plugin for synchronizing WordPress site and Crowdaa CMS 16 * Version: 1.2. 216 * Version: 1.2.3 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.2. 2');36 define('CROWDAA_SYNC_VERSION', '1.2.3'); 37 37 define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__); 38 38 define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync'); -
crowdaa-sync/trunk/CHANGELOG
r2755426 r2756893 6 6 7 7 ## [Unreleased] 8 9 ## [1.2.3] - 2022-07-13 10 11 ### Changed 12 - When there is a single image/video on the API, it is used as an article thumbnail 13 14 ### Removed 15 - Useless warning message when saving an article without picture 8 16 9 17 ## [1.2.2] - 2022-07-13 -
crowdaa-sync/trunk/README.txt
r2755426 r2756893 6 6 Requires PHP: 7.3 7 7 Tested up to: 5.9 8 Stable tag: 1.2. 28 Stable tag: 1.2.3 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-wp.php
r2755426 r2756893 343 343 $term = (int) $term->wp_id; 344 344 345 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); 345 346 $post_data = [ 346 'post_title' => $api_data->title, 347 'post_content' => $api_data->text, 348 'post_status' => 'publish', 349 'post_type' => 'post', 350 'post_author' => get_current_user_id(), 347 'post_title' => $api_data->title, 348 'post_content' => $api_data->text, 349 // 'post_date' => date('Y-m-d H:i:s', $publicationTime), 350 // 'post_date_gmt' => gmdate('Y-m-d H:i:s', $publicationTime), 351 'post_status' => 'publish', 352 'post_type' => 'post', 353 'post_author' => get_current_user_id(), 351 354 ]; 355 // if ($publicationTime > time()) { 356 // $data['post_status'] = 'future'; 357 // } 352 358 353 359 $wp_post_id = wp_insert_post($post_data); … … 369 375 } 370 376 377 // private static function api_date_to_unix($date) { 378 // $matches = []; 379 // preg_match('/^(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)\.\d+Z/', $date, $matches); 380 // $time = gmmktime( 381 // intval($matches[4], 10), 382 // intval($matches[5], 10), 383 // intval($matches[6], 10), 384 // intval($matches[2], 10), 385 // intval($matches[3], 10), 386 // intval($matches[1], 10), 387 // ); 388 // return ($time); 389 // } 390 371 391 private function update_wp_post_from_api($api_data, $wp_post_id) { 372 392 $created_posts = []; … … 376 396 $term = (int) $term->wp_id; 377 397 398 // $publicationTime = self::api_date_to_unix($api_data->publicationDate); 378 399 $data = [ 379 'ID' => $wp_post_id, 380 'post_title' => $api_data->title, 381 'post_content' => $api_data->text, 400 'ID' => $wp_post_id, 401 'post_title' => $api_data->title, 402 'post_content' => $api_data->text, 403 // 'post_date' => date('Y-m-d H:i:s', $publicationTime), 404 // 'post_date_gmt' => gmdate('Y-m-d H:i:s', $publicationTime), 382 405 ]; 406 // if ($publicationTime > time()) { 407 // $data['post_status'] = 'future'; 408 // } 383 409 384 410 wp_set_post_terms($wp_post_id, [$term], 'category'); … … 476 502 } 477 503 504 $article_vid = false; 505 $article_pic = false; 506 if ($api_data->videos) $article_vid = $api_data->videos[0]; 507 else if ($api_data->pictures) $article_pic = $api_data->pictures[0]; 508 509 $have_a_picture = isset($api_data->feedPicture) || $article_vid || $article_pic; 510 if (isset($api_data->feedPicture)) { 511 $feed_pic_url = $api_data->feedPicture->pictureUrl; 512 $feed_pic_id = $api_data->feedPicture->pictur_ideUrl; 513 } else if ($article_vid) { 514 $feed_pic_url = $article_vid->thumbUrl; 515 $feed_pic_id = $article_vid->_id; 516 } else if ($article_pic) { 517 $feed_pic_url = $article_pic->pictureUrl; 518 $feed_pic_id = $article_pic->_id; 519 } 520 478 521 $need_feed_update = false; 479 if( isset($api_data->feedPicture)&& !$api_feedpicture) {522 if($have_a_picture && !$api_feedpicture) { 480 523 $need_feed_update = true; 481 } else if (!isset($api_data->feedPicture) && $api_feedpicture) { 482 $need_feed_update = true; 483 } else if (isset($api_data->feedPicture) && $api_feedpicture) { 484 if ($api_data->feedPicture->_id !== $api_feedpicture_api) { 524 } else if (!$have_a_picture && $api_feedpicture) { 525 if ($article_vid && $article_vid->_id !== $api_feedpicture_api) { 526 $need_feed_update = true; 527 } else if ($article_pic && $article_pic->_id !== $api_feedpicture_api) { 528 $need_feed_update = true; 529 } 530 } else if ($have_a_picture && $api_feedpicture) { 531 if ($feed_pic_id !== $api_feedpicture_api) { 485 532 $need_feed_update = true; 486 533 } else { … … 493 540 494 541 if ($need_feed_update) { 495 if (! isset($api_data->feedPicture)) {542 if (!$have_a_picture) { 496 543 delete_post_thumbnail($wp_post_id); 497 544 update_post_meta($wp_post_id, 'api_feedpicture_id', ''); 498 545 } else { 499 $feed_pic_url = $api_data->feedPicture->pictureUrl;500 546 $ext = pathinfo(parse_url($feed_pic_url, PHP_URL_PATH), PATHINFO_EXTENSION); 501 $feed_pic_name = $ api_data->feedPicture->_id.'.'.$ext;547 $feed_pic_name = $feed_pic_id.'-thumbnail.'.$ext; 502 548 $fetch_err = false; 503 549 if(!$this->check_uploads($feed_pic_name)) { … … 516 562 } 517 563 update_post_meta($wp_post_id, 'api_feedpicture_id', serialize([ 518 'api_id' => $ api_data->feedPicture->_id,564 'api_id' => $feed_pic_id, 519 565 'attachment_id' => $attachment_id, 520 566 ])); -
crowdaa-sync/trunk/admin/class-crowdaa-sync-wp-hooks.php
r2744975 r2756893 69 69 $terms = get_the_terms(get_the_ID(), $post_type_taxonomy); 70 70 if (empty($terms)) { 71 Crowdaa_Sync_Admin_Display::admin_notice('error', __('You will not be able to synchronize this post until you add a Sync category', CROWDAA_SYNC_PLUGIN_NAME)); 72 } 73 74 $gallery = get_post_meta(get_the_ID(), 'second_featured_img', true); 75 if (empty($gallery)) { 76 Crowdaa_Sync_Admin_Display::admin_notice('error', __('You will not be able to synchronize this post until you add a Pictures or Videos in the Gallery', CROWDAA_SYNC_PLUGIN_NAME)); 71 Crowdaa_Sync_Admin_Display::admin_notice('error', __('Crowdaa-Sync: You will not be able to synchronize this post until you add a Sync category', CROWDAA_SYNC_PLUGIN_NAME)); 77 72 } 78 73 } -
crowdaa-sync/trunk/crowdaa-sync.php
r2755426 r2756893 14 14 * Plugin URI: 15 15 * Description: Plugin for synchronizing WordPress site and Crowdaa CMS 16 * Version: 1.2. 216 * Version: 1.2.3 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.2. 2');36 define('CROWDAA_SYNC_VERSION', '1.2.3'); 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.