Skip to content

Commit bdfc923

Browse files
Swap __FILE__ references to JETPACK__PLUGIN_FILE
This will enable easier migration of files to a subdirectory to keep the root cleaner, without messing up path location of files.
1 parent a842f4b commit bdfc923

8 files changed

+33
-26
lines changed

class.jetpack-client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static function remote_request( $args, $body = null ) {
4545

4646
$token_key = sprintf( '%s:%d:%d', $token_key, JETPACK__API_VERSION, $token->external_user_id );
4747

48-
require_once dirname( __FILE__ ) . '/class.jetpack-signature.php';
48+
require_once JETPACK__PLUGIN_DIR . 'class.jetpack-signature.php';
4949

5050
$time_diff = (int) Jetpack_Options::get_option( 'time_diff' );
5151
$jetpack_signature = new Jetpack_Signature( $token->secret, $time_diff );

class.jetpack-modules-list-table.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ function __construct() {
1717

1818
wp_register_script(
1919
'models.jetpack-modules',
20-
plugins_url( '_inc/jetpack-modules.models.js', __FILE__ ),
20+
plugins_url( '_inc/jetpack-modules.models.js', JETPACK__PLUGIN_FILE ),
2121
array( 'backbone', 'underscore' ),
2222
JETPACK__VERSION
2323
);
2424
wp_register_script(
2525
'views.jetpack-modules',
26-
plugins_url( '_inc/jetpack-modules.views.js', __FILE__ ),
26+
plugins_url( '_inc/jetpack-modules.views.js', JETPACK__PLUGIN_FILE ),
2727
array( 'backbone', 'underscore', 'wp-util' ),
2828
JETPACK__VERSION
2929
);
3030
wp_register_script(
3131
'jetpack-modules-list-table',
32-
plugins_url( '_inc/jetpack-modules.js', __FILE__ ),
32+
plugins_url( '_inc/jetpack-modules.js', JETPACK__PLUGIN_FILE ),
3333
array(
3434
'views.jetpack-modules',
3535
'models.jetpack-modules',

class.jetpack-network.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public function get_url( $args ) {
257257
public function add_network_admin_menu() {
258258
add_action( 'admin_print_styles', array( $this, 'network_admin_styles' ) );
259259

260-
add_menu_page(__('Jetpack', 'jetpack'), __('Jetpack', 'jetpack'), 'read', 'jetpack', array($this, 'network_admin_page'), 'div', 3);
260+
add_menu_page( __('Jetpack', 'jetpack'), __('Jetpack', 'jetpack'), 'read', 'jetpack', array($this, 'network_admin_page'), 'div', 3);
261261
add_submenu_page('jetpack', __('Jetpack Sites', 'jetpack'), __('Sites', 'jetpack'), 'manage_options', 'jetpack', array($this, 'network_admin_page'));
262262
add_submenu_page('jetpack', __('Settings', 'jetpack'), __('Settings', 'jetpack'), 'read', 'jetpack-settings', array($this, 'render_network_admin_settings_page'));
263263

@@ -269,8 +269,9 @@ public function add_network_admin_menu() {
269269
require_once( JETPACK__PLUGIN_DIR . '_inc/genericons.php' );
270270
jetpack_register_genericons();
271271

272-
if ( ! wp_style_is( 'jetpack-icons', 'registered' ) )
273-
wp_register_style( 'jetpack-icons', plugins_url( '_inc/jetpack-icons.min.css', __FILE__ ), false, JETPACK__VERSION );
272+
if ( ! wp_style_is( 'jetpack-icons', 'registered' ) ) {
273+
wp_register_style( 'jetpack-icons', plugins_url( '_inc/jetpack-icons.min.css', JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION );
274+
}
274275

275276
add_action( 'admin_enqueue_scripts', array( $this, 'admin_menu_css' ) );
276277
}

class.jetpack-sync.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public function reindex_trigger() {
721721
$response = array( 'status' => 'ERROR' );
722722

723723
// Force a privacy check
724-
Jetpack::check_privacy( __FILE__ );
724+
Jetpack::check_privacy( JETPACK__PLUGIN_FILE );
725725

726726
Jetpack::load_xml_rpc_client();
727727
$client = new Jetpack_IXR_Client( array(
@@ -785,7 +785,7 @@ public function reindex_ui() {
785785

786786
wp_enqueue_script(
787787
'jetpack_sync_reindex_control',
788-
plugins_url( '_inc/jquery.jetpack-sync.js', __FILE__ ),
788+
plugins_url( '_inc/jquery.jetpack-sync.js', JETPACK__PLUGIN_FILE ),
789789
array( 'jquery' ),
790790
JETPACK__VERSION
791791
);

class.jetpack-xmlrpc-server.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,10 +367,10 @@ function json_api( $args = array() ) {
367367
// needed?
368368
require_once ABSPATH . 'wp-admin/includes/admin.php';
369369

370-
require_once dirname( __FILE__ ) . '/class.json-api.php';
370+
require_once JETPACK__PLUGIN_DIR . 'class.json-api.php';
371371
$api = WPCOM_JSON_API::init( $method, $url, $post_body );
372372
$api->token_details['user'] = $user_details;
373-
require_once dirname( __FILE__ ) . '/class.json-api-endpoints.php';
373+
require_once JETPACK__PLUGIN_DIR . 'class.json-api-endpoints.php';
374374

375375
$display_errors = ini_set( 'display_errors', 0 );
376376
ob_start();

class.jetpack.php

+17-12
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ function require_jetpack_authentication() {
527527
* Load language files
528528
*/
529529
public static function plugin_textdomain() {
530-
load_plugin_textdomain( 'jetpack', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
530+
// Note to self, the third argument must not be hardcoded, to account for relocated folders.
531+
load_plugin_textdomain( 'jetpack', false, dirname( plugin_basename( JETPACK__PLUGIN_FILE ) ) . '/languages/' );
531532
}
532533

533534
/**
@@ -538,14 +539,17 @@ public static function plugin_textdomain() {
538539
* @return null
539540
*/
540541
public function register_assets() {
541-
if ( ! wp_script_is( 'spin', 'registered' ) )
542-
wp_register_script( 'spin', plugins_url( '_inc/spin.js', __FILE__ ), false, '1.3' );
542+
if ( ! wp_script_is( 'spin', 'registered' ) ) {
543+
wp_register_script( 'spin', plugins_url( '_inc/spin.js', JETPACK__PLUGIN_FILE ), false, '1.3' );
544+
}
543545

544-
if ( ! wp_script_is( 'jquery.spin', 'registered' ) )
545-
wp_register_script( 'jquery.spin', plugins_url( '_inc/jquery.spin.js', __FILE__ ) , array( 'jquery', 'spin' ), '1.3' );
546+
if ( ! wp_script_is( 'jquery.spin', 'registered' ) ) {
547+
wp_register_script( 'jquery.spin', plugins_url( '_inc/jquery.spin.js', JETPACK__PLUGIN_FILE ) , array( 'jquery', 'spin' ), '1.3' );
548+
}
546549

547-
if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) )
548-
wp_register_script( 'jetpack-gallery-settings', plugins_url( '_inc/gallery-settings.js', __FILE__ ), array( 'media-views' ), '20121225' );
550+
if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) ) {
551+
wp_register_script( 'jetpack-gallery-settings', plugins_url( '_inc/gallery-settings.js', JETPACK__PLUGIN_FILE ), array( 'media-views' ), '20121225' );
552+
}
549553

550554
/**
551555
* As jetpack_register_genericons is by default fired off a hook,
@@ -555,8 +559,9 @@ public function register_assets() {
555559
require_once( JETPACK__PLUGIN_DIR . '_inc/genericons.php' );
556560
jetpack_register_genericons();
557561

558-
if ( ! wp_style_is( 'jetpack-icons', 'registered' ) )
559-
wp_register_style( 'jetpack-icons', plugins_url( '_inc/jetpack-icons.min.css', __FILE__ ), false, JETPACK__VERSION );
562+
if ( ! wp_style_is( 'jetpack-icons', 'registered' ) ) {
563+
wp_register_style( 'jetpack-icons', plugins_url( '_inc/jetpack-icons.min.css', JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION );
564+
}
560565
}
561566

562567
/**
@@ -2136,12 +2141,12 @@ function admin_banner_styles() {
21362141

21372142
$min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
21382143

2139-
wp_enqueue_style( 'jetpack', plugins_url( "_inc/jetpack-banners{$min}.css", __FILE__ ), false, JETPACK__VERSION . '-20121016' );
2144+
wp_enqueue_style( 'jetpack', plugins_url( "_inc/jetpack-banners{$min}.css", JETPACK__PLUGIN_FILE ), false, JETPACK__VERSION . '-20121016' );
21402145
$wp_styles->add_data( 'jetpack', 'rtl', true );
21412146
}
21422147

21432148
function admin_scripts() {
2144-
wp_enqueue_script( 'jetpack-js', plugins_url( '_inc/jp.js', __FILE__ ), array( 'jquery', 'wp-util' ), JETPACK__VERSION . '-20121111' );
2149+
wp_enqueue_script( 'jetpack-js', plugins_url( '_inc/jp.js', JETPACK__PLUGIN_FILE ), array( 'jquery', 'wp-util' ), JETPACK__VERSION . '-20121111' );
21452150
wp_localize_script(
21462151
'jetpack-js',
21472152
'jetpackL10n',
@@ -3144,7 +3149,7 @@ function admin_page() {
31443149
</div>
31453150

31463151
<div id="jetpack-configuration" style="display:none;">
3147-
<p><img width="16" src="<?php echo esc_url( plugins_url( '_inc/images/wpspin_light-2x.gif', __FILE__ ) ); ?>" alt="Loading ..." /></p>
3152+
<p><img width="16" src="<?php echo esc_url( plugins_url( '_inc/images/wpspin_light-2x.gif', JETPACK__PLUGIN_FILE ) ); ?>" alt="Loading ..." /></p>
31483153
</div>
31493154
</div>
31503155
<?php

class.photon.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,6 @@ function filter_open_graph_tags( $tags, $parameters ) {
589589
* @return null
590590
*/
591591
public function action_wp_enqueue_scripts() {
592-
wp_enqueue_script( 'jetpack-photon', plugins_url( 'modules/photon/photon.js', __FILE__ ), array( 'jquery' ), 20130122, true );
592+
wp_enqueue_script( 'jetpack-photon', plugins_url( 'modules/photon/photon.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), 20130122, true );
593593
}
594594
}

functions.gallery.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ function admin_init() {
2222
* Registers/enqueues the gallery settings admin js.
2323
*/
2424
function wp_enqueue_media() {
25-
if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) )
26-
wp_register_script( 'jetpack-gallery-settings', plugins_url( 'gallery-settings/gallery-settings.js', __FILE__ ), array( 'media-views' ), '20121225' );
25+
if ( ! wp_script_is( 'jetpack-gallery-settings', 'registered' ) ) {
26+
wp_register_script( 'jetpack-gallery-settings', plugins_url( '_inc/gallery-settings.js', JETPACK__PLUGIN_FILE ), array( 'media-views' ), '20121225' );
27+
}
2728

2829
wp_enqueue_script( 'jetpack-gallery-settings' );
2930
}

0 commit comments

Comments
 (0)