| @@ -1,18 +1,18 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: Taboola |
| 4 | - * Plugin URI: https://developers.taboola.com/web-integrations/docs/wordpress-plugin | |
| 4 | + * Plugin URI: https://developers.taboola.com/web-integrations/discuss | |
| 5 | 5 | * Description: Taboola |
| 6 | - * Version: 2.1.0 | |
| 6 | + * Version: 2.0.1 | |
| 7 | 7 | * Author: Taboola |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -define ("TABOOLA_PLUGIN_VERSION","2.1.0"); // => UPDATE THIS FOR *EVERY* RELEASE (USED FOR TRACKING) | |
| 11 | -define ("TABOOLA_MIN_VER","2.0.1"); // => UPDATE THIS *ONLY* IF THIS RELEASE HAS *DB CHANGES* | |
| 12 | -define ("TABOOLA_DEBUG_MODE", false); // => SET THIS TO 'FALSE' FOR *EVERY* RELEASE (USED TO SUPRESS DEBUGGING LOGS) | |
| 10 | +define ("TABOOLA_PLUGIN_VERSION","2.0.1"); // => UPDATE FOR *EVERY* RELEASE (USED FOR TRACKING) | |
| 11 | +define ("TABOOLA_MIN_VER","2.0.1"); // => UPDATE *ONLY* IF THIS RELEASE HAS *DB CHANGES* | |
| 12 | +define ("TABOOLA_DEBUG_MODE", false); // => SET TO 'FALSE' FOR *EVERY* RELEASE (USED TO SUPRESS DEBUGGING LOGS) | |
| 13 | 13 | |
| 14 | -define ("TABOOLA_OPTION_NAME","taboola_plugin_version"); // Note: if this release has DB changes, then the min version will be saved under 'taboola_plugin_version' in 'wp_options'. | |
| 14 | +define ("TABOOLA_OPTION_NAME","taboola_plugin_version"); // *If* this release has DB changes, then the min version will be saved under 'taboola_plugin_version' in 'wp_options'. | |
| 15 | 15 | |
| 16 | 16 | define ("TABOOLA_XPATH_MARKER","/"); |
| 17 | 17 | define ("TABOOLA_JS_INDICATOR","{JS}"); |
| 18 | 18 | define ("TABOOLA_JS_MARKER","{"); |
| @@ -23,9 +23,8 @@ | ||
| 23 | 23 | |
| 24 | 24 | include_once('widget.php'); |
| 25 | 25 | require_once('JavaScriptWrapper.php'); |
| 26 | 26 | |
| 27 | - | |
| 28 | 27 | if (!class_exists('TaboolaWP')) { |
| 29 | 28 | class TaboolaWP |
| 30 | 29 | { |
| 31 | 30 | //save internal data |
| @@ -140,10 +139,9 @@ | ||
| 140 | 139 | $head_string = ""; |
| 141 | 140 | |
| 142 | 141 | // Only adding the loader if a widget is going to be placed on the page. |
| 143 | 142 | if ($this->is_widget_on_page()){ |
| 144 | - // PC - since these params will be inserted in 'loaderInjectionScript.js' via search and replace, | |
| 145 | - // double brackets are used to ensure that each key is a unique string. | |
| 143 | + | |
| 146 | 144 | $stringParams = array( |
| 147 | 145 | '{{PUBLISHER_ID}}' => $this->settings->publisher_id, |
| 148 | 146 | '{{PAGE_TYPE}}' => $this->get_page_type(), |
| 149 | 147 | '{{WORDPRESS_VERSION}}' => get_bloginfo('version'), |
| @@ -441,35 +439,34 @@ | ||
| 441 | 439 | add_menu_page('Taboola', 'Taboola', 'manage_options', 'taboola_widget', array(&$this, 'admin_taboola_settings'), $this->plugin_url.'img/taboola_icon.png', 110); |
| 442 | 440 | } |
| 443 | 441 | |
| 444 | 442 | function admin_taboola_settings(){ |
| 445 | - | |
| 446 | 443 | global $wpdb; |
| 447 | 444 | $settings = $wpdb->get_row("select * from ".$wpdb->prefix."_taboola_settings limit 1"); |
| 448 | 445 | $taboola_errors = array(); |
| 449 | 446 | if($_SERVER['REQUEST_METHOD'] == 'POST'){ |
| 450 | 447 | |
| 451 | - if(trim(strip_tags($_POST['publisher_id'])) == ''){ | |
| 448 | + if(trim($_POST['publisher_id']) == ''){ | |
| 452 | 449 | $taboola_errors[] = "Publisher ID"; |
| 453 | 450 | } |
| 454 | 451 | |
| 455 | 452 | if(isset($_POST['first_bc_enabled'])) { |
| 456 | - if (trim(strip_tags($_POST['first_bc_widget_id'])) == '') { | |
| 453 | + if (trim($_POST['first_bc_widget_id']) == '') { | |
| 457 | 454 | $taboola_errors[] = "Below-article > Widget ID"; |
| 458 | 455 | } |
| 459 | - if (trim(strip_tags($_POST['first_bc_placement'])) == '') { | |
| 456 | + if (trim($_POST['first_bc_placement']) == '') { | |
| 460 | 457 | $taboola_errors[] = "Below-article > Placement Name"; |
| 461 | 458 | } |
| 462 | 459 | } |
| 463 | 460 | |
| 464 | 461 | if(isset($_POST['mid_enabled'])) { |
| 465 | - if (trim(strip_tags($_POST['mid_widget_id'])) == '') { | |
| 462 | + if (trim($_POST['mid_widget_id']) == '') { | |
| 466 | 463 | $taboola_errors[] = "Mid-article > Widget ID"; |
| 467 | 464 | } |
| 468 | - if (trim(strip_tags($_POST['mid_placement'])) == '') { | |
| 465 | + if (trim($_POST['mid_placement']) == '') { | |
| 469 | 466 | $taboola_errors[] = "Mid-article > Placement Name"; |
| 470 | 467 | } |
| 471 | - if (trim(strip_tags($_POST['mid_location_string'])) == '') { | |
| 468 | + if (trim($_POST['mid_location_string']) == '') { | |
| 472 | 469 | $taboola_errors[] = "Mid-article > CSS selector"; |
| 473 | 470 | } |
| 474 | 471 | else { |
| 475 | 472 | // If the 'location' WAS filled in, then... |
| @@ -489,16 +486,16 @@ | ||
| 489 | 486 | |
| 490 | 487 | } |
| 491 | 488 | |
| 492 | 489 | if(isset($_POST['home_enabled'])) { |
| 493 | - if (trim(strip_tags($_POST['home_widget_id'])) == '') { | |
| 490 | + if (trim($_POST['home_widget_id']) == '') { | |
| 494 | 491 | $taboola_errors[] = "Homepage > Widget ID"; |
| 495 | 492 | } |
| 496 | - if (trim(strip_tags($_POST['home_placement'])) == '') { | |
| 493 | + if (trim($_POST['home_placement']) == '') { | |
| 497 | 494 | $taboola_errors[] = "Homepage > Placement Name"; |
| 498 | 495 | } |
| 499 | 496 | |
| 500 | - if (trim(strip_tags($_POST['home_location_string'])) == '') { | |
| 497 | + if (trim($_POST['home_location_string']) == '') { | |
| 501 | 498 | $taboola_errors[] = "Homepage > CSS selector"; |
| 502 | 499 | } |
| 503 | 500 | else { |
| 504 | 501 | // If the 'location' WAS filled in, then... |
| @@ -544,23 +541,13 @@ | ||
| 544 | 541 | "home_location_string" => !empty($_POST['home_location_string']) ? trim($_POST['home_location_string']) : '' |
| 545 | 542 | ); |
| 546 | 543 | |
| 547 | 544 | //var_dump($settings); |
| 548 | - | |
| 549 | - $is_valid_nonce = false; | |
| 550 | - | |
| 551 | - if (isset( $_POST['my_plugin_nonce']) && wp_verify_nonce( $_POST['my_plugin_nonce'], 'my_plugin_update_field_action' ) ) { | |
| 552 | - $is_valid_nonce = true; | |
| 545 | + if($settings == NULL){ | |
| 546 | + $wpdb->insert($this->tbl_taboola_settings, $data, null, null); | |
| 547 | + } else { | |
| 548 | + $wpdb->update($this->tbl_taboola_settings, $data, array('id' => $settings->id)); | |
| 553 | 549 | } |
| 554 | - | |
| 555 | - if ($is_valid_nonce) { | |
| 556 | - if($settings == NULL){ | |
| 557 | - $wpdb->insert($this->tbl_taboola_settings, $data, null, null); | |
| 558 | - } else { | |
| 559 | - $wpdb->update($this->tbl_taboola_settings, $data, array('id' => $settings->id)); | |
| 560 | - } | |
| 561 | - } | |
| 562 | - | |
| 563 | 550 | } |
| 564 | 551 | $settings = $wpdb->get_row("select * from ".$wpdb->prefix."_taboola_settings limit 1"); |
| 565 | 552 | } |
| 566 | 553 | |
| @@ -680,9 +667,9 @@ | ||
| 680 | 667 | } |
| 681 | 668 | } |
| 682 | 669 | |
| 683 | 670 | function update_db(){ |
| 684 | - | |
| 671 | + | |
| 685 | 672 | // If we are up to date, then skip this method... |
| 686 | 673 | if ($this->is_db_updated_for_min_ver(TABOOLA_MIN_VER)) { |
| 687 | 674 | //tb_write_log("All up to date!"); |
| 688 | 675 | return; |
| @@ -694,9 +681,9 @@ | ||
| 694 | 681 | require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
| 695 | 682 | |
| 696 | 683 | |
| 697 | 684 | //check mysql version |
| 698 | - if (function_exists('mysqli_get_server_info') && version_compare(mysqli_get_server_info(), '4.1.0', '>=')) { | |
| 685 | + if (function_exists('mysql_get_server_info') && version_compare(mysql_get_server_info(), '4.1.0', '>=')) { | |
| 699 | 686 | if (!empty($wpdb->charset)) |
| 700 | 687 | $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; |
| 701 | 688 | if (!empty($wpdb->collate)) |
| 702 | 689 | $charset_collate .= " COLLATE $wpdb->collate"; |