-
Notifications
You must be signed in to change notification settings - Fork 0
Filters
Important: This documentation is still under construction, some filters may be missing or not fully documented
Filters the array of list of social network links that can be edited in the Social page of the Settings section in the WordPress admin.
apply_filter('jpwp_toolkit_social_network_links', array $networks );$networks (array)
The keyword => label array of social networks.
return (array)
The updated social network array
The following example the code adds a GitHub field.
function add_github_link($networks) {
$networks['github'] = 'GitHub';
return $networks;
}
add_filter('jpwp_toolkit_social_network_links', 'add_github_link');This hook filter the content passed to Form::options() method before construct the HTML elements. Is a quick method to add a shorthand to options.
apply_filter('jpwp_toolkit_helpers_form_options', array|string $options );$options (array|string)
An array with the options
return (array)
The updated options array.
The following example the code adds the colors shorthand.
function add_color_options($options) {
// Always check if $options is your shorthand before process it.
if ('colors' != $options) {
// Isn't 'colors' shorthand, then returns the value unfiltered.
return $options;
}
$colors = [
'#FFFFFF' => __( 'White', 'textdomain' ),
'#808080' => __( 'Gray', 'textdomain' ),
'#000000' => __( 'Black', 'textdomain' ),
'#FF0000' => __( 'Red', 'textdomain' ),
'#FFFF00' => __( 'Yellow', 'textdomain' ),
'#008000' => __( 'Green', 'textdomain' ),
'#0000FF' => __( 'Blue', 'textdomain' ),
];
return $colors;
}
add_filter('jpwp_toolkit_helpers_form_options', 'add_color_options');Now you can use the colors shorthand to show these options.
echo Form::options( 'colors' );The code above will generate the following HTML:
<option value="#FFFFFF">White</option>
<option value="#808080">Gray</option>
<option value="#000000">Black</option>
<option value="#FF0000">Red</option>
<option value="#FFFF00">Yellow</option>
<option value="#008000">Green</option>
<option value="#0000FF">Blue</option>