Plugin Directory

Changeset 2818558


Ignore:
Timestamp:
11/15/2022 09:09:29 PM (3 years ago)
Author:
thatdevgirl
Message:

plugin updates for v1.2

Location:
block-controller
Files:
34 added
7 edited

Legend:

Unmodified
Added
Removed
  • block-controller/trunk/block-controller.php

    r2810324 r2818558  
    44 * Plugin Name: Block Controller
    55 * Description: This WordPress plugin allows administrators to control editor access to content blocks.
    6  * Version: 1.1.3
     6 * Version: 1.2
    77 * Author: Joni Halabi
    88 * Author URI: https://jhalabi.com
  • block-controller/trunk/build/block-controller-editor.min.js

    r2482804 r2818558  
    1 !function n(t,i,c){function s(r,e){if(!i[r]){if(!t[r]){var o="function"==typeof require&&require;if(!e&&o)return o(r,!0);if(u)return u(r,!0);throw(o=new Error("Cannot find module '"+r+"'")).code="MODULE_NOT_FOUND",o}o=i[r]={exports:{}},t[r][0].call(o.exports,function(e){return s(t[r][1][e]||e)},o,o.exports,n,t,i,c)}return i[r].exports}for(var u="function"==typeof require&&require,e=0;e<c.length;e++)s(c[e]);return s}({1:[function(e,r,o){"use strict";wp.hooks.addFilter("blocks.registerBlockType","tpmBlockController",function(e,r){return disabledBlocks.includes(r)?lodash.assign({},e,{supports:{inserter:!1}}):e});document.addEventListener("DOMContentLoaded",void 0)},{}],2:[function(e,r,o){"use strict";wp.domReady(function(){disabledBlocks.includes("core/embed")||disabledBlocks.forEach(function(e){e=e.split("/");"core-embed"==e[0]&&wp.blocks.unregisterBlockVariation("core/embed",e[1])})})},{}]},{},[1,2]);
     1!function n(t,i,c){function s(r,e){if(!i[r]){if(!t[r]){var o="function"==typeof require&&require;if(!e&&o)return o(r,!0);if(u)return u(r,!0);throw(o=new Error("Cannot find module '"+r+"'")).code="MODULE_NOT_FOUND",o}o=i[r]={exports:{}},t[r][0].call(o.exports,function(e){return s(t[r][1][e]||e)},o,o.exports,n,t,i,c)}return i[r].exports}for(var u="function"==typeof require&&require,e=0;e<c.length;e++)s(c[e]);return s}({1:[function(e,r,o){"use strict";wp.hooks.addFilter("blocks.registerBlockType","tpmBlockController",function(e,r){return TPM_BC_GLOBAL.disabledBlocks.includes(r)?lodash.assign({},e,{supports:{inserter:!1}}):e});document.addEventListener("DOMContentLoaded",void 0)},{}],2:[function(e,r,o){"use strict";wp.domReady(function(){TPM_BC_GLOBAL.disabledBlocks.includes("core/embed")||TPM_BC_GLOBAL.disabledBlocks.forEach(function(e){e=e.split("/");"core-embed"==e[0]&&wp.blocks.unregisterBlockVariation("core/embed",e[1])})})},{}]},{},[1,2]);
  • block-controller/trunk/inc/assets.php

    r2482804 r2818558  
    99
    1010class Assets {
     11
     12  private const HANDLE_ADMIN = 'tpm-block-controller-admin';
     13  private const HANDLE_EDITOR = 'tpm-block-controller-editor';
     14
    1115
    1216  /**
     
    2731   */
    2832  public function set_admin_assets(): void {
    29     $handle = 'tpm-block-controller-admin';
    3033    $css = '../build/block-controller.css';
    3134    $js = '../build/block-controller-admin.min.js';
    3235
    3336    wp_enqueue_style(
    34       $handle,
     37      self::HANDLE_ADMIN,
    3538      plugins_url( $css, __FILE__ ),
    3639      [],
     
    3942
    4043    wp_enqueue_script(
    41       $handle,
     44      self::HANDLE_ADMIN,
    4245      plugins_url( $js, __FILE__ ),
    4346      [ 'wp-data', 'jquery' ],
     
    5558   */
    5659  public function set_editor_assets(): void {
    57     $handle = 'tpm-block-controller-editor';
    5860    $js = '../build/block-controller-editor.min.js';
    5961
    6062    wp_enqueue_script(
    61       $handle,
     63      self::HANDLE_EDITOR,
    6264      plugins_url( $js, __FILE__ ),
    6365      [ 'wp-hooks', 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ],
     
    6567    );
    6668
    67     // Send list of blocks to disable to the JS for it to handle.
    68     wp_localize_script( $handle, 'disabledBlocks', $this->get_disabled_blocks() );
     69    // Get global data to pass to the JS.
     70    wp_add_inline_script(
     71      self::HANDLE_EDITOR,
     72      'const TPM_BC_GLOBAL = ' . json_encode([
     73        'disabledBlocks' => $this->get_disabled_blocks()
     74      ]),
     75      'before'
     76    );
    6977  }
    7078
  • block-controller/trunk/inc/packages.php

    r2810324 r2818558  
    4646    ],
    4747
     48    'Theme' => [
     49      'core/avatar'                => 'Avatar',
     50      'core/comments'              => 'Comments',
     51      'core/loginout'              => 'Login/out',
     52      'core/navigation'            => 'Navigation',
     53      'core/page-list'             => 'Page List',
     54      'core/post-author'           => 'Post Author',
     55      'core/post-author-biography' => 'Post Author Biography',
     56      'core/post-comments-form'    => 'Post Comments Form',
     57      'core/post-content'          => 'Post Content',
     58      'core/post-date'             => 'Post Date',
     59      'core/post-excerpt'          => 'Post Excerpt',
     60      'core/post-featured-image'   => 'Post Featured Image',
     61      'core/post-navigation-link'  => 'Post Navigation Link',
     62      'core/post-terms'            => 'Post Terms',
     63      'core/post-title'            => 'Post Title',
     64      'core/query'                 => 'Query',
     65      'core/query-title'           => 'Query Title',
     66      'core/read-more'             => 'Read More',
     67      'core/site-logo'             => 'Site Logo',
     68      'core/site-tagline'          => 'Site Tag Line',
     69      'core/site-title'            => 'Site Title',
     70      'core/term-description'      => 'Term Description'
     71    ],
     72
    4873    'Widgets' => [
    4974      'core/archives'        => 'Archives',
     
    77102      'core-embed/meetup-com'    => 'Meetup.com',
    78103      'core-embed/mixcloud'      => 'Mixcloud',
     104      'core-embed/pinterest'     => 'Pinterest',
    79105      'core-embed/polldaddy'     => 'Polldaddy',
    80106      'core-embed/reddit'        => 'Reddit',
     
    94120      'core-embed/videopress'    => 'VideoPress',
    95121      'core-embed/vimeo'         => 'Vimeo',
     122      'core-embed/wolfram-cloud' => 'Wolfram',
    96123      'core-embed/wordpress'     => 'WordPress',
    97124      'core-embed/wordpress-tv'  => 'WordPress.tv',
  • block-controller/trunk/readme.txt

    r2810324 r2818558  
    66Requires PHP: 7.0
    77Tested up to: 6.1
    8 Stable tag: 1.1.3
     8Stable tag: 1.1.4
    99
    1010Turn on and off specific post editor content blocks.
     
    3636== Changelog ==
    3737
     38= 1.2 =
     39* Replacing `wp_localize_script` with `wp_add_inline_script` to pass PHP data to the JavaScript. This better adheres to WordPress standards.
     40* Adding new blocks to the list of blocks capable of being disabled. Most of them are the ones that support full-site editing.
     41
    3842= 1.1.3 =
    3943* Fixing a fatal PHP bug that was discovered in PHP 8, where the array_merge to combine all blocks across all packages into a single array fails because the keys are also passed to the array_merge function.
  • block-controller/trunk/source/js/disable-blocks.js

    r2482804 r2818558  
    1919   */
    2020  function hide( settings, name ) {
    21     if ( disabledBlocks.includes( name ) ) {
     21    if ( TPM_BC_GLOBAL.disabledBlocks.includes( name ) ) {
    2222      // Hide block by setting the inserter attribute in block supports to false.
    2323      return lodash.assign( {}, settings, {
  • block-controller/trunk/source/js/disable-embeds.js

    r2482804 r2818558  
    1414wp.domReady( () => {
    1515
    16   if ( !disabledBlocks.includes( 'core/embed' ) ) {
    17     disabledBlocks.forEach( (block) => {
     16  if ( !TPM_BC_GLOBAL.disabledBlocks.includes( 'core/embed' ) ) {
     17    TPM_BC_GLOBAL.disabledBlocks.forEach( (block) => {
    1818      const blockName = block.split('/');
    1919
Note: See TracChangeset for help on using the changeset viewer.