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

Create an Edit link template part #24

Closed
bobbingwide opened this issue Nov 7, 2020 · 1 comment
Closed

Create an Edit link template part #24

bobbingwide opened this issue Nov 7, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

As mentioned in #23 we need the ability to allow an authorsied user easy access to the editor for a displayed post.
This should work for a single post or for any post listed in a query-posts block.

Requirements

  • Ability to display an edit link for the current post
  • Displayed to users who have the authority to edit the post
  • The link text should be (Edit), by default

Proposed solution

In genesis-a2z this was implemented using the [edit] shortcode.
In oik, a similar capability is implemented in the [bw_pages] shortcode as part of the format= parameter.
A value of lower case e causes the [Edit] link to appear for the current post.
It uses the WordPress core function get_edit_post_link()

/**
 * Format the Edit post link (format=e)
 *
 */
function bw_field_function_edit( $post, &$atts, $f ) {
 $link = get_edit_post_link( $post->ID );
 if ( $link ) {
   BW_::alink( "bw_edit", $link, __( "[Edit]", "oik" ) ); 
 }
}
@bobbingwide bobbingwide added the enhancement New feature or request label Nov 7, 2020
@bobbingwide bobbingwide self-assigned this Nov 7, 2020
bobbingwide added a commit that referenced this issue Nov 10, 2020
@bobbingwide
Copy link
Owner Author

This is now implemented using the Post Edit block ( https://github.com/bobbingwide/sb-post-edit-block ) in block-template-parts/metadates.html

<!-- wp:oik-sb/sb-post-edit-block {"fontSize":"small"} /-->

The [post-edit] shortcode can be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant