Revert "Shortcodes: only register when needed"
This reverts commit c4daffe5c6
.
This commit is contained in:
parent
c4daffe5c6
commit
ff58070a5e
3 changed files with 8 additions and 19 deletions
|
@ -69,6 +69,7 @@ function plugin_init() {
|
||||||
\add_action( 'init', array( __NAMESPACE__ . '\Collection\Followers', 'init' ) );
|
\add_action( 'init', array( __NAMESPACE__ . '\Collection\Followers', 'init' ) );
|
||||||
\add_action( 'init', array( __NAMESPACE__ . '\Admin', 'init' ) );
|
\add_action( 'init', array( __NAMESPACE__ . '\Admin', 'init' ) );
|
||||||
\add_action( 'init', array( __NAMESPACE__ . '\Hashtag', 'init' ) );
|
\add_action( 'init', array( __NAMESPACE__ . '\Hashtag', 'init' ) );
|
||||||
|
\add_action( 'init', array( __NAMESPACE__ . '\Shortcodes', 'init' ) );
|
||||||
\add_action( 'init', array( __NAMESPACE__ . '\Mention', 'init' ) );
|
\add_action( 'init', array( __NAMESPACE__ . '\Mention', 'init' ) );
|
||||||
\add_action( 'init', array( __NAMESPACE__ . '\Health_Check', 'init' ) );
|
\add_action( 'init', array( __NAMESPACE__ . '\Health_Check', 'init' ) );
|
||||||
\add_action( 'init', array( __NAMESPACE__ . '\Scheduler', 'init' ) );
|
\add_action( 'init', array( __NAMESPACE__ . '\Scheduler', 'init' ) );
|
||||||
|
|
|
@ -5,9 +5,14 @@ use function Activitypub\esc_hashtag;
|
||||||
|
|
||||||
class Shortcodes {
|
class Shortcodes {
|
||||||
/**
|
/**
|
||||||
* Register the shortcodes
|
* Class constructor, registering WordPress then Shortcodes
|
||||||
*/
|
*/
|
||||||
public static function register() {
|
public static function init() {
|
||||||
|
// do not load on admin pages
|
||||||
|
if ( is_admin() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ( get_class_methods( self::class ) as $shortcode ) {
|
foreach ( get_class_methods( self::class ) as $shortcode ) {
|
||||||
if ( 'init' !== $shortcode ) {
|
if ( 'init' !== $shortcode ) {
|
||||||
add_shortcode( 'ap_' . $shortcode, array( self::class, $shortcode ) );
|
add_shortcode( 'ap_' . $shortcode, array( self::class, $shortcode ) );
|
||||||
|
@ -15,17 +20,6 @@ class Shortcodes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister the shortcodes
|
|
||||||
*/
|
|
||||||
public static function unregister() {
|
|
||||||
foreach ( get_class_methods( self::class ) as $shortcode ) {
|
|
||||||
if ( 'init' !== $shortcode ) {
|
|
||||||
remove_shortcode( 'ap_' . $shortcode );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates output for the 'ap_hashtags' shortcode
|
* Generates output for the 'ap_hashtags' shortcode
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,7 +5,6 @@ use WP_Post;
|
||||||
use Activitypub\Collection\Users;
|
use Activitypub\Collection\Users;
|
||||||
use Activitypub\Model\Blog_User;
|
use Activitypub\Model\Blog_User;
|
||||||
use Activitypub\Activity\Base_Object;
|
use Activitypub\Activity\Base_Object;
|
||||||
use Activitypub\Shortcodes;
|
|
||||||
|
|
||||||
use function Activitypub\esc_hashtag;
|
use function Activitypub\esc_hashtag;
|
||||||
use function Activitypub\is_single_user;
|
use function Activitypub\is_single_user;
|
||||||
|
@ -467,8 +466,6 @@ class Post {
|
||||||
$post = $this->wp_post;
|
$post = $this->wp_post;
|
||||||
$content = $this->get_post_content_template();
|
$content = $this->get_post_content_template();
|
||||||
|
|
||||||
// Register our shortcodes just in time.
|
|
||||||
Shortcodes::register();
|
|
||||||
// Fill in the shortcodes.
|
// Fill in the shortcodes.
|
||||||
setup_postdata( $post );
|
setup_postdata( $post );
|
||||||
$content = do_shortcode( $content );
|
$content = do_shortcode( $content );
|
||||||
|
@ -480,9 +477,6 @@ class Post {
|
||||||
|
|
||||||
$content = \apply_filters( 'activitypub_the_content', $content, $post );
|
$content = \apply_filters( 'activitypub_the_content', $content, $post );
|
||||||
|
|
||||||
// Don't need these any more, should never appear in a post.
|
|
||||||
Shortcodes::unregister();
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue