Hooks and Constants of Demo Reset Free Plugin – (Free Plugin Only)

Overview

This document outlines the developer hooks and constants available for customizing the behavior of the Demo Reset Free plugin. It provides clear explanations, example code, and guidance on where to place each snippet for correct implementation.

Hooks and Constants List:

Hooks

demo_reset_allowed_upload_caps

  • This is a filter hook.
  • This hook allows restricted Demo User upload capabilities to be enabled.
  • Paste the given code into the functions.php file of your active theme.
  • This code activates upload capabilities for Demo Users. By default, the Demo Reset plugin disables upload capabilities for non-admins (Demo Users) to prevent files from piling up in the uploads directory without being recorded in the database. If you enable uploads for Demo Users, you may need to manually delete unwanted files via FTP after some time.
  • Code:
/**
 * Activates upload capabilities for non-admins (Demo Users).
 */
add_filter('demo_reset_allowed_upload_caps', function($allcaps) {
	if (isset($allcaps['upload_files']) && $allcaps['upload_files']) $allcaps['upload_files'] = 1;
	if (isset($allcaps['unfiltered_upload']) && $allcaps['unfiltered_upload']) $allcaps['unfiltered_upload'] = 1;
	return $allcaps;
});

demo_reset_reset_gap_tolerance

  • This is a filter hook.
  • This hook allows redefining the reset gap tolerance in seconds.
  • Paste the given code into the functions.php file of your active theme and change the reset gap tolerance in seconds as desired.
  • Reset gap tolerance is the maximum allowed time difference between the last two reset intervals for them to be treated as the same. By default, the Demo Reset Plugin sets this to 60 seconds. This parameter is one of several factors that determine the visibility of the Next Reset Time.
  • Code:
/**
 * Sets custom reset gap tolerance to determine the visibility of the Next Reset Time.
 */
add_filter('demo_reset_reset_gap_tolerance', function($tolerance) {
	$tolerance = 60;
	return $tolerance;
});

demo_reset_info_bar_custom_css

  • This is an action hook.
  • This hook allows adding custom CSS for the Info Bar.
  • Paste the given code into the functions.php file of your active theme and modify or add CSS lines as desired.
  • Code:
/**
 * Adds custom CSS for the Info Bar.
 */
add_action('demo_reset_info_bar_custom_css', function() {
	echo '#demo-reset-info-bar {border-bottom: 2px solid #ff3b30;}';
	echo '#demo-reset-info-bar {border-top: 2px solid #ff3b30;}';
});

Constants

DEMO_RESET_RESET_POINTS_LIMIT

  • This is a constant that can be redefined.
  • Redefining this constant allows you to increase or decrease the number of Reset Points you can create as the admin. The default value is 5.
  • Paste the given code line into the ‘Add any custom values’ section of the wp-config.php file and change the value as desired.
  • Code:
define('DEMO_RESET_RESET_POINTS_LIMIT', 5);

DEMO_RESET_RESET_HISTORY_LIMIT

  • This is a constant that can be redefined.
  • Redefining this constant allows you to increase or decrease the Reset History Limit, which controls the number of Reset History items displayed on the Demo Reset dashboard. The default value is 100.
  • Paste the given code line into the ‘Add any custom values’ section of the wp-config.php file and change the value as desired.
  • Code:
define('DEMO_RESET_RESET_HISTORY_LIMIT', 100);

DEMO_RESET_DEMO_USERNAMES_NUMBER

  • This is a constant that can be redefined.
  • Redefining this constant allows you to change the Reset Runner on which the visibility of the Next Reset Time depends. This constant can only be set to ‘reset_runner_url_token’ or ‘reset_runner_rest_url_token’. The default value is ‘reset_runner_url_token’.
  • Paste the given code line into the ‘Add any custom values’ section of the wp-config.php file and change the value as desired.
  • Code:
define('DEMO_RESET_DEMO_USERNAMES_NUMBER', 8);

DEMO_RESET_RUNNER_FOR_TIMER

  • This is a constant that can be redefined.
  • Redefining this constant allows you to increase or decrease the maximum number of Demo Usernames displayed on the Info Bar. The default value is 8.
  • Paste the given code line into the ‘Add any custom values’ section of the wp-config.php file and change the value as desired.
  • Code:
define('DEMO_RESET_RUNNER_FOR_TIMER', 'reset_runner_url_token');