Admin Page Framework Documentation

Packages

  • AdminPageFramework
    • Common
      • Factory
      • Form
        • FieldType
      • Utility
    • Factory
      • AdminPage
      • MetaBox
      • NetworkAdmin
      • PageMetaBox
      • PostType
      • TaxonomyField
      • TermMeta
      • UserMeta
      • Widget
    • Utility

Classes

  • AdminPageFramework_ClassTester
  • AdminPageFramework_PluginBootstrap
  • AdminPageFramework_PointerToolTip
  • AdminPageFramework_Requirement
  • AdminPageFramework_TableOfContents
  • AdminPageFramework_WPReadmeParser
  • AdminPageFramework_WPUtility_Time
  • AdminPageFramework_Zip

Resources

  • Tutorials
  • Support
  • Reporting Issues

Class AdminPageFramework_Requirement

Performs checks for given requirements whether the site can satisfy them.

Usage

Set requirements to the first parameter and perform the check() method to get the number of warnings.

Example

$_oRequirementCheck = new AdminPageFramework_Requirement(
    array(
        'php' => array(
            'version'   => '5.2.4',
            'error'     => 'The plugin requires the PHP version %1$s or higher.',
        ),
        'wordpress'         => array(
            'version'   => '3.4',
            'error'     => 'The plugin requires the WordPress version %1$s or higher.',
        ),
        'mysql'             => array(
            'version'   => '5.0',
            'error'     => 'The plugin requires the MySQL version %1$s or higher.',
        ),
    ),
    'My Plugin Name'
);

if ( $_oRequirementCheck->check() ) {
    $_oRequirementCheck->deactivatePlugin(
        $this->sFilePath,   // the plugin main file path
        __( 'Deactivating the plugin', 'admin-page-framework-loader' ),  // additional message
        true    // is in the activation hook. This will exit the script.
    );
}
Package: AdminPageFramework\Utility
Since: 3.4.6
Located at utility/requirement/AdminPageFramework_Requirement.php

Methods summary

public
# __construct( array $aRequirements = array(), string $sScriptName = '' )

Sets up properties.

To disable checking on particular item, set an empty value to the element or simply omit it.

$aRequirement = array(
 'mysql' => '',  // <-- mysql will be skipped.
 'php' ...
 // 'wordpress' will be omitted
)

Parameters

$aRequirements
array
$aRequirements An array holding a requirement definition.
  • php - (array) An array holding requirement information.
    • version - (string) a version number to be required. e.g. 1.5.0, 15.6RC01
    • error - (string) an error message to display to the user. Use a placeholder (%1$s) for the version set with the version argument to be embedded. e.g. The plugin requires the PHP version %1$s or higher.
  • wordpress - (array) An array holding requirement information.
    • version - (string) a version number to be required. e.g. 1.5.0, 15.6RC01
    • error - (string) an error message to display to the user. Use a placeholder (%1$s) for the version set with the version argument to be embedded. e.g. The plugin requires the WordPress version %1$s or higher.
  • mysql - (array) An array holding requirement information.
    • version - (string) a version number to be required. e.g. 1.5.0, 15.6RC01
    • error - (string) an error message to display to the user. Use a placeholder (%1$s) for the version set with the version argument to be embedded. e.g. The plugin requires the MySQL version %1$s or higher.
  • functions - (array) An array holding required function names in the keys and the message in the values. e.g. array( 'my_custom_func_in_other_script' => 'The function %1$s is missing. Please install the other script.' )
  • classes - (array) An array holding required class names in the keys and the message in the values. e.g. array( 'DOMDocument' => 'The plugin requires the DOMXML extension.' )
  • constants - (array) An array holding required constants in the keys and the message in the values. e.g. array( 'APSPATH' => 'The script cannot be loaded directly.' )
  • files - (array) An array holding required file paths in the keys and the message in the values. e.g. array( 'home/my_user_name/my_dir/scripts/my_scripts.php' => 'The required script could not be found.' )
$sScriptName
string
$sScriptName The script name.

Since

3.4.6
public integer
# check( )

Performs checks.

If it is not empty, it means there is a missing requirement.

Returns

integer
The number of warnings.

Since

3.4.6
public
# deactivatePlugin( string $sPluginFilePath, string $sMessage = '', boolean $bIsOnActivation = false )

Deactivates the plugin.

Parameters

$sPluginFilePath
string
$sPluginFilePath A plugin main file path.
$sMessage
string
$sMessage A message to be displayed to the user.
$bIsOnActivation
boolean
$bIsOnActivation Whether it is called upon plugin activation hook.

Since

3.4.6

Magic methods summary

Properties summary

public array $aWarnings
#

Stores warning messages of insufficient items.

Since

3.4.6

Related

If you find undocumented functionality, please report it here.

Admin Page Framework