uiXpress
Api

UiXpress Core Stop Filter

Control when UiXpress stops running using WordPress filter hooks

Overview

The uixpress/core/stop filter allows plugins and themes to programmatically stop UiXpress from initializing and running. This is useful when you need to disable UiXpress on specific pages, in certain contexts, or based on custom conditions.

When the filter returns true, UiXpress will stop early and only load minimal styles, preventing the full admin interface from loading.

Filter Hook

Hook Name

uixpress/core/stop

Hook Type

WordPress Filter Hook - Modifies the stop condition

Hook Signature

add_filter('uixpress/core/stop', function($should_stop, $action) {
  // Modify stop condition
  return $should_stop;
}, 10, 2);

Parameters

  • $should_stop (bool): Current stop condition. true stops UiXpress, false allows it to run.
  • $action (string): Current action from $_GET['action'] parameter (sanitized)

Return Value

Returns a boolean:

  • true - Stop UiXpress from running
  • false - Allow UiXpress to run normally

Priority

Default priority is 10. Lower numbers run first.

Default Behavior

By default, UiXpress will stop running in the following scenarios:

  1. Theme Updates: When action=update-selected-themes
  2. Plugin Updates: When action=update-selected
  3. Breakdance Builder: When breakdance_wpuiforbuilder_tinymce=true

Usage Examples

Always Stop UiXpress

add_filter('uixpress/core/stop', '__return_true');

Stop UiXpress on Specific Pages

add_filter('uixpress/core/stop', function($should_stop, $action) {
    $screen = get_current_screen();
    
    if ($screen && $screen->id === 'my-custom-page') {
        return true; // Stop UiXpress on this page
    }
    
    return $should_stop; // Keep default behavior
}, 10, 2);

Stop UiXpress Based on User Role

add_filter('uixpress/core/stop', function($should_stop, $action) {
    $current_user = wp_get_current_user();
    
    // Stop UiXpress for subscribers
    if (in_array('subscriber', $current_user->roles)) {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

Stop UiXpress Based on URL Parameters

add_filter('uixpress/core/stop', function($should_stop, $action) {
    // Stop UiXpress when a specific parameter is present
    if (isset($_GET['disable_uixpress']) && $_GET['disable_uixpress'] === '1') {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

Stop UiXpress for Specific Post Types

add_filter('uixpress/core/stop', function($should_stop, $action) {
    global $post_type;
    
    // Stop UiXpress when editing specific post types
    $disabled_types = ['product', 'order'];
    
    if (isset($post_type) && in_array($post_type, $disabled_types)) {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

Conditional Stop Based on Plugin State

add_filter('uixpress/core/stop', function($should_stop, $action) {
    // Stop UiXpress if another plugin is active
    if (is_plugin_active('conflicting-plugin/conflicting-plugin.php')) {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

Stop UiXpress During Maintenance Mode

add_filter('uixpress/core/stop', function($should_stop, $action) {
    // Stop UiXpress if site is in maintenance mode
    if (defined('WP_MAINTENANCE_MODE') && WP_MAINTENANCE_MODE) {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

Combine Multiple Conditions

add_filter('uixpress/core/stop', function($should_stop, $action) {
    $screen = get_current_screen();
    $current_user = wp_get_current_user();
    
    // Stop UiXpress if:
    // 1. On a specific screen, OR
    // 2. User has a specific role, OR
    // 3. A custom option is enabled
    if (
        ($screen && $screen->id === 'my-custom-page') ||
        in_array('subscriber', $current_user->roles) ||
        get_option('my_plugin_disable_uixpress', false)
    ) {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

Best Practices

1. Always Return the Original Value

Unless you want to override the default behavior, always return the original $should_stop value:

// Good - preserves default behavior
add_filter('uixpress/core/stop', function($should_stop, $action) {
    if (your_condition()) {
        return true;
    }
    return $should_stop; // Preserve default
}, 10, 2);

// Bad - ignores default behavior
add_filter('uixpress/core/stop', function($should_stop, $action) {
    return your_condition(); // Ignores default conditions
}, 10, 2);

2. Use Appropriate Priority

Use priority to control when your filter runs:

// High priority - runs early, before other filters
add_filter('uixpress/core/stop', 'my_stop_function', 5, 2);

// Low priority - runs late, after other filters
add_filter('uixpress/core/stop', 'my_stop_function', 20, 2);

3. Check Conditions Safely

Always check if variables exist before using them:

add_filter('uixpress/core/stop', function($should_stop, $action) {
    $screen = get_current_screen();
    
    // Safe check
    if ($screen && isset($screen->id) && $screen->id === 'my-page') {
        return true;
    }
    
    return $should_stop;
}, 10, 2);

4. Document Your Usage

When using this filter in a plugin, document why you're disabling UiXpress:

/**
 * Disable UiXpress on our custom admin page
 * 
 * Our custom page uses its own UI that conflicts with UiXpress
 */
add_filter('uixpress/core/stop', function($should_stop, $action) {
    $screen = get_current_screen();
    if ($screen && $screen->id === 'my-plugin-page') {
        return true;
    }
    return $should_stop;
}, 10, 2);

5. Use Namespaced Functions

If creating a reusable function, use a namespaced function name:

function my_plugin_should_stop_uixpress($should_stop, $action) {
    // Your logic here
    return $should_stop;
}

add_filter('uixpress/core/stop', 'my_plugin_should_stop_uixpress', 10, 2);

Troubleshooting

UiXpress Still Running When It Shouldn't

  1. Check Filter Priority: Ensure your filter runs before other filters that might override it
  2. Verify Return Value: Make sure you're returning true (not a truthy value)
  3. Check Hook Timing: Ensure the filter is added early enough (use plugins_loaded or earlier)
// Ensure filter is added early
add_action('plugins_loaded', function() {
    add_filter('uixpress/core/stop', 'my_stop_function', 10, 2);
});

UiXpress Stopped When It Shouldn't

  1. Check Other Plugins: Another plugin might be using this filter
  2. Verify Default Conditions: Check if default conditions are being triggered
  3. Review Filter Logic: Ensure your condition logic is correct

Debugging Filter Execution

You can debug filter execution by logging:

add_filter('uixpress/core/stop', function($should_stop, $action) {
    error_log('UiXpress stop check - Current: ' . ($should_stop ? 'true' : 'false'));
    error_log('UiXpress stop check - Action: ' . $action);
    
    // Your logic here
    
    $new_stop = your_condition() ? true : $should_stop;
    error_log('UiXpress stop check - New: ' . ($new_stop ? 'true' : 'false'));
    
    return $new_stop;
}, 10, 2);

API Reference

Filter Hook

Name: uixpress/core/stop

Type: WordPress Filter Hook

Parameters:

  • $should_stop (bool): Current stop condition
  • $action (string): Current action from $_GET['action']

Returns: Boolean (true to stop UiXpress, false to allow)

Priority: Default 10 (lower runs first)

Since: Version 1.0.6