Merged in feature/314-dev-dev01 (pull request #24)
auto-patch 314-dev-dev01-2024-01-25T04_09_02 * auto-patch 314-dev-dev01-2024-01-25T04_09_02
This commit is contained in:
@@ -18,7 +18,7 @@ class WPSEO_Admin_Asset_Manager {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const PREFIX = 'yoast-seo-';
|
||||
public const PREFIX = 'yoast-seo-';
|
||||
|
||||
/**
|
||||
* Class that manages the assets' location.
|
||||
@@ -40,7 +40,7 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* @param WPSEO_Admin_Asset_Location|null $asset_location The provider of the asset location.
|
||||
* @param string $prefix The prefix for naming assets.
|
||||
*/
|
||||
public function __construct( WPSEO_Admin_Asset_Location $asset_location = null, $prefix = self::PREFIX ) {
|
||||
public function __construct( ?WPSEO_Admin_Asset_Location $asset_location = null, $prefix = self::PREFIX ) {
|
||||
if ( $asset_location === null ) {
|
||||
$asset_location = self::create_default_location();
|
||||
}
|
||||
@@ -53,6 +53,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* Enqueues scripts.
|
||||
*
|
||||
* @param string $script The name of the script to enqueue.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_script( $script ) {
|
||||
wp_enqueue_script( $this->prefix . $script );
|
||||
@@ -62,6 +64,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* Enqueues styles.
|
||||
*
|
||||
* @param string $style The name of the style to enqueue.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_style( $style ) {
|
||||
wp_enqueue_style( $this->prefix . $style );
|
||||
@@ -69,6 +73,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
|
||||
/**
|
||||
* Enqueues the appropriate language for the user.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function enqueue_user_language_script() {
|
||||
$this->enqueue_script( 'language-' . YoastSEO()->helpers->language->get_researcher_language() );
|
||||
@@ -78,6 +84,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* Registers scripts based on it's parameters.
|
||||
*
|
||||
* @param WPSEO_Admin_Asset $script The script to register.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_script( WPSEO_Admin_Asset $script ) {
|
||||
$url = $script->get_src() ? $this->get_url( $script, WPSEO_Admin_Asset::TYPE_JS ) : false;
|
||||
@@ -99,6 +107,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* Registers styles based on it's parameters.
|
||||
*
|
||||
* @param WPSEO_Admin_Asset $style The style to register.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_style( WPSEO_Admin_Asset $style ) {
|
||||
wp_register_style(
|
||||
@@ -112,6 +122,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
|
||||
/**
|
||||
* Calls the functions that register scripts and styles with the scripts and styles to be registered as arguments.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_assets() {
|
||||
$this->register_scripts( $this->scripts_to_be_registered() );
|
||||
@@ -122,6 +134,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* Registers all the scripts passed to it.
|
||||
*
|
||||
* @param array $scripts The scripts passed to it.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_scripts( $scripts ) {
|
||||
foreach ( $scripts as $script ) {
|
||||
@@ -134,6 +148,8 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* Registers all the styles it receives.
|
||||
*
|
||||
* @param array $styles Styles that need to be registered.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register_styles( $styles ) {
|
||||
foreach ( $styles as $style ) {
|
||||
@@ -148,9 +164,11 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* @param string $handle The script handle.
|
||||
* @param string $object_name The object name.
|
||||
* @param array $data The l10n data.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function localize_script( $handle, $object_name, $data ) {
|
||||
\wp_localize_script( $this->prefix . $handle, $object_name, $data );
|
||||
wp_localize_script( $this->prefix . $handle, $object_name, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,9 +177,11 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* @param string $handle The script handle.
|
||||
* @param string $data The l10n data.
|
||||
* @param string $position Optional. Whether to add the inline script before the handle or after.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add_inline_script( $handle, $data, $position = 'after' ) {
|
||||
\wp_add_inline_script( $this->prefix . $handle, $data, $position );
|
||||
wp_add_inline_script( $this->prefix . $handle, $data, $position );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +239,7 @@ class WPSEO_Admin_Asset_Manager {
|
||||
* @return bool True when the script is enqueued.
|
||||
*/
|
||||
public function is_script_enqueued( $script ) {
|
||||
return \wp_script_is( $this->prefix . $script );
|
||||
return wp_script_is( $this->prefix . $script );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,7 +371,7 @@ class WPSEO_Admin_Asset_Manager {
|
||||
'name' => 'post-edit-classic',
|
||||
'src' => $scripts['post-edit']['src'],
|
||||
'deps' => array_map(
|
||||
static function( $dep ) {
|
||||
static function ( $dep ) {
|
||||
if ( $dep === self::PREFIX . 'block-editor' ) {
|
||||
return self::PREFIX . 'classic-editor';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user