Skip to content

Commit

Permalink
added example for PHP filters
Browse files Browse the repository at this point in the history
  • Loading branch information
gaambo committed Oct 29, 2024
1 parent ed5889d commit 4374f84
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
24 changes: 24 additions & 0 deletions examples/filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

/**
* Set swiper options on a per-block instance basis
* based on a custom className
*/
add_filter('good-slider/swiper-options', function ($swiperOptions, $blockAttributes) {
if (!empty($blockAttributes['className']) && str_contains($blockAttributes['className'], 'is-style-news-slider')) {
return [
'slidesPerView' => 1,
'spaceBetween' => 20,
'pagination' => true,
'navigation' => false,
'createElements' => true,
'loop' => true,
'breakpoints' => [
'1024' => [
'pagination' => false,
]
]
];
}
return $swiperOptions;
}, 10, 2);
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ We recommend installing the plugin extension through the WordPress Backend.
The UI currently allows for enabling/disabling navigation and pagination and the desktops default number of slides per view.

You can use the `good-slider/swiper-options` filter hook to set the swiper configuration for a specific block instance.
Have a look at the [examples on GitHub](https://github.com/goodwp/good-slider/tree/main/examples/filters.php).

All the available arguments are documented in the [Swiper v8 documentation](https://v8.swiperjs.com/swiper-api).

= Can I use my own enqueued Swiper script? =
Expand Down

0 comments on commit 4374f84

Please sign in to comment.