Plugin Directory

Changeset 3468771


Ignore:
Timestamp:
02/24/2026 04:27:40 PM (5 weeks ago)
Author:
dramb
Message:

Add Locale sensitive Date/Time display. Change Readme docs to show compatibility with Wordpress 6.9. Bump version number.

Location:
cs-integration
Files:
84 added
9 edited

Legend:

Unmodified
Added
Removed
  • cs-integration/trunk/README.md

    r3357920 r3468771  
    33* Tags: Events, ChurchSuite, Featured
    44* Requires at least: 6.4
    5 * Tested up to: 6.8
    6 * Stable tag: 1.0.6
     5* Tested up to: 6.9
     6* Stable tag: 1.0.7
    77* License: GPLv2 or later
    88
     
    209209## Changelog
    210210
     211### 1.0.7
     212
     213**2026-02-24**
     214* Added output of dates which takes account of the current Locale of the server
     215* Bumped version number
     216* Bumped Wordpress Compatibility testing to 6.9
     217
    211218### 1.0.6
    212219
  • cs-integration/trunk/README.txt

    r3357920 r3468771  
    33* Tags: Events, ChurchSuite, Featured
    44* Requires at least: 6.4
    5 * Tested up to: 6.8
    6 * Stable tag: 1.0.6
     5* Tested up to: 6.9
     6* Stable tag: 1.0.7
    77* License: GPLv2 or later
    88
     
    209209== Changelog ==
    210210
     211= 1.0.7 =
     212
     213**2026-02-24**
     214* Added output of dates which takes account of the current Locale of the server
     215* Bumped version number
     216* Bumped Wordpress Compatibility testing to 6.9
     217
    211218= 1.0.6 =
    212219
  • cs-integration/trunk/cs-integration.php

    r3357920 r3468771  
    2020 * Plugin URI:        https://github.com/AlwynBarry/cs-integration
    2121 * Description:       CS Integration provides shortcodes to request and display JSON data from the public JSON ChurchSuite feeds.
    22  * Version:           1.0.6
     22 * Version:           1.0.7
    2323 * Author:            Alwyn Barry
    2424 * Author URI:        https://github.com/AlwynBarry/
     
    3939 * This will be updated it as we release new versions.
    4040 */
    41 const CS_INTEGRATION_VERSION = '1.0.3';
     41const CS_INTEGRATION_VERSION = '1.0.7';
    4242
    4343/**
  • cs-integration/trunk/public/shortcodes/class-cs-calendar-event-view.php

    r3354836 r3468771  
    5959     */
    6060    public function display() : string {
     61        // A value to prevent repeated creation of a new instance
     62        $timeFormat = datefmt_create(
     63            \Locale::getDefault(),
     64            \IntlDateFormatter::NONE,
     65            \IntlDateFormatter::SHORT,
     66            null,
     67            \IntlDateFormatter::GREGORIAN
     68        );
    6169        // Display the event wrapper, and include the event unique ID, the event
    6270        // status and the event category as classes to be styled, if these are set
     
    7886        $event_time = '';
    7987        if ( $this->cs_event->is_start_date() ) {
    80             $event_time .= '    <div class="cs-time"><span class="cs-start-time">' . date_format( $this->cs_event->get_start_date(), 'g:ia' ) . '</span>';
    81             $event_time .= ( $this->cs_event->is_end_date() ) ? '-' . '<span class="cs-end-time">' . date_format( $this->cs_event->get_end_date(), 'g:ia' ) . '</span>' : '';
     88            $event_time .= '    <div class="cs-time"><span class="cs-start-time">' . datefmt_format( $timeFormat, $this->cs_event->get_start_date() ) . '</span>';
     89            $event_time .= ( $this->cs_event->is_end_date() ) ? '-' . '<span class="cs-end-time">' . datefmt_format( $timeFormat, $this->cs_event->get_end_date() ) . '</span>' : '';
    8290            $event_time .= '</div>' . "\n";
    8391        }
  • cs-integration/trunk/public/shortcodes/class-cs-calendar-shortcode.php

    r3350221 r3468771  
    4747     * Constant values created to prevent unnecessary re-creation of values used in expressions
    4848     */
     49    protected \IntlDateFormatter $shortDayFormat;
     50    protected \IntlDateFormatter $shortMonthFormat;
     51    protected \IntlDateFormatter $longMonthFormat;
    4952    protected readonly \DateInterval $one_day;
    5053    protected readonly \DateInterval $one_week;
     
    5861    protected \DateTime $date_from;
    5962    protected \DateTime $date_to;
     63    protected \DateTime $date_beyond; // A constant just to help mark when we're outside the calendar
    6064
    6165    /*
     
    6973     */
    7074    public function __construct( $atts ) {
    71         // Set the values always required by this shortcode
     75        // Set the date formatters used to remove repeated instance creation
     76        $this->set_date_formatters();
     77
     78        // Set the date constants used to remove repeated instance creation
    7279        $this->page_url = get_permalink();
    7380        $this->one_day = \DateInterval::createFromDateString( '1 day' );
     
    98105        $this->date_from = self::get_sunday_before_month( $this->month_start );
    99106        $this->date_to = self::get_saturday_after_month( $this->month_start );
     107        $this->date_beyond = clone $this->date_to;
     108        $this->date_beyond->add( $this->one_day );
    100109
    101110        // Override or set the atts we need so we get the events for this month
     
    107116        // Now we can call the parent constructor to set all other attributes
    108117        parent::__construct( $atts, ChurchSuite::EVENTS );
     118    }
     119
     120    /*
     121     * Set the 'constant' values used to remove repeated instance creation of the required date formatters.
     122     *
     123     * @since   1.0.2
     124     */
     125    private function set_date_formatters() {
     126        $this->shortDayFormat = datefmt_create(
     127            \Locale::getDefault(),
     128            \IntlDateFormatter::FULL,
     129            \IntlDateFormatter::NONE,
     130            null,
     131            \IntlDateFormatter::GREGORIAN,
     132            'EEE'
     133        );
     134        $this->shortMonthFormat = datefmt_create(
     135            \Locale::getDefault(),
     136            \IntlDateFormatter::FULL,
     137            \IntlDateFormatter::NONE,
     138            null,
     139            \IntlDateFormatter::GREGORIAN,
     140            'MMM'
     141        );
     142        $this->longMonthFormat = datefmt_create(
     143            \Locale::getDefault(),
     144            \IntlDateFormatter::FULL,
     145            \IntlDateFormatter::NONE,
     146            null,
     147            \IntlDateFormatter::GREGORIAN,
     148            'MMMM'
     149        );
    109150    }
    110151
     
    221262            . '    <div class="cs-calendar-month-header">' . "\n"
    222263            . '      <div class="cs-calendar-month-title">' . "\n"
    223             . '        ' .  $date->format( 'F' ) . ' ' . $date->format( 'Y' ) . "\n"
     264            . '        ' . datefmt_format($this->longMonthFormat, $date) .  ' ' . $date->format( 'Y' ) . "\n"
    224265            . '      </div>' . "\n"
    225                 . '      <div class="cs-calendar-month-nav">' . "\n"
     266            . '      <div class="cs-calendar-month-nav">' . "\n"
    226267            . '        <button type="button" class="cs-calendar-previous-link" onclick="window.location.href=' . $this->get_previous_month_link() . '">' . "\n"
    227                         . '          <svg fill="none" viewBox="0 0 24 24" stroke="currentColor">' . "\n"
    228                         . '            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>' . "\n"
    229                         . '          </svg>' . "\n"
    230                         . '        </button>' . "\n"
     268            . '          <svg fill="none" viewBox="0 0 24 24" stroke="currentColor">' . "\n"
     269            . '            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>' . "\n"
     270            . '          </svg>' . "\n"
     271            . '        </button>' . "\n"
    231272            . '        <button type="button" class="cs-calendar-next-link" onclick="window.location.href=' . $this->get_next_month_link() . '">' . "\n"
    232                         . '          <svg fill="none" viewBox="0 0 24 24" stroke="currentColor">' . "\n"
    233                         . '            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>' . "\n"
    234                         . '          </svg>' . "\n"
    235                         . '        </button>' . "\n"
    236                 . '      </div>' . "\n"
     273            . '          <svg fill="none" viewBox="0 0 24 24" stroke="currentColor">' . "\n"
     274            . '            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>' . "\n"
     275            . '          </svg>' . "\n"
     276            . '        </button>' . "\n"
     277            . '      </div>' . "\n"
    237278            . '    </div>' . "\n"
    238                 . '    <div class="cs-calendar-days-grid">' . "\n"
     279            . '    <div class="cs-calendar-days-grid">' . "\n"
    239280            . '      <div class="cs-calendar-day-name-header">' . "\n";
    240281       
     
    246287        $period = new \DatePeriod( $sunday_date, $this->one_day, $saturday_date );
    247288        foreach ( $period as $day ) {
    248             $output .= '        <div class="cs-calendar-day-name-cell">' . $day->format( 'D' ) . '</div>' . "\n";
     289            $output .= '        <div class="cs-calendar-day-name-cell">' . datefmt_format($this->shortDayFormat, $day) . '</div>' . "\n";
    249290        }
    250291
     
    253294
    254295                 . '    </div>' . "\n"
    255             . '    <div class="cs-calendar-days">' . "\n";
    256             return $output;
     296                . '    <div class="cs-calendar-days">' . "\n";
     297        return $output;
    257298    }
    258299
     
    288329        $output .= '      <span class="cs-day">' . $date->format( 'D' ) . '</span>' . "\n";
    289330        $output .= '      <span class="cs-date-number">' . $day . '</span>' . "\n";
    290         $output .= '      <span class="cs-month">' . $date->format( 'F' ) . '</span>' . "\n";
     331        $output .= '      <span class="cs-month">' . datefmt_format($this->shortMonthFormat, $date) . '</span>' . "\n";
    291332        $output .= '      <span class="cs-year">' . $date->format( 'Y' ) . '</span>' . "\n";
    292333        $output .= '    </div>';
     
    326367            $date = clone $this->date_from;
    327368            // Output the start of the first row of the table, for the first week
    328             // $output .= '<div class="cs-calendar-row">' . "\n";
    329369            $output .= self::get_day_top( $date, $this->is_date_in_month( $date ), $this->is_date_today( $date ) );
    330370            // Iterate over all events in the month; If none, the later loop will print out the blank month
  • cs-integration/trunk/public/shortcodes/class-cs-compact-event-view.php

    r3257115 r3468771  
    3232
    3333    /*
     34     * Constant values created to prevent unnecessary re-creation of values used in expressions
     35     * @since 1.0.0
     36     */
     37    protected \IntlDateFormatter $timeFormat;
     38
     39    /*
    3440     * The event to be displayed, set via the constructor
    3541     * @since 1.0.0
     
    5157        parent::__construct( $cs );
    5258        $this->cs_event = $cs_event;
     59        $this->set_date_formatters();
     60    }
     61
     62    /*
     63     * Set the 'constant' values used to remove repeated instance creation of the required date formatters.
     64     */
     65    private function set_date_formatters() {
     66        // Set the date formatters used to remove repeated instance creation
     67        $this->timeFormat = datefmt_create(
     68            \Locale::getDefault(),
     69            \IntlDateFormatter::NONE,
     70            \IntlDateFormatter::SHORT,
     71            null,
     72            \IntlDateFormatter::GREGORIAN
     73        );
    5374    }
    5475
     
    6889        // Display the event time and the end time if provided
    6990        if ( $this->cs_event->is_start_date() ) {
    70             $output .= '    <div class="cs-time"><span class="cs-start-time">' . date_format( $this->cs_event->get_start_date(), 'g:ia' ) . '</span>';
    71             $output .= ( $this->cs_event->is_end_date() ) ? '-' . '<span class="cs-end-time">' . date_format( $this->cs_event->get_end_date(), 'g:ia' ) . '</span>' : '';
     91            $output .= '    <div class="cs-time"><span class="cs-start-time">' . datefmt_format( $this->timeFormat, $this->cs_event->get_start_date() ) . '</span>';
     92            $output .= ( $this->cs_event->is_end_date() ) ? '-' . '<span class="cs-end-time">' . datefmt_format( $this->timeFormat, $this->cs_event->get_end_date() ) . '</span>' : '';
    7293            $output .= '</div>' . "\n";
    7394        }
  • cs-integration/trunk/public/shortcodes/class-cs-event-card-view.php

    r3257115 r3468771  
    3232
    3333    /*
     34     * Constant values created to prevent unnecessary re-creation of values used in expressions
     35     * @since   1.0.2
     36     * @access  protected
     37     * @var     \IntlDateFormatter $monthAndDateFormat  - a date formatter for month name and date
     38     * @var     \IntlDateFormatter $timeFormat          - a date formatter for a hour:min time
     39     */
     40    protected \IntlDateFormatter $monthAndDateFormat;
     41    protected \IntlDateFormatter $timeFormat;
     42
     43    /*
    3444     * The event to be displayed, set via the constructor
    3545     * @since 1.0.0
     
    5161        parent::__construct( $cs );
    5262        $this->cs_event = $cs_event;
     63        $this->set_date_formatters();
     64    }
     65
     66    /*
     67     * Set the 'constant' values used to remove repeated instance creation of the required date formatters.
     68     *
     69     * @since   1.0.7
     70     */
     71    private function set_date_formatters() {
     72        // Set the date formatters used to remove repeated instance creation
     73        $this->monthAndDateFormat = datefmt_create(
     74            \Locale::getDefault(),
     75            \IntlDateFormatter::MEDIUM,
     76            \IntlDateFormatter::NONE,
     77            null,
     78            \IntlDateFormatter::GREGORIAN
     79        );
     80        $this->timeFormat = datefmt_create(
     81            \Locale::getDefault(),
     82            \IntlDateFormatter::NONE,
     83            \IntlDateFormatter::SHORT,
     84            null,
     85            \IntlDateFormatter::GREGORIAN
     86        );
    5387    }
    5488
     
    6195     */
    6296    public function display() : string {
     97
    6398        // Display the card, and include the event unique ID
    6499        $output = '<div '
     
    82117        // Display the start and end times where they are provided
    83118        if ( $this->cs_event->is_start_date() ) {
    84             $output .= '    <div class="cs-date"><span class="cs-date-gliph">' . date_format( $this->cs_event->get_start_date(),'M jS, Y' ) . '</span></div>' . "\n";
     119            $output .= '    <div class="cs-date"><span class="cs-date-gliph">' . datefmt_format( $this->monthAndDateFormat, $this->cs_event->get_start_date() ) . '</span></div>' . "\n";
    85120            $output .= '    <div class="cs-time">';
    86             $output .= '        <span class="cs-time-gliph cs-start-time">' . date_format( $this->cs_event->get_start_date(), 'g:ia' ) . '</span>';
    87             $output .= ( $this->cs_event->is_end_date() ) ? ' - <span class="cs-end-time">' . date_format( $this->cs_event->get_end_date(), 'g:ia' ) . '</span>' . "\n" : "\n";
     121            $output .= '        <span class="cs-time-gliph cs-start-time">' . datefmt_format( $this->timeFormat, $this->cs_event->get_start_date() ) . '</span>';
     122            $output .= ( $this->cs_event->is_end_date() ) ? ' - <span class="cs-end-time">' . datefmt_format( $this->timeFormat, $this->cs_event->get_end_date() ) . '</span>' . "\n" : "\n";
    88123            $output .= '    </div>' . "\n";
    89124        }
  • cs-integration/trunk/public/shortcodes/class-cs-event-list-shortcode.php

    r3357920 r3468771  
    5151    protected readonly \DateInterval $one_day;
    5252
     53    /*
     54     * Process the supplied attributes to leave only valid parameters, create the URLs
     55     * required for the JSON feed from ChurchSuite and create the means to communicate via
     56     * that JSON feed.  Also, create the unique cache key appropriate for this query.
     57     *
     58     * @since   1.0.0
     59     * @param   array() $atts       An array of strings representing the attributes of the JSON call
     60     *                              Mandatory params: church_name - the ChurchSuite recognised name of the church
     61     */
    5362    public function __construct( $atts ) {
    5463        parent::__construct( $atts, ChurchSuite::EVENTS );
     64        // Set the convenience constant, used to reduce re-calculation in the loop over events
    5565        $this->one_day = \DateInterval::createFromDateString( '1 day' );
    5666    }
     
    6575    protected function display_event_date( \DateTime $event_date ) : string {
    6676        $result = '<div class="cs-date">';
    67         $result .= '<span class="cs-day">' . $event_date->format( 'D' ) . '</span>';
    68         $result .= '<span class="cs-date-number">' . $event_date->format( 'd' ) . '</span>';
    69         $result .= '<span class="cs-month">' . $event_date->format( 'M' ) . '</span>';
    70         $result .= '<span class="cs-year">' . $event_date->format( 'Y' ) . '</span>';
     77        $result .= '<span class="cs-day">' . datefmt_format( datefmt_create( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, null, \IntlDateFormatter::GREGORIAN, 'EE' ), $event_date ) . '</span>';
     78        $result .= '<span class="cs-date-number">' . datefmt_format( datefmt_create( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, null, \IntlDateFormatter::GREGORIAN, 'dd' ), $event_date ) . '</span>';
     79        $result .= '<span class="cs-month">' . datefmt_format( datefmt_create( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, null, \IntlDateFormatter::GREGORIAN, 'MMM' ),  $event_date ) . '</span>';
     80        $result .= '<span class="cs-year">' . datefmt_format( datefmt_create( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::NONE, null, \IntlDateFormatter::GREGORIAN, 'yyyy' ),  $event_date ) . '</span>';
    7181        $result .= '</div>';
    7282        return $result;
  • cs-integration/trunk/public/shortcodes/class-cs-group.php

    r3257115 r3468771  
    147147    protected function fetch_time_of_meeting( \stdclass $group_obj ) : string {
    148148        return ( isset( $group_obj->time ) && ( $group_obj->time !== '' ) )
    149             ? date_format( date_create( $group_obj->time ), 'g:ia' )
     149            ? datefmt_format( datefmt_create( \Locale::getDefault(), \IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, \IntlDateFormatter::GREGORIAN ), date_create( $group_obj->time ) )
    150150            : '' ;
    151151    }
Note: See TracChangeset for help on using the changeset viewer.