PluginProbe ʕ •ᴥ•ʔ
Smart Custom 404 Error Page / trunk
Smart Custom 404 Error Page vtrunk
trunk 11.4.6 11.4.7 11.4.8
404page / block.php
404page Last commit date
assets 1 year ago inc 1 year ago 404page.php 1 year ago block.json 3 years ago block.php 1 year ago functions.php 1 year ago index.php 8 years ago loader.php 1 year ago readme.txt 1 month ago shortcodes.php 1 year ago uninstall.php 1 year ago
block.php
40 lines
1 <?php
2
3 /**
4 * The 404page Plugin Block
5 *
6 * @since 11.4.0
7 *
8 **/
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13
14 add_action( 'init', function() {
15
16 if ( function_exists('register_block_type_from_metadata' ) ) {
17
18 register_block_type_from_metadata( __DIR__, [
19 'render_callback' => function( $atts ) {
20 $alignmentClass = ( $atts['alignment'] != null ) ? 'has-text-align-' . $atts['alignment'] : '';
21 return '<p ' . get_block_wrapper_attributes( [ 'class' => $alignmentClass ] ) . '>' . pp_404_get_the_url( $atts[ 'urltype' ] ) . '</p>';
22 }
23 ] );
24
25 }
26
27 } );
28
29
30 // Moved from init to enqueue_block_editor_assets in 11.4.1
31 add_action( 'enqueue_block_editor_assets', function() {
32
33 wp_enqueue_script(
34 '404page-block',
35 pp_404page()->get_asset_url( 'js', 'block.js' ),
36 [ 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ],
37 pp_404page()->get_plugin_version()
38 );
39
40 } );