-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgc-blocks.php
77 lines (64 loc) · 2.27 KB
/
gc-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
<?php
/**
* Plugin Name: GC Blocks
* Plugin URI: https://georgechond.com/
* Description: This plugin adds functionality for new custom blocks.
* Version: 1.0.6
* Requires at least: 5.2
* Requires PHP: 7.4
* Author: George Chond
* Author URI: https://georgechond.com/
*/
defined('ABSPATH') || exit; // Exit if accessed directly
define('GC_BLOCKS', plugin_dir_path( __FILE__ ));
// Check if ACF Classes exists
if (!class_exists('acf_pro') || !class_exists('acf')){
// Define path and URL to the ACF plugin.
define( 'MY_ACF_PATH', plugin_dir_path( __FILE__ ) . 'includes/acf/' );
define( 'MY_ACF_URL', plugin_dir_url( __FILE__ ) . 'includes/acf/' );
// Include the ACF plugin.
include_once( MY_ACF_PATH . 'acf.php' );
// Customize the url setting to fix incorrect asset URLs.
add_filter('acf/settings/url', 'set_acf_url');
function set_acf_url($url) {
return MY_ACF_URL;
}
// Hide the ACF admin menu item.
add_filter('acf/settings/show_admin', 'show_acf_admin');
function show_acf_admin($show_admin) {
return false;
}
}
// Save JSON to folder
function set_acf_json_save_folder($path){
$path = GC_BLOCKS . 'includes/json/';
return $path;
}
add_filter('acf/settings/save_json', 'set_acf_json_save_folder');
// Load JSON from folder
function add_acf_json_load_folder($paths){
// Remove original path
unset($paths[0]);
// Set new path
$paths[] = GC_BLOCKS . 'includes/json';
return $paths;
}
add_filter('acf/settings/load_json', 'add_acf_json_load_folder');
// Core Functions
include( GC_BLOCKS . 'includes/core/gcb_enqueue_block_editor_assets.php');
include( GC_BLOCKS . 'includes/core/gcb_json_sync.php');
include( GC_BLOCKS . 'includes/core/gcb_styles.php');
// Register New Block Category
include( GC_BLOCKS . 'includes/core/gcb_block_category.php');
// Register Blocks, JS and CSS
include( GC_BLOCKS . 'includes/gcb_register_blocks.php');
include( GC_BLOCKS . 'includes/gcb_register_scripts.php');
// Auto-Update from Git Repo
require( GC_BLOCKS . 'includes/plugin-update-checker/plugin-update-checker.php');
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
'https://github.com/gestok/gc-blocks',
__FILE__,
'gc-blocks'
);
//Set the branch that contains the stable release.
$myUpdateChecker->setBranch('main');