Skip to content

Instantly share code, notes, and snippets.

Anton Timmermans atimmer

Block or report user

Report or block atimmer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View externals.md

Gutenberg externals

All packages that the modern WordPress JavaScript uses are available as @wordpress/ packages. This means that a simple npm install @wordpress/data will get you the data module. The same that is used in WordPress. The challenge with this is that this code will be duplicated between WordPress and your plugin. Bundlers like webpack and browserify include all the code in @wordpress/data inside your built JavaScript file. To remedy this you can configure your bundler to use the available package from a global variable instead. For @wordpress/data this global is wp.data.

Your PHP configuration needs to be changed to accomodate this. When you use wp.data you need to make that script a dependency of your script. You can do this by providing it in the dependency array of wp_register_script:

wp_register_script( 'script-handle', 'path-to-script.js', array( 'wp-data' );
View Customer_On_All_Sites.php
<?php
namespace Yoast\YoastCom\Core\WordPress\Integration\WooCommerce;
use Yoast\YoastCom\Core\WordPress\Helper\Shop_Helper;
use Yoast\YoastCom\Core\WordPress\Integration;
use Yoast\YoastCom\Core\WordPress\Integration\Dependencies\Dependency;
use Yoast\YoastCom\Core\WordPress\Integration\Dependencies\WooCommerce_Dependency;
final class Customer_On_All_Sites implements Integration {
View create-yoast-seo-5.0-tables.sql
CREATE TABLE `wp_yoast_seo_links` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`post_id` bigint(20) unsigned NOT NULL,
`target_post_id` bigint(20) unsigned NOT NULL,
`type` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `link_direction` (`post_id`,`type`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
You can’t perform that action at this time.