'', // 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'); // ad 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' ); } // 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 ?>