Properties

$arrDefaultKeys

$arrDefaultKeys

$oMsg

$oMsg

Methods

replyToFieldLoader()

replyToFieldLoader()

replyToRemovingMediaLibraryTab()

replyToRemovingMediaLibraryTab( $arrTabs)

Removes the From URL tab from the media uploader.

since 2.1.3 since 2.1.5 Moved from AdminPageFramework_SettingsAPI. Changed the name from removeMediaLibraryTab() to replyToRemovingMediaLibraryTab().

Parameters

$arrTabs

replyToGetInputScripts()

replyToGetInputScripts()

replyToGetInputStyles()

replyToGetInputStyles()

replyToGetInputField()

replyToGetInputField( $vValue,  $arrField,  $arrOptions,  $arrErrors,  $arrFieldDefinition)

Returns the output of the field type.

Parameters

$vValue
$arrField
$arrOptions
$arrErrors
$arrFieldDefinition

__construct()

__construct( $strClassName,  $strFieldTypeSlug,  $oMsg,  $fAutoRegister)

Parameters

$strClassName
$strFieldTypeSlug
$oMsg
$fAutoRegister

replyToRegisterInputFieldType()

replyToRegisterInputFieldType( $arrFieldDefinitions)

Registers the field type.

A callback function for the field_types_{$strClassName} filter.

Parameters

$arrFieldDefinitions

getDefinitionArray()

getDefinitionArray()

Returns the field type definition array.

replytToGetInputField()

replytToGetInputField()

replyToGetInputIEStyles()

replyToGetInputIEStyles()

sanitizeSlug()

sanitizeSlug( $strSlug) : string

Converts non-alphabetic characters to underscore.

Parameters

$strSlug

Returns

string —

The sanitized string.

sanitizeString()

sanitizeString( $strString) : string

Converts non-alphabetic characters to underscore except hyphen(dash).

Parameters

$strString

Returns

string —

The sanitized string.

getCorrespondingArrayValue()

getCorrespondingArrayValue( $vSubject,  $strKey,  $strDefault,  $fBlankToDefault) : string|array

Retrieves a corresponding array value from the given array.

When there are multiple arrays and they have similar index structures but it's not certain if one has the key and the others, use this method to retrieve the corresponding key value.

Parameters

$vSubject
$strKey
$strDefault
$fBlankToDefault

Returns

string|array —

If the key does not exist in the passed array, it will return the default. If the subject value is not an array, it will return the subject value itself.

getArrayDimension()

getArrayDimension(array $array) : integer

Finds the dimension depth of the given array.

Parameters

array $array

the subject array to check.

Returns

integer —

returns the number of dimensions of the array.

uniteArrays()

uniteArrays( $arrPrecedence,  $arrDefault1) : array

Merges multiple multi-dimensional array recursively.

The advantage of using this method over the array unite operator or array_merge() is that it merges recursively and the null values of the preceding array will be overridden.

Parameters

$arrPrecedence
$arrDefault1

Returns

array —

the united array.

uniteArraysRecursive()

uniteArraysRecursive(array $arrPrecedence, array $arrDefault) : array

Merges two multi-dimensional arrays recursively.

The first parameter array takes its precedence. This is useful to merge default option values. An alternative to array_replace_recursive(); it is not supported PHP 5.2.x or below.

Parameters

array $arrPrecedence

the array that overrides the same keys.

array $arrDefault

the array that is going to be overridden.

Returns

array —

the united array.

getQueryValueInURLByKey()

getQueryValueInURLByKey( $strURL,  $strQueryKey) : string|null

Retrieves the query value from the given URL with a key.

Parameters

$strURL
$strQueryKey

Returns

string|null

fixNumber()

fixNumber( $numToFix,  $numDefault,  $numMin,  $numMax) : string|integer

Checks if the passed value is a number and set it to the default if not.

This is useful for form data validation. If it is a number and exceeds the set maximum number, it sets it to the maximum value. If it is a number and is below the minimum number, it sets to the minimum value. Set a blank value for no limit.

Parameters

$numToFix
$numDefault
$numMin
$numMax

Returns

string|integer —

A numeric value will be returned.

getRelativePath()

getRelativePath( $from,  $to)

Calculates the relative path from the given path.

This function is used to generate a template path.

Parameters

$from
$to

doActions()

doActions(array $arrActionHooks, mixed $vArgs1, mixed $vArgs2, mixed $_and_more) : void

Triggers the do_action() function with the given action names and the arguments.

This is useful to perform do_action() on multiple action hooks with the same set of arguments. For example, if there are the following action hooks, action_name, action_name1, and action_name2, and to perform these, normally it takes the following lines. do_action( 'action_name1', $var1, $var2 ); do_action( 'action_name2', $var1, $var2 ); do_action( 'action_name3', $var1, $var2 );

This method saves these line this way: $this->doActions( array( 'action_name1', 'action_name2', 'action_name3' ), $var1, $var2 );

Example

$this->doActions( array( 'action_name1' ), $var1, $var2, $var3 );

Parameters

array $arrActionHooks

a numerically indexed array consisting of action hook names to execute.

mixed $vArgs1

an argument to pass to the action callbacks.

mixed $vArgs2

another argument to pass to the action callbacks.

mixed $_and_more

add as many arguments as necessary to the next parameters.

addAndDoActions()

addAndDoActions(object $oCallerObject, array $arrActionHooks, mixed $vArgs1, mixed $vArgs2, mixed $_and_more) : void

