[wp-meta] [Making WordPress.org] #5513: Registered blocks list on plugins README displaying wrong labels.
Making WordPress.org
noreply at wordpress.org
Tue Nov 17 22:22:13 UTC 2020
#5513: Registered blocks list on plugins README displaying wrong labels.
------------------------------+---------------------
Reporter: wetah | Owner: (none)
Type: defect | Status: new
Priority: normal | Milestone:
Component: Plugin Directory | Resolution:
Keywords: |
------------------------------+---------------------
Comment (by wetah):
Replying to [comment:1 Otto42]:
Hey, thank you for the quick reply! Yes, we minimize our javascript, where
the registerBlockType function is called. But that really has been done
the same way in the last versions...
I checked the code that you linked. In this line:
https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html
/wp-content/plugins/plugin-directory/cli/class-import.php#L739
Where the regex matches the content, there is this
{{{
"#registerBlockType[^{}]{0,500}[(]\s*[\"']([-\w]+/[-\w]+)[\"']\s*,\s*[{]\s*title\s*:[\s\w(]*[\"']([^\"']*)[\"']#ms"
}}}
Now, I am a total noobie on ReGex, please don't judge me. But trying a bit
on this playground: https://regex101.com/, it seems that if I paste:
{{{
registerBlockType[^{}]{0,500}[(]\s*[\"']([-\w]+/[-\w]+)[\"']\s*,\s*[{]\s*title\s*:[\s\w(]*[\"']([^\"']*)[\"']
}}}
They explain me an error: ''"/ An unescaped delimiter must be escaped with
a backslash (\)"''. So updating the pattern to:
{{{
registerBlockType[^{}]{0,500}[(]\s*[\"']([-\w]+\/[-\w]+)[\"']\s*,\s*[{]\s*title\s*:[\s\w(]*[\"']([^\"']*)[\"']
}}}
It was able to detect my blocks names, even in the minified js. Does it
sounds correct or am I being naive?
> It is possible that it is not recognizing the blocks from the
registerBlockType call because your JS code is compressed and unreadable.
>
> Where are the calls to the registerBlockType function in the plugin, for
these blocks? If it can't find the title of the block, then it defaults
the title to the name of the plugin.
>
> The code to find the blocks in the plugin is complex, but public:
>
https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html
/wp-content/plugins/plugin-directory/cli/class-import.php#L729
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/5513#comment:2>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list