-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin.php
84 lines (70 loc) · 2.34 KB
/
plugin.php
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/**
* Plugin Name: iamport-block — CGB Gutenberg Block Plugin
* Plugin URI: https://github.com/ahmadawais/create-guten-block/
* Description: iamport-block — is a Gutenberg plugin created via create-guten-block.
* Author: mrahmadawais, maedahbatool
* Author URI: https://AhmadAwais.com/
* Version: 1.0.0
* License: GPL2+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
*
* @package CGB
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Block Initializer.
*/
// require_once plugin_dir_path( __FILE__ ) . 'src/init.php';
function iamport_editor_scripts()
{
// Make paths variables so we don't write em twice ;)
$blockPath = '/dist/blocks.build.js';
$editorStylePath = '/dist/blocks.editor.build.css';
// Enqueue the bundled block JS file
wp_enqueue_script(
'iamport-blocks-js',
plugins_url( $blockPath, __FILE__ ),
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' ],
filemtime( plugin_dir_path(__FILE__) . $blockPath )
);
// Enqueue optional editor only styles
wp_enqueue_style(
'iamport-blocks-editor-css',
plugins_url( $editorStylePath, __FILE__),
['wp-components'],
filemtime( plugin_dir_path( __FILE__ ) . $editorStylePath )
);
}
// Hook scripts function into block editor hook
add_action( 'enqueue_block_editor_assets', 'iamport_editor_scripts' );
function iamport_scripts()
{
$reactPath = '/dist/iamport.react.js';
// Make paths variables so we don't write em twice ;)
$stylePath = '/dist/blocks.style.build.css';
wp_enqueue_script(
'iamport-js-sdk',
'https://service.iamport.kr/js/iamport.payment-1.1.8.js',
array( 'jquery', 'jquery-ui-dialog' )
);
wp_enqueue_script(
'iamport-react-js',
plugins_url( $reactPath, __FILE__ ),
[ 'wp-i18n', 'wp-element', 'wp-blocks', 'wp-components', 'wp-editor' ],
filemtime( plugin_dir_path(__FILE__) . $reactPath )
);
// Enqueue frontend and editor block styles
wp_enqueue_style(
'iamport-blocks-css',
plugins_url($stylePath, __FILE__),
['wp-components'],
filemtime(plugin_dir_path(__FILE__) . $stylePath )
);
}
// Hook scripts function into block editor hook
add_action('enqueue_block_assets', 'iamport_scripts');
include __DIR__ . '/src/block/index.php';