View difference between Paste ID: egVmpL9L and zGw7PPsD
SHOW: | | - or go back to the newest paste.
1
class IBLikeable {
2
3-
	//constructor and other setup functions
3+
	function __construct() {
4
		// ... initialize class properties
5
		add_action( 'admin_print_scripts', array( $this, 'enqueue_admin' ) );
6
	}
7
8
	function register_admin_menus() {
9
10
		$hook = add_options_page('ibLikeable Settings', 'ibLikeable', 'manage_options', $this->prefix, array( $this, 'render_settings_page' ) );
11
		$this->settings_hook = $hook;
12
13
		add_action( 'admin_print_scripts-' . $hook, array( $this, 'enqueue_admin') );
14
15
	}
16
	// ... more code ...
17
18
	function enqueue_admin() {
19
		$screen = get_current_screen();
20
21
		if( $screen->id == $this->settings_hook ) {
22
			wp_register_style($this->prefix . '-settings', $this->url . 'css/settings_page.css' );
23
			wp_enqueue_style( $this->prefix . '-settings');
24
			wp_register_script( $this->prefix . '-settings-js', $this->url . 'js/settings_page.js', array('jQuery') );
25
			wp_enqueue_script($this->prefix . '-settings-js');
26
		}
27
	}
28
}