WordPress.org

Plugin Directory

Changeset 556724


Ignore:
Timestamp:
06/12/12 15:00:34 (22 months ago)
Author:
jorbin
Message:

better sanatize options

Location:
addthis/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • addthis/trunk/addthis_social_widget.php

    r556268 r556724  
    480480        // we're good 
    481481    } 
     482    else 
    482483    { 
    483484        _e( 'Cheatin’ uh?' ); 
     
    836837    $options['password'] = sanitize_text_field($data['addthis_password']); 
    837838 
     839if ( isset($data['username']) ) 
     840 $options['username'] = sanitize_text_field($data['username']); 
     841 
     842if ( isset($data['profile']) ) 
     843 $options['profile'] = sanitize_text_field($data['profile']); 
     844 
     845if ( isset($data['password']) ) 
     846    $options['password'] = sanitize_text_field($data['password']); 
     847 
     848if ( isset($data['wpfooter'])) 
     849    $options['wpfooter'] = (bool) $data['wpfooter']; 
     850 
     851 
    838852if (! isset($data['above']) ){ 
    839853} 
     
    9891003    if ( ! empty( $options) ){ 
    9901004        if ( isset($options['addthis_showonexcerpts']) &&  $options['addthis_showonexcerpts'] == true ) 
    991             add_filter('get_the_excerpt', 'addthis_display_social_widget_excerpt'); 
     1005            add_filter('get_the_excerpt', 'addthis_display_social_widget_excerpt', 11); 
    9921006         
    9931007        add_filter('the_content', 'addthis_display_social_widget', 15); 
     
    11251139 
    11261140        $text = str_replace(']]>', ']]>', $text); 
    1127         $text = strip_tags($text); 
     1141        
     1142        // 3.3 and earlier 
     1143        if (! function_exists('wp_trim_words')) 
     1144            $text = strip_tags($text); 
    11281145        $excerpt_length = apply_filters('excerpt_length', 55);  
    11291146        $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]'); 
    1130         $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); 
    1131         if ( count($words) > $excerpt_length ) { 
    1132             array_pop($words); 
    1133             $text = implode(' ', $words); 
    1134             $text = $text . $excerpt_more; 
    1135         } else { 
    1136             $text = implode(' ', $words); 
     1147 
     1148        // 3.3 and later 
     1149        if (function_exists('wp_trim_words')) 
     1150        { 
     1151            $text = wp_trim_words( $text, $excerpt_length, $excerpt_more ); 
     1152        } 
     1153        else 
     1154        { 
     1155            $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY); 
     1156            if ( count($words) > $excerpt_length ) { 
     1157                array_pop($words); 
     1158                $text = implode(' ', $words); 
     1159                $text = $text . $excerpt_more; 
     1160            } else { 
     1161                $text = implode(' ', $words); 
     1162            } 
    11371163        } 
    11381164        if ($options['addthis_showonexcerpts'] == false) 
  • addthis/trunk/includes/addthis_addjs.php

    r556133 r556724  
    5353 
    5454        // on theme swich, check for footer again 
    55         add_action('switch_theme', array($this, 'switch_theme')); 
     55        add_action('switch_theme', array($this, 'switch_theme'),15); 
    5656 
    5757        // In order for our wp_footer magic to work, we need to sometimes add our stuff  
     
    7070    function switch_theme(){ 
    7171        $footer = $this->check_for_footer(); 
    72         $options = $this->_options; 
    73         $options['wpfooter'] = $footer; 
    74         update_option( 'addthis_settings', $options);  
    75         $this->_options = $options; 
     72        $this->_options['wpfooter'] = $footer; 
     73        update_option( 'addthis_settings', $this->_options);  
    7674    } 
    7775 
     
    145143    /*  User name and other shared resources */ 
    146144    function getUsername(){ 
    147         return (isset($this->_options['addthis_username']))?  $this->_options['addthis_username'] : false; 
     145        return (isset($this->_options['username']))?  $this->_options['username'] : false; 
    148146 
    149147    } 
    150148    function setUsername($username){ 
    151         $this->_options['addthis_username'] = sanitize_text_field($username); 
     149        $this->_options['username'] = sanitize_text_field($username); 
    152150        update_option( 'addthis_settings', $options);  
    153151    } 
     
    164162 
    165163    function getPassword(){ 
    166         return (isset($this->_options['addthis_password']))?  $this->_options['addthis_password'] : $this->_cuid; 
     164        return (isset($this->_options['password']))?  $this->_options['password'] : $this->_cuid; 
    167165    } 
    168166 
    169167    function setPassword($password){ 
    170         $this->_options['addthis_password'] = sanitize_text_field($password); 
     168        $this->_options['password'] = sanitize_text_field($password); 
    171169        update_option( 'addthis_settings', $options);  
    172170    } 
Note: See TracChangeset for help on using the changeset viewer.