-
Notifications
You must be signed in to change notification settings - Fork 4
/
nova-blocks.php
113 lines (97 loc) · 3.36 KB
/
nova-blocks.php
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/**
* Plugin Name: Nova Blocks
* Plugin URI: https://github.com/pixelgrade/nova-blocks/
* Description: Nova Blocks is a collection of <strong>distinctive Gutenberg blocks</strong>, committed to making your site shine like a newborn star. It is taking a design-driven approach to help you made the right decisions and showcase your content in the best shape.
* Version: 1.1.5
* Author: Pixelgrade
* Author URI: https://www.pixelgrade.com
* Text Domain: __plugin_txtd
* Tested up to: 5.3.0
* Requires PHP: 5.4.0
* License: GPLv2 or later
*
* Nova Blocks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* You should have received a copy of the GNU General Public License
* along with Nova Blocks. If not, see <http://www.gnu.org/licenses/gpl-2.0.html>.
*/
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function novablocks_plugin_setup() {
// Set up a constant that will tell the rest of the plugin whether to use post meta attributes or not.
// This is needed since Gutenberg 6.6.0 introduced an issue with them causing a crash in the editor.
if ( ! defined( 'NOVABLOCKS_USE_POST_META_ATTRIBUTES' ) ) {
if ( defined( 'GUTENBERG_VERSION' ) && version_compare( GUTENBERG_VERSION, '6.6.0', '>=' ) ) {
define( 'NOVABLOCKS_USE_POST_META_ATTRIBUTES', false );
} else {
define( 'NOVABLOCKS_USE_POST_META_ATTRIBUTES', true );
}
}
}
// We will do this just after themes so we give them a chance to intervene.
add_action( 'after_setup_theme', 'novablocks_plugin_setup', 20 );
/**
* Gets this plugin's directory file path.
*
* @since 1.0.0
* @ignore
* @access private
*
* @return string
*/
function novablocks_get_plugin_path() {
static $novablocks_plugin_path;
if ( empty( $novablocks_plugin_path ) ) {
$novablocks_plugin_path = plugin_dir_path( __FILE__ );
}
return $novablocks_plugin_path;
}
/**
* Gets this plugin's URL.
*
* @since 1.0.0
* @ignore
* @access private
*
* @return string
*/
function novablocks_get_plugin_url() {
static $novablocks_plugin_url;
if ( empty( $novablocks_plugin_url ) ) {
$novablocks_plugin_url = plugins_url( null, __FILE__ );
}
return $novablocks_plugin_url;
}
function novablocks_body_class( $classes ) {
$position_indicators = get_post_meta( get_the_ID(), 'novablocks_hero_position_indicators', true );
if ( ! empty( $position_indicators ) || ( defined( 'NOVABLOCKS_USE_POST_META_ATTRIBUTES' ) && ! NOVABLOCKS_USE_POST_META_ATTRIBUTES ) ) {
$classes[] = 'novablocks-has-position-indicators';
}
return $classes;
}
add_filter( 'body_class', 'novablocks_body_class' );
function novablocks_add_blocks_category( $categories, $post ) {
return array_merge(
array(
array(
'slug' => 'nova-blocks',
'title' => 'Nova Blocks', // do not translate
),
),
$categories
);
}
add_filter( 'block_categories', 'novablocks_add_blocks_category', 10, 2 );
require_once dirname( __FILE__ ) . '/lib/extras.php';
require_once dirname( __FILE__ ) . '/lib/settings.php';
require_once dirname( __FILE__ ) . '/lib/enqueue-scripts.php';
// register block types
require_once dirname( __FILE__ ) . '/src/blocks/init.php';
// load block areas functionality
require_once dirname( __FILE__ ) . '/lib/block-areas/block-areas.php';