1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
<?php
final class Papi_Admin_Assets {
public function __construct() {
add_action( 'admin_enqueue_scripts', [$this, 'enqueue_css'] );
add_action( 'admin_enqueue_scripts', [$this, 'enqueue_js'] );
add_action( 'admin_enqueue_scripts', [$this, 'enqueue_locale'] );
}
public function enqueue_css() {
wp_enqueue_media();
wp_enqueue_style( 'wp-color-picker' );
wp_enqueue_style(
'papi-main',
dirname( PAPI_PLUGIN_URL ) . '/dist/css/style.min.css',
false,
null
);
}
public function enqueue_js() {
if ( strpos( $_SERVER['REQUEST_URI'], 'plugins.php' ) !== false ) {
return;
}
wp_enqueue_script(
'papi-main',
dirname( PAPI_PLUGIN_URL ) . '/dist/js/main.min.js',
[
'json2',
'jquery',
'jquery-ui-core',
'jquery-ui-sortable',
'wp-color-picker'
],
'',
true
);
}
public function enqueue_locale() {
wp_localize_script( 'papi-main', 'papiL10n', [
'remove' => __( 'Remove', 'papi' ),
'requiredError' => __( 'This fields are required:', 'papi' ),
] );
}
}
if ( is_admin() ) {
new Papi_Admin_Assets;
}