. */ // PLEASE NOTE: This plugin requires the use of the php curl library. // Please ensure you have this installed require_once dirname( __FILE__ ) . '/includeTwitter.php'; require_once dirname( __FILE__ ) . '/../../../wp-config.php'; require_once dirname( __FILE__ ) . '/twitterScript.php'; function startTwitterWidget() { if ( function_exists( 'register_sidebar_widget' ) ) { function widget_twitterblog( $args ) { $before_widget = ''; $before_title = ''; $after_title = ''; $after_widget = ''; if ( is_array( $args ) ) { if ( array_key_exists( 'before_widget', $args ) ) { $before_widget = $args['before_widget']; } if ( array_key_exists( 'before_title', $args ) ) { $before_title = $args['before_title']; } if ( array_key_exists( 'after_title', $args ) ) { $after_title = $args['after_title']; } if (array_key_exists( 'after_widget', $args ) ) { $after_widget = $args['after_widget']; } echo $before_widget; echo $before_title. 'Twitter Blog' . $after_title; displayTwitterPlugin(); echo $after_widget; } } register_sidebar_widget( 'Twitter Blog', 'widget_twitterblog' ); } } function displayTwitterPlugin($bolShowAllTweets = false) { $strUserIdsValue = get_option( TWITTER_USER_IDS ); $strIsShow = get_option( TWITTER_SHOW_STATUS ); $strShowLogo = get_option( TWITTER_SHOW_LOGO ); $strShowAtUsername = get_option( TWITTER_SHOW_AT_USERNAME ); $intAllTweetsPageId = (int) get_option( TWITTER_PAGE_ID ); $intLimitNumber = (int) get_option( TWITTER_RESTRICT_TWEETS ); // start: retrieve user data $arrUserData = get_option( TWITTER_USER_DATA ); // end: retrieve user data $arrNames = explode( ',', $strUserIdsValue ); $arrIsShow = explode( ',', $strIsShow ); if ( is_array( $arrUserData ) ) { // start: display header echo '
'; $intUserDataCount = count( $arrUserData ); $intRunCount = 0; $intShowCount = count( $arrIsShow ); $intIndexCount = 0; /***** Revised Section ********/ for ( $intIndex = 0; $intIndex < $intUserDataCount; $intIndex++ ) { if ( null == $arrUserData[$intIndex]['tweet'] ) { $intRunCount++; } if ( 'unchecked' == $arrIsShow[$intIndex] ) { $intIndexCount++; } $arrUserData[$intIndex]['show'] = $arrIsShow[$intIndex]; } /***** ****** ********/ if ( ( $intUserDataCount != $intRunCount ) && ( $intShowCount != $intIndexCount ) ) { echo ' '; } echo '
'; // end: display header // start: put into order by date function compareDates( $a, $b ) { return ( $a['date'] > $b['date'] ) ? -1 : 1; } usort( $arrUserData, 'compareDates' ); // end: put into order by date // start: display individual blogs if ( ( '' == $intLimitNumber ) || ( true == $bolShowAllTweets ) ) { $intLimitNumber = count( $arrUserData ); } $intCount = 0; foreach ( $arrUserData as $strElement ) { if ( ( null != $strElement['tweet'] ) && ( 'checked' == $strElement['show'] ) ) { if ( preg_match( TWITTER_USERNAME_REGEX, $strElement['name'] ) && ( preg_match( TWITTER_SOURCE_PATTERN_C, $strElement['avatar'] ) || preg_match( TWITTER_SOURCE_PATTERN_A, $strElement['avatar'] ) || preg_match( TWITTER_SOURCE_PATTERN_B, $strElement['avatar'] ) ) ) { echo '
avatar picture
"'. make_clickable( $strElement['tweet'] ) .'"
' . $strElement['name'] .'

'; if ( 0 != $strElement['date'] ) { echo '--- '.strftime( "%a %d %b %Y %R", $strElement['date'] ).' ---'; } else { echo 'Date not found'; } echo '
'; } } if ( $intCount == $intLimitNumber ) { break; } $intCount++; } // end: display individual blogs if ( !is_page( $strUrl ) ) { if ( null != $intAllTweetsPageId ) { $strUrl = get_permalink( $intAllTweetsPageId ); echo '
View All Tweets
'; } } // start: display "Created By" footer if ( 'checked' == $strShowLogo ) { echo '
Created by Plusnet
'; } // end: display "Created By" footer echo '
'; } } add_action( 'admin_head','includeTwitterCSS' ); add_action( 'wp_head', 'includeTwitterComponents' ); add_action( 'admin_menu', 'twitterAddOptionPage' ); add_action( 'init','startTwitterWidget' ); add_filter( 'the_content', 'processKeyword', '124544774' ); function processKeyword( $strContent ) { $strContent = preg_replace( "/\[twitter\]/ise", "displayTwitterPlugin(true)", $strContent, -1, $intMatches ); if ( $intMatches > 0 ) { $strContent = '' . $strContent; } return $strContent; } function twitterAddOptionPage() { add_submenu_page( 'plugins.php','Twitter Control', 'Twitter Control', 8, __FILE__, 'twitter_options_page' ); } function includeTwitterCSS() { echo ''; } // start: jQuery function to control the expansion and collapsing of the main app window function includeTwitterComponents() { echo ''; if ( is_front_page() ) { echo ''; } } // end: jQuery function to control the expansion and collapsing of the main app window function twitter_options_page() { $strUserIdsForScript = get_option( TWITTER_USER_IDS ); $arrNames = explode( ',', $strUserIdsForScript ); $arrUseNames = array(); $strUserIdsValue = get_option( TWITTER_USER_IDS ); $strIsShow = get_option( TWITTER_SHOW_STATUS ); $strShowLogo = get_option( TWITTER_SHOW_LOGO ); $strShowAtUsername = get_option( TWITTER_SHOW_AT_USERNAME ); $intLimitNumber = (int) get_option( TWITTER_RESTRICT_TWEETS ); $intAllTweetsPageId = (int) get_option( TWITTER_PAGE_ID ); $arrPagesInfo = get_pages(); $arrPageUrls = array(); if ( false == empty( $arrPagesInfo ) ) { foreach( $arrPagesInfo as $element ) { $arrPageIds[] = $element->ID; } } if ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) ) { if ( isset( $_POST['restrictupdate'] ) ) { if ( isset( $_POST['restrictnumber'] ) ) { $intLimitNumber = $_POST['restrictnumber']; update_option( TWITTER_RESTRICT_TWEETS, $intLimitNumber ); echo '

