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

Add missing navigation links #366

Open
wants to merge 9 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

use Wporg\TranslationEvents\Translation_Events;
use Wporg\TranslationEvents\Urls;

register_block_type(
'wporg-translate-events-2024/event-edit-link',
array(
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
'render_callback' => function ( array $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$event_id = $block->context['postId'];
$event = Translation_Events::get_event_repository()->get_event( $event_id );
if ( ! $event ) {
return '';
}

ob_start();
if ( ! current_user_can( 'edit_translation_event', $event->id() ) ) {
return '';
}
?>
<a href="<?php echo esc_url( Urls::event_edit( $event->id() ) ); ?>"
class="event-list-item-button"
title="<?php echo esc_attr__( 'Edit', 'gp-translation-events' ); ?>">
<span class="dashicons dashicons-edit"></span>
</a>
<?php
return ob_get_clean();
},
)
);
10 changes: 9 additions & 1 deletion themes/wporg-translate-events-2024/blocks/event-form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,15 @@

ob_start();
?>

<?php
if ( ! $is_create_form && current_user_can( 'edit_translation_event_attendees', $event->id() ) ) :
?>
<!-- wp:button {"align":"center"} -->
<div class="wp-block-button" style="text-align: right;">
<a class="wp-block-button__link" href="<?php echo esc_url( Urls::event_attendees( $event->id() ) ); ?>">Manage Attendees</a>
</div>
<!-- /wp:button -->
<?php endif; ?>
<!-- wp:columns -->
<div class="wp-block-columns">
<!-- wp:column {"width":"64%"} -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<?php
endif;
?>
<!-- wp:wporg-translate-events-2024/event-edit-link /-->
<!-- wp:wporg-translate-events-2024/event-trash-link /-->
</div>
<!-- wp:wporg-translate-events-2024/event-attendance-mode /-->
<!-- wp:wporg-translate-events-2024/event-start /-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

use Wporg\TranslationEvents\Urls;

register_block_type(
'wporg-translate-events-2024/event-nav-links',
array(
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
'render_callback' => function () {

ob_start();
?>
<!-- wp:group {"align":"right","layout":{"type":"flex","justifyContent":"right"}} -->
<div class="wp-block-group alignright" style="width: 35%; margin-left: auto; padding-right:var(--wp--preset--spacing--edge-space);">
<div class="wp-block-group__inner-container" style="display: flex; justify-content: flex-end; gap: 10px; align-items: center;">
<?php if ( is_user_logged_in() ) : ?>
<?php if ( current_user_can( 'manage_translation_events' ) ) : ?>
<a class="event-nav-link" href="<?php echo esc_url( Urls::events_trashed() ); ?>">Deleted Events</a>
<?php endif; ?>
<a class="event-nav-link" href="<?php echo esc_url( Urls::my_events() ); ?>">My Events</a>
<?php if ( current_user_can( 'create_translation_event' ) ) : ?>
<!-- wp:button {"className":"is-style-outline"} -->
<div class="wp-block-button is-style-outline">
<a class="wp-block-button__link wp-element-button" href="<?php echo esc_url( Urls::event_create() ); ?>">Create Event</a>
</div>
<!-- /wp:button -->
<?php endif; ?>
<?php endif; ?>
</div>
</div>
<!-- /wp:group -->
<?php
return ob_get_clean();
},
)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

use Wporg\TranslationEvents\Translation_Events;
use Wporg\TranslationEvents\Urls;

register_block_type(
'wporg-translate-events-2024/event-trash-link',
array(
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
'render_callback' => function ( array $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$event_id = $block->context['postId'];
$event = Translation_Events::get_event_repository()->get_event( $event_id );
if ( ! $event ) {
return '';
}

ob_start();
if ( ! current_user_can( 'trash_translation_event', $event->id() ) ) {
return '';
}
if ( $event->is_trashed() ) :
?>
<a href="<?php echo esc_url( Urls::event_trash( $event->id() ) ); ?>"
class="button is-small"
title="<?php echo esc_attr__( 'Restore', 'gp-translation-events' ); ?>">
<?php echo esc_attr__( 'Restore', 'gp-translation-events' ); ?>
</a>
<?php else : ?>
<a href="<?php echo esc_url( Urls::event_trash( $event->id() ) ); ?>"
class="event-list-item-button is-destructive"
title="<?php echo esc_attr__( 'Move to trash', 'gp-translation-events' ); ?>">
<span class="dashicons dashicons-trash"></span>
</a>
<?php
endif;
return ob_get_clean();
},
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
<!-- wp:wporg/site-breadcrumbs {"fontSize":"small"} /-->
</div>
<!-- /wp:group -->
<!-- wp:wporg-translate-events-2024/event-nav-links /-->
<div id="gp-js-message" class="gp-js-message"></div>
3 changes: 3 additions & 0 deletions themes/wporg-translate-events-2024/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ function register_blocks(): void {
include_once __DIR__ . '/blocks/pages/events/event-create/index.php';
include_once __DIR__ . '/blocks/event-form/index.php';
include_once __DIR__ . '/blocks/pages/events/event-edit/index.php';
include_once __DIR__ . '/blocks/event-edit-link/index.php';
include_once __DIR__ . '/blocks/event-trash-link/index.php';
include_once __DIR__ . '/blocks/event-nav-links/index.php';
}

function register_patterns(): void {
Expand Down
13 changes: 13 additions & 0 deletions themes/wporg-translate-events-2024/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,20 @@ select.wp-block-form-input__input {
color: #fff;
background-color: #46b450;
}
a.event-list-item-button:any-link {
text-decoration: none;
vertical-align: text-top;
}
.event-list-item-button.is-destructive {
color: var(--wp--preset--color--vivid-red);
}
.event-nav-link {
text-decoration: none;
}

.event-nav-link:hover {
text-decoration: underline;
}
@media (min-width: 960px) {

.wporg-marker-list__container .wporg-marker-list-item {
Expand Down
Loading