Adds the method of the given action hook name(s) to the given action hook(s) with arguments.

In other words, this enables to register methods to the custom hooks with the same name and triggers the callbacks (not limited to the registered ones) assigned to the hooks. Of course, the registered methods will be triggered right away. Thus, the magic overloading __call() should catch them and redirect the call to the appropriate methods. This enables, at the same time, publicly the added custom action hooks; therefore, third-party scripts can use the action hooks.

This is the reason the object instance must be passed to the first parameter. Regular functions as the callback are not supported for this method.

Example

$this->oUtil->addAndDoActions( $this, array( 'my_action1', 'my_action2', 'my_action3' ), 'argument_a', 'argument_b' );

Parameters

object $oCallerObject

the object that holds the callback method that matches the action hook name.

array $arrActionHooks

a numerically index array consisting of action hook names that serve as the callback method names.

mixed $vArgs1

the argument to pass to the hook callback functions.

mixed $vArgs2

another argument to pass to the hook callback functions.

mixed $_and_more

add as many arguments as necessary to the next parameters.

addAndDoAction()

addAndDoAction( $oCallerObject,  $strActionHook,  $vArgs1,  $vArgs2,  $_and_more) : void

Adds the methods of the given action hook name to the given action hook with arguments.

Parameters

$oCallerObject
$strActionHook
$vArgs1
$vArgs2
$_and_more

addAndApplyFilters()

addAndApplyFilters()

addAndApplyFilter()

addAndApplyFilter()

getFilterArrayByPrefix()

getFilterArrayByPrefix( $strPrefix,  $strClassName,  $strPageSlug,  $strTabSlug,  $fReverse) : array

Provides an array consisting of filters for the addAndApplyFileters() method.

The order is, page + tab -> page -> class, by default but it can be reversed with the $fReverse parameter value.

Parameters

$strPrefix
$strClassName
$strPageSlug
$strTabSlug
$fReverse

Returns

array —

Returns an array consisting of the filters.

goRedirect()

goRedirect( $strURL)

Redirects to the given URL and exits. Saves one extra line, exit;.

Parameters

$strURL

getCurrentAdminURL()

getCurrentAdminURL()

Retrieves the current URL in the admin page.

getQueryAdminURL()

getQueryAdminURL(array $arrAddingQueries, array $arrRemovingQueryKeys, string $strSubjectURL) : string

Returns a url with modified query stings.

Identical to the getQueryURL() method except that if the third parameter is omitted, it will use the currently browsed admin url.

Parameters

array $arrAddingQueries

The appending query key value pairs e.g. array( 'page' => 'my_page_slug', 'tab' => 'my_tab_slug' )

array $arrRemovingQueryKeys

( optional ) The removing query keys. e.g. array( 'settings-updated', 'my-custom-admin-notice' )

string $strSubjectURL

( optional ) The subject url to modify

Returns

string —

The modified url.

getQueryURL()

getQueryURL(array $arrAddingQueries, array $arrRemovingQueryKeys, string $strSubjectURL) : string

Returns a url with modified query stings.

Parameters

array $arrAddingQueries

The appending query key value pairs

array $arrRemovingQueryKeys

The removing query key value pairs

string $strSubjectURL

The subject url to modify

Returns

string —

The modified url.

getSRCFromPath()

getSRCFromPath( $strFilePath) : string

Calculates the URL from the given path.

Parameters

$strFilePath

Returns

string —

The source url

resolveSRC()

resolveSRC( $strSRC,  $fReturnNullIfNotExist)

Resolves the given src.

Checks if the given string is a url, a relative path, or an absolute path and returns the url if it's not a relative path.

Parameters

$strSRC
$fReturnNullIfNotExist

getDefaultKeys()

getDefaultKeys()

enqueueMediaUploader()

enqueueMediaUploader()

Enqueues scripts and styles for the media uploader.

getScript_CustomMediaUploaderObject()

getScript_CustomMediaUploaderObject()

Returns the JavaScript script that creates a custom media uploader object.

getEnqueuingScripts()

getEnqueuingScripts()

getEnqueuingStyles()

getEnqueuingStyles()

getScriptData()

getScriptData( $strPath,  $strType)

Returns an array of plugin data from the given path.

An alternative to get_plugin_data() as some users change the location of the wp-admin directory.

Parameters

$strPath
$strType

getImageInputTags()

getImageInputTags( $vValue,  $arrField,  $strFieldName,  $strTagID,  $strKey,  $strLabel,  $fMultipleFields,  $arrDefaultKeys)

A helper function for the above replyToGetInputField() method to return input elements.

Parameters

$vValue
$arrField
$strFieldName
$strTagID
$strKey
$strLabel
$fMultipleFields
$arrDefaultKeys

getImageInputValue()

getImageInputValue( $vValue,  $strKey,  $fMultipleFields,  $strCaptureAttribute,  $arrDefaultKeys)

A helper function for the above getImageInputTags() method that retrieve the specified input field value.

Parameters

$vValue
$strKey
$fMultipleFields
$strCaptureAttribute
$arrDefaultKeys

getImageUploaderButtonScript()

getImageUploaderButtonScript( $strInputID,  $fRpeatable,  $fExternalSource)

A helper function for the above getImageInputTags() method to add a image button script.

Parameters

$strInputID
$fRpeatable
$fExternalSource