Guest User

Untitled

a guest
Jan 21st, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. <?php
  2. class WpImageFactory{
  3.  
  4. const PLUGIN_SLUG = 'bawp_imagefactory';
  5. const POST_TYPES = array(self::PLUGIN_SLUG);
  6.  
  7. public static function init(){
  8. return new self();
  9. }
  10.  
  11. private function __construct() {
  12. add_action('admin_enqueue_scripts', array($this, 'enqueueAssets'));
  13. }
  14.  
  15. public static function enqueueAssets($hook){
  16. global $post_type;
  17. if(in_array($post_type, self::POST_TYPES)){
  18. if(($hook == 'post.php' || $hook == 'edit.php' || $hook == 'post-new.php')) {
  19. wp_enqueue_media();
  20. wp_enqueue_script('bawp-imagefactory', plugin_dir_url(__FILE__).'assets/bawp-imagefactory.js', null, 0.1, true);
  21. wp_enqueue_style('bawp-imagefactory', plugin_dir_url(__FILE__).'assets/bawp-imagefactory.css', null, 0.1, 'all');
  22. }
  23. }
  24. }
  25. }
  26. add_action('init',array(WpImageFactory::class, 'init'));
Add Comment
Please, Sign In to add comment