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:
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 inif ($id ==='query-c0d6112'&& is_user_logged_in()) { $query_args['post_type'] = array('location'); }return $query_args;},10,3);
The filter accepts three arguments:
$query_args: an associative array containing the dissected $query: an array of the query variables and their respective values.
$attributes: an associative array containing all set and unset attributes on the specific Query block
$id: a string reference to the Query block ID
Frontend Rendering: shortcode whitelist
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 oneif (is_user_logged_in()) { $array[] ='my_public_shortcode'; $array[] ='my_private_shortcode'; } else { $array[] ='my_public_shortcode'; }return $array;});
The filter accepts one argument:
$array: an empty index array
Custom Code Priority
The custom code priority constant allows you to specify the priority with which the Cwicly Custom Code snippets are loaded. This is useful in the eventuality you want to load custom snippets before/after specific items.
Simply define CC_CUSTOM_CODE_PRIORITY constant in your wp-config.php file to the desired value.
define('CC_CUSTOM_CODE_PRIORITY',5);
Remember to insert the previous definition before the famous line:
/* That's all, stop editing! Happy publishing. */
Custom Classes Column
You can add a list of custom classes to the Class Selector within its own column. The filter's main use if for plugin developers who wish to integrate their framework classes inside Cwicly without having to manually modify different database tables.
functioncwicly_plugin_classes_example( $plugin_classes ) {// Add a new entry to the $plugin_classes array with a unique key. $plugin_classes['pluginName'] =array('name'=>'Plugin Name',// Set the label.// Specify a custom color palette for the class list view// 'colors' => array(// 'list' => array(// 'light' => array(// 'background' => 'your-color',// 'color' => 'your-color',// ),// 'dark' => array(// 'background' => 'your-color',// 'color' => 'your-color',// ),// ),// ),// Define an array of CSS classes under the 'classes' key.'classes'=>array('first-class','second-class', ), );// Return the modified $plugin_classes array.return $plugin_classes;}add_filter('cwicly_plugin_classes','cwicly_plugin_classes_example',10,1);
Custom Global Colours
The custom global colour filter allows you to add a global colour custom folder containing externally defined colours. These colours will be available within the Cwicly colour picker.
functioncwicly_global_colors_primary( $global_colors ) {// Define the slug ('primary') color scheme and specify a name and colors. $global_colors['primary'] =array('name'=>'Primary','colors'=>array(array('name'=>'Primary P.','color'=>'var(--primary)', ),array('color'=>'var(--primary-alt)', ), ),'palettes'=>array(// Define palettes for the 'primary' color scheme. These will be grouped together.array('name'=>'Primary P.','colors'=>array('var(--primary-100)','var(--primary-200)','var(--primary-300)','var(--primary-400)', ), ),array('name'=>'Primary Alt','colors'=>array('var(--primary-alt-100)','var(--primary-alt-200)','var(--primary-alt-300)','var(--primary-alt-400)', ), ), ), );// Return the modified global colors array.return $global_colors;}add_filter('cwicly_global_colors','cwicly_global_colors_primary',10,1);
Nav Menu block classes position
By default, Nav Menu block classes are positionned in their relative <li> items with the current class when available. If you prefer to apply the classes to the <a> item directly, use the following snippet to modify the behaviour.
// Modify Nav Menu block classes position to 'link'add_filter('cwicly/nav/wordpress/classes_position',function ( $position ) {// Here, we are setting the $position variable. You have a choice between 'link' and 'list'. 'list' is set by default. $position ='link';// Return the modified $position variable. This value will be used by the filter.return $position; });
PHP code permission
Filter the Code block PHP permissions programatically, allowing you to globally or more precisely enable/disable PHP editing and saving in the Code block..
add_filter('cwicly/code/php',function () {// In this case, it always returns false, effectively disabling editing and saving of PHP code.returnfalse; });
JS code permission
Filter the Code block JS permissions programatically, allowing you to globally or more precisely enable/disable JS editing and saving in the Code block..
add_filter('cwicly/code/js',function () {// In this case, it always returns false, effectively disabling editing and saving of JS code.returnfalse; });
PHP code execution
Filter the Code block PHP execution permissions programatically, allowing you to globally or more precisely enable/disable PHP code execution in the Code block.
add_filter('cwicly/code/execute_eval',function () {// In this case, it always returns false, effectively disabling all Code block PHP execution.returnfalse; });
WPML original stylesheet
Do not load the original translated post stylesheet and load the current translated post stylesheet instead.
add_filter('cwicly/frontend/wpml/original_post_stylesheet',function () {returnfalse; // Disable filtering of original post stylesheet });