PluginProbe
Taboola / 2.1.0
Taboola v2.1.0
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
← All changes | taboola_widget.php +35 -22 2.0.12.1.0 View file →
@@ -1,18 +1,18 @@
1 1 <?php
2 2 /**
3 3 * Plugin Name: Taboola
4 - * Plugin URI: https://developers.taboola.com/web-integrations/discuss
4 + * Plugin URI: https://developers.taboola.com/web-integrations/docs/wordpress-plugin
5 5 * Description: Taboola
6 - * Version: 2.0.1
6 + * Version: 2.1.0
7 7 * Author: Taboola
8 8 */
9 9
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)
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)
13 13
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'.
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'.
15 15
16 16 define ("TABOOLA_XPATH_MARKER","/");
17 17 define ("TABOOLA_JS_INDICATOR","{JS}");
18 18 define ("TABOOLA_JS_MARKER","{");
@@ -23,8 +23,9 @@
23 23
24 24 include_once('widget.php');
25 25 require_once('JavaScriptWrapper.php');
26 26
27 +
27 28 if (!class_exists('TaboolaWP')) {
28 29 class TaboolaWP
29 30 {
30 31 //save internal data
@@ -139,9 +140,10 @@
139 140 $head_string = "";
140 141
141 142 // Only adding the loader if a widget is going to be placed on the page.
142 143 if ($this->is_widget_on_page()){
143 -
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.
144 146 $stringParams = array(
145 147 '{{PUBLISHER_ID}}' => $this->settings->publisher_id,
146 148 '{{PAGE_TYPE}}' => $this->get_page_type(),
147 149 '{{WORDPRESS_VERSION}}' => get_bloginfo('version'),
@@ -439,34 +441,35 @@
439 441 add_menu_page('Taboola', 'Taboola', 'manage_options', 'taboola_widget', array(&$this, 'admin_taboola_settings'), $this->plugin_url.'img/taboola_icon.png', 110);
440 442 }
441 443
442 444 function admin_taboola_settings(){
445 +
443 446 global $wpdb;
444 447 $settings = $wpdb->get_row("select * from ".$wpdb->prefix."_taboola_settings limit 1");
445 448 $taboola_errors = array();
446 449 if($_SERVER['REQUEST_METHOD'] == 'POST'){
447 450
448 - if(trim($_POST['publisher_id']) == ''){
451 + if(trim(strip_tags($_POST['publisher_id'])) == ''){
449 452 $taboola_errors[] = "Publisher ID";
450 453 }
451 454
452 455 if(isset($_POST['first_bc_enabled'])) {
453 - if (trim($_POST['first_bc_widget_id']) == '') {
456 + if (trim(strip_tags($_POST['first_bc_widget_id'])) == '') {
454 457 $taboola_errors[] = "Below-article > Widget ID";
455 458 }
456 - if (trim($_POST['first_bc_placement']) == '') {
459 + if (trim(strip_tags($_POST['first_bc_placement'])) == '') {
457 460 $taboola_errors[] = "Below-article > Placement Name";
458 461 }
459 462 }
460 463
461 464 if(isset($_POST['mid_enabled'])) {
462 - if (trim($_POST['mid_widget_id']) == '') {
465 + if (trim(strip_tags($_POST['mid_widget_id'])) == '') {
463 466 $taboola_errors[] = "Mid-article > Widget ID";
464 467 }
465 - if (trim($_POST['mid_placement']) == '') {
468 + if (trim(strip_tags($_POST['mid_placement'])) == '') {
466 469 $taboola_errors[] = "Mid-article > Placement Name";
467 470 }
468 - if (trim($_POST['mid_location_string']) == '') {
471 + if (trim(strip_tags($_POST['mid_location_string'])) == '') {
469 472 $taboola_errors[] = "Mid-article > CSS selector";
470 473 }
471 474 else {
472 475 // If the 'location' WAS filled in, then...
@@ -486,16 +489,16 @@
486 489
487 490 }
488 491
489 492 if(isset($_POST['home_enabled'])) {
490 - if (trim($_POST['home_widget_id']) == '') {
493 + if (trim(strip_tags($_POST['home_widget_id'])) == '') {
491 494 $taboola_errors[] = "Homepage > Widget ID";
492 495 }
493 - if (trim($_POST['home_placement']) == '') {
496 + if (trim(strip_tags($_POST['home_placement'])) == '') {
494 497 $taboola_errors[] = "Homepage > Placement Name";
495 498 }
496 499
497 - if (trim($_POST['home_location_string']) == '') {
500 + if (trim(strip_tags($_POST['home_location_string'])) == '') {
498 501 $taboola_errors[] = "Homepage > CSS selector";
499 502 }
500 503 else {
501 504 // If the 'location' WAS filled in, then...
@@ -541,13 +544,23 @@
541 544 "home_location_string" => !empty($_POST['home_location_string']) ? trim($_POST['home_location_string']) : ''
542 545 );
543 546
544 547 //var_dump($settings);
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));
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;
549 553 }
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 +
550 563 }
551 564 $settings = $wpdb->get_row("select * from ".$wpdb->prefix."_taboola_settings limit 1");
552 565 }
553 566
@@ -667,9 +680,9 @@
667 680 }
668 681 }
669 682
670 683 function update_db(){
671 -
684 +
672 685 // If we are up to date, then skip this method...
673 686 if ($this->is_db_updated_for_min_ver(TABOOLA_MIN_VER)) {
674 687 //tb_write_log("All up to date!");
675 688 return;
@@ -681,9 +694,9 @@
681 694 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
682 695
683 696
684 697 //check mysql version
685 - if (function_exists('mysql_get_server_info') && version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
698 + if (function_exists('mysqli_get_server_info') && version_compare(mysqli_get_server_info(), '4.1.0', '>=')) {
686 699 if (!empty($wpdb->charset))
687 700 $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
688 701 if (!empty($wpdb->collate))
689 702 $charset_collate .= " COLLATE $wpdb->collate";