Add coexistence checks to all enqueue methods to prevent loading both React and Grid.js assets simultaneously. Changes: - ReactAdmin.php: Only enqueue React assets when ?react=1 - Init.php: Skip Grid.js when React active on admin pages - Form.php, Coupon.php, Access.php: Restore classic assets when ?react=0 - Customer.php, Product.php, License.php: Add coexistence checks Now the toggle between Classic and React versions works correctly. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
60 lines
1.2 KiB
JavaScript
60 lines
1.2 KiB
JavaScript
/**
|
|
* Internal dependencies
|
|
*/
|
|
const {
|
|
TRANSLATION_FUNCTIONS,
|
|
REGEXP_SPRINTF_PLACEHOLDER,
|
|
getTextContentFromNode,
|
|
getTranslateFunctionName,
|
|
getTranslateFunctionArgs,
|
|
} = require( '../utils' );
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
schema: [],
|
|
messages: {
|
|
noPlaceholdersOnly:
|
|
'Translatable strings should not contain nothing but placeholders',
|
|
},
|
|
},
|
|
create( context ) {
|
|
return {
|
|
CallExpression( node ) {
|
|
const { callee, arguments: args } = node;
|
|
|
|
const functionName = getTranslateFunctionName( callee );
|
|
|
|
if ( ! TRANSLATION_FUNCTIONS.has( functionName ) ) {
|
|
return;
|
|
}
|
|
|
|
const candidates = getTranslateFunctionArgs(
|
|
functionName,
|
|
args
|
|
);
|
|
|
|
for ( const arg of candidates ) {
|
|
const argumentString = getTextContentFromNode( arg );
|
|
if ( ! argumentString ) {
|
|
continue;
|
|
}
|
|
|
|
const modifiedString = argumentString
|
|
.replace( /%%/g, 'VALID_ESCAPED_PERCENTAGE_SIGN' )
|
|
.replace( REGEXP_SPRINTF_PLACEHOLDER, '' );
|
|
|
|
if ( modifiedString.length > 0 ) {
|
|
continue;
|
|
}
|
|
|
|
context.report( {
|
|
node,
|
|
messageId: 'noPlaceholdersOnly',
|
|
} );
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|