Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions includes/functions/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ function setup() {
add_action( 'init', $n( 'init' ) );
add_action( 'admin_enqueue_scripts', $n( 'admin_scripts' ) );

// Editor styles. add_editor_style() doesn't work outside of a theme.
add_filter( 'mce_css', $n( 'mce_css' ) );
// Hook to allow async or defer on asset loading.
add_filter( 'script_loader_tag', $n( 'script_loader_tag' ), 10, 2 );

add_action( 'plugins_loaded', $n( 'maybe_load_features' ), 11 );

add_filter( 'ep_user_register_feature', '__return_false' );
Expand Down Expand Up @@ -138,56 +133,6 @@ function admin_scripts() {
);
}

/**
* Enqueue editor styles. Filters the comma-delimited list of stylesheets to load in TinyMCE.
*
* @param string $stylesheets Comma-delimited list of stylesheets.
* @return string
*/
function mce_css( $stylesheets ) {
if ( ! empty( $stylesheets ) ) {
$stylesheets .= ',';
}

return $stylesheets . ELASTICPRESS_LABS_URL . ( ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ?
'assets/css/frontend/editor-style.css' :
'dist/css/editor-style.min.css' );
}

/**
* Add async/defer attributes to enqueued scripts that have the specified script_execution flag.
*
* @link https://core.trac.wordpress.org/ticket/12009
* @param string $tag The script tag.
* @param string $handle The script handle.
* @return string
*/
function script_loader_tag( $tag, $handle ) {
$script_execution = wp_scripts()->get_data( $handle, 'script_execution' );

if ( ! $script_execution ) {
return $tag;
}

if ( 'async' !== $script_execution && 'defer' !== $script_execution ) {
return $tag;
}

// Abort adding async/defer for scripts that have this script as a dependency. _doing_it_wrong()?
foreach ( wp_scripts()->registered as $script ) {
if ( in_array( $handle, $script->deps, true ) ) {
return $tag;
}
}

// Add the attribute if it hasn't already been added.
if ( ! preg_match( ":\s$script_execution(=|>|\s):", $tag ) ) {
$tag = preg_replace( ':(?=></script>):', " $script_execution", $tag, 1 );
}

return $tag;
}

/**
* Check if minimum ElasticPress requirements are met before loading the plugin feature.
*/
Expand Down
Loading