Plugin Directory

Changeset 2972425


Ignore:
Timestamp:
09/27/2023 10:33:08 PM (2 years ago)
Author:
zeshanb
Message:

Registered shortcodes as block patterns

Location:
easy-cart/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • easy-cart/trunk/plugin.php

    r2812697 r2972425  
    44 * Plugin URI:        https://www.zdatatech.com/portfolio/plugins/easy-cart
    55 * Description:       A simple shopping cart using shortcodes. You desginate a page with slug /cart and add  [easy_cart/] shortcode to the /cart page and post [add_to_cart] shortcodes in other places on your wordpress site. This also serves as a example on using transient storage instead of sessions.
    6  * Version:           1.2
     6 * Version:           1.8
    77 * Requires at least: 5.3
     8 * Tested up to:      6.3
    89 * Requires PHP:      5.6
    910 * Author:            Zeshan B
     
    1516 */
    1617
    17  
    1818  add_action( 'init', 'ectp_check_cookie' );
    1919 
    2020  add_action( 'init', 'ectp_easy_cart_shortcodes' );
     21
     22  add_action( 'init', 'ectp_easy_cart_block_patterns' );
     23
     24  add_action( 'init', 'ectp_register_easycart_pattern_categories' );
    2125
    2226 
     
    297301     
    298302 }
    299  
    300  
     303
     304 function ectp_register_easycart_pattern_categories() {
     305    register_block_pattern_category(
     306        'easy-cart',
     307        array( 'label' => __( 'Easy Cart', 'Add to Cart' ) )
     308    );
     309  }
     310 
     311 function ectp_easy_cart_block_patterns() {
     312    register_block_pattern(
     313        'Easy-Cart/add-to-cart-pattern',
     314        array(
     315            'title'       => __( 'Add To Cart', 'Add To Cart' ),
     316            'description' => _x( 'Add To Cart Shortcode', 'Block pattern description', 'Easy Cart' ),
     317            'categories'  => array( 'easy-cart' ),
     318            'content'     => "<!-- wp:shortcode -->
     319            [add_to_cart itemid='201298' product_name='Your product name One' product_desc='description of your product.' product_qty=1 price=5.00 /]
     320            <!-- /wp:shortcode -->",
     321        )
     322    );
     323
     324    register_block_pattern(
     325        'Easy-Cart/easy-cart',
     326        array(
     327            'title'       => __( 'Easy Cart', 'Easy Cart' ),
     328            'description' => _x( 'Display cart Shortcode', 'Block pattern description', 'Easy Cart' ),
     329            'categories'  => array( 'easy-cart' ),
     330            'content'     => "<!-- wp:shortcode -->[easy_cart /]<!-- /wp:shortcode -->",
     331        )
     332    );
     333
     334    register_block_pattern(
     335        'Easy-Cart/empty-cart',
     336        array(
     337            'title'       => __( 'Empty Cart', 'Empty Cart' ),
     338            'description' => _x( 'Empty Cart Shortcode', 'Block pattern description', 'Empty Cart' ),
     339            'categories'  => array( 'easy-cart' ),
     340            'content'     => "<!-- wp:shortcode -->[empty_cart /]<!-- /wp:shortcode -->",
     341        )
     342    );
     343  }
    301344
    302345?>
  • easy-cart/trunk/readme.txt

    r2972320 r2972425  
    55Tested up to: 6.3
    66Requires PHP: 8.0
    7 Stable tag: 1.3
     7Stable tag: 1.8
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    4848
    4949== Changelog ==
     50
     51= 1.8 =
     52* Registered shortcodes as block patterns
    5053
    5154= 1.3 =
Note: See TracChangeset for help on using the changeset viewer.