Skip to content

Commit

Permalink
Statically access asset tools (#12744)
Browse files Browse the repository at this point in the history
Statically access asset tools (#12744)
  • Loading branch information
gravityrail authored and gititon committed Jun 21, 2019
1 parent 5f09806 commit 89a9af9
Show file tree
Hide file tree
Showing 62 changed files with 516 additions and 316 deletions.
4 changes: 3 additions & 1 deletion _inc/client/components/settings-card/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ export const SettingsCard = props => {
return (
<JetpackBanner
callToAction={ upgradeLabel }
title={ __( 'Connect your site to Google Analytics in seconds with Jetpack Premium or Professional.' ) }
title={ __(
'Connect your site to Google Analytics in seconds with Jetpack Premium or Professional.'
) }
plan={ PLAN_JETPACK_PREMIUM }
feature={ feature }
onClick={ handleClickForTracking( feature ) }
Expand Down
4 changes: 2 additions & 2 deletions _inc/client/my-plan/my-plan-header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class MyPlanHeader extends React.Component {
'Worried about security? Get backups, automated security fixes and more: {{a}}Upgrade now{{/a}}',
{
components: {
a: <UpgradeLink source="myplan-header-free-plan-text-link" />
}
a: <UpgradeLink source="myplan-header-free-plan-text-link" />,
},
}
) }
</p>
Expand Down
3 changes: 2 additions & 1 deletion _inc/lib/admin-pages/class.jetpack-settings-page.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Automattic\Jetpack\Tracking;
use Automattic\Jetpack\Assets;

include_once( 'class.jetpack-admin-page.php' );
include_once( JETPACK__PLUGIN_DIR . 'class.jetpack-modules-list-table.php' );
Expand Down Expand Up @@ -137,7 +138,7 @@ function additional_styles() {
function page_admin_scripts() {
wp_enqueue_script(
'jetpack-admin-js',
Jetpack::get_file_url_for_environment( '_inc/build/jetpack-admin.min.js', '_inc/jetpack-admin.js' ),
Assets::get_file_url_for_environment( '_inc/build/jetpack-admin.min.js', '_inc/jetpack-admin.js' ),
array( 'jquery' ),
JETPACK__VERSION
);
Expand Down
3 changes: 2 additions & 1 deletion class.jetpack-connection-banner.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use Automattic\Jetpack\Assets\Logo;
use Automattic\Jetpack\Assets;

class Jetpack_Connection_Banner {
/**
Expand Down Expand Up @@ -105,7 +106,7 @@ function maybe_initialize_hooks( $current_screen ) {
public static function enqueue_banner_scripts() {
wp_enqueue_script(
'jetpack-connection-banner-js',
Jetpack::get_file_url_for_environment(
Assets::get_file_url_for_environment(
'_inc/build/jetpack-connection-banner.min.js',
'_inc/jetpack-connection-banner.js'
),
Expand Down
3 changes: 2 additions & 1 deletion class.jetpack-idc.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Automattic\Jetpack\Assets;
use Automattic\Jetpack\Logo as Jetpack_Logo;

/**
Expand Down Expand Up @@ -256,7 +257,7 @@ function enqueue_idc_notice_files() {

wp_enqueue_script(
'jetpack-idc-js',
Jetpack::get_file_url_for_environment( '_inc/build/idc-notice.min.js', '_inc/idc-notice.js' ),
Assets::get_file_url_for_environment( '_inc/build/idc-notice.min.js', '_inc/idc-notice.js' ),
array( 'jquery' ),
JETPACK__VERSION,
true
Expand Down
8 changes: 5 additions & 3 deletions class.jetpack-modules-list-table.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Automattic\Jetpack\Assets;

if ( ! class_exists( 'WP_List_Table' ) )
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';

Expand Down Expand Up @@ -29,7 +31,7 @@ function __construct() {

wp_register_script(
'models.jetpack-modules',
Jetpack::get_file_url_for_environment(
Assets::get_file_url_for_environment(
'_inc/build/jetpack-modules.models.min.js',
'_inc/jetpack-modules.models.js'
),
Expand All @@ -38,7 +40,7 @@ function __construct() {
);
wp_register_script(
'views.jetpack-modules',
Jetpack::get_file_url_for_environment(
Assets::get_file_url_for_environment(
'_inc/build/jetpack-modules.views.min.js',
'_inc/jetpack-modules.views.js'
),
Expand All @@ -47,7 +49,7 @@ function __construct() {
);
wp_register_script(
'jetpack-modules-list-table',
Jetpack::get_file_url_for_environment(
Assets::get_file_url_for_environment(
'_inc/build/jetpack-modules.min.js',
'_inc/jetpack-modules.js'
),
Expand Down
17 changes: 7 additions & 10 deletions class.jetpack.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Automattic\Jetpack\Sync\Sender;
use Automattic\Jetpack\Sync\Users;
use Automattic\Jetpack\Tracking;
use Automattic\Jetpack\Assets;

/*
Options:
Expand Down Expand Up @@ -1086,7 +1087,7 @@ public function register_assets() {
if ( ! wp_script_is( 'spin', 'registered' ) ) {
wp_register_script(
'spin',
self::get_file_url_for_environment( '_inc/build/spin.min.js', '_inc/spin.js' ),
Assets::get_file_url_for_environment( '_inc/build/spin.min.js', '_inc/spin.js' ),
false,
'1.3'
);
Expand All @@ -1095,7 +1096,7 @@ public function register_assets() {
if ( ! wp_script_is( 'jquery.spin', 'registered' ) ) {
wp_register_script(
'jquery.spin',
self::get_file_url_for_environment( '_inc/build/jquery.spin.min.js', '_inc/jquery.spin.js' ),
Assets::get_file_url_for_environment( '_inc/build/jquery.spin.min.js', '_inc/jquery.spin.js' ),
array( 'jquery', 'spin' ),
'1.3'
);
Expand All @@ -1104,7 +1105,7 @@ public function register_assets() {
if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) ) {
wp_register_script(
'jetpack-gallery-settings',
self::get_file_url_for_environment( '_inc/build/gallery-settings.min.js', '_inc/gallery-settings.js' ),
Assets::get_file_url_for_environment( '_inc/build/gallery-settings.min.js', '_inc/gallery-settings.js' ),
array( 'media-views' ),
'20121225'
);
Expand All @@ -1113,7 +1114,7 @@ public function register_assets() {
if ( ! wp_script_is( 'jetpack-twitter-timeline', 'registered' ) ) {
wp_register_script(
'jetpack-twitter-timeline',
self::get_file_url_for_environment( '_inc/build/twitter-timeline.min.js', '_inc/twitter-timeline.js' ),
Assets::get_file_url_for_environment( '_inc/build/twitter-timeline.min.js', '_inc/twitter-timeline.js' ),
array( 'jquery' ),
'4.0.0',
true
Expand All @@ -1123,7 +1124,7 @@ public function register_assets() {
if ( ! wp_script_is( 'jetpack-facebook-embed', 'registered' ) ) {
wp_register_script(
'jetpack-facebook-embed',
self::get_file_url_for_environment( '_inc/build/facebook-embed.min.js', '_inc/facebook-embed.js' ),
Assets::get_file_url_for_environment( '_inc/build/facebook-embed.min.js', '_inc/facebook-embed.js' ),
array( 'jquery' ),
null,
true
Expand Down Expand Up @@ -6993,11 +6994,7 @@ public static function is_function_in_backtrace( $names ) {
* @return string The URL to the file
*/
public static function get_file_url_for_environment( $min_path, $non_min_path ) {
$path = ( Constants::is_defined( 'SCRIPT_DEBUG' ) && Constants::get_constant( 'SCRIPT_DEBUG' ) )
? $non_min_path
: $min_path;

return plugins_url( $path, JETPACK__PLUGIN_FILE );
return Assets::get_file_url_for_environment( $min_path, $non_min_path );
}

/**
Expand Down
4 changes: 3 additions & 1 deletion class.photon.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Automattic\Jetpack\Assets;

class Jetpack_Photon {
/**
* Class variables
Expand Down Expand Up @@ -1184,7 +1186,7 @@ public function action_wp_enqueue_scripts() {
}
wp_enqueue_script(
'jetpack-photon',
Jetpack::get_file_url_for_environment(
Assets::get_file_url_for_environment(
'_inc/build/photon/photon.min.js',
'modules/photon/photon.js'
),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"automattic/jetpack-logo": "@dev",
"automattic/jetpack-constants": "@dev",
"automattic/jetpack-jitm": "@dev",
"automattic/jetpack-asset-tools": "@dev",
"automattic/jetpack-assets": "@dev",
"automattic/jetpack-sync": "@dev",
"automattic/jetpack-tracking": "@dev",
"automattic/jetpack-autoloader": "@dev"
Expand Down
Loading

0 comments on commit 89a9af9

Please sign in to comment.