Plugin Directory

Changeset 1489651


Ignore:
Timestamp:
09/04/2016 07:44:05 AM (10 years ago)
Author:
mhallmann
Message:

Version 0.5

Location:
sepa-girocode
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • sepa-girocode/trunk/readme.txt

    r1484707 r1489651  
    2222Just use the shortcode [girocode] in any page or post you want to display a girocode.
    2323
     24= And how to show the girocode generator form? =
     25
     26Just use the shortcode [girocode-generator].
     27
    2428= Which parameters are available? =
    2529
     30For [girocode]:
    2631* iban: International Bank Account Number of the beneficiary
    2732* bic: Bank Identifier Code, facultative for participants of the European Economic Area
     
    3540* dimension: Width (and also height) of the code in pixels (standard = 150)
    3641* divclass: Optional CSS-class for wrapping div-element
     42
     43For [girocode-generator]:
     44There are currently now parameters available.
    3745
    3846= Come on, show me an example ... =
     
    50581. Some example Girocodes
    5159
     602. Girocode generator form
     61
    5262== Changelog ==
     63= 0.5 (2016-09-04)  =
     64* Added girocode-generator form
     65
    5366= 0.4.4 (2016-08-27)  =
    5467* Fixed transient lifetime
  • sepa-girocode/trunk/sepa-girocode.php

    r1484703 r1489651  
    99Plugin URI:  http://www.halli-online.de/sepa-girocode/
    1010Description: Create EPC-Codes (in Germany known as Girocode) for money transfer | Girocode-Barcode für SEPA-Überweisungen erstellen
    11 Version:     0.4.4
     11Version:     0.5
    1212Author:      Michael Hallmann
    1313Author URI:  http://www.halli-online.de/
     
    4545    $this->data['dimension'] = 150;
    4646    $this->data['frame'] = 1;
    47     $this->data['divclass'] = "";
     47    $this->data['divclass'] = "";  // deprecated
     48    $this->data['style'] = '';
     49    $this->data['class'] = '';
     50    $this->data['alt'] = '';
     51    $this->data['title'] = '';
    4852
    4953}
     
    225229}
    226230
    227 public function getQrDiv() {
     231public function getQrImgTag() {
    228232    $key = $this->getTransientKey();
    229233    $img_src = "index.php?sepa-girocode=show-code&key=" . $key;
    230234    $click_url = "index.php?sepa-girocode=get-codefile&key=" . $key;
    231235    $width_height = $this->dimension;
    232     $output = "";
    233     $a = "";
    234     $ae = "";
     236   
    235237   
    236238    if ($this->isclickable == 1) {
    237         $a = "<a href='$click_url' target='_blank'>";
    238         $ae = "</a>";
    239     }
    240    
    241    
    242     if (strlen($this->divclass) == 0) {
    243         $output .= "<div>";
     239        $a = "<a href=\"$click_url\" target=\"_blank\">";
     240        $ae = "</a>";
    244241    } else {
    245         $output .= "<div class='" . $this->divclass . "'>";
    246     }
    247    
    248     $output .= "$a<img src='$img_src' width='$width_height' height='$width_height'></img>$ae</div>";
     242        $a = "";
     243        $ae = "";
     244    }
     245   
     246    $output = "<img src=\"$img_src\" width=\"$width_height\" height=\"$width_height\"";
     247   
     248    if (strlen($this->class) > 0) {
     249        $output .= " class=\"" . $this->class . "\"";
     250    }
     251   
     252    if (strlen($this->title) > 0) {
     253        $output .= " title=\"" . $this->title . "\"";
     254    }
     255   
     256    if (strlen($this->alt) > 0) {
     257        $output .= " alt=\"" . $this->alt . "\"";
     258    }
     259   
     260    if (strlen($this->style) > 0) {
     261        $output .= " style=\"" . $this->style . "\"";
     262    }
     263
     264    $output = $a . $output . "/>" . $ae;
    249265
    250266    return $output;
     
    267283}
    268284
    269    
     285function sepa_girocode_update() {
     286    global $wpdb;
     287    // delete all transients
     288    $result = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name LIKE '_transient_sgc_%'");
     289    foreach ($result as $transient) {
     290        delete_transient(trim(substr($transient->option_name, 11, 999)));
     291    }
     292}
    270293   
    271294   
     
    291314    }
    292315
    293     return $sgc->getQrDiv();
     316    return $sgc->getQrImgTag();
    294317}   
    295318
     
    336359
    337360
     361// Generator
     362function sepa_girocode_shortcode_generator( $atts ) {
     363   
     364    $output = "";
     365   
     366    if ( isset( $_POST['gcf-submitted'] ) ) {
     367       
     368        $sgc = new sepa_girocode_class();
     369        $sgc->beneficiary = sanitize_text_field( $_POST["gcf-beneficiary"] );
     370        $sgc->iban = sanitize_text_field( $_POST["gcf-iban"] );
     371        $sgc->bic = sanitize_text_field( $_POST["gcf-bic"] );
     372        $sgc->amount = sanitize_text_field( $_POST["gcf-amount"] );
     373        $sgc->purpose = sanitize_text_field( $_POST["gcf-purpose"] );
     374        $sgc->purposecode = sanitize_text_field( $_POST["gcf-purposecode"] );
     375        $sgc->isclickable = 0;
     376        $sgc->dimension = 300;
     377
     378        // $to = get_option( 'admin_email' );
     379
     380        $key =  $sgc->getTransientKey();
     381
     382        if ( false === ( $value = get_transient($key) ) ) {
     383            $tmp = set_transient($key,
     384                          $sgc,
     385                          HOUR_IN_SECONDS);
     386            if (!$tmp) die ("Konnte Transient nicht setzen! KEY = " . $key);
     387        }
     388
     389        $output .= '<div style="float:right;width=300px;"><p>' . $sgc->getQrImgTag() . '</p></div>';
     390       
     391       
     392    }
     393   
     394   
     395   
     396    //$sgc = new sepa_girocode_class();
     397       
     398    $output .=  '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post">';
     399   
     400    $output .=  '<p>';
     401    $output .=  'Zahlungsempfänger*<br />';
     402    $output .=  '<input type="text" name="gcf-beneficiary" title="nur Buchstaben, Zahlen, Leerzeichen und die Zeichen :?,-(+.)/ sind erlaubt, max. 70 Zeichen" minlength="2" maxlenth="70" pattern="[a-zA-Z0-9 :?,-(+.)/]+" value="' . ( isset( $_POST["gcf-beneficiary"] ) ? esc_attr( $_POST["gcf-beneficiary"] ) : 'Deutsches Rotes Kreuz' ) . '" size="40" required />';
     403    $output .=  '</p>';
     404   
     405    $output .=  '<p>';
     406    $output .=  'IBAN* <br />';
     407    $output .=  '<input type="text" name="gcf-iban" minlength="15" maxlength="31" title="nur Buchstaben und Zahlen erlaubt" pattern="[a-zA-Z0-9]+" value="' . ( isset( $_POST["gcf-iban"] ) ? esc_attr( $_POST["gcf-iban"] ) : 'DE63370205000005023307' ) . '" size="40" required/>';
     408    $output .=  '</p>';
     409   
     410    $output .=  '<p>';
     411    $output .=  'BIC* <br />';
     412    $output .=  '<input type="text" name="gcf-bic" minlength="8" maxlength="11" title="nur Buchstaben und Zahlen erlaubt, min. 8, max. 11 Stellen" pattern="[a-zA-Z0-9]+" value="' . ( isset( $_POST["gcf-bic"] ) ? esc_attr( $_POST["gcf-bic"] ) : 'BFSWDE33XXX' ) . '" size="40" required />';
     413    $output .=  '</p>';
     414
     415    $output .=  '<p>';
     416    $output .=  'Betrag in EUR* <br />';
     417    $output .=  '<input type="number" name="gcf-amount" min="0" max="999999999" step="1" value="' . ( isset( $_POST["gcf-amount"] ) ? esc_attr( $_POST["gcf-amount"] ) : '20' ) . '" size="40" />';
     418    $output .=  '</p>';
     419   
     420    $output .=  '<p>';
     421    $output .=  'Verwendungszweck*<br />';
     422    $output .=  '<input type="text" name="gcf-purpose" title="nur Buchstaben, Zahlen, Leerzeichen und die Zeichen :?,-(+.)/ sind erlaubt, max. 140 Zeichen" maxlength="140" pattern="[a-zA-Z0-9 :?,-(+.)/]+" value="' . ( isset( $_POST["gcf-purpose"] ) ? esc_attr( $_POST["gcf-purpose"] ) : 'Spende' ) . '" size="40" required />';
     423    $output .=  '</p>';
     424   
     425    $output .=  '<p>';
     426    $output .=  'Purpose-Code*<br />';
     427    $output .=  '<fieldset>';
     428    $output .=  '<input type="radio" name="gcf-purposecode" id = "standard" value = "" ' . ( ! isset($_POST["gcf-purposecode"]) || $_POST["gcf-purposecode"]  == ""  ?  'checked' : '' ) . ' size="40" />';
     429    $output .=  '<label for="standard">Standard</label>';
     430    $output .=  '</br>';
     431    $output .=  '<input type="radio" name="gcf-purposecode" id = "char" value = "CHAR" ' . ( isset($_POST["gcf-purposecode"]) && $_POST["gcf-purposecode"]  == "CHAR"  ?  'checked' : '' ) . ' size="40" />';
     432    $output .=  '<label for="char">Spende (CHAR)</label>';
     433    $output .=  '</fieldset>';
     434    $output .=  '</p>';
     435   
     436   
     437   
     438   
     439    $output .=  '<p><input type="submit" name="gcf-submitted" value="Girocode generieren"/></p>';
     440    $output .=  '</form>';
     441
     442    return $output;
     443}   
     444
     445
     446
     447
     448
    338449register_activation_hook( __FILE__, 'sepa_girocode_activate' );
    339450register_deactivation_hook( __FILE__, 'sepa_girocode_deactivate' );
    340451
     452
    341453add_shortcode( 'girocode', 'sepa_girocode_shortcode' );
     454add_shortcode( 'girocode-generator', 'sepa_girocode_shortcode_generator' );
     455
     456
    342457add_action('parse_request', 'sepa_girocode_parse_request');
    343458add_filter('query_vars', 'sepa_girocode_query_vars');
    344459
     460add_action( 'upgrader_process_complete', 'sepa_girocode_upgrade');
     461
     462
    345463?>
Note: See TracChangeset for help on using the changeset viewer.