Plugin Directory

Changeset 3457476


Ignore:
Timestamp:
02/09/2026 09:30:59 PM (7 weeks ago)
Author:
kionae
Message:

2.0.4

  • Fixing security issue with clear redirect count AJAX call
  • Added code to flush permalinks on activation to prevent 404s
Location:
qr-redirector
Files:
237 added
2 edited

Legend:

Unmodified
Added
Removed
  • qr-redirector/trunk/qr-redirector.php

    r3435207 r3457476  
    22/**
    33 * @package QR Redirector
    4  * @version 2.0.3
     4 * @version 2.0.4
    55 */
    66/*
     
    99Description: QR Redirector lets you create dynamic QR Codes by a generating a QR code for a URL on your site, and redirecting that URL anywhere you want.
    1010Author: Nikki Blight <nblight@nlb-creations.com>
    11 Version: 2.0.3
     11Version: 2.0.4
    1212Author URI: http://www.nlb-creations.com
    1313*/
     
    2929use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
    3030use Endroid\QrCode\Writer\PngWriter;
     31
     32/**
     33 * Flush permalinks so we don't get a bunch of 404 errors after activation for the custom post type
     34 */
     35function qr_plugin_activate() {
     36    //register post types
     37    qr_create_post_types();
     38    // Flush rewrite rules
     39    flush_rewrite_rules();
     40}
     41register_activation_hook( __FILE__, 'qr_plugin_activate' );
    3142
    3243/**
     
    151162 */
    152163function qr_clear_count($post_id) {
     164   
     165    // Verify the nonce
     166    if ( ! isset( $_POST['qr_nonce'] ) || ! wp_verify_nonce( $_POST['qr_nonce'], 'qr-security' ) ) {
     167        wp_send_json_error( 'Security check failed' );
     168        wp_die();
     169    }
     170   
    153171    if(!$post_id) {
    154172        $post_id = $_POST['post_id'];
     
    158176    update_post_meta($post_id,'qr_redirect_count',$count);
    159177}
     178
     179/**
     180 * Generate the javascript to make an AJAX call to the qr_clear_count() function on the qrcode edit page
     181 */
     182function qr_clear_count_javascript() {
     183    global $post_type;
     184   
     185    if( 'qrcode' == $post_type ) {
     186        global $post;
     187       
     188        ?>
     189        <script type="text/javascript" >
     190        jQuery("#clear_count_button").click(function($) {
     191            var data = {
     192                'action': 'qr_clear_count',
     193                'post_id': <?php echo $post->ID; ?>,
     194                'qr_nonce' : '<?php echo wp_create_nonce('qr-security'); ?>'
     195            };
     196   
     197            if (confirm("Are you sure you want to clear the redirect count?") == true) {
     198                jQuery.post(ajaxurl, data, function(response) {
     199                    jQuery("#qr_count_value").text("0");
     200                });
     201            }
     202        });
     203        </script> <?php
     204    }
     205}
     206add_action( 'admin_footer', 'qr_clear_count_javascript' ); //insert the javascript
     207add_action( 'wp_ajax_qr_clear_count', 'qr_clear_count' ); //connect the AJAX call to the PHP function
    160208
    161209/**
     
    354402    echo '</div>';
    355403}
    356 
    357 /**
    358  * Generate the javascript to make an AJAX call to the qr_clear_count() function on the qrcode edit page
    359  */
    360 function qr_clear_count_javascript() {
    361     global $post_type;
    362    
    363     if( 'qrcode' == $post_type ) {
    364         global $post;
    365        
    366         ?>
    367         <script type="text/javascript" >
    368         jQuery("#clear_count_button").click(function($) {
    369             var data = {
    370                 'action': 'qr_clear_count',
    371                 'post_id': <?php echo $post->ID; ?>
    372             };
    373    
    374             if (confirm("Are you sure you want to clear the redirect count?") == true) {
    375                 jQuery.post(ajaxurl, data, function(response) {
    376                     jQuery("#qr_count_value").text("0");
    377                 });
    378             }
    379         });
    380         </script> <?php
    381     }
    382 }
    383 add_action( 'admin_footer', 'qr_clear_count_javascript' ); //insert the javascript
    384 add_action( 'wp_ajax_qr_clear_count', 'qr_clear_count' ); //connect the AJAX call to the PHP function
    385404
    386405/**
  • qr-redirector/trunk/readme.txt

    r3435207 r3457476  
    44Tags: qr code, redirection
    55Requires at least: 3.2.0
    6 Tested up to: 6.9
    7 Stable tag: 2.0.3
     6Tested up to: 6.9.1
     7Stable tag: 2.0.4
    88
    99QR Redirector lets you create a QR code for a URL on your site, and redirect that URL anywhere.  The result is a reusable QR Code.
     
    7171
    7272== Changelog ==
     73
     74= 2.0.4 =
     75* Fixing security issue with clear redirect count AJAX call
     76* Added code to flush permalinks on activation to prevent 404s
    7377
    7478= 2.0.3 =
Note: See TracChangeset for help on using the changeset viewer.