| 1 |
<?php |
| 2 |
|
| 3 |
namespace ISC\Admin; |
| 4 |
|
| 5 |
use \ISC\Admin_Utils; |
| 6 |
|
| 7 |
/** |
| 8 |
* Add general admin scripts |
| 9 |
*/ |
| 10 |
class Admin_Scripts { |
| 11 |
|
| 12 |
/** |
| 13 |
* Constructor |
| 14 |
*/ |
| 15 |
public function __construct() { |
| 16 |
add_action( 'admin_enqueue_scripts', [ $this, 'add_admin_scripts' ] ); |
| 17 |
add_action( 'admin_print_scripts', [ $this, 'admin_head_scripts' ] ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Add scripts to ISC-related pages |
| 22 |
*/ |
| 23 |
public function add_admin_scripts() { |
| 24 |
$screen = get_current_screen(); |
| 25 |
|
| 26 |
if ( ! isset( $screen->id ) ) { |
| 27 |
return; |
| 28 |
} |
| 29 |
|
| 30 |
// Load CSS |
| 31 |
if ( Admin_Utils::is_isc_page() ) { |
| 32 |
wp_enqueue_style( 'isc_image_settings_css', ISCBASEURL . '/admin/assets/css/isc.css', false, ISCVERSION ); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Display scripts in <head></head> section of admin page. Useful for creating js variables in the js global namespace. |
| 38 |
*/ |
| 39 |
public function admin_head_scripts() { |
| 40 |
global $pagenow; |
| 41 |
$screen = get_current_screen(); |
| 42 |
// add style to plugin overview page |
| 43 |
if ( isset( $screen->id ) && $screen->id === 'plugins' ) { |
| 44 |
?> |
| 45 |
<style> |
| 46 |
.row-actions .isc-get-pro { |
| 47 |
font-weight: bold; |
| 48 |
color: #F70; |
| 49 |
} |
| 50 |
</style> |
| 51 |
<?php |
| 52 |
} |
| 53 |
// add to any backend pages |
| 54 |
?> |
| 55 |
<style> |
| 56 |
div.error.isc-notice { |
| 57 |
border-left-color: #F70; |
| 58 |
} |
| 59 |
</style> |
| 60 |
<?php |
| 61 |
// Define the base modules array |
| 62 |
$params = [ |
| 63 |
'ajaxNonce' => wp_create_nonce( 'isc-admin-ajax-nonce' ), |
| 64 |
// Allow other plugins to modify the modules |
| 65 |
'moduleSections' => apply_filters( |
| 66 |
'isc_settings_plugin_modules_related_sections', |
| 67 |
[ |
| 68 |
'image_sources' => [ |
| 69 |
'isc_settings_section_overlay', |
| 70 |
'isc_settings_section_list_below_content', |
| 71 |
'isc_settings_section_complete_list', |
| 72 |
'isc_settings_section_licenses', |
| 73 |
'isc_settings_section_misc', |
| 74 |
], |
| 75 |
] |
| 76 |
), |
| 77 |
]; |
| 78 |
wp_localize_script( 'jquery', 'isc', $params ); |
| 79 |
} |
| 80 |
} |