-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwp-block-cards.php
More file actions
48 lines (36 loc) · 1.4 KB
/
wp-block-cards.php
File metadata and controls
48 lines (36 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* Plugin Name: Cards Block
* Description: Grid or carousel with card blocks which have an image, title, description and link.
* Requires at least: 5.8
* Requires PHP: 7.1
* Version: 1.3.4
* Author: SMFB Dinamo
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wpd-blocks
*
* @package wpd
*/
function wpd_block_cards_block_init() {
register_block_type( __DIR__ . '/blocks/container' );
}
add_action( 'init', 'wpd_block_cards_block_init' );
function wpd_block_card_block_init() {
register_block_type( __DIR__ . '/blocks/card' );
}
add_action( 'init', 'wpd_block_card_block_init' );
function wpd_block_card_get_image_size() : array {
return apply_filters( 'wpd_block_card_image_size', [ 1240, 1240, false ] );
}
function wpd_block_card_image_size() {
list( $width, $height, $crop ) = wpd_block_card_get_image_size();
add_image_size( 'wpd-block-card', $width, $height, $crop );
}
add_action( 'after_setup_theme', 'wpd_block_card_image_size' );
function wpd_block_card_image_size_choose( array $size_names ) : array {
list( $width, $height ) = wpd_block_card_get_image_size();
$size_names['wpd-block-card'] = sprintf( __( 'Card (%sx%s)', 'wpd-blocks' ), $width, $height );
return $size_names;
}
add_filter( 'image_size_names_choose', 'wpd_block_card_image_size_choose' );