Changeset 451 for branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php
- Timestamp:
- Nov 20, 2009, 2:52:16 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/wp-content/plugins/xpressme/xpressme.php
r413 r451 22 22 require_once dirname( __FILE__ ).'/include/functions_for_wp_old.php' ; 23 23 24 if (!is_wordpress_style() && ( !empty($xpress_config->theme_select) || $xpress_config->theme_select != 'use_wordpress_select') ){ 25 add_filter('stylesheet', 'xpress_Stylesheet'); 26 add_filter('template', 'xpress_ThemeTemplate'); 27 } 28 function xpress_Stylesheet($stylesheet) { 29 global $xpress_config; 30 $theme = $xpress_config->theme_select; 31 $theme = get_theme($theme); 32 33 if (empty($theme)) { 34 return $stylesheet; 35 } 36 return $theme['Stylesheet']; 37 } 38 39 function xpress_ThemeTemplate($template) { 40 global $xpress_config; 41 $theme = $xpress_config->theme_select; 42 $theme = get_theme($theme); 43 44 if (empty($theme)) { 45 return $template; 46 } 47 return $theme['Template']; 48 } 49 24 50 function my_plugin_menu() 25 51 { … … 190 216 echo '<form method="post" action="' . $_SERVER["REQUEST_URI"] . '">'."\n" ; 191 217 echo '<table class="form-table">'."\n"; 218 $upload_title = __('Media Upload Base Path','xpressme'); 219 if($xoops_config->is_wpmu) $upload_title = $upload_title . '(WPMU is not select)'; 192 220 echo $xpress_config->yes_no_radio_option('is_use_xoops_upload_path', 193 __('Media Upload Base Path','xpressme'),221 $upload_title, 194 222 __('Use XOOPS UPLOAD PATH','xpressme'), 195 __('USE WordPress BASE_PATH','xpressme') 196 );197 198 echo $xpress_config->groupe_role_option();199 223 __('USE WordPress BASE_PATH','xpressme'), 224 $xoops_config->is_wpmu 225 ); 226 $lock = ($xoops_config->module_url != get_bloginfo('url')); 227 echo $xpress_config->groupe_role_option($lock); 200 228 echo $xpress_config->d3forum_option($do_message); 201 229 echo "</table>\n"; … … 253 281 __('NO','xpressme') 254 282 ); 283 echo $xpress_config->yes_no_radio_option('is_block_error_display', 284 __('Select warning display of block file version check','xpressme'), 285 __('Do display','xpressme'), 286 __('Do not display','xpressme') 287 ); 255 288 echo "</table>\n"; 256 289 … … 264 297 } 265 298 266 function upgrade_page() 267 { 268 global $xoops_config,$xpress_config; 269 270 $xpress_version = $xoops_config->module_version . $xoops_config->module_codename; 271 $check_url = "http://ja1.xpressme.info/version_check/?version=$xpress_version"; 272 273 echo '<div class="wrap">'."\n"; 274 echo '<div id="icon-options-general" class="icon32"><br /></div>'."\n"; 275 echo '<h2>' . __('XPressME Upgrade', 'xpressme') . "</h2><br>\n"; 276 277 if(get_xpress_latest_version()){ 278 $latest = get_option('xpressme_latest_version'); 279 if ($latest) { 280 $site_url=$latest['url']; 281 $package=$latest['package']; 282 $latest_version=$latest['latest_version']; 283 $check_time=$latest['check_time']; 284 } 285 286 287 if (version_compare($xpress_version, $latest_version, '>')){ 288 echo '<h3 class="response">'; 289 printf(__('You are using a XPressME Integration Kit development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.', 'xpressme') , $xpress_version , $site_url); 290 echo '</h3>'; 291 292 } else if (version_compare($xpress_version, $latest_version, '<')) { 293 echo '<h3 class="response">'. __('There is a new version of XPressME Integration Kit available for upgrade', 'xpressme') . '</h3>'; 294 echo '<p>'; 295 // printf(__('You can upgrade to version %s automatically or download the package and install it manually:'),$latest_version); 296 printf(__('You can upgrade to version %s download the package and install it manually:', 'xpressme'),$latest_version); 297 echo '</p>'; 298 echo '<a class="button" href="' . $package . '">'; 299 printf(__('Download %s', 'xpressme') , $latest_version); 300 echo '</a>'; 301 } else { 302 echo '<h3 class="response">'. __('You have the latest version of XPressME Integration Kit. You do not need to upgrade', 'xpressme') . '</h3>'; 303 } 304 } else { 305 echo '<h3 class="response">'; 306 printf(__('There is no response from <a href="%s">version check API</a> now. sorry, please confirm it after.', 'xpressme'),$check_url); 307 echo "</div>\n"; 308 } 309 } 310 311 function xp_remote_get($url, $headers = ""){ 312 global $xoops_config; 313 $xpress_version = $xoops_config->module_version . $xoops_config->module_codename; 314 315 require_once( $xoops_config->module_path . '/wp-includes/class-snoopy.php'); 316 317 // Snoopy is an HTTP client in PHP 318 $client = new Snoopy(); 319 $client->agent = 'XPressME/' . $xpress_version; 320 $client->read_timeout = 2; 321 if (is_array($headers) ) { 322 $client->rawheaders = $headers; 323 } 324 325 @$client->fetch($url); 326 $response['response']['code'] = $client->status; 327 $response['body'] = $client->results; 328 return $response; 329 return $client; 330 331 } 332 333 function get_xpress_latest_version(){ 334 global $wp_version, $wpdb, $wp_local_package; 335 global $xoops_config; 336 337 $xpress_version = $xoops_config->module_version . $xoops_config->module_codename; 338 339 $check_url = "http://ja.xpressme.info/version_check/?version=$xpress_version"; 340 $request_options = array( 341 'timeout' => 3, 342 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) 343 ); 344 345 if (! function_exists('wp_remote_get')) { 346 $response = xp_remote_get($check_url); 347 348 if (empty($response['body'])) return false; 349 } else { 350 351 $response = wp_remote_get($check_url, $request_options); 352 353 if ( is_wp_error( $response ) ) 354 return false; 355 } 356 if ( 200 != $response['response']['code'] ) 357 return false; 358 $body = trim( $response['body'] ); 359 $body = str_replace(array("\r\n", "\r"), "\n", $body); 360 $returns = explode("\n", $body); 361 $response = $returns[0]; 362 if ( isset( $returns[1] ) ) 363 $url = clean_url( $returns[1] ); 364 if ( isset( $returns[2] ) ) 365 $package = clean_url( $returns[2] ); 366 if ( isset( $returns[3] ) ) 367 $latest_version = $returns[3]; 368 369 $write_options = array ( 370 'url' => $url , 371 'package' => $package , 372 'latest_version' => $latest_version , 373 'check_time' => time() 374 ); 375 376 $latest_version = get_option('xpressme_latest_version'); 377 if (!$latest_version) { 378 add_option('xpressme_latest_version', $write_options); 379 } else { 380 update_option('xpressme_latest_version', $write_options); 381 } 382 return true; 383 } 384 385 function xpress_update_check() { 386 if ( defined('WP_INSTALLING') ) 387 return; 388 global $pagenow; 389 390 $php_query_string = $_SERVER['QUERY_STRING']; 391 392 if ( 'admin.php' == $pagenow && 'page=upgrade_page' == $php_query_string) 393 return; 394 395 global $wp_version, $wpdb, $wp_local_package; 396 global $xoops_config; 397 398 $php_query_string = $_SERVER['QUERY_STRING']; 399 $xpress_version = $xoops_config->module_version . $xoops_config->module_codename; 400 401 $latest = get_option('xpressme_latest_version'); 402 if (!$latest ) { 403 get_xpress_latest_version(); 404 $latest = get_option('xpressme_latest_version'); 405 } 406 407 if ($latest) { 408 $next_check = $latest['check_time'] + (60*60*24); 409 $now_time = time(); 410 if ($next_check < $now_time ){ 411 get_xpress_latest_version(); 412 $latest = get_option('xpressme_latest_version'); 413 } 414 } 415 416 if ($latest) { 417 $url=$latest['url']; 418 $package=$latest['package']; 419 $latest_version=$latest['latest_version']; 420 $check_time=$latest['check_time']; 421 $upgrade_page = $xoops_config->module_url . "/wp-admin/admin.php?page=upgrade_page"; 422 423 if (version_compare($xpress_version, $latest_version, '<')) { 424 if ( current_user_can('manage_options') ){ 425 $msg = sprintf( __('XPressME Integration Kit Version %1$s is available! <a href="%2$s">Please update now</a>.', 'xpressme'), $latest_version, $upgrade_page ); 426 } else { 427 $msg = sprintf( __('XPressME Integration Kit Version %1$s is available! Please notify the site administrator.', 'xpressme'), $latest_version ); 428 } 429 echo "<div id='update-nag'>$msg </div>"; 430 } 431 } 432 } 433 299 include_once dirname( __FILE__ ).'/include/xpress_upgrade.php' ; 434 300 add_action( 'admin_notices', 'xpress_update_check', 3 ); 435 301 436 302 include_once dirname( __FILE__ ).'/include/dashboard_feed.php' ; 437 303 304 include_once dirname( __FILE__ ).'/xpressme_widget_class.php' ; 305 438 306 ?>
Note: See TracChangeset
for help on using the changeset viewer.