Plugin Directory

Changeset 3028256


Ignore:
Timestamp:
01/29/2024 01:36:14 PM (2 years ago)
Author:
crowdaa
Message:

Added version 1.8.2.

Location:
crowdaa-sync
Files:
5 edited
75 copied

Legend:

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

    r3028192 r3028256  
    66
    77## [Unreleased]
     8
     9## [1.8.2] - 2024-01-29
     10
     11### Changed
     12
     13- Now displaying article event start & end dates.
    814
    915## [1.8.1] - 2024-01-29
  • crowdaa-sync/tags/1.8.2/README.txt

    r3028192 r3028256  
    66Requires PHP: 7.3
    77Tested up to: 5.9
    8 Stable tag: 1.8.1
     8Stable tag: 1.8.2
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crowdaa-sync/tags/1.8.2/admin/class-crowdaa-sync-meta-box.php

    r3028189 r3028256  
    413413
    414414    if (isset($_POST['crowdaa_event_start'])) {
    415       error_log(print_r(['DEBUG crowdaa_event_start', $_POST['crowdaa_event_start']], true));
    416415      update_post_meta($post_id, 'crowdaa_event_start', $_POST['crowdaa_event_start']);
    417416    }
    418417
    419418    if (isset($_POST['crowdaa_event_end'])) {
    420       error_log(print_r(['DEBUG crowdaa_event_end', $_POST['crowdaa_event_end']], true));
    421419      update_post_meta($post_id, 'crowdaa_event_end', $_POST['crowdaa_event_end']);
    422420    }
  • crowdaa-sync/tags/1.8.2/admin/class-crowdaa-sync-wp-hooks.php

    r3028192 r3028256  
    3333    add_action('created_category', [$this, 'on_category_saved'], 10, 2);
    3434    add_action('edited_category', [$this, 'on_category_saved'], 10, 2);
    35     // add_filter('the_content', [$this, 'add_event_fields']);
     35    add_filter('the_content', [$this, 'add_event_fields']);
    3636  }
    3737
     
    216216   * @return string
    217217   */
    218   // public function add_event_fields($content)
    219   // {
    220   //   if (is_singular() && in_the_loop() && is_main_query()) {
    221   //     $post_id = the_ID();
    222   //     $terms = wp_get_post_terms($post_id, 'category');
    223   //     $is_event = false;
    224   //     foreach ($terms as $term) {
    225   //       if (get_term_meta($term->term_id, 'crowdaa_is_event', true) === 'yes') {
    226   //         $is_event = true;
    227   //         break;
    228   //       }
    229   //     }
    230 
    231   //     if ($is_event) {
    232   //     }
    233 
    234   //     return ($content . esc_html__('I’m filtering the content inside the main loop', 'wporg'));
    235   //   }
    236 
    237   //   return ($content);
    238   // }
     218  public function add_event_fields($content)
     219  {
     220    if (is_singular() && in_the_loop() && is_main_query()) {
     221      $post_id = get_the_ID();
     222      $terms = wp_get_post_terms($post_id, 'category');
     223      $is_event = false;
     224      foreach ($terms as $term) {
     225        if (get_term_meta($term->term_id, 'crowdaa_is_event', true) === 'yes') {
     226          $is_event = true;
     227          break;
     228        }
     229      }
     230
     231      if ($is_event) {
     232        $eventStartDate = get_post_meta($post_id, 'crowdaa_event_start', true);
     233        $eventEndDate = get_post_meta($post_id, 'crowdaa_event_end', true);
     234        if (!$eventStartDate) $eventStartDate = date('Y-m-d\TH:i:s\.\0\0\0\Z');
     235        if (!$eventEndDate) $eventEndDate = date('Y-m-d\TH:i:s\.\0\0\0\Z');
     236        $atText = esc_html('at', CROWDAA_SYNC_PLUGIN_NAME);
     237
     238        $eventStartDateJson = json_encode($eventStartDate);
     239        $eventEndDateJson = json_encode($eventEndDate);
     240        $startText = esc_html('This event starts the', CROWDAA_SYNC_PLUGIN_NAME);
     241        $eventStartCode = <<<SCRIPT
     242$startText
     243<script type="text/javascript">
     244(() => {
     245  const date = new Date($eventStartDateJson);
     246  document.currentScript.replaceWith(date.toLocaleDateString());
     247})();
     248</script>
     249$atText
     250<script type="text/javascript">
     251(() => {
     252  const date = new Date($eventStartDateJson);
     253  document.currentScript.replaceWith(date.toLocaleTimeString());
     254})();
     255</script>
     256SCRIPT
     257;
     258        $endText = esc_html('and ends the', CROWDAA_SYNC_PLUGIN_NAME);
     259        $eventEndCode = <<<SCRIPT
     260$endText
     261<script type="text/javascript">
     262(() => {
     263  const date = new Date($eventEndDateJson);
     264  document.currentScript.replaceWith(date.toLocaleDateString());
     265})();
     266</script>
     267$atText
     268<script type="text/javascript">
     269(() => {
     270  const date = new Date($eventEndDateJson);
     271  document.currentScript.replaceWith(date.toLocaleTimeString());
     272})();
     273</script>.
     274SCRIPT
     275;
     276        $rootStyle = 'font-style: italic;';
     277        $eventCode = <<<SCRIPT
     278<p style="$rootStyle">
     279  $eventStartCode
     280  $eventEndCode
     281</p>
     282SCRIPT
     283;
     284        $content = $eventCode . $content;
     285      }
     286
     287      return ($content);
     288    }
     289
     290    return ($content);
     291  }
    239292}
  • crowdaa-sync/tags/1.8.2/crowdaa-sync.php

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

    r3028192 r3028256  
    66
    77## [Unreleased]
     8
     9## [1.8.2] - 2024-01-29
     10
     11### Changed
     12
     13- Now displaying article event start & end dates.
    814
    915## [1.8.1] - 2024-01-29
  • crowdaa-sync/trunk/README.txt

    r3028192 r3028256  
    66Requires PHP: 7.3
    77Tested up to: 5.9
    8 Stable tag: 1.8.1
     8Stable tag: 1.8.2
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • crowdaa-sync/trunk/admin/class-crowdaa-sync-meta-box.php

    r3028189 r3028256  
    413413
    414414    if (isset($_POST['crowdaa_event_start'])) {
    415       error_log(print_r(['DEBUG crowdaa_event_start', $_POST['crowdaa_event_start']], true));
    416415      update_post_meta($post_id, 'crowdaa_event_start', $_POST['crowdaa_event_start']);
    417416    }
    418417
    419418    if (isset($_POST['crowdaa_event_end'])) {
    420       error_log(print_r(['DEBUG crowdaa_event_end', $_POST['crowdaa_event_end']], true));
    421419      update_post_meta($post_id, 'crowdaa_event_end', $_POST['crowdaa_event_end']);
    422420    }
  • crowdaa-sync/trunk/admin/class-crowdaa-sync-wp-hooks.php

    r3028192 r3028256  
    3333    add_action('created_category', [$this, 'on_category_saved'], 10, 2);
    3434    add_action('edited_category', [$this, 'on_category_saved'], 10, 2);
    35     // add_filter('the_content', [$this, 'add_event_fields']);
     35    add_filter('the_content', [$this, 'add_event_fields']);
    3636  }
    3737
     
    216216   * @return string
    217217   */
    218   // public function add_event_fields($content)
    219   // {
    220   //   if (is_singular() && in_the_loop() && is_main_query()) {
    221   //     $post_id = the_ID();
    222   //     $terms = wp_get_post_terms($post_id, 'category');
    223   //     $is_event = false;
    224   //     foreach ($terms as $term) {
    225   //       if (get_term_meta($term->term_id, 'crowdaa_is_event', true) === 'yes') {
    226   //         $is_event = true;
    227   //         break;
    228   //       }
    229   //     }
    230 
    231   //     if ($is_event) {
    232   //     }
    233 
    234   //     return ($content . esc_html__('I’m filtering the content inside the main loop', 'wporg'));
    235   //   }
    236 
    237   //   return ($content);
    238   // }
     218  public function add_event_fields($content)
     219  {
     220    if (is_singular() && in_the_loop() && is_main_query()) {
     221      $post_id = get_the_ID();
     222      $terms = wp_get_post_terms($post_id, 'category');
     223      $is_event = false;
     224      foreach ($terms as $term) {
     225        if (get_term_meta($term->term_id, 'crowdaa_is_event', true) === 'yes') {
     226          $is_event = true;
     227          break;
     228        }
     229      }
     230
     231      if ($is_event) {
     232        $eventStartDate = get_post_meta($post_id, 'crowdaa_event_start', true);
     233        $eventEndDate = get_post_meta($post_id, 'crowdaa_event_end', true);
     234        if (!$eventStartDate) $eventStartDate = date('Y-m-d\TH:i:s\.\0\0\0\Z');
     235        if (!$eventEndDate) $eventEndDate = date('Y-m-d\TH:i:s\.\0\0\0\Z');
     236        $atText = esc_html('at', CROWDAA_SYNC_PLUGIN_NAME);
     237
     238        $eventStartDateJson = json_encode($eventStartDate);
     239        $eventEndDateJson = json_encode($eventEndDate);
     240        $startText = esc_html('This event starts the', CROWDAA_SYNC_PLUGIN_NAME);
     241        $eventStartCode = <<<SCRIPT
     242$startText
     243<script type="text/javascript">
     244(() => {
     245  const date = new Date($eventStartDateJson);
     246  document.currentScript.replaceWith(date.toLocaleDateString());
     247})();
     248</script>
     249$atText
     250<script type="text/javascript">
     251(() => {
     252  const date = new Date($eventStartDateJson);
     253  document.currentScript.replaceWith(date.toLocaleTimeString());
     254})();
     255</script>
     256SCRIPT
     257;
     258        $endText = esc_html('and ends the', CROWDAA_SYNC_PLUGIN_NAME);
     259        $eventEndCode = <<<SCRIPT
     260$endText
     261<script type="text/javascript">
     262(() => {
     263  const date = new Date($eventEndDateJson);
     264  document.currentScript.replaceWith(date.toLocaleDateString());
     265})();
     266</script>
     267$atText
     268<script type="text/javascript">
     269(() => {
     270  const date = new Date($eventEndDateJson);
     271  document.currentScript.replaceWith(date.toLocaleTimeString());
     272})();
     273</script>.
     274SCRIPT
     275;
     276        $rootStyle = 'font-style: italic;';
     277        $eventCode = <<<SCRIPT
     278<p style="$rootStyle">
     279  $eventStartCode
     280  $eventEndCode
     281</p>
     282SCRIPT
     283;
     284        $content = $eventCode . $content;
     285      }
     286
     287      return ($content);
     288    }
     289
     290    return ($content);
     291  }
    239292}
  • crowdaa-sync/trunk/crowdaa-sync.php

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