mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Move localization function
This commit is contained in:
@@ -1,7 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class DisplayFeaturedImageGenesisWidgetsBlocksFields
|
||||
*/
|
||||
class DisplayFeaturedImageGenesisWidgetsBlocksFields {
|
||||
|
||||
/**
|
||||
* @var \DisplayFeaturedImageGenesisWidgetsForm
|
||||
*/
|
||||
private $form;
|
||||
|
||||
/**
|
||||
* Get the data for localizing everything.
|
||||
* @return array
|
||||
*/
|
||||
public function get_localization_data() {
|
||||
$common = array(
|
||||
'icon' => 'format-image',
|
||||
'category' => 'widgets',
|
||||
);
|
||||
$output = array();
|
||||
$blocks = include 'fields/blocks.php';
|
||||
foreach ( $blocks as $block => $data ) {
|
||||
if ( empty( $data['nickname'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$common['panels'] = array(
|
||||
'main' => array(
|
||||
'title' => __( 'Block Settings', 'display-featured-image-genesis' ),
|
||||
'initialOpen' => true,
|
||||
'attributes' => $this->fields( $block ),
|
||||
),
|
||||
);
|
||||
$common['block'] = "displayfeaturedimagegenesis/{$block}";
|
||||
$output[ $block ] = array_merge(
|
||||
$data,
|
||||
$common
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fields for the block.
|
||||
*
|
||||
|
||||
@@ -78,42 +78,8 @@ class DisplayFeaturedImageGenesisWidgetsBlocks {
|
||||
* Localize.
|
||||
*/
|
||||
public function localize() {
|
||||
wp_localize_script( "{$this->block}block", 'DisplayFeaturedImageBlock', $this->get_localization_data() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for localizing everything.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_localization_data() {
|
||||
$common = array(
|
||||
'icon' => 'format-image',
|
||||
'category' => 'widgets',
|
||||
);
|
||||
$output = array();
|
||||
$fields = $this->get_fields_class();
|
||||
foreach ( $this->blocks() as $block => $data ) {
|
||||
if ( empty( $data['nickname'] ) ) {
|
||||
continue;
|
||||
}
|
||||
$common['panels'] = array(
|
||||
'main' => array(
|
||||
'title' => __( 'Block Settings', 'display-featured-image-genesis' ),
|
||||
'initialOpen' => true,
|
||||
'attributes' => $fields->fields( $block ),
|
||||
),
|
||||
);
|
||||
$common['block'] = "{$this->name}{$block}";
|
||||
if ( ! empty( $data['nickname'] ) ) {
|
||||
$block = $data['nickname'];
|
||||
}
|
||||
$output[ $block ] = array_merge(
|
||||
$data,
|
||||
$common
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
wp_localize_script( "{$this->block}block", 'DisplayFeaturedImageBlock', $fields->get_localization_data() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user