web/wp-content/plugins/akismet/admin.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
    21 
    21 
    22     if ( function_exists( 'get_plugin_page_hook' ) )
    22     if ( function_exists( 'get_plugin_page_hook' ) )
    23         $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
    23         $hook = get_plugin_page_hook( 'akismet-stats-display', 'index.php' );
    24     else
    24     else
    25         $hook = 'dashboard_page_akismet-stats-display';
    25         $hook = 'dashboard_page_akismet-stats-display';
    26     add_action('admin_head-'.$hook, 'akismet_stats_script');
       
    27     add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
    26     add_meta_box('akismet-status', __('Comment History'), 'akismet_comment_status_meta_box', 'comment', 'normal');
    28 }
    27 }
    29 add_action('admin_init', 'akismet_admin_init');
    28 add_action('admin_init', 'akismet_admin_init');
    30 
    29 
    31 add_action( 'admin_enqueue_scripts', 'akismet_load_js_and_css' );
    30 add_action( 'admin_enqueue_scripts', 'akismet_load_js_and_css' );
    54 function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
    53 function akismet_nonce_field($action = -1) { return wp_nonce_field($action); }
    55 $akismet_nonce = 'akismet-update-key';
    54 $akismet_nonce = 'akismet-update-key';
    56 
    55 
    57 function akismet_plugin_action_links( $links, $file ) {
    56 function akismet_plugin_action_links( $links, $file ) {
    58 	if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
    57 	if ( $file == plugin_basename( dirname(__FILE__).'/akismet.php' ) ) {
    59 		$links[] = '<a href="admin.php?page=akismet-key-config">'.__('Settings').'</a>';
    58 		$links[] = '<a href="' . admin_url( 'admin.php?page=akismet-key-config' ) . '">'.__( 'Settings' ).'</a>';
    60 	}
    59 	}
    61 
    60 
    62 	return $links;
    61 	return $links;
    63 }
    62 }
    64 
    63 
   238 </div>
   237 </div>
   239 </div>
   238 </div>
   240 <?php
   239 <?php
   241 }
   240 }
   242 
   241 
   243 function akismet_stats_script() {
       
   244 	?>
       
   245 <script type="text/javascript">
       
   246 function resizeIframe() {
       
   247   
       
   248     document.getElementById('akismet-stats-frame').style.height = "2500px";
       
   249     
       
   250 };
       
   251 function resizeIframeInit() {
       
   252 	document.getElementById('akismet-stats-frame').onload = resizeIframe;
       
   253 	window.onresize = resizeIframe;
       
   254 }
       
   255 addLoadEvent(resizeIframeInit);
       
   256 </script><?php
       
   257 }
       
   258 
       
   259 
       
   260 function akismet_stats_display() {
   242 function akismet_stats_display() {
   261 	global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
   243 	global $akismet_api_host, $akismet_api_port, $wpcom_api_key;
   262 	$blog = urlencode( get_bloginfo('url') );
   244 	$blog = urlencode( get_bloginfo('url') );
   263 
   245 
   264 	$url = 'http://';
   246 	$url = 'http://';
   267 
   249 
   268 	$url .= 'akismet.com/web/1.0/user-stats.php';
   250 	$url .= 'akismet.com/web/1.0/user-stats.php';
   269 	$url .= "?blog={$blog}&api_key=" . akismet_get_key();
   251 	$url .= "?blog={$blog}&api_key=" . akismet_get_key();
   270 	?>
   252 	?>
   271 	<div class="wrap">
   253 	<div class="wrap">
   272 	<iframe src="<?php echo $url; ?>" width="100%" height="100%" frameborder="0" id="akismet-stats-frame"></iframe>
   254 	<iframe src="<?php echo $url; ?>" width="100%" height="2500px" frameborder="0" id="akismet-stats-frame"></iframe>
   273 	</div>
   255 	</div>
   274 	<?php
   256 	<?php
   275 }
   257 }
   276 
   258 
   277 function akismet_stats() {
   259 function akismet_stats() {
   327 		return;
   309 		return;
   328 	} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) &&  wp_next_scheduled('akismet_schedule_cron_recheck') ) {
   310 	} elseif ( ( empty($_SERVER['SCRIPT_FILENAME']) || basename($_SERVER['SCRIPT_FILENAME']) == 'edit-comments.php' ) &&  wp_next_scheduled('akismet_schedule_cron_recheck') ) {
   329 		function akismet_warning() {
   311 		function akismet_warning() {
   330 			global $wpdb;
   312 			global $wpdb;
   331 				akismet_fix_scheduled_recheck();
   313 				akismet_fix_scheduled_recheck();
   332 				$waiting = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" ) );
   314 				$waiting = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE meta_key = 'akismet_error'" );
   333 				$next_check = wp_next_scheduled('akismet_schedule_cron_recheck');
   315 				$next_check = wp_next_scheduled('akismet_schedule_cron_recheck');
   334 				if ( $waiting > 0 && $next_check > time() )
   316 				if ( $waiting > 0 && $next_check > time() )
   335 					echo "
   317 					echo "
   336 			<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(__('Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation. Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.'), 'admin.php?page=akismet-key-config')."</p></div>
   318 			<div id='akismet-warning' class='updated fade'><p><strong>".__('Akismet has detected a problem.')."</strong> ".sprintf(__('Some comments have not yet been checked for spam by Akismet. They have been temporarily held for moderation. Please check your <a href="%s">Akismet configuration</a> and contact your web host if problems persist.'), 'admin.php?page=akismet-key-config')."</p></div>
   337 			";
   319 			";
   739 			akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), substr($response[1], 0, 50)), 'check-error' );
   721 			akismet_update_comment_history( $c['comment_ID'], sprintf( __('Akismet was unable to re-check this comment (response: %s)'), substr($response[1], 0, 50)), 'check-error' );
   740 		}
   722 		}
   741 
   723 
   742 		delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
   724 		delete_comment_meta( $c['comment_ID'], 'akismet_rechecking' );
   743 	}
   725 	}
   744 	wp_safe_redirect( $_SERVER['HTTP_REFERER'] );
   726 	$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url( 'edit-comments.php' );
       
   727 	wp_safe_redirect( $redirect_to );
   745 	exit;
   728 	exit;
   746 }
   729 }
   747 
   730 
   748 add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
   731 add_action('admin_action_akismet_recheck_queue', 'akismet_recheck_queue');
   749 
   732