Developer Reference
Scalability Pro exposes a set of PHP constants and one add-on registration filter for developers who need to tune its behaviour beyond what the settings screens offer, or who are building an add-on that plugs into it. This article covers the configuration constants you can define in wp-config.php, how to set them, and how the spro_register_addons filter lets an external plugin register itself and its settings tab.
Every constant listed here is defined with a guard in the plugin’s defines.php, so defining it earlier (in wp-config.php) always wins. Anything not listed here is either internal or not consumed by the current code, so leave it alone.
Configuration constants
| Constant | Default | Purpose |
|---|---|---|
SPRO_ATTRIBUTE_AJAX_LIMIT | 10 | Number of attribute terms fetched per request when the Ajax Attribute Editing feature is active. Keeps the product editor responsive on attributes with very large term sets. Set to 0 to disable the limiting behaviour entirely. |
SPRO_KEEP_DEFER_TERM_COUNTS_OPTION | true | Keeps the Defer Term Counting option and its supporting code active. When falsey, the deferred term-count machinery is not wired up. |
SPRO_ALWAYS_DO_TERM_RECOUNTS | array('nav_menu', 'link_category', 'post_format', 'wp_theme', 'wp_template_part_area', 'elementor_library_type', 'elementor_library_category') | Taxonomies that are always recounted even while Defer Term Counting is deferring counts for everything else. Redefine the array to add your own taxonomies. |
SPRO_REMOVE_SORT_ORDER_POST_TYPES | array('product', array('product', 'product_variation')) | Post types for which the natural (menu-order) sort clause is removed, avoiding an expensive sort on large archives. Only applies when the natural sort-order option is set and no explicit orderby is requested. |
SPRO_SQL_CALC_ROWS_FINGERPRINT | array() | Stack-trace fingerprints used to widen removal of SQL_CALC_FOUND_ROWS. By default only the main query is stripped; add substrings that appear in a query’s stack trace (for example a plugin folder or calling function) to strip it from those queries too. |
SPRO_CACHE_PMXE_META_KEYS | false | Enables caching of the distinct meta-key list WP All Export builds when exporting a custom post type, which is otherwise a slow scan of postmeta. |
SPRO_PREVENT_WPAI_DUP_CHECK | false | When true, short-circuits WP All Import’s in-file duplicate check, which scans the import file for duplicates and is wasteful on large imports. |
SPRO_NAV_MENU_OPTIMISATIONS | false | Enables the nav-menu query optimisations in the archive options code. |
SPRO_ALLOW_NAV_MENU_ITEMS_FILTERS | false | Query filters are normally suppressed for nav_menu_item queries, so the standard optimisations do not reach them. Set true to force suppress_filters off for those queries so the optimisations apply. |
Two of these are booleans that are on by default (SPRO_KEEP_DEFER_TERM_COUNTS_OPTION) and off by default (SPRO_CACHE_PMXE_META_KEYS, SPRO_PREVENT_WPAI_DUP_CHECK, both nav-menu constants); the rest are numbers or arrays. Where a constant relates to a feature that has its own settings screen, the constant tunes the underlying behaviour rather than turning the feature on. See Ajax Attribute Editing for SPRO_ATTRIBUTE_AJAX_LIMIT and Defer Term Counting for SPRO_KEEP_DEFER_TERM_COUNTS_OPTION and SPRO_ALWAYS_DO_TERM_RECOUNTS.
How to set a constant
Define the constant in wp-config.php, above the line that says to stop editing. Because defines.php only defines each constant if it is not already defined, your value takes precedence.
define('SPRO_ATTRIBUTE_AJAX_LIMIT', 25);
define('SPRO_ALWAYS_DO_TERM_RECOUNTS', array(
'nav_menu',
'link_category',
'post_format',
'product_cat',
));
define('SPRO_SQL_CALC_ROWS_FINGERPRINT', array(
'my-plugin/includes/class-archive-query.php',
));
Array constants replace the default wholesale, so if you are adding to SPRO_ALWAYS_DO_TERM_RECOUNTS include the existing entries you still want alongside your additions.
Redefining an array constant overwrites the default array entirely, it does not append to it. Copy the default entries you still want into your define() alongside your additions, or you will silently drop taxonomies (or fingerprints) the plugin was relying on.
Registering an add-on
Scalability Pro can host add-on plugins. An add-on registers through the spro_register_addons filter, which passes an array keyed by add-on slug. Each entry must declare a dir (the add-on’s base directory); the loader then requires tabs/<slug>/functions.php from that directory on plugins_loaded, and, if present, registers tabs/<slug>/tab.php as a settings tab in the Scalability Pro admin page.
The slug is the array key, and it is what forms the tabs/<slug>/ path, so the add-on’s files must live under a folder matching that key. Register during your own plugin’s load so the filter is in place before plugins_loaded priority 10.
if (defined('SPROPLUGIN_DIR')) {
add_filter('spro_register_addons', function ($addons) {
$addons['archives'] = array(
'plugin_file' => __FILE__,
'dir' => MY_ADDON_PLUGIN_DIR,
'version' => MY_ADDON_VERSION,
'label' => 'Archives',
'tab_slug' => 'archives',
);
return $addons;
});
}
The loader uses require_once, so an add-on that also registers with another parent (Super Speedy Filters has an equivalent loader) will not redeclare its functions when both parents resolve to the same file. Super Speedy Listings is the reference add-on and registers exactly as shown above under the archives slug; see the Super Speedy Archives Add-on for the working example.
Guarding the registration with defined('SPROPLUGIN_DIR') means the add-on only tries to attach when Scalability Pro is actually active.
Add the spro_register_addons filter during your own plugin’s load, before plugins_loaded priority 10, and wrap it in defined('SPROPLUGIN_DIR'). That way your tab registers in time and your add-on stays dormant (rather than fatal) whenever Scalability Pro is not present.
Notes
A few constants are internal and not intended for you to redefine, though they are handy to read. SPRO_VERSION holds the plugin version (read from the plugin header), SPRO_PLUGIN_NAME is the display name, and SPROPLUGIN_DIR is the plugin’s base directory, which is the value an add-on checks before registering.
SPRO_DB_VERSION (currently 6.13) tracks the schema version of Scalability Pro’s own tables and drives upgrade routines, so treat it as read-only. SPRO_ROW_CACHE_KEY is an internal cache-key prefix for the cached admin list tables and should not be redefined. If you are relying on the Remove Image Sizes Globally feature, note that it is driven by its own settings rather than a constant, so configure it from the settings screen rather than in wp-config.php.
WordPress Abilities API and MCP
On WordPress versions that provide the Abilities API, Scalability Pro registers 12 abilities in the spro namespace: get-settings, describe-settings, measure, set-settings, apply-setting, get-index-status, describe-recommended, apply-recommended, scan-options, get-options-plan, apply-options-plan and revert-options-plan. The read abilities inspect, measure and plan; safe writes use set-settings; confirmed changes use the dedicated apply/revert paths.
The capability split is spro_manage for inspection and safe settings, and spro_apply for confirmed changes. Administrators inherit both from manage_options. The shared Super Speedy bridge exposes permitted abilities through one site-wide connection; Scalability Pro registers no dedicated MCP server. Older WordPress versions simply skip the Abilities integration.
The measure ability accepts at most ten URLs on the site’s exact scheme, host and port, plus the named post-count, recent-posts and term-count database probes. It never accepts arbitrary SQL.
Further reading
spro_register_addons exactly as documented here
Comments