$addon) { $addon_file = $addon['slug'] . '/' . $addon['slug'] . '.php'; if (file_exists(WP_PLUGIN_DIR . '/' . $addon_file)) { $tb_installed_addons[$addon_id] = true; if(is_plugin_active($addon_file)) { $tb_active_addons[$addon_id] = true; } else { $tb_active_addons[$addon_id] = false; } } else { $tb_installed_addons[$addon_id] = false; } } return false; } function tb_admin_load_scripts() { global $js_labels; wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-core'); wp_enqueue_script('jquery-ui-tabs'); wp_enqueue_script('jquery-fancybox', '/' . PLUGINDIR . '/tweet-blender/js/fancybox/jquery.fancybox-1.3.4.pack.js',array('jquery')); wp_enqueue_script('tb-lib', '/' . PLUGINDIR . '/tweet-blender/js/lib.js',array('jquery')); wp_localize_script('tb-lib', 'TB_labels', $js_labels); wp_enqueue_script('tb-admin', '/' . PLUGINDIR . '/tweet-blender/js/admin.js',array('jquery','jquery-ui-core','jquery-ui-tabs','jquery-fancybox','tb-lib')); } function tb_admin_load_styles() { wp_enqueue_style('tweet-blender-css', '/' . PLUGINDIR .'/tweet-blender/css/admin.css'); wp_enqueue_style('jquery-ui-css', '/' . PLUGINDIR . '/tweet-blender/css/jquery-ui/jquery-ui.css'); wp_enqueue_style('jquery-tabs-css', '/' . PLUGINDIR . '/tweet-blender/css/jquery-ui/ui.tabs.css'); wp_enqueue_style('jquery-fancybox-css', '/' . PLUGINDIR . '/tweet-blender/js/fancybox/jquery.fancybox-1.3.4.css'); } // register admin page add_action('admin_menu', 'tb_admin_menu'); function tb_admin_menu() { global $tb_installed_addons, $tb_active_addons, $tb_addons; // add hooks for Tweet Blender admin $pagehook = add_options_page(__('Tweet Blender Settings'), __('Tweet Blender', 'tweetblender'), 'manage_options', __FILE__, 'tb_admin_page'); add_action( 'admin_print_scripts-' . $pagehook, 'tb_admin_load_scripts' ); add_action( 'admin_print_styles-' . $pagehook, 'tb_admin_load_styles' ); // add hooks for addons tb_check_addons(); foreach($tb_addons as $addon_id => $addon) { $addon_file = $addon['slug'] . '/' . $addon['slug'] . '.php'; if ($tb_installed_addons[$addon_id] && $tb_active_addons[$addon_id]) { include_once(WP_PLUGIN_DIR . '/' . $addon_file); add_action( 'admin_print_scripts-' . $pagehook, 'tb_admin_load_scripts_addon' . $addon_id ); add_action( 'admin_print_styles-' . $pagehook, 'tb_admin_load_styles_addon' . $addon_id ); } } } function tb_admin_page() { global $wp_json, $tb_option_names, $tb_option_names_system, $tb_keep_tweets_options, $tb_languages, $cache_clear_results, $tb_throttle_time_options, $tb_installed_addons, $tb_active_addons, $tb_package_names; $upgrade_message = ''; // if add-on installation is requested, perform it if (isset($_GET['install_addon'])) { // get item number if (isset($_POST['item_number'])) { $item_number = $_POST['item_number']; } elseif (isset($_GET['item_number'])) { $item_number = $_GET['item_number']; } else { echo __('Error','tweetblender') . ': ' . __('addon ID was not specified', 'tweetblender'); } // store transaction ID to prefs for future auto updates if (isset($_POST['txn_id']) && $item_number) { tb_save_txn_id($item_number, $_POST['txn_id']); } // perform installation tb_download_package($item_number); return; } // check for new versions of addons if we haven't checked recently elseif (!get_transient('tb_addon_checked_upgrade')) { foreach($tb_package_names as $item_number => $name) { // if user purchased the addon if ($txn_id = tb_get_txn_id($item_number)) { $version_check_url = 'http://tweetblender.com/check_upgrade.php?item_number=' . $item_number . '&blog_url=' . urlencode(get_bloginfo('url')) . '&txn_id=' . $txn_id; $version_download_url = 'http://tweetblender.com/download.php?item_number=' . $item_number . '&blog_url=' . urlencode(get_bloginfo('url')) . '&txn_id=' . $txn_id; $response = wp_remote_get($version_check_url); if(!is_wp_error($response)) { if (isset($response['headers']['have-newer-version']) && $response['headers']['have-newer-version'] == 1) { $upgrade_message .= sprintf(__('Newer version of %s is available','tweetblender') . ' - ' . __('upgrade automatically','tweetblender') . ' ' . __('or','tweetblender') . ' ' . __('download to install manually','tweetblender') . '', $name, tb_get_current_page_url(), $item_number, $version_download_url); } } } } // don't check again for 24 hours set_transient('tb_addon_checked_upgrade', true, 60*60*24); } // Read in existing option values from database $tb_o = get_option('tweet-blender'); // set defaults if (empty($tb_o) || (isset($tb_o['archive_tweets_num']) && $tb_o['archive_tweets_num'] < 1)) { $tb_o['archive_tweets_num'] = 20; } // get API limit info $api_limit_data = null; if ($json_data = tb_get_server_rate_limit_json($tb_o)) { $api_limit_data = $wp_json->decode($json_data); } // perform maintenance if (isset($tb_o['archive_keep_tweets']) && $tb_o['archive_keep_tweets'] > 0) { tb_db_cache_clear('WHERE DATEDIFF(now(),created_at) > ' . $tb_o['archive_keep_tweets']); } // See if the user has posted us some information if( isset($_POST['tb_new_data']) && $_POST['tb_new_data'] == 'Y' ) { // check nonce check_admin_referer('tweet_blender_settings_save','tb_nonce'); // if we are disabling cache - clear it if (isset($tb_o['advanced_disabled_cache']) && (!$tb_o['advanced_disable_cache'] && $_POST['advanced_disable_cache'])) { tb_db_cache_clear(); } // if we are clearing individual cached sources if (isset($_POST['delete_cache_src']) && $_POST['delete_cache_src']) { $cleared_sources = array(); foreach ($_POST['delete_cache_src'] as $del_src) { tb_db_cache_clear("WHERE source='$del_src'"); $cleared_sources[] = $del_src; } if (sizeof($cleared_sources) > 0 ) { $cache_clear_results = __('Cleared cached tweets for', 'tweetblender') . ' ' . implode(', ',$cleared_sources); } } // check if we are rerouting with oAuth if ((isset($_POST['advanced_reroute_on']) && $_POST['advanced_reroute_on']) && (isset($_POST['advanced_reroute_type']) && $_POST['advanced_reroute_type'] == 'oauth')) { if(!isset($tb_o['oauth_access_token'])) { // Create TwitterOAuth object and get request token $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET); // Get request token $request_token = $connection->getRequestToken(get_bloginfo('url') . '/' . PLUGINDIR . "/tweet-blender/lib/twitteroauth/callback.php"); if ($connection->http_code == 200) { // Save request token to session $tb_o['oauth_token'] = $token = $request_token['oauth_token']; $tb_o['oauth_token_secret'] = $request_token['oauth_token_secret']; update_option('tweet-blender',$tb_o); $errors[] = __('To take advantage of a whitelisted account with oAuth ' , 'tweetblender') . "__('please use your Twitter account to authorize access','tweetblender')."; } else { $errors[] = __("Not able to form oAuth authorization request URL. HTTP status code: ", 'tweetblender') . $connection->http_code; } } } if (isset($errors) && sizeof($errors) > 0) { $message = '
' . __('Settings saved', 'tweetblender') . '. ' . $cache_clear_results . '
'. __('Addon installation was cancelled','tweetblender') . ' ' . __('If you have any questions, please use one of the links under the Help tab', 'tweetblender') . '.
' . $upgrade_message . '
:
one time flat fee of $%s. This will perform a one-click install of a new plugin and you will get FREE upgrades with new features in the future.', 'tweetblender' ),'2.99'); ?>
:
one time flat fee of $%s. This will perform a one-click install of a new plugin and you will get FREE upgrades with new features in the future.', 'tweetblender' ),'8.99'); ?>
prefix . "tweetblender"; $sql = "SELECT source, COUNT(*) AS tweets_num, UNIX_TIMESTAMP(MAX(created_at)) AS last_update FROM " . $table_name . " GROUP BY source"; $results = $wpdb->get_results($sql); return $results; } ?>