Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add global header block #9

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions blocks/global-header/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Global Header

## Register as a block (for Full Site Editing themes)

Add as a composer dependency, install, then

```php
add_action( 'muplugins_loaded', function() {
require_once REPO_TOOLS_DIR . '/block.php';
} );
```


## Include directly in PHP (for classic themes)

Add as a composer dependency, install, then

require_once 'vendor/wporg-repo-tools/blocks/global-header/header.php';


## Embed as an iframe (for Trac, Codex, etc)

21 changes: 21 additions & 0 deletions blocks/global-header/block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace WordPress_org\Repo_Tools\Global_Header;

defined( 'WPINC' ) || die();

add_action( 'init', __NAMESPACE__ . '\register_assets', 9 );

function register_assets() {
register_block_type(
'wordpress-org/global-header',
array( 'render_callback' => __NAMESPACE__ . '\render_global_header' )
);
}

function render_global_header( $attributes ) {
ob_start();
require_once __DIR__ . '/header.php';
return ob_get_clean();
}

2 changes: 2 additions & 0 deletions blocks/global-header/header.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
echo 'this is the global header :)';