Skip to content

Commit cbbd216

Browse files
committed
Remove global variable and fixed load_plugin_textdomain
1 parent 754be79 commit cbbd216

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file, per [the Keep a Changelog standard](http://keepachangelog.com/).
44

5+
## [Unreleased]
6+
7+
### Changed
8+
9+
- Remove global variable.
10+
11+
### Fixed
12+
13+
- load_plugin_textdomain.
14+
515
## [0.7.1] - 2024-12-07
616

717
### Changed

accordion-block.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,11 @@
3232
require_once PIXALB_ACCORDION_BLOCK_PATH . 'vendor/autoload.php';
3333
}
3434

35-
$updater = PucFactory::buildUpdateChecker(
35+
PucFactory::buildUpdateChecker(
3636
'https://github.com/pixelalbatross/accordion-block/',
3737
__FILE__,
3838
'accordion-block'
39-
);
40-
41-
$updater->setBranch( 'main' );
39+
)->setBranch( 'main' );
4240

4341
/**
4442
* Registers the block using the metadata loaded from the `block.json` file.
@@ -47,7 +45,7 @@
4745
*
4846
* @see https://developer.wordpress.org/reference/functions/register_block_type/
4947
*/
50-
function accordion_block_init() {
48+
function init() {
5149

5250
$block_json_files = glob( PIXALB_ACCORDION_BLOCK_PATH . 'build/*/block.json' );
5351

@@ -67,24 +65,24 @@ function accordion_block_init() {
6765
}
6866
}
6967
}
70-
add_action( 'init', __NAMESPACE__ . '\accordion_block_init' );
68+
add_action( 'init', __NAMESPACE__ . '\init' );
7169

7270
/**
7371
* Registers the block textdomain.
7472
*
7573
* @return void
7674
*/
77-
function accordion_block_i18n() {
75+
function i18n() {
7876
load_plugin_textdomain( 'accordion-block', false, plugin_basename( PIXALB_ACCORDION_BLOCK_PATH ) . '/languages' );
7977
}
80-
add_action( 'plugins_loaded', __NAMESPACE__ . '\accordion_block_i18n' );
78+
add_action( 'init', __NAMESPACE__ . '\i18n' );
8179

8280
/**
8381
* Handles JavaScript detection.
8482
*
8583
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
8684
*/
87-
function accordion_block_js_detection() {
85+
function js_detection() {
8886
echo "<script>!function(s){s.classList.contains('js')?s.classList:s.classList.add('js')}(document.documentElement);</script>\n";
8987
}
90-
add_action( 'wp_head', __NAMESPACE__ . '\accordion_block_js_detection', 0 );
88+
add_action( 'wp_head', __NAMESPACE__ . '\js_detection', 0 );

0 commit comments

Comments
 (0)