Yoast_GA_Admin_Assets

This class is for the backend.

Defined (1)

The class is defined in the following location(s).

/admin/class-admin-assets.php  
  1. class Yoast_GA_Admin_Assets { 
  2.  
  3. /** 
  4. * Add the scripts to the admin head 
  5. */ 
  6. public static function enqueue_scripts() { 
  7. wp_enqueue_script( 'yoast_focusable', self::get_asset_path( 'assets/dependencies/focusable/focus-element-overlay.min.js' ), array( 'jquery' ), false ); 
  8.  
  9. wp_enqueue_script( 'yoast_ga_admin', self::get_asset_path( 'assets/js/yoast_ga_admin' ) . self::file_ext( '.js' ), array( 'jquery', 'yoast_focusable' ), GAWP_VERSION ); 
  10.  
  11. // Enqueue the qtip js file 
  12. wp_enqueue_script( 'jquery-qtip', self::get_asset_path( 'assets/dependencies/qtip/jquery.qtip.min.js' ), array( 'jquery' ), '1.0.0-RC3', true ); 
  13.  
  14. // Enqueue the chosen js file 
  15. wp_enqueue_script( 'chosen_js', self::get_asset_path( 'assets/dependencies/chosen/chosen.jquery.min.js' ), array(), GAWP_VERSION, true ); 
  16.  
  17. /** 
  18. * Add the styles in the admin head 
  19. */ 
  20. public static function enqueue_styles() { 
  21. wp_enqueue_style( 'yoast_ga_styles', self::get_asset_path( 'assets/css/yoast_ga_styles' ) . self::file_ext( '.css' ), array(), GAWP_VERSION ); 
  22.  
  23. /** 
  24. * Enqueues the settings page specific styles 
  25. */ 
  26. public static function enqueue_settings_styles() { 
  27. // Enqueue the chosen css file 
  28. wp_enqueue_style( 'chosen_css', self::get_asset_path( 'assets/dependencies/chosen/chosen' ) . self::file_ext( '.css' ), array(), GAWP_VERSION ); 
  29.  
  30. /** 
  31. * Loading the assets for dashboard 
  32. */ 
  33. public static function enqueue_dashboard_assets() { 
  34.  
  35. wp_enqueue_script( 'ga-admin-dashboard', self::get_asset_path( 'assets/js/yoast_ga_admin_dashboard' ) . self::file_ext( '.js' ), array(), GAWP_VERSION ); 
  36. wp_enqueue_style( 'ga-admin-dashboard-css', self::get_asset_path( 'assets/css/yoast_ga_admin_dashboard' ) . self::file_ext( '.css' ), array(), GAWP_VERSION ); 
  37.  
  38. // Enqueue the d3 js file 
  39. wp_enqueue_script( 'd3_js', self::get_asset_path( 'assets/dependencies/rickshaw/d3.v3.min.js' ), array(), GAWP_VERSION, true ); 
  40.  
  41. // Enqueue the ricksaw js file 
  42. wp_enqueue_script( 'rickshaw_js', self::get_asset_path( 'assets/dependencies/rickshaw/rickshaw.min.js' ), array(), GAWP_VERSION, true ); 
  43.  
  44. // Enqueue the rickshaw css 
  45. wp_enqueue_style( 'rickshaw_css', self::get_asset_path( 'assets/dependencies/rickshaw/rickshaw.min.css' ), array(), GAWP_VERSION ); 
  46.  
  47. // Enqueue the datatables js file 
  48. wp_enqueue_script( 'datatables_js', self::get_asset_path( 'assets/dependencies/datatables/js/jquery.dataTables.min.js' ), array(), GAWP_VERSION, true ); 
  49.  
  50. // Enqueue the datatables css 
  51. wp_enqueue_style( 'datatables_css', self::get_asset_path( 'assets/dependencies/datatables/css/jquery.dataTables.min.css' ), array(), GAWP_VERSION ); 
  52.  
  53. Yoast_GA_Dashboards::get_instance()->add_dashboard_js_translations(); 
  54.  
  55. /** 
  56. * Getting the full path to given $asset 
  57. * @param string $asset 
  58. * @return string 
  59. */ 
  60. public static function get_asset_path( $asset ) { 
  61. static $plugin_directory; 
  62.  
  63. if ( $plugin_directory == null ) { 
  64. $plugin_directory = plugin_dir_url( GAWP_FILE ); 
  65.  
  66. $return = $plugin_directory . $asset; 
  67.  
  68. return $return; 
  69.  
  70. /** 
  71. * Check whether we can include the minified version or not 
  72. * @param string $ext 
  73. * @return string 
  74. */ 
  75. private static function file_ext( $ext ) { 
  76. if ( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) { 
  77. $ext = '.min' . $ext; 
  78.  
  79. return $ext; 
  80.