Last active
June 6, 2024 08:54
-
-
Save baldawayash15/05950dbb6a73fae04e8f81ed2684be77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Placeholder Classes | |
if ( ! class_exists( 'Placeholder_Block' ) ) { | |
class Placeholder_Block { | |
public $name; | |
function __construct( $name ) { | |
$this->name = $name; | |
add_action( 'init', array( $this, 'onInit' ) ); | |
} | |
function ourRenderCallback( $attributes, $content ) { | |
ob_start(); | |
require get_theme_file_path( "/blocks/{$this->name}.php" ); | |
return ob_get_clean(); | |
} | |
function onInit() { | |
wp_register_script( $this->name, get_stylesheet_directory_uri() . "/blocks/{$this->name}.js", array( 'wp-blocks', 'wp-editor' ) ); | |
register_block_type( "blocktheme/{$this->name}", array( | |
'editor_script' => $this->name, | |
'render_callback' => array( $this, 'ourRenderCallback' ) | |
) ); | |
} | |
} | |
} | |
new Placeholder_Block( 'header' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include ( get_theme_file_path( '/includes/class-placeholder-block.php' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wp.blocks.registerBlockType("gtrpsblocktheme/header", { | |
title: "Global Trade Review Header", | |
edit: function () { | |
return wp.element.createElement( | |
"div", | |
{ className: "gtr-placeholder-block" }, | |
"Global Trade Review Header Placeholder" | |
); | |
}, | |
save: function () { | |
return null; | |
}, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Header code goes here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment