Created
December 24, 2014 16:58
-
-
Save N-Molham/6b90e7eb2c286cc28870 to your computer and use it in GitHub Desktop.
Dashboard User Password Generator demo plugin - generator assets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in the User_Password_Generator_Demo class constructor | |
// Dashboard hook for add js and css files | |
add_action( 'admin_enqueue_scripts', array( &$this, 'enqueues' ) ); | |
// add new methon to User_Password_Generator_Demo class | |
/** | |
* Assets Enqueues | |
* | |
* @since 1.0 | |
* | |
* @return void | |
*/ | |
public function enqueues() | |
{ | |
// current page ID | |
$screen_id = get_current_screen()->id; | |
// don't do anything if a page other than "adding new user" or "user profile" page | |
if ( !in_array( $screen_id, array( 'user', 'profile' ) ) ) | |
return; | |
// load Style file | |
wp_enqueue_style( 'upgd-generator-style', UPGD_URI .'assets/css/generator.css' ); | |
// load Javascript file in footer | |
wp_enqueue_script( 'upgd-generator-script', UPGD_URI .'assets/js/generator.js', array( 'jquery' ), false, true ); | |
// some data the generator depends on | |
wp_localize_script( 'upgd-generator-script', 'upgd', array ( | |
'password' => array ( | |
'chars' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789', | |
'special_chars' => '!@#$%^&*()', | |
'extra_special_chars' => '-_ []{}<>~`+=,.;:/?|', | |
), | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment