Skip to content

Commit

Permalink
Merge comments component back into navigation component.
Browse files Browse the repository at this point in the history
  • Loading branch information
miina committed Oct 31, 2018
1 parent 8c5dd63 commit 544a747
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 156 deletions.
1 change: 0 additions & 1 deletion pwa.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@

/** WP_Service_Worker_Component Implementation Classes */
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-configuration-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-offline-commenting-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-navigation-routing-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-precaching-routes-component.php';
require_once PWA_PLUGIN_DIR . '/wp-includes/components/class-wp-service-worker-precaching-routes.php';
Expand Down
1 change: 0 additions & 1 deletion wp-includes/class-wp-service-workers.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public function __construct() {
'navigation_routing' => new WP_Service_Worker_Navigation_Routing_Component(),
'precaching_routes' => new WP_Service_Worker_Precaching_Routes_Component(),
'caching_routes' => new WP_Service_Worker_Caching_Routes_Component(),
'offline_commenting' => new WP_Service_Worker_Offline_Commenting_Component(),
);

$this->scripts = new WP_Service_Worker_Scripts( $components );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,19 @@ public function serve( WP_Service_Worker_Scripts $scripts ) {
);
}

$scripts->register(
'wp-offline-commenting',
array(
'src' => array( $this, 'get_offline_commenting_script' ),
'deps' => array( 'wp-base-config' ),
)
);

$scripts->register(
'wp-navigation-routing',
array(
'src' => array( $this, 'get_script' ),
'deps' => array( 'wp-base-config' ),
'deps' => array( 'wp-base-config', 'wp-offline-commenting' ),
)
);

Expand Down Expand Up @@ -485,4 +493,20 @@ public function get_script() {
$script
);
}

/**
* Get script for offline commenting requests.
*
* @return string Script.
*/
public function get_offline_commenting_script() {
$script = file_get_contents( PWA_PLUGIN_DIR . '/wp-includes/js/service-worker-offline-commenting.js' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
$script = preg_replace( '#/\*\s*global.+?\*/#', '', $script );

return str_replace(
array_keys( $this->replacements ),
array_values( $this->replacements ),
$script
);
}
}

This file was deleted.

0 comments on commit 544a747

Please sign in to comment.