Filters
A normaliser makes different browsers render a website's CSS consistently, by providing a standard set of CSS rules that are compatible with all browsers. This ensures that the layout and styling of a website looks the same across different browsers and devices, by resetting and normalising the default styles applied by the browser.
If you want to provide your own normaliser for the frontend, use the following snippet:
add_filter('cc_normaliser_frontend', function ($arguments) {
$normaliser_frontend = wp_upload_dir()['baseurl'] . '/custom/normaliser.css';
return $normaliser_frontend;
});
If you want to provide your own normaliser for the editor, use the following snippet:
add_filter('cc_normaliser_editor', function ($arguments) {
$normaliser_editor = wp_upload_dir()['basedir'] . '/custom/normaliser-editor.css';
return $normaliser_editor;
});
The query args filter allows you to modify the query arguments before they are processed in the Query block.
add_filter( 'cwicly/query/args', function( $query_args, $attributes, $id ) {
// Change the post_type to location if the user is logged in
if ($id === 'query-c0d6112' && is_user_logged_in()) {
$query_args['post_type'] = array('location');
}
return $query_args;
}, 10, 3 );
The filter accepts three arguments:
- 1.
$query_args
: an associative array containing the dissected$query
: an array of the query variables and their respective values. - 2.
$attributes
: an associative array containing all set and unset attributes on the specific Query block - 3.
$id
: a string reference to the Query block ID
The shortcode whitelist filter allows you to specify the shortcodes that you consider safe to run when using Frontend Rendering with Cwicly blocks.
add_filter('cwicly/frontend/shortcodes_whitelist', function ($array) {
// Add two shortcodes to the list if the user is logged in, otherwise just one
if (is_user_logged_in()) {
$array[] = 'my_public_shortcode';
$array[] = 'my_private_shortcode';
} else {
$array[] = 'my_public_shortcode';
}
return $array;
});
The filter accepts one argument:
- 1.
$array
: an empty index array
Last modified 1mo ago