Plugin Directory

Changeset 3292550


Ignore:
Timestamp:
05/13/2025 12:37:46 PM (11 months ago)
Author:
eventilla
Message:

Deploy version 2.0.3

Location:
eventilla-events
Files:
296 added
6 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • eventilla-events/trunk/README.md

    r3283265 r3292550  
    11# Eventilla WordPress plugin
    22
    3 Display events via Eventilla API. Add events to content via shortcode.
     3Eventilla is SaaS based event management software available from www.eventilla.com/en/. It can be used to publish event landing pages, sending event invites, gathering registrations and selling tickets. Event manager has easy to use tools and comprehensive reports, surveys and all the features needed to run succesfull events. We also offer free mobile app to scan tickets with QR-codes.
    44
    5 ## Plugin requirements
     5You can show Eventilla events on your WordPress site either as a single event or as a list of events. Shortcode and Block Editor is supported.
    66
    7 - Requires support for PHP SimpleXML library
     7Event lists can be filtered with tags added in Eventilla.
    88
    9 ## Plugin restriction
     9Because events are saved as custom posts, it is possible to query the posts with a custom wp-query.
    1010
    11 - Because of duplicate ids in eventilla form.
     11Published in [official WordPress plugin repository](https://wordpress.org/plugins/eventilla-events/)
    1212
    13 ## Updating the plugin
     13## Plugin development
     14This guide presumes that you have local WordPress installation running.
    1415
    15 When publishing an update, update the version number in the `eventilla-wp.php` file:
     16For local MacOS development [Laravel Valet](https://laravel.com/docs/11.x/valet) or [Laravel Herd](https://herd.laravel.com) are recommended environments to run local WordPress installation.
     17
     18### Starting the development
     19#### 1. Clone the repository to your PROJECT_FOLDER
     20```
     21cd PROJECT_FOLDER
     22git clone git@gitlab.com:eventilla/wordpress-plugin-v2.git
     23```
     24#### 2. Add the plugin to your WordPress installation
     25```
     26# Symlink the plugin so development can happen in PROJECT_FOLDER
     27ln -s wordpress-plugin-v2 WORDPRESS_INSTALLATION_PATH/wp-content/plugins/eventilla-events
     28# Activate plugin
     29cd WORDPRESS_INSTALLATION_PATH
     30wp plugin activate eventilla-events
     31```
     32#### 3. Node
     33```
     34cd PROJECT_FOLDER
     35npm install
     36# Run node (if you develop React functionality)
     37npm run start
     38```
     39
     40### Development practices
     41- Use feature/fix branches and PR's to master in Gitlab
     42- Use existing WP React components if available: see https://wordpress.github.io/gutenberg
     43- See [@wp-scripts](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/) about collection of reusable scripts tailored for WordPress development.
     44- See [WordPress's plugin development best practices](https://developer.wordpress.org/plugins/plugin-basics/best-practices/)
     45
     46### React development
     47- Main file `public/build/index.tsx`
     48- Loaded: Eventilla_WP_Admin::enqueue_scripts();
     49- Uses TypeScript for type safety
     50- Integrates with WordPress components (@wordpress/components)
     51- Supports WordPress i18n (@wordpress/i18n)
     52- Hot reloading during development
     53- Production builds output to public/build/
     54
     55### Rest routes
     56 The `Eventilla_WP_REST_API` implements custom REST API endpoints for the Eventilla WordPress plugin. It provides functionality for managing events, filters, and tools through WordPress's REST API.
     57
     58#### Current Endpoints
     59The plugin currently provides the following endpoints under the `eventilla/v1` namespace:
     60
     61- `GET /eventilla/v1/filters` - Retrieves filter data for the Eventilla Tools page
     62- `POST /eventilla/v1/events` - Fetches events with various filtering options
     63- `POST /eventilla/v1/events/update` - Queues events for update from the Eventilla Tools page
     64
     65#### Adding a New Route
     66
     67To add a new route to the API, follow these steps:
     68
     691. Add your route configuration to the `$routes` array in the class:
     70
     71```php
     72private static $routes = [
     73    // ... existing routes ...
     74    'your-new-endpoint' => [
     75        'methods' => 'GET', // or 'POST', 'PUT', 'DELETE'
     76        'callback' => [self::class, 'your_callback_method'],
     77        'permission_callback' => [self::class, 'current_user_can_manage_options'],
     78    ],
     79];
     80```
     81
     822. Create the callback method in the class:
     83
     84```php
     85public static function your_callback_method($request) {
     86    // Your endpoint logic here
     87    return rest_ensure_response($your_data);
     88}
     89```
     90
     913. The route will be automatically registered when the plugin initializes.
     92
     93### Custom endpoints
     94
     95The `Eventilla_WP_Router` class provides a simple routing system for WordPress that allows you to create custom endpoints accessible via `wp-load.php`.
     96
     97The router listens for requests to `wp-load.php` with a specific namespace parameter (`eventilla_route`). When a matching request is found, it validates the request parameters and authentication (if required) before executing the corresponding callback function.
     98
     99#### Adding a New Route
     100
     101To add a new route, you need to add an entry to the `$routes` array in the `Eventilla_WP_Router` class. Here's the structure:
     102
     103```php
     104'route_name' => [
     105    'parameters' => [
     106        'parameter_name' => true, // true means parameter is required
     107        // or
     108        'parameter_name' => ['value1', 'value2'], // array of allowed values
     109    ],
     110    'auth' => true, // whether authentication is required
     111    'auth_option' => 'option_name', // WordPress option name containing the secret
     112    'callback' => ['Class_Name', 'method_name'], // callback to execute
     113],
     114```
     115
     116### Logs
     117You can define log level in settings to see debug information.
     118
     119### Update changes
     120If there are any changes you need to run **just once** after the plugin is updated, add a new function to the `includes/class-eventilla-wp-updater.php` files `$updates` array. Key is the version number and value is the function name to be ran once from the class.
     121
     122## Making new release
     1231. Merge feature branches via pull request (squash commits and delete branch after merge) to `master`
     1242. Pull `master` to local environment and test basic functionality
     125- Event updating works
     126- Admin views work
     127- New functionality works
     1283. Add new version info
     129Note that we are using [semver](https://semver.org/).
     130When publishing an update, update the version number
     131- in `eventilla-wp.php` Plugin info
     132- in the `eventilla-wp.php` file:`define('EVENTILLA_WP_VERSION', '1.9.0');`
     1334. Update release info to `README.txt`
     134At least add new version line below description.
     1355. Build npm for production `npm run build`
     1366. Commit and add tag
     137Commit changes with new version number
     138```
     139git add eventilla-wp.php README.txt
     140git commit -m"VERSION MUMBER HERE"
     141git tag -a [VERSION NUMBER] -m[SHORT DESCRIPTION ABOUT THE NEW VERSION]"
     142```
     143
     144Finally, push the changes with the tag. OBS! This runs CI/CD pipeline in Gitlab which releases the changes to WordPress plugin repository.
    16145
    17146```
    18 define('EVENTILLA_WP_VERSION', '1.9.0');
     147git push origin master --tags
    19148```
    20149
    21 If there are any changes you need to run once after the plugin is updated, add a new function to the `includes/class-eventilla-wp-updater.php` files `$updates` array. Key is the version number and value is the function name to be ran once from the class.
     150
    22151
    23152## Librariers
  • eventilla-events/trunk/README.txt

    r3290524 r3292550  
    66Tested up to: 6.7.1
    77Requires PHP: 7.4
    8 Stable tag: 2.0.2
     8Stable tag: 2.0.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5353== Screenshots ==
    5454
    55 == Changelog ==
     55=== Changelog ==
     56= 2.0.3 =
     57- Adds support for datafields and datafields_extended.
    5658= 2.0.2 =
    5759- Bug fixes
    5860- Eventilla tags are again saved as custom taxonomy terms
    5961= 2.0.1 =
    60 - Added missing files from previous update
    61 = 2.0.0 =
     62- Added missing files from previous update 2.0.0
    6263- Rewrote API Client for efficiency
    6364- Fixed images being deleted when event is if they are used elsewhere
  • eventilla-events/trunk/admin/settings/class-eventilla-opt-chosen-event-fields.php

    r3283302 r3292550  
    3030    public function sanitize_field($raw)
    3131    {
    32         $allowedEventFields = ["id", "url", "languages", "name", "description", "short_description", "timezone", "starts", "ends", "organization", "organization_id", "location", "logo", "status", "modified", "tickets", "forms", "tags", "datafields", "template", "max_attendees", "registration_open", "tabs"];
     32        $allowedEventFields = [
     33         "id",
     34         "url",
     35         "languages",
     36         "name", "description",
     37         "short_description",
     38         "timezone",
     39         "starts",
     40         "ends",
     41         "organization",
     42         "organization_id",
     43         "location",
     44         "logo",
     45         "status",
     46         "modified",
     47         "tickets",
     48         "forms",
     49         "tags",
     50         "datafields",
     51         "datafields_extended",
     52         "template",
     53         "max_attendees",
     54         "registration_open",
     55         "tabs"
     56        ];
    3357        $sanitizedArrayOfFields = [];
    3458        if (!empty($raw)) {
  • eventilla-events/trunk/admin/settings/class-eventilla-opt.php

    r3283302 r3292550  
    1818    {
    1919        \add_settings_field(
    20             self::$prefix . $this->get_option_name(),
     20            $this->get_option_name(),
    2121            $this->description,
    2222            [$this, 'render_field'],
     
    3030        register_setting(
    3131            self::$plugin_name,
    32             self::$prefix . $this->get_option_name(),
     32            $this->get_option_name(),
    3333            [$this, 'sanitize_field']
    3434        );
  • eventilla-events/trunk/eventilla-wp.php

    r3290524 r3292550  
    1616 * Plugin URI:        https://www.eventilla.com/
    1717 * Description:       Eventilla Events brings your event information from eventilla.com to WordPress as custom posts.
    18  * Version:           2.0.2
     18 * Version:           2.0.3
    1919 * Author:            Eventilla
    2020 * Author URI:        http://www.eventilla.com
     
    3636 */
    3737if(!defined('EVENTILLA_WP_VERSION')) {
    38     define('EVENTILLA_WP_VERSION', '2.0.0');
     38    define('EVENTILLA_WP_VERSION', '2.0.3');
    3939}
    4040
  • eventilla-events/trunk/includes/model/class-eventilla-event.php

    r3290524 r3292550  
    172172            return $event;
    173173        }
     174       
    174175        $event->update_wp_post_with_eventilla_data( $body );
    175176
     
    263264        }
    264265
     266        $this->post = get_post( $post_result );
     267
    265268        $this->logger->debug( 'WordPress post updated', [ 'eventilla_uid' => $this->eventilla_uid, 'post_id' => $post_result ] );
    266         $this->post = get_post( $post_result );
    267 
    268269
    269270        // Finally, set tags as terms in 'eventilla_tag' taxonomy.
     
    280281     * @author Anttoni Niemenmaa / Eventilla <tuki@eventilla.com>
    281282     */
    282     private function save_terms( array $event ): array {
     283    private function save_terms($event) {
    283284
    284285        $tags = [];
    285         
     286       
    286287        if( array_key_exists('tags', $event) ) {
    287288            $tags = json_decode($event['tags']);
     
    323324     */
    324325    private function get_meta_input( array $event ): array {
     326
     327
     328        $this->logger->debug( 'Getting meta input for event', [ 'eventilla_uid' => $this->eventilla_uid, 'event' => $event ] );
    325329
    326330        $meta_input = [
     
    350354            'eventilla_modified'          => ((string) $event['modified'])??null,
    351355            'eventilla_tabs'              => isset($event['tabs']) ? (string) json_encode($event['tabs']) : null,
     356            'eventilla_datafields'        => isset($event['datafields']) ? (string) json_encode($event['datafields']) : null,
     357            'eventilla_datafields_extended' => isset($event['datafields_extended']) ? (string) json_encode($event['datafields_extended']) : null,
    352358        ];
    353359
  • eventilla-events/trunk/public/build/index.asset.php

    r3283302 r3292550  
    1 <?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '92fc6568b9941bc0899f');
     1<?php return array('dependencies' => array('react', 'react-jsx-runtime', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'e35420f1d6d968851b61');
  • eventilla-events/trunk/public/build/index.js

    r3283302 r3292550  
    1 (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,n=window.wp.domReady;var s=e.n(n);const o=window.wp.element,a=window.wp.i18n,l=window.wp.components,i=window.ReactJSXRuntime,d=({label:e,value:n,onChange:s,events:o})=>{const[a,d]=(0,t.useState)(!1),[r,c]=(0,t.useState)(""),h=o.map((e=>({date:new Date(e.start_date)})));return(0,i.jsxs)("div",{style:{width:"180px"},children:[(0,i.jsx)(l.Button,{style:{width:"100%",height:"28px",justifyContent:"center"},variant:"primary",onClick:()=>d(!a),children:n?(e=>{if(!e)return"";const t=new Date(e);return`${t.getDate()}.${t.getMonth()+1}.${t.getFullYear()}`})(n):e}),a&&(0,i.jsx)(l.Popover,{onClose:()=>d(!1),position:"bottom center",children:(0,i.jsx)("div",{style:{padding:"10px"},children:(0,i.jsx)(l.DatePicker,{currentDate:n,startOfWeek:1,label:e,value:n,events:h,onChange:e=>{c(e),d(!1),s(e)}})})})]})},r=({events:e,onCityChange:n,onTagChange:s,onSearchChange:o,onFutureEventsChange:r,onDateFromChange:c,onDateToChange:h,selectedEvents:p,setSelectedEvents:v})=>{const[g,x]=(0,t.useState)(!0),[u,j]=(0,t.useState)([]),[y,C]=(0,t.useState)([]),[_,w]=(0,t.useState)(""),[m,S]=(0,t.useState)(""),[f,b]=(0,t.useState)(""),[E,D]=(0,t.useState)(""),[T,k]=(0,t.useState)("");return(0,t.useEffect)((()=>{fetch("https://wordpress-vanilla.test/wp-json/eventilla/v1/filters",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce}}).then((e=>e.json())).then((e=>{j(e.cities),C(e.tags)}))}),[]),(0,i.jsxs)("div",{style:{display:"flex",gap:"30px",alignItems:"end",justifyContent:"start",marginBottom:"10px"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",height:"29px",fontSize:"14px",color:"#666"},children:[(0,i.jsx)(l.FormToggle,{checked:g,onChange:()=>{const e=!g;x(e),r(e),e&&(b(""),c(""))}}),(0,i.jsx)("div",{children:(0,a.__)("Event in future","eventilla-tools")})]}),(0,i.jsx)(d,{label:(0,a.__)("Start date from","eventilla-tools"),value:f,onChange:e=>{if(b(e),c(e),e){const t=new Date(e),n=new Date;n.setHours(0,0,0,0),t<n&&g&&(x(!1),r(!1))}},events:e}),(0,i.jsx)(d,{label:(0,a.__)("Start date to","eventilla-tools"),value:E,onChange:e=>{D(e),h(e)},events:e}),(0,i.jsx)("div",{style:{height:"52px",width:"200px"},children:(0,i.jsx)(l.ComboboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Select city","eventilla-tools"),value:_,onChange:e=>{w(e),n(e)},onFilterValueChange:()=>{},options:u,allowReset:!0})}),(0,i.jsx)("div",{style:{height:"52px",width:"200px"},children:(0,i.jsx)(l.ComboboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Select tag","eventilla-tools"),className:"eventilla-tools__combobox-control",value:m,onChange:e=>{S(e),s(e)},onFilterValueChange:()=>{},options:y,allowReset:!0})}),(0,i.jsx)("div",{style:{backgroundColor:"white"},children:(0,i.jsx)(l.SearchControl,{__nextHasNoMarginBottom:!0,style:{height:"29px",border:"1px solid #E0E0E0"},label:(0,a.__)("Search events","eventilla-tools"),value:T,onChange:e=>{k(e),o(e)}})})]})},c=({key:e,event:t,selectedEvents:n,setSelectedEvents:s,index:o})=>(0,i.jsxs)("div",{className:"event-item",style:{display:"grid",gridTemplateColumns:"3fr 1fr 1fr 1fr 1fr",alignItems:"center",gap:"10px",padding:"10px 10px 20px 10px",borderBottom:"1px solid #d9dadc",backgroundColor:o%2==1?"transparent":"#f6f7f7"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"top",gap:"10px",fontWeight:"bold"},children:[(0,i.jsx)(l.CheckboxControl,{checked:n.includes(t),onChange:()=>s([...n,t])}),(0,i.jsx)("a",{style:{textDecoration:"none"},href:`/wp-admin/post.php?post=${t.id}&action=edit`,children:t.title})]}),(0,i.jsx)("div",{children:new Date(t.start_date).toLocaleDateString()}),(0,i.jsx)("div",{children:new Date(t.end_date).toLocaleDateString()}),(0,i.jsx)("div",{children:t.city}),(0,i.jsx)("div",{children:(()=>{try{return JSON.parse(t.tags).join(", ")}catch{return t.tags}})()})]}),h=({events:e,selectedEvents:t,setSelectedEvents:n})=>(0,i.jsxs)("div",{style:{backgroundColor:"white",border:"1px solid #d9dadc"},children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr 1fr 1fr 1fr",alignItems:"center",gap:"10px",padding:"10px",borderBottom:"1px solid #d9dadc"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,i.jsx)(l.CheckboxControl,{__nextHasNoMarginBottom:!0,checked:t.length===e.length,onChange:t=>{n(t?[...e]:[])}}),(0,a.__)("Title","eventilla-tools")]}),(0,i.jsx)("div",{children:(0,a.__)("Start Date","eventilla-tools")}),(0,i.jsx)("div",{children:(0,a.__)("End Date","eventilla-tools")}),(0,i.jsx)("div",{children:(0,a.__)("City","eventilla-tools")}),(0,i.jsx)("div",{children:(0,a.__)("Tags","eventilla-tools")})]}),e.map(((e,s)=>(0,i.jsx)(c,{event:e,selectedEvents:t,setSelectedEvents:n,index:s},e.id)))]}),p=()=>{const[e,n]=(0,t.useState)([]),[s,o]=(0,t.useState)(""),[d,c]=(0,t.useState)(""),[p,v]=(0,t.useState)(""),[g,x]=(0,t.useState)(!0),[u,j]=(0,t.useState)(""),[y,C]=(0,t.useState)(""),[_,w]=(0,t.useState)([]),[m,S]=(0,t.useState)(!1);return(0,t.useEffect)((()=>{((e,t,s,o=!0,a,l)=>{const i={args:{post_type:"eventilla_event",...e?{city:e}:{},...t?{tag:t}:{},...s?{search:s}:{},future_events:o,...a?{date_from:a}:{},...l?{date_to:l}:{}}};fetch("/wp-json/eventilla/v1/events",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce},body:JSON.stringify(i)}).then((e=>e.json())).then((e=>{n(e)}))})(s,d,p,g,u,y)}),[s,d,p,g,u,y]),(0,i.jsx)("div",{style:{width:"100%",minHeight:"100vh"},children:(0,i.jsxs)("div",{style:{padding:"20px"},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,i.jsx)("h1",{children:(0,a.__)("Eventilla Tools","eventilla-tools")}),(0,i.jsx)(l.Button,{isSecondary:!0,onClick:()=>{S(!0),fetch("/wp-json/eventilla/v1/events/update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce},body:JSON.stringify({events:_})}).then((e=>e.json())).then((e=>{S(!1),alert((0,a.__)("Events have been queued for update.","eventilla-tools")),window.location.reload(),S(!1)})).catch((e=>{console.error(e),S(!1)}))},disabled:m,children:m?(0,a.__)("Updating...","eventilla-tools"):(0,a.__)("Update Events","eventilla-tools")})]}),(0,i.jsxs)("div",{style:{marginTop:"20px"},children:[(0,i.jsx)(r,{events:e,onCityChange:e=>{o(e)},onTagChange:e=>{c(e)},onSearchChange:e=>{v(e)},onFutureEventsChange:e=>{x(e)},onDateFromChange:e=>{j(e)},onDateToChange:e=>{C(e)}}),(0,i.jsx)(h,{events:e,selectedEvents:_,setSelectedEvents:w})]})]})})};s()((()=>{const e=document.getElementById("eventilla-tools");console.log(e),e&&(0,o.createRoot)(e).render((0,i.jsx)(p,{}))}))})();
     1(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,n=window.wp.domReady;var o=e.n(n);const s=window.wp.element,a=window.wp.i18n,l=window.wp.components,i=window.ReactJSXRuntime,d=({label:e,value:n,onChange:o,events:s})=>{const[a,d]=(0,t.useState)(!1),[r,c]=(0,t.useState)(""),h=s.map((e=>({date:new Date(e.start_date)})));return(0,i.jsxs)("div",{style:{width:"180px"},children:[(0,i.jsx)(l.Button,{style:{width:"100%",height:"28px",justifyContent:"center"},variant:"primary",onClick:()=>d(!a),children:n?(e=>{if(!e)return"";const t=new Date(e);return`${t.getDate()}.${t.getMonth()+1}.${t.getFullYear()}`})(n):e}),a&&(0,i.jsx)(l.Popover,{onClose:()=>d(!1),position:"bottom center",children:(0,i.jsx)("div",{style:{padding:"10px"},children:(0,i.jsx)(l.DatePicker,{currentDate:n,startOfWeek:1,label:e,value:n,events:h,onChange:e=>{c(e),d(!1),o(e)}})})})]})},r=({events:e,onCityChange:n,onTagChange:o,onSearchChange:s,onFutureEventsChange:r,onDateFromChange:c,onDateToChange:h,selectedEvents:p,setSelectedEvents:v})=>{const[g,x]=(0,t.useState)(!0),[u,j]=(0,t.useState)([]),[y,C]=(0,t.useState)([]),[_,w]=(0,t.useState)(""),[m,S]=(0,t.useState)(""),[f,b]=(0,t.useState)(""),[E,D]=(0,t.useState)(""),[T,k]=(0,t.useState)("");return(0,t.useEffect)((()=>{fetch("/wp-json/eventilla/v1/filters",{method:"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce}}).then((e=>e.json())).then((e=>{j(e.cities),C(e.tags)}))}),[]),(0,i.jsxs)("div",{style:{display:"flex",gap:"30px",alignItems:"end",justifyContent:"start",marginBottom:"10px"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px",height:"29px",fontSize:"14px",color:"#666"},children:[(0,i.jsx)(l.FormToggle,{checked:g,onChange:()=>{const e=!g;x(e),r(e),e&&(b(""),c(""))}}),(0,i.jsx)("div",{children:(0,a.__)("Event in future","eventilla-tools")})]}),(0,i.jsx)(d,{label:(0,a.__)("Start date from","eventilla-tools"),value:f,onChange:e=>{if(b(e),c(e),e){const t=new Date(e),n=new Date;n.setHours(0,0,0,0),t<n&&g&&(x(!1),r(!1))}},events:e}),(0,i.jsx)(d,{label:(0,a.__)("Start date to","eventilla-tools"),value:E,onChange:e=>{D(e),h(e)},events:e}),(0,i.jsx)("div",{style:{height:"52px",width:"200px"},children:(0,i.jsx)(l.ComboboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Select city","eventilla-tools"),value:_,onChange:e=>{w(e),n(e)},onFilterValueChange:()=>{},options:u,allowReset:!0})}),(0,i.jsx)("div",{style:{height:"52px",width:"200px"},children:(0,i.jsx)(l.ComboboxControl,{__nextHasNoMarginBottom:!0,label:(0,a.__)("Select tag","eventilla-tools"),className:"eventilla-tools__combobox-control",value:m,onChange:e=>{S(e),o(e)},onFilterValueChange:()=>{},options:y,allowReset:!0})}),(0,i.jsx)("div",{style:{backgroundColor:"white"},children:(0,i.jsx)(l.SearchControl,{__nextHasNoMarginBottom:!0,style:{height:"29px",border:"1px solid #E0E0E0"},label:(0,a.__)("Search events","eventilla-tools"),value:T,onChange:e=>{k(e),s(e)}})})]})},c=({key:e,event:t,selectedEvents:n,setSelectedEvents:o,index:s})=>(0,i.jsxs)("div",{className:"event-item",style:{display:"grid",gridTemplateColumns:"3fr 1fr 1fr 1fr 1fr",alignItems:"center",gap:"10px",padding:"10px 10px 20px 10px",borderBottom:"1px solid #d9dadc",backgroundColor:s%2==1?"transparent":"#f6f7f7"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"top",gap:"10px",fontWeight:"bold"},children:[(0,i.jsx)(l.CheckboxControl,{checked:n.includes(t),onChange:()=>o([...n,t])}),(0,i.jsx)("a",{style:{textDecoration:"none"},href:`/wp-admin/post.php?post=${t.id}&action=edit`,children:t.title})]}),(0,i.jsx)("div",{children:new Date(t.start_date).toLocaleDateString()}),(0,i.jsx)("div",{children:new Date(t.end_date).toLocaleDateString()}),(0,i.jsx)("div",{children:t.city}),(0,i.jsx)("div",{children:(()=>{try{return JSON.parse(t.tags).join(", ")}catch{return t.tags}})()})]}),h=({events:e,selectedEvents:t,setSelectedEvents:n})=>(0,i.jsxs)("div",{style:{backgroundColor:"white",border:"1px solid #d9dadc"},children:[(0,i.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr 1fr 1fr 1fr",alignItems:"center",gap:"10px",padding:"10px",borderBottom:"1px solid #d9dadc"},children:[(0,i.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[(0,i.jsx)(l.CheckboxControl,{__nextHasNoMarginBottom:!0,checked:t.length===e.length,onChange:t=>{n(t?[...e]:[])}}),(0,a.__)("Title","eventilla-tools")]}),(0,i.jsx)("div",{children:(0,a.__)("Start Date","eventilla-tools")}),(0,i.jsx)("div",{children:(0,a.__)("End Date","eventilla-tools")}),(0,i.jsx)("div",{children:(0,a.__)("City","eventilla-tools")}),(0,i.jsx)("div",{children:(0,a.__)("Tags","eventilla-tools")})]}),e.map(((e,o)=>(0,i.jsx)(c,{event:e,selectedEvents:t,setSelectedEvents:n,index:o},e.id)))]}),p=()=>{const[e,n]=(0,t.useState)([]),[o,s]=(0,t.useState)(""),[d,c]=(0,t.useState)(""),[p,v]=(0,t.useState)(""),[g,x]=(0,t.useState)(!0),[u,j]=(0,t.useState)(""),[y,C]=(0,t.useState)(""),[_,w]=(0,t.useState)([]),[m,S]=(0,t.useState)(!1);return(0,t.useEffect)((()=>{((e,t,o,s=!0,a,l)=>{const i={args:{post_type:"eventilla_event",...e?{city:e}:{},...t?{tag:t}:{},...o?{search:o}:{},future_events:s,...a?{date_from:a}:{},...l?{date_to:l}:{}}};fetch("/wp-json/eventilla/v1/events",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce},body:JSON.stringify(i)}).then((e=>e.json())).then((e=>{n(e)}))})(o,d,p,g,u,y)}),[o,d,p,g,u,y]),(0,i.jsx)("div",{style:{width:"100%",minHeight:"100vh"},children:(0,i.jsxs)("div",{style:{padding:"20px"},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,i.jsx)("h1",{children:(0,a.__)("Eventilla Tools","eventilla-tools")}),(0,i.jsx)(l.Button,{isSecondary:!0,onClick:()=>{S(!0),fetch("/wp-json/eventilla/v1/events/update",{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":window.wpApiSettings.nonce},body:JSON.stringify({events:_})}).then((e=>e.json())).then((e=>{S(!1),alert((0,a.__)("Events have been queued for update.","eventilla-tools")),window.location.reload(),S(!1)})).catch((e=>{console.error(e),S(!1)}))},disabled:m,children:m?(0,a.__)("Updating...","eventilla-tools"):(0,a.__)("Update Events","eventilla-tools")})]}),(0,i.jsxs)("div",{style:{marginTop:"20px"},children:[(0,i.jsx)(r,{events:e,onCityChange:e=>{s(e)},onTagChange:e=>{c(e)},onSearchChange:e=>{v(e)},onFutureEventsChange:e=>{x(e)},onDateFromChange:e=>{j(e)},onDateToChange:e=>{C(e)}}),(0,i.jsx)(h,{events:e,selectedEvents:_,setSelectedEvents:w})]})]})})};o()((()=>{const e=document.getElementById("eventilla-tools");console.log(e),e&&(0,s.createRoot)(e).render((0,i.jsx)(p,{}))}))})();
  • eventilla-events/trunk/src/components/ToolsPageFilters.tsx

    r3283302 r3292550  
    4040
    4141    useEffect( () => {
    42         fetch( 'https://wordpress-vanilla.test/wp-json/eventilla/v1/filters', {
     42        fetch( '/wp-json/eventilla/v1/filters', {
    4343            method: 'GET',
    4444            headers: {
Note: See TracChangeset for help on using the changeset viewer.