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

Shortcode Features - Add Shortcode Column and Copy To Clipboard feature #28

Merged
merged 7 commits into from
Mar 13, 2024

Conversation

ZaneTheGreat
Copy link
Collaborator

Resolves #26

This pull request consists of the following features below:

  1. Added shortcode column.
  2. Populate column with shortcodes based on the post status and post slug.
  3. Added shortcode's copy to clipboard feature.

@ZaneTheGreat ZaneTheGreat added enhancement New feature or request Need Code Review labels Feb 15, 2024
@ZaneTheGreat ZaneTheGreat requested a review from ronalfy February 15, 2024 14:45
@ZaneTheGreat ZaneTheGreat self-assigned this Feb 15, 2024
Copy link
Contributor

@ronalfy ronalfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall code looks good. I've requested a few changes.


// Copy the value to the clipboard.
navigator.clipboard.writeText( shortcodeValue ).then( () => {
// Logs success message in console.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There needs to be a check to make sure this object is available in browsers such as Firefox.

See feature detection in this article: https://web.dev/articles/async-clipboard#feature_detection

const spanElement = button.querySelector( 'span' );
if ( spanElement ) {
spanElement.classList.remove( 'dashicons', 'dashicons-clipboard' );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to a checkbox when copied and use wp.a11y.speak to communicate the button state?

https://make.wordpress.org/accessibility/handbook/markup/wp-a11y-speak/

// Generate the shortcode for the button with dashicon.
$button_shortcode = sprintf(
'<button type="button" class="pw-copy-clipboard" title="Copy to Clipboard">%s</button>',
'<span class="dashicons dashicons-clipboard"></span>'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need an aria-label here.


// Generate the shortcode for the readonly input.
$shortcode = sprintf(
'<input type="text" value="%s" readonly>',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make sure this input is disabled?

@ronalfy ronalfy merged commit 741d215 into main Mar 13, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Need Code Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add shortcode column to wp_block post type
3 participants