Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: separate domain based on plugin #2470

Merged
merged 9 commits into from
Feb 5, 2025
1 change: 1 addition & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
.jshintrc
Gruntfile.js
phpcs.xml
phpcs.export.xml
phpstan.neon
.eslintrc
.gitattributes
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -86,6 +86,9 @@
"jsx-a11y/alt-text": "warn",
"jsx-a11y/anchor-is-valid": "warn",
"jsx-a11y/no-noninteractive-element-interactions": "warn",
"jsx-a11y/no-autofocus": "warn"
"jsx-a11y/no-autofocus": "warn",
"@wordpress/i18n-text-domain": ["error", {
"allowedTextDomain": ["otter-blocks", "otter-pro", "blocks-export-import", "blocks-css", "blocks-animation"]
}]
}
}
4 changes: 3 additions & 1 deletion .github/workflows/create-build-url.yml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ name: Build and publish the ZIP build file

on:
pull_request:
types: [ opened, synchronize, ready_for_review ]
types: [opened, synchronize, ready_for_review]
branches-ignore:
- "update_dependencies"
jobs:
@@ -31,6 +31,8 @@ jobs:
run: composer install --no-dev --prefer-dist --no-progress --no-suggest
- name: Install npm deps
run: npm ci
- name: Set version to Stable Tag
run: npm run grunt:version
- name: Build files
run: npm run build
- name: Create zip
2 changes: 2 additions & 0 deletions .github/workflows/deploy-stagging.yml
Original file line number Diff line number Diff line change
@@ -33,6 +33,8 @@ jobs:
run: composer install --no-dev --prefer-dist --no-progress --no-suggest
- name: Install npm deps
run: npm ci
- name: Set version to Stable Tag
run: npm run grunt:version
- name: Build files
run: npm run build
- name: Zip files
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -21,6 +21,8 @@ jobs:
run: composer install --no-dev --prefer-dist --no-progress --no-suggest
- name: Install npm deps
run: npm ci
- name: Set version to Stable Tag
run: npm run grunt:version
- name: Build files
run: npm run build
- name: Build zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -16,3 +16,4 @@ license.json
.fleet
tests/assets/*_tmp
.phpunit.result.cache
languages
1 change: 1 addition & 0 deletions .wp-env.override.json
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
"FS_METHOD": "direct",
"WP_DEFAULT_THEME": "twentytwentythree"
},
"phpVersion": "7.4",
"env": {
"development": {
"themes": [ "./test/emptytheme" ],
13 changes: 12 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -85,7 +85,18 @@ module.exports = function( grunt ) {
flags: ''
},
src: [ 'plugins/otter-pro/otter-pro.php' ]
}
},
readmetxt: {
options: {
prefix: 'Stable tag:\\s*'
},
src: [
'readme.txt',
'plugins/blocks-animation/readme.txt',
'plugins/blocks-css/readme.txt',
'plugins/blocks-export-import/readme.txt',
]
},
},
wp_readme_to_markdown: {
plugin: {
6 changes: 6 additions & 0 deletions bin/dist.sh
Original file line number Diff line number Diff line change
@@ -22,9 +22,15 @@ else
DIST_FOLDER=$BUILD_NAME
fi


# Take all the files, filter the dev ones (e.g. node_modules, src), and save the result to './dist'
rsync -rc --exclude-from ".distignore" "./" "dist/$DIST_FOLDER"

# Change the individual sub-text-domain for the included sub-plugins in the main one.
composer install --prefer-dist --no-progress --no-suggest
composer run format-dist -- "./dist/$DIST_FOLDER"
composer install --no-dev --prefer-dist --no-progress --no-suggest

cd dist

# Create a zip file in './artifact' from the filtered files in the './dist'
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@
"lint": "phpcs",
"format": "phpcbf",
"phpunit": "phpunit",
"phpstan": "phpstan analyse --memory-limit 2G"
"phpstan": "phpstan analyse --memory-limit 2G",
"format-dist": "phpcbf --standard=phpcs.export.xml"
},
"prefer-stable": true,
"config": {
41 changes: 25 additions & 16 deletions inc/class-blocks-animation.php
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ public function init() {
if ( ! defined( 'BLOCKS_ANIMATION_URL' ) ) {
define( 'BLOCKS_ANIMATION_URL', OTTER_BLOCKS_URL );
define( 'BLOCKS_ANIMATION_PATH', OTTER_BLOCKS_PATH );
define( 'BLOCKS_ANIMATION_OTTER', true );
}

add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ) );
@@ -63,7 +64,8 @@ public function init() {
* @access public
*/
public function enqueue_editor_assets() {
$asset_file = include BLOCKS_ANIMATION_PATH . '/build/animation/index.asset.php';
$asset_file = include BLOCKS_ANIMATION_PATH . '/build/animation/index.asset.php';
$is_using_otter_files = defined( 'BLOCKS_ANIMATION_OTTER' );

wp_enqueue_style(
'otter-animation',
@@ -92,7 +94,7 @@ public function enqueue_editor_assets() {
)
);

wp_set_script_translations( 'otter-animation', 'blocks-animation' );
wp_set_script_translations( 'otter-animation', $is_using_otter_files ? 'otter-blocks' : 'blocks-animation' );

$asset_file = include BLOCKS_ANIMATION_PATH . '/build/animation/anim-count.asset.php';
wp_enqueue_script(
@@ -105,6 +107,8 @@ public function enqueue_editor_assets() {

wp_script_add_data( 'otter-count', 'defer', true );

wp_set_script_translations( 'otter-count', $is_using_otter_files ? 'otter-blocks' : 'blocks-animation' );

wp_enqueue_script(
'otter-typing',
BLOCKS_ANIMATION_URL . 'build/animation/anim-typing.js',
@@ -114,6 +118,8 @@ public function enqueue_editor_assets() {
);

wp_script_add_data( 'otter-typing', 'defer', true );

wp_set_script_translations( 'otter-typing', $is_using_otter_files ? 'otter-blocks' : 'blocks-animation' );
}

/**
@@ -251,7 +257,10 @@ public function render_welcome_notice() {
true
);

wp_set_script_translations( 'otter-animation-welcome-notice-scripts', 'otter-blocks' );
wp_set_script_translations(
'otter-animation-welcome-notice-scripts',
defined( 'BLOCKS_ANIMATION_OTTER' ) ? 'otter-blocks' : 'blocks-animation'
);

wp_localize_script(
'otter-animation-welcome-notice-scripts',
@@ -272,32 +281,32 @@ public function render_welcome_notice() {
admin_url( 'plugins.php' )
)
),
'activating' => __( 'Activating', 'otter-blocks' ) . '…',
'installing' => __( 'Installing', 'otter-blocks' ) . '…',
'done' => __( 'Done', 'otter-blocks' ),
'activating' => __( 'Activating', 'blocks-animation' ) . '…',
'installing' => __( 'Installing', 'blocks-animation' ) . '…',
'done' => __( 'Done', 'blocks-animation' ),
)
);

$notice_html = '<div class="notice notice-info otter-animation-welcome-notice">';
$notice_html .= '<button type="button" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>';
$notice_html .= '<button type="button" class="notice-dismiss"><span class="screen-reader-text">' . esc_html__( 'Dismiss this notice.', 'blocks-animation' ) . '</span></button>';
$notice_html .= '<div class="notice-content">';

$notice_html .= '<img class="otter-preview" style="max-height: 300px;" src="' . esc_url( BLOCKS_ANIMATION_URL . '/assets/images/welcome-notice.png' ) . '" alt="' . esc_attr__( 'Otter Blocks preview', 'otter-blocks' ) . '"/>';
$notice_html .= '<img class="otter-preview" style="max-height: 300px;" src="' . esc_url( BLOCKS_ANIMATION_URL . '/assets/images/welcome-notice.png' ) . '" alt="' . esc_attr__( 'Otter Blocks preview', 'blocks-animation' ) . '"/>';

$notice_html .= '<div class="notice-copy">';

$notice_html .= '<h1 class="notice-title">';
$notice_html .= sprintf(
/* translators: %1$s: Add-on Blocks, %2$s: Enhanced Animations, %3$s: Visibility Conditions */
__( 'Power Up Your Site with %1$s, %2$s, %3$s, and more!', 'otter-blocks' ),
'<span>' . __( 'Add-on Blocks', 'otter-blocks' ) . '</span>',
'<span>' . __( 'Enhanced Animations', 'otter-blocks' ) . '</span>',
'<span>' . __( 'Visibility Conditions', 'otter-blocks' ) . '</span>'
__( 'Power Up Your Site with %1$s, %2$s, %3$s, and more!', 'blocks-animation' ),
'<span>' . __( 'Add-on Blocks', 'blocks-animation' ) . '</span>',
'<span>' . __( 'Enhanced Animations', 'blocks-animation' ) . '</span>',
'<span>' . __( 'Visibility Conditions', 'blocks-animation' ) . '</span>'
);

$notice_html .= '</h1>';

$notice_html .= '<p class="description">' . __( 'Otter is a Gutenberg Blocks page builder plugin that adds extra functionality to the WordPress Block Editor (also known as Gutenberg) for a better page building experience without the need for traditional page builders.', 'otter-blocks' ) . '</p>';
$notice_html .= '<p class="description">' . __( 'Otter is a Gutenberg Blocks page builder plugin that adds extra functionality to the WordPress Block Editor (also known as Gutenberg) for a better page building experience without the need for traditional page builders.', 'blocks-animation' ) . '</p>';

$notice_html .= '<div class="actions">';

@@ -307,14 +316,14 @@ public function render_welcome_notice() {
$notice_html .= '<span class="text">';
$notice_html .= 'installed' === $otter_status ?
/* translators: %s: Otter Blocks */
sprintf( __( 'Activate %s', 'otter-blocks' ), 'Otter Blocks' ) :
sprintf( __( 'Activate %s', 'blocks-animation' ), 'Otter Blocks' ) :
/* translators: %s: Otter Blocks */
sprintf( __( 'Install & Activate %s', 'otter-blocks' ), 'Otter Blocks' );
sprintf( __( 'Install & Activate %s', 'blocks-animation' ), 'Otter Blocks' );
$notice_html .= '</span>';
$notice_html .= '</button>';

$notice_html .= '<a href="https://wordpress.org/plugins/otter-blocks/" target="_blank" class="button button-secondary button-hero">';
$notice_html .= '<span>' . __( 'Learn More', 'otter-blocks' ) . '</span>';
$notice_html .= '<span>' . __( 'Learn More', 'blocks-animation' ) . '</span>';
$notice_html .= '<span class="dashicons dashicons-external"></span>';
$notice_html .= '</a>';

3 changes: 2 additions & 1 deletion inc/class-blocks-css.php
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ public function init() {
if ( ! defined( 'BLOCKS_CSS_URL' ) ) {
define( 'BLOCKS_CSS_URL', OTTER_BLOCKS_URL );
define( 'BLOCKS_CSS_PATH', OTTER_BLOCKS_PATH );
define( 'BLOCKS_CSS_OTTER', true );
}

add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ), 1 );
@@ -86,7 +87,7 @@ public function enqueue_editor_assets() {
)
);

wp_set_script_translations( 'otter-css', 'blocks-css' );
wp_set_script_translations( 'otter-css', defined( 'BLOCKS_CSS_OTTER' ) ? 'otter-blocks' : 'blocks-css' );

wp_enqueue_style(
'otter-css',
5 changes: 3 additions & 2 deletions inc/class-blocks-export-import.php
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ public function init() {
if ( ! defined( 'BLOCKS_EXPORT_IMPORT_URL' ) ) {
define( 'BLOCKS_EXPORT_IMPORT_URL', OTTER_BLOCKS_URL );
define( 'BLOCKS_EXPORT_IMPORT_PATH', OTTER_BLOCKS_PATH );
define( 'BLOCKS_EXPORT_OTTER', true );
}

add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_editor_assets' ), 1 );
@@ -47,8 +48,8 @@ public function enqueue_editor_assets() {
$asset_file['version'],
true
);
wp_set_script_translations( 'blocks-export-import', 'blocks-export-import' );

wp_set_script_translations( 'blocks-export-import', defined( 'BLOCKS_EXPORT_OTTER' ) ? 'otter-blocks' : 'blocks-export-import' );
}

/**
4 changes: 2 additions & 2 deletions inc/css/class-block-frontend.php
Original file line number Diff line number Diff line change
@@ -700,7 +700,7 @@ public static function instance() {
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'otter-blocks' ), '1.0.0' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'blocks-css' ), '1.0.0' );
}

/**
@@ -712,6 +712,6 @@ public function __clone() {
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'otter-blocks' ), '1.0.0' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'blocks-css' ), '1.0.0' );
}
}
12 changes: 6 additions & 6 deletions inc/css/class-css-handler.php
Original file line number Diff line number Diff line change
@@ -136,7 +136,7 @@ public function register_routes() {
'id' => array(
'type' => 'integer',
'required' => true,
'description' => __( 'ID of the Post.', 'otter-blocks' ),
'description' => __( 'ID of the Post.', 'blocks-css' ),
'validate_callback' => function ( $param, $request, $key ) {
return is_numeric( $param );
},
@@ -160,7 +160,7 @@ public function register_routes() {
'id' => array(
'type' => 'integer',
'required' => true,
'description' => __( 'ID of the Reusable Block.', 'otter-blocks' ),
'description' => __( 'ID of the Reusable Block.', 'blocks-css' ),
'validate_callback' => function ( $param, $request, $key ) {
return is_numeric( $param );
},
@@ -224,7 +224,7 @@ public function save_post_meta( \WP_REST_Request $request ) {

self::mark_review_block_metadata( $post_id );

return rest_ensure_response( array( 'message' => __( 'CSS updated.', 'otter-blocks' ) ) );
return rest_ensure_response( array( 'message' => __( 'CSS updated.', 'blocks-css' ) ) );
}

/**
@@ -311,7 +311,7 @@ public function save_block_meta( \WP_REST_Request $request ) {

self::mark_review_block_metadata( $post_id );

return rest_ensure_response( array( 'message' => __( 'CSS updated.', 'otter-blocks' ) ) );
return rest_ensure_response( array( 'message' => __( 'CSS updated.', 'blocks-css' ) ) );
}

/**
@@ -598,7 +598,7 @@ public static function instance() {
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'otter-blocks' ), '1.0.0' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'blocks-css' ), '1.0.0' );
}

/**
@@ -610,6 +610,6 @@ public function __clone() {
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'otter-blocks' ), '1.0.0' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin&#8217; huh?', 'blocks-css' ), '1.0.0' );
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
"prod:lite": "wp-scripts build --config webpack.config.js",
"prod:pro": "wp-scripts build --config webpack.config.pro.js",
"prod:grunt": "grunt build",
"grunt:version": "grunt version",
"start": "rm -rf build && npm-run-all --parallel dev:*",
"dev:lite": "wp-scripts start --config webpack.config.js",
"dev:pro": "wp-scripts start --config webpack.config.pro.js",
@@ -42,7 +43,7 @@
"lint:php": "wp-env run --env-cwd='wp-content/plugins/otter-blocks' cli composer run-script lint",
"format:php": "wp-env run --env-cwd='wp-content/plugins/otter-blocks' cli composer run-script format",
"wp-env": "wp-env",
"build:makepot": "docker run --user root --rm --volume \"$(pwd):/var/www/html/otter-blocks\" wordpress:cli bash -c 'php -d memory_limit=512M \"$(which wp)\" --version --allow-root && wp i18n make-pot otter-blocks ./otter-blocks/languages/otter-pro.pot --include=src/pro,otter-pro,build/pro --allow-root --headers={\\\"Last-Translator\\\":\\\"[email protected]\\\"\\,\\\"Report-Msgid-Bugs-To\\\":\\\"https://github.com/Codeinwp/otter-blocks/issues\\\"\\,\\\"Project-Id-Version\\\":\\\"Otter-Blocks\\\"\\,\\\"POT-Creation-Date\\\":\\\"\\\"}'"
"build:makepot": "docker run --user root --rm --volume \"$(pwd):/var/www/html/otter-blocks\" wordpress:cli bash -c 'php -d memory_limit=512M \"$(which wp)\" --version --allow-root && wp i18n make-pot otter-blocks ./otter-blocks/languages/otter-pro.pot --include=\"otter-pro,build/pro,inc\" --allow-root --domain=otter-pro --headers={\\\"Last-Translator\\\":\\\"[email protected]\\\"\\,\\\"Report-Msgid-Bugs-To\\\":\\\"https://github.com/Codeinwp/otter-blocks/issues\\\"\\,\\\"Project-Id-Version\\\":\\\"Otter-Blocks\\\"\\,\\\"POT-Creation-Date\\\":\\\"\\\"}'"
},
"repository": {
"type": "git",
39 changes: 39 additions & 0 deletions phpcs.export.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0"?>
<ruleset name="">
<description>ThemeIsle ruleset</description>

<rule ref="WordPress-VIP-Go" />

<rule ref="WordPress-Core" />

<rule ref="WordPress-Docs" />

<rule ref="WordPress-Extra">
<!-- Forget about file names -->
<exclude name="WordPress.Files.FileName" />
</rule>


<config name="testVersion" value="5.6-" />

<rule ref="PHPCompatibility" />

<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array">
<element value="otter-blocks" />
</property>
</properties>
</rule>

<rule ref="WordPress.Utils.I18nTextDomainFixer">
<properties>
<property name="old_text_domain"
value="blocks-animation,blocks-import-export,otter-pro,blocks-css" />
<property name="new_text_domain" value="otter-blocks" />
</properties>
</rule>

<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>build/*</exclude-pattern>
</ruleset>
Loading
Loading