Skip to content

Commit

Permalink
adds more info to the README and changes the hook being used to load …
Browse files Browse the repository at this point in the history
…the blocks from init to plugins loaded
  • Loading branch information
mlaetitia committed Mar 23, 2024
1 parent 2b2e863 commit 9e62322
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
33 changes: 28 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ Your plugin *must* contain a `CHANGELOG.md` file.

Your plugin must have an entrypoint with the same name as the folder, i.e. `hello-world/hello-world.php`.

## Introduction

To work on this repository we advise the use of the following instructions. Using `git sparse-checkout` will make sure you'll only download and work on files related to a specific block.

### Sparse Checkout

The instructions will show you how to use sparse-checkout to work on a single block. You can work on extra blocks on your site by running

`git sparse-checkout add %block_name%`

If you need to remove sparse-checkout functionality altogether, you can run:

`git sparse-checkout disable`

More information here: https://git-scm.com/docs/git-sparse-checkout

## Creating a new block

You can add a new block to the monorepo by running the following steps. Make sure you're starting from the `wp-content/plugins` folder:
Expand All @@ -28,10 +44,9 @@ git push

```

From here, you can start editing your block.

From here, you can start editing your block and follow the regular process to do so.

## Editing an existing block
## Checkout and edit an existing block

**Do not forget that changing a block will auto update it on all sites that use this block. Please be careful!**

Expand All @@ -54,6 +69,14 @@ When updating a **static** block — if we add any changes to the edit or save f

## Partner Agnostic

Make sure that project-specific styles and data go into the project code and not the block in this repo
Keep in mind that blocks in this repository can be installed on multiple sites.

When you need to make any changes, make sure those changes (design and/or functionality) are applicable to any other sites and are improving upon the existing code.

Make sure that project-specific styles and data go into the project code and not the block code in this repo .

### Adding site / partner specific styles

Any partner-specific styling rules should be added via a separate stylesheet that should be registered through https://developer.wordpress.org/themes/features/block-stylesheets/#registering-a-block-stylesheet

https://developer.wordpress.org/themes/features/block-stylesheets/#registering-a-block-stylesheet
### Adding site / partner specific styles
12 changes: 6 additions & 6 deletions special-projects-blocks-monorepo.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Dynamic Table of Contents
* Description: Creates a table of contents that's dynamically (PHP) rendered.
* Plugin Name: Special Projects Blocks Monorepo
* Description: Aggregates the blocks we have created.
* Requires at least: 6.1
* Requires PHP: 8.0
* Version: 0.3
Expand All @@ -10,7 +10,7 @@
* Update URI: https://github.com/a8cteam51/special-projects-blocks-monorepo/
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: dynamic-table-of-contents
* Text Domain: wpsp-blocks
*
* @package wpsp
*/
Expand All @@ -22,14 +22,14 @@
*
* Example: /dynamic-table-of-contents/dynamic-table-of-contents.php
*/
function load_add_downloaded_blocks(){
function load_add_downloaded_blocks() {
$dirs = glob( dirname( __FILE__ ) . '/*', GLOB_ONLYDIR );

foreach ( $dirs as $dir ) {
if ( file_exists( $dir . DIRECTORY_SEPARATOR . basename( $dir ) . '.php' ) ) {
require $dir . DIRECTORY_SEPARATOR . basename( $dir ) . '.php';
include $dir . DIRECTORY_SEPARATOR . basename( $dir ) . '.php';
}
}
}

add_action( 'init', 'load_add_downloaded_blocks' );
add_action( 'plugins_loaded', 'load_add_downloaded_blocks' );

0 comments on commit 9e62322

Please sign in to comment.