-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #366 from WordPress/fix-navigation
Add missing navigation links
- Loading branch information
Showing
8 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
themes/wporg-translate-events-2024/blocks/event-edit-link/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}, | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
themes/wporg-translate-events-2024/blocks/event-nav-links/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?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 ( $attributes ) { | ||
$page_block_name = esc_html( $attributes['page_block_name'] ); | ||
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 | ||
$show_separator = false; | ||
if ( current_user_can( 'manage_translation_events' ) ) : | ||
$show_separator = true; | ||
?> | ||
<a class="event-nav-link" href="<?php echo esc_url( Urls::events_trashed() ); ?>">Deleted Events</a> | ||
<?php endif; ?> | ||
|
||
<?php if ( 'my-events' !== $page_block_name ) : ?> | ||
<?php if ( $show_separator ) : ?> | ||
<span class="separator">|</span> | ||
<?php endif; ?> | ||
<a class="event-nav-link" href="<?php echo esc_url( Urls::my_events() ); ?>">My Events</a> | ||
<?php endif; ?> | ||
|
||
<?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(); | ||
}, | ||
) | ||
); |
43 changes: 43 additions & 0 deletions
43
themes/wporg-translate-events-2024/blocks/event-trash-link/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}, | ||
) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters