| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Taboola |
| 4 | 4 | * Plugin URI: http://taboola.com |
| 5 | 5 | * Description: Taboola |
| 6 | - * Version: 1.0.7 | |
| 6 | + * Version: 1.0.5 | |
| 7 | 7 | * Author: Taboola |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | define ("XPATH_MARKER","/"); |
| @@ -12,13 +12,11 @@ | ||
| 12 | 12 | define ("JS_MARKER","{"); |
| 13 | 13 | define ("TABOOLA_CONTENT_FORMAT_STRING",'string'); |
| 14 | 14 | define ("TABOOLA_CONTENT_FORMAT_SCRIPT",'script'); |
| 15 | 15 | define ("TABOOLA_CONTENT_FORMAT_HTML",'html'); |
| 16 | -define ("TABOOLA_PLUGIN_VERSION","1.0.8"); | |
| 17 | 16 | |
| 18 | 17 | |
| 19 | 18 | include_once('widget.php'); |
| 20 | -require_once('JavaScriptWrapper.php'); | |
| 21 | 19 | |
| 22 | 20 | if (!class_exists('TaboolaWP')) { |
| 23 | 21 | class TaboolaWP |
| 24 | 22 | { |
| @@ -26,9 +24,8 @@ | ||
| 26 | 24 | public $data = array(); |
| 27 | 25 | public $_is_widget_on_page; |
| 28 | 26 | public $_is_head_script_loaded = false; |
| 29 | 27 | |
| 30 | - | |
| 31 | 28 | function TaboolaWP() |
| 32 | 29 | { |
| 33 | 30 | global $wpdb; |
| 34 | 31 | |
| @@ -55,10 +52,8 @@ | ||
| 55 | 52 | create_function('', 'return register_widget("WP_Widget_Taboola");') |
| 56 | 53 | ); |
| 57 | 54 | } |
| 58 | 55 | |
| 59 | - $this->should_place_tag_outside_of_content = $this->settings->out_of_content_enabled; | |
| 60 | - | |
| 61 | 56 | if (is_admin()) { |
| 62 | 57 | //add menu for plugin |
| 63 | 58 | add_action( 'admin_menu', array(&$this, 'admin_generate_menu') ); |
| 64 | 59 | add_filter('plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 ); |
| @@ -118,20 +113,15 @@ | ||
| 118 | 113 | // return the head loader script |
| 119 | 114 | function taboola_header_loader_js() { |
| 120 | 115 | $head_string = ""; |
| 121 | 116 | |
| 122 | - // Only adding the loader if a widget is going to be placed on the page. | |
| 117 | + // Only adding Script1 if a widget is going to be placed on the page. | |
| 123 | 118 | if ($this->is_widget_on_page()){ |
| 124 | 119 | |
| 125 | - $stringParams = array( | |
| 126 | - '{{PUBLISHER_ID}}' => $this->settings->publisher_id, | |
| 127 | - '{{PAGE_TYPE}}' => $this->get_page_type(), | |
| 128 | - '{{WORDPRESS_VERSION}}' => get_bloginfo('version'), | |
| 129 | - '{{PLUGIN_VERSION}}' => TABOOLA_PLUGIN_VERSION | |
| 130 | - ); | |
| 120 | + $script1_content = str_replace('{{PUBLISHER_ID}}', $this->settings->publisher_id, file_get_contents($this->plugin_directory.'js/script1.js')); | |
| 121 | + $script1_content = str_replace('{{PAGE_TYPE}}',$this->get_page_type(),$script1_content); | |
| 131 | 122 | |
| 132 | - $scriptWrapper = new JavaScriptWrapper("loaderInjectionScript.js",$stringParams); | |
| 133 | - $head_string = $scriptWrapper->getScripMarkupString(); | |
| 123 | + $head_string = '<script type="text/javascript">'.$script1_content.'</script>'; | |
| 134 | 124 | } |
| 135 | 125 | |
| 136 | 126 | return $head_string; |
| 137 | 127 | } |
| @@ -145,12 +135,12 @@ | ||
| 145 | 135 | |
| 146 | 136 | |
| 147 | 137 | function taboola_footer_loader_js() { |
| 148 | 138 | |
| 149 | - // Only adding flush script if a widget is going to be placed on the page. | |
| 139 | + // Only adding Script1 if a widget is going to be placed on the page. | |
| 150 | 140 | if ( $this->is_widget_on_page() ){ |
| 151 | - $flushInjectionScript = new JavaScriptWrapper('flushInjectionScript.js',array()); | |
| 152 | - echo $flushInjectionScript->getScripMarkupString(); | |
| 141 | + $script3_content = file_get_contents($this->plugin_directory.'js/script3.js'); | |
| 142 | + echo '<script type="text/javascript">'.$script3_content.'</script>'; | |
| 153 | 143 | } |
| 154 | 144 | } |
| 155 | 145 | |
| 156 | 146 | function load_taboola_content($content) |
| @@ -157,26 +147,23 @@ | ||
| 157 | 147 | { |
| 158 | 148 | $taboola_content = array(); |
| 159 | 149 | if ($this->should_show_content_widget()){ |
| 160 | 150 | |
| 161 | - $firstWidgetParams = array('{{WIDGET_ID}}' => $this->settings->first_bc_widget_id, | |
| 162 | - '{{CONTAINER}}' => 'taboola-below-article', | |
| 163 | - '{{PLACEMENT}}' => 'below-article'); | |
| 151 | + $script2_content = str_replace('{{WIDGET_ID}}', $this->settings->first_bc_widget_id, file_get_contents($this->plugin_directory.'js/script2.js')); | |
| 152 | + $script2_content = str_replace('{{CONTAINER}}', 'taboola-below-article', $script2_content); | |
| 153 | + $script2_content = str_replace('{{PLACEMENT}}', 'below-article', $script2_content); | |
| 164 | 154 | |
| 165 | - $firstWidgetScript = new JavaScriptWrapper("widgetInjectionScript.js",$firstWidgetParams); | |
| 166 | - $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-below-article'></div>"; | |
| 167 | - $taboola_content[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $firstWidgetScript; | |
| 155 | + $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = '<div id="taboola-below-article"></div>'; | |
| 156 | + $taboola_content[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $script2_content; | |
| 168 | 157 | |
| 169 | 158 | // Adding the 2nd widget if needed |
| 170 | 159 | if($this->settings->second_bc_enabled && trim($this->settings->second_bc_widget_id) != ''){ |
| 160 | + $script2_content = str_replace('{{WIDGET_ID}}', $this->settings->second_bc_widget_id, file_get_contents($this->plugin_directory.'js/script2.js')); | |
| 161 | + $script2_content = str_replace('{{CONTAINER}}', 'taboola-below-article-second', $script2_content); | |
| 162 | + $script2_content = str_replace('{{PLACEMENT}}', 'below-article-2nd', $script2_content); | |
| 171 | 163 | |
| 172 | - $secondWidgetParams = array('{{WIDGET_ID}}' => $this->settings->second_bc_widget_id, | |
| 173 | - '{{CONTAINER}}' => 'taboola-below-article-second', | |
| 174 | - '{{PLACEMENT}}' => 'below-article-2nd'); | |
| 175 | - $secondWidgetScript = new JavaScriptWrapper("widgetInjectionScript.js",$secondWidgetParams); | |
| 176 | - | |
| 177 | - $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-below-article-second'></div>"; | |
| 178 | - $taboola_content[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $secondWidgetScript; | |
| 164 | + $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = '<div id="taboola-below-article-second"></div>'; | |
| 165 | + $taboola_content[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $script2_content; | |
| 179 | 166 | } |
| 180 | 167 | |
| 181 | 168 | $content = $this->embed_taboola_content_location($content,$taboola_content,trim($this->settings->location_string)); |
| 182 | 169 | } |
| @@ -221,15 +208,14 @@ | ||
| 221 | 208 | |
| 222 | 209 | if ($full_indicator == JS_INDICATOR){ |
| 223 | 210 | |
| 224 | 211 | $xpath = substr($location,strlen(JS_INDICATOR)); |
| 225 | - $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array( | |
| 226 | - "{{HTML}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_HTML), | |
| 227 | - "{{SCRIPT}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_SCRIPT)) | |
| 228 | - ); | |
| 229 | - $scriptWrapper->appendScript("injectWidgetByXpath('".$xpath."');"); | |
| 230 | - $content = $content."<span id='tbdefault'></span><script type='text/javascript'>".$scriptWrapper."</script>"; | |
| 212 | + $js_inject_script = file_get_contents($this->plugin_directory.'js/js_inject.min.js'); | |
| 213 | + $js_inject_script = str_replace("{{XPATH}}",$xpath,$js_inject_script); | |
| 214 | + $js_inject_script = str_replace("{{HTML}}",$this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_HTML),$js_inject_script); | |
| 215 | + $js_inject_script = str_replace("{{SCRIPT}}",$this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_SCRIPT),$js_inject_script); | |
| 231 | 216 | |
| 217 | + $content = $content."<span id='tbdefault'></span><script type='text/javascript'>".$js_inject_script."</script>"; | |
| 232 | 218 | $do_default = false; |
| 233 | 219 | } |
| 234 | 220 | |
| 235 | 221 | // server side selector provided (see simple_html_dom selectors http://simplehtmldom.sourceforge.net/manual.htm) |
| @@ -249,19 +235,8 @@ | ||
| 249 | 235 | $content = $html_doc; |
| 250 | 236 | $do_default = false; |
| 251 | 237 | } |
| 252 | 238 | } |
| 253 | - | |
| 254 | - // tag is placed outside of content in order to allow "read more" functionality. | |
| 255 | - }elseif ($this->should_place_tag_outside_of_content){ | |
| 256 | - | |
| 257 | - $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array( | |
| 258 | - "{{HTML}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_HTML), | |
| 259 | - "{{SCRIPT}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_SCRIPT)) | |
| 260 | - ); | |
| 261 | - $scriptWrapper->appendScript("injectWidgetByMarker('tbmarker');"); | |
| 262 | - $content = $content."<span id='tbmarker'></span><script type='text/javascript'>".$scriptWrapper."</script>"; | |
| 263 | - $do_default = false; | |
| 264 | 239 | } |
| 265 | 240 | |
| 266 | 241 | // Default - add to the end of the content |
| 267 | 242 | if ($do_default){ |
| @@ -301,10 +276,9 @@ | ||
| 301 | 276 | "first_bc_enabled" => $_POST['first_bc_enabled'] == 'on' ? true : false, |
| 302 | 277 | "first_bc_widget_id" => trim($_POST['first_bc_widget_id']), |
| 303 | 278 | "second_bc_enabled" => $_POST['second_bc_enabled'] == 'on' ? true : false, |
| 304 | 279 | "second_bc_widget_id" => trim($_POST['second_bc_widget_id']), |
| 305 | - "location_string" => trim($_POST['location_string']), | |
| 306 | - "out_of_content_enabled" => $_POST['out_of_content_enabled'] == 'on' ? true : false | |
| 280 | + "location_string" => trim($_POST['location_string']) | |
| 307 | 281 | ); |
| 308 | 282 | |
| 309 | 283 | //var_dump($settings); |
| 310 | 284 | if($settings == NULL){ |
| @@ -350,13 +324,12 @@ | ||
| 350 | 324 | `second_bc_enabled` TINYINT(1) NOT NULL DEFAULT FALSE, |
| 351 | 325 | `second_bc_widget_id` VARCHAR(255) DEFAULT NULL, |
| 352 | 326 | `second_bc_custom_css` TEXT DEFAULT NULL, |
| 353 | 327 | `location_string` TEXT DEFAULT NULL, |
| 354 | - `out_of_content_enabled` TINYINT(1) NOT NULL DEFAULT TRUE, | |
| 355 | 328 | PRIMARY KEY (`id`) |
| 356 | 329 | )" . $charset_collate . ";"; |
| 357 | 330 | |
| 358 | - // create/update the table | |
| 331 | + // creat/update the table | |
| 359 | 332 | dbDelta($sql_table_settings); |
| 360 | 333 | } |
| 361 | 334 | } |
| 362 | 335 | } |