Changeset 403109
- Timestamp:
- 07/01/2011 06:20:43 AM (15 years ago)
- File:
-
- 1 edited
-
wp-s3/trunk/s3.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-s3/trunk/s3.php
r402696 r403109 6 6 Description: This plugin helps the users to view your blog in a pda and iPhone browser. 7 7 Author: Imthiaz Rafiq 8 Version: 1. 08 Version: 1.1 Alpha 9 9 Author URI: http://imthi.com/ 10 10 */ 11 12 error_reporting(E_ALL);13 ini_set('display_errors', true);14 11 15 12 class S3Plugin { … … 18 15 var $s3CacheFolder; 19 16 var $siteURL; 20 21 17 var $isCloudFrontURLEnabled; 22 23 18 var $s3AccessKey; 24 19 var $s3SecretKey; … … 77 72 $this->s3UseCloudFrontURL = (bool) get_option('s3plugin_use_cloudfrontURL', 0); 78 73 $this->s3CloudFrontURL = untrailingslashit(get_option('s3plugin_cloudfrontURL')); 79 80 if ($this->s3UseCloudFrontURL && !empty ($this->s3UseCloudFrontURL)){74 75 if ($this->s3UseCloudFrontURL && !empty($this->s3UseCloudFrontURL)) { 81 76 $this->isCloudFrontURLEnabled = TRUE; 82 } else{77 } else { 83 78 $this->isCloudFrontURLEnabled = FALSE; 84 79 } 85 86 80 81 87 82 $this->cronScheduleTime = get_option('s3plugin_cron_interval', 300); 88 83 $this->cronUploadLimit = get_option('s3plugin_cron_limit', 20); … … 98 93 'deactivatePlugin')); 99 94 add_action('admin_menu', array(&$this, 's3AdminMenu')); 95 add_filter('script_loader_src', array(&$this, 'script_loader_src')); 96 100 97 if (isset($_GET ['page']) && $_GET ['page'] == 's3plugin-options') { 101 98 ob_start(); … … 122 119 } 123 120 121 function script_loader_src($scriptURL) { 122 if (!is_admin()) { 123 $urlParts = parse_url($scriptURL); 124 $justURL = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path']; 125 $fileCDNURL = self::getCDNURL($justURL); 126 if ($fileCDNURL !== FALSE) { 127 if (isset($urlParts['query']) && !empty($urlParts['query'])) { 128 return $fileCDNURL . '?' . $urlParts['query']; 129 } 130 return $fileCDNURL; 131 } 132 } 133 return $scriptURL; 134 } 135 124 136 function s3AdminMenu() { 125 137 if (function_exists('add_submenu_page')) { … … 149 161 } 150 162 update_option('s3plugin_cloudfrontURL', $_POST ['s3plugin_cloudfrontURL']); 151 163 152 164 if ($this->checkS3AccessAndBucket($_POST ['s3plugin_amazon_key_id'], $_POST ['s3plugin_amazon_secret_key'], $useSSL, $_POST ['s3plugin_amazon_bucket_name']) === FALSE) { 153 165 $s3PuginMessage = 'Connection failed. Plugin not active.'; … … 264 276 $fileContents = file_get_contents($cacheFilePath); 265 277 if ($fileContents == 'done') { 266 if ($instance->isCloudFrontURLEnabled){267 return $instance->s3CloudFrontURL . '/'.$relativePath;268 } else{278 if ($instance->isCloudFrontURLEnabled) { 279 return $instance->s3CloudFrontURL . '/' . $relativePath; 280 } else { 269 281 return "http://{$instance->s3BucketName}.s3.amazonaws.com/" . $relativePath; 270 282 } … … 355 367 $wp_s3 = S3Plugin::getInstance(); 356 368 369 function jsDebug($var='') { 370 print "<script type='text/javascript'>\n"; 371 print "console.log('{$var}');\n"; 372 print "</script>\n"; 373 } 374 357 375 function cmVarDebug($var, $echo = true) { 358 376 $dump = "<div style=\"border:1px solid #f00;font-family:arial;font-size:12px;font-weight:normal;background:#f0f0f0;text-align:left;padding:3px;\"><pre>" . print_r($var, true) . "</pre></div>";
Note: See TracChangeset
for help on using the changeset viewer.