-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblock-styles-manager.php
82 lines (73 loc) · 2.04 KB
/
block-styles-manager.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
<?php
/**
* Plugin Name: Block Style Manager by Pixelgrade
* 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: 0.0.1
* Author: Pixelgrade
* Author URI: https://www.pixelgrade.com
* Text Domain: __plugin_txtd
* Tested up to: 5.2
*
* 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/>.
*
*/
/**
* Gets this plugin's absolute directory path.
*
* @since 2.1.0
* @ignore
* @access private
*
* @return string
*/
function _get_plugin_directory() {
return __DIR__;
}
/**
* Gets this plugin's URL.
*
* @since 2.1.0
* @ignore
* @access private
*
* @return string
*/
function _get_plugin_url() {
static $plugin_url;
if ( empty( $plugin_url ) ) {
$plugin_url = plugins_url( null, __FILE__ );
}
return $plugin_url;
}
include __DIR__ . '/lib/enqueue-scripts.php';
function get_block_styles() {
$styles = get_option( 'block-styles', '' );
return $styles;
}
function update_block_styles( $request ) {
$styles = $request->get_param( 'styles' );
update_option( 'block-styles', $styles );
return $styles;
}
function block_styles_endpoints() {
add_action( 'rest_api_init', function () {
register_rest_route( 'block-styles/v1','/styles', array(
'methods' => 'GET',
'callback' => 'get_block_styles',
) );
} );
add_action( 'rest_api_init', function () {
register_rest_route( 'block-styles/v1','/styles', array(
'methods' => 'POST',
'callback' => 'update_block_styles',
) );
} );
}
add_action( 'init', 'block_styles_endpoints' );