1 | <?php |
||
21 | abstract class Assets implements AssetsInterface |
||
22 | { |
||
23 | /** |
||
24 | * Constructor. |
||
25 | */ |
||
26 | public function __construct() |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function developmentAssets() |
||
45 | |||
46 | /** |
||
47 | * {@inheritdoc} |
||
48 | */ |
||
49 | public function productionAssets() |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | public function adminAssets() |
||
59 | |||
60 | /** |
||
61 | * Method that wraps the WordPress internal "wp_enqueue_script" |
||
62 | * simplifying the process adding some common default values. |
||
63 | * |
||
64 | * @param string $name The name of asset |
||
65 | * @param string $from The from location, by default is the JS files default location |
||
66 | * @param array $dependencies Array which contains the dependencies of the given asset |
||
67 | * @param string $version The version, by default is "1.0.0" |
||
68 | * @param bool $inFooter Checks if the asset is going to be in the footer or not |
||
69 | * @param array|string|null $ajaxUrl The ajax url to expose in JS files |
||
70 | * |
||
71 | * @return $this Self class instance |
||
72 | */ |
||
73 | protected function addScript( |
||
89 | |||
90 | /** |
||
91 | * Method that wraps the WordPress internal "wp_enqueue_style" |
||
92 | * simplifying the process adding some common default values. |
||
93 | * |
||
94 | * @param string $name The name of asset |
||
95 | * @param string $from The from location, by default is the CSS files default location |
||
96 | * @param array $dependencies Array which contains the dependencies of the given asset, by default is empty |
||
97 | * @param string $version The version, by default is "1.0.0" |
||
98 | * @param string $media The media, by default is "all" |
||
99 | * |
||
100 | * @return $this Self class instance |
||
101 | */ |
||
102 | protected function addStylesheet( |
||
113 | |||
114 | /** |
||
115 | * Registers the ajax urls inside given JS filename. |
||
116 | * |
||
117 | * @param string $name The script file name |
||
118 | * @param string $ajaxUrl The name that is going to expose in JS file as ajaxUrl |
||
119 | * |
||
120 | * Usage example with name="subscribe" and ajaxUrl="subscribeAjax": |
||
121 | * |
||
122 | * // subscribe.js |
||
123 | * |
||
124 | * $.ajax({ |
||
125 | * url: subscribeAjax.ajaxUrl, |
||
126 | * method: 'GET', |
||
127 | * data: { |
||
128 | * action: 'ajax-action-registered-in-your-php-file', |
||
129 | * } |
||
130 | * }).done(function (response) { |
||
131 | * (...) |
||
132 | * }); |
||
133 | */ |
||
134 | protected function registerAjaxUrls($name, $ajaxUrl) |
||
145 | |||
146 | /** |
||
147 | * Build dynamically the asset directory path with the given parameters. |
||
148 | * |
||
149 | * @param string $from The from location |
||
150 | * @param string $name The filename without extension |
||
151 | * @param string $fileType The file type, by default is "js" |
||
152 | * |
||
153 | * @return string |
||
154 | */ |
||
155 | private function path($from, $name, $fileType = 'js') |
||
159 | |||
160 | /** |
||
161 | * Registers all the scripts and stylesheet files. |
||
162 | * It's a callback of WordPress internal "wp_enqueue_scripts" method. |
||
163 | * |
||
164 | * @deprecated since version 1.5, will be removed in 2.0. Implement productionAssets and developmentAssets instead. |
||
165 | */ |
||
166 | public function assets() |
||
169 | } |
||
170 |