add_action

Definition:
function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {}

Hooks a function on to a specific action.
Actions are the hooks that the WordPress core launches at specific points during execution, or when specific events occur. Plugins can specify that one or more of its PHP functions are executed at these points, using the Action API.

Parameters

  • string $tag: The name of the action to which the $function_to_add is hooked.
  • callback $function_to_add: The name of the function you wish to be called.
  • int $priority: optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
  • int $accepted_args: optional. The number of arguments the function accept (default 1).

Source code

function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {

	return add_filter($tag, $function_to_add, $priority, $accepted_args);

}

209

addslashes_gpc

Definition:
function addslashes_gpc($gpc) {}

Adds slashes to escape strings.
Slashes will first be removed if magic_quotes_gpc is set, see http://www.php.net/magic_quotes for more details.

Parameters

  • string $gpc: The string returned from HTTP request data.

Return values

returns:Returns a string escaped with slashes.

Source code

function addslashes_gpc($gpc) {

	if ( get_magic_quotes_gpc() )

		$gpc = stripslashes($gpc);



	return esc_sql($gpc);

}

207

activate_plugins

Definition:
function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {}

Activate multiple plugins.
When WP_Error is returned, it does not mean that one of the plugins had errors. It means that one or more of the plugins file path was invalid.

Parameters

  • string|array $plugins
  • string $redirect: Redirect to page after successful activation.
  • bool $network_wide: Whether to enable the plugin for all sites in the network.
  • bool $silent: Prevent calling activation hooks. Default is false.

Return values

returns:True when finished or WP_Error if there were errors during a plugin activation.

Source code

function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false ) {

	if ( !is_array($plugins) )

		$plugins = array($plugins);



	$errors = array();

	foreach ( $plugins as $plugin ) {

		if ( !empty($redirect) )

			$redirect = add_query_arg('plugin', $plugin, $redirect);

		$result = activate_plugin($plugin, $redirect, $network_wide, $silent);

		if ( is_wp_error($result) )

			$errors[$plugin] = $result;

	}



	if ( !empty($errors) )

		return new WP_Error('plugins_invalid', __('One of the plugins is invalid.'), $errors);



	return true;

}

203

activate_plugin

Definition:
function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {}

Attempts activation of plugin in a "sandbox" and redirects on success.
A plugin that is already activated will not attempt to be activated again.

Parameters

  • string $plugin: Plugin path to main plugin file with plugin data.
  • string $redirect: Optional. URL to redirect to.
  • bool $network_wide: Whether to enable the plugin for all sites in the network or just the current site. Multisite only. Default is false.
  • bool $silent: Prevent calling activation hooks. Optional, default is false.

Return values

returns:WP_Error on invalid file or null on success.

Defined actions

  • activate_plugin
    do_action( 'activate_plugin', $plugin, $network_wide );
  • activate_’.$plugin
    do_action( 'activate_' . $plugin, $network_wide );
  • activated_plugin
    do_action( 'activated_plugin', $plugin, $network_wide );

Source code

function activate_plugin( $plugin, $redirect = '', $network_wide = false, $silent = false ) {

	$plugin = plugin_basename( trim( $plugin ) );



	if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) {

		$network_wide = true;

		$current = get_site_option( 'active_sitewide_plugins', array() );

	} else {

		$current = get_option( 'active_plugins', array() );

	}



	$valid = validate_plugin($plugin);

	if ( is_wp_error($valid) )

		return $valid;



	if ( !in_array($plugin, $current) ) {

		if ( !empty($redirect) )

			wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error

		ob_start();

		include_once(WP_PLUGIN_DIR . '/' . $plugin);



		if ( ! $silent ) {

			do_action( 'activate_plugin', $plugin, $network_wide );

			do_action( 'activate_' . $plugin, $network_wide );

		}



		if ( $network_wide ) {

			$current[$plugin] = time();

			update_site_option( 'active_sitewide_plugins', $current );

		} else {

			$current[] = $plugin;

			sort($current);

			update_option('active_plugins', $current);

		}



		if ( ! $silent ) {

			do_action( 'activated_plugin', $plugin, $network_wide );

		}



		if ( ob_get_length() > 0 ) {

			$output = ob_get_clean();

			return new WP_Error('unexpected_output', __('The plugin generated unexpected output.'), $output);

		}

		ob_end_clean();

	}



	return null;

}

201

absint

Definition:
function absint( $maybeint ) {}

Converts value to nonnegative integer.

Parameters

  • mixed $maybeint: Data you wish to have converted to a nonnegative integer

Return values

returns:An nonnegative integer

Source code

function absint( $maybeint ) {

	return abs( intval( $maybeint ) );

}

199