Changeset 1029921
- Timestamp:
- 11/21/2014 06:40:47 AM (11 years ago)
- Location:
- write-time/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (1 diff)
-
write-time.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
write-time/trunk/readme.txt
r1022453 r1029921 55 55 56 56 == Changelog == 57 = 0.2.2 = 58 add menu. and bugfix. 57 59 58 60 = 0.1 = -
write-time/trunk/write-time.php
r1022614 r1029921 4 4 Plugin URI: http://11neko.com/ 5 5 Description: To display the time it took to write the article . 6 Version: 0.2. 16 Version: 0.2.3 7 7 Author: shinji yonetsu 8 8 Author URI: http://11neko.com/ … … 36 36 $post_time = strtotime($post_time); 37 37 $last_edit_time = strtotime($last_edit_time); 38 $created_total_time = get_post_meta($created_edit_time_id, 'created_total_time', false); 39 40 38 41 39 42 if( $post_time === $last_edit_time ){ … … 62 65 } 63 66 } 67 68 if( empty($created_total_time)){ 69 $total_edit_time = get_post_meta($created_edit_time_id, 'total_edit_time', false); 70 $total_article_time = get_post_meta($created_edit_time_id, 'total_article_time', false); 71 if(!isset($total_edit_time[0])){ 72 echo 'set_total'; 73 $total_edit_time[0] = 0; 74 } 75 if(!isset($total_article_time[0])){ 76 echo 'set_article'; 77 $total_article_time[0] = 0; 78 } 79 $created_total_time = $total_edit_time[0] + $total_article_time[0]; 80 add_post_meta($created_edit_time_id, 'created_total_time', $created_total_time); 81 } else{ 82 $total_edit_time = get_post_meta($created_edit_time_id, 'total_edit_time', false); 83 $total_article_time = get_post_meta($created_edit_time_id, 'total_article_time', false); 84 if(!isset($total_edit_time[0])){ 85 echo 'set_total'; 86 $total_edit_time[0] = 0; 87 } 88 if(!isset($total_article_time[0])){ 89 echo 'set_article'; 90 $total_article_time[0] = 0; 91 } 92 $created_total_time = $total_edit_time[0] + $total_article_time[0]; 93 update_post_meta($created_edit_time_id, 'created_total_time', $created_total_time); 94 } 95 64 96 } 65 97 add_action( 'admin_head-post.php', 'get_article_edit_start_time' ); … … 99 131 function display_time($time_format){ 100 132 global $post; 101 $created_time = get_post_meta( $post->ID , 'total_article_time' , false ); 102 $edit_time = get_post_meta( $post->ID , 'total_edit_time' , false ); 103 $show_time = $created_time[0] + $edit_time[0]; 104 $show_hor_time = floor($show_time / 3600); 105 $show_min_time = floor($show_time / 60); 133 $created_time = get_post_meta( $post->ID , 'created_total_time' , true ); 134 //$show_time = $created_time[0] + $edit_time[0]; 135 $show_hor_time = floor($created_time / 3600); 136 $show_min_time = floor($created_time / 60); 106 137 $show_min_time = $show_min_time % 60; 107 $show_sec_time = $ show_time % 60;138 $show_sec_time = $created_time % 60; 108 139 // time_format_setting 109 140 if( !empty($created_time) or !empty($edit_time) ){ 110 141 if($time_format == 'default'){ 111 142 echo _e('This article' , 'write-time'); 112 if( $ show_time > 60 && $show_time < 3600){143 if( $created_time > 60 && $created_time < 3600){ 113 144 echo $show_min_time, _e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 114 } elseif( $ show_time > 3600){145 } elseif( $created_time > 3600){ 115 146 echo $show_hor_time,_e('hour' , 'write-time'),$show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 116 147 } else{ … … 120 151 } elseif($time_format == 'only'){ 121 152 echo _e('This article' , 'write-time'); 122 if( $ show_time > 60 && $show_time < 3600){153 if( $created_time > 60 && $created_time < 3600){ 123 154 echo $show_min_time,_e('<span>minute</span>' , 'write-time'),$show_sec_time,_e('<span>second</span>' , 'write-time'); 124 } elseif( $ show_time > 3600 ){155 } elseif( $created_time > 3600 ){ 125 156 echo $show_hor_time,_e('<span>hour</span>' , 'write-time'),$show_min_time,_e('<span>minute</span>' , 'write-time'),$show_sec_time,_e('<span>second</span>' , 'write-time'); 126 157 } else{ … … 132 163 } 133 164 165 166 // add menu 167 add_action('admin_menu' , 'add_write_time_menu'); 168 function add_write_time_menu(){ 169 add_menu_page('WriteTime', 'WriteTime', 'manage_options', 'write_time_page', 'write_time_display' , 'dashicons-clock'); 170 } 171 172 // display page 173 function write_time_display(){ 174 $count; // 記事数 175 $all_create_time; // 執筆時間 176 // 最終計算値の値があるものだけ取得 177 178 //$page = (get_query_var('paged')) ? get_query_var('paged') : 1; 179 $wp_query = new WP_Query(); 180 $args = array( 181 'meta_key' => 'created_total_time', 182 'posts_per_page' => -1 183 ); 184 //$wp_query = new WP_Query($args); 185 $wp_query->query($args); 186 187 // display 188 echo '<table class="write_date"><tr><th>ID</th><th>date</th><th>title</th><th>status</th><th>write time</th></tr>'; 189 //while ( $wp_query->have_posts() ) : $wp_query->the_post(); 190 $total_count = 0; 191 $count = 0; 192 while ($wp_query->have_posts()) : $wp_query->the_post(); 193 $post_id = get_the_ID(); 194 $total = get_post_meta($post_id , 'created_total_time' ,true); 195 $total_count += $total; 196 197 echo '<tr><td>' , get_the_id() , '</td>'; 198 echo '<td>' , the_time('Y-m-d') , '</td>'; 199 echo '<td>' , get_the_title() , '</td>'; 200 echo '<td>' , get_post_status() , '</td>'; 201 echo '<td>'; 202 $show_hor_time = floor($total / 3600); 203 $show_min_time = floor($total / 60); 204 $show_min_time = $total % 60; 205 $show_sec_time = $total % 60; 206 207 if( $total > 60 && $total < 3600){ 208 echo $show_min_time, _e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 209 } elseif( $total > 3600){ 210 echo $show_hor_time,_e('hour' , 'write-time'),$show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 211 } else{ 212 echo $show_sec_time,_e('second' , 'write-time'); 213 } 214 echo '</td></tr>'; 215 216 $count++; 217 endwhile; 218 echo '</table>'; 219 220 $show_hor_time = floor($total_count / 3600); 221 $show_min_time = floor($total_count / 60); 222 $show_min_time = $total_count % 60; 223 $show_sec_time = $total_count % 60; 224 225 // 総合情報 226 echo '<p>ALL article' , $count , '</p>'; 227 echo '<p>ALL write time'; 228 if( $total_count > 60 && $total_count < 3600){ 229 echo $show_min_time, _e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 230 } elseif( $total_count > 3600){ 231 echo $show_hor_time,_e('hour' , 'write-time'),$show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 232 } else{ 233 echo $show_sec_time,_e('second' , 'write-time'); 234 } 235 echo '</p><br>'; 236 wp_reset_query(); 237 238 239 } 240 241 242 243 244 245 246 247 248 249 250 134 251 ?>
Note: See TracChangeset
for help on using the changeset viewer.