forked from studiopress/atomic-blocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
loader.php
124 lines (104 loc) · 3.71 KB
/
loader.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
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
* Bootstraps the Atomic Blocks plugin.
*
* @package AtomicBlocks
*/
/**
* Initialize the blocks
*/
function atomic_blocks_loader() {
$atomic_blocks_includes_dir = plugin_dir_path( __FILE__ ) . 'includes/';
$atomic_blocks_src_dir = plugin_dir_path( __FILE__ ) . 'src/';
$atomic_blocks_dist_dir = plugin_dir_path( __FILE__ ) . 'dist/';
/**
* Load the blocks functionality
*/
require_once plugin_dir_path( __FILE__ ) . 'dist/init.php';
/**
* Load Getting Started page
*/
require_once plugin_dir_path( __FILE__ ) . 'dist/getting-started/getting-started.php';
/**
* Load Container Block PHP
*/
require_once plugin_dir_path( __FILE__ ) . 'src/blocks/block-container/index.php';
/**
* Load Social Block PHP
*/
require_once plugin_dir_path( __FILE__ ) . 'src/blocks/block-sharing/index.php';
/**
* Load Post Grid PHP
*/
require_once plugin_dir_path( __FILE__ ) . 'src/blocks/block-post-grid/index.php';
/**
* Load the newsletter block and related dependencies.
*/
if ( PHP_VERSION_ID >= 50600 ) {
if ( ! class_exists( '\DrewM\MailChimp\MailChimp' ) ) {
require_once $atomic_blocks_includes_dir . 'libraries/drewm/mailchimp-api/MailChimp.php';
}
require_once $atomic_blocks_includes_dir . 'exceptions/class-api-error-exception.php';
require_once $atomic_blocks_includes_dir . 'exceptions/class-mailchimp-api-error-exception.php';
require_once $atomic_blocks_includes_dir . 'interfaces/newsletter-provider-interface.php';
require_once $atomic_blocks_includes_dir . 'classes/class-mailchimp.php';
require_once $atomic_blocks_includes_dir . 'newsletter/newsletter-functions.php';
require_once $atomic_blocks_src_dir . 'blocks/block-newsletter/index.php';
}
/**
* Layout Component Registry.
*/
if ( PHP_VERSION_ID >= 50600 ) {
require_once $atomic_blocks_includes_dir . 'layout/layout-functions.php';
require_once $atomic_blocks_includes_dir . 'layout/class-component-registry.php';
require_once $atomic_blocks_includes_dir . 'layout/register-layout-components.php';
/**
* REST API Endpoints for Layouts.
*/
require_once $atomic_blocks_includes_dir . 'layout/layout-endpoints.php';
}
/**
* Compatibility functionality.
*/
require_once $atomic_blocks_includes_dir . 'compat.php';
}
add_action( 'plugins_loaded', 'atomic_blocks_loader' );
/**
* Load the plugin textdomain
*/
function atomic_blocks_init() {
load_plugin_textdomain( 'atomic-blocks', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'init', 'atomic_blocks_init' );
/**
* Adds a redirect option during plugin activation on non-multisite installs.
*
* @param bool $network_wide Whether or not the plugin is being network activated.
*/
function atomic_blocks_activate( $network_wide = false ) {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Only used to do a redirect. False positive.
if ( ! $network_wide && ! isset( $_GET['activate-multi'] ) ) {
add_option( 'atomic_blocks_do_activation_redirect', true );
}
}
register_activation_hook( __FILE__, 'atomic_blocks_activate' );
/**
* Redirect to the Atomic Blocks Getting Started page on single plugin activation.
*/
function atomic_blocks_redirect() {
if ( get_option( 'atomic_blocks_do_activation_redirect', false ) ) {
delete_option( 'atomic_blocks_do_activation_redirect' );
wp_safe_redirect( esc_url( admin_url( 'admin.php?page=atomic-blocks' ) ) );
exit;
}
}
add_action( 'admin_init', 'atomic_blocks_redirect' );
/**
* Add image sizes
*/
function atomic_blocks_image_sizes() {
// Post Grid Block.
add_image_size( 'ab-block-post-grid-landscape', 600, 400, true );
add_image_size( 'ab-block-post-grid-square', 600, 600, true );
}
add_action( 'after_setup_theme', 'atomic_blocks_image_sizes' );