Info updated.

'; } } if ( isset( $_POST['otheroptionsupdate'] ) ) { // start: set to / not to display "@username" blogs if ( $_POST['at'] ) { $strShowAtUsername = 'checked'; } else { $strShowAtUsername = 'unchecked'; } // end: set to / not to display "@username" blogs // start: set to / not to display "created by" footer if ( $_POST['logo'] ) { $strShowLogo = 'checked'; } else { $strShowLogo = 'unchecked'; } // end: set to / not to display "created by" footer update_option( TWITTER_SHOW_LOGO, $strShowLogo ); update_option( TWITTER_SHOW_AT_USERNAME, $strShowAtUsername ); echo '

Info updated.

'; } if ( isset( $_POST['usernameupdate'] ) ) { if ( isset( $_POST[TWITTER_USER_IDS] ) ) { if ( !( empty( $_POST[TWITTER_USER_IDS] ) ) ) { if ( ( empty( $strUserIdsValue ) ) ) { $strUserIdsValue = $_POST[TWITTER_USER_IDS]; $strIsShow = 'checked'; } else { $strUserIdsValue = $strUserIdsValue.','.$_POST[TWITTER_USER_IDS]; $strIsShow = $strIsShow.',checked'; } } $arrRemoveValues = array(); $arrNamesTemp = explode( ',', $strUserIdsValue ); // start: collect the list of users to delete foreach ( $arrNamesTemp as $strElement ) { if ( 'delete' == $_POST['delete-'.$strElement] ) { $arrRemoveValues[] = $strElement; } } // end: collect the list of users to delete $arrResult = array_diff( $arrNamesTemp, $arrRemoveValues ); if ( isset( $_POST['updateshownames'] ) ) { // start: set to / not to display blogs by a specific user $arrShowValues = array(); foreach ( $arrResult as $strElement ) { if ( $strElement == $_POST['checkbox-'.$strElement] ) { $arrShowValues[] = 'checked'; } else { $arrShowValues[] = 'unchecked'; } } // end: set to / not to display blogs by a specific user $strIsShow = implode( ",", $arrShowValues ); } $strUserIdsValue = implode( ",", $arrResult ); // start: Save the posted values in the database update_option( TWITTER_USER_IDS, $strUserIdsValue ); update_option( TWITTER_SHOW_STATUS, $strIsShow ); // end: Save the posted values in the database echo '

Info updated.

'; } } if ( isset( $_POST['url'] ) ) { $intAllTweetsPageId = $_POST['urllist']; if ( -1 == $intAllTweetsPageId ) { $intAllTweetsPageId = null; } update_option( TWITTER_PAGE_ID, $intAllTweetsPageId ); echo '

URL Updated.

'; } if ( isset( $_POST['hidden'] ) ) { $bolScriptHasRun = twitterScriptMain(); if ( true == $bolScriptHasRun ) { echo '

Blogs Updated.

'; } else { echo '

WARNING: Blogs have NOT been Updated.

'; } } } displayTwitterOptionsPage( $strUserIdsValue, $strIsShow, $strShowAtUsername, $strShowLogo, $intLimitNumber, $arrPageIds, $intAllTweetsPageId ); } function displayTwitterOptionsPage( $strUserIdsValue, $strIsShow, $strShowAtUsername, $strShowLogo, $intLimitNumber, $arrPageIds, $intAllTweetsPageId ) { // start: setup default setting for showing the created by footer if ( null == $strShowLogo || '' == $strShowLogo ) { $strShowLogo = "checked"; } // end: setup default setting for showing the created by footer // start: display options on page $arrNames = explode( ',', $strUserIdsValue ); $arrIsShow = explode( ',', $strIsShow ); echo '

Twitter Control

'; if ( '' != $arrNames[0] ) { echo ' '; $intCount = 0; foreach ( $arrNames as $strElement ) { $strElement = htmlentities( $strElement ); if ( '' != $strElement ) { echo ' '; } $intCount++; } echo ' '; } else { echo ' '; } echo '
--- List Of Usernames ---
ShowUsername 
'.$strElement.'


No Active Usernames

New Username

--- Other Options ---
Show Option
"@username" tagged posts
"Created by" text footer


--- Restrict Tweets ---
Restrict Number Of Tweets


All Tweets URL

If you have setup an "All Tweets" page then please select it from the following list so that the main Twitter app can link to the correct page. For information on setting up an "All Tweets" page please see the readme.txt file that accompanies this plugin.




Update Blogs

To populate the cache file with your current registered user\'s blogs, click on the button opposite.

Please note: you will need to perform this task to reflect any changes made on registered user\'s blogs.


This process may take a few minutes to run,
especially if you are collecting a large number of blogs.

'; // end: display options on page } ?>