PluginProbe
Taboola / 2.0.1
Taboola v2.0.1
1.0.4 1.0.5 1.0.6 1.0.8 2.0.1 2.0.2 2.1.0 2.1.1 2.2.2 2.2.3 3.0.0 3.0.1 3.0.2 3.1.0 trunk 1.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.2 1.0.3
taboola / JavaScriptWrapper.php

JavaScriptWrapper.php in Taboola 2.0.1, at JavaScriptWrapper.php

47 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4
5 class JavaScriptWrapper {
6
7 private $_scriptFileContent;
8 private $_currentScript;
9 private $_fileName;
10 private $_params;
11 private $_plugin_directory;
12
13 /**
14 * JavaScriptWrapper constructor.
15 *
16 * @param $_fileName "should be a file from the js folder"
17 * @param $_params "key/value array with parameters to be replaced in the script"
18 */
19 public function __construct( $_fileName, $_params ) {
20
21 $this->_plugin_directory = plugin_dir_path(__FILE__);
22 $this->_fileName = $_fileName;
23 $this->_params = $_params;
24
25 $this->loadScriptFromFile($this->_fileName, $this->_params);
26 }
27
28
29 function loadScriptFromFile($fileName, $params){
30 $this->_scriptFileContent = file_get_contents($this->_plugin_directory.'js/'.$fileName);
31 $this->_currentScript = str_replace(array_keys($params),array_values($params),$this->_scriptFileContent);
32 }
33
34 function appendScript($jscript){
35 $this->_currentScript .= $jscript;
36 }
37
38 function __toString() {
39 return $this->_currentScript;
40 }
41
42 function getScriptMarkupString(){
43 return "<script type='text/javascript'>".$this."</script>";
44 }
45
46
47 }