Plugin Directory

Changeset 139035


Ignore:
Timestamp:
07/25/2009 03:12:26 AM (17 years ago)
Author:
plpetitclerc
Message:
 
Location:
wp-prettyphoto/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-prettyphoto/trunk/readme.txt

    r139032 r139035  
    4747* Reimplemented Localizations
    4848* Added French localization
     49* Removed mobile detection
    4950
    5051= Version 1.4 =
  • wp-prettyphoto/trunk/wp-prettyphoto.php

    r139032 r139035  
    3131    $this->_buildOptions();
    3232    $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) {
    3535        // jQuery - removing to make sure we're using 1.3.2
    3636        wp_deregister_script('jquery');
     
    4444      wp_enqueue_style('prettyphoto', $wpurl.'/css/prettyPhoto.css', false, '2.4');
    4545    }
    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    }
    4754    add_action('wp_head', array(&$this, 'wppp_styles'));
    4855    if ($this->_doOutput()) {
     
    7582
    7683  /**
     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  /**
    7797   * Produces options output
    7898   * @author Pier-Luc Petitclerc <pL@fusi0n.org>
     
    83103  */
    84104  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;
    107108    }
    108109    return false;
     
    174175  */
    175176  public function wppp_settings($v, $k) {
    176     if ($v['name'] == 'Theme') { $v['values'] = $this->_getThemes(); }
    177177    if (isSet($v['values'])) {
    178178      $e = '';
     
    211211    $fileTypes        = $this->_getFileTypes(array('type'=>'all','context'=>true));
    212212    $pattern          = array();
    213     $rel              = $this->_getOpt('rel');
     213    $rel              = $this->wppp_rel;
    214214    $pattern[]        = "/<a(.*?)href=('|\")([A-Za-z0-9\/_\.\~\:-]*?)($fileTypes)('|\")(.*?)>/i";
    215215    $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'; }
    218218    return preg_replace_callback($pattern, array(&$this,'_regexCallback'), $content);
    219219  }
     
    231231  private function _regexCallback($matches) {
    232232    global $post;
    233     $rel            = $this->_getOpt('rel');
     233    $rel            = $this->wppp_rel;
    234234    $pattern        = array();
    235235    $replacement    = array();
     
    239239    $replacement[]  = '<a$1href=$2$3$4$5$6$7>';
    240240
    241     if ($this->_getOpt('automate_yt')) {
     241    if ($this->wppp_automate_yt) {
    242242      $pattern[]    = '/<a(.*?)href=(\'|")(http:\/\/www\.youtube\.com\/watch\?v=[A-Za-z0-9]*)(\'|")(.*?)>/i';
    243243      $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";
     
    245245      $replacement[]= '<a$1href=$2$3$4$5$6$7>';
    246246    }
    247     if ($this->_getOpt('automate_ext')) {
     247    if ($this->wppp_automate_ext) {
    248248      $pattern[]    = '/<a(.*?)href=(\'|")(.*iframe=true.*)(\'|")(.*?)>/i';
    249249      $pattern[]    = "/<a(.*?)href=('|\")(.*iframe=true.*)(.*?)(rel=('|\")".$rel."(.*?)('|\"))([ \t\r\n\v\f]*?)((rel=('|\")".$rel."(.*?)('|\"))?)([ \t\r\n\v\f]?)([^\>]*?)>/i";
     
    267267    switch ($opts['type']) {
    268268      case 'mov':
    269         return $opts['context']? $this->_getOpt('automate_mov')? '\.mov' : false : '\.mov';
     269        return $opts['context']? $this->wppp_automate_mov? '\.mov' : false : '\.mov';
    270270      break;
    271271      case 'swf':
    272         return $opts['context']? $this->_getOpt('automate_swf')? '\.swf' : false : '\.swf';
     272        return $opts['context']? $this->wppp_automate_swf? '\.swf' : false : '\.swf';
    273273      break;
    274274      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';
    276276      break;
    277277      case 'all':
     
    312312  }
    313313
     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  */
    314322  private function wppp_get_option($k) {
    315323    $v = get_option($k);
    316     return ($v === false)? $this->opts[$k]['default'] : $v;
    317   }
     324    return (!$v)? $this->opts[$k]['default'] : $v;
     325  }
     326
    318327  /**
    319328   * Builds Options Array
     
    426435    return $themes;
    427436  }
    428 
    429   /**
    430    * Detects if user is using a known mobile browser
    431    * @param null
    432    * @return bool True if user is using a mobile browser, false if he is not
    433    * @author Andy Moore <andy@andymoore.info>
    434    * @author Pier-Luc Petitclerc <pL@fusi0n.org>
    435    * @link http://detectmobilebrowsers.mobi
    436    * @since 1.1
    437    * @access private
    438   */
    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   }
    452437}
    453438
Note: See TracChangeset for help on using the changeset viewer.