|
@@ 132-148 (lines=17) @@
|
| 129 |
|
public function register_blocks() { |
| 130 |
|
$blocks = array(); |
| 131 |
|
|
| 132 |
|
foreach ( $this->styles as $style ) { |
| 133 |
|
if ( in_array( $style['type'], array( 'block' ) ) ) { |
| 134 |
|
wp_register_style( |
| 135 |
|
$style['handle'], |
| 136 |
|
$this->url . $style['src'], |
| 137 |
|
isset( $style['deps'] ) ? $style['deps'] : array(), |
| 138 |
|
$this->version, |
| 139 |
|
isset( $style['media'] ) ? $style['media'] : 'all' |
| 140 |
|
); |
| 141 |
|
|
| 142 |
|
if ( ! isset( $blocks[ $style['block'] ] ) ) { |
| 143 |
|
$blocks[ $style['block'] ] = array(); |
| 144 |
|
} |
| 145 |
|
|
| 146 |
|
$blocks[ $style['block'] ]['editor_style'] = $style['handle']; |
| 147 |
|
} |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
foreach ( $this->scripts as $script ) { |
| 151 |
|
if ( in_array( $script['type'], array( 'block' ) ) ) { |
|
@@ 150-168 (lines=19) @@
|
| 147 |
|
} |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
foreach ( $this->scripts as $script ) { |
| 151 |
|
if ( in_array( $script['type'], array( 'block' ) ) ) { |
| 152 |
|
wp_register_script( |
| 153 |
|
$script['handle'], |
| 154 |
|
$this->url . $script['src'], |
| 155 |
|
isset( $script['deps'] ) ? $script['deps'] : array(), |
| 156 |
|
$this->version, |
| 157 |
|
isset( $script['footer'] ) ? $script['footer'] : false |
| 158 |
|
); |
| 159 |
|
|
| 160 |
|
$this->localize_script( $script ); |
| 161 |
|
|
| 162 |
|
if ( ! isset( $blocks[ $script['block'] ] ) ) { |
| 163 |
|
$blocks[ $script['block'] ] = array(); |
| 164 |
|
} |
| 165 |
|
|
| 166 |
|
$blocks[ $script['block'] ]['editor_script'] = $script['handle']; |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
foreach ( $blocks as $slug => $opts ) { |
| 171 |
|
register_block_type( $slug, $opts ); |