PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-post-list/src/class-post-list.php +47 -53 13.5.2 → 16.3 View file →
@@ -6,8 +6,9 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Post_List;
9 9
10 +use Automattic\Jetpack\Assets;
10 11 use WP_Post;
11 12 use WP_Screen;
12 13
13 14 /**
@@ -14,9 +15,9 @@
14 15 * The Post_List Admin Area
15 16 */
16 17 class Post_List {
17 18
18 - const PACKAGE_VERSION = '0.6.2';
19 + const PACKAGE_VERSION = '0.10.4';
19 20 const FEATURE = 'enhanced_post_list';
20 21
21 22 /**
22 23 * The configuration method that is called from the jetpack-config package.
@@ -90,8 +91,18 @@
90 91 'jetpack_posts_list_ui_style',
91 92 'rtl',
92 93 plugin_dir_url( __DIR__ ) . './src/rtl.css'
93 94 );
95 + Assets::register_script(
96 + 'jetpack_posts_list',
97 + '../build/index.js',
98 + __FILE__,
99 + array(
100 + 'in_footer' => true,
101 + 'enqueue' => true,
102 + 'textdomain' => 'jetpack-post-list',
103 + )
104 + );
94 105 }
95 106 }
96 107
97 108 /**
@@ -113,47 +124,55 @@
113 124 }
114 125 }
115 126
116 127 /**
117 - * Checks the current post type and adds the Share post
128 + * If the current_screen has 'edit' as the base, add filters and actions to change the post list tables.
129 + *
130 + * @param object $current_screen The current screen.
131 + */
132 + public function add_filters_and_actions_for_screen( $current_screen ) {
133 + if ( 'edit' !== $current_screen->base ) {
134 + return;
135 + }
136 +
137 + $this->maybe_customize_columns( $current_screen->post_type );
138 + $this->maybe_add_copy_link_action( $current_screen->post_type );
139 + }
140 +
141 + /**
142 + * Checks the current post type and adds the Copy link post
118 143 * action if it is appropriate to do so.
119 144 *
120 145 * @param string $post_type The post type associated with the current request.
121 146 */
122 - public function maybe_add_share_action( $post_type ) {
123 - // Add Share action if post type supports 'publicize', uses the 'block editor', and the feature flag is true.
124 - if (
125 - post_type_supports( $post_type, 'publicize' ) &&
126 - use_block_editor_for_post_type( $post_type ) &&
127 - /**
128 - * Determine whether we should show the share action for this post type.
129 - * The default is false.
130 - *
131 - * @since 0.2.0
132 - *
133 - * @param boolean Whether we should show the share action for this post type.
134 - * @param string The current post type.
135 - */
136 - apply_filters( 'jetpack_post_list_display_share_action', false, $post_type )
137 - ) {
138 - // Add Share post action.
139 - add_filter( 'post_row_actions', array( $this, 'add_share_action' ), 20, 2 );
140 - add_filter( 'page_row_actions', array( $this, 'add_share_action' ), 20, 2 );
147 + public function maybe_add_copy_link_action( $post_type ) {
148 + if ( ! is_post_type_viewable( $post_type ) ) {
149 + return;
141 150 }
151 + add_filter( 'post_row_actions', array( $this, 'add_copy_link_action' ), 20, 2 );
152 + add_filter( 'page_row_actions', array( $this, 'add_copy_link_action' ), 20, 2 );
142 153 }
143 154
144 155 /**
145 - * If the current_screen has 'edit' as the base, add filters and actions to change the post list tables.
156 + * Adds the Copy link post action which copies the post link to the clipboard.
146 157 *
147 - * @param object $current_screen The current screen.
158 + * @param array $post_actions The current array of post actions.
159 + * @param WP_Post $post The current post in the post list table.
160 + *
161 + * @return array The modified post actions array.
148 162 */
149 - public function add_filters_and_actions_for_screen( $current_screen ) {
150 - if ( 'edit' !== $current_screen->base ) {
151 - return;
163 + public function add_copy_link_action( $post_actions, $post ) {
164 + if ( $post->post_status === 'trash' ) {
165 + return $post_actions;
152 166 }
153 167
154 - $this->maybe_customize_columns( $current_screen->post_type );
155 - $this->maybe_add_share_action( $current_screen->post_type );
168 + $post_actions['copy-link'] = sprintf(
169 + '<a href="%1$s" aria-label="%2$s" class="jetpack-post-list__copy-link-action">%3$s</a>',
170 + esc_url( get_permalink( $post ) ),
171 + esc_html__( 'Copy link to clipboard', 'jetpack-post-list' ),
172 + esc_html__( 'Copy link', 'jetpack-post-list' )
173 + );
174 + return $post_actions;
156 175 }
157 176
158 177 /**
159 178 * Checks if the current quick edit save is for a post list
@@ -166,35 +185,10 @@
166 185 // phpcs:disable WordPress.Security.NonceVerification.Missing
167 186 if ( ! empty( $_POST['screen'] ) && str_starts_with( sanitize_key( $_POST['screen'] ), 'edit-' ) && ! empty( $_POST['post_type'] ) ) {
168 187 $type = sanitize_key( $_POST['post_type'] );
169 188 $this->maybe_customize_columns( $type );
170 - $this->maybe_add_share_action( $type );
171 189 }
172 190 // phpcs:enable WordPress.Security.NonceVerification.Missing
173 - }
174 -
175 - /**
176 - * Adds the Share post action which links to the editor with the sidebar open.
177 - *
178 - * @param array $post_actions The current array of post actions.
179 - * @param WP_Post $post The current post in the post list table.
180 - *
181 - * @return array The modified post actions array.
182 - */
183 - public function add_share_action( $post_actions, $post ) {
184 - $edit_url = get_edit_post_link( $post->ID, 'raw' );
185 - if ( ! $edit_url ) {
186 - // Do nothing since we do not have an edit URL to work with.
187 - return $post_actions;
188 - }
189 -
190 - $url = add_query_arg( 'jetpackSidebarIsOpen', 'true', $edit_url );
191 - $text = _x( 'Share', 'Share the post on social networks', 'jetpack-post-list' );
192 - $title = _draft_or_post_title( $post );
193 - /* translators: post title */
194 - $label = sprintf( __( 'Share &#8220;%s&#8221; via Jetpack Social', 'jetpack-post-list' ), $title );
195 - $post_actions['share'] = sprintf( '<a href="%s" aria-label="%s">%s</a>', esc_url( $url ), esc_attr( $label ), esc_html( $text ) );
196 - return $post_actions;
197 191 }
198 192
199 193 /**
200 194 * Adds a new column header for displaying the thumbnail of a post.