Plugin Directory

Changeset 2782077


Ignore:
Timestamp:
09/08/2022 04:46:54 PM (4 years ago)
Author:
kionae
Message:

1.6.3

  • fixed conflict with the Quick Edit script and non-qrcode Quick Edit links in the WordPress dashboard
  • added the ability to clear the redirect count for a QR code from the edit page
Location:
qr-redirector
Files:
448 added
2 edited

Legend:

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

    r2706605 r2782077  
    22/**
    33 * @package QR Redirector
    4  * @version 1.6.2
     4 * @version 1.6.3
    55 */
    66/*
    7 Plugin Name: QR Redirector
    8 Plugin URI: http://nlb-creations.com/2012/10/19/wordpress-plugin-qr-redirector/
    9 Description: QR Redirector lets you essentially create dynamic QR Codes by a generating a QR code for a URL on your site, and redirecting that URL anywhere you want.
    10 Author: Nikki Blight <nblight@nlb-creations.com>
    11 Version: 1.6.2
    12 Author URI: http://www.nlb-creations.com
    13 */
     7 Plugin Name: QR Redirector
     8 Plugin URI: http://nlb-creations.com/2012/10/19/wordpress-plugin-qr-redirector/
     9 Description: QR Redirector lets you essentially create dynamic QR Codes by a generating a QR code for a URL on your site, and redirecting that URL anywhere you want.
     10 Author: Nikki Blight <nblight@nlb-creations.com>
     11 Version: 1.6.3
     12 Author URI: http://www.nlb-creations.com
     13 */
    1414
    1515include('phpqrcode/qrlib.php');
     
    2424        wp_register_style( 'qr_admin_css', plugins_url('/admin.css', __FILE__), false, '1.0.0' );
    2525        wp_enqueue_style( 'qr_admin_css' );
    26     }
    27     wp_enqueue_script('quick-edit-script', plugin_dir_url(__FILE__) . '/post-quick-edit-script.js', array('jquery','inline-edit-post' ));
     26        wp_enqueue_script('quick-edit-script', plugin_dir_url(__FILE__) . '/post-quick-edit-script.js', array('jquery','inline-edit-post' ));
     27    }
    2828}
    2929add_action('admin_enqueue_scripts', 'load_qr_admin_style');
     
    4949            $uri = $_SERVER['REQUEST_URI'];
    5050        }
    51    
     51       
    5252        $post = get_page_by_path($uri,'OBJECT','qrcode');
    5353    }
     
    5555    if(!is_admin() && is_singular( 'qrcode' )) {
    5656        //if(isset($post->post_type) && $post->post_type == 'qrcode') {
    57             $url = get_post_meta($post->ID, 'qr_redirect_url', true);
    58             $response = get_post_meta($post->ID, 'qr_redirect_response', true);
     57        $url = get_post_meta($post->ID, 'qr_redirect_url', true);
     58        $response = get_post_meta($post->ID, 'qr_redirect_response', true);
     59       
     60        if($url != '') {
     61            qr_add_count($post->ID);
    5962           
    60             if($url != '') {
    61                 qr_add_count($post->ID);
    62                
    63                 if($response == '') {
    64                     header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //prevent browers from caching the redirect url
    65                     header( 'Location: '.$url, true );
    66                 }
    67                 else {
    68                     header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //prevent browers from caching the redirect url
    69                     header( 'Location: '.$url, true, $response );
    70                 }
    71                 exit();
     63            if($response == '') {
     64                header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //prevent browers from caching the redirect url
     65                header( 'Location: '.$url, true );
    7266            }
    7367            else {
    74                 //if for some reason there's no url, redirect to homepage
    7568                header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //prevent browers from caching the redirect url
    76                 header( 'Location: '.get_bloginfo('url'));
    77                 exit();
    78             }
     69                header( 'Location: '.$url, true, $response );
     70            }
     71            exit();
     72        }
     73        else {
     74            //if for some reason there's no url, redirect to homepage
     75            header( 'Cache-Control: no-store, no-cache, must-revalidate' ); //prevent browers from caching the redirect url
     76            header( 'Location: '.get_bloginfo('url'));
     77            exit();
     78        }
    7979        //}
    8080    }
     
    8484function qr_create_post_types() {
    8585    register_post_type( 'qrcode',
    86         array(
    87             'labels' => array(
    88                 'name' => __( 'QR Redirects' ),
    89                 'singular_name' => __( 'QR Redirect' ),
    90                 'add_new' => __( 'Add QR Redirect'),
    91                 'add_new_item' => __( 'Add QR Redirect'),
    92                 'edit_item' => __( 'Edit QR Redirect' ),
    93                 'new_item' => __( 'New QR Redirect' ),
    94                 'view_item' => __( 'View QR Redirect' )
    95             ),
    96             'show_ui' => true,
    97             'description' => 'Post type for QR Redirects',
    98             //'menu_position' => 5,
    99             'menu_icon' => WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) . '/qr-menu-icon.png',
    100             'public' => true,
    101             'exclude_from_search' => true,
    102             'supports' => array('title'),
    103             'rewrite' => array('slug' => 'qr'),
    104             'can_export' => true
    105         )
    106     );
     86            array(
     87                    'labels' => array(
     88                            'name' => __( 'QR Redirects' ),
     89                            'singular_name' => __( 'QR Redirect' ),
     90                            'add_new' => __( 'Add QR Redirect'),
     91                            'add_new_item' => __( 'Add QR Redirect'),
     92                            'edit_item' => __( 'Edit QR Redirect' ),
     93                            'new_item' => __( 'New QR Redirect' ),
     94                            'view_item' => __( 'View QR Redirect' )
     95                    ),
     96                    'show_ui' => true,
     97                    'description' => 'Post type for QR Redirects',
     98                    //'menu_position' => 5,
     99                    'menu_icon' => WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)) . '/qr-menu-icon.png',
     100                    'public' => true,
     101                    'exclude_from_search' => true,
     102                    'supports' => array('title'),
     103                    'rewrite' => array('slug' => 'qr'),
     104                    'can_export' => true
     105            )
     106            );
    107107}
    108108
     
    118118}
    119119
     120//simple function to clear the count for a given qr code
     121function qr_clear_count($post_id) {
     122    if(!$post_id) {
     123        $post_id = $_POST['post_id'];
     124    }
     125   
     126    $count = 0;
     127    update_post_meta($post_id,'qr_redirect_count',$count);
     128}
     129
    120130// Add a custom postmeta field for the redirect url
    121131add_action( 'add_meta_boxes', 'qr_dynamic_add_custom_box' );
     
    126136//Add boxes to the edit screens for a qrcode post type
    127137function qr_dynamic_add_custom_box() {
    128     //the redirect url
     138    //the redirect url
    129139    add_meta_box(
    130         'dynamic_url',
    131         __( 'Redirect URL', 'myplugin_textdomain' ),
    132         'qr_redirect_custom_box',
    133         'qrcode');
    134        
    135     //the actual generated qr code
    136     add_meta_box(
    137         'dynamic_qr',
    138         __( 'QR Code', 'myplugin_textdomain' ),
    139         'qr_image_custom_box',
    140         'qrcode',
    141         'side');
     140            'dynamic_url',
     141            __( 'Redirect URL', 'myplugin_textdomain' ),
     142            'qr_redirect_custom_box',
     143            'qrcode');
     144           
     145            //the actual generated qr code
     146            add_meta_box(
     147                    'dynamic_qr',
     148                    __( 'QR Code', 'myplugin_textdomain' ),
     149                    'qr_image_custom_box',
     150                    'qrcode',
     151                    'side');
    142152}
    143153
    144154//print the url custom meta box content
    145155function qr_redirect_custom_box() {
    146     global $post;
    147     // Use nonce for verification
    148     wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );
    149    
    150     echo '<div id="meta_inner">';
    151 
    152     //get the saved metadata
    153     $url = get_post_meta($post->ID,'qr_redirect_url',true);
    154     $ecl = get_post_meta($post->ID,'qr_redirect_ecl',true);
    155     $size = get_post_meta($post->ID,'qr_redirect_size',true);
    156     $response = get_post_meta($post->ID,'qr_redirect_response',true);
    157     $notes = get_post_meta($post->ID,'qr_redirect_notes',true);
    158 
    159     //output the form
     156    global $post;
     157    // Use nonce for verification
     158    wp_nonce_field( plugin_basename( __FILE__ ), 'dynamicMeta_noncename' );
     159   
     160    echo '<div id="meta_inner">';
     161   
     162    //get the saved metadata
     163    $url = get_post_meta($post->ID,'qr_redirect_url',true);
     164    $ecl = get_post_meta($post->ID,'qr_redirect_ecl',true);
     165    $size = get_post_meta($post->ID,'qr_redirect_size',true);
     166    $response = get_post_meta($post->ID,'qr_redirect_response',true);
     167    $notes = get_post_meta($post->ID,'qr_redirect_notes',true);
     168   
     169    //output the form
    160170    echo '<p> <strong>URL to Redirect to:</strong> <input type="text" name="qr_redirect[url]" value="'.$url.'" style="width: 80%;" /> </p>';
    161171   
     
    260270//print the qr code image and meta info
    261271function qr_image_custom_box() {
    262     global $post;
    263     $img = get_post_meta($post->ID, 'qr_image_url', true);
    264    
    265     echo '<div id="meta_inner" style="text-align: center;">';
     272    global $post;
     273    $img = get_post_meta($post->ID, 'qr_image_url', true);
     274   
     275    echo '<div id="meta_inner" style="text-align: center;">';
    266276   
    267277    if($post->post_status == "publish") {
     
    276286            $count = 0;
    277287        }
    278         echo '<br /><br />This QR has redirected <strong>'.$count.'</strong> times';
     288        echo '<br /><br />This QR has redirected <strong><span id="qr_count_value">'.$count.'</span></strong> times';
     289       
     290        //create a button to clear count
     291        echo '<br /><br />';
     292        echo '<div class="button" id="clear_count_button">Clear Count</div>';
     293       
     294       
    279295    }
    280296    else {
     
    283299    echo '</div>';
    284300}
     301
     302//add the javascript to make an AJAX call to the qr_clear_count function
     303function qr_clear_count_javascript() {
     304    global $post_type;
     305   
     306    if( 'qrcode' == $post_type ) {
     307        global $post;
     308       
     309        ?>
     310        <script type="text/javascript" >
     311        jQuery("#clear_count_button").click(function($) {
     312            var data = {
     313                'action': 'qr_clear_count',
     314                'post_id': <?php echo $post->ID; ?>
     315            };
     316   
     317            if (confirm("Are you sure you want to clear the redirect count?") == true) {
     318                jQuery.post(ajaxurl, data, function(response) {
     319                    jQuery("#qr_count_value").text("0");
     320                });
     321            }
     322        });
     323        </script> <?php
     324    }
     325}
     326add_action( 'admin_footer', 'qr_clear_count_javascript' ); //insert the javascript
     327add_action( 'wp_ajax_qr_clear_count', 'qr_clear_count' ); //connect the AJAX call to the PHP function
    285328
    286329//when the post is saved, save our custom postmeta too
  • qr-redirector/trunk/readme.txt

    r2778447 r2782077  
    1111== Description ==
    1212
    13 QR Redirector lets you set up your own QR Code redirection site.  The plugin creates a new custom post type called QR Redirect, which generates a QR code
    14 that points to the post's permalink.  You may then specify any URL you like for the post to redirect to.  Useful if you have an offsite contest, form, newsletter
    15 sign-up, etc. You can even change the URL you're redirecting to without having to worry about updating the QR code in your advertising media.
     13QR Redirector lets you set up your own QR Code redirection site.  The plugin creates a new custom post type called QR Redirect, which generates a QR code that points to the post's permalink.  You may then specify any URL you like for the post to redirect to.  Useful if you have an offsite contest, form, newsletter sign-up, etc. You can even change the URL you're redirecting to without having to worry about updating the QR code in your advertising media.
    1614
    17 This allows you to continuously reuse your QR codes on printed or linked marketing material... you can change the destination you're sending your users to
    18 without ever having to change the artwork you're using to promote it.
     15This allows you to continuously reuse your QR codes on printed or linked marketing material... you can change the destination you're sending your users to without ever having to change the artwork you're using to promote it.
    1916
    20 This plugin is the second incarnation of the QR Code Redirect plugin.  It was developed to be self contained after the Google Chart API deprecated its QR Code
    21 generation service.  Instead of relying on a third party service to generate the QR code, this plugin uses the PHPQRCode library by Dominik Dzienia, and stores
    22 the QR image on your website.
     17This plugin is the second incarnation of the QR Code Redirect plugin.  It was developed to be self contained after the Google Chart API deprecated its QR Code generation service.  Instead of relying on a third party service to generate the QR code, this plugin uses the PHPQRCode library by Dominik Dzienia, and stores the QR image on your website.
    2318
    2419== Installation ==
     
    4035= If I need to change the URL I want to redirect to, do I have to update the QR Code image in all of my ads? =
    4136
    42 No.  The QR Code points to a Wordpress permalink on your site.  The only time you would ever have to switch out an image is if you change your site's permalink
    43 settings, and thus change the permalinks of the QR Redirect posts.  Presumably this is something you won't be doing too often, if ever.
     37No.  The QR Code points to a Wordpress permalink on your site.  The only time you would ever have to switch out an image is if you change your site's permalink settings, and thus change the permalinks of the QR Redirect posts.  Presumably this is something you won't be doing too often, if ever.
    4438
    4539= What happens if I change the size or error correction level? =
    4640
    47 A new image with the appropriate settings will be generated and the original image will be removed from your site.  Any shortcodes in use on your site will be
    48 automatically updated.  Printed versions of the old image will still function, but if you were hotlinking the original image somewhere outside of your website
    49 you will need to update it there.  If you have previously uploaded an old image to another site, rather than hotlinking, it will still function.
     41A new image with the appropriate settings will be generated and the original image will be removed from your site.  Any shortcodes in use on your site will be automatically updated.  Printed versions of the old image will still function, but if you were hotlinking the original image somewhere outside of your website you will need to update it there.  If you have previously uploaded an old image to another site, rather than hotlinking, it will still function.
    5042
    5143= Why do I need this? =
    5244
    53 QR Codes on their own are static.  In order to update them, you have to generate a whole new image (which would suck if you were putting them on flyers or some
    54 other printed medium and suddenly needed to change them).  This plugin lets you point your QR code's embeded URL to a different web address if you need to. 
     45QR Codes on their own are static.  In order to update them, you have to generate a whole new image (which would suck if you were putting them on flyers or some other printed medium and suddenly needed to change them).  This plugin lets you point your QR code's embeded URL to a different web address from the WordPress backend rather than changing your marketing artwork. 
    5546
    56 For example, if you are using an off-site service to host a contest, you can point a QR code at that site for the duration of the contest and later change it to
    57 point to another page with the contest winners.
     47For example, if you are using an off-site service to host a contest, you can point a QR code at that site for the duration of the contest and later change it to point to another page with the contest winners.
    5848
    5949= How are your QR Codes generated? =
    6050
    61 Using the PHPQRCode library by Dominik Dzienia.  This is a PHP implementation of QR Code 2-D barcode generator. It is a pure-php LGPL-licensed implementation based
    62 on C libqrencode by Kentaro Fukuchi.
     51Using the PHPQRCode library by Dominik Dzienia.  This is a PHP implementation of QR Code 2-D barcode generator. It is a pure-php LGPL-licensed implementation based on C libqrencode by Kentaro Fukuchi.
    6352
    6453For more information, see: http://phpqrcode.sourceforge.net/
     
    6655= Why did you turn this into a new plugin instead of just updating the old QR Code Redirect plugin? =
    6756
    68 Largely because of the new way in which the QR codes are generated.  Users would have had to resave all of their old QR Redirect posts in order to generate the
    69 new images.  This didn't seem very user friendly to me.
     57Largely because of the new way in which the QR codes are generated.  Users would have had to re-save all of their old QR Redirect posts in order to generate the new images.  This didn't seem very user friendly to me.
    7058
    71 Additionally, not everyone may want to host QR images on their own site.  The old plugin will continue to function until Google removes the QR functionality from
    72 its Charts API.  I decided that this would be a good way to give people the option of hosting the images themselves, or letting Google do it for them.
     59Additionally, not everyone may want to host QR images on their own site.  The old plugin will continue to function until Google removes the QR functionality from its Charts API.  I decided that this would be a good way to give people the option of hosting the images themselves, or letting Google do it for them.
     60
     61= I'm getting a "Page not found" error when I scan my QR Code.  What's wrong? =
     62
     63This sometimes happens when first installing the plugin, and occasionally if you have deactivated it and re-activated it.  This issue can be fixed by going to Settings > Permalinks, and clicking the save button to let WordPress know it needs to update its link structure.
    7364
    7465== Screenshots ==
     
    7768
    7869== Changelog ==
     70
     71= 1.6.3 =
     72* fixed conflict with the Quick Edit script and non-qrcode Quick Edit links in the WordPress dashboard
     73* added the ability to clear the redirect count for a QR code from the edit page
    7974
    8075= 1.6.2 =
Note: See TracChangeset for help on using the changeset viewer.