'ID' ) ) as $user_id ) { $followers = get_user_meta( $user_id, 'activitypub_followers', true ); if ( $followers ) { foreach ( $followers as $actor ) { Followers::add_follower( $user_id, $actor ); } } } Activitypub::flush_rewrite_rules(); } /** * Updates the custom template to use shortcodes instead of the deprecated templates. * * @return void */ private static function migrate_from_0_16() { // Get the custom template. $old_content = \get_option( 'activitypub_custom_post_content', ACTIVITYPUB_CUSTOM_POST_CONTENT ); // If the old content exists but is a blank string, we're going to need a flag to updated it even // after setting it to the default contents. $need_update = false; // If the old contents is blank, use the defaults. if ( '' === $old_content ) { $old_content = ACTIVITYPUB_CUSTOM_POST_CONTENT; $need_update = true; } // Set the new content to be the old content. $content = $old_content; // Convert old templates to shortcodes. $content = \str_replace( '%title%', '[ap_title]', $content ); $content = \str_replace( '%excerpt%', '[ap_excerpt]', $content ); $content = \str_replace( '%content%', '[ap_content]', $content ); $content = \str_replace( '%permalink%', '[ap_permalink type="html"]', $content ); $content = \str_replace( '%shortlink%', '[ap_shortlink type="html"]', $content ); $content = \str_replace( '%hashtags%', '[ap_hashtags]', $content ); $content = \str_replace( '%tags%', '[ap_hashtags]', $content ); // Store the new template if required. if ( $content !== $old_content || $need_update ) { \update_option( 'activitypub_custom_post_content', $content ); } } /** * Clear the cache after updating to 1.3.0 * * @return void */ private static function migrate_from_1_2_0() { $user_ids = get_users( array( 'fields' => 'ID', 'capability__in' => array( 'publish_posts' ), ) ); foreach ( $user_ids as $user_id ) { wp_cache_delete( sprintf( Followers::CACHE_KEY_INBOXES, $user_id ), 'activitypub' ); } } /** * Unschedule Hooks after updating to 2.0.0 * * @return void */ private static function migrate_from_2_0_0() { wp_clear_scheduled_hook( 'activitypub_send_post_activity' ); wp_clear_scheduled_hook( 'activitypub_send_update_activity' ); wp_clear_scheduled_hook( 'activitypub_send_delete_activity' ); wp_unschedule_hook( 'activitypub_send_post_activity' ); wp_unschedule_hook( 'activitypub_send_update_activity' ); wp_unschedule_hook( 'activitypub_send_delete_activity' ); } }