| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Taboola |
| 4 | - * Plugin URI: http://taboola.com | |
| 4 | + * Plugin URI: https://developers.taboola.com/web-integrations/discuss | |
| 5 | 5 | * Description: Taboola |
| 6 | - * Version: 1.0.10 | |
| 6 | + * Version: 1.0.15 | |
| 7 | 7 | * Author: Taboola |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | define ("XPATH_MARKER","/"); |
| @@ -12,9 +12,9 @@ | ||
| 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.10"); | |
| 16 | +define ("TABOOLA_PLUGIN_VERSION","1.0.15"); | |
| 17 | 17 | |
| 18 | 18 | |
| 19 | 19 | include_once('widget.php'); |
| 20 | 20 | require_once('JavaScriptWrapper.php'); |
| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | public $_is_widget_on_page; |
| 28 | 28 | public $_is_head_script_loaded = false; |
| 29 | 29 | |
| 30 | 30 | |
| 31 | - function TaboolaWP() | |
| 31 | + function __construct() | |
| 32 | 32 | { |
| 33 | 33 | global $wpdb; |
| 34 | 34 | |
| 35 | 35 | //initialize plugin constant |
| @@ -51,13 +51,15 @@ | ||
| 51 | 51 | // Enable sidebar widgets |
| 52 | 52 | if($this->settings != NULL && !empty($this->settings->publisher_id)){ |
| 53 | 53 | //register Taboola widget |
| 54 | 54 | add_action('widgets_init', |
| 55 | - create_function('', 'return register_widget("WP_Widget_Taboola");') | |
| 55 | + function(){ | |
| 56 | + return register_widget("WP_Widget_Taboola"); | |
| 57 | + } | |
| 56 | 58 | ); |
| 57 | 59 | } |
| 58 | 60 | |
| 59 | - $this->should_place_tag_outside_of_content = $this->settings->out_of_content_enabled; | |
| 61 | + //$this->should_place_tag_outside_of_content = $this->settings->out_of_content_enabled; | |
| 60 | 62 | |
| 61 | 63 | if (is_admin()) { |
| 62 | 64 | //add menu for plugin |
| 63 | 65 | add_action( 'admin_menu', array(&$this, 'admin_generate_menu') ); |
| @@ -125,9 +127,11 @@ | ||
| 125 | 127 | $stringParams = array( |
| 126 | 128 | '{{PUBLISHER_ID}}' => $this->settings->publisher_id, |
| 127 | 129 | '{{PAGE_TYPE}}' => $this->get_page_type(), |
| 128 | 130 | '{{WORDPRESS_VERSION}}' => get_bloginfo('version'), |
| 129 | - '{{PLUGIN_VERSION}}' => TABOOLA_PLUGIN_VERSION | |
| 131 | + '{{PHP_VERSION}}' => phpversion(), | |
| 132 | + '{{PLUGIN_VERSION}}' => TABOOLA_PLUGIN_VERSION, | |
| 133 | + '{{LOCATION}}' => $this->settings->location_string | |
| 130 | 134 | ); |
| 131 | 135 | |
| 132 | 136 | $scriptWrapper = new JavaScriptWrapper("loaderInjectionScript.js",$stringParams); |
| 133 | 137 | $head_string = $scriptWrapper->getScripMarkupString(); |
| @@ -231,9 +235,9 @@ | ||
| 231 | 235 | |
| 232 | 236 | $do_default = false; |
| 233 | 237 | } |
| 234 | 238 | |
| 235 | - // server side selector provided (see simple_html_dom selectors http://simplehtmldom.sourceforge.net/manual.htm) | |
| 239 | + // server side selector provided (see simple_html_dom selectors https://simplehtmldom.sourceforge.net/manual.htm) | |
| 236 | 240 | // basically it's CSS selectors like in jQuery |
| 237 | 241 | } else{ |
| 238 | 242 | |
| 239 | 243 | require_once('simple_html_dom.php'); |
| @@ -251,9 +255,9 @@ | ||
| 251 | 255 | } |
| 252 | 256 | } |
| 253 | 257 | |
| 254 | 258 | // tag is placed outside of content in order to allow "read more" functionality. |
| 255 | - }elseif ($this->should_place_tag_outside_of_content){ | |
| 259 | + }elseif ($this->settings->out_of_content_enabled){ | |
| 256 | 260 | |
| 257 | 261 | $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array( |
| 258 | 262 | "{{HTML}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_HTML), |
| 259 | 263 | "{{SCRIPT}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_SCRIPT)) |
| @@ -285,10 +289,10 @@ | ||
| 285 | 289 | |
| 286 | 290 | if(trim($_POST['publisher_id']) == ''){ |
| 287 | 291 | $taboola_errors[] = "Please add a 'Publisher ID' in order to apply changes to your widgets"; |
| 288 | 292 | } |
| 289 | - if(($_POST['first_bc_enabled'] == 'on' && trim($_POST['first_bc_widget_id']) == '') || | |
| 290 | - ($_POST['second_bc_enabled'] == 'on' && trim($_POST['second_bc_widget_id']) == '') | |
| 293 | + if((isset($_POST['first_bc_enabled']) && trim($_POST['first_bc_widget_id']) == '') || | |
| 294 | + (isset($_POST['second_bc_enabled']) && trim($_POST['second_bc_widget_id']) == '') | |
| 291 | 295 | ){ |
| 292 | 296 | $taboola_errors[] = "Please add a 'Widget ID' in order to apply changes to your widgets"; |
| 293 | 297 | } |
| 294 | 298 | if (trim($_POST['location_string']) != '' && !$this->is_location_string_valid($_POST['location_string'])){ |
| @@ -297,14 +301,14 @@ | ||
| 297 | 301 | if(count($taboola_errors) == 0){ |
| 298 | 302 | |
| 299 | 303 | $data = array( |
| 300 | 304 | "publisher_id" => trim($_POST['publisher_id']), |
| 301 | - "first_bc_enabled" => $_POST['first_bc_enabled'] == 'on' ? true : false, | |
| 305 | + "first_bc_enabled" => isset($_POST['first_bc_enabled']) ? true : false, | |
| 302 | 306 | "first_bc_widget_id" => trim($_POST['first_bc_widget_id']), |
| 303 | - "second_bc_enabled" => $_POST['second_bc_enabled'] == 'on' ? true : false, | |
| 307 | + "second_bc_enabled" => isset($_POST['second_bc_enabled']) ? true : false, | |
| 304 | 308 | "second_bc_widget_id" => trim($_POST['second_bc_widget_id']), |
| 305 | 309 | "location_string" => trim($_POST['location_string']), |
| 306 | - "out_of_content_enabled" => $_POST['out_of_content_enabled'] == 'on' ? true : false | |
| 310 | + "out_of_content_enabled" => isset($_POST['out_of_content_enabled']) ? true : false | |
| 307 | 311 | ); |
| 308 | 312 | |
| 309 | 313 | //var_dump($settings); |
| 310 | 314 | if($settings == NULL){ |