54 | | * @type string $name The name of the block (eg: `bp/member`). |
55 | | * @type string $editor_script_url URL to the JavaScript main file of the BP Block |
56 | | * to load into the Block Editor. |
57 | | * @type array $editor_script_deps The list of JavaScript dependency handles for the |
58 | | * BP Block main file. |
59 | | * @type string $script_url URL to the JavaScript file to load into the Block |
60 | | * Editor and on front-end. |
61 | | * @type array $script_deps The list of JavaScript dependency handles for the |
62 | | * JavaScript file to load into the Block Editor and |
63 | | * on front-end. |
64 | | * @type string $editor_style_url URL to the CSS main file of the BP Block to load |
65 | | * into the Block Editor. |
66 | | * @type array $editor_style_deps The list of CSS dependency handles for the |
67 | | * CSS main file. |
68 | | * @type string $style_url URL to the CSS file to load into the Block Editor |
69 | | * and on front-end. |
70 | | * @type array $style_deps The list of CSS dependency handles for the CSS file |
71 | | * to load into the Block Editor and on front-end. |
| 55 | * @type string $editor_script_url URL to the JavaScript main file of the BP Block |
| 56 | * to load into the Block Editor. |
| 57 | * @type array $editor_script_deps The list of JavaScript dependency handles for the |
| 58 | * BP Block main file. |
| 59 | * @type string $script_url URL to the JavaScript file to load into the Block |
| 60 | * Editor and on front-end. |
| 61 | * @type array $script_deps The list of JavaScript dependency handles for the |
| 62 | * JavaScript file to load into the Block Editor and |
| 63 | * on front-end. |
| 64 | * @type string $view_script_url URL to the JavaScript file to load on front-end. |
| 65 | * @type array $view_script_deps The list of JavaScript dependency handles for the |
| 66 | * JavaScript file to load on front-end. |
| 67 | * @type string $editor_style_url URL to the CSS main file of the BP Block to load |
| 68 | * into the Block Editor. |
| 69 | * @type array $editor_style_deps The list of CSS dependency handles for the |
| 70 | * CSS main file. |
| 71 | * @type string $style_url URL to the CSS file to load into the Block Editor |
| 72 | * and on front-end. |
| 73 | * @type array $style_deps The list of CSS dependency handles for the CSS file |
| 74 | * to load into the Block Editor and on front-end. |
| 75 | * @type string $domain_path The path to the folder where custom block translations |
| 76 | * are located. |
| 77 | * @type array $buddypress_contexts The list of BuddyPress contexts a block can be loaded into. |
79 | | $min = bp_core_get_minified_asset_suffix(); |
80 | | $wp_args = array_intersect_key( |
81 | | $args, |
82 | | array( |
83 | | 'name' => '', |
84 | | 'render_callback' => '', |
85 | | 'attributes' => '', |
86 | | 'editor_script' => '', |
87 | | 'script' => '', |
88 | | 'editor_style' => '', |
89 | | 'style' => '', |
90 | | ) |
| 85 | $min = bp_core_get_minified_asset_suffix(); |
| 86 | $metadata_map = array( |
| 87 | 'ancestor' => 'ancestor', |
| 88 | 'apiVersion' => 'api_version', |
| 89 | 'attributes' => 'attributes', |
| 90 | 'category' => 'category', |
| 91 | 'description' => 'description', |
| 92 | 'editorScript' => 'editor_script', |
| 93 | 'editorStyle' => 'editor_style', |
| 94 | 'example' => 'example', |
| 95 | 'icon' => 'icon', |
| 96 | 'keywords' => 'keywords', |
| 97 | 'name' => 'name', |
| 98 | 'parent' => 'parent', |
| 99 | 'providesContext' => 'provides_context', |
| 100 | 'script' => 'script', |
| 101 | 'style' => 'style', |
| 102 | 'styles' => 'styles', |
| 103 | 'supports' => 'supports', |
| 104 | 'textdomain' => 'textdomain', |
| 105 | 'title' => 'title', |
| 106 | 'usesContext' => 'uses_context', |
| 107 | 'variations' => 'variations', |
| 108 | 'version' => 'version', |
| 109 | 'viewScript' => 'view_script', |
| 112 | // Init WordPress Block $args. |
| 113 | $wp_args = array(); |
| 114 | |
| 115 | // rekey $args. |
| 116 | foreach ( $args as $arg_key => $arg ) { |
| 117 | $snake_case_key = ''; |
| 118 | |
| 119 | if ( isset( $metadata_map[ $arg_key ] ) ) { |
| 120 | $snake_case_key = $metadata_map[ $arg_key ]; |
| 121 | $wp_args[ $snake_case_key ] = $arg; |
| 122 | } elseif ( in_array( $arg_key, $metadata_map, true ) ) { |
| 123 | $wp_args[ $arg_key ] = $arg; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | if ( isset( $args['render_callback'] ) && $args['render_callback'] ) { |
| 128 | $wp_args['render_callback'] = $args['render_callback']; |
| 129 | } |
| 130 | |
| 134 | if ( isset( $wp_args['api_version'], $args['plugin_url'] ) && 2 === (int) $wp_args['api_version'] ) { |
| 135 | foreach ( array( 'editor_script', 'editor_style', 'script', 'style', 'view_script' ) as $asset_key ) { |
| 136 | if ( ! isset( $wp_args[ $asset_key ] ) ) { |
| 137 | continue; |
| 138 | } |
| 139 | |
| 140 | $asset_abs_uri_key = $asset_key . '_url'; |
| 141 | $args[ $asset_abs_uri_key ] = trailingslashit( $args['plugin_url'] ) . remove_block_asset_path_prefix( $wp_args[ $asset_key ] ); |
| 142 | $args[ $asset_key ] = str_replace( '/', '-', $wp_args['name'] ) . '-' . str_replace( '_', '-', $asset_key ); |
| 143 | $wp_args[ $asset_key ] = $args[ $asset_key ]; |
| 144 | } |
| 145 | } |
| 146 | |
100 | | 'editor_script_url' => '', |
101 | | 'editor_script_deps' => array(), |
102 | | 'script_url' => '', |
103 | | 'script_deps' => array(), |
104 | | 'editor_style_url' => '', |
105 | | 'editor_style_deps' => array(), |
106 | | 'style_url' => '', |
107 | | 'style_deps' => array(), |
| 151 | 'editor_script_url' => '', |
| 152 | 'editor_script_deps' => array(), |
| 153 | 'script_url' => '', |
| 154 | 'script_deps' => array(), |
| 155 | 'view_script_url' => '', |
| 156 | 'view_script_deps' => array(), |
| 157 | 'editor_style_url' => '', |
| 158 | 'editor_style_deps' => array(), |
| 159 | 'style_url' => '', |
| 160 | 'style_deps' => array(), |
| 161 | 'domain_path' => null, |
| 162 | 'buddypress_contexts' => array(), |