Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:10up/insert-special-characters i…
Browse files Browse the repository at this point in the history
…nto develop
  • Loading branch information
Sidsector9 committed Oct 19, 2023
2 parents 79a77bb + e4cb145 commit 4f34f0f
Show file tree
Hide file tree
Showing 13 changed files with 802 additions and 538 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on: [pull_request]

permissions:
contents: read
pull-requests: write

jobs:
dependency-review:
Expand All @@ -22,3 +23,4 @@ jobs:
license-check: true
vulnerability-check: false
config-file: 10up/.github/.github/dependency-review-config.yml@trunk
comment-summary-in-pr: on-failure
7 changes: 5 additions & 2 deletions .github/workflows/php-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@ jobs:
- name: Install dependencies
run: composer install

- name: Run PHP Compatibility
run: vendor/bin/phpcs insert-special-characters.php --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.4-
- name: Run PHP Compatibility on all files.
run: vendor/bin/phpcs inc --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 7.4-

- name: Run PHP Compatibility on main file.
run: vendor/bin/phpcs insert-special-characters.php --standard=PHPCompatibilityWP --extensions=php --runtime-set testVersion 5.6-
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ All notable changes to this project will be documented in this file, per [the Ke

## [Unreleased] - TBD

## [1.1.1] - 2023-10-17
### Fixed
- Address an issue where some blocks would crash due to a missing attribute (props [@dkotter](https://github.com/dkotter) via [#221](https://github.com/10up/insert-special-characters/pull/221)).

### Security
- Bump `@babel/traverse` from 7.20.5 to 7.23.2 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#219](https://github.com/10up/insert-special-characters/pull/219)).

## [1.1.0] - 2023-10-16
### Added
- Show a faux cursor to preserve context (props [@Sidsector9](https://github.com/Sidsector9), [@helen](https://github.com/helen), [@ravinderk](https://github.com/ravinderk) via [#207](https://github.com/10up/insert-special-characters/pull/207)).
- Check for minimum required PHP version before loading the plugin (props [@kmgalanakis](https://github.com/kmgalanakis), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#210](https://github.com/10up/insert-special-characters/pull/210)).

### Changed
- Bump WordPress "tested up to" version to 6.3 (props [@kmgalanakis](https://github.com/kmgalanakis), [@jeffpaul](https://github.com/jeffpaul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#212](https://github.com/10up/insert-special-characters/pull/212), [#215](https://github.com/10up/insert-special-characters/pull/215)).

### Fixed
- Ensure that when highlighting a special character, the block doesn't crash (props [@jrmd](https://github.com/jrmd), [@dkotter](https://github.com/dkotter) via [#204](https://github.com/10up/insert-special-characters/pull/204)).

### Security
- Bump `semver` from 5.7.1 to 5.7.2 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#202](https://github.com/10up/insert-special-characters/pull/202)).
- Bump `word-wrap` from 1.2.3 to 1.2.4 (props [@dependabot](https://github.com/apps/dependabot), [@Sidsector9](https://github.com/Sidsector9) via [#206](https://github.com/10up/insert-special-characters/pull/206)).
- Bump `@cypress/request` from 2.88.10 to 3.0.0, `cypress` from 12.8.1 to 13.3.1 and `@10up/cypress-wp-utils` from 0.1.0 to 0.2.0 (props [@dependabot](https://github.com/apps/dependabot), [@dkotter](https://github.com/dkotter) via [#213](https://github.com/10up/insert-special-characters/pull/213)).
- Bump `tough-cookie` from 4.1.2 to 4.1.3 and `@cypress/request` from 2.88.10 to 2.88.12 (props [@dependabot](https://github.com/apps/dependabot), [@ravinderk](https://github.com/ravinderk) via [#214](https://github.com/10up/insert-special-characters/pull/214)).
- Bump `postcss` from 8.4.20 to 8.4.31 (props [@dependabot](https://github.com/apps/dependabot), [@faisal-alvi](https://github.com/faisal-alvi) via [#216](https://github.com/10up/insert-special-characters/pull/216)).

## [1.0.7] - 2023-06-28
### Added
- Mochawesome reporter added for Cypress test report (props [@jayedul](https://github.com/jayedul), [@peterwilsoncc](https://github.com/peterwilsoncc) via [#194](https://github.com/10up/insert-special-characters/pull/194)).
Expand Down Expand Up @@ -150,6 +175,8 @@ All notable changes to this project will be documented in this file, per [the Ke
- Plugin header and icon images (props [@McCallumDillon](https://github.com/McCallumDillon) via [#28](https://github.com/10up/insert-special-characters/pull/28))

[Unreleased]: https://github.com/10up/insert-special-characters/compare/trunk...develop
[1.1.1]: https://github.com/10up/insert-special-characters/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/10up/insert-special-characters/compare/1.0.7...1.1.0
[1.0.7]: https://github.com/10up/insert-special-characters/compare/1.0.6...1.0.7
[1.0.6]: https://github.com/10up/insert-special-characters/compare/1.0.5...1.0.6
[1.0.5]: https://github.com/10up/insert-special-characters/compare/1.0.4...1.0.5
Expand Down
2 changes: 1 addition & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following individuals are responsible for curating the list of issues, respo

Thank you to all the people who have already contributed to this repository via bug reports, code, design, ideas, project management, translation, testing, etc.

[Adam Silverstein (@adamsilverstein)](https://github.com/adamsilverstein), [Helen Hou-Sandi (@helen)](https://github.com/helen), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Mark Root-Wiley (@mrwweb)](https://github.com/mrwweb), [Dominik Schilling (@ocean90)](https://github.com/ocean90), [</Aljoscha> (@josch87)](https://github.com/josch87), [David Chabbi (@davidchabbi)](https://profiles.wordpress.org/davidchabbi/), [Sami Keijonen (@samikeijonen)](https://github.com/samikeijonen), [John Watkins (@johnwatkins0)](https://github.com/johnwatkins0), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Pablo Amato (@pabamato)](https://github.com/pabamato), [Ankit K Gupta (@ankitguptaindia)](https://github.com/ankitguptaindia), [Herb Miller (@bobbingwide)](https://github.com/bobbingwide), [Jeffrey Carandang (@phpbits)](https://github.com/phpbits), [Brandon Berg (@BBerg10up)](https://github.com/BBerg10up), [Siddharth Thevaril (@Sidsector9)](https://github.com/Sidsector9), [Pablo Amato (@pabamato)](https://github.com/pabamato), [Evgeny Vlasenko (@mahnunchik)](https://github.com/mahnunchik), [Ajay Maurya (@ajmaurya99)](https://github.com/ajmaurya99), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Max Lyuchin (@cadic)](https://github.com/cadic), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Peter Wilson (@peterwilsoncc)](https://github.com/peterwilsoncc), [David Godleman (@cldhmmr)](https://github.com/cldhmmr), [Ulrich Pogson (@grappler)](https://github.com/grappler), [Mathew Payne (@GeekMasher)](https://github.com/GeekMasher), [Faisal Alvi (@faisal-alvi)](https://github.com/faisal-alvi), [Alex Lion (@alexclassroom)](https://github.com/alexclassroom), [GitHub Dependabot (@dependabot)](https://github.com/apps/dependabot), [Jayedul Kabir (@jayedul)](https://github.com/jayedul), [Jerome Duncan (@jrmd)](https://github.com/jrmd), [Garth Gutenberg (@ggutenberg)](https://github.com/ggutenberg), [Ben Marshall (@bmarshall511)](https://github.com/bmarshall511).
[Adam Silverstein (@adamsilverstein)](https://github.com/adamsilverstein), [Helen Hou-Sandi (@helen)](https://github.com/helen), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Mark Root-Wiley (@mrwweb)](https://github.com/mrwweb), [Dominik Schilling (@ocean90)](https://github.com/ocean90), [</Aljoscha> (@josch87)](https://github.com/josch87), [David Chabbi (@davidchabbi)](https://profiles.wordpress.org/davidchabbi/), [Sami Keijonen (@samikeijonen)](https://github.com/samikeijonen), [John Watkins (@johnwatkins0)](https://github.com/johnwatkins0), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Pablo Amato (@pabamato)](https://github.com/pabamato), [Ankit K Gupta (@ankitguptaindia)](https://github.com/ankitguptaindia), [Herb Miller (@bobbingwide)](https://github.com/bobbingwide), [Jeffrey Carandang (@phpbits)](https://github.com/phpbits), [Brandon Berg (@BBerg10up)](https://github.com/BBerg10up), [Siddharth Thevaril (@Sidsector9)](https://github.com/Sidsector9), [Pablo Amato (@pabamato)](https://github.com/pabamato), [Evgeny Vlasenko (@mahnunchik)](https://github.com/mahnunchik), [Ajay Maurya (@ajmaurya99)](https://github.com/ajmaurya99), [Dharmesh Patel (@iamdharmesh)](https://github.com/iamdharmesh), [Darin Kotter (@dkotter)](https://github.com/dkotter), [Max Lyuchin (@cadic)](https://github.com/cadic), [Vikram Moparthy (@vikrampm1)](https://github.com/vikrampm1), [Peter Wilson (@peterwilsoncc)](https://github.com/peterwilsoncc), [David Godleman (@cldhmmr)](https://github.com/cldhmmr), [Ulrich Pogson (@grappler)](https://github.com/grappler), [Mathew Payne (@GeekMasher)](https://github.com/GeekMasher), [Faisal Alvi (@faisal-alvi)](https://github.com/faisal-alvi), [Alex Lion (@alexclassroom)](https://github.com/alexclassroom), [GitHub Dependabot (@dependabot)](https://github.com/apps/dependabot), [Jayedul Kabir (@jayedul)](https://github.com/jayedul), [Jerome Duncan (@jrmd)](https://github.com/jrmd), [Garth Gutenberg (@ggutenberg)](https://github.com/ggutenberg), [Ben Marshall (@bmarshall511)](https://github.com/bmarshall511), [Ravinder Kumar (@ravinderk)](https://github.com/ravinderk), [Konstantinos Galanakis (@kmgalanakis)](https://github.com/kmgalanakis).

## Libraries

Expand Down
173 changes: 173 additions & 0 deletions inc/plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?php
/**
* Registers JS and CSS assets.
*
* @package insert-special-characters
*/

namespace InsertSpecialCharacters;

/**
* Registers JS and CSS assets.
*/
function register_assets() {
$asset_data_file = trailingslashit( ISC_PLUGIN_PATH ) . 'build/index.asset.php';

if ( ! file_exists( $asset_data_file ) ) {
return;
}

$script_data = include $asset_data_file;

wp_register_script(
'insert-special-characters',
ISC_PLUGIN_URL . 'build/index.js',
$script_data['dependencies'],
$script_data['version'],
true
);

wp_register_style(
'insert-special-characters-css',
ISC_PLUGIN_URL . 'build/index.css',
array(),
$script_data['version']
);

wp_set_script_translations( 'insert-special-characters', 'insert-special-characters', ISC_PLUGIN_PATH . 'languages' );
}

add_action( 'init', __NAMESPACE__ . '\register_assets' );


/**
* Enqueue the admin JavaScript assets.
*/
function gcm_block_enqueue_scripts() {

wp_enqueue_script( 'insert-special-characters' );

wp_enqueue_style( 'insert-special-characters-css' );

wp_add_inline_script(
'insert-special-characters',
sprintf(
'var tenupIscVars = window.tenupIscVars || {}; tenupIscVars = %1$s',
wp_json_encode(
array(
'most_read_palette' => get_most_used_palette_setting(),
)
)
)
);
}
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\gcm_block_enqueue_scripts' );

/**
* Registers settings fields.
*/
function register_settings_fields() {
register_setting(
'writing',
'tenup_isc_most_read_palette',
array(
'type' => 'boolean',
'show_in_rest' => true,
'default' => false,
)
);

add_settings_section(
'tenup_isc_writing_section',
esc_html__( 'Insert Special Characters', 'insert-special-characters' ),
null,
'writing'
);

add_settings_field(
'tenup_isc_most_read_palette',
esc_html__( 'Most used characters palette', 'insert-special-characters' ),
__NAMESPACE__ . '\render_isc_writing_setting',
'writing',
'tenup_isc_writing_section',
array(
'label_for' => 'tenup_isc_most_read_palette',
)
);
}
add_action( 'admin_init', __NAMESPACE__ . '\register_settings_fields' );

/**
* Renders settings fields.
*/
function render_isc_writing_setting() {
$option = get_most_used_palette_setting();
?>
<p>
<label for="tenup_isc_most_read_palette">
<input
type="checkbox"
name="tenup_isc_most_read_palette"
id="tenup_isc_most_read_palette"
<?php checked( $option, true, true ); ?>
>
<?php esc_html_e( 'Check this to enable the most used character palette.', 'insert-special-characters' ); ?>
</label>
</p>

<?php if ( $option ) : ?>
<p>
<button class="button secondary" id="isc_reset_palette" type="button" style="margin-top: 16px;">
<?php esc_html_e( 'Clear palette', 'insert-special-characters' ); ?>
</button>
&nbsp;
<?php esc_html_e( 'Press this to clear palette data.', 'insert-special-characters' ); ?>
</p>
<?php
endif;
}

/**
* Helper function to get most used character palette setting.
*
* @return boolean
*/
function get_most_used_palette_setting() {
return 'on' === get_option( 'tenup_isc_most_read_palette' );
}

/**
* Loads admin scripts.
*
* @param string $hook The current admin page.
*/
function load_admin_scripts( $hook ) {
if ( 'options-writing.php' !== $hook ) {
return;
}

$asset_data_file = trailingslashit( ISC_PLUGIN_PATH ) . 'build/admin.asset.php';

if ( ! file_exists( $asset_data_file ) ) {
return;
}

$script_data = include $asset_data_file;

wp_enqueue_script(
'insert-special-characters-admin-js',
ISC_PLUGIN_URL . 'build/admin.js',
$script_data['dependencies'],
$script_data['version'],
true
);

wp_localize_script(
'insert-special-characters-admin-js',
'tenupIscAdminVars',
array(
'palette_deleted_message' => __( 'Palette cleared', 'insert-special-characters' ),
)
);
}
add_action( 'admin_enqueue_scripts', __NAMESPACE__ . '\load_admin_scripts' );
Loading

0 comments on commit 4f34f0f

Please sign in to comment.