Coder Social home page Coder Social logo

tammohaannl / block-slider-carousel Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thewebsolver/tws-block-slider-carousel

0.0 0.0 0.0 1.01 MB

Convert WordPress blocks into Slider Carousel using swiper-js

License: GNU General Public License v3.0

JavaScript 91.20% PHP 7.28% CSS 1.52%

block-slider-carousel's Introduction

Logo

TWS Block Slider Carousel

CONVERT WORDPRESS GUTENBERG BLOCKS INTO SLIDER CAROUSEL

Convert eligible WordPress blocks into slider carousel as a swiper instance. Eligible blocks means:

  • Block that can have inner blocks (such as Group block core/group) which has parent child DOM Element. For example, in Group block:
    • Parent is the outer <div> element with class wp-block-group, and
    • Child is the inner <div> element with class wp-block-group__inner-container.

Installation (via Composer):

To install this plugin, edit your composer.json file:

"require": {
	"thewebsolver/tws-block-slider-carousel": "dev-master"
}

Then from terminal, run:

$ composer install

Usage

Add support for custom blocks

If you want to convert any other block to slider carousel which implements similar parent/child DOM Element as core Group block, you can add them with the filter hook.

<?php // Filename: functions.php

/**
 * Make custom block eligible for converting to slider carousel.
 *
 * @param string[] $blocks The eligible blocks to convert to slider carousel.
 * @return string[] The modified eligible block names.
 */
function add_eligible_block_for_slider( array $blocks ): array {
	$blocks[] = 'namespace/custom-block';

	return $blocks;
}
add_filter( 'hzfex_eligible_slider_carousel_blocks', 'add_eligible_block_for_slider' );

/**
 * Make above block converted to slider on frontend.
 *
 * @param string[] $elements The custom block's outer & inner container classnames.
 * @return string[] The modified block element classes.
 */
function convert_block_to_slider( array $elements ): array {
	$elements[] = array(
		'parent'  => 'parent-block-classname',
		'child'   => 'parent-block-inner-container-classname'
	);

	return $elements;
}
add_filter( 'hzfex_slider_carousel_container_element', 'convert_block_to_slider' );

Inside Block Editor Inspector

Once eligible blocks are set, slider carousel can be enabled and options can be configured right from the inspector control panel.

Filter Hooks

All PHP codes (including filters) are in the main plugin file tws-block-slider-carousel.php.

Filter Name Parameters Type
hzfex_eligible_slider_carousel_blocks $blocks string[]
hzfex_slider_carousel_container_element $elements string[]
hzfex_slider_carousel_navigation_arrows $buttons string[]
hzfex_slider_carousel_bullet_content $contents string[]

Screenshots

Core Options

core

General Options

general

Bullet Options

bullet

Responsive Options

breakpoint

Support

-----------------------------------
 * DEVELOPED-MAINTAINED-SUPPPORTED BY
 * -----------------------------------
 * ███║     ███╗   ████████████████
 * ███║     ███║   ═════════██████╗
 * ███║     ███║        ╔══█████═╝
 *  ████████████║      ╚═█████
 * ███║═════███║      █████╗
 * ███║     ███║    █████═╝
 * ███║     ███║   ████████████████╗
 * ╚═╝      ╚═╝    ═══════════════╝

block-slider-carousel's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.