WordPress.org

Plugin Directory

Changeset 409877


Ignore:
Timestamp:
07/14/11 20:08:10 (3 years ago)
Author:
MrWiblog
Message:

Version 1.4:
Fixed bug with vouchers that require an email address
Added optional displaying of voucher descriptions in shortcodes
Style changes

Location:
voucherpress/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • voucherpress/trunk/readme.txt

    r392883 r409877  
    44Tags: buddypress, voucher, vouchers, pdf, print, download, offer, code, special, coupon, ticket, token,  
    55Requires at least: 2.8 
    6 Tested up to: 3.0.3 
    7 Stable tag: 1.3 
     6Tested up to: 3.2.1 
     7Stable tag: 1.4 
    88 
    99VoucherPress is a Wordpress plugin that allows you to give downloadable, printable vouchers/tickets/coupons/tokens in PDF format away on your site. 
     
    7373The "id" parameter is the unique ID of the voucher. The correct ID to use is available in the screen where you edit the voucher. 
    7474 
     75You can also how the description after the link: 
     76 
     77[voucher id="123" description="true"] 
     78 
    7579The second shows a link to a voucher, but with a preview of the voucher (just the background image, no text) and the voucher name as the image alternate text: 
    7680 
    7781[voucher id="123" preview="true"] 
    7882 
     83And you can show the description after the preview as well: 
     84 
     85[voucher id="123" preview="true" description="true"] 
     86 
    7987You can also show an unordered list of all your live vouchers using this shortcode: 
    8088 
    8189[voucherlist] 
     90 
     91And a list of all live vouchers with their descriptions: 
     92 
     93[voucherlist description="true"] 
    8294 
    8395And you can also show the form for people to enter their name and email address if they wish to register for a restricted voucher: 
     
    124136== Changelog == 
    125137 
     138= 1.4 (2011/07/14) = 
     139 
     140Fixed bug with vouchers that require an email address 
     141Added optional displaying of voucher descriptions in shortcodes 
     142Style changes 
     143 
    126144= 1.3 (2011/06/03) = 
    127145 
  • voucherpress/trunk/voucherpress.php

    r392883 r409877  
    33 * @package VoucherPress 
    44 * @author Chris Taylor 
    5  * @version 1.3 
     5 * @version 1.4 
    66 */ 
    77/* 
     
    1010Description: VoucherPress allows you to offer downloadable, printable vouchers from your Wordpress site. Vouchers can be available to anyone, or require a name and email address before they can be downloaded. 
    1111Author: Chris Taylor 
    12 Version: 1.3 
     12Version: 1.4 
    1313Author URI: http://www.stillbreathing.co.uk/ 
    1414*/ 
     
    1616// set the current version 
    1717function voucherpress_current_version() { 
    18     return "1.3"; 
     18    return "1.4"; 
    1919} 
    2020 
     
    5555        } 
    5656        // setup shortcodes 
    57         if ( !is_admin() ) { 
    58             //add_filter('widget_text', 'voucher_do_voucher_shortcode', 11); 
    59             //add_filter('widget_text', 'voucher_do_voucher_form_shortcode', 11); 
    60             //add_filter('widget_text', 'voucher_do_list_shortcode', 11); 
    61         } 
    6257        // [voucher id="" preview=""] 
    6358        add_shortcode( 'voucher', 'voucher_do_voucher_shortcode' ); 
     
    538533        } 
    539534        echo ' 
    540         <p><a href="' . wp_nonce_url( "admin.php?page=vouchers&amp;download=emails", "voucherpress_download_csv" ) . '">' . __( "Download all registered email addresses", "voucherpress" ) . '</a></p> 
     535        <p><a href="' . wp_nonce_url( "admin.php?page=vouchers&amp;download=emails", "voucherpress_download_csv" ) . '" class="button">' . __( "Download all registered email addresses", "voucherpress" ) . '</a></p> 
    541536        </div>'; 
    542537     
     
    719714        if ( $voucher->downloads > 0 ) { 
    720715            echo __( "Downloads:", "voucherpress" ) . " " . $voucher->downloads; 
    721             echo ' | <a href="' . wp_nonce_url( "admin.php?page=vouchers&amp;download=emails&amp;voucher=" . $voucher->id, "voucherpress_download_csv" ) . '">' . __( "CSV", "voucherpress" ) . '</a>'; 
     716            echo ' | <a href="' . wp_nonce_url( "admin.php?page=vouchers&amp;download=emails&amp;voucher=" . $voucher->id, "voucherpress_download_csv" ) . '" class="button">' . __( "CSV", "voucherpress" ) . '</a>'; 
    722717            echo ' | '; 
    723718        } 
    724719         
    725         echo '<a href="#" id="showshortcodes">Shortcodes</a></span></h2> 
     720        echo '<a href="#" id="showshortcodes" class="button">Shortcodes</a></span></h2> 
    726721         
    727722        <div class="hider" id="shortcodes"> 
    728723         
    729         <h3>' . __( "Shortcode for this voucher:", "voucherpress" ) . ' <input type="text" value="[voucher id=&quot;' . $voucher->id . '&quot;]" /> = <a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( stripslashes( $voucher->name ) ) . '</a></h3> 
     724        <h3>' . __( "Shortcode for this voucher:", "voucherpress" ) . ' <input type="text" value="[voucher id=&quot;' . $voucher->id . '&quot;]" /></h3> 
     725        <p><a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( stripslashes( $voucher->name ) ) . '</a></p> 
     726         
     727        <h3>' . __( "Shortcode for this voucher with description:", "voucherpress" ) . ' <input type="text" value="[voucher id=&quot;' . $voucher->id . '&quot; description=&quot;true&quot;]" /></h3> 
     728        <p><a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( stripslashes( $voucher->name ) ) . '</a> ' . htmlspecialchars( stripslashes( $voucher->description ) ) . '</p> 
    730729         
    731730        '; 
     
    734733        { 
    735734        echo ' 
    736         <h3>' . __( "Shortcode for this voucher registration form:", "voucherpress" ) . ' <input type="text" value="[voucherform id=&quot;' . $voucher->id . '&quot;]" /></h3> 
     735        <h3>' . __( "Shortcode for this voucher registration form:", "voucherpress" ) . '</h3> 
     736        <p><input type="text" value="[voucherform id=&quot;' . $voucher->id . '&quot;]" /></p> 
    737737        '; 
    738738        } 
     
    740740        echo ' 
    741741         
    742         <h3>' . __( "Shortcode for this voucher:", "voucherpress" ) . ' <input type="text" value="[voucher id=&quot;' . $voucher->id . '&quot; preview=&quot;true&quot;]" /> = <a href="' . voucherpress_link( $voucher->guid ) . '"><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( stripslashes( $voucher->name ) ) . '" /></a></h3> 
    743          
    744         <h3>' . __( "Link for this voucher:", "voucherpress" ) . ' <input type="text" value="' . voucherpress_link( $voucher->guid ) . '" /></h3> 
     742        <h3>' . __( "Thumbnail for this voucher:", "voucherpress" ) . ' <input type="text" value="[voucher id=&quot;' . $voucher->id . '&quot; preview=&quot;true&quot;]" /></h3> 
     743        <p><a href="' . voucherpress_link( $voucher->guid ) . '"><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( stripslashes( $voucher->name ) ) . '" /></a></p> 
     744         
     745        <h3>' . __( "Thumbnail for this voucher with description:", "voucherpress" ) . ' <input type="text" value="[voucher id=&quot;' . $voucher->id . '&quot; preview=&quot;true&quot; description=&quot;true&quot;]" /></h3> 
     746        <p><a href="' . voucherpress_link( $voucher->guid ) . '"><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( stripslashes( $voucher->name ) ) . '" /></a><br />' . htmlspecialchars( stripslashes( $voucher->description ) ) . '</p> 
     747         
     748        <h3>' . __( "Link for this voucher:", "voucherpress" ) . '</h3> 
     749        <p><input type="text" value="' . voucherpress_link( $voucher->guid ) . '" /></p> 
    745750         
    746751        </div> 
     
    14241429    extract( shortcode_atts( array(  
    14251430        'id' => '', 
    1426         'preview' => '' 
     1431        'preview' => '', 
     1432        'description' => 'false' 
    14271433    ), $atts ) ); 
    14281434    if ( $id != "" ) { 
     
    14301436        if ( $voucher && ( ( $voucher->expiry == "" || (int)$voucher->expiry == 0 || (int)$voucher->expiry > time() ) ) && ( $voucher->startdate == "" || (int)$voucher->startdate == 0 || (int)$voucher->startdate < time() ) ) { 
    14311437            if ( $preview == 'true' ) { 
    1432                 return '<a href="' . voucherpress_link( $voucher->guid ) . '"><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( $voucher->name ) . '" /></a>'; 
     1438                $r = '<a href="' . voucherpress_link( $voucher->guid ) . '"><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( $voucher->name ) . '" /></a>'; 
    14331439            } else { 
    1434                 return '<a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( $voucher->name ) . '</a>'; 
     1440                $r = '<a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( $voucher->name ) . '</a>'; 
    14351441            } 
     1442            if ( strtolower( $description ) == "true" ) { 
     1443                $r .= ' ' . $voucher->description; 
     1444            } 
     1445            return $r; 
    14361446        } else { 
    14371447            $r = "<!-- The shortcode for voucher " . $id . " is displaying nothing because the voucher was not found, or the expiry date has passed, or the start date is still in the future"; 
     
    14651475 
    14661476// process a shortcode for a list of vouchers 
    1467 function voucher_do_list_shortcode() { 
     1477function voucher_do_list_shortcode( $atts ) { 
     1478    extract( shortcode_atts( array(  
     1479        'description' => 'false' 
     1480    ), $atts ) ); 
    14681481     
    14691482    $vouchers = voucherpress_get_vouchers(); 
     
    14741487        foreach( $vouchers as $voucher ) { 
    14751488         
    1476             $r .= '<li><a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( $voucher->name ) . '</a></li>'; 
     1489            $r .= '<li><a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( $voucher->name ) . '</a>'; 
     1490            if ( strtolower( $description ) == "true" ) { 
     1491                $r .= "<br />" . $voucher->description; 
     1492            } 
     1493            $r .= '</li>'; 
    14771494         
    14781495        } 
     
    18801897    if ( isset( $wpdb->base_prefix ) ) { $prefix = $wpdb->base_prefix; } 
    18811898    $sql = "select b.domain, b.path, v.id, v.name, v.`text`, v.terms, v.require_email, v.`limit`, v.live, v.startdate, v.expiry, v.guid,  
    1882 (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id) as downloads 
     1899(select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id and d.downloaded > 0) as downloads 
    18831900from " . $prefix . "voucherpress_vouchers v 
    18841901inner join " . $wpdb->base_prefix . "blogs b on b.blog_id = v.blog_id 
     
    19011918    if ( isset( $wpdb->base_prefix ) ) { $prefix = $wpdb->base_prefix; } 
    19021919    $sql = $wpdb->prepare( "select v.id, v.name, v.`text`, v.`description`, v.terms, v.require_email, v.`limit`, v.live, v.startdate, v.expiry, v.guid,  
    1903 (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id) as downloads 
     1920(select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id and d.downloaded > 0) as downloads 
    19041921from " . $prefix . "voucherpress_vouchers v 
    19051922where (%s = '1' or v.live = 1) 
     
    19281945group by b.domain, b.path, v.id, v.name, v.`text`, v.terms, v.require_email, v.`limit`, v.live, v.expiry, v.guid 
    19291946where v.deleted = 0 
     1947and d.downloaded > 0 
    19301948order by count(d.id) desc 
    19311949" . $limit . ";"; 
     
    19471965where v.blog_id = %d 
    19481966and v.deleted = 0 
     1967and d.downloaded > 0 
    19491968group by v.id, v.name, v.`text`, v.terms, v.require_email, v.`limit`, v.live, v.expiry, v.guid 
    19501969order by count(d.id) desc 
     
    19661985        $sql = $wpdb->prepare( "select v.id, v.name, v.`text`, v.`description`, v.terms, v.font, v.template, v.require_email, v.`limit`, v.startdate, v.expiry, v.guid, v.live, '' as registered_email, '' as registered_name, 
    19671986        v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes, 
    1968         (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id) as downloads 
     1987        (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id and d.downloaded > 0) as downloads 
    19691988        from " . $prefix . "voucherpress_vouchers v 
    19701989        where  
     
    19832002            $sql = $wpdb->prepare( "select v.id, v.name, v.`text`, v.`description`, v.terms, v.font, v.template, v.require_email, v.`limit`, v.startdate, v.expiry, v.guid, v.live, r.email as registered_email, r.name as registered_name, 
    19842003            v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes, 
    1985             (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id) as downloads 
     2004            (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id and d.downloaded > 0) as downloads 
    19862005            from " . $prefix . "voucherpress_vouchers v 
    19872006            left outer join " . $prefix . "voucherpress_downloads r on r.voucherid = v.id and r.guid = %s 
     
    19972016            $sql = $wpdb->prepare( "select v.id, v.name, v.`text`, v.`description`, v.terms, v.font, v.template, v.require_email, v.`limit`, v.startdate, v.expiry, v.guid, v.live, '' as registered_email, '' as registered_name, 
    19982017            v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes, 
    1999             (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id) as downloads 
     2018            (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id and d.downloaded > 0) as downloads 
    20002019            from " . $prefix . "voucherpress_vouchers v 
    20012020            where  
     
    20242043    if ( isset( $wpdb->base_prefix ) ) { $prefix = $wpdb->base_prefix; } 
    20252044    $sql = $wpdb->prepare( "select v.id, v.`limit`, 
    2026     (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id) as downloads 
     2045    (select count(d.id) from " . $prefix . "voucherpress_downloads d where d.voucherid = v.id and d.downloaded > 0) as downloads 
    20272046    from " . $prefix . "voucherpress_vouchers v 
    20282047    where  
     
    24312450            // a limit has been set 
    24322451            if ( (int)$row->limit != 0 ) { 
    2433                 $sql = $wpdb->prepare( "select count(id) from " . $prefix . "voucherpress_downloads where voucherid = %d", $row->id ); 
     2452                $sql = $wpdb->prepare( "select count(id) from " . $prefix . "voucherpress_downloads where voucherid = %d and downloaded > 0", $row->id ); 
    24342453                $downloads = $wpdb->get_var( $sql ); 
    24352454                // if the limit has been reached 
     
    25212540    if ( isset( $wpdb->base_prefix ) ) { $prefix = $wpdb->base_prefix; } 
    25222541    // get the codes type for this voucher 
    2523     $sql = $wpdb->prepare( "select v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes, count(d.id) as downloads from " . $prefix . "voucherpress_vouchers v left outer join " . $prefix . "voucherpress_downloads d on d.voucherid = v.id where v.id = %d and v.deleted = 0 group by v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes;", $voucherid ); 
     2542    $sql = $wpdb->prepare( "select v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes, count(d.id) as downloads from " . $prefix . "voucherpress_vouchers v left outer join " . $prefix . "voucherpress_downloads d on d.voucherid = v.id and d.downloaded > 0 where v.id = %d and v.deleted = 0 group by v.codestype, v.codeprefix, v.codesuffix, v.codelength, v.codes;", $voucherid ); 
    25242543    $voucher_codestype = $wpdb->get_row( $sql ); 
    25252544    // using custom codes 
Note: See TracChangeset for help on using the changeset viewer.