Admin.php
3 weeks ago
AdminAbout.php
3 weeks ago
AdminAssets.php
3 weeks ago
AdminConvert.php
3 weeks ago
AdminCore.php
3 weeks ago
AdminDashboard.php
3 weeks ago
AdminIntegration.php
3 weeks ago
AdminPages.php
3 weeks ago
AdminSettings.php
3 weeks ago
AdminTools.php
3 weeks ago
AdminAssets.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPParsidate\Admin; |
| 4 | |
| 5 | defined( 'ABSPATH' ) || exit; |
| 6 | |
| 7 | use WPParsidate\Helper\{Assets, Nonce}; |
| 8 | |
| 9 | class AdminAssets { |
| 10 | public function __construct() { |
| 11 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueueScripts' ) ); |
| 12 | } |
| 13 | |
| 14 | public function enqueueScripts(): void { |
| 15 | if ( ! AdminPages::isSettingPage() ) { |
| 16 | return; |
| 17 | } |
| 18 | $pluginVersion = Assets::getVersion(); |
| 19 | $debugName = WP_PARSI_DEBUG_MODE ? '' : '.min'; |
| 20 | |
| 21 | //wp_enqueue_media(); |
| 22 | //wp_enqueue_style( 'wp-color-picker' ); |
| 23 | //wp_enqueue_script( 'wp-color-picker' ); |
| 24 | |
| 25 | wp_enqueue_style( WP_PARSI_KEY_SLUG . '-admin-style', |
| 26 | Assets::url( 'css-admin/admin-style' . $debugName . '.css' ), false, $pluginVersion ); |
| 27 | |
| 28 | wp_enqueue_script( WP_PARSI_KEY_SLUG . '-admin', |
| 29 | Assets::url( 'js-admin/script.min.js' ), |
| 30 | [ |
| 31 | 'jquery', |
| 32 | 'jquery-ui-sortable', |
| 33 | ], $pluginVersion, [ 'in_footer' => true ] ); |
| 34 | |
| 35 | wp_localize_script( WP_PARSI_KEY_SLUG . '-admin', WP_PARSI_KEY_CAP, array( |
| 36 | 'ajaxUrl' => admin_url( 'admin-ajax.php' ), |
| 37 | 'ajaxNonce' => Nonce::create(), |
| 38 | 'pageRefreshedAfter' => apply_filters( 'wp_parsidate_settings_page_refreshed_after', 0 ), |
| 39 | 'pageRefreshUrl' => apply_filters( 'wp_parsidate_settings_page_refresh_url', null ), |
| 40 | 'removeText' => esc_html__( 'Remove', 'wp-parsidate' ), |
| 41 | 'dtuConfirmDelete' => esc_html__( 'Are you sure you want to delete this item(s)?', 'wp-parsidate' ), |
| 42 | 'copyText' => esc_html__( 'Click to copy this text.', 'wp-parsidate' ), |
| 43 | ) ); |
| 44 | } |
| 45 | |
| 46 | public static function imageUrl( $path ): string { |
| 47 | return WP_PARSI_URL . 'assets/images/' . $path; |
| 48 | } |
| 49 | } |
| 50 |