XPressME Integration Kit

Trac

Changeset 370


Ignore:
Timestamp:
Aug 25, 2009, 11:35:32 AM (15 years ago)
Author:
toemon
Message:

XPressME のアップデート通知 WP2011への対応 fixes #205

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php

    r369 r370  
    3434        add_submenu_page(__FILE__, __('Integration Settings', 'xpressme'), __('Integration Settings', 'xpressme'), 8, 'integration_option_page', 'integration_option_page'); 
    3535        add_submenu_page(__FILE__, __('Other Settings', 'xpressme'), __('Other Settings', 'xpressme'), 8, 'other_option_page', 'other_option_page'); 
    36         if (function_exists('wp_remote_get')) 
     36//      if (function_exists('wp_remote_get')) 
    3737                add_submenu_page(__FILE__, __('Upgrade', 'xpressme'), __('Upgrade', 'xpressme'), 8, 'upgrade_page', 'upgrade_page'); 
    3838        add_submenu_page(__FILE__, __('to XOOPS Admin', 'xpressme'), __('to XOOPS Admin', 'xpressme'), 8,  'redirect_xoops_admin', 'redirect_xoops_admin'); 
     
    308308} 
    309309 
     310function xp_remote_get($url, $headers = ""){ 
     311        global $xoops_config; 
     312        $xpress_version = $xoops_config->module_version . $xoops_config->module_codename; 
     313 
     314        require_once( $xoops_config->module_path . '/wp-includes/class-snoopy.php'); 
     315 
     316        // Snoopy is an HTTP client in PHP 
     317        $client = new Snoopy(); 
     318        $client->agent = 'XPressME/' . $xpress_version; 
     319        $client->read_timeout = 2; 
     320        if (is_array($headers) ) { 
     321                $client->rawheaders = $headers; 
     322        } 
     323 
     324        @$client->fetch($url); 
     325        $response['response']['code'] = $client->status; 
     326        $response['body'] = $client->results; 
     327        return $response; 
     328        return $client; 
     329 
     330} 
     331 
    310332function get_xpress_latest_version(){ 
    311333        global $wp_version, $wpdb, $wp_local_package; 
     
    320342        ); 
    321343 
    322         if (! function_exists('wp_remote_get')) return false; 
    323          
    324         $response = wp_remote_get($check_url, $request_options); 
    325         if ( is_wp_error( $response ) ) 
    326                 return false; 
    327  
     344        if (! function_exists('wp_remote_get')) { 
     345                $response = xp_remote_get($check_url); 
     346                 
     347                if (empty($response['body'])) return false; 
     348        } else { 
     349         
     350                $response = wp_remote_get($check_url, $request_options); 
     351                 
     352                if ( is_wp_error( $response ) ) 
     353                        return false; 
     354        } 
    328355        if ( 200 != $response['response']['code'] ) 
    329356                return false; 
    330  
    331357        $body = trim( $response['body'] ); 
    332358        $body = str_replace(array("\r\n", "\r"), "\n", $body); 
    333359        $returns = explode("\n", $body); 
    334         $response = esc_attr( $returns[0] ); 
     360        $response = $returns[0]; 
    335361        if ( isset( $returns[1] ) ) 
    336                 $url = esc_url( $returns[1] ); 
     362                $url = clean_url( $returns[1] ); 
    337363        if ( isset( $returns[2] ) ) 
    338                 $package = esc_url( $returns[2] ); 
     364                $package = clean_url( $returns[2] ); 
    339365        if ( isset( $returns[3] ) ) 
    340                 $latest_version = esc_attr( $returns[3] ); 
     366                $latest_version = $returns[3]; 
    341367 
    342368        $write_options = array ( 
Note: See TracChangeset for help on using the changeset viewer.