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