$arrDefaultKeys
$arrDefaultKeys
Defines the import field type.
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.
$vSubject | ||
$strKey | ||
$strDefault | ||
$fBlankToDefault |
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.
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.
$arrPrecedence | ||
$arrDefault1 |
the united array.
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.
array | $arrPrecedence | the array that overrides the same keys. |
array | $arrDefault | the array that is going to be overridden. |
the united array.
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.
$numToFix | ||
$numDefault | ||
$numMin | ||
$numMax |
A numeric value will be returned.
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 );
$this->doActions( array( 'action_name1' ), $var1, $var2, $var3 );
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(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.
$this->oUtil->addAndDoActions( $this, array( 'my_action1', 'my_action2', 'my_action3' ), 'argument_a', 'argument_b' );
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. |
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.
$strPrefix | ||
$strClassName | ||
$strPageSlug | ||
$strTabSlug | ||
$fReverse |
Returns an array consisting of the filters.
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.
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 |
The modified url.
getQueryURL(array $arrAddingQueries, array $arrRemovingQueryKeys, string $strSubjectURL) : string
Returns a url with modified query stings.
array | $arrAddingQueries | The appending query key value pairs |
array | $arrRemovingQueryKeys | The removing query key value pairs |
string | $strSubjectURL | The subject url to modify |
The modified url.
getInputFieldNameFlat( $arrField)
Retrieves the field name attribute whose dimensional elements are delimited by the pile character.
Instead of [] enclosing array elements, it uses the pipe(|) to represent the multi dimensional array key. This is used to create a reference the submit field name to determine which button is pressed.
$arrField |
getInputFieldValueFromLabel( $arrField)
Retrieves the input field value from the label.
This method is similar to the above getInputFieldValue() but this does not check the stored option value. It uses the value set to the vLabel key. This is for submit buttons including export custom field type that the label should serve as the value.
$arrField |