Ensure everything is loaded properly after #376 (#378)

Also fixes an spl_autoload bug
This commit is contained in:
Matt Wiebe 2023-07-27 12:35:28 -05:00 committed by GitHub
parent be26a18214
commit f49e15bfbf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View file

@ -67,7 +67,12 @@ spl_autoload_register(
$base = 'Activitypub\\'; $base = 'Activitypub\\';
if ( strncmp( $full_class, $base, strlen( $base ) ) === 0 ) { if ( strncmp( $full_class, $base, strlen( $base ) ) === 0 ) {
$class = strtolower( str_replace( $base, '', $full_class ) ); $maybe_uppercase = str_replace( $base, '', $full_class );
$class = strtolower( $maybe_uppercase );
// All classes should be capitalized. If this is instead looking for a lowercase method, we ignore that.
if ( $maybe_uppercase === $class ) {
return;
}
if ( false !== strpos( $class, '\\' ) ) { if ( false !== strpos( $class, '\\' ) ) {
$parts = explode( '\\', $class ); $parts = explode( '\\', $class );

View file

@ -28,7 +28,7 @@ class Activitypub {
\add_action( 'wp_trash_post', array( self::class, 'trash_post' ), 1 ); \add_action( 'wp_trash_post', array( self::class, 'trash_post' ), 1 );
\add_action( 'untrash_post', array( self::class, 'untrash_post' ), 1 ); \add_action( 'untrash_post', array( self::class, 'untrash_post' ), 1 );
\add_action( 'init', array( self::class, 'add_rewrite_rules' ) ); \add_action( 'init', array( self::class, 'add_rewrite_rules' ), 11 );
\add_action( 'after_setup_theme', array( self::class, 'theme_compat' ), 99 ); \add_action( 'after_setup_theme', array( self::class, 'theme_compat' ), 99 );
} }

View file

@ -5,7 +5,8 @@ use Activitypub\Collection\Followers;
class Blocks { class Blocks {
public static function init() { public static function init() {
\add_action( 'init', array( self::class, 'register_blocks' ) ); // this is already being called on the init hook, so just add it.
self::register_blocks();
\add_action( 'wp_enqueue_scripts', array( self::class, 'add_data' ) ); \add_action( 'wp_enqueue_scripts', array( self::class, 'add_data' ) );
\add_action( 'enqueue_block_editor_assets', array( self::class, 'add_data' ) ); \add_action( 'enqueue_block_editor_assets', array( self::class, 'add_data' ) );
} }