PluginProbe
Taboola / 3.1.0
Taboola v3.1.0
1.0.4 1.0.5 1.0.6 1.0.8 2.0.1 2.0.2 2.1.0 2.1.1 2.2.2 2.2.3 3.0.0 3.0.1 3.0.2 3.1.0 trunk 1.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.2 1.0.3
← All changes | settings.php +275 -181 2.2.33.1.0 View file →
@@ -1,5 +1,4 @@
1 -<!-- Latest font-awesome include-->
2 1 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
3 2
4 3 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
5 4 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
@@ -20,17 +19,23 @@
20 19 <a href="#tab1" class="nav-tab" id="tab1-link">Web</a>
21 20 <a href="#tab2" class="nav-tab" id="tab2-link">Web Push</a>
22 21 </h2>
23 22
24 -<!-- errors/success message -->
25 -
26 - <?php
27 - if($_SERVER['REQUEST_METHOD'] == 'POST' && count($taboola_errors) == 0){
23 +<?php
24 + if($_SERVER['REQUEST_METHOD'] == 'POST' && count($taboola_errors) == 0 && $taboola_save_error == ''){
28 25 echo "<div class='label-success'>";
29 26 echo "<h3 style='color:green;'>Changes applied!</h3>";
30 27 echo "<span>Verify the new changes by browsing to your site.</span>";
31 28 echo "</div>";
32 29 }
30 +
31 + if($taboola_save_error != ''){
32 + echo "<div class='label-error'>";
33 + echo "<h3 style='color:red;'>Settings were not saved</h3>";
34 + echo "<p>".esc_html($taboola_save_error)."</p>";
35 + echo "<p><b>All values</b> have been reverted to the last successful save.</p>";
36 + echo "</div>";
37 + }
33 38
34 39 if(count($taboola_errors) > 0){
35 40 echo "<div class='label-error'>";
36 41 echo "<h3 style='color:red;'>Missing or incorrect values</h3>";
@@ -47,27 +52,15 @@
47 52 ?>
48 53
49 54 <script>
50 55 function setEnabledDisabled(divID, chkToggle) {
51 - /*
52 - JS function for form.
53 - Enables/disables fields for the given section ('divID'), depending on whether 'chkToggle' is checked.
54 - */
55 -
56 56 var applyColor = (chkToggle.checked ? "#000" : "#666");
57 -
58 - // Set all labels in that section ('divID') to the relevant color.
59 57 $(divID).find("label").css("color", applyColor);
60 -
61 - // Disable (/enable) all input fields in that section ('divID'), except for 'chkToggle'.
62 - // Once done, apply a gray border color.
63 58 $(divID).find("input").not("#" + chkToggle.id).prop("disabled", !chkToggle.checked).css("borderColor", "#ccc");
64 59 $(divID).find("select").not("#" + chkToggle.id).prop("disabled", !chkToggle.checked).css("borderColor", "#ccc");
65 -
66 60 }
67 61 </script>
68 62
69 -<!-- tab-switching JQuery -->
70 63 <script>
71 64 jQuery(document).ready(function($) {
72 65 function showTab(tabId) {
73 66 $('.nav-tab').removeClass('nav-tab-active');
@@ -76,9 +69,8 @@
76 69 $('a[href="' + tabId + '"]').addClass('nav-tab-active');
77 70 $(tabId).addClass('active').show();
78 71 }
79 72
80 - // On tab click, update the URL hash and hidden input value
81 73 $('.nav-tab').click(function(e) {
82 74 e.preventDefault();
83 75 var tabId = $(this).attr('href');
84 76 window.location.hash = tabId;
@@ -85,9 +77,8 @@
85 77 $('#active_tab').val(tabId);
86 78 showTab(tabId);
87 79 });
88 80
89 - // On page load, show the tab from the URL hash or default to the first tab
90 81 var hash = window.location.hash;
91 82 if (hash) {
92 83 showTab(hash);
93 84 $('#active_tab').val(hash);
@@ -94,9 +85,8 @@
94 85 } else {
95 86 showTab('#tab1');
96 87 }
97 88
98 - // Set the active tab before form submission
99 89 $('form').submit(function() {
100 90 var activeTab = $('.nav-tab.nav-tab-active').attr('href');
101 91 $('#active_tab').val(activeTab);
102 92 });
@@ -104,13 +94,8 @@
104 94 </script>
105 95
106 96 <script>
107 97 $(document).ready(function(){
108 - // On page load:
109 - if ($('#mid_paragraph_ui_mode').val() == 'Other') {
110 - $("#mid_css_selector_div").show();
111 - }
112 -
113 98 if ($('#home_enabled').prop("checked") === true) {
114 99 $("#homepage").show();
115 100 var ad = $('#show-advanced-settings');
116 101 ad.text("<< Hide advanced settings");
@@ -119,9 +104,8 @@
119 104 </script>
120 105
121 106 <script>
122 107 $(document).ready(function(){
123 - // On clicking 'Advanced settings'
124 108 $("#show-advanced-settings").click(function() {
125 109 $("#homepage").slideToggle("fast");
126 110 var ad = $('#show-advanced-settings');
127 111 ad.text() == "Show advanced settings >>" ? ad.text("<< Hide advanced settings") : ad.text("Show advanced settings >>");
@@ -128,41 +112,9 @@
128 112 });
129 113 });
130 114 </script>
131 115
132 -
133 -<script>
134 -$(document).ready(function(){
135 -
136 - // On selecting an item in the dropdown:
137 - $('#mid_paragraph_ui_mode').on('change', function(e){
138 - e.preventDefault();
139 - if ( this.value == 'Other')
140 - {
141 - $("#mid_css_selector_div").show();
142 -
143 - // Highlight relevant fields:
144 - $("#mid_location_string, #mid_occurrence").addClass('highlight');
145 - setTimeout(() => $("#mid_occurrence, #mid_location_string").removeClass('highlight'), 1500);
146 -
147 - }
148 - else
149 - {
150 - $("#mid_location_string").val("p"); // Set it back to the default value of 'p'
151 - $("#mid_css_selector_div").hide();
152 -
153 - // Highlight the 'occurrence' field:
154 - $("#mid_occurrence").addClass('highlight');
155 - setTimeout(() => $("#mid_occurrence").removeClass('highlight'), 1000);
156 - }
157 - });
158 -});
159 -</script>
160 -
161 -
162 -<!-- Welcome Massage -->
163 -
164 - <div class="publisher_welcome_massage">
116 +<div class="publisher_welcome_massage">
165 117 <h2 class="welcome_heading">Welcome to Taboola WordPress Plugin</h2>
166 118 <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>
167 119 <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>
168 120 <div class="list_l1">
@@ -169,17 +121,16 @@
169 121 <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>
170 122 </div>
171 123 </div>
172 124
173 -<!-- Welcome Massage-->
174 -
175 125 <form method="POST">
176 126 <?php
177 - // Generate a nonce and pass it via a hidden field
178 127 $my_nonce = wp_create_nonce( 'my_plugin_update_field_action' );
179 128 ?>
180 129 <input type="hidden" name="my_plugin_nonce" value="<?php echo esc_attr( $my_nonce ); ?>"/>
130 +<input type="hidden" id="active_tab" name="active_tab" value="#tab1"/>
181 131
132 +
182 133 <div id="tab1" class="tab-content">
183 134 <h2 class="general_h2">General Settings</h2>
184 135
185 136 <div class="settings_block">
@@ -184,15 +135,12 @@
184 135
185 136 <div class="settings_block">
186 137 <div class="style_box1"><label id="pub_id">Publisher ID :</label>
187 138 <div class="tooltip">
188 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
189 - <!-- <img class="helpTooltip__icon___1XWGN" src='<?php echo $this->plugin_url.'img/tooltip_image.svg' ?>'/> -->
190 139 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN_first">
191 140 <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>
192 141 </g>
193 142 </svg>
194 - <!-- <div id="arrow" ></div> -->
195 143 <div>Your Publisher ID, as provided by Taboola.</div>
196 144 </div>
197 145 </div>
198 146 <div class="pub_id">
@@ -204,10 +152,9 @@
204 152 </label>
205 153 </div>
206 154 </div>
207 155
208 - <!-- Below Article Widget -->
209 - <h2 class="widget_h2">Taboola Units</h2>
156 + <h2 class="widget_h2">Taboola Units</h2>
210 157 <div id="below_article" class="settings_block widget_settings_block">
211 158 <div class="switch_style">
212 159 <label class="switch">
213 160 <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" />
@@ -218,9 +165,8 @@
218 165 <div class="label_below">
219 166 <div class="mode_style">
220 167 <label id="first_bc_widget_id_label" style="float:left;">Mode (Widget ID):</label>
221 168 <div class="tooltip">
222 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
223 169 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
224 170 <g fill="none" fill-rule="evenodd">
225 171 <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>
226 172 </g>
@@ -230,9 +176,8 @@
230 176 </div>
231 177 <div class="placement_style">
232 178 <label id="first_bc_placement_label" style="float:left;">Placement Name:</label>
233 179 <div class='tooltip'>
234 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
235 180 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
236 181 <g fill="none" fill-rule="evenodd">
237 182 <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>
238 183 </g>
@@ -251,11 +196,8 @@
251 196 <div class="placement_below">
252 197 <input type="text" id="first_bc_placement" value="<?php echo !empty($settings->first_bc_placement) ? strip_tags($settings->first_bc_placement) : "" ?>" name="first_bc_placement" placeholder="Placement Name" />
253 198 </div>
254 199 </div>
255 -
256 - <!-- Below Article Widget -->
257 - <!-- Advanced Settings -->
258 200 <br />
259 201 <div class='location_section'>
260 202 <div class='checkbox_read'>
261 203 <input id="out_of_content_enabled" type="checkbox" <?php echo !empty($settings->out_of_content_enabled) ? "checked='checked'" : "" ?> name="out_of_content_enabled" />
@@ -273,103 +215,77 @@
273 215 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>
274 216 </div>
275 217 </div>
276 218 </div>
277 - <!-- Advanced Settings -->
278 219
279 - <!-- Mid Article Widget -->
280 -
281 220 <div id="mid_article" class="settings_block widget_settings_block">
282 - <div class="switch_style">
283 - <label class="switch">
284 - <input id="mid_enabled" type="checkbox" <?php echo !empty($settings->mid_enabled) ? "checked='checked'" : "" ?> onclick="setEnabledDisabled('#mid_article', this)" name="mid_enabled"/>
285 - <span class="slider round"></span>
286 - </label>
287 - <b style="font-size:15px;">Mid-article</b>
288 - </div>
221 + <div class="switch_style">
222 + <label class="switch">
223 + <input id="mid_enabled" type="checkbox" <?php echo !empty($settings->mid_enabled) ? "checked='checked'" : "" ?> onclick="setEnabledDisabled('#mid_article', this)" name="mid_enabled"/>
224 + <span class="slider round"></span>
225 + </label>
226 + <b style="font-size:15px;">Mid-article</b>
227 + </div>
289 228
290 - <div>
291 - <div class="mode_style_mid"><label id="mid_widget_id_label" style="float:left;">Mode (Widget ID):</label>
292 - <div class='tooltip'>
293 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
294 - <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
295 - <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>
296 - </g>
297 - </svg>
298 - <div>Your <i>mid-article</i> Mode (Widget ID), as provided by Taboola.</div>
299 - </div>
229 + <div id="mid-article-widgets-container">
230 + <?php
231 + $mid_widgets = !empty($settings->mid_widgets) ? json_decode($settings->mid_widgets) : array();
232 + if (empty($mid_widgets)) {
233 + $mid_widgets = array(new stdClass());
234 + }
235 + foreach ($mid_widgets as $index => $widget) {
236 + ?>
237 + <div class="mid-article-widget" style="border: 1px solid #ddd; padding: 10px; margin-top: 10px; border-radius: 5px;">
238 + <h4 style="font-size: 14px; font-weight: bold;">Mid-Article Widget #<?php echo $index + 1; ?></h4>
239 + <div style="display: flex; flex-wrap: wrap;">
240 + <div style="flex: 1; min-width: 250px; padding-right: 10px;">
241 + <label>Mode (Widget ID):</label>
242 + <input class="widefat" type="text" name="mid_widget_id[]" value="<?php echo esc_attr($widget->widget_id ?? ''); ?>" placeholder="thumbnails-mid1" />
300 243 </div>
301 - <div class="placement_style_mid"><label id="mid_placement_label" style="float:left;">Placement Name:</label>
302 - <div class='tooltip'>
303 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
304 - <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
305 - <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>
306 - </g>
307 - </svg>
308 - <div>Your <i>mid-article</i> Placement Name, as provided by Taboola.</div>
309 - </div>
244 + <div style="flex: 1; min-width: 250px;">
245 + <label>Placement Name:</label>
246 + <input class="widefat" type="text" name="mid_placement[]" value="<?php echo esc_attr($widget->placement ?? ''); ?>" placeholder="Mid Article Thumbnails" />
310 247 </div>
311 248 </div>
312 - <div>
313 - <div class="widget_below_mid">
314 - <input id="mid_widget_id" type="text" value="<?php echo !empty($settings->mid_widget_id) ? strip_tags($settings->mid_widget_id) : "" ?>" name="mid_widget_id" placeholder="Widget ID" />
315 - </div>
316 - <div class="placement_below_mid">
317 - <input id = "mid_placement" type="text" value="<?php echo !empty($settings->mid_placement) ? strip_tags($settings->mid_placement) : "" ?>" name="mid_placement" placeholder="Placement Name" />
318 - </div>
249 + <div class='heading_mid_home'><label style="float:left;">Position the widget immediately below the element:</label>
250 + <div class='tooltip'>
251 + <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
252 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
253 + <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>
254 + </g>
255 + </svg>
256 + <div>The widget will be placed <i>just beneath</i> this element.<br><br>
257 + To target an element, 2 pieces of information are needed:<br><br>
258 + i) A CSS selector - e.g. <i>p</i> (for paragraph).<br>
259 + ii) An occurrence - e.g. 1st, 2nd, 3rd, etc.<br><br>
260 + For more information, see the <a href="https://developers.taboola.com/web-integrations/docs/wordpress-plugin-managing-placements" target='_blank'>Taboola Dev Center</a>.
319 261 </div>
262 + </div>
263 + </div>
320 264
321 - <div id="mid_occurrence_div">
322 - <div class="mode_style_mid_selector"><label id="mid_location_string_label" style="float:left;">Position the widget below:</label>
323 - <div class='tooltip'>
324 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
325 - <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
326 - <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>
327 - </g>
328 - </svg>
329 - <div>
330 - Enter the paragraph number to target. <br>
331 - E.g. To target the <b>5th</b> paragraph, fill in <i>5</i>.<br><br>
332 - ----<br>
333 - <i>Advanced</i> - to use a <b>custom</b> selector:<br><br>
334 - 1) Choose 'Other'. <br>
335 - 2) Fill in a selector (<i>right</i>), and an occurrence (<i>left</i>).
336 - </div>
337 - </div>
265 + <div style="display: flex; flex-wrap: wrap; margin-top: 10px;">
266 + <div style="flex: 1; min-width: 200px; padding-right: 10px;">
267 + <label>Position:</label>
268 + <select class="widefat mid-widget-type-selector" name="mid_paragraph_ui_mode[]">
269 + <option value="Paragraph" <?php echo !isset($widget->location_string) || $widget->location_string === 'p' ? 'selected' : ''; ?>>Paragraph</option>
270 + <option value="Other" <?php echo isset($widget->location_string) && $widget->location_string !== 'p' ? 'selected' : ''; ?>>Other (Custom)</option>
271 + </select>
338 272 </div>
339 - <div class="placement_below_mid_occurrence">
340 - <select name="mid_paragraph_ui_mode" id="mid_paragraph_ui_mode">
341 - <option value="Paragraph" <?php echo (!empty($settings->mid_paragraph_ui_mode) && $settings->mid_paragraph_ui_mode == "Paragraph") ? "selected" : ""?> >Paragraph</option>
342 - <option value="Other" <?php echo (!empty($settings->mid_paragraph_ui_mode) && $settings->mid_paragraph_ui_mode == "Other") ? "selected" : ""?>>Other</option>
343 - </select>&nbsp;
344 - <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;">
273 + <div style="flex: 1; min-width: 150px; padding-right: 10px;" class="mid-css-selector-container">
274 + <label>CSS selector:</label>
275 + <input class="widefat" type="text" name="mid_location_string[]" value="<?php echo esc_attr($widget->location_string ?? 'p'); ?>" />
345 276 </div>
346 -
347 - </div>
348 - <div id="mid_css_selector_div">
349 -
350 - <div class="placement_style_mid_occurrence"><label id="mid_occurrence_label" style="float:left;">CSS selector :</label>
351 - <div class='tooltip'>
352 - <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
353 - <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>
354 - </g>
355 - </svg>
356 - <div>
357 - <i>Advanced</i> - fill in a selector to target - e.g.:<br><br>
358 - <i>#my-id</i> - to target an <i>ID</i> of "my-id".<br>
359 - <i>.my-class</i> - to target a <i>class</i> of "my-class".
360 - </div>
361 - </div>
277 + <div style="flex: 1; min-width: 150px;">
278 + <label>Paragraph/Element Number:</label>
279 + <input class="widefat" type="number" name="mid_location_string_occurrence[]" value="<?php echo esc_attr($widget->occurrence ?? '1'); ?>" min="1" style="width:80px;">
362 280 </div>
363 - <div class="widget_below_mid_selector">
364 - <input id = "mid_location_string" type="text" value="<?php echo !empty($settings->mid_location_string) ? strip_tags($settings->mid_location_string) : "p" ?>" name="mid_location_string" placeholder="E.g. p for paragraph" />
365 - </div>
366 281 </div>
282 + <button type="button" class="button remove-mid-widget" style="margin-top: 10px;">Remove Widget</button>
283 + </div>
284 + <?php } ?>
367 285 </div>
368 - <!-- Mid Article Widget -->
369 -
370 - <!-- Right Rail Article Widget -->
371 -
286 + <button type="button" id="add-mid-widget" class="button button-primary" style="margin-top: 15px;">+ Add Another Mid-Article Widget</button>
287 + </div>
372 288 <div id="right-rail" class="settings_block widget_settings_block">
373 289 <label id="right-rail-label"><b style="font-size:15px;margin-left: 10px;">Right-rail (sidebar)</b> </label>
374 290 <div style="font-size:14px;margin: 5px 10px 10px 10px;">You can insert a <b>Taboola</b> unit in your website <b>sidebar</b> (if your <b>WordPress</b> theme provides one):</div>
375 291
@@ -383,13 +299,132 @@
383 299 <hr>
384 300 To <b>watch a demo</b> of the above steps, see our <a href="https://developers.taboola.com/web-integrations/docs/sidebar-widget" target="_blank">online docs</a>.
385 301 </div>
386 302 </div>
303 +<div id="category_widget" class="settings_block widget_settings_block">
304 + <div class="switch_style">
305 + <label class="switch">
306 + <input id="category_enabled"
307 + type="checkbox"
308 + <?php echo !empty($settings->category_enabled) ? "checked='checked'" : "" ?>
309 + onclick="setEnabledDisabled('#category_widget', this)"
310 + name="category_enabled"/>
311 + <span class="slider round"></span>
312 + </label>
313 + <b style="font-size:15px;float: left;">Category (Section Page)</b>
314 + <div class='tooltip'>
315 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
316 + <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>
317 + </g>
318 + </svg>
319 + <div>Settings will be applied to all 'Category/Section' pages on your site.</div>
320 + </div>
321 + </div>
387 322
388 -<!-- Right Rail Article Widget -->
323 + <div class="label_below">
324 +
325 + <div class="mode_style">
326 + <label id="category_widget_id_label" style="float:left;">Mode (Widget ID):</label>
327 + <div class='tooltip'>
328 + <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
329 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
330 + <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>
331 + </g>
332 + </svg>
333 + <div>Your <i>category</i> Mode (Widget ID), as provided by Taboola.</div>
334 + </div>
335 + </div>
336 +
337 + <div class="placement_style"><label id="category_placement_label" style="float:left;">Placement Name:</label>
338 + <div class='tooltip'>
339 + <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
340 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
341 + <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>
342 + </g>
343 + </svg>
344 + <div>Your <i>category</i> Placement Name, as provided by Taboola.</div>
345 + </div>
346 + </div>
347 + </div>
348 +
389 349
390 -<!-- Homepage mid widget -->
350 + <div class="input_below">
351 + <div class="widget_below">
352 + <input id="category_widget_id" type="text"
353 + value="<?php echo !empty($settings->category_widget_id) ? strip_tags($settings->category_widget_id) : '' ?>"
354 + name="category_widget_id" placeholder="Widget ID"/>
355 + </div>
356 + <div class="placement_below">
357 + <input id="category_placement" type="text"
358 + value="<?php echo !empty($settings->category_placement) ? strip_tags($settings->category_placement) : '' ?>"
359 + name="category_placement" placeholder="Placement Name"/>
360 + </div>
361 + </div>
391 362
363 + <div class='heading_mid_home'><label style="float:left;">Position the widget immediately below the element:</label>
364 + <div class='tooltip'>
365 + <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
366 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
367 + <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>
368 + </g>
369 + </svg>
370 + <div>The widget will be placed <i>just beneath</i> this element.<br><br>
371 + To target an element, 2 pieces of information are needed:<br><br>
372 + i) A CSS selector - e.g. <i>p</i> (for paragraph).<br>
373 + ii) An occurrence - e.g. 1st, 2nd, 3rd, etc.<br><br>
374 + For more information, see the <a href="https://developers.taboola.com/web-integrations/docs/wordpress-plugin-managing-placements" target='_blank'>Taboola Dev Center</a>.
375 + </div>
376 + </div>
377 + </div>
378 +
379 + <div class="home_occurrence">
380 + <div class="mode_style_home_selector">
381 + <label id="category_location_string_label" style="float:left;">CSS selector&nbsp;:</label>
382 + <div class='tooltip'>
383 + <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
384 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
385 + <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>
386 + </g>
387 + </svg>
388 + <div>
389 + The element to target - e.g.:<br><br>
390 + <i>section</i> - to target a <i>section</i>.<br>
391 + <i>#my-id</i> - to target an <i>ID</i> of "my-id".<br>
392 + <i>.my-class</i> - to target a <i>class</i> of "my-class".
393 + </div>
394 + </div>
395 +
396 + </div>
397 + <div class="placement_style_home_occurrence">
398 + <label id="category_occurrence_label" style="float:left;">Occurrence&nbsp;:</label>
399 + <div class='tooltip'>
400 + <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
401 + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
402 + <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>
403 + </g>
404 + </svg>
405 + <div>For a <b>non-unique</b> selector - e.g. <i>section</i> - fill in the <b>occurrence</b> to target.<br><br>
406 + E.g. To target the <b>2nd</b> section, fill in <i>2</i>. <br><br>
407 + For a <b>unique</b> selector - e.g. <i>#my-id</i> - leave the default value of '1'.</div>
408 + </div>
409 +
410 + </div>
411 + </div>
412 +
413 + <div class="home_placement">
414 + <div class="widget_below_home_selector">
415 + <input id="category_location_string" type="text"
416 + value="<?php echo !empty($settings->category_location_string) ? strip_tags($settings->category_location_string) : '' ?>"
417 + name="category_location_string" placeholder="e.g. #content"/>
418 + </div>
419 + <div class="placement_below_home_Occurrence">
420 + <input id="category_occurrence" type="number" min="1"
421 + value="<?php echo !empty($settings->category_location_string_occurrence) ? $settings->category_location_string_occurrence : '1' ?>"
422 + name="category_location_string_occurrence"
423 + style="width:65px;">
424 + </div>
425 + </div>
426 +</div>
392 427 <div id="homepage" class="settings_block widget_settings_block">
393 428 <div class="switch_style">
394 429 <label class="switch">
395 430 <input id="home_enabled" type="checkbox" <?php echo !empty($settings->home_enabled) ? "checked='checked'" : "" ?> onclick="setEnabledDisabled('#homepage', this)" name="home_enabled"/>
@@ -397,9 +432,8 @@
397 432 </label>
398 433 <div>
399 434 <b style="font-size:15px;float: left;">Homepage (front page)</b>
400 435 <div class='tooltip'>
401 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
402 436 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
403 437 <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>
404 438 </g>
405 439 </svg>
@@ -410,9 +444,8 @@
410 444
411 445 <div>
412 446 <div class="mode_style_home"><label id="home_widget_id_label" style="float:left;">Mode (Widget ID):</label>
413 447 <div class='tooltip'>
414 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
415 448 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
416 449 <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>
417 450 </g>
418 451 </svg>
@@ -420,9 +453,8 @@
420 453 </div>
421 454 </div>
422 455 <div class="placement_style_home"><label id="home_placement_label" style="float:left;">Placement Name:</label>
423 456 <div class='tooltip'>
424 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
425 457 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
426 458 <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>
427 459 </g>
428 460 </svg>
@@ -440,9 +472,8 @@
440 472 </div>
441 473
442 474 <div class='heading_mid_home'><label style="float:left;">Position the widget immediately below the element:</label>
443 475 <div class='tooltip'>
444 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
445 476 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
446 477 <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>
447 478 </g>
448 479 </svg>
@@ -458,9 +489,8 @@
458 489
459 490 <div class="home_occurrence">
460 491 <div class="mode_style_home_selector"><label id="home_location_string_label" style="float:left;">CSS selector :</label>
461 492 <div class='tooltip'>
462 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
463 493 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
464 494 <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>
465 495 </g>
466 496 </svg>
@@ -473,9 +503,8 @@
473 503 </div>
474 504 </div>
475 505 <div class="placement_style_home_occurrence"><label id="home_occurrence_label" style="float:left;">Occurrence :</label>
476 506 <div class='tooltip'>
477 - <!-- <i class="fa fa-question-circle" aria-hidden="true"></i> -->
478 507 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN">
479 508 <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>
480 509 </g>
481 510 </svg>
@@ -494,10 +523,8 @@
494 523 </div>
495 524 </div>
496 525 </div>
497 526
498 -<!-- Homepage mid widget -->
499 -
500 527 <div id="advanced-settings-main">
501 528 <a id="show-advanced-settings">Show advanced settings >></a>
502 529 <div class="change_button">
503 530 <input class='apply_button' type="submit" value="Apply Changes"/>
@@ -514,9 +541,8 @@
514 541 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="helpTooltip__icon___1XWGN_first">
515 542 <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>
516 543 </g>
517 544 </svg>
518 - <!-- <div id="arrow" ></div> -->
519 545 <div>Your SC web-push numeric account ID, as provided by Taboola.<br>
520 546 This integration is only for sponsored web-push <br> <br>
521 547 The header script and service worker will only be injected if the publisher already has the taboola widget running on their site.
522 548 </div>
@@ -553,34 +579,102 @@
553 579 $userDetails = wp_get_current_user();
554 580 $detailsString = $userDetails->first_name." ".$userDetails->last_name;
555 581 ?>
556 582 <img src="https://logs-01.loggly.com/inputs/d14862f3-64ad-49ca-b28d-1b5d155414ec.gif?source=wp&type=settings&pub=<?=$logPublisher?>&user=<?=urlencode($detailsString)?>&email=<?=urlencode($userDetails->user_email)?>&url=<?=urlencode("//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}")?>"/>
557 - <!-- <form name="install_log" style="display:none;" method="post" action="http://logs-01.loggly.com/inputs/d14862f3-64ad-49ca-b28d-1b5d155414ec/tag/http/">
558 - <input name="tim" type="hidden" value="<?=date("H:i:s.000")?>">
559 - <input name="pub" type="hidden" value="<?=$logPublisher?>">
560 - <input name="data" type="hideen" value="WORDPRESS_PLUGIN_INSTALL|<?="//{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}|{$detailsString}"?>">
561 - </form> -->
562 583 </div>
563 584
564 585 <script>
565 -
566 - // Set enabled/disabled appearance upon page load
567 - // (Function is defined earlier on the page.)
568 586 setEnabledDisabled('#below_article', document.getElementById("first_bc_enabled"));
569 587 setEnabledDisabled('#mid_article', document.getElementById("mid_enabled"));
570 588 setEnabledDisabled('#homepage', document.getElementById("home_enabled"));
571 589 setEnabledDisabled('#web_push', document.getElementById("web_push_enabled"));
590 + setEnabledDisabled('#category_widget',document.getElementById('category_enabled'));
591 +</script>
572 592
593 +<script>
594 +jQuery(document).ready(function($) {
595 + let widgetCounter = $('#mid-article-widgets-container .mid-article-widget').length;
596 +
597 + // Function to set the initial correct view for widgets
598 + function initializeWidgetView() {
599 + $('#mid-article-widgets-container .mid-widget-type-selector').each(function() {
600 + var container = $(this).closest('.mid-article-widget');
601 + var selectorInputContainer = container.find('.mid-css-selector-container');
602 +
603 + if ($(this).val() === 'Paragraph') {
604 + selectorInputContainer.hide();
605 + } else {
606 + selectorInputContainer.show();
607 + }
608 + });
609 + }
610 +
611 + // Call the function on page load to fix the initial view
612 + initializeWidgetView();
613 +
614 + // Add a new mid-article widget section
615 + $('#add-mid-widget').on('click', function() {
616 + widgetCounter++;
617 + var widgetHtml = `
618 + <div class="mid-article-widget" style="border: 1px solid #ddd; padding: 10px; margin-top: 10px; border-radius: 5px;">
619 + <h4 style="font-size: 14px; font-weight: bold;">Mid-Article Widget #${widgetCounter}</h4>
620 + <div style="display: flex; flex-wrap: wrap;">
621 + <div style="flex: 1; min-width: 250px; padding-right: 10px;">
622 + <label>Mode (Widget ID):</label>
623 + <input class="widefat" type="text" name="mid_widget_id[]" placeholder="thumbnails-mid1" />
624 + </div>
625 + <div style="flex: 1; min-width: 250px;">
626 + <label>Placement Name:</label>
627 + <input class="widefat" type="text" name="mid_placement[]" placeholder="Mid Article Thumbnails" />
628 + </div>
629 + </div>
630 + <div style="display: flex; flex-wrap: wrap; margin-top: 10px;">
631 + <div style="flex: 1; min-width: 200px; padding-right: 10px;">
632 + <label>Position below:</label>
633 + <select class="widefat mid-widget-type-selector" name="mid_paragraph_ui_mode[]">
634 + <option value="Paragraph" selected>Paragraph</option>
635 + <option value="Other">Other (Custom)</option>
636 + </select>
637 + </div>
638 + <div style="flex: 1; min-width: 150px; padding-right: 10px; display:none;" class="mid-css-selector-container">
639 + <label>CSS selector:</label>
640 + <input class="widefat" type="text" name="mid_location_string[]" value="p" />
641 + </div>
642 + <div style="flex: 1; min-width: 150px;">
643 + <label>Paragraph/Element Number:</label>
644 + <input class="widefat" type="number" name="mid_location_string_occurrence[]" value="1" min="1" style="width:80px;">
645 + </div>
646 + </div>
647 + <button type="button" class="button remove-mid-widget" style="margin-top: 10px;">Remove Widget</button>
648 + </div>`;
649 + $('#mid-article-widgets-container').append(widgetHtml);
650 + });
651 +
652 + // Remove a mid-article widget section
653 + $('#mid-article-widgets-container').on('click', '.remove-mid-widget', function() {
654 + $(this).closest('.mid-article-widget').remove();
655 + $('#mid-article-widgets-container .mid-article-widget').each(function(index) {
656 + $(this).find('h4').text(`Mid-Article Widget #${index + 1}`);
657 + });
658 + widgetCounter = $('#mid-article-widgets-container .mid-article-widget').length;
659 + });
660 +
661 + // Handle the show/hide for the CSS selector field on change
662 + $('#mid-article-widgets-container').on('change', '.mid-widget-type-selector', function() {
663 + var container = $(this).closest('.mid-article-widget');
664 + var selectorInputContainer = container.find('.mid-css-selector-container');
665 + var selectorInput = selectorInputContainer.find('input');
666 +
667 + if ($(this).val() === 'Paragraph') {
668 + selectorInputContainer.hide();
669 + selectorInput.val('p');
670 + } else {
671 + selectorInputContainer.show();
672 + }
673 + });
674 +});
573 675 </script>
574 676
575 677 <script>
576 -
577 - // Fadeouts for error/success messages
578 678 setTimeout(function(){jQuery('.label-success').fadeOut()}, 5000);
579 679 setTimeout(function(){jQuery('.label-error').fadeOut()}, 8000);
580 -
581 - // PC
582 - // window.onload = function(){
583 - // document.forms['install_log'].submit()
584 - // }
585 -
586 680 </script>