Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRACKING-PR: Export & Import, plus block cherries #25

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/blocks/event-date/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '9a693c52f333685e40d8');
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => '7e39cbc446a04833fd2d');
2 changes: 1 addition & 1 deletion build/blocks/event-date/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/events-list/events-list.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '312b602bf15d128a6649');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '425cbfc777f973f269e8');
10 changes: 5 additions & 5 deletions build/blocks/events-list/events-list.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/events-list/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '4418243136224c349ef8');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '52e9a2c60b1e9c4bd949');
10 changes: 5 additions & 5 deletions build/blocks/events-list/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/online-event/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '22c4d9952ae84d4f8973');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'ff0e9054014152ff4254');
2 changes: 1 addition & 1 deletion build/blocks/online-event/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/online-event/online-event.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'f43e82fe6319c886ac86');
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '05f1e5613efaf2de28d8');
2 changes: 1 addition & 1 deletion build/blocks/online-event/online-event.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '2999d8fa4ee33d0629f3');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '66dc6181d71b53497b9b');
10 changes: 5 additions & 5 deletions build/blocks/rsvp/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/rsvp/rsvp.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '9c0620b4f014481d9eb4');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '5ff709f139c55900a4f1');
10 changes: 5 additions & 5 deletions build/blocks/rsvp/rsvp.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/venue/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => 'be4e990d06a384882695');
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-date', 'wp-element', 'wp-i18n'), 'version' => 'ca97c7f43478ea502d02');
2 changes: 1 addition & 1 deletion build/blocks/venue/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/blocks/venue/venue.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '099b5eebfcf36f51f05e');
<?php return array('dependencies' => array('react', 'wp-components', 'wp-data', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => '9ba1e4313b72a8d0d2e6');
2 changes: 1 addition & 1 deletion build/blocks/venue/venue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/panels.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-date', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '0e9cff2f47704ffb8596');
<?php return array('dependencies' => array('moment', 'react', 'wp-api-fetch', 'wp-components', 'wp-core-data', 'wp-data', 'wp-date', 'wp-edit-post', 'wp-element', 'wp-i18n', 'wp-plugins'), 'version' => '35cd67adc5273b90d0ae');
2 changes: 1 addition & 1 deletion build/panels.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gatherpress.php
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
* Author URI: https://gatherpress.org/
* Version: 0.29.0-alpha
* Requires PHP: 7.4
* Requires at least: 6.4
* Requires at least: 6.5
* Text Domain: gatherpress
* Domain Path: /languages
* License: GNU General Public License v2.0 or later
48 changes: 48 additions & 0 deletions includes/core/classes/class-block.php
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ protected function __construct() {
* @return void
*/
protected function setup_hooks(): void {
add_action( 'init', array( $this, 'register_block_patterns' ), 10 );
// Priority 11 needed for block.json translations of title and description.
add_action( 'init', array( $this, 'register_blocks' ), 11 );
add_filter( 'load_script_translation_file', array( $this, 'fix_translation_location' ), 10, 3 );
@@ -94,4 +95,51 @@ public function register_blocks(): void {
);
}
}

/**
* Register custom block patterns.
*
* This method ...
*
* @since 0.30.0
*
* @return void
*/
public function register_block_patterns(): void {

/**
* Mainly for use with the 'venue-details' block,
* which is a group block under the hood
* and uses this pattern as innerBlocks template.
*/
\register_block_pattern(
'gatherpress/venue-details',
array(
'title' => 'Invisible Venue Details Block Pattern',
// Even this post-title seems useless, it's not.
// It is the entry point for all our hooked blocks
// and as such absolutely important!
'content' => '<!-- wp:post-title /-->', // this will a be hooked ;)
'inserter' => false,
'source' => 'plugin',
)
);

/**
* Made to be used with the 'template' parameter
* when registering of the 'gatherpress_event' post type.
*/
\register_block_pattern(
'gatherpress/venue-template',
array(
'title' => 'Invisible Venue Template Block Pattern',
// Even this paragraph seems useless, it's not.
// It is the entry point for all our hooked blocks
// and as such absolutely important!
'content' => '<!-- wp:post-featured-image /--><!-- wp:paragraph {"placeholder":"Add some infos about the venue and maybe a nice picture."} --><p></p><!-- /wp:paragraph -->', // this will a be hooked ;)
'inserter' => false,
'source' => 'plugin',
)
);
}
}
101 changes: 79 additions & 22 deletions includes/core/classes/class-event-query.php
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ protected function __construct() {
*/
protected function setup_hooks(): void {
add_action( 'pre_get_posts', array( $this, 'prepare_event_query_before_execution' ) );
add_filter( 'posts_clauses', array( $this, 'adjust_admin_event_sorting' ) );
add_filter( 'posts_clauses', array( $this, 'adjust_admin_event_sorting' ), 10, 2 );
}

/**
@@ -231,10 +231,10 @@ static function () use ( $page_id ) {
switch ( $events_query ) {
case 'upcoming':
remove_filter( 'posts_clauses', array( $this, 'adjust_sorting_for_past_events' ) );
add_filter( 'posts_clauses', array( $this, 'adjust_sorting_for_upcoming_events' ) );
add_filter( 'posts_clauses', array( $this, 'adjust_sorting_for_upcoming_events' ), 10, 2 );
break;
case 'past':
add_filter( 'posts_clauses', array( $this, 'adjust_sorting_for_past_events' ) );
add_filter( 'posts_clauses', array( $this, 'adjust_sorting_for_past_events' ), 10, 2 );
remove_filter( 'posts_clauses', array( $this, 'adjust_sorting_for_upcoming_events' ) );
break;
default:
@@ -251,11 +251,27 @@ static function () use ( $page_id ) {
*
* @since 1.0.0
*
* @param array $query_pieces An array containing pieces of the SQL query.
* @see https://developer.wordpress.org/reference/hooks/posts_clauses/
*
* @param array $query_pieces An array containing pieces of the SQL query.
* @param WP_Query $query The WP_Query instance (passed by reference).
* @return array The modified SQL query pieces with adjusted sorting criteria for upcoming events.
*/
public function adjust_sorting_for_upcoming_events( array $query_pieces ): array {
return $this->adjust_event_sql( $query_pieces, 'upcoming', 'ASC' );
public function adjust_sorting_for_upcoming_events( array $query_pieces, \WP_Query $query ): array {


// \error_log( 'adjust_sorting_for_upcoming_events: ' . \var_export( [
// (bool) $query->get( 'include_unfinished' ),
// $query
// ], true ) );

return $this->adjust_event_sql(
$query_pieces,
'upcoming',
$query->get( 'order' ),
$query->get( 'orderby' ),
(bool) $query->get( 'include_unfinished' )
);
}

/**
@@ -264,12 +280,18 @@ public function adjust_sorting_for_upcoming_events( array $query_pieces ): array
* This method modifies the SQL query pieces, including join, where, orderby, etc., to adjust the sorting criteria
* for past events in the query. It ensures that events are ordered by their start datetime in the desired order.
*
* @param array $query_pieces An array containing pieces of the SQL query.
*
* @param array $query_pieces An array containing pieces of the SQL query.
* @param WP_Query $query The WP_Query instance (passed by reference).
* @return array The modified SQL query pieces with adjusted sorting criteria for past events.
*/
public function adjust_sorting_for_past_events( array $query_pieces ): array {
return $this->adjust_event_sql( $query_pieces, 'past' );
public function adjust_sorting_for_past_events( array $query_pieces, \WP_Query $query ): array {
return $this->adjust_event_sql(
$query_pieces,
'past',
$query->get( 'order' ),
$query->get( 'orderby' ),
(bool) $query->get( 'include_unfinished' )
);
}

/**
@@ -280,18 +302,17 @@ public function adjust_sorting_for_past_events( array $query_pieces ): array {
*
* @since 1.0.0
*
* @param array $query_pieces An array containing pieces of the SQL query.
* @param array $query_pieces An array containing pieces of the SQL query.
* @param WP_Query $query The WP_Query instance (passed by reference).
* @return array The modified SQL query pieces with adjusted sorting criteria.
*/
public function adjust_admin_event_sorting( array $query_pieces ): array {
public function adjust_admin_event_sorting( array $query_pieces, \WP_Query $query ): array {
if ( ! is_admin() ) {
return $query_pieces;
}

global $wp_query;

if ( 'datetime' === $wp_query->get( 'orderby' ) ) {
$query_pieces = $this->adjust_event_sql( $query_pieces, 'all', $wp_query->get( 'order' ) );
if ( 'datetime' === $query->get( 'orderby' ) ) {
$query_pieces = $this->adjust_event_sql( $query_pieces, 'all', $query->get( 'order' ) );
}

return $query_pieces;
@@ -304,14 +325,24 @@ public function adjust_admin_event_sorting( array $query_pieces ): array {
* the `gatherpress_events` table in the database join. It allows querying events based on different
* criteria such as upcoming or past events and specifying the event order (DESC or ASC).
*
* @see https://developer.wordpress.org/reference/hooks/posts_join/
* @see https://developer.wordpress.org/reference/hooks/posts_orderby/
* @see https://developer.wordpress.org/reference/hooks/posts_where/
*
* @since 1.0.0
*
* @param array $pieces An array of query pieces, including join, where, orderby, and more.
* @param string $type The type of events to query (options: 'all', 'upcoming', 'past').
* @param string $order The event order ('DESC' for descending or 'ASC' for ascending).
* @return array An array containing adjusted SQL clauses for the Event query.
*/
public function adjust_event_sql( array $pieces, string $type = 'all', string $order = 'DESC' ): array {
public function adjust_event_sql(
array $pieces,
string $type = 'all',
string $order = 'DESC',
array|string $order_by = ['datetime'],
bool $inclusive = true
): array {
global $wpdb;

$defaults = array(
@@ -324,13 +355,37 @@ public function adjust_event_sql( array $pieces, string $type = 'all', string $o
'limits' => '',
);
$pieces = array_merge( $defaults, $pieces );
$table = sprintf( Event::TABLE_FORMAT, $wpdb->prefix );
$table = sprintf( Event::TABLE_FORMAT, $wpdb->prefix ); // could also (just) be $wpdb->{gatherpress_events}
$pieces['join'] .= ' LEFT JOIN ' . esc_sql( $table ) . ' ON ' . esc_sql( $wpdb->posts ) . '.ID='
. esc_sql( $table ) . '.post_id';
$order = strtoupper( $order );

if ( in_array( $order, array( 'DESC', 'ASC' ), true ) ) {
$pieces['orderby'] = sprintf( esc_sql( $table ) . '.datetime_start_gmt %s', esc_sql( $order ) );

// ORDERBY is an array, which allows to orderby multiple values.
// Currently it is only allowed to order events by ONE value.
$order_by = ( is_array( $order_by ) ) ? $order_by[0] : $order_by;
switch ( strtolower( $order_by ) ) {
case 'id':
$pieces['orderby'] = sprintf( esc_sql( $wpdb->posts ) . '.ID %s', esc_sql( $order ) );
break;

case 'title':
$pieces['orderby'] = sprintf( esc_sql( $wpdb->posts ) . '.post_name %s', esc_sql( $order ) );
break;

case 'modified':
$pieces['orderby'] = sprintf( esc_sql( $wpdb->posts ) . '.post_modified_gmt %s', esc_sql( $order ) );
break;

case 'rand':
$pieces['orderby'] = esc_sql( 'RAND()' );
break;

case 'datetime':
default:
$pieces['orderby'] = sprintf( esc_sql( $table ) . '.datetime_start_gmt %s', esc_sql( $order ) );
break;
}
}

if ( 'all' === $type ) {
@@ -339,10 +394,12 @@ public function adjust_event_sql( array $pieces, string $type = 'all', string $o

$current = gmdate( Event::DATETIME_FORMAT, time() );

$column = ( ($inclusive && 'upcoming' === $type) || (! $inclusive && 'past' === $type) ) ? 'datetime_end_gmt' : 'datetime_start_gmt';

if ( 'upcoming' === $type ) {
$pieces['where'] .= $wpdb->prepare( ' AND %i.datetime_end_gmt >= %s', $table, $current ); // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedIdentifierPlaceholder
$pieces['where'] .= $wpdb->prepare( ' AND %i.%i >= %s', $table, $column, $current ); // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedIdentifierPlaceholder
} elseif ( 'past' === $type ) {
$pieces['where'] .= $wpdb->prepare( ' AND %i.datetime_end_gmt < %s', $table, $current ); // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedIdentifierPlaceholder
$pieces['where'] .= $wpdb->prepare( ' AND %i.%i < %s', $table, $column, $current ); // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnsupportedIdentifierPlaceholder
}

return $pieces;
1 change: 1 addition & 0 deletions includes/core/classes/class-event-setup.php
Original file line number Diff line number Diff line change
@@ -136,6 +136,7 @@ public function register_post_type(): void {
'custom-fields',
),
'menu_icon' => 'dashicons-nametag',
'has_archive' => true,
'rewrite' => array(
'slug' => _x( 'event', 'Post Type Slug', 'gatherpress' ),
),
84 changes: 77 additions & 7 deletions includes/core/classes/class-export.php
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@
use GatherPress\Core\Migrate;
use GatherPress\Core\Traits\Singleton;
use WP_Post;
use WP_Query;

/**
* Class Export.
@@ -52,10 +53,56 @@ public function __construct() {
* @return void
*/
protected function setup_hooks(): void {
add_filter( 'wxr_export_skip_postmeta', array( $this, 'set_entry_point' ), 10, 3 );
add_action( 'gatherpress_export', array( $this, 'export' ) );
// add_filter( 'wxr_export_skip_postmeta', array( $this, 'set_entry_point' ), 10, 3 );
// add_action( 'gatherpress_export', array( $this, 'export' ) );

/**
* Fires at the beginning of an export, before any headers are sent.
*
* @since 2.3.0
*
* @param array $args An array of export arguments.
*/
add_action( 'export_wp', function( $args ){

/**
* Called via setup_postdata() at the beginning of each singular post export.
*
* Fires once the post data has been set up.
*
* @param WP_Post $post The Post object (passed by reference).
* @param WP_Query $query The current Query object (passed by reference).
*/
add_action( 'the_post', function( WP_Post $post, WP_Query $query ) : void {
if ( self::validate_post( $post ) ) {
// Save a temporary marker, which allows to hook into the export process per post later on.
add_post_meta( $post->ID, 'do_export_event_meta', true );
}
}, 10, 2 );

/**
* Filters whether to selectively skip post meta used for WXR exports.
*
* @param bool $skip Whether to skip the current post meta. Default false.
* @param string $meta_key Current meta key.
* @param object $meta Current meta object.
* @return bool Whether to skip the current post meta. Default false.
*/
add_filter( 'wxr_export_skip_postmeta', function( bool $skip, string $meta_key, object $meta ) : bool {
if ( 'do_export_event_meta' === $meta_key ) {
// Echos out xml with pseudo-postmeta.
self::export( get_post( $meta->post_id ) );
// Deletes temporary marker.
delete_post_meta( $meta->post_id, 'do_export_event_meta' );
// Prevent 'normal' export processing for that particular postmeta field.
return true;
}
return $skip;
}, 10, 3 );
} );
}


/**
* Extend WordPress' native Export
*
@@ -85,7 +132,7 @@ protected function setup_hooks(): void {
* @param object $meta Current meta object.
*
* @return bool
*/
public static function set_entry_point( bool $skip, string $meta_key, object $meta ): bool {
if ( self::validate( $meta_key ) ) {
/**
@@ -96,13 +143,14 @@ public static function set_entry_point( bool $skip, string $meta_key, object $me
* @param WP_Post $post Current 'gatherpress_event' post being exported.
* @param string $meta_key Current meta key.
* @param object $meta Current meta object.
*/
* /
do_action( 'gatherpress_export', get_post(), $meta_key, $meta );
}
return $skip;
}
*/

/**
/**
* Checks if the currently exported post is of type 'gatherpress_event'
* and if the given, processed meta_key is '_edit_last'.
*
@@ -111,13 +159,35 @@ public static function set_entry_point( bool $skip, string $meta_key, object $me
* @param string $meta_key Current meta key.
*
* @return bool
*/
protected static function validate( string $meta_key = '' ): bool {
if ( Event::POST_TYPE !== get_post_type() ) {
return false;
}
if ( '_edit_last' !== $meta_key ) {
// if ( '_edit_last' !== $meta_key ) {
// return false;
// }
// Makes sure this runs only once.
if ( did_action( 'gatherpress_export' ) ) {
return false;
}
return true;
}
*/

/**
* Checks if the currently exported post is of type 'gatherpress_event'.
*
* @since 1.0.0
*
* @param WP_Post $post Current meta key.
*
* @return bool
*/
protected static function validate_post( WP_Post $post ): bool {

if ( Event::POST_TYPE !== $post->post_type ) {
return false;
}
return true;
5 changes: 4 additions & 1 deletion includes/core/classes/class-venue.php
Original file line number Diff line number Diff line change
@@ -129,7 +129,7 @@ public function register_post_type(): void {
),
'menu_icon' => 'dashicons-location',
'template' => array(
array( 'gatherpress/venue' ),
array( 'core/pattern', array( 'slug' => 'gatherpress/venue-details' ) ),
),
'rewrite' => array(
'slug' => _x( 'venue', 'Post Type Slug', 'gatherpress' ),
@@ -199,6 +199,9 @@ public function register_taxonomy(): void {
'show_in_rest' => true,
)
);
// THIS IS IMPORTANT
// It is neccessary to make this tax visible on event posts within REST responses.
register_taxonomy_for_object_type( self::TAXONOMY, Event::POST_TYPE );
}

/**
7 changes: 7 additions & 0 deletions src/panels/event-settings/index.js
Original file line number Diff line number Diff line change
@@ -22,6 +22,9 @@ import NotifyMembersPanel from './notify-members';
import OnlineEventLinkPanel from './online-link';
import VenueSelectorPanel from './venue-selector';


import { EventPluginDocumentSettings } from './slot.js';

/**
* A settings panel for event-specific settings in the block editor.
*
@@ -43,6 +46,10 @@ const EventSettings = () => {
initialOpen={true}
className="gatherpress-event-settings"
>


<EventPluginDocumentSettings.Slot />

<VStack spacing={6}>
<DateTimeRangePanel />
<VenueSelectorPanel />
18 changes: 18 additions & 0 deletions src/panels/event-settings/slot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Defines as extensibility slot for the Production panel.
*/

/**
* WordPress dependencies
*/
import { createSlotFill, PanelRow } from '@wordpress/components';

export const { Fill, Slot } = createSlotFill('EventPluginDocumentSettings');

export const EventPluginDocumentSettings = ({ children, className }) => (
<Fill>
<PanelRow className={className}>{children}</PanelRow>
</Fill>
);

EventPluginDocumentSettings.Slot = Slot;
14 changes: 14 additions & 0 deletions src/panels/venue-settings/index.js
Original file line number Diff line number Diff line change
@@ -16,6 +16,11 @@ import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
import { isVenuePostType } from '../../helpers/venue';
import VenueInformationPanel from './venue-information';


import { VenuePluginDocumentSettings } from './slot.js';
import VenuePluginFill from './slotfill';


/**
* VenueSettings Component
*
@@ -35,6 +40,9 @@ const VenueSettings = () => {
initialOpen={true}
className="gatherpress-venue-settings"
>

<VenuePluginDocumentSettings.Slot />

<VStack spacing={6}>
<VenueInformationPanel />
</VStack>
@@ -68,3 +76,9 @@ registerPlugin('gatherpress-venue-settings', {
dispatch('core/edit-post').toggleEditorPanelOpened(
'gatherpress-venue-settings/gatherpress-venue-settings'
);





registerPlugin('venue-slot-fill', { render: VenuePluginFill });
33 changes: 33 additions & 0 deletions src/panels/venue-settings/slot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Defines as extensibility slot for the Production panel.
*/

/**
* WordPress dependencies
*/
import { createSlotFill, PanelRow } from '@wordpress/components';

export const { Fill, Slot } = createSlotFill('VenuePluginDocumentSettings');

// export const VenuePluginDocumentSettings = ({ children, className }) => (
export const VenuePluginDocumentSettings = ( props ) => {
console.log(props);
return (

<Fill>
<PanelRow className={props.className}>{props.children}</PanelRow>
</Fill>

// <SlotFillProvider>
// <Panel header="Panel with slot">
// <PanelBody>
// <Slot name="ExampleSlot"/>
// </PanelBody>
// </Panel>
// <Fill name="ExampleSlot" >
// Panel body
// </Fill>
// </SlotFillProvider>
)};

VenuePluginDocumentSettings.Slot = Slot;
31 changes: 31 additions & 0 deletions src/panels/venue-settings/slotfill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Retrieves the translation of text.
*
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/
*/
import { __ } from '@wordpress/i18n';

import { Fill } from '@wordpress/components';



/**
* Internal dependencies
*/
// const DURATION_META = window.Theater.ProductionBlocks.duration.PostMetaKey;
import { VenuePluginDocumentSettings } from './slot.js';


export default function VenuePluginFill() {

return (
<>
<Fill name="EventPluginDocumentSettings">
<p>THE "VenuePluginDocumentSettings" in EventPluginDocumentSettings</p>
</Fill>
<Fill name="EventPluginDocumentSettings">
<VenuePluginDocumentSettings.Slot />
</Fill>
</>
);
}