Changeset 3459181
- Timestamp:
- 02/11/2026 05:51:25 PM (11 days ago)
- Location:
- sided/trunk
- Files:
-
- 8 edited
-
includes/block-editor/index.js (modified) (3 diffs)
-
includes/block-editor/sided-block-editor.php (modified) (1 diff)
-
partials/functions.php (modified) (8 diffs)
-
partials/sided-create-debate-from-block.php (modified) (1 diff)
-
partials/sided-create-debate.php (modified) (1 diff)
-
partials/sided-settings.php (modified) (6 diffs)
-
readme.txt (modified) (1 diff)
-
sided.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
sided/trunk/includes/block-editor/index.js
r2976952 r3459181 53 53 data: { 54 54 action: 'wpa_fetch_debates', 55 sided_ajax_nonce: (typeof sidedBlockEditor !== 'undefined' && sidedBlockEditor.ajaxNonce) ? sidedBlockEditor.ajaxNonce : '', 55 56 searchText: event.target.value, 56 57 results_per_page: event.target.value.length === 0 ? 10 : 999 … … 107 108 data: { 108 109 action: 'wpa_fetch_current_debate', 110 sided_ajax_nonce: (typeof sidedBlockEditor !== 'undefined' && sidedBlockEditor.ajaxNonce) ? sidedBlockEditor.ajaxNonce : '', 109 111 debateId: debateId 110 112 }, … … 471 473 data: { 472 474 action: 'wpa_fetch_current_debate', 475 sided_ajax_nonce: (typeof sidedBlockEditor !== 'undefined' && sidedBlockEditor.ajaxNonce) ? sidedBlockEditor.ajaxNonce : '', 473 476 debateId: debateId 474 477 }, -
sided/trunk/includes/block-editor/sided-block-editor.php
r2976952 r3459181 23 23 ); 24 24 25 wp_localize_script( 26 'embed-sided-debates-block-editor', 27 'sidedBlockEditor', 28 array( 29 'ajaxNonce' => wp_create_nonce( 'sided_ajax' ), 30 ) 31 ); 32 25 33 register_block_type( 26 34 'sided/sided-debate-selector', -
sided/trunk/partials/functions.php
r3379194 r3459181 111 111 if ($embed_placement_option['active'] == 'true' && $embed_placement_option['embed_location_on_page'] !== 'sidebar') { 112 112 return sprintf( 113 '%s<div class="sided-widget" clientId="% d" placementId="%d"></div>',113 '%s<div class="sided-widget" clientId="%s" placementId="%s"></div>', 114 114 $content, 115 $sided_selected_network,116 $embed_placement_option['placement_id']115 esc_attr( (string) $sided_selected_network ), 116 esc_attr( (string) $embed_placement_option['placement_id'] ) 117 117 ); 118 118 } … … 166 166 167 167 add_action('wp_ajax_wpa_sided_initiate_script', 'sided_wpa_sided_initiate_script_callback'); 168 add_action('wp_ajax_nopriv_wpa_sided_initiate_script', 'sided_wpa_sided_initiate_script_callback');169 168 function sided_wpa_sided_initiate_script_callback() 170 169 { 170 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 171 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 172 } 173 if ( ! current_user_can( 'manage_options' ) ) { 174 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 175 } 171 176 echo esc_js(update_option('sided_sided_initiate_script', sanitize_text_field($_POST['checked']))); 172 177 wp_die(); … … 174 179 175 180 add_action('wp_ajax_wpa_send_cats_to_sided', 'sided_wpa_send_cats_to_sided_callback'); 176 add_action('wp_ajax_nopriv_wpa_send_cats_to_sided', 'sided_wpa_send_cats_to_sided_callback');177 181 function sided_wpa_send_cats_to_sided_callback() 178 182 { 183 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 184 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 185 } 186 if ( ! current_user_can( 'manage_options' ) ) { 187 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 188 } 179 189 echo esc_js(update_option('send_cats_to_sided', sanitize_text_field($_POST['checked']))); 180 190 wp_die(); … … 182 192 183 193 add_action('wp_ajax_wpa_send_tags_to_sided', 'sided_wpa_send_tags_to_sided_callback'); 184 add_action('wp_ajax_nopriv_wpa_send_tags_to_sided', 'sided_wpa_send_tags_to_sided_callback');185 194 function sided_wpa_send_tags_to_sided_callback() 186 195 { 196 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 197 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 198 } 199 if ( ! current_user_can( 'manage_options' ) ) { 200 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 201 } 187 202 echo esc_js(update_option('send_tags_to_sided', sanitize_text_field($_POST['checked']))); 188 203 wp_die(); 189 204 } 190 205 191 add_action('wp_ajax_nopriv_wpa_fetch_embed_placements', 'sided_wpa_fetch_embed_placements_callback');192 206 add_action('wp_ajax_wpa_fetch_embed_placements', 'sided_wpa_fetch_embed_placements_callback'); 193 207 function sided_wpa_fetch_embed_placements_callback() 194 208 { 209 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 210 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 211 } 212 if ( ! current_user_can( 'manage_options' ) ) { 213 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 214 } 195 215 update_option('sided_sided_selected_network', sanitize_text_field($_POST['selectedValue'])); 196 216 delete_option('sided_sided_embed_placement_options'); … … 213 233 } 214 234 215 add_action('wp_ajax_nopriv_wpa_sided_generate_smart_poll', 'sided_wpa_sided_generate_smart_poll_callback');216 235 add_action('wp_ajax_wpa_sided_generate_smart_poll', 'sided_wpa_sided_generate_smart_poll_callback'); 217 236 function sided_wpa_sided_generate_smart_poll_callback() 218 237 { 238 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 239 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 240 } 241 if ( ! current_user_can( 'manage_options' ) ) { 242 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 243 } 219 244 //print_r($_POST['SPC_keyword_val']); 220 245 $url = SIDED_API_URL . '/admin/debate/generateDebates?count=4&url=' . sanitize_text_field($_POST['SPC_keyword_val']); … … 239 264 240 265 add_action('wp_ajax_wpa_save_embed_options', 'wpa_save_embed_options_callback'); 241 add_action('wp_ajax_nopriv_wpa_save_embed_options', 'wpa_save_embed_options_callback');242 266 function wpa_save_embed_options_callback() 243 267 { 244 $_POST['jsonObj']['updated_at'] = current_datetime(); 245 // commented on 2024-10-16, it was not saving embed placement options 246 // echo esc_js(update_option('sided_sided_embed_placement_options', esc_js($_POST['jsonObj']))); 247 248 // changes made on 2024-10-16 to save embed placement options 249 if (get_option('sided_sided_embed_placement_options') == false) { 250 add_option('sided_sided_embed_placement_options', $_POST['jsonObj']); 268 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 269 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 270 } 271 if ( ! current_user_can( 'manage_options' ) ) { 272 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 273 } 274 $raw = isset( $_POST['jsonObj'] ) && is_array( $_POST['jsonObj'] ) ? wp_unslash( $_POST['jsonObj'] ) : array(); 275 $allowed_locations = array( 'bottom_of_every_post', 'sidebar' ); 276 $sanitized = array(); 277 foreach ( $raw as $index => $item ) { 278 if ( ! is_array( $item ) ) { 279 continue; 280 } 281 $placement_id = isset( $item['placement_id'] ) ? absint( $item['placement_id'] ) : 0; 282 $embed_location = isset( $item['embed_location_on_page'] ) && in_array( $item['embed_location_on_page'], $allowed_locations, true ) 283 ? $item['embed_location_on_page'] 284 : 'bottom_of_every_post'; 285 $sanitized[ $index ] = array( 286 'active' => ! empty( $item['active'] ) && $item['active'] !== 'false' ? 'true' : 'false', 287 'placement_id' => $placement_id, 288 'placement_text' => isset( $item['placement_text'] ) ? sanitize_text_field( $item['placement_text'] ) : '', 289 'embed_location_on_page' => $embed_location, 290 ); 291 } 292 $sanitized['updated_at'] = current_datetime(); 293 if ( get_option( 'sided_sided_embed_placement_options' ) == false ) { 294 add_option( 'sided_sided_embed_placement_options', $sanitized ); 251 295 } else { 252 update_option('sided_sided_embed_placement_options', $_POST['jsonObj']); 253 } 254 // changes made on 2024-10-16 to save embed placement options end 296 update_option( 'sided_sided_embed_placement_options', $sanitized ); 297 } 255 298 wp_die(); 256 299 } … … 300 343 } 301 344 302 add_action('wp_ajax_nopriv_wpa_fetch_debates', 'wpa_fetch_debates_callback');303 345 add_action('wp_ajax_wpa_fetch_debates', 'wpa_fetch_debates_callback'); 304 346 function wpa_fetch_debates_callback() 305 347 { 348 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 349 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 350 } 351 if ( ! current_user_can( 'manage_options' ) ) { 352 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 353 } 306 354 $selected_network = get_option('sided_sided_selected_network') ? get_option('sided_sided_selected_network') : 1; 307 355 //$selected_network = array_key_exists('selected_network', $_SESSION) ? $_SESSION['selected_network'] : 1; … … 328 376 } 329 377 330 add_action('wp_ajax_nopriv_wpa_fetch_current_debate', 'wpa_fetch_current_debate_callback');331 378 add_action('wp_ajax_wpa_fetch_current_debate', 'wpa_fetch_current_debate_callback'); 332 379 function wpa_fetch_current_debate_callback() 333 380 { 334 381 if ( ! isset( $_REQUEST['sided_ajax_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_REQUEST['sided_ajax_nonce'] ) ), 'sided_ajax' ) ) { 382 wp_send_json_error( array( 'message' => __( 'Security check failed.', 'sided' ) ), 403 ); 383 } 384 if ( ! current_user_can( 'manage_options' ) ) { 385 wp_send_json_error( array( 'message' => __( 'You do not have permission to perform this action.', 'sided' ) ), 403 ); 386 } 335 387 $debateId = isset($_GET['debateId']) ? sanitize_text_field($_GET['debateId']) : ''; 336 388 $url = SIDED_API_URL . '/debate/'.$debateId.'?deviceId='.$debateId; -
sided/trunk/partials/sided-create-debate-from-block.php
r3194244 r3459181 330 330 data: { 331 331 action: 'wpa_sided_generate_smart_poll', 332 sided_ajax_nonce: '<?php echo esc_js( wp_create_nonce( 'sided_ajax' ) ); ?>', 332 333 SPC_keyword_val: SPC_keyword.val(), 333 334 }, -
sided/trunk/partials/sided-create-debate.php
r3194244 r3459181 316 316 data: { 317 317 action: 'wpa_sided_generate_smart_poll', 318 sided_ajax_nonce: '<?php echo esc_js( wp_create_nonce( 'sided_ajax' ) ); ?>', 318 319 SPC_keyword_val: SPC_keyword.val(), 319 320 }, -
sided/trunk/partials/sided-settings.php
r3369836 r3459181 121 121 <?php 122 122 $placement_options_array = get_option('sided_sided_embed_placement_options'); 123 if (isset($placement_options_array['updated_at'])) { 124 unset($placement_options_array['updated_at']); 123 if ( ! is_array( $placement_options_array ) ) { 124 $placement_options_array = array(); 125 } 126 if ( isset( $placement_options_array['updated_at'] ) ) { 127 unset( $placement_options_array['updated_at'] ); 128 } 129 $placement_options_safe = array(); 130 foreach ( $placement_options_array as $key => $item ) { 131 if ( ! is_array( $item ) ) { 132 continue; 133 } 134 $placement_options_safe[ $key ] = array( 135 'active' => isset( $item['active'] ) ? $item['active'] : 'false', 136 'placement_id' => isset( $item['placement_id'] ) ? (int) $item['placement_id'] : 0, 137 'placement_text' => isset( $item['placement_text'] ) ? esc_html( $item['placement_text'] ) : '', 138 'embed_location_on_page' => isset( $item['embed_location_on_page'] ) ? esc_attr( $item['embed_location_on_page'] ) : 'bottom_of_every_post', 139 ); 125 140 } 126 141 127 142 ?> 128 143 <script type="text/javascript"> 144 var sided_ajax_nonce = '<?php echo esc_js( wp_create_nonce( 'sided_ajax' ) ); ?>'; 129 145 (function ($) { 130 146 $('input[name="sided_initiate_script"]').change(function() { 131 147 var data = { 132 148 action: 'wpa_sided_initiate_script', 149 sided_ajax_nonce: sided_ajax_nonce, 133 150 checked: $(this).is(":checked") ? true : false, 134 151 }; … … 141 158 var data = { 142 159 action: 'wpa_send_cats_to_sided', 160 sided_ajax_nonce: sided_ajax_nonce, 143 161 checked: $(this).is(":checked") ? true : false, 144 162 }; … … 151 169 var data = { 152 170 action: 'wpa_send_tags_to_sided', 171 sided_ajax_nonce: sided_ajax_nonce, 153 172 checked: $(this).is(":checked") ? true : false, 154 173 }; … … 167 186 data: { 168 187 action: 'wpa_fetch_embed_placements', 188 sided_ajax_nonce: sided_ajax_nonce, 169 189 selectedValue: selectedValue 170 190 }, … … 186 206 function fetch_selected_placements(){ 187 207 $('#placement-option-wrapper').html(''); 188 var dataArray = $.parseJSON('<?php echo wp_json_encode($placement_options_array); ?>');189 if (dataArray == ''){ $(".select_network").trigger("change"); }208 var dataArray = <?php echo wp_json_encode( $placement_options_safe ); ?>; 209 if ( ! dataArray || dataArray.length === 0 ) { $(".select_network").trigger("change"); } 190 210 $.each(dataArray , function(key, value){ 191 211 var checked = value['active'] == 'true' ? 'checked' : ''; … … 204 224 var data = { 205 225 action: 'wpa_save_embed_options', 226 sided_ajax_nonce: sided_ajax_nonce, 206 227 jsonObj: jsonObj, 207 228 }; -
sided/trunk/readme.txt
r3439973 r3459181 5 5 Requires at least: 4.7 6 6 Tested up to: 6.5.3 7 Stable tag: 1.4.1 17 Stable tag: 1.4.12 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later -
sided/trunk/sided.php
r3439973 r3459181 1 1 <?php 2 2 /** 3 * Plugin Name: Sided 4 * Plugin URI: https://sided.co/ 5 * Description: It is a wordpress plugin to embed sided polls in your Wordpress website. 6 * Version: 1.4.11 7 * Author: Sided 8 **/ 3 * Plugin Name: Sided 4 * Plugin URI: https://sided.co/ 5 * Description: It is a wordpress plugin to embed sided polls in your Wordpress website. 6 * Version: 1.4.12 7 * Author: Sided 8 * Author URI: https://sided.co/ 9 * License: GPLv2 or later 10 * License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 * Text Domain: sided 12 */ 9 13 10 define( 'SIDED_VERSION', '1.4.1 1' );14 define( 'SIDED_VERSION', '1.4.12' ); 11 15 define( 'SIDED_PLUGIN', __FILE__ ); 12 16 define( 'SIDED_PLUGIN_DIR', untrailingslashit( dirname( SIDED_PLUGIN ) ) );
Note: See TracChangeset
for help on using the changeset viewer.