aboutsummaryrefslogtreecommitdiffstats
path: root/include/plugin.php
diff options
context:
space:
mode:
authorAndrew Manning <tamanning@zoho.com>2016-06-12 14:38:48 -0400
committerAndrew Manning <tamanning@zoho.com>2016-06-12 14:38:48 -0400
commita1183bf09a93459282078038b94ef89c00297604 (patch)
tree2e14bec170e37c6615fcd5ff2892233ddffce452 /include/plugin.php
parent7fc2b13fe605ad461f6b6aeacd6a187c1ef794de (diff)
parent1789c3242adcf11fe37f0ef0ec6180966853eeda (diff)
downloadvolse-hubzilla-a1183bf09a93459282078038b94ef89c00297604.tar.gz
volse-hubzilla-a1183bf09a93459282078038b94ef89c00297604.tar.bz2
volse-hubzilla-a1183bf09a93459282078038b94ef89c00297604.zip
Merge remote-tracking branch 'upstream/dev' into embedphotos
Diffstat (limited to 'include/plugin.php')
-rwxr-xr-xinclude/plugin.php33
1 files changed, 22 insertions, 11 deletions
diff --git a/include/plugin.php b/include/plugin.php
index be4e92f03..9b84039a6 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -593,26 +593,37 @@ function script_path() {
return $scheme . '://' . $hostname;
}
-function head_add_js($src) {
- App::$js_sources[] = $src;
+function head_add_js($src, $priority = 0) {
+ if(! is_array(App::$js_sources[$priority]))
+ App::$js_sources[$priority] = array();
+ App::$js_sources[$priority][] = $src;
}
-function head_remove_js($src) {
+function head_remove_js($src, $priority = 0) {
- $index = array_search($src, App::$js_sources);
+ $index = array_search($src, App::$js_sources[$priority]);
if($index !== false)
- unset(App::$js_sources[$index]);
+ unset(App::$js_sources[$priority][$index]);
}
+// We should probably try to register main.js with a high priority, but currently we handle it
+// separately and put it at the end of the html head block in case any other javascript is
+// added outside the head_add_js construct.
+
function head_get_js() {
+
$str = '';
- $sources = App::$js_sources;
- if(count($sources))
- foreach($sources as $source) {
- if($source === 'main.js')
- continue;
- $str .= format_js_if_exists($source);
+ if(App::$js_sources) {
+ foreach(App::$js_sources as $sources) {
+ if(count($sources)) {
+ foreach($sources as $source) {
+ if($src === 'main.js')
+ continue;
+ $str .= format_js_if_exists($source);
+ }
+ }
}
+ }
return $str;
}