Skip to content

Commit

Permalink
Merge pull request #8 from vektor-inc/fix/core-to-default-on-origin-keys
Browse files Browse the repository at this point in the history
【確認中】WordPress5.9対応 coreからdefaultに変更
  • Loading branch information
sysbird committed Jan 21, 2022
2 parents 59f64dc + 55e53c3 commit a8d7acc
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1,5 +1,5 @@
# VK Color Palette Manager

```
composer require vektor-inc/vk-color-palette-manager
composer require --no-dev vektor-inc/vk-color-palette-manager
```
39 changes: 26 additions & 13 deletions src/VkColorPaletteManager.php
Expand Up @@ -5,7 +5,7 @@
* @package vektor-inc/vk-color-palette-manager
* @license GPL-2.0+
*
* @version 0.0.11
* @version 0.0.15
*/

namespace VektorInc\VK_Color_Palette_Manager;
Expand All @@ -27,6 +27,7 @@ public function __construct() {
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'add_color_palette_css' ), 11 );
// 11 指定が無いと先に読み込んでしまって効かない
add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'add_color_palette_css_to_editor' ), 11 );
load_textdomain( 'vk-color-palette-manager', dirname( __FILE__ ) . '/languages/vk-color-palette-manager-' . get_locale() . '.mo' );
}

/**
Expand All @@ -51,8 +52,8 @@ public static function customize_register( $wp_customize ) {
'label' => '',
'section' => 'colors',
'type' => 'text',
'custom_title_sub' => __( 'Color Palette Setting', 'vcpm_textdomain' ),
'custom_html' => __( 'This color is reflected in the block editor\'s color palette.', 'vcpm_textdomain' ),
'custom_title_sub' => __( 'Color Palette Setting', 'vk-color-palette-manager' ),
'custom_html' => __( 'This color is reflected in the block editor\'s color palette.', 'vk-color-palette-manager' ),
'priority' => 1000,
)
)
Expand All @@ -69,7 +70,7 @@ public static function customize_register( $wp_customize ) {
'sanitize_callback' => 'sanitize_hex_color',
)
);
$label = __( 'Custom color', 'vcpm_textdomain' ) . ' ' . $i;
$label = __( 'Custom color', 'vk-color-palette-manager' ) . ' ' . $i;
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
Expand All @@ -95,7 +96,7 @@ public static function add_color_array() {
for ( $i = 1; $i <= 5; $i++ ) {
if ( ! empty( $options_color[ 'color_custom_' . $i ] ) ) {
$vcm_add_color_array[] = array(
'name' => __( 'Custom color', 'vcpm_textdomain' ) . ' ' . $i,
'name' => __( 'Custom color', 'vk-color-palette-manager' ) . ' ' . $i,
'slug' => 'vk-color-custom-' . $i,
'color' => $options_color[ 'color_custom_' . $i ],
);
Expand All @@ -114,14 +115,26 @@ public static function add_color_array() {
*/
public static function additional_color_palette( $editor_settings, $block_editor_context ) {
$add_color = self::add_color_array();
$editor_settings['__experimentalFeatures']['color']['palette']['core'] = array_merge(
$editor_settings['__experimentalFeatures']['color']['palette']['core'],
$add_color
);
$editor_settings['colors'] = array_merge(
$editor_settings['colors'],
$add_color
);
if ( ! empty( $add_color ) ) {
if ( ! empty( $editor_settings['__experimentalFeatures']['color']['palette']['default'] ) ) {
$editor_settings['__experimentalFeatures']['color']['palette']['default'] = array_merge(
$editor_settings['__experimentalFeatures']['color']['palette']['default'],
$add_color
);
} elseif ( ! empty( $editor_settings['__experimentalFeatures']['color']['palette']['core'] ) ) {
$editor_settings['__experimentalFeatures']['color']['palette']['core'] = array_merge(
$editor_settings['__experimentalFeatures']['color']['palette']['core'],
$add_color
);
} else {
$editor_settings['__experimentalFeatures']['color']['palette']['default'] = $add_color;
$editor_settings['__experimentalFeatures']['color']['palette']['core'] = $add_color;
}
$editor_settings['colors'] = array_merge(
$editor_settings['colors'],
$add_color
);
}
return $editor_settings;
}

Expand Down
Binary file added src/languages/vk-color-palette-manager-ja.mo
Binary file not shown.
29 changes: 29 additions & 0 deletions src/languages/vk-color-palette-manager-ja.po
@@ -0,0 +1,29 @@
msgid ""
msgstr ""
"Project-Id-Version: Color Palette Manager\n"
"POT-Creation-Date: 2021-11-18 15:43+0900\n"
"PO-Revision-Date: 2021-11-18 17:04+0900\n"
"Last-Translator: \n"
"Language-Team: Vektor,Inc.\n"
"Language: ja\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.0\n"
"X-Poedit-Basepath: ..\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Poedit-KeywordsList: __;_e\n"
"X-Poedit-SourceCharset: UTF-8\n"
"X-Poedit-SearchPath-0: VkColorPaletteManager.php\n"

#: VkColorPaletteManager.php:55
msgid "Color Palette Setting"
msgstr "カラーパレット設定"

#: VkColorPaletteManager.php:56
msgid "This color is reflected in the block editor's color palette."
msgstr "この色はエディターのカラーパレットに反映されます。"

#: VkColorPaletteManager.php:73 VkColorPaletteManager.php:99
msgid "Custom color"
msgstr "カスタムカラー"

0 comments on commit a8d7acc

Please sign in to comment.