WP Inline Comment Errors plug-in
Configuration functions
wpice_set_config_options
Parameters
(array) (required) config_options data array (see below)
'show_post_data' => true | false
'req_mark_location' => 'after-label' | 'after-field' | 'none'
'req_mark' => '*'
'hide_wp_req_mark' => true | false
'auto_display_errors' => 'action function name' | null
'anchor_fragment_name' => 'goto_error_message'
'error_template_path' > 'wpice-comment-error-template.php'
Return Values
none
Description
This action sets parameters for how the comment form displays $_POST data, required field mark, automatic display of errors, and sets the path to the custom error template. Call this action from your functions.php file. Pass the config_options
array to the action to configure.
show_post_data
, defaults to true
true – Displays $_POST data in form fields if comment contains errors.
false – Do not automatically display $_POST data.
req_mark_location
, defaults to ‘after-label’
after-field – Display required mark after field.
after-label – Display required mark after label tag text.
none – Do not display the required mark.
req_mark
, defaults to
*
This property stores the HTML for required mark.
hide_wp_req_mark
, defaults to true
true – Removes WordPress generated required mark from author and email field HTML.
false – Does not remove the WordPress generated required mark.
auto_display_errors
, defaults to ‘comment_form_top’
(string) – Name of comment form action function to position error list.
null – Do not automatically display errors.
anchor_fragment_name
, defaults to ‘goto_error_message’. This is the value the plug-in uses for the fragment identifier and name attribute of the anchor tag.
error_template_path
, defaults to ‘wpice-comment-error-template.php’. This is the path to the error template relative to the current theme directory. If you do not provide a path, then the plug-in will look for a file with the name,’wpice-comment-error-template.php’, in the current theme. If it cannot find this file it will use the default WordPress error display.
Usage
do_action('wpice_set_config_options',$config_options);
Examples
Disable the automatic display of the error list.
$config_options = array(
'auto_display_errors' => null
);
do_action('wpice_set_config_options',$config_options);
Use the comment_form_before action hook to display automatic error list message before the form.
$config_options = array(
'auto_display_errors' => 'comment_form_before'
);
do_action('wpice_set_config_options',$config_options);
Change the required field mark to “!” and your own style sheet class.
$config_options = array(
'req_mark' => '!'
);
do_action('wpice_set_config_options',$config_options);
Change the anchor fragment name.
$config_options = array(
'anchor_fragment_name' => 'my_anchor_name'
);
do_action('wpice_set_config_options',$config_options);
Set the path and file name for the custom error template.
$config_options = array(
'error_template_path' => '/my_directory/my-comment-error.php'
);
do_action('wpice_set_config_options',$config_options);
wpice_get_config_options
Parameters
None. Note that you must pass an empty string as the second argument. WordPress requires this for the apply_filters() function.
Return Value
(array) – returns the config_options array.
Description
Returns an array of all configuration options.
Usage
$my_config = apply_filters('wpice_get_config_options','')
Example
$my_config = do_action('wpice_get_config_options','')
print_r($my_config); // display all values in the array
wpice_set_messages
Parameters
(array) (required) custom_error_messages data array (see below)
'author' => '',
'email' => '',
'comment'=> '',
'comment-duplicate' => ''
Return Value
none.
Description
Use this function to set the error messages that the user will see for author/name, email, comment and comment duplicate errors. Note that any error message you provide in a validation function will override the corresponding field’s message stored by this function. Consequently this function is most useful for changing the messages of the default error list.
Usage
do_action(‘wpice_set_messages’,$custom_error_messages);
Example
Set the four types of messages for the default error list.
$error_msgs = array(
'author' => 'Please include your name.',
'email' => 'Please include a valid email address.',
'comment'=> 'Please include a comment.',
'comment_duplicate' => 'This is a duplicate comment,
please post a new comment.'
);
do_action('wpice_set_messages',$error_msgs);
wpice_get_defined_messages
Parameters
none. Must pass empty string as second argument to apply_filters
.
Return values
(array) returns associative array listing all of the error messages defined by wpice_set_messages. Note that this function does not return the actual error messages generated after validation. Use the error information functions to get any error messages generated after the user submits the comment form.
Usage
apply_filters('wpice_get_defined_messages','');
Example
$my_messages = apply_filters('wpice_get_defined_messages','');
print_r($my_messages);