Changeset 139035
- Timestamp:
- 07/25/2009 03:12:26 AM (17 years ago)
- Location:
- wp-prettyphoto/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
wp-prettyphoto.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-prettyphoto/trunk/readme.txt
r139032 r139035 47 47 * Reimplemented Localizations 48 48 * Added French localization 49 * Removed mobile detection 49 50 50 51 = Version 1.4 = -
wp-prettyphoto/trunk/wp-prettyphoto.php
r139032 r139035 31 31 $this->_buildOptions(); 32 32 $wpurl = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__), '', plugin_basename(__FILE__)); 33 if (!is_admin() && !$this->is_mobile()) {34 if ($this-> _getOpt('jsreplace')== 1) {33 if (!is_admin()) { 34 if ($this->wppp_jsreplace == 1) { 35 35 // jQuery - removing to make sure we're using 1.3.2 36 36 wp_deregister_script('jquery'); … … 44 44 wp_enqueue_style('prettyphoto', $wpurl.'/css/prettyPhoto.css', false, '2.4'); 45 45 } 46 if (is_admin()) { add_action('admin_init', array(&$this, 'wppp_section_register')); } 46 else { 47 $currentLocale = get_locale(); 48 if (!empty($currentLocale)) { 49 $moFile = dirname(__FILE__).'/lang/wp-prettyphoto-'.$currentLocale.'.mo'; 50 if (@file_exists($moFile) && is_readable($moFile)) { load_plugin_textdomain('wp-prettyphoto', $moFile); } 51 } 52 add_action('admin_init', array(&$this, 'wppp_section_register')); 53 } 47 54 add_action('wp_head', array(&$this, 'wppp_styles')); 48 55 if ($this->_doOutput()) { … … 75 82 76 83 /** 84 * Overloading hack/shortcut to retrieve option value 85 * @param string $name Option Name (Key in the array without wppp_ prefix) 86 * @return array Option data 87 * @access public 88 * @author Pier-Luc Petitclerc <pL@fusi0n.org> 89 * @since 1.4.1 90 */ 91 public function __get($name) { 92 $name = (substr($name,0,5) == 'wppp_')? $name : 'wppp_'.$name; 93 return $this->wppp_get_option($name); 94 } 95 96 /** 77 97 * Produces options output 78 98 * @author Pier-Luc Petitclerc <pL@fusi0n.org> … … 83 103 */ 84 104 private function _doOutput() { 85 if (!$this->is_mobile()) { 86 $a = array('automate_all', 'automate_img', 'automate_swf', 'automate_mov', 'automate_yt', 'automate_ext'); 87 foreach ($a as $i) { 88 if ($this->_getOpt($i) == 1) return true; 89 } 90 } 91 return false; 92 } 93 94 /** 95 * Fetches options data 96 * @param string $optName Option Name (Key in the array without wppp_ prefix) 97 * @param string $key Key name of the option item to return 98 * @return array Option data 99 * @access public 100 * @author Pier-Luc Petitclerc <pL@fusi0n.org> 101 * @since 1.4 102 */ 103 private function _getOpt($optName, $key='current') { 104 $optName = (substr($optName,0,5) == 'wppp_')? $optName : 'wppp_'.$optName; 105 if (array_key_exists($optName, $this->opts)) { 106 return (array_key_exists($key, $this->opts[$optName]))? $this->opts[$optName][$key] : $this->opts[$optName]; 105 $a = array('wppp_automate_all', 'wppp_automate_img', 'wppp_automate_swf', 'wppp_automate_mov', 'wppp_automate_yt', 'wppp_automate_ext'); 106 foreach ($a as $i) { 107 if ($this->$i == 1) return true; 107 108 } 108 109 return false; … … 174 175 */ 175 176 public function wppp_settings($v, $k) { 176 if ($v['name'] == 'Theme') { $v['values'] = $this->_getThemes(); }177 177 if (isSet($v['values'])) { 178 178 $e = ''; … … 211 211 $fileTypes = $this->_getFileTypes(array('type'=>'all','context'=>true)); 212 212 $pattern = array(); 213 $rel = $this-> _getOpt('rel');213 $rel = $this->wppp_rel; 214 214 $pattern[] = "/<a(.*?)href=('|\")([A-Za-z0-9\/_\.\~\:-]*?)($fileTypes)('|\")(.*?)>/i"; 215 215 $pattern[] = "/<a(.*?)href=('|\")([A-Za-z0-9\/_\.\~\:-]*?)($fileTypes)('|\")(.*?)(rel=('|\")".$rel."(.*?)('|\"))([ \t\r\n\v\f]*?)((rel=('|\")".$rel."(.*?)('|\"))?)([ \t\r\n\v\f]?)([^\>]*?)>/i"; 216 if ($this-> _getOpt('automate_yt')) { $pattern[] = '/<a(.*?)href=(\'|")(http:\/\/www\.youtube\.com\/watch\?v=[A-Za-z0-9]*)(\'|")(.*?)>/i'; }217 if ($this-> _getOpt('automate_ext')) { $pattern[] = '/<a(.*?)href=(\'|")(.*iframe=true.*)(\'|")(.*?)>/i'; }216 if ($this->wppp_automate_yt) { $pattern[] = '/<a(.*?)href=(\'|")(http:\/\/www\.youtube\.com\/watch\?v=[A-Za-z0-9]*)(\'|")(.*?)>/i'; } 217 if ($this->wppp_automate_ext) { $pattern[] = '/<a(.*?)href=(\'|")(.*iframe=true.*)(\'|")(.*?)>/i'; } 218 218 return preg_replace_callback($pattern, array(&$this,'_regexCallback'), $content); 219 219 } … … 231 231 private function _regexCallback($matches) { 232 232 global $post; 233 $rel = $this-> _getOpt('rel');233 $rel = $this->wppp_rel; 234 234 $pattern = array(); 235 235 $replacement = array(); … … 239 239 $replacement[] = '<a$1href=$2$3$4$5$6$7>'; 240 240 241 if ($this-> _getOpt('automate_yt')) {241 if ($this->wppp_automate_yt) { 242 242 $pattern[] = '/<a(.*?)href=(\'|")(http:\/\/www\.youtube\.com\/watch\?v=[A-Za-z0-9]*)(\'|")(.*?)>/i'; 243 243 $pattern[] = "/<a(.*?)href=('|\")(http:\/\/www\.youtube\.com\/watch\?v=[A-Za-z0-9]*)('|\")(.*?)(rel=('|\")".$rel."(.*?)('|\"))([ \t\r\n\v\f]*?)((rel=('|\")".$rel."(.*?)('|\"))?)([ \t\r\n\v\f]?)([^\>]*?)>/i"; … … 245 245 $replacement[]= '<a$1href=$2$3$4$5$6$7>'; 246 246 } 247 if ($this-> _getOpt('automate_ext')) {247 if ($this->wppp_automate_ext) { 248 248 $pattern[] = '/<a(.*?)href=(\'|")(.*iframe=true.*)(\'|")(.*?)>/i'; 249 249 $pattern[] = "/<a(.*?)href=('|\")(.*iframe=true.*)(.*?)(rel=('|\")".$rel."(.*?)('|\"))([ \t\r\n\v\f]*?)((rel=('|\")".$rel."(.*?)('|\"))?)([ \t\r\n\v\f]?)([^\>]*?)>/i"; … … 267 267 switch ($opts['type']) { 268 268 case 'mov': 269 return $opts['context']? $this-> _getOpt('automate_mov')? '\.mov' : false : '\.mov';269 return $opts['context']? $this->wppp_automate_mov? '\.mov' : false : '\.mov'; 270 270 break; 271 271 case 'swf': 272 return $opts['context']? $this-> _getOpt('automate_swf')? '\.swf' : false : '\.swf';272 return $opts['context']? $this->wppp_automate_swf? '\.swf' : false : '\.swf'; 273 273 break; 274 274 case 'img': 275 return $opts['context']? $this-> _getOpt('automate_img')? '\.bmp|\.gif|\.jpg|\.jpeg|\.png' : false : '\.bmp|\.gif|\.jpg|\.jpeg|\.png';275 return $opts['context']? $this->wppp_automate_img? '\.bmp|\.gif|\.jpg|\.jpeg|\.png' : false : '\.bmp|\.gif|\.jpg|\.jpeg|\.png'; 276 276 break; 277 277 case 'all': … … 312 312 } 313 313 314 /** 315 * Shortcut/hack to return option value or option default if value is not set 316 * @param string $k Option Name 317 * @return mixed Option Value 318 * @access private 319 * @since 1.4.1 320 * @author Pier-Luc Petitclerc <pL@fusi0n.org> 321 */ 314 322 private function wppp_get_option($k) { 315 323 $v = get_option($k); 316 return ($v === false)? $this->opts[$k]['default'] : $v; 317 } 324 return (!$v)? $this->opts[$k]['default'] : $v; 325 } 326 318 327 /** 319 328 * Builds Options Array … … 426 435 return $themes; 427 436 } 428 429 /**430 * Detects if user is using a known mobile browser431 * @param null432 * @return bool True if user is using a mobile browser, false if he is not433 * @author Andy Moore <andy@andymoore.info>434 * @author Pier-Luc Petitclerc <pL@fusi0n.org>435 * @link http://detectmobilebrowsers.mobi436 * @since 1.1437 * @access private438 */439 private function is_mobile() {440 $ua = $_SERVER['HTTP_USER_AGENT'];441 $a = $_SERVER['HTTP_ACCEPT'];442 $b = array(array('ipod', 'iphone', 'android', 'opera mini', 'blackberry'),443 array('palm os', 'palm', 'hiptop', 'avantgo', 'plucker', 'xiino', 'blazer', 'elaine',444 'windows ce; ppc;', 'windows ce; smartphone;', 'windows ce; iemobile',445 'up.browser', 'up.link', 'mmp', 'symbian', 'smartphone', 'midp', 'wap', 'vodafone', 'o2', 'pocket', 'kindle', 'mobile', 'pda', 'psp', 'treo'));446 $r = array('('.implode($b['0'], ')|(').')',447 '/('.implode($b['1'], '|').')/i');448 return (eregi($r['0'], $ua) || preg_match($r['1'], $ua) ||449 ((strpos($a,'text/vnd.wap.wml')>0) || (strpos($a,'application/vnd.wap.xhtml+xml')>0)) ||450 isset($_SERVER['HTTP_X_WAP_PROFILE']) || isset($_SERVER['HTTP_PROFILE']))? true : false;451 }452 437 } 453 438
Note: See TracChangeset
for help on using the changeset viewer.