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
| const FLIP_CARDS = 'loop-patterns/flip-cards'; | |
| wp.domReady( function() { | |
| wp.blocks.registerBlockVariation( 'core/query', { | |
| name: FLIP_CARDS, | |
| title: 'Flip Cards', | |
| description: 'Flip Cards Query', | |
| isActive: ( { namespace, query } ) => { | |
| return ( | |
| namespace === FLIP_CARDS |
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
| import './simple-query'; |
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
| <?php | |
| /** | |
| * Register Scripts | |
| * | |
| * @return void | |
| */ | |
| function block_assets_scripts_enqueue() { | |
| $block_asset_dependencies = [ 'wp-i18n', 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ]; | |
| wp_enqueue_script( 'loop-patterns-scripts', plugins_url( 'build/index.js', __FILE__ ), $block_asset_dependencies ); |
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
| const SIMPLE_QUERY = 'loop-patterns/simple-query'; | |
| wp.domReady( function() { | |
| wp.blocks.registerBlockVariation( 'core/query', { | |
| name: SIMPLE_QUERY, | |
| title: 'Simple Query', | |
| description: 'Displays a Simple Query', | |
| isActive: ( { namespace, query } ) => { | |
| return ( | |
| namespace === SIMPLE_QUERY |
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
| innerBlocks: [ | |
| [ | |
| 'core/post-template', | |
| {}, | |
| [ | |
| [ 'core/post-title' ], | |
| [ 'core/post-excerpt' ] | |
| ], | |
| ], | |
| [ 'core/query-pagination' ], |
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
| attributes: { | |
| perPage: 3, | |
| pages: 0, | |
| offset: 0, | |
| postType: 'post', | |
| order: 'desc', | |
| orderBy: 'date', | |
| author: '', | |
| search: '', | |
| exclude: [], |
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
| wp.blocks.registerBlockVariation( 'core/query', { | |
| name: SIMPLE_QUERY, | |
| title: 'Simple Query', | |
| description: 'Displays a Simple Query', | |
| return ( | |
| namespace === SIMPLE_QUERY | |
| && query.postType === 'post' | |
| ); | |
| }, | |
| icon: 'edit-large', |
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
| /** | |
| * Order by last word in title. | |
| * | |
| * @param string $orderby orderby | |
| * @param object $query data | |
| * | |
| * @link https://wordpress.stackexchange.com/questions/1003/order-posts-by-last-word-in-title | |
| * | |
| * @return string | |
| */ |
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
| const SIMPLE_QUERY = `loop-patterns/simple-query` | |
| wp.domReady( function() { | |
| wp.blocks.registerBlockVariation( 'core/query', {} ) | |
| ); |
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
| cd loop-patterns | |
| // cd to the src folder and create 2 directories | |
| cd src && mkdir css simple-query | |
| // cd into our first variation dir and create index.js | |
| cd simple-query && touch index.js |