Plugin Directory

Changeset 2869284


Ignore:
Timestamp:
02/22/2023 10:36:00 AM (3 years ago)
Author:
taboolawordpress
Message:

Version 2.0.1

Location:
taboola
Files:
19 added
8 edited

Legend:

Unmodified
Added
Removed
  • taboola/trunk/JavaScriptWrapper.php

    r1640639 r2869284  
    4040    }
    4141
    42     function getScripMarkupString(){
     42    function getScriptMarkupString(){
    4343        return "<script type='text/javascript'>".$this."</script>";
    4444    }
  • taboola/trunk/js/js_inject.min.js

    r1640639 r2869284  
    1 function insertAfter(e,t){t.parentNode.insertBefore(e,t.nextSibling)}function getElementByXPath(e,t){if(!t)t=document;if(t.evaluate)return t.evaluate(e,document,null,9,null).singleNodeValue;while(e.charAt(0)=="/")e=e.substr(1);var n=t;var r=e.split("/");for(var i=0;i<r.length;i++){var a=r[i].split(/(\w*)\[(\d*)\]/gi).filter(function(e){return!(e==""||e.match(/\s/gi))},this);var l=a[0];var o=a[1]?a[1]-1:0;if(i<r.length-1)n=n.getElementsByTagName(l)[o];else return n.getElementsByTagName(l)[o]}}if(!Array.prototype.filter){Array.prototype.filter=function(e){var t=this.length>>>0;if(typeof e!="function"){throw new TypeError}var n=[];var r=arguments[1];for(var i=0;i<t;i++){if(i in this){var a=this[i];if(e.call(r,a,i,this)){n.push(a)}}}return n}}function injectWidgetByXpath(e){var t=getElementByXPath(e);if(t==null){t=document.getElementById("tbdefault")}innerInject(t)}function injectWidgetByMarker(e){var t=document.getElementById(e);innerInject(t.parentNode)}function innerInject(e){var t=document.createElement("span");var n=document.createElement("script");var r="if JS crashes here, the first innerHTML value should be enclosed with single quotes instead of double, go to the minified version and change it";t.innerHTML="{{HTML}}";n.innerHTML="{{SCRIPT}}";insertAfter(t,e);insertAfter(n,t)}
     1function insertAfter(e, t) {
     2    t.parentNode.insertBefore(e, t.nextSibling)
     3}
     4
     5function getElementByXPath(e, t) {
     6    if (!t) t = document;
     7    if (t.evaluate) return t.evaluate(e, document, null, 9, null).singleNodeValue;
     8    while (e.charAt(0) == "/") e = e.substr(1);
     9    var n = t;
     10    var r = e.split("/");
     11    for (var i = 0; i < r.length; i++) {
     12        var a = r[i].split(/(\w*)\[(\d*)\]/gi).filter(function(e) {
     13            return !(e == "" || e.match(/\s/gi))
     14        }, this);
     15        var l = a[0];
     16        var o = a[1] ? a[1] - 1 : 0;
     17        if (i < r.length - 1) n = n.getElementsByTagName(l)[o];
     18        else return n.getElementsByTagName(l)[o]
     19    }
     20}
     21if (!Array.prototype.filter) {
     22    Array.prototype.filter = function(e) {
     23        var t = this.length >>> 0;
     24        if (typeof e != "function") {
     25            throw new TypeError
     26        }
     27        var n = [];
     28        var r = arguments[1];
     29        for (var i = 0; i < t; i++) {
     30            if (i in this) {
     31                var a = this[i];
     32                if (e.call(r, a, i, this)) {
     33                    n.push(a)
     34                }
     35            }
     36        }
     37        return n
     38    }
     39}
     40
     41function injectWidgetByXpath(e) {
     42    var t = getElementByXPath(e);
     43    if (t == null) {
     44        t = document.getElementById("tbdefault")
     45    }
     46    innerInject(t)
     47}
     48
     49function injectWidgetByMarker(e) {
     50    var t = document.getElementById(e);
     51    innerInject(t.parentNode)
     52}
     53
     54function innerInject(e) {
     55    var t = document.createElement("span");
     56    var n = document.createElement("script");
     57    var r = "if JS crashes here, the first innerHTML value should be enclosed with single quotes instead of double, go to the minified version and change it";
     58    t.innerHTML = "{{HTML}}";
     59    n.innerHTML = "{{SCRIPT}}";
     60    insertAfter(t, e);
     61    insertAfter(n, t)
     62}
  • taboola/trunk/js/loaderInjectionScript.js

    r2828580 r2869284  
    33_taboola.push({listenTo:'render',handler:function(p){TRC.modDebug.logMessageToServer(2,"wordpress-integ");}});
    44_taboola.push({additional_data:{sdkd:{
    5     "os" : "Wordpress",
    6     "osv" : "{{WORDPRESS_VERSION}}",
    7     "php_ver" : "{{PHP_VERSION}}",
    8     "sdkt" : "Taboola Wordpress Plugin",
    9     "sdkv" : "{{PLUGIN_VERSION}}",
    10     "location" : "{{LOCATION}}"
    11 }}});
    12 !function (e, f, u) {
    13     e.async = 1;
    14   e.src = u;
    15   f.parentNode.insertBefore(e, f);
     5            "os": "Wordpress",
     6            "osv": "{{WORDPRESS_VERSION}}",
     7            "php_ver": "{{PHP_VERSION}}",
     8            "sdkt": "Taboola Wordpress Plugin",
     9            "sdkv": "{{PLUGIN_VERSION}}",
     10            "loc_mid": "{{LOC_MID}}",
     11            "loc_home": "{{LOC_HOME}}"
     12        }
     13    }
     14});
     15! function(e, f, u) {
     16    e.async = 1;
     17    e.src = u;
     18    f.parentNode.insertBefore(e, f);
    1619}(document.createElement('script'), document.getElementsByTagName('script')[0], '//cdn.taboola.com/libtrc/{{PUBLISHER_ID}}/loader.js');
  • taboola/trunk/readme.txt

    r2828580 r2869284  
    22Contributors: Taboola
    33Tags: content recommendations, taboola, discovery,ad networks, ads, advertising, affiliate, content ads, contextual ads, Contextual Advertising, engagement, income, monetization, monetize, pay per click, popular posts, posts, ppc, related, Related Content, related post thumbnails, related posts, relevant ads, revenue, similar posts, text ads, widgets,recommendations,thumbnails, traffic, widget
    4 Requires at least: 5.2.x
    5 Tested up to: 6.0.2
     4Requires at least: 5.2
     5Tested up to: 6.1.1
    66Stable tag: trunk
    77License: GNU General Public License v3.0
    8 License URI: https://www.gnu.org/licenses/gpl-3.0.txt
     8License URI: http://www.gnu.org/licenses/gpl-3.0.txt
    99
    1010Use the Taboola widget to generate revenue from 3rd-party content and increase engagement.
     
    6363== Changelog ==
    6464
    65 = 1.0.15 =
    66 * Added logging for PHP version.
     65= 2.0.1 =
     66* Minor UI improvements
     67
     68= 2.0.0 =
     69* Enhanced UI and functionality
     70* Support for below-article, mid-article and homepage widgets
     71* Tested on Wordpress 6.1.1
    6772
    6873= 1.0.14 =
    69 * Additional logging.
     74* Additional logging
    7075
    7176= 1.0.13 =
    72 * Minor fixes and improvements.
     77* Minor fixes and improvements
    7378
    7479= 1.0.12 =
    75 * Minor fix for PHP 8.0.x
     80* Minor Fix for PHP 8.0.x
    7681
    7782= 1.0.11 =
  • taboola/trunk/settings.php

    r2795104 r2869284  
     1<!-- Latest font-awesome include-->
     2<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
     3
     4<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
     5<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
     6<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
     7
    18<style>
     9
    210    .taboola-container {
    311        padding: 20px;
    412        padding-left: 0;
    5         width: 400px;
    613        font-size: 14px;
    7     }
    8     table {
    9         width: 380px;
    10         margin-left: 20px;
    11     }
    12     table td img {
     14        background-color: #FAF9F6;
     15        font-family: Roboto,Lato,Hind -apple-system,Helvetica Neue,sans-serif;
     16    }
     17
     18    .settings_block {
     19        background-color: #fff;
     20        border: 1px solid #d4d9df;
     21        border-radius: 8px;
     22        margin-top: 10px;
     23        width: 50%;
     24    }
     25
     26    .settings_block.widget_settings_block { /* Give the widget settings block some extra space at the end */
     27        padding-bottom: 15px;
     28    }
     29
     30    .settings_block input {
     31        border-color: #ccc; /* Most of the inputs are styled via jQuery. This is for any others - e.g. #publisher-id */
     32    }
     33
     34    .publisher_welcome_massage{
     35        float: right;
     36        width: 36%;
     37        padding: 20px 10px 10px 0px;
     38        margin: 40px 6% 0 0;
     39        background: #FFFACD;
     40        border: 1px solid #d4d9df;
     41        border-radius: 20px;
     42    }
     43
     44    .switch_style{
     45        margin : 10px 10px 20px 10px;
     46    }
     47
     48    .style_box1, .pub_id{
     49        padding: 10px 10px 0px 20px;
     50    }
     51
     52    .statement{
     53        padding: 10px 10px 10px 20px;
     54    }
     55
     56    .widget_below, .widget_below_mid, .widget_below_mid_selector, .widget_below_home, .widget_below_home_selector{
     57        width: 50%;
     58        float: left;
     59        padding: 5px 0px 0px 20px;
     60    }
     61   
     62    .mode_style, .mode_style_mid, .mode_style_home, .mode_style_home_selector{
     63        width: 50%;
     64        padding: 0px 0px 3px 20px;
     65        float:left;
     66    }
     67
     68    .placement_style, .placement_style_mid, .placement_style_home_occurrence,.placement_style_home {
     69        padding: 0px 0px 8px 0px;
     70        width: 50%;
     71        float: right;
     72    }
     73
     74    .widget_below_mid_selector{
     75        padding: 8px 0px 0px 0px;
     76    }
     77
     78    .placement_below_mid_occurrence,.mode_style_mid_selector {
     79        padding: 0px 0px 8px 20px;
     80    }
     81
     82    .heading_mid_home{
     83        padding: 20px 0px 8px 20px;
     84    }
     85
     86    #mid_occurrence_div, #mid_css_selector_div {
     87        width: 50%;
     88        float: left;
     89        margin: 19px 0px 0px 0px;
     90    }
     91
     92    /* slider button CSS */
     93
     94    .switch {
    1395        position: relative;
    14         top: 3px;
    15         margin-left: 5px;
    16     }
    17         /*    table {
    18                 padding: 12px;
    19                 border: 3px solid #467FD7;
    20                 border-radius: 5px;
    21                 margin-top: 10px;
    22                 width: 100%;
    23             }*/
    24     table tr td:first-child {
    25         width: 110px;
    26     }
    27     table input {
    28         width: 100%;
    29     }
    30     input[type='text'] {
    31         border-radius: 3px;
    32     }
    33     hr {
    34         margin-top: 15px;
    35         margin-bottom: 15px;
    36         border-bottom: none;
    37     }
    38     input[type='checkbox'] {
    39 
    40     }
    41     input[type='submit']{
     96        display: inline-block;
     97        width: 45px;
     98        height: 20px;
    4299        float: right;
    43100    }
    44     .checkbox {
    45         margin-bottom: 10px;
    46     }
     101
     102    .switch input {
     103        opacity: 0;
     104        width: 0;
     105        height: 0;
     106    }
     107
     108    .slider {
     109        position: absolute;
     110        cursor: pointer;
     111        top: 0;
     112        left: 0;
     113        right: -1px;
     114        bottom: 0;
     115        background-color: #ccc;
     116        -webkit-transition: .4s;
     117        transition: .4s;
     118    }
     119
     120    .slider:before {
     121        position: absolute;
     122        content: "";
     123        height: 18px;
     124        width: 18px;
     125        left: 1px;
     126        bottom: 1px;
     127        background-color: white;
     128        -webkit-transition: .4s;
     129        transition: .4s;
     130    }
     131
     132    input:checked + .slider {
     133        background-color: #0f4c81;
     134    }
     135
     136    input:focus + .slider {
     137        box-shadow: 0 0 1px #0f4c81;
     138    }
     139
     140    input:checked + .slider:before {
     141        -webkit-transform: translateX(26px);
     142        -ms-transform: translateX(26px);
     143        transform: translateX(26px);
     144    }
     145
     146    /* Rounded sliders */
     147
     148    .slider.round {
     149        border-radius: 34px;
     150    }
     151
     152    .slider.round:before {
     153        border-radius: 50%;
     154    }
     155
     156    /* slider button CSS */
     157
    47158    .request_link {
    48159        float: right;
     
    50161        line-height: 26px;
    51162    }
    52     table .tooltip {
    53         /*        position:relative;
    54                 top:50px;
    55                 left:50px;*/
    56     }
    57     .tooltip div { /* hide and position tooltip */
    58         background-color: black;
    59         color: white;
    60         border-radius: 5px;
    61         opacity: 0;
     163
     164/* hide and position tooltip */
     165
     166    .tooltip div{
     167        visibility: hidden;
     168        width: auto;
     169        display: inline-block;
     170        background: #0f4c81;
     171        color: #ffffff;
     172        font-weight: normal;
     173        font-size: 12px;
     174        border-radius: 6px;
     175        padding: 5px;
     176        margin-left: 5px;
     177        max-width: 350px;
    62178        position: absolute;
    63         -webkit-transition: opacity 0.5s;
    64         -moz-transition: opacity 0.5s;
    65         -ms-transition: opacity 0.5s;
    66         -o-transition: opacity 0.5s;
    67         transition: opacity 0.5s;
    68         width: 200px;
    69         padding: 10px;
    70         margin-left: 30px;
    71         margin-top: -45px;
    72     }
    73     table .tooltip:hover div { /* display tooltip on hover */
    74         opacity:1;
    75     }
     179        z-index: 999;
     180        transition-delay: 0.25s;
     181    }
     182
     183    .tooltip div a:hover{
     184        text-decoration: underline;
     185    }
     186
     187    .tooltip{
     188        opacity: 1 !important;
     189        font-size: 13px !important;
     190        display: contents !important;
     191    }
     192
     193    .tooltip:hover div{
     194        visibility: visible;
     195        transition-delay: 0.5s;
     196    }
     197
     198    .tooltip div a{
     199        text-decoration: none;
     200        font-weight: bold;
     201        color: #fff;
     202    }
     203
    76204    .label-success {
    77         font-size: 17px;
     205        background: #a4fba6 !important;
     206        border: 1px solid #d2f2d4;
     207        border-radius: 10px;
     208        padding: 10px 30px 20px 10px;
     209        font-size: 14px;
    78210        display: block;
    79211        margin-top: 10px;
    80212        color: green;
     213        width: 50%;
    81214    }
    82215    .label-error {
    83         font-size: 17px;
     216        background: #ffbaba;
     217        border: 1px solid #ffbaba;
     218        border-radius: 10px;
     219        padding: 10px 30px 20px 10px;
     220        font-size: 14px;
    84221        display: block;
    85222        margin-top: 10px;
    86223        color: red;
    87     }
    88 
    89     .toggle_icon{
    90         background: url(<?php echo $this->plugin_url.'img/arrow_right_32.png' ?>) no-repeat;
    91         background-size:contain;
    92         width:24px;
    93         height:24px;
    94         display:inline-block;
    95         vertical-align: middle;
    96     }
    97 
    98     .toggle_icon_on{
    99         -ms-transform: rotate(90deg); /* IE 9 */
    100         -webkit-transform: rotate(90deg); /* Chrome, Safari, Opera */
    101         transform: rotate(90deg);
    102     }
     224        width: 50%;
     225    }
     226
     227    .label-error ul {
     228        list-style-position: inside;
     229        list-style-type: disc;
     230        text-indent: 2em;
     231    }
     232
     233    .label-error p {
     234        font-size: 14px;
     235    }
     236
     237    .change_button{
     238        float: right;
     239    }
     240
    103241    .apply_button{
    104         margin-top: 20px !important;
     242        /* margin-top: 20px; */
     243        background-color: #0f4c81;
     244        color: #fff;
     245        padding: 0.8rem 1rem;
     246        border-radius: 7px;
     247        border: transparent;
     248        float: right;
     249    }
     250
     251    .apply_button:hover {
     252        background-color: #1261A0;
     253        cursor: pointer;
     254    }
     255
     256    .helpTooltip__icon___1XWGN,
     257    .helpTooltip__icon___1XWGN_read{
     258        color: #b8c1ca;
     259        width: 1em;
     260        height: 1em;
     261        margin: 4px;
     262    }
     263
     264    .helpTooltip__icon___1XWGN_read{
     265        margin-top: 4px;
     266    }
     267
     268    .helpTooltip__icon___1XWGN_first{
     269        color: #b8c1ca;
     270        width: 1em;
     271        height: 1em;
     272    }
     273
     274    .checkbox_read{
     275        padding: 0px 0px 5px 20px;
     276        float: left;
     277    }
     278
     279    label:hover{
     280        cursor: default;
     281    }
     282
     283    ::placeholder{
     284        color: #DEDEDE;
     285    }
     286
     287    .widget_h2,.general_h2{
     288        font-size: 18px;
     289        font-weight: 500;
     290    }
     291
     292    .list_l1{
     293        border-top: 1px solid #DEDEDE;
     294        margin: 30px 20px 0px 0px;
     295        margin-left: 14%;
     296    }
     297
     298    .theme_image{
     299        width: 50%;
     300    }
     301
     302    .welcome_heading{
     303        margin-left: 8%;
     304        font-size: 1.5em;
     305    }
     306
     307    .first_p,
     308    .second_p{
     309        margin-left: 14%;
     310        font-size: 14px;
     311    }
     312
     313    .list_l1 p{
     314        font-size: 13px;
     315    }
     316
     317    input#publisher-id,
     318    input#first_bc_placement,
     319    input#mid_placement,
     320    input#home_placement{
     321        width: 36%;
     322    }
     323
     324    input#first_bc_widget_id,
     325    input#mid_widget_id,
     326    input#mid_location_string,
     327    input#home_widget_id,
     328    input#home_location_string{
     329        width: 77%;
     330    }
     331   
     332    label{
     333        font-weight: normal !important;
     334    }
     335
     336    label#pub_id{
     337        color: #000000;
     338    }
     339
     340    input#out_of_content_enabled {
     341        height: 16px;
     342        width: 16px;
     343    }
     344
     345    input[type=checkbox]:checked::before {
     346        width: 1.8rem !important;
     347    }
     348
     349    input[type=checkbox]:focus {
     350        outline: none !important;
     351        outline-offset: 0px !important;
     352    }
     353
     354    input[type=checkbox]{
     355        margin: -5px 0 0;
     356    }
     357
     358    #homepage{
     359        display: none;
     360    }
     361
     362    #show-advanced-settings{
     363        text-decoration: none;
     364        color: #666666;
     365        margin-top: 5px;
     366        cursor: pointer;
     367        float: left;
     368        width: 50%;
     369        font-family: Roboto, Lato, "Hind -apple-system", "Helvetica Neue", sans-serif;
     370        font-style: italic;
     371    }
     372
     373    #advanced-settings-main{
     374        margin: 10px 0px 0px 10px;
     375        width: 49%;
     376    }
     377
     378    div#mid_article {
     379        padding-bottom: 100px;
     380    }
     381
     382    #mid_css_selector_div{
     383        display: none;
     384    }
     385
     386    input.highlight {
     387        border: 1px solid orange !important;
    105388    }
    106389
    107390</style>
    108391
     392<?php
     393
     394// $short_version =strlen(TABOOLA_PLUGIN_VERSION) == 5 ? substr(TABOOLA_PLUGIN_VERSION,0,3) : ""; // E.g. '2.1.0' => '2.1' (else '')
     395
     396?>
     397
     398  <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
     399  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script> -->
     400
     401
    109402<div class="taboola-container">
    110     <img src='<?php echo $this->plugin_url.'img/taboola.png' ?>' style='width:200px;'/>
    111     <hr>
     403    <div class="theme_image">
     404        <img src='<?php echo $this->plugin_url.'img/taboola.png' ?>' style='width:150px;'/>
     405    </div>
     406
     407    <h2 style="font-size:1.7em;">Taboola WordPress Plugin 2</h2>
     408
     409<!-- errors/success message -->
     410
     411    <?php
     412    if($_SERVER['REQUEST_METHOD'] == 'POST' && count($taboola_errors) == 0){
     413        echo "<div class='label-success'>";
     414        echo "<h3 style='color:green;'>Changes applied!</h3>";
     415        echo "<span>Verify the new changes by browsing to your site.</span>";
     416        echo "</div>";
     417    }
     418   
     419    if(count($taboola_errors) > 0){
     420        echo "<div class='label-error'>";
     421            echo "<h3 style='color:red;'>Missing or incorrect values</h3>";
     422            echo "<p>The following fields contained missing or incorrect values:</p>";
     423            echo "<ul>";
     424            for($i = 0; $i < count($taboola_errors); $i++){
     425                echo "<li>".$taboola_errors[$i]."</li>";
     426            }
     427            echo "</ul>";
     428            echo "<p><b>All values</b> have been reverted to the last successful save.</p>";
     429        echo "</div>";
     430    }
     431
     432    ?>
     433
     434<script>
     435    function setEnabledDisabled(divID, chkToggle) {
     436        /*
     437            JS function for form.
     438            Enables/disables fields for the given section ('divID'), depending on whether 'chkToggle' is checked.
     439        */
     440
     441        var applyColor = (chkToggle.checked ? "#000" : "#666");
     442
     443        // Set all labels in that section ('divID') to the relevant color.
     444        $(divID).find("label").css("color", applyColor);
     445
     446        // Disable (/enable) all input fields in that section ('divID'), except for 'chkToggle'.
     447        // Once done, apply a gray border color.
     448        $(divID).find("input").not("#" + chkToggle.id).prop("disabled", !chkToggle.checked).css("borderColor", "#ccc");
     449        $(divID).find("select").not("#" + chkToggle.id).prop("disabled", !chkToggle.checked).css("borderColor", "#ccc");
     450
     451    }
     452</script>
     453
     454<script>
     455$(document).ready(function(){
     456    // On page load:
     457    if ($('#mid_paragraph_ui_mode').val() == 'Other') {
     458        $("#mid_css_selector_div").show();
     459    }
     460
     461    if ($('#home_enabled').prop("checked") === true) {
     462        $("#homepage").show();
     463        var ad = $('#show-advanced-settings');
     464        ad.text("<< Hide advanced settings");
     465    }       
     466});
     467</script>
     468
     469<script>
     470$(document).ready(function(){
     471 // On clicking 'Advanced settings'
     472    $("#show-advanced-settings").click(function() {
     473        $("#homepage").slideToggle("fast");
     474        var ad = $('#show-advanced-settings');
     475        ad.text() == "Show advanced settings >>" ? ad.text("<< Hide advanced settings") : ad.text("Show advanced settings >>");
     476    });
     477});
     478</script>
     479
     480
     481<script>
     482$(document).ready(function(){
     483
     484    // On selecting an item in the dropdown:
     485    $('#mid_paragraph_ui_mode').on('change', function(e){
     486        e.preventDefault();
     487        if ( this.value == 'Other')
     488        {
     489            $("#mid_css_selector_div").show();
     490
     491            // Highlight relevant fields:
     492            $("#mid_location_string, #mid_occurrence").addClass('highlight');
     493            setTimeout(() => $("#mid_occurrence, #mid_location_string").removeClass('highlight'), 1500);
     494           
     495        }
     496        else
     497        {
     498            $("#mid_location_string").val("p"); // Set it back to the default value of 'p'
     499            $("#mid_css_selector_div").hide();
     500
     501            // Highlight the 'occurrence' field:
     502            $("#mid_occurrence").addClass('highlight');
     503            setTimeout(() => $("#mid_occurrence").removeClass('highlight'), 1000);           
     504        }
     505    });
     506
     507});
     508</script>
     509
     510
     511
     512<!-- Welcome Massage -->
     513
     514    <div class="publisher_welcome_massage">
     515        <h2 class="welcome_heading">Welcome to Taboola WordPress Plugin 2!</h2>
     516        <p class="first_p">For detailed instructions, see the <a href="https://developers.taboola.com/web-integrations/docs/wordpress-plugin-managing-placements" target='_blank'>Taboola Dev Center.</a></p>
     517        <p class="second_p"><b>Stuck? Need a hand?</b> Feel free to reach out via our <a href="https://developers.taboola.com/web-integrations/discuss" target='_blank'>Online Community</a>.</p>
     518        <div class="list_l1">
     519            <p>Usage of this plugin is subject to <b>Taboola's</b> <a href="https://www.taboola.com/policies/platform-terms-of-service" target='_blank'>terms of service.</a></p>
     520        </div>
     521    </div>
     522
     523<!--  Welcome Massage-->
    112524
    113525    <form method="POST">
    114         <table>
    115             <tr>
    116                 <td>Publisher ID</td>
    117                 <td>
    118                     <input type="text" name="publisher_id" placeholder="publisher" value="<?php echo !empty($settings->publisher_id) ? htmlspecialchars($settings->publisher_id) : '' ?>"/>
    119                 </td>
    120                 <td class='tooltip'>
    121                     <img src='<?php echo $this->plugin_url.'img/question-mark.png' ?>'/>
    122                     <div>Please contact your Taboola representative to receive the Publisher ID </div>
    123                 </td>
    124             </tr>
    125             <tr>
    126                 <td colspan='2' style='line-height: 26px; font-size: 13px;'>
    127                     Don't have a Publisher ID?
    128                     <a style='float: inherit; margin-left:5px;' class='request_link' href=' https://taboola.com/contact' target='_blank'>Contact Taboola</a>
    129                 </td>
    130             </tr>
    131         </table>
    132 
    133         <hr style='margin-bottom: 25px; margin-top: 5px;'>
    134 
    135         <div class='checkbox'>
    136             <input id="first_bc_enabled" type="checkbox" <?php echo !empty($settings->first_bc_enabled) ? "checked='checked'" : "" ?> name="first_bc_enabled"/>
    137             Below Article
     526        <h2 class="general_h2">General Settings</h2>
     527   
     528        <div class="settings_block">
     529            <div class="style_box1"><label id="pub_id">Publisher ID :</label>
     530             <div class="tooltip">
     531                    <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     532                    <!-- <img class="helpTooltip__icon___1XWGN" src='<?php echo $this->plugin_url.'img/tooltip_image.svg' ?>'/> -->
     533                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN_first">
     534                            <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     535                        </g>
     536                    </svg>
     537                    <!-- <div id="arrow" ></div> -->
     538                    <div>Your Publisher ID, as provided by Taboola.</div>
     539                </div>
     540            </div>
     541            <div class="pub_id">
     542                <input id="publisher-id" type="text" name="publisher_id" placeholder="publisher" value="<?php echo !empty($settings->publisher_id) ? htmlspecialchars($settings->publisher_id) : '' ?>"/>
     543            </div>
     544            <div class="statement">
     545                <label style="color: #000000;">Don't have an account with taboola?</label>
     546                <a style='float: inherit;' class='request_link' href='http://taboola.com/contact' target='_blank'>Contact us</a>
     547                <label style="margin-left: -9px; color: #000000;">to get started.</label>
     548            </div>
    138549        </div>
    139         <table>
    140             <tr>
    141                 <td>Widget ID</td>
    142                 <td>
    143                     <input type="text" value="<?php echo !empty($settings->first_bc_widget_id) ? htmlspecialchars($settings->first_bc_widget_id) : '' ?>" name="first_bc_widget_id" placeholder="Widget ID" />
    144                 </td>
    145                 <td class='tooltip'>
    146                     <img src='<?php echo $this->plugin_url.'img/question-mark.png' ?>'/>
    147                     <div>Please contact your Taboola representative to receive the Widget ID</div>
    148                 </td>
    149             </tr>
    150 
    151         </table>
    152         <hr>
    153 
    154         <div class='checkbox'>
    155             <input id="second_bc_enabled" type="checkbox" <?php echo !empty($settings->second_bc_enabled) ? "checked='checked'" : "" ?> name="second_bc_enabled"/>
    156             Below Article 2nd
     550
     551
     552<!-- Below Article Widget -->
     553    <h2 class="widget_h2">Taboola Units</h2>
     554    <div id="below_article" class="settings_block widget_settings_block">
     555          <div class="switch_style">
     556            <label class="switch">
     557              <input id="first_bc_enabled" type="checkbox" <?php echo !empty($settings->first_bc_enabled) ? "checked='checked'" : "" ?> onclick="setEnabledDisabled('#below_article', this)" name="first_bc_enabled" />
     558              <span class="slider round"></span>
     559            </label>
     560            <b style="font-size:15px;">Below-article</b>
     561          </div>
     562          <div class="label_below">
     563            <div class="mode_style">
     564              <label id="first_bc_widget_id_label" style="float:left;">Mode (Widget ID):</label>
     565              <div class="tooltip">
     566                <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     567                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     568                  <g fill="none" fill-rule="evenodd">
     569                    <path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     570                  </g>
     571                </svg>
     572                <div>Your <i>below-article</i> Mode (Widget ID), as provided by Taboola. </div>
     573              </div>
     574            </div>
     575            <div class="placement_style">
     576              <label id="first_bc_placement_label" style="float:left;">Placement Name:</label>
     577              <div class='tooltip'>
     578                <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     579                <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     580                  <g fill="none" fill-rule="evenodd">
     581                    <path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     582                  </g>
     583                </svg>
     584                <div>Your <i>below-article</i> Placement Name, as provided by Taboola. <br>
     585                  <br> When upgrading from v1, fill in 'below-article'. <br>
     586                  <br> For more information, reach out via our <a href="https://developers.taboola.com/web-integrations/discuss" target='_blank'>Online Community</a>, or contact Taboola Support.
     587                </div>
     588              </div>
     589            </div>
     590          </div>
     591          <div class="input_below">
     592            <div class="widget_below">
     593              <input id="first_bc_widget_id" type="text" value="<?php echo !empty($settings->first_bc_widget_id) ? htmlspecialchars($settings->first_bc_widget_id) : "" ?>" name="first_bc_widget_id" placeholder="Widget ID" />
     594            </div>
     595            <div class="placement_below">
     596              <input type="text" id="first_bc_placement" value="<?php echo !empty($settings->first_bc_placement) ? htmlspecialchars($settings->first_bc_placement) : "" ?>" name="first_bc_placement" placeholder="Placement Name" />
     597            </div>
     598          </div>
     599
     600          <!-- Below Article Widget -->
     601          <!-- Advanced Settings -->
     602          <br />
     603          <div class='location_section'>
     604            <div class='checkbox_read'>
     605              <input id="out_of_content_enabled" type="checkbox" <?php echo !empty($settings->out_of_content_enabled) ? "checked='checked'" : "" ?> name="out_of_content_enabled" />
     606              <label id="out_of_content_enabled_label">Place the feed/widget just after the article container (required for <b>Read More</b>)</label>
     607            </div>
     608            <div class='tooltip'>
     609              <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN_read">
     610                <g fill="none" fill-rule="evenodd">
     611                  <path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     612                </g>
     613              </svg>
     614              <div>
     615                Required in order for Taboola to activate <i>Read More</i>.<br><br>
     616                Read More buttons can boost audience engagement significantly, especially on mobile devices.<br><br>
     617                For more information, see the <a href="https://developers.taboola.com/web-integrations/docs/wordpress-plugin-managing-placements#below-article-widget" target='_blank'>Taboola Dev Center</a>.</div>
     618            </div>
     619          </div>
    157620        </div>
    158 
    159         <table>
    160             <tr>
    161                 <td>Widget ID</td>
    162                 <td>
    163                     <input type="text" value="<?php echo !empty($settings->second_bc_widget_id) ? htmlspecialchars($settings->second_bc_widget_id) : '' ?>" name="second_bc_widget_id" placeholder="Widget ID" />
    164                 </td>
    165                 <td class='tooltip'>
    166                     <img src='<?php echo $this->plugin_url.'img/question-mark.png' ?>'/>
    167                     <div>Please contact your Taboola representative to receive the Widget ID</div>
    168                 </td>
    169             </tr>
    170 
    171         </table>
    172         <hr style='border-bottom: 1px solid #fafafa;'>
    173 
    174         <?php $location_defined = !empty($settings->location_string); ?>
    175 
    176 
    177         <div class='toggle_intercept checkbox'>
    178             <?php if ($location_defined): ?>
    179                 <div class='toggle_icon toggle_icon_on'></div>
    180                  Advanced Settings
    181                 </div>
    182                 <table class='location_section'>
    183 
    184             <?php else: ?>
    185                 <div class='toggle_icon'></div>
    186                  Advanced Settings
    187                 </div>
    188                 <table class='location_section' style='display:none'>
    189 
    190             <?php endif; ?>
    191 
    192             <tr>
    193                 <td>Location</td>
    194                 <td>
    195                     <input type="text" value="<?php echo !empty($settings->location_string) ? htmlspecialchars($settings->location_string) : '' ?>" name="location_string" placeholder="" />
    196                 </td>
    197                 <td class='tooltip'>
    198                     <img src='<?php echo $this->plugin_url.'img/question-mark.png' ?>'/>
    199                     <div>This field controls the location of these widgets on the page. If you would like to move your widget from its default location directly below the article a Taboola representative will provide you with the necessary information.</div>
    200                 </td>
    201             </tr>
    202             <tr>
    203                 <td colspan="2"> <div class='checkbox'>
    204                         <input id="out_of_content_enabled" type="checkbox" <?php echo !empty($settings->out_of_content_enabled) ? "checked='checked'" : "" ?> name="out_of_content_enabled"/>
    205                         Place widget after main content DOM element
    206                     </div></td>
    207                 <td class='tooltip'>
    208                     <img src='<?php echo $this->plugin_url.'img/question-mark.png' ?>'/>
    209                     <div>This may be disabled if your website doesn't use Taboola's "Read more" feature, or if the widget is not placed correctly. DO NOT disable it if your widget includes "Read More"</div>
    210                 </td>
    211 
    212             </tr>
    213 
    214         </table>
    215         <input class='button-secondary apply_button' type="submit" value="Apply Changes ✔"/>
    216         <!--         <a class='request_link' href=' https://taboola.com/contact' target='_blank'>Request Widget</a> -->
     621<!-- Advanced Settings -->
     622
     623<!-- Mid Article Widget -->
     624
     625<div id="mid_article" class="settings_block widget_settings_block">
     626            <div class="switch_style">
     627                <label class="switch">
     628                <input id="mid_enabled" type="checkbox" <?php echo !empty($settings->mid_enabled) ? "checked='checked'" : "" ?> onclick="setEnabledDisabled('#mid_article', this)" name="mid_enabled"/>
     629                    <span class="slider round"></span>
     630                </label>
     631                <b style="font-size:15px;">Mid-article</b>
     632            </div>
     633
     634            <div>
     635                <div class="mode_style_mid"><label id="mid_widget_id_label" style="float:left;">Mode (Widget ID):</label>
     636                    <div class='tooltip'>
     637                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     638                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     639                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     640                             </g>
     641                         </svg>
     642                        <div>Your <i>mid-article</i> Mode (Widget ID), as provided by Taboola.</div>
     643                    </div>
     644                </div>
     645                <div class="placement_style_mid"><label id="mid_placement_label" style="float:left;">Placement Name:</label>
     646                    <div class='tooltip'>
     647                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     648                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     649                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     650                             </g>
     651                         </svg>
     652                        <div>Your <i>mid-article</i> Placement Name, as provided by Taboola.</div>           
     653                    </div>
     654                </div>
     655            </div>
     656            <div>
     657                <div class="widget_below_mid">
     658                    <input id="mid_widget_id" type="text" value="<?php echo !empty($settings->mid_widget_id) ? htmlspecialchars($settings->mid_widget_id) : "" ?>" name="mid_widget_id" placeholder="Widget ID" />
     659                </div>
     660                <div class="placement_below_mid">
     661                    <input id = "mid_placement" type="text" value="<?php echo !empty($settings->mid_placement) ? htmlspecialchars($settings->mid_placement) : "" ?>" name="mid_placement" placeholder="Placement Name" />
     662                </div>
     663            </div>
     664
     665            <div id="mid_occurrence_div">
     666                <div class="mode_style_mid_selector"><label id="mid_location_string_label" style="float:left;">Position the widget below:</label>
     667                    <div class='tooltip'>
     668                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     669                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     670                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     671                                </g>
     672                         </svg>
     673                         <div>
     674                            Enter the paragraph number to target. <br>
     675                            E.g. To target the <b>5th</b> paragraph, fill in <i>5</i>.<br><br>
     676                            ----<br>
     677                            <i>Advanced</i> - to use a <b>custom</b> selector:<br><br>
     678                            1) Choose 'Other'. <br>
     679                            2) Fill in a selector (<i>right</i>), and an occurrence (<i>left</i>).
     680                        </div>
     681                    </div>
     682                </div>
     683                <div class="placement_below_mid_occurrence">
     684                    <select name="mid_paragraph_ui_mode" id="mid_paragraph_ui_mode">
     685                        <option value="Paragraph" <?php echo (!empty($settings->mid_paragraph_ui_mode) && $settings->mid_paragraph_ui_mode == "Paragraph") ? "selected" : ""?> >Paragraph</option>
     686                        <option value="Other" <?php echo (!empty($settings->mid_paragraph_ui_mode) && $settings->mid_paragraph_ui_mode == "Other") ? "selected" : ""?>>Other</option>
     687                    </select>&nbsp;
     688                    <input type="number" id="mid_occurrence" value="<?php echo !empty($settings->mid_location_string_occurrence) ? $settings->mid_location_string_occurrence : "1" ?>" name="mid_location_string_occurrence" placeholder="" style="width:65px;">
     689                </div>
     690
     691            </div>
     692            <div id="mid_css_selector_div">
     693
     694                <div class="placement_style_mid_occurrence"><label id="mid_occurrence_label" style="float:left;">CSS selector :</label>
     695                    <div class='tooltip'>
     696                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     697                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     698                                </g>
     699                         </svg>
     700                         <div>
     701                            <i>Advanced</i> - fill in a selector to target - e.g.:<br><br>
     702                            <i>#my-id</i> - to target an <i>ID</i> of "my-id".<br>
     703                            <i>.my-class</i> - to target a <i>class</i> of "my-class".
     704                        </div>
     705                    </div>
     706                </div>
     707                <div class="widget_below_mid_selector">
     708                    <input id = "mid_location_string" type="text" value="<?php echo !empty($settings->mid_location_string) ? htmlspecialchars($settings->mid_location_string) : "p" ?>" name="mid_location_string" placeholder="E.g. p for paragraph" />
     709                </div>
     710            </div>
     711    </div>
     712<!-- Mid Article Widget -->
     713
     714<!-- Homepage mid widget -->
     715
     716
     717<div id="homepage" class="settings_block widget_settings_block">
     718        <div class="switch_style">
     719                <label class="switch">
     720                <input id="home_enabled" type="checkbox" <?php echo !empty($settings->home_enabled) ? "checked='checked'" : "" ?> onclick="setEnabledDisabled('#homepage', this)" name="home_enabled"/>
     721                <span class="slider round"></span>
     722                </label>
     723                <div>
     724                    <b style="font-size:15px;float: left;">Homepage (front page)</b>
     725                    <div class='tooltip'>
     726                            <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     727                            <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     728                                    <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     729                                    </g>
     730                            </svg>
     731                            <div>Settings will be applied to the page that you marked as your 'front page'.</div>
     732                        </div>
     733                    </div>
     734                </div>
     735
     736            <div>
     737                <div class="mode_style_home"><label id="home_widget_id_label" style="float:left;">Mode (Widget ID):</label>
     738                    <div class='tooltip'>
     739                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     740                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     741                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     742                                </g>
     743                         </svg>
     744                        <div>Your <i>homepage</i> Mode (Widget ID), as provided by Taboola.</div>
     745                    </div>
     746                </div>
     747                <div class="placement_style_home"><label id="home_placement_label" style="float:left;">Placement Name:</label>
     748                    <div class='tooltip'>
     749                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     750                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     751                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     752                                </g>
     753                         </svg>
     754                        <div>Your <i>homepage</i> Placement Name, as provided by Taboola.</div>           
     755                    </div>
     756                </div>
     757            </div>
     758            <div>
     759                <div class="widget_below_home">
     760                    <input id="home_widget_id" type="text" value="<?php echo !empty($settings->home_widget_id) ? htmlspecialchars($settings->home_widget_id) : "" ?>" name="home_widget_id" placeholder="Widget ID" />
     761                </div>
     762                <div class="placement_below_home">
     763                    <input id = "home_placement" type="text" value="<?php echo !empty($settings->home_placement) ? htmlspecialchars($settings->home_placement) : "" ?>" name="home_placement" placeholder="Placement Name" />
     764                </div>
     765            </div>
     766
     767            <div class='heading_mid_home'><label style="float:left;">Position the widget immediately below the element:</label>
     768            <div class='tooltip'>
     769                    <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     770                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     771                            <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     772                            </g>
     773                    </svg>
     774                    <div>The widget will be placed <i>just beneath</i> this element.<br><br>
     775                            To target an element, 2 pieces of information are needed:<br><br>
     776                            i) A CSS selector - e.g. <i>p</i> (for paragraph).<br>
     777                            ii) An occurrence - e.g. 1st, 2nd, 3rd, etc.<br><br>
     778                            For more information, see the <a href="https://developers.taboola.com/web-integrations/docs/wordpress-plugin-managing-placements" target='_blank'>Taboola Dev Center</a>.
     779                </div>
     780            </div>
     781        </div>
     782
     783
     784        <div class="home_occurrence">
     785                <div class="mode_style_home_selector"><label id="home_location_string_label" style="float:left;">CSS selector :</label>
     786                    <div class='tooltip'>
     787                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     788                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     789                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     790                                </g>
     791                         </svg>
     792                         <div>
     793                            The element to target - e.g.:<br><br>
     794                            <i>section</i> - to target a <i>section</i>.<br>
     795                            <i>#my-id</i> - to target an <i>ID</i> of "my-id".<br>
     796                            <i>.my-class</i> - to target a <i>class</i> of "my-class".
     797                        </div>
     798                    </div>
     799                </div>
     800                <div class="placement_style_home_occurrence"><label id="home_occurrence_label" style="float:left;">Occurrence :</label>
     801                    <div class='tooltip'>
     802                        <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
     803                        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
     804                                <g fill="none" fill-rule="evenodd"><path fill="currentColor" d="M12 2c5.52 0 10 4.48 10 10s-4.48 10-10 10S2 17.52 2 12 6.48 2 12 2zm-1 15.505v.99c0 .291.226.505.505.505h.99c.291 0 .505-.226.505-.505v-.99a.497.497 0 0 0-.505-.505h-.99a.497.497 0 0 0-.505.505zm4.07-6.255c.57-.57.93-1.37.93-2.25 0-2.21-1.79-4-4-4S8 6.79 8 9h2c0-1.1.9-2 2-2s2 .9 2 2c0 .55-.22 1.05-.59 1.41l-1.24 1.26C11.45 12.4 11 13.4 11 14.5v.5h2c0-1.5.45-2.1 1.17-2.83l.9-.92z"></path>
     805                                </g>
     806                         </svg>
     807                         <div>For a <b>non-unique</b> selector - e.g. <i>section</i> - fill in the <b>occurrence</b> to target.<br><br>
     808                        E.g. To target the <b>2nd</b> section, fill in <i>2</i>. <br><br>
     809                        For a <b>unique</b> selector - e.g. <i>#my-id</i> - leave the default value of '1'.</div>           
     810                    </div>
     811                </div>
     812            </div>
     813            <div class="home_placement">
     814                <div class="widget_below_home_selector">
     815                    <input id = "home_location_string" type="text" value="<?php echo !empty($settings->home_location_string) ? htmlspecialchars($settings->home_location_string) : "" ?>" name="home_location_string" placeholder="E.g. p for paragraph" /></td>
     816                </div>
     817                <div class="placement_below_home_Occurrence">
     818                    <input type="number" id="home_occurrence" value="<?php echo !empty($settings->home_location_string_occurrence) ? $settings->home_location_string_occurrence : "1" ?>" name="home_location_string_occurrence" placeholder="" style="width:65px;">
     819                </div>
     820            </div>
     821</div>
     822<div id="advanced-settings-main">
     823    <a id="show-advanced-settings">Show advanced settings >></a>
     824    <div class="change_button">
     825        <input class='apply_button' type="submit" value="Apply Changes"/>
     826    </div>
     827</div>
     828
     829<!-- Homepage mid widget -->
     830
    217831    </form>
    218832    <div style='clear:both'></div>
     
    229843        <input name="data" type="hideen" value="WORDPRESS_PLUGIN_INSTALL|<?="//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}|{$detailsString}"?>">
    230844    </form> -->
    231 
    232     <?php
    233     if($_SERVER['REQUEST_METHOD'] == 'POST' && count($taboola_errors) == 0){
    234         echo "<span class='label-success'>Your changes have been made! You can now see them on your site</span>";
    235     }
    236 
    237     if(count($taboola_errors) > 0){
    238         for($i = 0; $i < count($taboola_errors); $i++){
    239             echo "<span class='label-error'>".$taboola_errors[$i]."</span>";
    240         }
    241     }
    242     ?>
    243845</div>
     846
    244847<script>
    245     function sync_checkboxes(){
    246         if(jQuery('#first_bc_enabled').attr("checked")){
    247             jQuery('#second_bc_enabled').attr('disabled',false)
    248         } else {
    249             jQuery('#second_bc_enabled').attr('checked', false);
    250             jQuery('#second_bc_enabled').attr('disabled',true)
    251         }
    252     }
    253     jQuery('#first_bc_enabled').change(sync_checkboxes);
    254     setTimeout(function(){jQuery('.label-success').fadeOut()}, 6000);
    255     setTimeout(function(){jQuery('.label-error').fadeOut()}, 6000);
    256     sync_checkboxes()
    257 
    258     jQuery('.toggle_intercept').click(function(){
    259         if (jQuery('.location_section').fadeToggle != undefined){
    260             jQuery('.location_section').fadeToggle('fast');
    261         }else{
    262             jQuery('.location_section').toggle();
    263         }
    264         jQuery('.toggle_icon').toggleClass('toggle_icon_on');
    265     });
    266 
    267     window.onload = function(){
    268         document.forms['install_log'].submit()
    269 
    270     }
     848
     849    // Set enabled/disabled appearance upon page load
     850    // (Function is defined earlier on the page.)
     851    setEnabledDisabled('#below_article', document.getElementById("first_bc_enabled"));
     852    setEnabledDisabled('#mid_article', document.getElementById("mid_enabled"));
     853    setEnabledDisabled('#homepage', document.getElementById("home_enabled"));
     854
    271855</script>
     856
     857<script>
     858
     859    // Fadeouts for error/success messages
     860    setTimeout(function(){jQuery('.label-success').fadeOut()}, 5000);
     861    setTimeout(function(){jQuery('.label-error').fadeOut()}, 8000);
     862
     863    // PC
     864    // window.onload = function(){
     865    //     document.forms['install_log'].submit()
     866    // }
     867
     868</script>
  • taboola/trunk/simple_html_dom.php

    r2795104 r2869284  
    11<?php
    22/**
    3  * Website: https://sourceforge.net/projects/simplehtmldom/
    4  * Additional projects that may be used: https://sourceforge.net/projects/debugobject/
     3 * Website: http://sourceforge.net/projects/simplehtmldom/
     4 * Additional projects that may be used: http://sourceforge.net/projects/debugobject/
    55 * Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
    66 * Contributions by:
     
    10661066        // strip out comments
    10671067        $this->remove_noise("'<!--(.*?)-->'is");
    1068         // Per sourceforge https://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
     1068        // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
    10691069        // Script tags removal now preceeds style tag removal.
    10701070        // strip out <script> tags
     
    15071507    protected function parse_attr($node, $name, &$space)
    15081508    {
    1509         // Per sourceforge: https://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
     1509        // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
    15101510        // If the attribute is already defined inside a tag, only pay atetntion to the first one as opposed to the last one.
    15111511        if (isset($node->attr[$name]))
  • taboola/trunk/taboola_widget.php

    r2828580 r2869284  
    44 * Plugin URI: https://developers.taboola.com/web-integrations/discuss
    55 * Description: Taboola
    6  * Version: 1.0.15
     6 * Version: 2.0.1
    77 * Author: Taboola
    88 */
    99
    10 define ("XPATH_MARKER","/");
    11 define ("JS_INDICATOR","{JS}");
    12 define ("JS_MARKER","{");
     10define ("TABOOLA_PLUGIN_VERSION","2.0.1"); // => UPDATE FOR *EVERY* RELEASE (USED FOR TRACKING)
     11define ("TABOOLA_MIN_VER","2.0.1"); // => UPDATE *ONLY* IF THIS RELEASE HAS *DB CHANGES*
     12define ("TABOOLA_DEBUG_MODE", false); // => SET TO 'FALSE' FOR *EVERY* RELEASE (USED TO SUPRESS DEBUGGING LOGS)
     13
     14define ("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
     16define ("TABOOLA_XPATH_MARKER","/");
     17define ("TABOOLA_JS_INDICATOR","{JS}");
     18define ("TABOOLA_JS_MARKER","{");
    1319define ("TABOOLA_CONTENT_FORMAT_STRING",'string');
    1420define ("TABOOLA_CONTENT_FORMAT_SCRIPT",'script');
    1521define ("TABOOLA_CONTENT_FORMAT_HTML",'html');
    16 define ("TABOOLA_PLUGIN_VERSION","1.0.15");
    1722
    1823
     
    2833        public $_is_head_script_loaded = false;
    2934
    30 
    3135        function __construct()
    3236        {
     
    4751
    4852            //activation function
    49             register_activation_hook($this->plugin_name, array(&$this, 'activate'));
     53            register_activation_hook($this->plugin_name, array(&$this, 'update_db'));
     54            add_action('admin_init', array(&$this, 'update_db'));
    5055
    5156            // Enable sidebar widgets
    52             if($this->settings != NULL && !empty($this->settings->publisher_id)){
     57            if ($this->settings != NULL && !empty($this->settings->publisher_id)){
    5358                //register Taboola widget
    5459                add_action('widgets_init',
    55                 function(){
    56                     return register_widget("WP_Widget_Taboola");
     60                    function(){
     61                        return register_widget("WP_Widget_Taboola");
    5762                    }
    5863                );
     
    6570                add_action( 'admin_menu', array(&$this, 'admin_generate_menu') );
    6671                add_filter('plugin_action_links', array(&$this, 'plugin_action_links'), 10, 2 );
    67             } else {
    68                 if($this->settings != NULL){
     72            }else if ($this->settings != NULL){
    6973                    add_action('wp_head', array(&$this, 'taboola_header_loader_inject'));
    7074                    add_action('wp_footer', array(&$this, 'taboola_footer_loader_js'));
    7175                    add_filter('the_content', array(&$this, 'load_taboola_content'));
    72                 }
    73             }
    74         }
    75 
    76 
    77 
     76                    add_filter('the_content', array(&$this, 'load_taboola_content_mid'));
     77                    add_filter('the_content', array(&$this, 'load_taboola_content_home'));
     78            }
     79    }
    7880
    7981        function plugin_action_links($links, $file) {
     
    9799        }
    98100
     101        private function should_show_content_widget_mid(){
     102            // PC - only if v2 was installed:
     103            if (!$this->is_db_updated_for_min_ver("2.0.0"))
     104                return false;
     105            $retVal1 = ((trim($this->settings->publisher_id) != '') && is_single() && $this->settings->mid_enabled && trim($this->settings->mid_widget_id) != '');
     106            return $retVal1;
     107        }
     108
     109        private function should_show_content_widget_home(){
     110            // PC - only if v2 was installed:
     111            if (!$this->is_db_updated_for_min_ver("2.0.0"))
     112                return false;
     113            $retVal2 = ((trim($this->settings->publisher_id) != '') && is_front_page() && $this->settings->home_enabled && trim($this->settings->home_widget_id) != '');
     114            return $retVal2;
     115        }
     116
    99117        private function should_show_sidebar_widget(){
    100118            $retVal = ((trim($this->settings->publisher_id) != '') && is_active_widget( false, false, TABOOLA_WIDGET_BASE_ID, true ));
     
    104122        // Determine if a taboola widget should be added somewhere on the current page (content or sidebar)
    105123        function is_widget_on_page(){
    106             return  $this->should_show_content_widget() || $this->should_show_sidebar_widget();
     124            return  $this->should_show_content_widget() || $this->should_show_content_widget_mid() || $this->should_show_content_widget_home() || $this->should_show_sidebar_widget();
    107125        }
    108126
    109127        function get_page_type(){
    110 
    111128            $page_type='article';
    112129            if (is_front_page()){
    113             $page_type='home';
     130                $page_type='home';
    114131            }else if (is_category() || is_archive() || is_search()){
    115132                $page_type='category';
     
    131148                    '{{PHP_VERSION}}' => phpversion(),
    132149                    '{{PLUGIN_VERSION}}' => TABOOLA_PLUGIN_VERSION,
    133                     '{{LOCATION}}' => $this->settings->location_string
     150                    '{{LOC_MID}}' => $this->settings->mid_location_string,
     151                    '{{LOC_HOME}}' => $this->settings->home_location_string
    134152                );
    135153
    136154                $scriptWrapper = new JavaScriptWrapper("loaderInjectionScript.js",$stringParams);
    137                 $head_string = $scriptWrapper->getScripMarkupString();
     155                $head_string = $scriptWrapper->getScriptMarkupString();
    138156            }
    139157
     
    144162        // This function is used for the hook action, injects the header content to the <head> tag.
    145163        function taboola_header_loader_inject(){
    146 
    147164            echo $this->taboola_header_loader_js();
    148165        }
     
    154171            if ( $this->is_widget_on_page() ){
    155172                $flushInjectionScript = new JavaScriptWrapper('flushInjectionScript.js',array());
    156                 echo $flushInjectionScript->getScripMarkupString();
    157             }
    158         }
    159 
     173                echo $flushInjectionScript->getScriptMarkupString();
     174            }
     175        }
     176
     177        // Below-article widget
    160178        function load_taboola_content($content)
    161179        {
     
    163181            if ($this->should_show_content_widget()){
    164182
    165                 $firstWidgetParams = array('{{WIDGET_ID}}' => $this->settings->first_bc_widget_id,
    166                     '{{CONTAINER}}' => 'taboola-below-article',
    167                     '{{PLACEMENT}}' =>  'below-article');
     183                $firstWidgetParams = array(
     184                    '{{WIDGET_ID}}' => $this->settings->first_bc_widget_id,
     185                    '{{CONTAINER}}' => 'taboola-below-article-thumbnails',
     186                    // PC - If v2 was not installed, then use v1 logic
     187                    '{{PLACEMENT}}' =>  (!empty($this->settings->first_bc_placement)) ? $this->settings->first_bc_placement : 'below-article' // In case v1 upgrade has not run yet
     188                );
    168189
    169190                $firstWidgetScript = new JavaScriptWrapper("widgetInjectionScript.js",$firstWidgetParams);
    170                 $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-below-article'></div>";
     191                $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-below-article-thumbnails'></div>";
    171192                $taboola_content[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $firstWidgetScript;
    172193
    173                 // Adding the 2nd widget if needed
    174                 if($this->settings->second_bc_enabled && trim($this->settings->second_bc_widget_id) != ''){
    175 
    176                     $secondWidgetParams = array('{{WIDGET_ID}}' => $this->settings->second_bc_widget_id,
    177                                                '{{CONTAINER}}' => 'taboola-below-article-second',
    178                                                '{{PLACEMENT}}' =>  'below-article-2nd');
     194                $content = $this->embed_taboola_content_location($content,$taboola_content);
     195            }
     196
     197            return $content;
     198        }
     199
     200        // Mid-article-widget
     201        function load_taboola_content_mid($content)
     202        {
     203            $taboola_content_mid = array();
     204            if ($this->should_show_content_widget_mid()){
     205
     206                    $secondWidgetParams = array('{{WIDGET_ID}}' => $this->settings->mid_widget_id,
     207                        '{{CONTAINER}}' => 'taboola-mid-article-thumbnails',
     208                        '{{PLACEMENT}}' =>  $this->settings->mid_placement);
     209                                               
    179210                    $secondWidgetScript = new JavaScriptWrapper("widgetInjectionScript.js",$secondWidgetParams);
    180 
    181                     $taboola_content[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-below-article-second'></div>";
    182                     $taboola_content[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $secondWidgetScript;
     211                    $taboola_content_mid[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-mid-article-thumbnails'></div>";
     212                    $taboola_content_mid[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $secondWidgetScript;
     213
     214                $content = $this->embed_taboola_content_location_mid($content,$taboola_content_mid,trim($this->settings->mid_location_string));
     215            }
     216
     217            return $content;
     218        }
     219
     220        // Homepage widget
     221        function load_taboola_content_home($content)
     222        {
     223           
     224                $taboola_content_home = array();
     225                if ($this->should_show_content_widget_home()){
     226
     227                        $homeWidgetParams = array('{{WIDGET_ID}}' => $this->settings->home_widget_id,
     228                            '{{CONTAINER}}' => 'taboola-homepage-thumbnails',
     229                            '{{PLACEMENT}}' =>  $this->settings->home_placement);
     230                                               
     231                        $homeWidgetScript = new JavaScriptWrapper("widgetInjectionScript.js",$homeWidgetParams);
     232                        $taboola_content_home[TABOOLA_CONTENT_FORMAT_HTML][] = "<div id='taboola-homepage-thumbnails'></div>";
     233                        $taboola_content_home[TABOOLA_CONTENT_FORMAT_SCRIPT][] = $homeWidgetScript;
     234
     235                    $content = $this->embed_taboola_content_location_home($content,$taboola_content_home,trim($this->settings->home_location_string));
    183236                }
    184 
    185                 $content = $this->embed_taboola_content_location($content,$taboola_content,trim($this->settings->location_string));
    186             }
    187 
    188237            return $content;
    189         }
    190 
     238           
     239        }
     240
     241        // Below-article widget
    191242
    192243        // Extract the taboola content in the required format:
     
    213264
    214265
    215         // Do the actual logic of choosing where to place the taboola content based on the "location" attribute
    216         function embed_taboola_content_location($content, $taboola_content, $location){
     266        // Mid-article widget
     267        function format_taboola_content_mid($taboola_content_mid,$format){
     268            $ret_val = null;
     269
     270            switch($format){
     271                case TABOOLA_CONTENT_FORMAT_STRING:
     272                    $result_string = join("",$taboola_content_mid[TABOOLA_CONTENT_FORMAT_HTML]).
     273                        "<script type='text/javascript'>".join("\n",$taboola_content_mid[TABOOLA_CONTENT_FORMAT_SCRIPT])."</script>";
     274                    $ret_val = $result_string;
     275                    break;
     276
     277                // script or html
     278                default:
     279                    $ret_val = str_replace("\n","",join("",$taboola_content_mid[$format]));
     280                    break;
     281            }
     282
     283            return $ret_val;
     284        }
     285
     286
     287        // Homepage widget
     288        function format_taboola_content_home($taboola_content_home,$format){
     289           
     290            $ret_val = null;
     291
     292            switch($format){
     293                case TABOOLA_CONTENT_FORMAT_STRING:
     294                    $result_string = join("",$taboola_content_home[TABOOLA_CONTENT_FORMAT_HTML]).
     295                        "<script type='text/javascript'>".join("\n",$taboola_content_home[TABOOLA_CONTENT_FORMAT_SCRIPT])."</script>";
     296                    $ret_val = $result_string;     
     297                    break;
     298
     299                // script or html
     300                default:
     301                    $ret_val = str_replace("\n","",join("",$taboola_content_home[$format]));
     302                    break;
     303            }
     304
     305            return $ret_val;
     306       
     307         }
     308
     309        // Below-article widget
     310        // Do the actual logic of choosing where to place the taboola content.
     311        function embed_taboola_content_location($content, $taboola_content){
    217312            $do_default = true;
    218313
    219             if (isset($location) && $location != ''){
    220                 $first_char = substr($location,0,1);
    221 
    222                 // DIV/XPATH provided for JS handling
    223                 if ($first_char == JS_MARKER){
    224                     $full_indicator = substr($location,0,strlen(JS_INDICATOR));
    225 
    226                     if ($full_indicator == JS_INDICATOR){
    227 
    228                         $xpath = substr($location,strlen(JS_INDICATOR));
    229                         $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array(
    230                             "{{HTML}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_HTML),
    231                             "{{SCRIPT}}" => $this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_SCRIPT))
    232                         );
    233                         $scriptWrapper->appendScript("injectWidgetByXpath('".$xpath."');");
    234                         $content = $content."<span id='tbdefault'></span><script type='text/javascript'>".$scriptWrapper."</script>";
    235 
    236                         $do_default = false;
    237                     }
    238 
    239                 // server side selector provided (see simple_html_dom selectors https://simplehtmldom.sourceforge.net/manual.htm)
    240                 // basically it's CSS selectors like in jQuery
    241                 } else{
    242 
    243                     require_once('simple_html_dom.php');
    244 
    245                     $html_doc = str_get_html($content);
    246                     $target_location = $html_doc->find($location,0);
    247 
    248                     // if the location was found within the html content
    249                     if (isset($target_location) && is_object($target_location)){
    250 
    251                         // adding taboola content AFTER the target location
    252                         $target_location->outertext = $target_location->outertext.$this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_STRING);
    253                         $content = $html_doc;
    254                         $do_default = false;
    255                     }
    256                 }
    257 
    258314            // tag is placed outside of content in order to allow "read more" functionality.
    259             }elseif ($this->settings->out_of_content_enabled){
     315            if ($this->settings->out_of_content_enabled){
    260316
    261317                $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array(
     
    268324            }
    269325
    270             // Default - add to the end of the content
     326            // Default for below-article widget - add to the end of the content
    271327            if ($do_default){
    272328                $content = $content.$this->format_taboola_content($taboola_content,TABOOLA_CONTENT_FORMAT_STRING);
     
    276332        }
    277333
     334        // Mid-article widget
     335        // Do the actual logic of choosing where to place the taboola content based on the "location" attribute       
     336        function embed_taboola_content_location_mid($content, $taboola_content_mid, $location){
     337            $do_default = true;
     338
     339            if (isset($location) && $location != ''){
     340                $first_char = substr($location,0,1);
     341
     342                // DIV/XPATH provided for JS handling
     343                if ($first_char == TABOOLA_JS_MARKER){
     344                    $full_indicator = substr($location,0,strlen(TABOOLA_JS_INDICATOR));
     345
     346                    if ($full_indicator == TABOOLA_JS_INDICATOR){
     347
     348                        $xpath = substr($location,strlen(TABOOLA_JS_INDICATOR));
     349                        $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array(
     350                            "{{HTML}}" => $this->format_taboola_content_mid($taboola_content_mid,TABOOLA_CONTENT_FORMAT_HTML),
     351                            "{{SCRIPT}}" => $this->format_taboola_content_mid($taboola_content_mid,TABOOLA_CONTENT_FORMAT_SCRIPT))
     352                        );
     353                        $scriptWrapper->appendScript("injectWidgetByXpath('".$xpath."');");
     354                        $content = $content."<span id='tbdefault'></span><script type='text/javascript'>".$scriptWrapper."</script>";
     355
     356                        $do_default = false;
     357                    }
     358
     359                // server side selector provided (see simple_html_dom selectors http://simplehtmldom.sourceforge.net/manual.htm)
     360                // basically it's CSS selectors like in jQuery
     361                } else{
     362                    require_once('simple_html_dom.php');
     363
     364                    $html_doc = str_get_html($content);
     365                    $target_location = $html_doc->find($location,($this->settings->mid_location_string_occurrence)-1);
     366
     367                    // if the location was found within the html content
     368                    if (isset($target_location) && is_object($target_location)){
     369
     370                        // adding taboola content AFTER the target location
     371                        $target_location->outertext = $target_location->outertext.$this->format_taboola_content_mid($taboola_content_mid,TABOOLA_CONTENT_FORMAT_STRING);
     372                        $content = $html_doc;
     373                        $do_default = false;
     374                    }
     375                }
     376            }
     377            // Default for below-article widget - add to the end of the content
     378            // if ($do_default){
     379            //     $content = $content.$this->format_taboola_content_mid($taboola_content_mid,TABOOLA_CONTENT_FORMAT_STRING);
     380            // }
     381
     382            return $content;
     383        }
     384
     385        // Homepage widget
     386        // Do the actual logic of choosing where to place the taboola content based on the "location" attribute 
     387        function embed_taboola_content_location_home($content, $taboola_content_home, $location){
     388
     389                $do_default = true;
     390
     391                if (isset($location) && $location != ''){
     392                    $first_char = substr($location,0,1);
     393
     394                    // DIV/XPATH provided for JS handling
     395                    if ($first_char == TABOOLA_JS_MARKER){
     396                        $full_indicator = substr($location,0,strlen(TABOOLA_JS_INDICATOR));
     397
     398                        if ($full_indicator == TABOOLA_JS_INDICATOR){
     399
     400                            $xpath = substr($location,strlen(TABOOLA_JS_INDICATOR));
     401                            $scriptWrapper = new JavaScriptWrapper("js_inject.min.js",array(
     402                                "{{HTML}}" => $this->format_taboola_content_home($taboola_content_home,TABOOLA_CONTENT_FORMAT_HTML),
     403                                "{{SCRIPT}}" => $this->format_taboola_content_home($taboola_content_home,TABOOLA_CONTENT_FORMAT_SCRIPT))
     404                            );
     405                            $scriptWrapper->appendScript("injectWidgetByXpath('".$xpath."');");
     406                            $content = $content."<span id='tbdefault'></span><script type='text/javascript'>".$scriptWrapper."</script>";
     407
     408                            $do_default = false;
     409                        }
     410
     411                    // server side selector provided (see simple_html_dom selectors http://simplehtmldom.sourceforge.net/manual.htm)
     412                    // basically it's CSS selectors like in jQuery
     413                    } else{
     414                        require_once('simple_html_dom.php');
     415
     416                        $html_doc = str_get_html($content);
     417                        $target_location = $html_doc->find($location,($this->settings->home_location_string_occurrence)-1);
     418
     419                        // if the location was found within the html content
     420                        if (isset($target_location) && is_object($target_location)){
     421
     422                            // adding taboola content AFTER the target location
     423                            $target_location->outertext = $target_location->outertext.$this->format_taboola_content_home($taboola_content_home,TABOOLA_CONTENT_FORMAT_STRING);
     424                            $content = $html_doc;
     425                            $do_default = false;
     426                        }
     427                    }
     428                }
     429                // Default for below-article widget - add to the end of the content
     430                // if ($do_default){
     431                //     $content = $content.$this->format_taboola_content_home($taboola_content_home,TABOOLA_CONTENT_FORMAT_STRING);
     432                // }
     433                return $content;
     434
     435        }
    278436
    279437        function admin_generate_menu(){
     
    289447
    290448                if(trim($_POST['publisher_id']) == ''){
    291                     $taboola_errors[] = "Please add a 'Publisher ID' in order to apply changes to your widgets";
     449                    $taboola_errors[] = "Publisher ID";
    292450                }
    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']) == '')
    295                 ){
    296                     $taboola_errors[] = "Please add a 'Widget ID' in order to apply changes to your widgets";
     451
     452                if(isset($_POST['first_bc_enabled'])) {
     453                    if (trim($_POST['first_bc_widget_id']) == '') {
     454                        $taboola_errors[] = "Below-article > Widget ID";
     455                    }
     456                    if (trim($_POST['first_bc_placement']) == '') {
     457                        $taboola_errors[] = "Below-article > Placement Name";
     458                    }
    297459                }
    298                 if (trim($_POST['location_string']) != '' && !$this->is_location_string_valid($_POST['location_string'])){
    299                     $taboola_errors[] = "Location string not valid, please contact your Taboola account manager to get a valid location string";
     460
     461                if(isset($_POST['mid_enabled'])) {
     462                    if (trim($_POST['mid_widget_id']) == '') {
     463                        $taboola_errors[] = "Mid-article > Widget ID";
     464                    }
     465                    if (trim($_POST['mid_placement']) == '') {
     466                        $taboola_errors[] = "Mid-article > Placement Name";
     467                    }
     468                    if (trim($_POST['mid_location_string']) == '') {
     469                        $taboola_errors[] = "Mid-article > CSS selector";
     470                    }
     471                    else {
     472                        // If the 'location' WAS filled in, then...
     473
     474                        // 1) Check for a valid 'location':
     475
     476                        // Validation method has not been implemented
     477                        // mid_if  (!$this->is_locaton_string_valid1($_POST['mid_location_string'])) {
     478                        //     $taboola_errors[] = "Mid-article > CSS Selector (invalid value)";
     479                        // }
     480
     481                        // 2) Validate the 'occurrence':
     482                        if (!$this->is_mid_location_string_occurrence_valid($_POST['mid_location_string_occurrence'])) {
     483                            $taboola_errors[] = "Mid-article > Occurance (must be >= 1)";
     484                        }
     485                    }
     486
    300487                }
     488
     489                if(isset($_POST['home_enabled'])) {
     490                    if (trim($_POST['home_widget_id']) == '') {
     491                        $taboola_errors[] = "Homepage > Widget ID";
     492                    }
     493                    if (trim($_POST['home_placement']) == '') {
     494                        $taboola_errors[] = "Homepage > Placement Name";
     495                    }
     496
     497                    if (trim($_POST['home_location_string']) == '') {
     498                        $taboola_errors[] = "Homepage > CSS selector";
     499                    }
     500                    else {
     501                        // If the 'location' WAS filled in, then...
     502
     503                        // 1) Check for a valid 'location':
     504
     505                        // Validation method has not been implemented
     506                        // if (!$this->is_home_location_string_valid($_POST['home_location_string'])) {
     507                        //     $taboola_errors[] = "Homepage > CSS Selector (invalid value)";
     508                        // }                   
     509
     510                        // 2) Validate the 'occurrence':
     511                        if (!empty($_POST['home_location_string']) && !$this->is_home_location_string_occurrence_valid($_POST['home_location_string_occurrence'])) {
     512                            $taboola_errors[] = "Homepage > Occurance (must be >= 1)";
     513                        }
     514                    }
     515                }       
     516               
    301517                if(count($taboola_errors) == 0){
    302518
    303519                    $data = array(
    304520                        "publisher_id" => trim($_POST['publisher_id']),
     521
    305522                        "first_bc_enabled" => isset($_POST['first_bc_enabled']) ? true : false,
    306                         "first_bc_widget_id" => trim($_POST['first_bc_widget_id']),
    307                         "second_bc_enabled" => isset($_POST['second_bc_enabled']) ? true : false,
    308                         "second_bc_widget_id" => trim($_POST['second_bc_widget_id']),
    309                         "location_string" => trim($_POST['location_string']),
    310                         "out_of_content_enabled" => isset($_POST['out_of_content_enabled']) ? true : false
     523                        "first_bc_widget_id" => !empty($_POST['first_bc_widget_id']) ? trim($_POST['first_bc_widget_id']) : '',
     524                        "first_bc_placement" => !empty($_POST['first_bc_placement']) ? trim($_POST['first_bc_placement']) : '',
     525
     526                        "out_of_content_enabled" => isset($_POST['out_of_content_enabled']) ? true : false,
     527
     528                        "mid_enabled" => isset($_POST['mid_enabled']) ? true : false,
     529                        "mid_widget_id" => !empty($_POST['mid_widget_id']) ? trim($_POST['mid_widget_id']) : '',
     530                        "mid_placement" => !empty($_POST['mid_placement']) ? trim($_POST['mid_placement']) : '',
     531                        "mid_paragraph_ui_mode" => !empty($_POST['mid_paragraph_ui_mode']) ? trim($_POST['mid_paragraph_ui_mode']) : '',
     532
     533                        "mid_location_string_occurrence" => !empty($_POST['mid_location_string_occurrence']) ? $_POST['mid_location_string_occurrence'] : '',
     534                        "mid_location_string" => !empty($_POST['mid_location_string']) ? trim($_POST['mid_location_string']) : '',
     535
     536                        "home_enabled" => isset($_POST['home_enabled']) ? true : false,
     537                        "home_widget_id" => !empty($_POST['home_widget_id']) ? trim($_POST['home_widget_id']) : '',
     538                        "home_placement" => !empty($_POST['home_placement']) ? trim($_POST['home_placement']) : '',
     539
     540                        "home_location_string_occurrence" => !empty($_POST['home_location_string_occurrence']) ? $_POST['home_location_string_occurrence'] : '',
     541                        "home_location_string" => !empty($_POST['home_location_string']) ? trim($_POST['home_location_string']) : ''
    311542                    );
    312543
     
    321552            }
    322553
    323 
    324554            include_once('settings.php');
    325555        }
    326556
    327         function is_location_string_valid($location_string){
     557        function is_mid_location_string_valid($mid_location_string){
    328558            // TODO:: validate the location string
    329559            return true;
    330560        }
    331         function activate(){
     561
     562        function is_mid_location_string_occurrence_valid($mid_location_string_occurrence){
     563
     564            if ((int)$mid_location_string_occurrence >= 1) {
     565                return true;
     566            }
     567            return false;
     568        }
     569
     570        function is_home_location_string_valid($home_location_string){
     571            // TODO:: validate the location string
     572            return true;
     573        }
     574
     575        function is_home_location_string_occurrence_valid($home_location_string_occurrence){
     576
     577            if ((int)$home_location_string_occurrence >= 1) {
     578                return true;
     579            }
     580            return false;
     581        }
     582        function columnExists($column_name) {
    332583            global $wpdb;
    333 
     584            $table_name = $wpdb->prefix . "_taboola_settings";
     585            tb_write_log("table name : " . $table_name);
     586            tb_write_log("column name : " . $column_name);
     587
     588            $column_exists = $wpdb->get_var("SHOW COLUMNS FROM $table_name LIKE '$column_name'") !== null;
     589
     590            if ($column_exists) {
     591                tb_write_log("Yes - column " . $column_name . " DOES exist!"); //PC
     592                return true;
     593            } else {
     594                tb_write_log("No - column " . $column_name . " does NOT exist!"); //PC
     595                return false;
     596            }
     597        }
     598
     599        function is_upgrade_from_v1() {         
     600
     601            if($this->columnExists("first_bc_widget_id") && !$this->columnExists("first_bc_placement")){
     602                tb_write_log("This IS a v1 upgrade!"); //PC
     603                return true;
     604            }
     605            else {
     606                tb_write_log("This is NOT a v1 upgrade!"); //PC
     607                return false;
     608            }
     609
     610        }
     611
     612        function is_db_updated_for_min_ver($min_ver) {
     613            /**
     614             * Checks if the DB was *previously* updated for the minimum version specified.
     615             * $min_ver should be passed in a format like this: "2.1.0"
     616             */
     617            global $wpdb;
     618
     619            // Check the saved version in wp_options. Default to '1.0.0' if the option is not found.
     620            $saved_version = get_option(TABOOLA_OPTION_NAME, '1.0.0');
     621           
     622            $db_is_up_to_date = version_compare($saved_version, $min_ver, '>=');
     623            //tb_write_log($db_is_up_to_date);
     624            return $db_is_up_to_date;
     625 
     626        }         
     627     
     628        function is_db_updated_for_current_ver() {
     629            /**
     630             * Checks if the DB was *previously* updated for the version currently loaded.
     631            */
     632            global $wpdb;
     633
     634            // Check the saved version in wp_options. Default to '1.0.0' if the option is not found.
     635            $saved_version = get_option(TABOOLA_OPTION_NAME, '1.0.0');
     636           
     637            // Get the currently loaded plugin version from wp_options.
     638            $plugin_version = $this->get_loaded_plugin_version();
     639
     640            $db_is_up_to_date = version_compare($saved_version, $plugin_version, '>=');
     641            //tb_write_log($db_is_up_to_date);
     642            return $db_is_up_to_date;
     643 
     644        }       
     645
     646        function get_loaded_plugin_version() {
     647
     648            $plugin_data = get_plugin_data( __FILE__ ); // Can be invoked from Admin page only
     649            $loaded_plugin_version = $plugin_data['Version'];
     650            return $loaded_plugin_version;
     651
     652        }
     653
     654        function save_taboola_version($min_ver) {
     655            // Get the currently loaded plugin version
     656            // $plugin_version = $this->get_loaded_plugin_version();
     657
     658            tb_write_log("SAVING NEW MIN VERSION: " . $min_ver); // PC
     659
     660            // Check the saved version in wp_options. Default to '' if the option is not found.
     661            $saved_version = get_option(TABOOLA_OPTION_NAME, '');
     662            if ($saved_version == '') {
     663                add_option(TABOOLA_OPTION_NAME, $min_ver);
     664            }
     665            else {
     666                update_option(TABOOLA_OPTION_NAME, $min_ver);
     667            }
     668        }
     669
     670        function update_db(){
     671
     672            // If we are up to date, then skip this method...
     673            if ($this->is_db_updated_for_min_ver(TABOOLA_MIN_VER)) {
     674               //tb_write_log("All up to date!");
     675                return;
     676            }
     677           
     678            $this->save_taboola_version(TABOOLA_MIN_VER);
     679           
     680            global $wpdb;
    334681            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    335 
    336             $settings_table = $this->tbl_taboola_settings;
     682           
    337683
    338684            //check mysql version
     
    343689                    $charset_collate .= " COLLATE $wpdb->collate";
    344690            }
     691
     692            // Check if this is an upgrade from v1
     693            $is_upgrade_from_v1 = $this->is_upgrade_from_v1();
     694
     695            // tb_write_log("Is upgrade from v1: " . ($is_upgrade_from_v1 ? 'true' : 'false'));
     696
    345697
    346698            //settings table structure
     
    351703                    `first_bc_enabled` TINYINT(1) NOT NULL DEFAULT FALSE,
    352704                    `first_bc_widget_id` VARCHAR(255) DEFAULT NULL,
     705                    `first_bc_placement` VARCHAR(255) DEFAULT " . ($is_upgrade_from_v1 ? "'below-article'" : "NULL") .",
    353706                    `first_bc_custom_css` TEXT DEFAULT NULL,
    354707                    `second_bc_enabled` TINYINT(1) NOT NULL DEFAULT FALSE,
     
    356709                    `second_bc_custom_css` TEXT DEFAULT NULL,
    357710                    `location_string` TEXT DEFAULT NULL,
     711                    `mid_enabled` TINYINT(1) NOT NULL DEFAULT FALSE,
     712                    `mid_widget_id` VARCHAR(255) DEFAULT NULL,
     713                    `mid_placement` VARCHAR(255) DEFAULT NULL,
    358714                    `out_of_content_enabled` TINYINT(1) NOT NULL DEFAULT TRUE,
     715                    `mid_location_string` TEXT DEFAULT NULL,
     716                    `mid_location_string_occurrence` SMALLINT DEFAULT NULL,
     717                    `mid_paragraph_ui_mode` VARCHAR(255) DEFAULT NULL,
     718                    `home_enabled` TINYINT(1) NOT NULL DEFAULT FALSE,
     719                    `home_widget_id` VARCHAR(255) DEFAULT NULL,
     720                    `home_placement` VARCHAR(255) DEFAULT NULL,
     721                    `home_location_string` TEXT DEFAULT NULL,
     722                    `home_location_string_occurrence` SMALLINT DEFAULT NULL,
    359723                    PRIMARY KEY (`id`)
    360724                )" . $charset_collate . ";";
     725               
     726                // tb_write_log($sql_table_settings);
    361727
    362728                // create/update the table
     
    369735$taboolaWP = new TaboolaWP();
    370736
     737/*
     738A few utility methods for logging
     739*/
     740
     741// Writes debugging messages to 'logs/debug.log'.
     742// The exact file location depends on *where* you trigger the function.
     743// In this script, we trigger the function from the admin dashboard.
     744// So the log file is located under 'wp-admin/logs'.
     745function tb_write_log($log_msg)
     746{
     747    $log_filename = "logs";
     748    if (!file_exists($log_filename))
     749    {
     750        mkdir($log_filename, 0777, true);
     751    }
     752    $log_file_data = $log_filename.'/debug.log';
     753
     754    // Add date/time
     755     $date = date('Y-m-d H:i:s');
     756    $log_msg_with_date = $date." : ".$log_msg;
     757   
     758    if (TABOOLA_DEBUG_MODE)
     759        file_put_contents($log_file_data, $log_msg_with_date . "\n", FILE_APPEND);
     760   
     761}
     762
     763// Write to console
     764function tb_console_log( $data ){
     765
     766    If(wp_get_environment_type() === 'development') {
     767
     768        echo '<script>';
     769        echo 'console.log('. json_encode( $data ) .')';
     770        echo '</script>';
     771
     772    }
     773}
     774
     775// Write to webpage and stop
     776function tb_print_to_page($data) {
     777    If(wp_get_environment_type() === 'development') {
     778        print_r($data);
     779        die;
     780    }
     781}
     782
    371783//
  • taboola/trunk/widget.php

    r1640639 r2869284  
    7878    }
    7979
    80     function form( $instance ) {
     80    function form( $instance ) { 
    8181        $instance = wp_parse_args( (array) $instance );
    8282        $widget_id = esc_attr( $instance['widget_id'] );
Note: See TracChangeset for help on using the changeset viewer.