Skip to content

Commit

Permalink
Working prototype.
Browse files Browse the repository at this point in the history
  • Loading branch information
KSym04 committed Mar 24, 2019
1 parent 4226e42 commit d8abd63
Show file tree
Hide file tree
Showing 433 changed files with 11,162 additions and 18 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
node*
vendor*
60 changes: 58 additions & 2 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
.cqcw-block {
display: inline-block;
position: relative;
}

.cqcw-block--address {
display: inline-block;
.cqcw-block__button,
.cqcw-block__button:hover,
.cqcw-block__button:focus {
outline: none;
}

.cqcw-block__button:focus {
color: #000000;
}

.cqcw-block__label {
font-weight: 600;
}

.cqcw-block__dialog.active {
display: block;
}

.cqcw-block__dialog {
display: none;
position: absolute;
bottom: 0;
left: 100%;
width: 230px;
background-color: #ffffff;
margin: 0 0 0 1em;
padding: 0;
border: 1px solid #e5e5e5;
box-shadow: 3px 3px 3px rgba( 0, 0, 0, 0.05 );
}

.cqcw-block__dialog img {
width: 100%;
}

.cqcw-block__dialog-heading {
display: block;
padding-top: 20px;
line-height: 1;
font-size: 18px;
font-style: normal;
text-transform: uppercase;
text-align: center;
}

.cqcw-block__dialog-content {
display: block;
width: 100%;
background-color: #e5e5e5;
margin: 0;
padding: 10px 10px;
line-height: 1.4;
color: #444444;
font-size: 12px;
font-style: normal;
font-weight: 400;
text-align: center;
}
16 changes: 16 additions & 0 deletions assets/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
jQuery(document).ready(function(){
jQuery('.cqcw-block__button').on('click',function(e){
e.preventDefault();
// reset all active state.
var cqcwActiveBlockDOM = jQuery(document);
cqcwActiveBlockDOM.find('.cqcw-block.active').toggleClass('active');
cqcwActiveBlockDOM.find('.cqcw-block__button.active').toggleClass('active');
cqcwActiveBlockDOM.find('.cqcw-block__dialog.active').toggleClass('active');

// initialize clicked on element.
var cqcwDialogID = jQuery(this).attr('href');
jQuery(this).toggleClass('active');
jQuery(this).parent('.cqcw-block').toggleClass('active');
jQuery(cqcwDialogID).toggleClass('active');
});
});
19 changes: 15 additions & 4 deletions crypto-qr-code-wp.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,35 @@ public function initialize() {
'dir' => plugin_dir_url( __FILE__ )
);

// Global Defines.
define( 'CRYPTO_QR_CODE_WP_UPLOADS', trailingslashit( WP_CONTENT_DIR ) );
define( 'CRYPTO_QR_CODE_WP_URL', trailingslashit( WP_CONTENT_URL ) );

// Resources.
add_action( 'init', array( $this, 'mesterz_calculator_register_bootstrap' ) );
add_action( 'init', array( $this, 'register_assets' ) );

// Libraries.
include( 'includes/shortcode.php' );
include( 'includes/widgets.php' );

// Vendor.
include( 'includes/vendor/phpqrcode/qrlib.php' );
}

/*
* mesterz_calculator_register_bootstrap
* register_assets
*
* @type function
* @date 03/24/19
* @since 1.0.0
*/
function mesterz_calculator_register_bootstrap() {
wp_register_script( 'crypto-qr-code-wp', plugin_dir_url( __FILE__ ) . 'assets/js/script.js', array( 'jquery' ), $this->settings['version'] );
function register_assets() {
wp_register_script( 'crypto-qr-code-wp', plugin_dir_url( __FILE__ ) . 'assets/js/script.js', array( 'jquery' ), $this->settings['version'] );
wp_register_style( 'crypto-qr-code-wp', plugin_dir_url( __FILE__ ) . 'assets/css/style.css', array(), $this->settings['version'] );

// Call assets.
wp_enqueue_script( 'crypto-qr-code-wp' );
wp_enqueue_style( 'crypto-qr-code-wp' );
}
}

