PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 1.5
bBlocks – Essential Gutenberg Blocks & Patterns Collection v1.5
2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 All 105 releases
b-blocks / plugin.php

plugin.php in bBlocks – Essential Gutenberg Blocks & Patterns Collection 1.5, at plugin.php

157 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: b Blocks
4 * Description: Gutenberg Blocks Collection and Page Builder.
5 * Version: 1.5
6 * Author: bPlugins LLC
7 * Author URI: http://bplugins.com
8 * License: GPLv3
9 * License URI: https://www.gnu.org/licenses/gpl-3.0.txt
10 * Text Domain: b-blocks
11 */
12
13 // ABS PATH
14 if ( !defined( 'ABSPATH' ) ) { exit; }
15
16 // Constant
17 define( 'B_BLOCKS_PLUGIN_VERSION', '1.5' );
18 define( "B_BLOCKS_ASSETS_DIR", plugin_dir_url( __FILE__ ) . 'assets/' );
19
20 // B Blocks
21 class BBlocks{
22 protected static $_instance = null;
23
24 function __construct(){
25 add_action( 'init', [$this, 'register'] );
26 add_action( 'enqueue_block_assets', [$this, 'enqueueBockAssets'] );
27 add_action( 'wp_enqueue_scripts', [$this, 'wpEnqueueScripts'] );
28 if ( version_compare( $GLOBALS['wp_version'], '5.8-alpha-1', '<' ) ) {
29 add_filter( 'block_categories', [$this, 'registerCategories'] );
30 } else { add_filter( 'block_categories_all', [$this, 'registerCategories'] ); }
31 add_action( 'after_setup_theme', [$this, 'afterSetupTheme'] );
32 }
33
34 public static function instance(){
35 if(self::$_instance === null){
36 self::$_instance = new self();
37 }
38 return self::$_instance;
39 }
40
41 // Register
42 function register(){
43 wp_register_script( 'b_blocks_editor_script', plugins_url( 'dist/editor.js', __FILE__ ), array( 'wp-blob', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-rich-text', 'swiperJS' ), B_BLOCKS_PLUGIN_VERSION, false ); // Backend Script
44
45 wp_register_style( 'b_blocks_editor_style', plugins_url( 'dist/editor.css', __FILE__ ), array( 'wp-edit-blocks' ), B_BLOCKS_PLUGIN_VERSION ); // Backend Style
46
47 wp_register_script( 'b_blocks_script', plugins_url( 'dist/script.js', __FILE__ ), array( 'jquery', 'mailtoui', 'swiperJS' ), B_BLOCKS_PLUGIN_VERSION, true ); // Frontend Script
48
49 wp_register_style( 'b_blocks_style', plugins_url( 'dist/style.css', __FILE__ ), array( 'wp-editor' ), B_BLOCKS_PLUGIN_VERSION ); // Frontend Style
50
51 wp_set_script_translations( 'b_blocks_editor_script', 'b-blocks', plugin_dir_path( __FILE__ ) . 'languages' ); // Translate
52
53 // Register Blocks
54 // b_blocks_wp_register_script( 'section' );
55 // b_blocks_wp_register_script( 'modal' );
56 // b_blocks_wp_register_script( 'tabs' );
57 // b_blocks_wp_register_script( 'accordion' );
58 // b_blocks_wp_register_script( 'note' );
59 // b_blocks_wp_register_script( 'highlight-text' );
60 // b_blocks_wp_register_script( 'progress-bar' );
61 // b_blocks_wp_register_script( 'spacer' );
62 // b_blocks_wp_register_script( 'selection' );
63 // b_blocks_wp_register_script( 'divider' );
64 // b_blocks_wp_register_script( 'to-top' );
65 }
66
67 // Register Scripts
68 static function registerScripts( $block, $options = array() ){
69 register_block_type( 'b-blocks/' . $block, array_merge(
70 array(
71 'editor_script' => 'b_blocks_editor_script',
72 'editor_style' => 'b_blocks_editor_style',
73 'script' => 'b_blocks_script',
74 'style' => 'b_blocks_style',
75 ),
76 $options
77 ) );
78 }
79
80 // Register categories
81 function registerCategories($categories){
82 return array_merge( array( array(
83 'slug' => 'bBlocks',
84 'title' => __( 'B Blocks', 'b-blocks' ),
85 )), $categories );
86 }
87
88 // Enqueue block assets
89 function enqueueBockAssets(){
90 wp_enqueue_script( 'swiperJS', B_BLOCKS_ASSETS_DIR . 'js/swiper-bundle.min.js', array(), '7.0.3', true );
91 wp_enqueue_script( 'font-awesome-kit', 'https://kit.fontawesome.com/bf44dc31ae.js', array(), B_BLOCKS_PLUGIN_VERSION, true );
92 }
93
94 // WP enqueue scripts
95 function wpEnqueueScripts() {
96 wp_enqueue_style( 'dashicon' );
97 wp_enqueue_style( 'fancybox', B_BLOCKS_ASSETS_DIR . 'css/fancybox.min.css', '', '3.5.6', 'all' );
98
99 wp_enqueue_script( 'mailtoui', B_BLOCKS_ASSETS_DIR . 'js/mailtoui-min.js', array(), B_BLOCKS_PLUGIN_VERSION, true );
100 wp_enqueue_script( 'fancybox', B_BLOCKS_ASSETS_DIR . 'js/fancybox.min.js', array( 'jquery' ), '3.5.6', true );
101 }
102
103 // After setup theme
104 function afterSetupTheme(){
105 add_theme_support( 'align-wide' );
106
107 add_image_size( 'b_blocks_large', 1200, 800, true );
108 add_image_size( 'b_blocks_medium', 525, 350, true );
109 add_image_size( 'b_blocks_square', 300, 300, true );
110 add_image_size( 'b_blocks_thumbnail', 150, 100, true );
111 }
112 }
113 BBlocks::instance();
114
115 // Generate Styles
116 class BBlocksStyleGenerator {
117 public static $styles = array();
118 public static function addStyle($selector, $styles){
119 if(array_key_exists($selector, self::$styles)){
120 self::$styles[$selector] = wp_parse_args(self::$styles[$selector], $styles);
121 }else { self::$styles[$selector] = $styles; }
122 }
123 public static function renderStyle(){
124 $output = '';
125 foreach(self::$styles as $selector => $style){
126 $new = '';
127 foreach($style as $property => $value){
128 if($value == ''){
129 $new .= $property;
130 }else {
131 $new .= " $property: $value;";
132 }
133 }
134 $output .= "$selector { $new }";
135 }
136 return $output;
137 }
138 }
139
140 // Require files
141 require_once plugin_dir_path( __FILE__ ) . 'inc/posts.php';
142 require_once plugin_dir_path( __FILE__ ) . 'inc/slider.php';
143 require_once plugin_dir_path( __FILE__ ) . 'inc/section-heading.php';
144 require_once plugin_dir_path( __FILE__ ) . 'inc/image-gallery.php';
145 require_once plugin_dir_path( __FILE__ ) . 'inc/image-comparison.php';
146 require_once plugin_dir_path( __FILE__ ) . 'inc/flip-boxes.php';
147 require_once plugin_dir_path( __FILE__ ) . 'inc/team-members.php';
148 require_once plugin_dir_path( __FILE__ ) . 'inc/price-lists.php';
149 require_once plugin_dir_path( __FILE__ ) . 'inc/feature-boxes.php';
150 require_once plugin_dir_path( __FILE__ ) . 'inc/info-box.php';
151 require_once plugin_dir_path( __FILE__ ) . 'inc/lottie-player.php';
152 require_once plugin_dir_path( __FILE__ ) . 'inc/button-group.php';
153 require_once plugin_dir_path( __FILE__ ) . 'inc/countdown.php';
154 require_once plugin_dir_path( __FILE__ ) . 'inc/cards.php';
155 require_once plugin_dir_path( __FILE__ ) . 'inc/mailto.php';
156 require_once plugin_dir_path( __FILE__ ) . 'inc/gif.php';
157 require_once plugin_dir_path( __FILE__ ) . 'inc/qr-code.php';