PluginProbe
ShiftController Employee Shift Scheduling / 4.9.85
ShiftController Employee Shift Scheduling v4.9.85
4.9.97 4.9.96 4.9.95 4.9.74 4.9.75 4.9.76 4.9.77 4.9.78 4.9.84 4.9.85 4.9.87 4.9.91 4.9.92 trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 3.2.4 All 38 releases
shiftcontroller / hc3 / _wordpress / enqueuer.php

enqueuer.php in ShiftController Employee Shift Scheduling 4.9.85, at hc3/_wordpress/enqueuer.php

87 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if (! defined('ABSPATH')) exit; // Exit if accessed directly
2 class HC3_Enqueuer implements HC3_IEnqueuer
3 {
4 protected $scripts = array();
5 protected $styles = array();
6 protected $uri = NULL;
7
8 protected $prfx = 'hc3-';
9
10 public function __construct(
11 HC3_Hooks $hooks,
12 HC3_Uri $uri
13 )
14 {
15 $this->uri = $hooks->wrap($uri);
16 }
17
18 public function addScript( $handle, $path )
19 {
20 wp_enqueue_script( 'jquery' );
21 if( substr($handle, 0, strlen($this->prfx)) != $this->prfx ){
22 $handle = $this->prfx . $handle;
23 }
24
25 $path = $this->_fullPath( $path );
26 $this->scripts[ $handle ] = $path;
27 // echo "ENQUEUEING SCRIPT: '$handle', '$path'<br>";
28 wp_enqueue_script( $handle, $path );
29
30 return $this;
31 }
32
33 public function addStyle( $handle, $path )
34 {
35 if( substr($handle, 0, strlen($this->prfx)) != $this->prfx ){
36 $handle = $this->prfx . $handle;
37 }
38
39 $path = $this->_fullPath( $path );
40 $this->styles[ $handle ] = $path;
41
42 wp_enqueue_style( $handle, $path );
43
44 return $this;
45 }
46
47 public function getScripts()
48 {
49 wp_enqueue_script( 'jquery' );
50 $return = $this->scripts;
51 return $return;
52 }
53
54 public function getStyles()
55 {
56 $return = $this->styles;
57 return $return;
58 }
59
60 protected function _fullPath( $src )
61 {
62 if( $this->uri->isFullUrl($src) ){
63 return $src;
64 }
65
66 if( defined('HC3_DEV_URL') && HC3_DEV_URL && (substr($src, 0, strlen('hc3/')) == 'hc3/') ){
67 $src = HC3_DEV_URL . substr($src, strlen('hc3/'));
68 return $src;
69 }
70
71 $assets_web_dir = $this->uri->assetsPath( $src );
72
73 if( substr($assets_web_dir, -1) != '/' ){
74 $test = explode('/', $assets_web_dir);
75 $last_part = array_pop( $test );
76 if( strpos($last_part, '.') !== FALSE ){
77 $assets_web_dir = dirname($assets_web_dir);
78 }
79 }
80 if( substr($assets_web_dir, -1) != '/' ){
81 $assets_web_dir = $assets_web_dir . '/';
82 }
83
84 $src = $assets_web_dir . $src;
85 return $src;
86 }
87 }