-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.php
42 lines (34 loc) · 1.08 KB
/
plugin.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
<?php
/*
* Plugin Name: Rockpool Blocks
* Plugin URI: https://smallwins.co.uk
* Description: Custom Gutenberg editor blocks for Rockpool. Good for creating drag-and-drop landing pages.
* Author: Joshua Hackett
* Author URI: https://smallwins.co.uk
* Version: 1.0.0
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Block Initializer.
*/
require_once plugin_dir_path( __FILE__ ) . 'src/init.php';
ob_start();
add_action('shutdown', function() {
$final = '';
// We'll need to get the number of ob levels we're in, so that we can iterate over each, collecting
// that buffer's output into the final output.
$levels = ob_get_level();
for ($i = 0; $i < $levels; $i++) {
$final .= ob_get_clean();
}
// Apply any filters to the final output
echo apply_filters('final_output', $final);
}, 0);
add_filter('final_output', function($output) {
$output = preg_replace('/<div class="container">\s*<\/div>/', '', $output);
$output = preg_replace('/<div class="container"><p>\s*<\/p><\/div>/', '', $output);
return $output;
});