-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshipping-workshop.php.mustache
59 lines (54 loc) · 2.22 KB
/
shipping-workshop.php.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Plugin Name: Shipping Workshop
* Version: 1.0
* Author: Thomas Roberts and Niels Lange
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: shipping-workshop
* Description: A tutorial plugin to extend the Checkout block by adding a "not at home" shipping option.
*
* @package create-block
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
add_action( 'plugin_row_meta', 'wceu23_shipping_workshop_add_plugin_links', 10, 2 );
function wceu23_shipping_workshop_add_plugin_links( $links, $file ) {
if ( basename( dirname(__FILE__ ) ) . '/' . basename( __FILE__ ) !== $file ) {
return $links;
}
$links[] = '<a href="https://github.com/woocommerce/wceu23-shipping-workshop-starter">' . __( 'Workshop starter files', 'shipping-workshop' ) . '</a>';
$links[] = '<a href="https://github.com/woocommerce/wceu23-shipping-workshop-final">' . __( 'Workshop final files', 'shipping-workshop' ) . '</a>';
$links[] = '<a href="https://developer.woocommerce.com/2023/08/07/extending-the-woocommerce-checkout-block-to-add-custom-shipping-options/">' . __( 'Video tutorial', 'shipping-workshop' ) . '</a>';
return $links;
}
// Define SHIPPING_WORKSHOP_VERSION.
$plugin_data = get_file_data( __FILE__, array( 'version' => 'version' ) );
define( 'SHIPPING_WORKSHOP_VERSION', $plugin_data['version'] );
/**
* Include the dependencies needed to instantiate the block.
*/
add_action('woocommerce_blocks_loaded', function() {
require_once __DIR__ . '/shipping-workshop-blocks-integration.php';
add_action(
'woocommerce_blocks_checkout_block_registration',
function( $integration_registry ) {
$integration_registry->register( new Shipping_Workshop_Blocks_Integration() );
}
);
});
/**
* Registers the slug as a block category with WordPress.
*/
function register_Shipping_Workshop_block_category( $categories ) {
return array_merge(
$categories,
[
[
'slug' => 'shipping-workshop',
'title' => __( 'Shipping_Workshop Blocks', 'shipping-workshop' ),
],
]
);
}
add_action( 'block_categories_all', 'register_Shipping_Workshop_block_category', 10, 2 );