Skip to content

Commit

Permalink
Remove global variable and fixed load_plugin_textdomain
Browse files Browse the repository at this point in the history
  • Loading branch information
s3rgiosan committed Dec 7, 2024
1 parent 5d59274 commit dabf323
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

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

## [Unreleased]

### Changed

- Remove global variable.

### Fixed

- load_plugin_textdomain.

## [0.6.1] - 2024-12-07

### Changed
Expand Down
18 changes: 8 additions & 10 deletions slider-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@
require_once PIXALB_SLIDER_BLOCK_PATH . 'vendor/autoload.php';
}

$updater = PucFactory::buildUpdateChecker(
PucFactory::buildUpdateChecker(
'https://github.com/pixelalbatross/slider-block/',
__FILE__,
'slider-block'
);

$updater->setBranch( 'main' );
)->setBranch( 'main' );

/**
* Registers the block using the metadata loaded from the `block.json` file.
Expand All @@ -47,7 +45,7 @@
*
* @see https://developer.wordpress.org/reference/functions/register_block_type/
*/
function slider_block_init() {
function init() {

$block_json_files = glob( PIXALB_SLIDER_BLOCK_PATH . 'build/*/block.json' );

Expand All @@ -67,24 +65,24 @@ function slider_block_init() {
}
}
}
add_action( 'init', __NAMESPACE__ . '\slider_block_init' );
add_action( 'init', __NAMESPACE__ . '\init' );

/**
* Registers the block textdomain.
*
* @return void
*/
function slider_block_i18n() {
function i18n() {
load_plugin_textdomain( 'slider-block', false, plugin_basename( PIXALB_SLIDER_BLOCK_PATH ) . '/languages' );
}
add_action( 'plugins_loaded', __NAMESPACE__ . '\slider_block_i18n' );
add_action( 'init', __NAMESPACE__ . '\i18n' );

/**
* Handles JavaScript detection.
*
* Adds a `js` class to the root `<html>` element when JavaScript is detected.
*/
function slider_block_js_detection() {
function js_detection() {
echo "<script>!function(s){s.classList.contains('js')?s.classList:s.classList.add('js')}(document.documentElement);</script>\n";
}
add_action( 'wp_head', __NAMESPACE__ . '\slider_block_js_detection', 0 );
add_action( 'wp_head', __NAMESPACE__ . '\js_detection', 0 );

0 comments on commit dabf323

Please sign in to comment.