Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 2 |
CRAP | n/a |
0 / 0 |
|
| should_load_override_preview_button_url | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
20 | |||
| wpcom_enqueue_override_preview_button_url_assets | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Apply the new font-smoothing styles. |
| 4 | * |
| 5 | * @package automattic/jetpack-mu-wpcom |
| 6 | */ |
| 7 | |
| 8 | use Automattic\Jetpack\Jetpack_Mu_Wpcom; |
| 9 | |
| 10 | /** |
| 11 | * Check if the feature should be loaded. |
| 12 | * |
| 13 | * @return bool |
| 14 | */ |
| 15 | function should_load_override_preview_button_url() { |
| 16 | if ( ! class_exists( 'Automattic\Jetpack\Status\Host' ) ) { |
| 17 | return false; |
| 18 | } |
| 19 | |
| 20 | $host = new Automattic\Jetpack\Status\Host(); |
| 21 | if ( ! $host->is_wpcom_simple() ) { |
| 22 | return false; |
| 23 | } |
| 24 | |
| 25 | global $pagenow; |
| 26 | $allowed_pages = array( |
| 27 | 'post.php', |
| 28 | 'post-new.php', |
| 29 | ); |
| 30 | return isset( $pagenow ) && in_array( $pagenow, $allowed_pages, true ); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Enqueue assets |
| 35 | */ |
| 36 | function wpcom_enqueue_override_preview_button_url_assets() { |
| 37 | if ( ! should_load_override_preview_button_url() ) { |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | $asset_file = include Jetpack_Mu_Wpcom::BASE_DIR . 'build/override-preview-button-url/override-preview-button-url.asset.php'; |
| 42 | $script_dependencies = $asset_file['dependencies'] ?? array(); |
| 43 | $script_version = $asset_file['version'] ?? filemtime( Jetpack_Mu_Wpcom::BASE_DIR . 'build/override-preview-button-url/override-preview-button-url.js' ); |
| 44 | $script_id = 'wpcom-override-preview-button-url-script'; |
| 45 | |
| 46 | wp_enqueue_script( |
| 47 | $script_id, |
| 48 | plugins_url( 'build/override-preview-button-url/override-preview-button-url.js', Jetpack_Mu_Wpcom::BASE_FILE ), |
| 49 | $script_dependencies, |
| 50 | $script_version, |
| 51 | true |
| 52 | ); |
| 53 | } |
| 54 | add_action( 'admin_enqueue_scripts', 'wpcom_enqueue_override_preview_button_url_assets' ); |