Skip to content

Commit

Permalink
Moved obfuscation comments to a php doc comment
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonjd committed Mar 21, 2022
1 parent 0319a9a commit 0fcafbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
13 changes: 0 additions & 13 deletions lib/block-supports/spacing.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ function gutenberg_apply_spacing_support( $block_type, $block_attributes ) {
$style_engine = WP_Style_Engine_Gutenberg::get_instance();

if ( $has_padding_support ) {
/*
// We can also return an obfuscated classname.
// Do we need to add !important rules to the stylesheet in this case
// seeing as they're not inline?
$classes[] = $style_engine->add_style_from_attributes(
'wp-block-supports',
$attributes_styles,
array( 'spacing', 'padding' ),
array(
'obfuscate' => true,
)
);
*/
$padding_styles = $style_engine->get_inline_styles_from_attributes(
$block_styles,
array( 'spacing', 'padding' )
Expand Down
11 changes: 8 additions & 3 deletions lib/style-engine/class-wp-style-engine-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,16 @@ public function get_generated_styles() {

/**
* Stores style rules for a given CSS selector (the key) and returns an associated classname.
* Accepts an array of options, rules, and selector for constructing the rules.
*
* @param string $key A class name used to construct a key.
* @param array $options An array of options, rules, and selector for constructing the rules.
* @param array $options = array(
* 'prefix' => (string) An optional beginning classname fragment, such as selector syntax, e.g., `#`
* 'suffix' => (string) An optional ending classname fragment.
* 'selector' => (string) An optional CSS selector for specificity, e.g., `> p`.
* 'rules' => (array) An array of valid CSS rules, e.g., array( 'padding-top' => '1em', 'color' => 'pink' ).
* 'obfuscate' => (boolean) Whether to hash the classname.
* );.
*
* @return string The class name for the added style.
*/
Expand All @@ -138,8 +145,6 @@ public function add_style( $key, $options ) {
if ( ! empty( $options['obfuscate'] ) && true === $options['obfuscate'] ) {
// Generate a consistent, obfuscated key by hashing a unique class based on the rules.
// Outputs something like .wp-my-key__002d308c.
// Will we ever need to decode/decrypt the classname?
// If so, look at openssl_encrypt().
$class = $key . '__' . hash( 'crc32', $class );
}

Expand Down

0 comments on commit 0fcafbe

Please sign in to comment.