Created
          August 25, 2022 18:50 
        
      - 
      
 - 
        
Save mwhiteley16/35be7c6a2dd124b6369a0eac9497f7fb to your computer and use it in GitHub Desktop.  
    block.json testing
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | (function($){ | |
| var initializeBlock = function( $block ) { | |
| $('.block-faq__toggle-question').click(function() { | |
| $(this).children('.block-faq__toggle-question-icons').attr('aria-selected', function (i, attr) { | |
| return attr == 'true' ? 'false' : 'true' | |
| }); | |
| $(this).children('.block-faq__toggle-question-icons').attr('aria-expanded', function (i, attr) { | |
| return attr == 'true' ? 'false' : 'true' | |
| }); | |
| $(this).siblings('.block-faq__toggle-answer').slideToggle().attr('aria-expanded', function (i, attr) { | |
| return attr == 'true' ? 'false' : 'true' | |
| }); | |
| }); | |
| } | |
| // Initialize each block on page load (front end). | |
| $(document).ready(function(){ | |
| $('.block-faq').each(function(){ | |
| initializeBlock( $(this) ); | |
| return false; // stop after first run to ensure it works if multiple instances are on page | |
| }); | |
| }); | |
| if( window.acf ) { | |
| window.acf.addAction( 'render_block_preview/type=acf-faq', initializeBlock ); | |
| } | |
| })(jQuery); | 
  
    
      This file contains hidden or 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
    
  
  
    
  | { | |
| "name": "wd/acf-faq", | |
| "title": "FAQ Block", | |
| "description": "A block to show FAQ items with an optional toggle.", | |
| "category": "wd-blocks", | |
| "icon": "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22.5 22.5'><defs><style>.a{fill:#222;}.b{fill:#1fa8af;}</style></defs><path class='a' d='M20.17,4a10.17,10.17,0,0,0-7-3.5L11.91.38h-.18a.64.64,0,0,0-.47.13A.68.68,0,0,0,11,.93L10.6,3.79a.48.48,0,0,0,.12.43.54.54,0,0,0,.44.18h.11l1.44.17c3.94.45,6.12,2.69,5.84,6a8.37,8.37,0,0,1-2.49,5.12A8.14,8.14,0,0,1,10,18.06l-.65,0H9.15a.8.8,0,0,0-.5.17.68.68,0,0,0-.25.44L8,21.5a.49.49,0,0,0,.12.42.57.57,0,0,0,.45.18h.17l1,0h.34a11.61,11.61,0,0,0,8.21-3.39,12.76,12.76,0,0,0,3.77-7.92A9.49,9.49,0,0,0,20.17,4Z'/><path class='b' d='M9.2,17h.15L10,17a7.61,7.61,0,0,0,3.64-.77L15,6.15a8.65,8.65,0,0,0-2.33-.57l-1-.12-1,7.35L9.23,7c-.11-.45-.33-.67-.65-.67H7.16c-.29,0-.5.22-.65.67L5.1,12.81,3.82,3a.55.55,0,0,0-.61-.55H.78a.36.36,0,0,0-.29.16A.6.6,0,0,0,.37,3a.5.5,0,0,0,0,.18L2.53,19.22a1.07,1.07,0,0,0,.23.6.64.64,0,0,0,.53.23H5.16c.37,0,.61-.21.73-.65l2-7.19Z'/></svg>", | |
| "apiVersion": 2, | |
| "keywords": [ | |
| ], | |
| "acf": { | |
| "mode": "preview", | |
| "renderTemplate": "render.php" | |
| }, | |
| "styles": [ | |
| ], | |
| "supports": { | |
| "align": [ | |
| "wide" | |
| ], | |
| "alignContent": false, | |
| "alignText": false, | |
| "anchor": false, | |
| "color": { | |
| "text": false, | |
| "background": false, | |
| "link": false | |
| }, | |
| "fullHeight": false | |
| }, | |
| "script": "block-faq-js" | |
| } | 
  
    
      This file contains hidden or 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
    
  
  
    
  | /** | |
| * Frontend scripts & styles | |
| */ | |
| function wd_global_enqueues() { | |
| // custom blocks javascript | |
| wp_register_script( | |
| 'block-faq-js', | |
| get_stylesheet_directory_uri() . '/blocks/faq/block.js', | |
| [ 'jquery' ], | |
| WD_THEME_VERSION, | |
| false | |
| ); | |
| } | |
| add_action( 'wp_enqueue_scripts', 'wd_global_enqueues' ); | |
| /** | |
| * Block editor scripts | |
| */ | |
| function wd_admin_enqueues() { | |
| // custom blocks javascript | |
| wp_register_script( | |
| 'block-faq-js', | |
| get_stylesheet_directory_uri() . '/blocks/faq/block.js', | |
| [ 'jquery' ], | |
| WD_THEME_VERSION, | |
| false | |
| ); | |
| } | |
| add_action( 'enqueue_block_editor_assets', 'wd_admin_enqueues' ); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment