Skip to content

Commit

Permalink
Manage incompatibilities and add a filter to have all the rules
Browse files Browse the repository at this point in the history
  • Loading branch information
webaxones committed Aug 3, 2024
1 parent 1b59531 commit a0f926b
Show file tree
Hide file tree
Showing 31 changed files with 576 additions and 425 deletions.
Binary file modified .wordpress-org/screenshot-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified .wordpress-org/screenshot-7.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-8.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .wordpress-org/screenshot-9.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-i18n', 'wp-notices', 'wp-plugins'), 'version' => 'bcd6cb4e252b3d42baa6');
<?php return array('dependencies' => array('react', 'wp-components', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-i18n', 'wp-notices', 'wp-plugins'), 'version' => 'eccd1fcee4002381057b');
2 changes: 1 addition & 1 deletion build/index.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This file contains only old changelog. See readme.txt for newer versions.

= 1.5.9 =
* Add rule for percentages symbols
* Refactor some code
* Actualise Readme

= 1.5.8 =
* Add rule for fraction symbols

Expand Down
2 changes: 1 addition & 1 deletion consistency.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Consistency
* Plugin URI: https://www.webaxones.com
* Description: Fixes typographical consistency
* Version: 1.6.5
* Version: 1.7.0
* Requires at least: 6.1
* Requires PHP: 7.4
* Author: Loïc Antignac
Expand Down
138 changes: 69 additions & 69 deletions includes/Asset/Asset.php
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
<?php
namespace Webaxones\Consistency\Asset;

defined( 'ABSPATH' ) || exit;

use Webaxones\Consistency\Utils\Contracts\ActionInterface;
use Webaxones\Consistency\Plugin;
use const Webaxones\Consistency\PLUGIN_PATH;
use const Webaxones\Consistency\PLUGIN_URL;
use Webaxones\Consistency\Config\LocalizedRules;

/**
* Consistency's Assets
*
* This class declares Consistency's assets to be hooked
*
* @throws
*/
class Asset implements ActionInterface
{
/**
* {@inheritdoc}
*/
public function getActions(): array
{
return [ 'enqueue_block_editor_assets' => [ 'enqueueEditorAsset' ] ];
}

/**
* Enqueue Editor Asset
*
* @return void
*/
public function enqueueEditorAsset(): void
{
$info = include PLUGIN_PATH . 'build/index.asset.php';
wp_enqueue_script(
Plugin::PREFIX . '-editor-script',
PLUGIN_URL . 'build/index.js',
$info['dependencies'],
$info['version'],
true
);

// Convert dash style locales code to undescore style for JS
$locales = LocalizedRules::$list;
$locales = array_map(
function ( $value ) {
return array_map(
function ( $value ) {
return str_replace( '-', '_', $value );
},
$value
);
},
$locales
);

// Pass localized rules to the script
$localizedRules = 'const localesByRules = ' . json_encode( $locales );
wp_add_inline_script(
Plugin::PREFIX . '-editor-script',
$localizedRules,
'before'
);

wp_set_script_translations( Plugin::PREFIX . '-editor-script', 'consistency' );
}
}
<?php
namespace Webaxones\Consistency\Asset;

defined( 'ABSPATH' ) || exit;

use Webaxones\Consistency\Utils\Contracts\ActionInterface;
use Webaxones\Consistency\Plugin;
use const Webaxones\Consistency\PLUGIN_PATH;
use const Webaxones\Consistency\PLUGIN_URL;
use Webaxones\Consistency\Config\LocalizedRules;

/**
* Consistency's Assets
*
* This class declares Consistency's assets to be hooked
*
* @throws
*/
class Asset implements ActionInterface
{
/**
* {@inheritdoc}
*/
public function getActions(): array
{
return [ 'enqueue_block_editor_assets' => [ 'enqueueEditorAsset' ] ];
}

/**
* Enqueue Editor Asset
*
* @return void
*/
public function enqueueEditorAsset(): void
{
$info = include PLUGIN_PATH . 'build/index.asset.php';
wp_enqueue_script(
Plugin::PREFIX . '-editor-script',
PLUGIN_URL . 'build/index.js',
$info['dependencies'],
$info['version'],
true
);

// Convert dash style locales code to undescore style for JS
$locales = LocalizedRules::$list;
$locales = array_map(
function ( $value ) {
return array_map(
function ( $value ) {
return str_replace( '-', '_', $value );
},
$value
);
},
$locales
);

// Pass localized rules to the script
$localizedRules = 'const localesByRules = ' . json_encode( $locales );
wp_add_inline_script(
Plugin::PREFIX . '-editor-script',
$localizedRules,
'before'
);

wp_set_script_translations( Plugin::PREFIX . '-editor-script', 'consistency' );
}
}
36 changes: 36 additions & 0 deletions includes/Config/LocalizationManagement.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Webaxones\Consistency\Config;

defined( 'ABSPATH' ) || exit;

use Webaxones\Consistency\Utils\Contracts\ValueInterface;

/**
* Localization Management
*/
class LocalizationManagement implements ValueInterface
{
/**
* Indicates whether the management of correction localization is enabled.
*
* @var bool
*/
protected bool $isLocalizationManaged;

/**
* Constructor
*/
public function __construct( bool $isLocalizationManaged )
{
$this->isLocalizationManaged = $isLocalizationManaged;
}

/**
* {@inheritdoc}
*/
public function build(): bool
{
return $this->isLocalizationManaged ?? true;
}
}
10 changes: 5 additions & 5 deletions includes/Config/RestSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
class RestSchema
{
/**
* Schema of Global settings in REST API
* Schema of rules settings in REST API
*
* @var array $globalSetting Schema of Global settings in REST API used in register_settings
* @var array $ruleSettingSchema Schema of the setting in the REST API used in register_setting, which will contain the correction rules.
*/
public static array $globalSetting = [
public static array $ruleSettingSchema = [
'items' => [
'type' => 'object',
'properties' => [
Expand All @@ -30,9 +30,9 @@ class RestSchema
/**
* Schema of User Meta Settings in REST API
*
* @var array $userMeta Schema of User Meta Settings in REST API used in register_meta
* @var array $userMetaSchema Schema of the user meta in the REST API used in register_meta, which will contain the user choices for corrections (e.g., fix on paste, on the fly).
*/
public static array $userMeta = [
public static array $userMetaSchema = [
'items' => [
'type' => 'object',
'properties' => [
Expand Down
Loading

0 comments on commit a0f926b

Please sign in to comment.