: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Assets registry handles the registration of stylesheets and scripts required for plugin functionality.
* @package AdvancedAds\Framework
* @author Advanced Ads <info@wpadvancedads.com>
namespace AdvancedAds\Framework;
use AdvancedAds\Framework\Interfaces\Integration_Interface;
defined( 'ABSPATH' ) || exit;
class Assets_Registry implements Integration_Interface {
* Version of plugin local asset.
* Prefix to use in handle to make it unique.
* @param string $handle Name of the stylesheet.
public static function enqueue_style( $handle ): void {
wp_enqueue_style( self::prefix_it( $handle ) );
* @param string $handle Name of the script.
public static function enqueue_script( $handle ): void {
wp_enqueue_script( self::prefix_it( $handle ) );
* @param string $handle Name of the asset.
public static function prefix_it( $handle ): string {
return self::PREFIX . '-' . $handle;
public function hooks(): void {
add_action( 'admin_enqueue_scripts', [ $this, 'register_assets' ], 0 );
public function register_assets(): void {
$this->register_styles();
$this->register_scripts();
public function register_styles(): void {}
public function register_scripts(): void {}
* @param string $handle Name of the stylesheet. Should be unique.
* @param string|bool $src URL of the stylesheet.
* @param string[] $deps Optional. An array of registered stylesheet handles this stylesheet depends on.
* @param string|bool|null $ver Optional. String specifying stylesheet version number.
* @param string $media Optional. The media for which this stylesheet has been defined.
private function register_style( $handle, $src, $deps = [], $ver = false, $media = 'all' ) {
wp_register_style( self::prefix_it( $handle ), ADVADS_BASE_URL . $src, $deps, $ver, $media );
* @param string $handle Name of the stylesheet. Should be unique.
* @param string|bool $src URL of the stylesheet.
* @param string[] $deps Optional. An array of registered stylesheet handles this stylesheet depends on.
* @param string|bool|null $ver Optional. String specifying stylesheet version number.
* @param bool $in_footer Optional. The media for which this stylesheet has been defined.
private function register_script( $handle, $src, $deps = [], $ver = false, $in_footer = false ) {
$new_src = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? $src : str_replace( '.js', '.min.js', $src );
wp_register_script( self::prefix_it( $handle ), ADVADS_BASE_URL . $src, $deps, $ver, $in_footer );