Skip to content

Commit c46f8a6

Browse files
authored
Admin: Move admin-specific callbacks into wp-admin (#1385)
* Admin: Move admin-specific callbacks into admin Removes unused Upgrade Notice callback. * Remove deprecated methods outright * Bring back update notice appender * Revert readme changes
1 parent e6d443e commit c46f8a6

File tree

2 files changed

+26
-39
lines changed

2 files changed

+26
-39
lines changed

includes/class-activitypub.php

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ public static function init() {
4343

4444
\add_action( 'user_register', array( self::class, 'user_register' ) );
4545

46-
\add_action( 'in_plugin_update_message-' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'plugin_update_message' ) );
47-
48-
if ( site_supports_blocks() ) {
49-
\add_action( 'tool_box', array( self::class, 'tool_box' ) );
50-
}
51-
5246
\add_filter( 'activitypub_get_actor_extra_fields', array( Extra_Fields::class, 'default_actor_extra_fields' ), 10, 2 );
5347

5448
\add_action( 'updated_postmeta', array( self::class, 'updated_postmeta' ), 10, 4 );
@@ -428,15 +422,6 @@ public static function flush_rewrite_rules() {
428422
\flush_rewrite_rules();
429423
}
430424

431-
/**
432-
* Adds metabox on wp-admin/tools.php.
433-
*/
434-
public static function tool_box() {
435-
if ( \current_user_can( 'edit_posts' ) ) {
436-
\load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/toolbox.php' );
437-
}
438-
}
439-
440425
/**
441426
* Theme compatibility stuff.
442427
*/
@@ -459,30 +444,6 @@ public static function theme_compat() {
459444
}
460445
}
461446

462-
/**
463-
* Display plugin upgrade notice to users.
464-
*
465-
* @param array $data The plugin data.
466-
*/
467-
public static function plugin_update_message( $data ) {
468-
if ( ! isset( $data['upgrade_notice'] ) ) {
469-
return;
470-
}
471-
472-
printf(
473-
'<div class="update-message">%s</div>',
474-
wp_kses(
475-
wpautop( $data['upgrade_notice '] ),
476-
array(
477-
'p' => array(),
478-
'a' => array( 'href', 'title' ),
479-
'strong' => array(),
480-
'em' => array(),
481-
)
482-
)
483-
);
484-
}
485-
486447
/**
487448
* Register Custom Post Types.
488449
*/

includes/wp-admin/class-admin.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public static function init() {
5555

5656
\add_filter( 'dashboard_glance_items', array( self::class, 'dashboard_glance_items' ) );
5757
\add_filter( 'plugin_action_links_' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'add_plugin_settings_link' ) );
58+
\add_action( 'in_plugin_update_message-' . ACTIVITYPUB_PLUGIN_BASENAME, array( self::class, 'plugin_update_message' ), 10, 2 );
59+
60+
if ( site_supports_blocks() ) {
61+
\add_action( 'tool_box', array( self::class, 'tool_box' ) );
62+
}
5863
}
5964

6065
/**
@@ -595,4 +600,25 @@ public static function add_plugin_settings_link( $actions ) {
595600

596601
return $actions;
597602
}
603+
604+
/**
605+
* Display plugin upgrade notice to users.
606+
*
607+
* @param array $data The plugin data.
608+
* @param object $update The plugin update data.
609+
*/
610+
public static function plugin_update_message( $data, $update ) {
611+
if ( ! isset( $update->upgrade_notice ) ) {
612+
return;
613+
}
614+
615+
echo '<br>' . wp_strip_all_tags( $update->upgrade_notice ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
616+
}
617+
618+
/**
619+
* Adds metabox on wp-admin/tools.php.
620+
*/
621+
public static function tool_box() {
622+
\load_template( ACTIVITYPUB_PLUGIN_DIR . 'templates/toolbox.php' );
623+
}
598624
}

0 commit comments

Comments
 (0)