Initial commit: Atomaste website
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<?php // You don't belong here.
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php defined( 'ABSPATH' ) or die();
|
||||
define( 'burst_rest_api_optimizer', true );
|
||||
if ( ! function_exists( 'burst_exclude_plugins_for_rest_api' ) ) {
|
||||
/**
|
||||
* Exclude all other plugins from the active plugins list if this is a Burst rest request
|
||||
*
|
||||
* @param array $plugins The active plugins.
|
||||
*
|
||||
* @return array The filtered active plugins.
|
||||
*/
|
||||
function burst_exclude_plugins_for_rest_api( $plugins ) {
|
||||
// if not an rsp request return all plugins
|
||||
// but for some requests, we need to load other plugins, to ensure we can detect them.
|
||||
if ( isset( $_SERVER['REQUEST_URI'] ) && (
|
||||
strpos( $_SERVER['REQUEST_URI'], 'burst/v1' ) === false ||
|
||||
strpos( $_SERVER['REQUEST_URI'], 'otherpluginsdata' ) !== false ||
|
||||
strpos( $_SERVER['REQUEST_URI'], 'plugin_actions' ) !== false ||
|
||||
strpos( $_SERVER['REQUEST_URI'], 'fields/set' ) !== false ||
|
||||
strpos( $_SERVER['REQUEST_URI'], 'goals/get' ) !== false
|
||||
)
|
||||
) {
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
// Only leave burst and pro add ons active for this request
|
||||
foreach ( $plugins as $key => $plugin ) {
|
||||
if ( strpos( $plugin, 'burst-' ) !== false ) {
|
||||
continue;
|
||||
}
|
||||
unset( $plugins[ $key ] );
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
add_filter( 'option_active_plugins', 'burst_exclude_plugins_for_rest_api' );
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined( 'ABSPATH' ) or die();
|
||||
|
||||
// check if our optimizer is installed, or if the mu plugins folder is not writable
|
||||
if ( ! defined( 'burst_rest_api_optimizer' ) && ! get_option( 'burst_rest_api_optimizer_not_writable' ) ) {
|
||||
$php = file_get_contents( trailingslashit( plugin_dir_path( __FILE__ ) ) . 'optimization-code.php' );
|
||||
if ( is_writable( WP_CONTENT_DIR ) && ! is_dir( WPMU_PLUGIN_DIR ) ) {
|
||||
mkdir( WPMU_PLUGIN_DIR );
|
||||
}
|
||||
if ( is_writable( WPMU_PLUGIN_DIR ) ) {
|
||||
file_put_contents( trailingslashit( WPMU_PLUGIN_DIR ) . 'burst_rest_api_optimizer.php', $php );
|
||||
} else {
|
||||
// stop trying for a while
|
||||
update_option( 'burst_rest_api_optimizer_not_writable', true, false );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user