dynamic_js = $dynamic_js; $this->enqueue_separate_scripts(); } /** * Enqueues separate scripts. * * @access public * @since 1.0.0 */ public function enqueue_separate_scripts() { $wp_content_dir = untrailingslashit( wp_normalize_path( WP_CONTENT_DIR ) ); $wp_content_url = content_url(); $scripts = $this->dynamic_js->get_ordered_scripts(); foreach ( $scripts as $script ) { // Get URL in case we're using path. if ( 0 !== strpos( $script['url'], 'http' ) ) { $script['url'] = str_replace( $wp_content_dir, $wp_content_url, wp_normalize_path( $script['url'] ) ); } // Strip protocols. $script['url'] = set_url_scheme( $script['url'] ); wp_enqueue_script( $script['handle'], $script['url'], $script['deps'], $script['ver'], $script['in_footer'] ); } $localizations = $this->dynamic_js->get_localizations(); foreach ( $localizations as $l10n ) { wp_localize_script( $l10n['handle'], $l10n['name'], $l10n['data'] ); } } }