: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @author OnTheGo Systems
class OTGS_Assets_Store {
private $assets_files_store = array();
private $assets = array();
public function get( $type, $handle = null ) {
if ( array_key_exists( $type, $this->assets ) ) {
$result = $this->assets[ $type ];
if ( array_key_exists( $handle, $this->assets[ $type ] ) ) {
$result = $this->assets[ $type ][ $handle ];
public function add_assets_location( $path ) {
if ( ! in_array( $path, $this->assets, true ) ) {
$this->assets_files_store[] = $path;
private function parse_assets() {
foreach ( $this->assets_files_store as $assets_file ) {
$this->add_asset( $assets_file );
* @param string $assets_file
private function add_asset( $assets_file ) {
if ( ! is_file( $assets_file ) ) {
// @codingStandardsIgnoreStart
$assets = file_get_contents( $assets_file );
// @codingStandardsIgnoreEnd
if ( ! $assets || ! is_string( $assets ) ) {
$assets_data = json_decode( $assets, true );
if ( $assets_data && array_key_exists( 'entrypoints', $assets_data ) ) {
foreach ( $assets_data['entrypoints'] as $handle => $resources ) {
$this->add_resources( $handle, $resources );
* @param array $resources
private function add_resources( $handle, $resources ) {
foreach ( $resources as $type => $path ) {
if ( ! array_key_exists( $type, $this->assets ) ) {
$this->assets[ $type ] = array();
$this->assets[ $type ][ $handle ] = $path;