Skip to content

Commit

Permalink
New Role Capability
Browse files Browse the repository at this point in the history
Fixes #3
  • Loading branch information
kjroelke committed Aug 2, 2024
1 parent 24c0141 commit cbafa28
Show file tree
Hide file tree
Showing 4 changed files with 595 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@

A custom child theme of [Pro Theme by Themeco](https://theme.co/pro).

## Getting Started (Developers)

- Take a look at the `src` folder for all front-end styles/code.
- Take a look inside the `includes` folder for all PHP related code.

If you're looking to make changes and you're not a developer with Kingdom One, `style.css` and `functions.php` will behave as normal. Edit at your own risk!

- See further documentation of Pro Theme at https://theme.co/docs.
- See codebase of this child theme at https://github.com/kingdom-one/faith-based-expeditions

# Changelog

## 0.3.0

- Updated roles to allow only administrators to edit locked blocks.
- Added `patterns` directory with first `egypt` tour pattern.

## 0.2.0

- Implemented the Join a Tour redirect with Javascript.
Expand Down
24 changes: 24 additions & 0 deletions includes/class-theme-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public function __construct() {
$this->asset_handler = new Asset_Handler( true );
add_action( 'wp_enqueue_scripts', array( $this->asset_handler, 'enqueue_assets' ) );
add_action( 'wp_enqueue_scripts', array( $this->asset_handler, 'dequeue_scripts' ), 40 );
add_filter(
'block_editor_settings_all',
array( $this, 'hide_block_locking_ui' ),
10,
2
);
}

/**
Expand Down Expand Up @@ -54,4 +60,22 @@ private function load_required_files() {
}
}
}

/**
* Hides the Block Lock settings for non-admin users on Tour post type.
*
* @param array $settings Default editor settings.
* @param \WP_Block_Editor_Context $context the block context object.
*
* @return array
*/
public function hide_block_locking_ui( $settings, $context ): array {
$is_tour = $context->post && 'tour' === get_post_type( $context->post->ID );
$is_admin = current_user_can( 'edit_files' );
if ( $is_tour && ! $is_admin ) {
$settings['canLockBlocks'] = false;
$settings['codeEditingEnabled'] = false;
}
return $settings;
}
}
Loading

0 comments on commit cbafa28

Please sign in to comment.