Expand Down
30 changes: 20 additions & 10 deletions includes/shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,37 @@
function crypto_qr_code_wp_shortcode_logic( $atts ) {
// Parse shortcode attributes.
$a = shortcode_atts( array(
'label' => '',
'heading' => esc_html__( 'Donate', 'crypto-qr-code-wp' ),
'label' => '',
'address' => ''
), $atts );

if( empty( $a['label'] ) && empty( $a['address'] ) ) {
if( empty( $a['address'] ) || empty( $a['label'] ) ) {
return;
}

// Set variables.
$content = NULL;
settype( $content, 'string' );

// Build template.
$content .= '<span class="cqcw-block">
<label class="cqcw-block--label">'. $a['label'] .'</label>:
<a href="#'. $a['label'] .'_'. $a['address'] .'" title="'. $a['label'] .' - '. $a['address'] .'" class="cqcw-block--button">'. $a['address'] .'</a>
</span>';
$heading = $a['heading'];
$label = $a['label'];
$address = $a['address'];

// Generate QR address.
$qr_svgCode_generate = QRcode::svg( $address, CRYPTO_QR_CODE_WP_UPLOADS . 'uploads/crypto-qr-codes/' . $address . '.svg' );
$qr_svgCode_url = CRYPTO_QR_CODE_WP_URL . 'uploads/crypto-qr-codes/' . $address . '.svg';

// Call assets.
wp_enqueue_script( 'crypto-qr-code-wp' );
wp_enqueue_style( 'crypto-qr-code-wp' );
// Build template.
$content .= "<span class=\"cqcw-block\">
<label class=\"cqcw-block__label\">{$label}:</label>
<a href=\"#{$label}_{$address}\" class=\"cqcw-block__button\">{$address}</a>
<em id=\"{$label}_{$address}\" class=\"cqcw-block__dialog\">
<strong class=\"cqcw-block__dialog-heading\">{$heading}</strong>
<img src=\"{$qr_svgCode_url}\" alt=\"{$address}\" />
<strong class=\"cqcw-block__dialog-content\">{$address}</strong>
</em>
</span>";

return $content;
}
Expand Down
2 changes: 2 additions & 0 deletions includes/vendor/phpqrcode/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
temp/*.png
38 changes: 38 additions & 0 deletions includes/vendor/phpqrcode/CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
* 1.0.0 build 2010031920

- first public release
- help in readme, install
- cleanup ans separation of QRtools and QRspec
- now TCPDF binding requires minimal changes in TCPDF, having most of job
done in QRtools tcpdfBarcodeArray
- nicer QRtools::timeBenchmark output
- license and copyright notices in files
- indent cleanup - from tab to 4spc, keep it that way please :)
- sf project, repository, wiki
- simple code generator in index.php

* 1.1.0 build 2010032113

- added merge tool wich generate merged version of code
located in phpqrcode.php
- splited qrconst.php from qrlib.php

* 1.1.1 build 2010032405

- patch by Rick Seymour allowing saving PNG and displaying it at the same time
- added version info in VERSION file
- modified merge tool to include version info into generated file
- fixed e-mail in almost all head comments

* 1.1.2 build 2010032722

- full integration with TCPDF thanks to Nicola Asuni, it's author
- fixed bug with alphanumeric encoding detection

* 1.1.3 build 2010081807

- short opening tags replaced with standard ones

* 1.1.4 build 2010100721

- added missing static keyword QRinput::check (found by Luke Brookhart, Onjax LLC)
67 changes: 67 additions & 0 deletions includes/vendor/phpqrcode/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
== REQUIREMENTS ==

* PHP5
* PHP GD2 extension with JPEG and PNG support

== INSTALLATION ==

If you want to recreate cache by yourself make sure cache directory is
writable and you have permisions to write into it. Also make sure you are
able to read files in it if you have cache option enabled

== CONFIGURATION ==

Feel free to modify config constants in qrconfig.php file. Read about it in
provided comments and project wiki page (links in README file)

== QUICK START ==

Notice: probably you should'nt use all of this in same script :)

<?php

//include only that one, rest required files will be included from it
include "qrlib.php"

//write code into file, Error corection lecer is lowest, L (one form: L,M,Q,H)
//each code square will be 4x4 pixels (4x zoom)
//code will have 2 code squares white boundary around

QRcode::png('PHP QR Code :)', 'test.png', 'L', 4, 2);

//same as above but outputs file directly into browser (with appr. header etc.)
//all other settings are default
//WARNING! it should be FIRST and ONLY output generated by script, otherwise
//rest of output will land inside PNG binary, breaking it for sure
QRcode::png('PHP QR Code :)');

//show benchmark
QRtools::timeBenchmark();

//rebuild cache
QRtools::buildCache();

//code generated in text mode - as a binary table
//then displayed out as HTML using Unicode block building chars :)
$tab = $qr->encode('PHP QR Code :)');
QRspec::debug($tab, true);

== TCPDF INTEGRATION ==

Inside bindings/tcpdf you will find slightly modified 2dbarcodes.php.
Instal phpqrcode liblaty inside tcpdf folder, then overwrite (or merge)
2dbarcodes.php

Then use similar as example #50 from TCPDF examples:

<?php

$style = array(
'border' => true,
'padding' => 4,
'fgcolor' => array(0,0,0),
'bgcolor' => false, //array(255,255,255)
);

//code name: QR, specify error correction level after semicolon (L,M,Q,H)
$pdf->write2DBarcode('PHP QR Code :)', 'QR,L', '', '', 30, 30, $style, 'N');
Loading

0 comments on commit d8abd63

Please sign in to comment.