Skip to content

Commit

Permalink
Update PHPCS ruleset and fix errors and warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradyvercher committed Nov 23, 2024
1 parent 02e5c4b commit 61b60b0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 37 deletions.
7 changes: 5 additions & 2 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.0-"/>
<config name="testVersion" value="8.0-"/>

<!-- Rules: WordPress Coding Standards - see
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
<rule ref="WordPress-Extra"/><!-- Includes WordPress-Core -->
<rule ref="WordPress-Extra">
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
</rule>

<rule ref="WordPress-Docs"/>
<!-- For help in understanding these custom sniff properties:
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
Expand Down
77 changes: 42 additions & 35 deletions php/BlockType/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,39 +47,42 @@ public function register_hooks() {
* @since 0.1.0
*/
protected function register_block_type() {
register_block_type( 'cedaro/code', [
'title' => esc_html__( 'Shiny Code', 'shiny-code' ),
'description' => esc_html__( 'Edit and display code with syntax highlighting.', 'shiny-code' ),
'icon' => 'editor-code',
'category' => 'formatting',
'keywords' => [ 'code' ],
'attributes' => [
'content' => [
'type' => 'string',
'source' => 'text',
'selector' => 'code',
register_block_type(
'cedaro/code',
[
'title' => esc_html__( 'Shiny Code', 'shiny-code' ),
'description' => esc_html__( 'Edit and display code with syntax highlighting.', 'shiny-code' ),
'icon' => 'editor-code',
'category' => 'formatting',
'keywords' => [ 'code' ],
'attributes' => [
'content' => [
'type' => 'string',
'source' => 'text',
'selector' => 'code',
],
'firstLineNumber' => [
'type' => 'number',
'default' => 1,
],
'highlightLines' => [
'type' => 'array',
'default' => [],
],
'language' => [
'type' => 'string',
],
'showLineNumbers' => [
'type' => 'boolean',
'default' => true,
],
],
'firstLineNumber' => [
'type' => 'number',
'default' => 1,
'supports' => [
'align' => [ 'full', 'wide' ],
'html' => false,
],
'highlightLines' => [
'type' => 'array',
'default' => [],
],
'language' => [
'type' => 'string',
],
'showLineNumbers' => [
'type' => 'boolean',
'default' => true,
],
],
'supports' => [
'align' => [ 'full', 'wide' ],
'html' => false,
],
] );
]
);
}

/**
Expand Down Expand Up @@ -137,10 +140,14 @@ protected function enqueue_editor_assets() {

$themes = $this->plugin->get_themes();

wp_localize_script( 'cedaro-code-block-editor', '_shinyCode', [
'languages' => $this->plugin->get_languages(),
'themes' => $themes,
] );
wp_localize_script(
'cedaro-code-block-editor',
'_shinyCode',
[
'languages' => $this->plugin->get_languages(),
'themes' => $themes,
]
);

foreach ( $themes as $theme => $data ) {
if ( empty( $data['codemirror'] ) ) {
Expand Down

0 comments on commit 61b60b0

Please sign in to comment.