# jetpack/16.3/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-assets.php

Jetpack – WP Security, Backup, Speed, &amp; Growth, version 16.3. 94 lines.

- Page: https://pluginprobe.com/plugins/jetpack/16.3/code/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-assets.php
- Raw: https://pluginprobe.com/plugins/jetpack/16.3/raw/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-assets.php
- Modified: 2026-09-21T19:42:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/jetpack/16.3/code/jetpack_vendor/automattic/jetpack-publicize/src/class-publicize-assets.php#L10-L20`.

```php
<?php
/**
 * Publicize_Assets.
 *
 * @package automattic/jetpack-publicize
 */

namespace Automattic\Jetpack\Publicize;

use Automattic\Jetpack\Assets;
use Automattic\Jetpack\WP_Build_Polyfills\WP_Build_Polyfills;

/**
 * Publicize_Assets class.
 */
class Publicize_Assets {

	/**
	 * Initialize the class.
	 */
	public static function configure() {
		Publicize_Script_Data::configure();

		add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'enqueue_block_editor_scripts' ), 15 );
	}

	/**
	 * Whether to enqueue the block editor scripts.
	 *
	 * @return boolean True if the criteria are met.
	 */
	public static function should_enqueue_block_editor_scripts() {

		$post_type = get_post_type();

		if ( empty( $post_type ) || ! post_type_supports( $post_type, 'publicize' ) ) {
			return false;
		}

		return Publicize_Utils::current_user_can_access_publicize_data();
	}

	/**
	 * Enqueue block editor scripts and styles.
	 */
	public static function enqueue_block_editor_scripts() {
		if ( ! self::should_enqueue_block_editor_scripts() ) {
			return;
		}

		// We don't want to render the Social UI in Jetpack sidebar
		// if Jetpack is old, which has it bundled.
		if ( defined( 'JETPACK__VERSION' ) && ( version_compare( (string) JETPACK__VERSION, '14.5-a.1', '<' ) ) ) {
			return;
		}

		$script_to_load = class_exists( 'Jetpack' ) ? 'block-editor-jetpack' : 'block-editor-social';

		self::register_wp_build_polyfills();

		// Dequeue the old Social assets.
		wp_dequeue_script( 'jetpack-social-editor' );
		wp_dequeue_style( 'jetpack-social-editor' );

		Assets::register_script(
			'jetpack-social-editor',
			sprintf( '../build/%s.js', $script_to_load ),
			__FILE__,
			array(
				'in_footer'  => true,
				'textdomain' => 'jetpack-publicize-pkg',
				'enqueue'    => true,
			)
		);
	}

	/**
	 * Register the wp-build polyfills Social's block editor bundles request.
	 *
	 * Runs only where enqueue_block_editor_scripts() loads those bundles, as the editor has no `page` slug
	 * to gate on. Keep it there: below WP 7.1 it can replace Core's wp-private-apis and wp-rich-text editor-wide.
	 */
	public static function register_wp_build_polyfills() {
		if ( ! class_exists( WP_Build_Polyfills::class ) ) {
			return;
		}

		WP_Build_Polyfills::register(
			'jetpack-social',
			array( 'wp-theme', 'wp-private-apis', 'wp-rich-text' )
		);
	}
}

```
