You can use filter dlxplugins/ajaxify/comments/options/pre_output to filter the options returned by the plugin.
The filter accepts 3 arguments:
$options: (array) Optioons array containing the labels.
$post_id: (int) Post ID of the comment being posted to.
$post_type: (string) Post type of the comment being posted to.
Here is an example of changing the labels for WooCommerce reviews:
<?php/** * This snippet demonstrates changing the labels for the WooCommerce product reviews. */add_action('plugins_loaded','dlx_my_ajaxify_plugins_loaded');/** * Run when the plugin is loaded. */functiondlx_my_ajaxify_plugins_loaded() {add_filter('dlxplugins/ajaxify/comments/options/pre_output','dlx_ajaxify_comments_options',10,3);}/** * Modify options before they are output. * * @paramarray $options The options to output. * @paramint $post_id The post ID the options are being output to. * @paramstring $post_type The post type the options are being output to. */functiondlx_ajaxify_comments_options( $options, $post_id, $post_type ) {// Check if WooCommerce product, and change a few strings.if ( 'product'=== $post_type ) {// Change the text for the reviews and messages. $options['textPosted'] =__('Your review has been posted. Thank you!','plugin-domain'); $options['textPostedUnapproved'] =__('Your review has been posted and is awaiting moderation. Thank you!','plugin-domain'); $options['textReloadPage'] =__('Reloading page. Please wait.','plugin-domain'); $options['textPostComment'] =__('Posting your review. Please wait.','plugin-domain'); $options['textRefreshComments'] =__('Loading reviews. Please wait.','plugin-domain'); $options['textUnknownError'] =__('Something went wrong, your review has not been posted.','plugin-domain'); $options['textErrorTypeComment'] =__('Please type your review text.','plugin-domain'); $options['textErrorCommentsClosed'] =__('Sorry, reviews are closed for this item.','plugin-domain'); $options['textErrorMustBeLoggedIn'] =__('Sorry, you must be logged in to post a review.','plugin-domain'); $options['textErrorFillRequiredFields'] =__('Please fill the required fields (name, email).','plugin-domain'); $options['textErrorInvalidEmailAddress'] =__('Please enter a valid email address.','plugin-domain'); $options['textErrorPostTooQuickly'] =__('You are posting reviews too quickly. Please wait a minute and resubmit your review.','plugin-domain'); $options['textErrorDuplicateComment'] =__('Duplicate review detected. It looks like you have already submitted this review.','plugin-domain'); }return $options;}
Actions and Filters
Action: Execute code before Ajaxify starts loading in
Action definition:
/** * Fires before the main WPAC actions/filters. Useful for hooking in early. */do_action('dlxplugins/ajaxify/comments/wp');
Action: Execute code after Ajaxify enqueues its scripts
Action definition:
/** * Do action after scripts are enqueued. */do_action('dlxplugins/ajaxify/comments/enqueue_scripts', $version, $in_footer );
This action is executed after all of Ajaxify Comments' scripts have been enqueued. This is useful to run custom scripts after Ajaxify Comments.
Filter: Force Ajaxify Comments to load
Regardless if Ajaxify Comments is disabled, you can pass true to force load the scripts and functionality needed to take over the comment section. This can still be overruled by the dlxplugins/ajaxify/comments/can_load filter.
Filter definition:
/** * Filter whether to load the plugin's scripts. * * @parambool $can_force_script_override Whether to load the plugin's scripts. Pass `true` to force scripts to load. */$can_force_script_override =apply_filters('dlxplugins/ajaxify/comments/force_load',false);
Filter: Block Ajaxify Comments from loading
Prevent any loading of Ajaxify Comments scripts or functionality regarding the comment section.
Filter definition:
/** * Filter whether to load the plugin's scripts. * * @since 2.0.0 * * @parambool $can_load Whether to load the plugin's scripts. Pass `false` to prevent scripts from loading. */$can_load =apply_filters('dlxplugins/ajaxify/comments/can_load',true);if ( ! $can_load ) {return;}
Filter: Prevent Activation Redirect
This next filter, if false is returned, will not redirect the plugin to the plugin's settings screen after activation.
Filter definition:
/** * Filter whether to redirect on plugin activation. * * @parambool $can_redirect Whether to redirect on plugin activation. Pass `false` to prevent redirect. */$can_redirect =apply_filters('dlxplugins/ajaxify/comments/activation/can_redirect',true);
Filter: Return a Custom Color Palette in the Admin
Ajaxify Comments allows changing the alert and text colors in the Appearance settings of the admin.
When selecting colors, Ajaxify attempts to get the theme's colors. You can return custom colors by hooking into this next filter.
Filter definition:
/** * Filter the color palette. * * @paramarray $color_palette Color palette { * @type string $name Primary color name. * @type string $slug Primary color slug. * @type string $color Primary color hex or var. * } */returnapply_filters('ajaxify/comments/theme_color_palette', $color_palette );
Filter: Filter the options before they are output as JSON
Filter the options before they are output via JSON as settings. This can be used to manipulate labels or settings per post and post type.
Filter definition:
/** * Filter the options before they are output. * This is useful for adding custom options or modifying labels. * * @paramarray $options The options to be output. * @paramint $post_id The post ID. * @paramstring $post_type The post type. */$options =apply_filters('dlxplugins/ajaxify/comments/options/pre_output', $options, get_the_ID(), get_post_type( get_the_ID()));