Skip to content

Commit

Permalink
Copy Post: Add a Jetpack logo to row action link (#35552)
Browse files Browse the repository at this point in the history
* Add green logomark SVG

* Use Jetpack logomark for Copy action

* changelog

* Iterate on copy, ensure translations

* Use styled Jetpack Logo class

* Remove redundant SVG file

* Force logo color to link color

* Change custom fill to black

---------

Co-authored-by: Jason Moon <[email protected]>
  • Loading branch information
jsnmoon and jsnmoon authored Feb 26, 2024
1 parent 76b2f66 commit fdfff59
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: other

Copy Post: Add Jetpack Logo to row action link
36 changes: 31 additions & 5 deletions projects/plugins/jetpack/modules/copy-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* @package automattic/jetpack
*/

use Automattic\Jetpack\Assets\Logo;

// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.

/**
Expand All @@ -28,6 +30,7 @@ class Jetpack_Copy_Post {
*/
public function __construct() {
if ( 'edit.php' === $GLOBALS['pagenow'] ) {
add_action( 'admin_head', array( $this, 'print_inline_styles' ) );
add_filter( 'post_row_actions', array( $this, 'add_row_action' ), 10, 2 );
add_filter( 'page_row_actions', array( $this, 'add_row_action' ), 10, 2 );
return;
Expand All @@ -39,6 +42,26 @@ public function __construct() {
}
}

/**
* Echos inline styles for the Jetpack logo.
*
* @return void
*/
public function print_inline_styles() {
echo '
<style id="jetpack-copy-post-styles">
#jetpack-logo__icon {
height: 14px;
width: 14px;
vertical-align: text-bottom;
}
#jetpack-logo__icon path {
fill: inherit;
}
</style>
';
}

/**
* Update the new (target) post data with the source post data.
*
Expand Down Expand Up @@ -308,19 +331,22 @@ public function add_row_action( $actions, $post ) {
return $actions;
}

$edit_url = add_query_arg(
$edit_url = add_query_arg(
array(
'post_type' => $post->post_type,
'jetpack-copy' => $post->ID,
),
admin_url( 'post-new.php' )
);
$edit_action = array(

$jetpack_logo = new Logo();
$edit_action = array(
'jetpack-copy' => sprintf(
'<a href="%s" aria-label="%s">%s</a>',
'<a href="%1$s" aria-label="%2$s">%3$s %4$s</a>',
esc_url( $edit_url ),
esc_attr__( 'Copy this post.', 'jetpack' ),
esc_html__( 'Copy', 'jetpack' )
esc_attr__( 'Copy this post with Jetpack', 'jetpack' ),
esc_html__( 'Copy', 'jetpack' ),
$jetpack_logo->get_jp_emblem()
),
);

Expand Down

0 comments on commit fdfff59

Please sign in to comment.