Skip to content

Commit d51f0b2

Browse files
committed
Include a sponsor link on Plugins Page.
1 parent bcce67f commit d51f0b2

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

src/FakerPress/Admin.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,28 @@ public function _filter_body_class( $classes ) {
278278

279279
return implode( ' ', $more );
280280
}
281+
282+
/**
283+
* Filters the array of row meta for each plugin in the Plugins list table.
284+
*
285+
* @since 0.6.3
286+
*
287+
* @param array<int, string> $plugin_meta An array of the plugin's metadata.
288+
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
289+
*
290+
* @return array<int, string> Updated array of the plugin's metadata.
291+
*/
292+
public function filter_plugin_row_meta( array $plugin_meta, $plugin_file ) {
293+
if ( 'fakerpress/fakerpress.php' !== $plugin_file ) {
294+
return $plugin_meta;
295+
}
296+
297+
$plugin_meta[] = sprintf(
298+
'<a href="%1$s"><span class="dashicons dashicons-star-filled" aria-hidden="true" style="font-size:14px;line-height:1.3"></span>%2$s</a>',
299+
'https://fakerpress.com/r/sponsor',
300+
esc_html_x( 'Sponsor', 'verb', 'fakerpress' )
301+
);
302+
303+
return $plugin_meta;
304+
}
281305
}

src/FakerPress/Hooks.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ protected function add_filters() {
8080

8181
add_filter( 'admin_title', [ $admin, '_filter_set_admin_page_title' ], 15, 2 );
8282

83+
add_filter( 'plugin_row_meta', [ $admin, 'filter_plugin_row_meta' ], 10, 2 );
8384

8485
// Allow WordPress
8586
add_filter( 'fakerpress.messages.allowed_html', [ $admin, '_filter_messages_allowed_html' ], 1, 1 );

0 commit comments

Comments
 (0)