Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Inline QRCodes
- Version: 1.0
- Author: Ozh
- Author URI: http://ozh.org/
- */
- yourls_add_filter( 'share_box_data', 'inline_qr_data' );
- function inline_qr_data( $data ) {
- // Generate a real QR code for $data['shorturl']
- $data['shortlink_title'] = '<div id="qrcode">QR for '.$data['shorturl'].'</div>' . $data['shortlink_title'] ;
- return $data;
- }
- yourls_add_filter( 'add_new_link', 'inline_qr_add_url' );
- function inline_qr_add_url( $data ) {
- $shorturl = $data['shorturl'];
- $data['html'] .= "<script>inline_qr_code( '$shorturl' );</script>";
- return $data;
- }
- yourls_add_action( 'html_head', 'inline_qr_js' );
- function inline_qr_js() {
- echo <<<JS
- <style>
- #copybox { width: 300px; }
- #qrcode { float:right;width:50px;height:50px;margin-top:30px;background:red; font-size:8px; }
- </style>
- <script>
- function inline_qr_code( url ) {
- url = ( url == null ? $( '#origlink' ).attr('href') : url );
- // This function would fetch an actual QR code :
- $('#qrcode').html('QR Code for '+url);
- }
- $(document).ready(function(){
- // Share button behavior
- $('.button_share').click(function(){
- inline_qr_code();
- });
- // Tab behavior on stats page
- $('a[href=#stat_tab_share]').click(function(){
- inline_qr_code();
- });
- inline_qr_code();
- });
- </script>
- JS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement