Plugin Directory

Changeset 2756893


Ignore:
Timestamp:
07/15/2022 11:50:20 AM (4 years ago)
Author:
crowdaa
Message:

Added version 1.2.3

Location:
crowdaa-sync
Files:
5 edited
30 copied

Legend:

Unmodified
Added
Removed
  • crowdaa-sync/tags/1.2.3/CHANGELOG

    r2755426 r2756893  
    66
    77## [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
    816
    917## [1.2.2] - 2022-07-13
  • crowdaa-sync/tags/1.2.3/README.txt

    r2755426 r2756893  
    66Requires PHP: 7.3
    77Tested up to: 5.9
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License 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  
    343343    $term = (int) $term->wp_id;
    344344
     345    // $publicationTime = self::api_date_to_unix($api_data->publicationDate);
    345346    $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(),
    351354    ];
     355    // if ($publicationTime > time()) {
     356    //   $data['post_status'] = 'future';
     357    // }
    352358
    353359    $wp_post_id = wp_insert_post($post_data);
     
    369375  }
    370376
     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
    371391  private function update_wp_post_from_api($api_data, $wp_post_id) {
    372392    $created_posts  = [];
     
    376396    $term = (int) $term->wp_id;
    377397
     398    // $publicationTime = self::api_date_to_unix($api_data->publicationDate);
    378399    $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),
    382405    ];
     406    // if ($publicationTime > time()) {
     407    //   $data['post_status'] = 'future';
     408    // }
    383409
    384410    wp_set_post_terms($wp_post_id, [$term], 'category');
     
    476502    }
    477503
     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
    478521    $need_feed_update = false;
    479     if(isset($api_data->feedPicture) && !$api_feedpicture) {
     522    if($have_a_picture && !$api_feedpicture) {
    480523      $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) {
    485532        $need_feed_update = true;
    486533      } else {
     
    493540
    494541    if ($need_feed_update) {
    495       if (!isset($api_data->feedPicture)) {
     542      if (!$have_a_picture) {
    496543        delete_post_thumbnail($wp_post_id);
    497544        update_post_meta($wp_post_id, 'api_feedpicture_id', '');
    498545      } else {
    499         $feed_pic_url = $api_data->feedPicture->pictureUrl;
    500546        $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;
    502548        $fetch_err = false;
    503549        if(!$this->check_uploads($feed_pic_name)) {
     
    516562          }
    517563          update_post_meta($wp_post_id, 'api_feedpicture_id', serialize([
    518             'api_id' => $api_data->feedPicture->_id,
     564            'api_id' => $feed_pic_id,
    519565            'attachment_id' => $attachment_id,
    520566          ]));
  • crowdaa-sync/tags/1.2.3/admin/class-crowdaa-sync-wp-hooks.php

    r2744975 r2756893  
    6969      $terms = get_the_terms(get_the_ID(), $post_type_taxonomy);
    7070      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));
    7772      }
    7873    }
  • crowdaa-sync/tags/1.2.3/crowdaa-sync.php

    r2755426 r2756893  
    1414 * Plugin URI:       
    1515 * Description:       Plugin for synchronizing WordPress site and Crowdaa CMS
    16  * Version:           1.2.2
     16 * Version:           1.2.3
    1717 * Requires at least: 5.5
    1818 * Requires PHP:      7.2
     
    3434 * Uses SemVer - https://semver.org
    3535 */
    36 define('CROWDAA_SYNC_VERSION', '1.2.2');
     36define('CROWDAA_SYNC_VERSION', '1.2.3');
    3737define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__);
    3838define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync');
  • crowdaa-sync/trunk/CHANGELOG

    r2755426 r2756893  
    66
    77## [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
    816
    917## [1.2.2] - 2022-07-13
  • crowdaa-sync/trunk/README.txt

    r2755426 r2756893  
    66Requires PHP: 7.3
    77Tested up to: 5.9
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crowdaa-sync/trunk/admin/class-crowdaa-sync-add-info-wp.php

    r2755426 r2756893  
    343343    $term = (int) $term->wp_id;
    344344
     345    // $publicationTime = self::api_date_to_unix($api_data->publicationDate);
    345346    $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(),
    351354    ];
     355    // if ($publicationTime > time()) {
     356    //   $data['post_status'] = 'future';
     357    // }
    352358
    353359    $wp_post_id = wp_insert_post($post_data);
     
    369375  }
    370376
     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
    371391  private function update_wp_post_from_api($api_data, $wp_post_id) {
    372392    $created_posts  = [];
     
    376396    $term = (int) $term->wp_id;
    377397
     398    // $publicationTime = self::api_date_to_unix($api_data->publicationDate);
    378399    $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),
    382405    ];
     406    // if ($publicationTime > time()) {
     407    //   $data['post_status'] = 'future';
     408    // }
    383409
    384410    wp_set_post_terms($wp_post_id, [$term], 'category');
     
    476502    }
    477503
     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
    478521    $need_feed_update = false;
    479     if(isset($api_data->feedPicture) && !$api_feedpicture) {
     522    if($have_a_picture && !$api_feedpicture) {
    480523      $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) {
    485532        $need_feed_update = true;
    486533      } else {
     
    493540
    494541    if ($need_feed_update) {
    495       if (!isset($api_data->feedPicture)) {
     542      if (!$have_a_picture) {
    496543        delete_post_thumbnail($wp_post_id);
    497544        update_post_meta($wp_post_id, 'api_feedpicture_id', '');
    498545      } else {
    499         $feed_pic_url = $api_data->feedPicture->pictureUrl;
    500546        $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;
    502548        $fetch_err = false;
    503549        if(!$this->check_uploads($feed_pic_name)) {
     
    516562          }
    517563          update_post_meta($wp_post_id, 'api_feedpicture_id', serialize([
    518             'api_id' => $api_data->feedPicture->_id,
     564            'api_id' => $feed_pic_id,
    519565            'attachment_id' => $attachment_id,
    520566          ]));
  • crowdaa-sync/trunk/admin/class-crowdaa-sync-wp-hooks.php

    r2744975 r2756893  
    6969      $terms = get_the_terms(get_the_ID(), $post_type_taxonomy);
    7070      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));
    7772      }
    7873    }
  • crowdaa-sync/trunk/crowdaa-sync.php

    r2755426 r2756893  
    1414 * Plugin URI:       
    1515 * Description:       Plugin for synchronizing WordPress site and Crowdaa CMS
    16  * Version:           1.2.2
     16 * Version:           1.2.3
    1717 * Requires at least: 5.5
    1818 * Requires PHP:      7.2
     
    3434 * Uses SemVer - https://semver.org
    3535 */
    36 define('CROWDAA_SYNC_VERSION', '1.2.2');
     36define('CROWDAA_SYNC_VERSION', '1.2.3');
    3737define('CROWDAA_SYNC_PLUGIN_DIR', __DIR__);
    3838define('CROWDAA_SYNC_PLUGIN_NAME', 'crowdaa-sync');
Note: See TracChangeset for help on using the changeset viewer.