'', // user can specify a separate URL ), $atts)); // declare and specify the variables // if a separate url is not specified, the url is the content of the shortcode enclosed in [qr] [/qr] if (empty($url)){$url = $content;} // not sure what this does exactly, either. it obviously has something to do with the language pack(s) $theqrcode = new qrgenerator(); // calls the main function that will return an Android Market QR code if (strlen ($url) > 4){ return $theqrcode->create_qr_code($url);} } // if the current wordpress version supports shortcodes, register the shortcode: // the name of the shortcode used in wordpress, and the name of the function that handles it if ( !function_exists('add_shortcode') ) return; add_shortcode('qr', 'qr_creator'); // "init" is the name of the WordPress action we want this plug-in to hook onto, and it // runs after WordPress has finished loading - but before any headers are sent. // the second value should be the name of the function we want to add, i.e. our own main plug-in function, but // I had to create a function based on the class in order for it to work. add_action( 'init', create_function( '', 'global $QRc; $QRc = new qrgenerator();' ) ); // a lot of settings bullshit (had a terrible time coding it since the WordPress documentation for it sucked: // it was just a complete mess of different and sometimes downright incorrect instructions // if the user has the proper rights if ( is_admin() ){ // add options menu in WordPress, and call the function that registers the settings add_action('admin_menu', 'qr_plugin_menu'); // add an options page and register settings function qr_plugin_menu() { add_options_page('Android Market QR Codes Options', 'Android Market QR Codes', 'manage_options', 'android-qr-codes', 'qr_plugin_options'); register_setting( 'qr-code-options', 'qrcalign' ); register_setting( 'qr-code-options', 'qrcsize' ); register_setting( 'qr-code-options', 'qrcborderc' ); register_setting( 'qr-code-options', 'qrctitle' ); register_setting( 'qr-code-options', 'qrcandroidimg' ); register_setting( 'qr-code-options', 'qrcshowmarketinfo' ); register_setting( 'qr-code-options', 'qrcappboxcss' ); register_setting( 'qr-code-options', 'qrcappratingcss' ); // add the various options to WordPress mySQL database // had this part right in the beginning of create_qr_code in qrgenerator.php earlier, but then // the default settings would only be shown in the config screen if the plugin already had been used once add_option("qrcalign", 'right'); add_option("qrcsize", '130x130'); add_option("qrcborderc", '1px solid #ededed;'); add_option("qrctitle", 'Scan or click to download'); add_option("qrcandroidimg", ''); add_option("qrcshowmarketinfo", 'yes'); add_option("qrcappboxcss", 'padding:7px; margin:10px; border:1px dotted #cccccc; text-align:right; font-size:12px; font-weight: bold;'); add_option("qrcappratingcss", 'float:left;font-size:12px;font-weight:bold;'); } // the function that shows the actual settings function qr_plugin_options() { if (!current_user_can('manage_options')) { wp_die( __('You do not have sufficient permissions to access this page.') ); } // we don't want PHP now unless we need to ?>