27 $is_error = $return_object instanceof
Exception;
29 if ( wp_doing_ajax() ) {
30 $buffer = ob_get_clean();
33 error_log(
"[GravityKit] Buffer output before returning AJAX response: {$buffer}" );
35 header(
'GravityKit: ' . json_encode( $buffer ) );
39 wp_send_json_error( $return_object->getMessage() );
41 wp_send_json_success( $return_object );
46 throw new Exception( $return_object->getMessage() );
49 return $return_object;
62 $path = realpath( __DIR__ .
'/../../assets' );
64 return $file ? trailingslashit( $path ) . $file : $path;
77 $url = plugin_dir_url( self::get_assets_path() ) .
'assets';
79 return $file ? trailingslashit(
$url ) . $file :
$url;
91 return ! wp_doing_ajax()
93 : is_multisite() && strpos( wp_get_referer(), network_admin_url() ) !==
false;
104 return is_multisite() && is_main_site() && ! self::is_network_admin();
115 return is_multisite() && ! is_main_site();
128 if ( ! function_exists(
'get_plugins' ) ) {
129 require_once ABSPATH .
'wp-admin/includes/plugin.php';
144 if ( ! function_exists(
'is_plugin_active' ) ) {
145 require_once ABSPATH .
'wp-admin/includes/plugin.php';
150 foreach ( self::get_plugins() as $path => $plugin ) {
151 if ( empty( $plugin[
'TextDomain'] ) ) {
155 $plugins[ $plugin[
'TextDomain'] ] = array(
156 'name' => $plugin[
'Name'],
158 'plugin_file' => file_exists( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $path ) ? WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $path : null,
159 'version' => $plugin[
'Version'],
160 'text_domain' => $plugin[
'TextDomain'],
161 'active' => is_plugin_active( $path ),
162 'network_activated' => is_plugin_active_for_network( $path ),
180 $installed_plugins = self::get_installed_plugins();
182 $text_domains_arr = explode(
'|', $text_domains_str );
184 foreach ( $text_domains_arr as $text_domain ) {
185 if ( isset( $installed_plugins[ $text_domain ] ) ) {
186 return $installed_plugins[ $text_domain ];
206 public static function get_plugin_data( $plugin_file, $markup =
true, $translate =
true ) {
207 if ( ! function_exists(
'get_plugin_data' ) ) {
208 require_once ABSPATH .
'wp-admin/includes/plugin.php';
224 return ( is_string(
$value ) && function_exists(
$value ) ) ||
244 return ( is_object(
$value[0] ) || is_string(
$value[0] ) ) &&
static get_assets_url( $file='')
Returns URL to UI assets.
static get_plugin_data( $plugin_file, $markup=true, $translate=true)
Wrapper for WP's get_plugin_data() function.
static is_main_network_site()
Checks if the current page is a main network site, but not the network admin area.
static get_installed_plugin_by_text_domain( $text_domains_str)
Searches installed plugin by text domain(s) and returns its data.
static get_installed_plugins()
Returns a list of installed products keyed by text domain.
static is_callable_function( $value)
Checks if value is a callable function.
static is_not_main_network_site()
Checks if the current page is not a main network site.
static is_network_admin()
Checks if the current page is a network admin area.
static get_assets_path( $file='')
Returns path to UI assets.
static process_return( $return_object=true)
Processes return object based on the request type (e.g., AJAX) and status.
static is_callable_class_method( $value)
Checks if value is a callable class method.
static get_plugins()
Wrapper for WP's get_plugins() function.