Requesting data in Gutenberg with getEntityRecords

WordPress provides a number of ways to retrieve data in Gutenbergs, one way I really like is the getEntityRecords selector. I have started using it more and more recently and find it great to use in my custom blocks.

Unfortunately, the documentation is a little sparse and there are some things to consider when working with it. However, once you start using it and its relatives, I think you’ll agree that it’s a great choice!

(more…)

Continue ReadingRequesting data in Gutenberg with getEntityRecords

Restricting PluginDocumentSettingPanel by post type

Now that the PluginDocumentSettingPanel is in WordPress core, we can add our own panels to the Document Settings panel using the registerPlugin function.

const { registerPlugin } = wp.plugins;
const { PluginDocumentSettingPanel } = wp.editPost;

const MyCustomSideBarPanel = () => (
    <PluginDocumentSettingPanel
        name="my-custom-panel"
        title="My Custom Panel"
    >
        Hello, World!
    </PluginDocumentSettingPanel>
);
registerPlugin( 'my-custom-panel', {render: MyCustomSideBarPanel } );

The above code will insert a new Panel in the Document Sidebar with the title of My Custom Panel ” and will display “Hello, World!” as it’s content. If we want this panel to appear on every post type registered, then we’re done but what if we want to restrict this panel to just a single post type?

(more…)

Continue ReadingRestricting PluginDocumentSettingPanel by post type

Thanks Adam!

Wordpress 4.7 was just released and it marks the sixth release in a row that I have been lucky enough to contribute to. Contributing to WordPress core has always been a…

Continue ReadingThanks Adam!

Should we trust WordPress Core translations?

A while ago I was working on a patch to refresh the code for the default widgets that are included with WordPress Core. One of the changes made was to replace the i18n methods currently in-place with their counterparts that escape and translate the output. This is a pretty common practice as translation files can be a potential attack vector for hackers. WordPress.com VIP will usually request that this is added to any strings being translated and it is part of the 10up best practices. (more…)

Continue ReadingShould we trust WordPress Core translations?