'; } //function to write a link to the meta widget function pmcWriteMetaLink() { //get the settings from the database $pmcTwitterID = get_option('pmcTwitterID'); //build the link echo '
  • Twitter RSS
  • '; } //function to add admin menu function pmcTwitterMenu() { add_options_page('Twitter RSS Options', 'Twitter RSS Options', 8, 'twitterrsspage', 'pmcTwitterOptions'); } //function to display admin form function pmcTwitterOptions() { echo '
    '; echo '

    Add Twitter RSS

    '; echo '

    Find My Twitter ID

    '; echo '
    '; echo ''; echo '
    '; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
    '; echo ''; echo '
    '; echo '
    '; echo '

    Settings

    '; echo '
    '; wp_nonce_field('update-options'); echo ''; echo ''; echo '
    '; echo ''; echo ''; echo ''; echo '
    '; echo ''; echo ''; echo ''; echo '
    '; echo ''; echo ''; echo ''; } else { echo '/>'; } echo '
    '; echo ''; echo '
    '; echo ''; echo ''; echo '
    '; echo '

    Settings

    '; echo '

    '; echo 'RSS Icon Text: What a visitor will see when they click your RSS Icon in their browsers address bar. Automatically preceeded by "Subscribe to".'; echo '

    '; echo 'Your Twitter ID: Twitter uses a numeric ID for each user. If you know your Twitter ID, type it in here, otherwise use the "Find My Twitter ID" utility above.'; echo '

    '; echo '
    '; } //function to check if we should process the form function pmcCheckProcess() { //check the $_POST variable if (array_key_exists('process-form', $_POST)) { //save the Twitter Screen Name if (get_option('pmcTwitterScreen') != '') { update_option('pmcTwitterScreen', $_POST['pmcTwitterScreen']); } else { add_option('pmcTwitterScreen', $_POST['pmcTwitterScreen']); } //get Twitter ID pmcGetTwitterID(); } } //function to get Twitter ID from Twitter username function pmcGetTwitterID() { //require class_http.php require_once(dirname(__FILE__).'/class_http.php'); //create a new connection $pmcTwitterConn = new http(); //get the Twitter username from post variable $pmcTwitterUser = get_option('pmcTwitterScreen'); //set the url to the Twitter API $pmcTwitterAPI = 'http://twitter.com/users/show/' . $pmcTwitterUser . '.xml'; //make sure that we can connect, if not display an error message if (!$pmcTwitterConn->fetch($pmcTwitterAPI, "0", "twitter")) { echo "

    There is a problem with the http request!

    "; echo $pmcTwitterConn->log; exit(); } //if we have connected, then get the data. //as this is xml data, we are lookig for the ID key and it's value. $pmcTwitterData=$pmcTwitterConn->body; preg_match ('/(.*)<\/id>/', $pmcTwitterData, $matches); //update the options database with the Twitter ID //remove the HTML tags from the returned key $pmcTrimID = trim($matches[0], ""); //update the database with the ID if (get_option('pmcTwitterID') != '') { update_option('pmcTwitterID', $pmcTrimID); } else{ add_option('pmcTwitterID', $pmcTrimID); } } //when the plugin is loaded, we run the init function add_action("plugins_loaded", "pmcAddTwitterRSS_init"); ?>