Plugin Directory

Changeset 3772660


Ignore:
Timestamp:
10/29/2026 10:42:49 AM (3 days ago)
Author:
automaize
Message:

Expose "Anzahl Events"/"Sichtbarkeit in die Zukunft" via staff REST (1.6.3)

GET/PUT /amzec/v1/staff/settings lets the app read and change these two
settings without a trip to wp-admin.

Location:
automaize-event-calendar/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • automaize-event-calendar/trunk/automaize-event-calendar.php

    r3772653 r3772660  
    33 * Plugin Name: Automaize Event Calendar
    44 * Description: Displays upcoming events in a responsive tile grid with recurring event support and optional WooCommerce integration.
    5  * Version:     1.6.2
     5 * Version:     1.6.3
    66 * Author:      Automaize
    77 * Author URI:  https://automaize.app
    … …  
    1818}
    1919
    20 define( 'AMZEC_VERSION', '1.6.2' );
     20define( 'AMZEC_VERSION', '1.6.3' );
    2121define( 'AMZEC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    2222define( 'AMZEC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • automaize-event-calendar/trunk/includes/class-aec-rest.php

    r3772653 r3772660  
    198198                register_rest_route(
    199199                        self::NAMESPACE_,
     200                        '/staff/settings',
     201                        array(
     202                                array(
     203                                        'methods'             => WP_REST_Server::READABLE,
     204                                        'callback'            => array( __CLASS__, 'get_staff_settings' ),
     205                                        'permission_callback' => array( __CLASS__, 'check_api_key' ),
     206                                ),
     207                                array(
     208                                        'methods'             => WP_REST_Server::EDITABLE,
     209                                        'callback'            => array( __CLASS__, 'update_staff_settings' ),
     210                                        'permission_callback' => array( __CLASS__, 'check_api_key' ),
     211                                ),
     212                        )
     213                );
     214
     215                register_rest_route(
     216                        self::NAMESPACE_,
    200217                        '/staff/media',
    201218                        array(
    … …  
    586603
    587604                return rest_ensure_response( array( 'success' => true ) );
     605        }
     606
     607        /**
     608         * GET /staff/settings - the subset of Events > Einstellungen that the
     609         * app also lets staff change directly (currently: "Anzahl Events" /
     610         * "Sichtbarkeit in die Zukunft"). Everything else on that settings page
     611         * (API key, accent color, button text) stays wp-admin-only.
     612         *
     613         * @return WP_REST_Response
     614         */
     615        public static function get_staff_settings() {
     616                $opts = AMZEC_Settings::get_options();
     617                return rest_ensure_response(
     618                        array(
     619                                'default_count'       => (int) $opts['default_count'],
     620                                'default_future_days' => (int) $opts['default_future_days'],
     621                        )
     622                );
     623        }
     624
     625        /**
     626         * PUT /staff/settings { default_count?, default_future_days? }
     627         *
     628         * @param WP_REST_Request $request Request.
     629         * @return WP_REST_Response
     630         */
     631        public static function update_staff_settings( WP_REST_Request $request ) {
     632                return rest_ensure_response( AMZEC_Settings::update_display_defaults( $request->get_params() ) );
    588633        }
    589634
  • automaize-event-calendar/trunk/includes/class-aec-settings.php

    r3708972 r3772660  
    279279
    280280        /**
     281         * Updates just default_count/default_future_days, leaving every other
     282         * option (api_key, primary_color, ...) untouched - used by the staff
     283         * REST route so the app can offer these two without a way to overwrite
     284         * the rest of this option via a partial payload.
     285         *
     286         * @param array $data { default_count?, default_future_days? }
     287         * @return array{default_count:int, default_future_days:int}
     288         */
     289        public static function update_display_defaults( array $data ) {
     290                $current = get_option( self::OPTION_KEY, array() );
     291
     292                if ( isset( $data['default_count'] ) ) {
     293                        $current['default_count'] = max( 1, min( 100, absint( $data['default_count'] ) ) );
     294                }
     295                if ( isset( $data['default_future_days'] ) ) {
     296                        $current['default_future_days'] = absint( $data['default_future_days'] );
     297                }
     298
     299                update_option( self::OPTION_KEY, $current );
     300
     301                $opts = self::get_options();
     302                return array(
     303                        'default_count'       => (int) $opts['default_count'],
     304                        'default_future_days' => (int) $opts['default_future_days'],
     305                );
     306        }
     307
     308        /**
    281309         * Returns the merged options with defaults.
    282310         */
  • automaize-event-calendar/trunk/readme.txt

    r3772653 r3772660  
    55Tested up to:      7.0
    66Requires PHP:      7.4
    7 Stable tag:        1.6.2
     7Stable tag:        1.6.3
    88License:           GPL-2.0-or-later
    99License URI:       https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7979== Changelog ==
    8080
     81= 1.6.3 =
     82* New: `GET`/`PUT /amzec/v1/staff/settings` exposes "Anzahl Events" and "Sichtbarkeit in die Zukunft" (from Events > Einstellungen) to the app, so staff can change how many events show without a trip to wp-admin.
     83
    8184= 1.6.2 =
    8285* Fix: `GET /amzec/v1/events` (used by the website's homepage) ignored the "Anzahl Events" setting under Events > Einstellungen when the caller didn't pass its own `count` - it silently fell back to a hardcoded 12 instead. It now falls back to the configured setting, same as the `[amzec_events]` shortcode already did.
Note: See TracChangeset for help on using the changeset viewer.