Changeset 1033049
- Timestamp:
- 11/26/2014 09:27:09 AM (11 years ago)
- Location:
- write-time/trunk
- Files:
-
- 5 added
- 3 edited
-
css (added)
-
css/style.css (added)
-
js (added)
-
js/exporting.js (added)
-
js/highstock.js (added)
-
languages/write-time-ja.mo (modified) (previous)
-
languages/write-time-ja.po (modified) (2 diffs)
-
write-time.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
write-time/trunk/languages/write-time-ja.po
r1022353 r1033049 4 4 msgstr "" 5 5 "Project-Id-Version: write time\n" 6 "POT-Creation-Date: 2014-11- 09 00:57+0900\n"7 "PO-Revision-Date: 2014-11- 09 00:58+0900\n"6 "POT-Creation-Date: 2014-11-26 18:15+0900\n" 7 "PO-Revision-Date: 2014-11-26 18:17+0900\n" 8 8 "Last-Translator: yonetsu <[email protected]>\n" 9 9 "Language-Team: shinji yonetsu\n" … … 19 19 "X-Poedit-SearchPath-0: ..\n" 20 20 21 #: ../write-time.php:1 11 ../write-time.php:12121 #: ../write-time.php:159 22 22 msgid "This article" 23 23 msgstr "この記事は" 24 24 25 #: ../write-time.php:113 ../write-time.php:115 25 #: ../write-time.php:161 ../write-time.php:163 ../write-time.php:170 26 #: ../write-time.php:172 ../write-time.php:286 ../write-time.php:288 27 #: ../write-time.php:311 ../write-time.php:313 26 28 msgid "minute" 27 29 msgstr "分" 28 30 29 #: ../write-time.php:113 ../write-time.php:115 ../write-time.php:117 31 #: ../write-time.php:161 ../write-time.php:163 ../write-time.php:165 32 #: ../write-time.php:170 ../write-time.php:172 ../write-time.php:174 33 #: ../write-time.php:286 ../write-time.php:288 ../write-time.php:290 34 #: ../write-time.php:311 ../write-time.php:313 ../write-time.php:315 30 35 msgid "second" 31 36 msgstr "秒" 32 37 33 #: ../write-time.php:1 1538 #: ../write-time.php:163 ../write-time.php:288 ../write-time.php:313 34 39 msgid "hour" 35 40 msgstr "時間" 36 41 37 #: ../write-time.php:1 19 ../write-time.php:12942 #: ../write-time.php:167 38 43 msgid "I wrote in ." 39 44 msgstr "で書きました。" 40 45 41 #: ../write-time.php:123 ../write-time.php:125 42 msgid "<span>minute</span>" 43 msgstr "<span>分</span>" 44 45 #: ../write-time.php:123 ../write-time.php:125 ../write-time.php:127 46 msgid "<span>second</span>" 47 msgstr "<span>秒</span>" 48 49 #: ../write-time.php:125 46 #: ../write-time.php:172 50 47 msgid "<span>hour</span>" 51 48 msgstr "<span>時間</span>" 49 50 #: ../write-time.php:267 51 msgid "" 52 "<table class=\"write_date\"><tbody class=\"scrollBody\"><tr><th>ID</" 53 "th><th>date</th><th>title</th><th>status</th><th>write time</th><th>edit</" 54 "th></tr>" 55 msgstr "" 56 "<table class=\"write_date\"><tbody class=\"scrollBody\"><tr><th>ID</th><th>日" 57 "付</th><th>記事タイトル</th><th>公開状態</th><th>執筆時間</th><th>編集リンク" 58 "</th></tr>" 59 60 #: ../write-time.php:308 61 msgid "<p>ALL article" 62 msgstr "<p>全記事数" 63 64 #: ../write-time.php:309 65 msgid "<p>ALL write time" 66 msgstr "<p>執筆時間合計" 67 68 #~ msgid "<span>minute</span>" 69 #~ msgstr "<span>分</span>" 70 71 #~ msgid "<span>second</span>" 72 #~ msgstr "<span>秒</span>" 52 73 53 74 #~ msgctxt "text direction" -
write-time/trunk/write-time.php
r1029928 r1033049 4 4 Plugin URI: http://11neko.com/ 5 5 Description: To display the time it took to write the article . 6 Version: 0. 2.46 Version: 0.3 7 7 Author: shinji yonetsu 8 8 Author URI: http://11neko.com/ … … 37 37 $last_edit_time = strtotime($last_edit_time); 38 38 $created_total_time = get_post_meta($created_edit_time_id, 'created_total_time', false); 39 40 41 42 if( $post_time === $last_edit_time ){ 39 $post_status = get_post_status($created_edit_time_id); 40 41 if( $post_time === $last_edit_time or $post_status == "future"){ 43 42 $start_edit_time_flg = get_post_meta($created_edit_time_id, 'start_edit_time', false); 44 43 if( empty($start_edit_time_flg) ){ … … 107 106 $start_edit_time = get_post_meta($created_edit_time_id, 'start_edit_time', false); 108 107 $first_created_endtime = get_post_meta($created_edit_time_id, 'first_created_endtime', false); 108 109 109 if( !empty($first_created_endtime)){ 110 110 if( !empty($start_edit_time)){ … … 129 129 add_action('pre_post_update', 'get_article_last_edit_time'); 130 130 131 132 function future_post($post_id){ 133 if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) 134 return $post_id; 135 global $post; 136 if($post_id->post_status == 'future'){ 137 echo "true"; 138 } else{ 139 echo "false"; 140 } 141 } 142 143 add_action( 'edit_post', 'my_function' ); 144 131 145 // Program for beginners function 132 146 // single or page 133 147 function display_time($time_format){ 148 date_default_timezone_set( 'Asia/Tokyo' ); 134 149 global $post; 135 150 $created_time = get_post_meta( $post->ID , 'created_total_time' , true ); 136 //$show_time = $created_time[0] + $edit_time[0];137 151 $show_hor_time = floor($created_time / 3600); 138 152 $show_min_time = floor($created_time / 60); 139 153 $show_min_time = $show_min_time % 60; 140 154 $show_sec_time = $created_time % 60; 155 141 156 // time_format_setting 142 157 if( !empty($created_time) or !empty($edit_time) ){ 143 if($time_format == 'defa ult'){158 if($time_format == 'defalut'){ 144 159 echo _e('This article' , 'write-time'); 145 160 if( $created_time > 60 && $created_time < 3600){ … … 151 166 } 152 167 echo _e('I wrote in .' , 'write-time'); 153 } elseif($time_format == 'only'){ 154 echo _e('This article' , 'write-time'); 168 } elseif($time_format == 'custom'){ 155 169 if( $created_time > 60 && $created_time < 3600){ 156 echo $show_min_time,_e(' <span>minute</span>' , 'write-time'),$show_sec_time,_e('<span>second</span>' , 'write-time');170 echo $show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 157 171 } elseif( $created_time > 3600 ){ 158 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');172 echo $show_hor_time,_e('<span>hour</span>' , 'write-time'),$show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 159 173 } else{ 160 echo $show_sec_time,_e('<span>second</span>' , 'write-time'); 161 } 162 echo _e('I wrote in .' , 'write-time'); 163 } 164 } 174 echo $show_sec_time,_e('second' , 'write-time'); 175 } 176 177 } 178 } 179 } 180 181 182 // add menu style & script 183 add_action( 'admin_init', 'my_plugin_admin_init' ); 184 185 function my_plugin_admin_init() { 186 wp_register_style( 'myPluginStylesheet', plugins_url('css/style.css', __FILE__) ); 187 wp_register_style( 'myPluginStylesheet2', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css' ); 188 wp_register_script( 'my-plugin-script', plugins_url( 'js/highstock.js', __FILE__ ) ); 189 wp_register_script( 'my-plugin-script2', plugins_url( 'js/exporting.js', __FILE__ ) ); 190 wp_register_script( 'my-plugin-script3', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js'); 165 191 } 166 192 167 193 168 194 // add menu 169 add_action('admin_menu' , 'add_write_time_menu'); 170 function add_write_time_menu(){ 171 add_menu_page('WriteTime', 'WriteTime', 'manage_options', 'write_time_page', 'write_time_display' , 'dashicons-clock'); 172 } 173 195 196 function my_plugin_admin_styles() { 197 wp_enqueue_style( 'myPluginStylesheet' ); 198 wp_enqueue_style( 'myPluginStylesheet2' ); 199 } 200 201 function my_plugin_admin_scripts() { 202 wp_enqueue_script( 'my-plugin-script' ); 203 wp_enqueue_script( 'my-plugin-script2' ); 204 wp_enqueue_script( 'my-plugin-script3' ); 205 } 174 206 // display page 175 function write_time_display(){ 207 ///////////////////////////////////////////////////////////////// 208 209 add_action('admin_menu' , 'add_hoge'); 210 function add_hoge(){ 211 $page = add_menu_page('write time', 'write time', 'manage_options', 'myplugin_id', 'write_time_page','dashicons-clock'); 212 add_action( 'admin_print_styles-' . $page, 'my_plugin_admin_styles' ); 213 add_action('admin_print_scripts-' . $page, 'my_plugin_admin_scripts2'); 214 } 215 function my_plugin_admin_scripts2() { 216 wp_enqueue_script( 'my-plugin-script' ); 217 wp_enqueue_script( 'my-plugin-script2' ); 218 wp_enqueue_script( 'my-plugin-script3' ); 219 } 220 221 add_action( 'wp_ajax_'.myplugin_get_action_name(), 'myplugin_response' ); 222 add_action( 'wp_ajax_nopriv_'.myplugin_get_action_name(), 'myplugin_response' ); 223 224 function myplugin_get_action_name() { 225 return 'myplugin_action'; 226 } 227 228 function myplugin_get_nonce_name() { 229 return 'myplugin-nonce'; 230 } 231 232 function write_time_page() { 233 echo '<h2>write time Page</h2>'; 234 echo '<div id="container"></div>'; 235 $nonce_name = myplugin_get_nonce_name(); 236 $nonce = wp_create_nonce( $nonce_name ); 237 $action_name = myplugin_get_action_name(); 238 $url = admin_url( 'admin-ajax.php' ); 239 240 $json_options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT; 241 $url = json_encode( $url, $json_options ); 242 243 244 $json = json_encode( 245 array( 246 'action' => $action_name, 247 'security' => $nonce, 248 'foo' => 'bar' 249 ), $json_options ); 250 176 251 $count; 177 252 $all_create_time; … … 184 259 $wp_query->query($args); 185 260 186 // display 187 echo '<table class="write_date"><tr><th>ID</th><th>date</th><th>title</th><th>status</th><th>write time</th></tr>'; 261 262 // glaph 263 echo '<div id="container"></div>'; 264 265 // display date 266 echo '<div class="table_style">'; 267 echo _e('<table class="write_date"><tbody class="scrollBody"><tr><th>ID</th><th>date</th><th>title</th><th>status</th><th>write time</th><th>edit</th></tr>' , 'write-time'); 188 268 $total_count = 0; 189 269 $count = 0; 190 270 while ($wp_query->have_posts()) : $wp_query->the_post(); 191 $post_id = get_the_ID(); 192 $total = get_post_meta($post_id , 'created_total_time' ,true); 193 $total_count += $total; 194 195 echo '<tr><td>' , get_the_id() , '</td>'; 196 echo '<td>' , the_time('Y-m-d') , '</td>'; 197 echo '<td>' , get_the_title() , '</td>'; 198 echo '<td>' , get_post_status() , '</td>'; 199 echo '<td>'; 200 $show_hor_time = floor($total / 3600); 201 $show_min_time = floor($total / 60); 202 $show_min_time = $total % 60; 203 $show_sec_time = $total % 60; 204 205 if( $total > 60 && $total < 3600){ 206 echo $show_min_time, _e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 207 } elseif( $total > 3600){ 208 echo $show_hor_time,_e('hour' , 'write-time'),$show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 209 } else{ 210 echo $show_sec_time,_e('second' , 'write-time'); 211 } 212 echo '</td></tr>'; 213 214 $count++; 271 $post_id = get_the_ID(); 272 $total = get_post_meta($post_id , 'created_total_time' ,true); 273 if(!empty($total)){ 274 echo '<tr><td>' , get_the_id() , '</td>'; 275 echo '<td>' , the_time('Y-m-d') , '</td>'; 276 echo '<td>' , get_the_title() , '</td>'; 277 echo '<td>' , get_post_status() , '</td>'; 278 echo '<td>'; 279 $show_hor_time = floor($total / 3600); 280 $show_min_time = floor($total / 60); 281 $show_min_time = $show_min_time % 60; 282 $show_sec_time = $total % 60; 283 284 285 if( $total > 60 && $total < 3600){ 286 echo $show_min_time, _e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 287 } elseif( $total > 3600){ 288 echo $show_hor_time,_e('hour' , 'write-time'),$show_min_time,_e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); 289 } else{ 290 echo $show_sec_time,_e('second' , 'write-time'); 291 } 292 echo '</td>'; 293 echo '<td>' , edit_post_link('edit') , '</td>'; 294 echo '</tr>'; 295 } 296 $total_count += $total; 297 $count++; 215 298 endwhile; 299 echo '</tbody>'; 216 300 echo '</table>'; 217 301 echo '</div>'; 302 218 303 $show_hor_time = floor($total_count / 3600); 219 304 $show_min_time = floor($total_count / 60); 220 $show_min_time = $ total_count% 60;305 $show_min_time = $show_min_time % 60; 221 306 $show_sec_time = $total_count % 60; 222 223 echo '<p>ALL article', $count , '</p>';224 echo '<p>ALL write time';307 echo '<div class="article_date"'; 308 echo _e('<p>ALL article' , 'write-time') , $count , '</p>'; 309 echo _e('<p>ALL write time' , 'write-time') ; 225 310 if( $total_count > 60 && $total_count < 3600){ 226 311 echo $show_min_time, _e('minute' , 'write-time'),$show_sec_time,_e('second' , 'write-time'); … … 230 315 echo $show_sec_time,_e('second' , 'write-time'); 231 316 } 232 echo '</p><br>'; 317 echo '</p>'; 318 echo '</div>'; 233 319 wp_reset_query(); 234 320 321 ?> 322 323 <div id="result"></div> 324 <script type="text/javascript"> 325 function utc2dateString(utc_msec) { 326 d=new Date(); 327 d.setTime(utc_msec); 328 return d.getFullYear()+'/'+(d.getMonth()+1)+'/'+d.getDate(); 329 } 330 331 (function($) { 332 333 var url = <?php echo $url ?>; 334 var data = <?php echo $json ?>; 335 336 $.post(url,data,function (ret) { 337 console.log(ret); 338 Highcharts.setOptions({ 339 global: { 340 useUTC: true 341 }, 342 lang: { 343 rangeSelectorZoom: '表示範囲', 344 resetZoom: '表示期間をリセット', 345 resetZoomTitle: '表示期間をリセット', 346 rangeSelectorFrom: '表示期間', 347 rangeSelectorTo: '〜', 348 printButtonTitle: 'チャートを印刷', 349 exportButtonTitle: '画像としてダウンロード', 350 downloadJPEG: 'JPEG画像でダウンロード', 351 downloadPDF: 'PDF文書でダウンロード', 352 downloadPNG: 'PNG画像でダウンロード', 353 downloadSVG: 'SVG形式でダウンロード', 354 months: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'], 355 weekdays: ['日', '月', '火', '水', '木', '金', '土'], 356 numericSymbols: null 357 } 358 }); 359 235 360 236 } 361 362 // Create the chart 363 $('#container').highcharts('StockChart', { 364 rangeSelector : { 365 selected : 1 366 }, 367 368 title : { 369 text : 'write time' 370 }, 371 372 series : [{ 373 name : 'write time', 374 turboThreshold: 0, 375 data : ret, 376 tooltip: { 377 shared: true, 378 pointFormat: '{point.y} 分', 379 valueDecimals: 0 380 } 381 }], 382 383 xAxis: [{ 384 labels: { 385 formatter: function(){ return utc2dateString(this.value); } 386 } 387 }], 388 navigator: { 389 baseSeries: 0 390 }, 391 392 yAxis: [{ 393 title: { 394 text: '時間(分)' 395 } 396 }], 397 398 plotOptions: { 399 series: { 400 dataGrouping: { 401 dateTimeLabelFormats: { 402 millisecond: ['%Y/%m/%d %H:%M:%S.%L', '%Y/%m/%d %H:%M:%S.%L', '-%H:%M:%S.%L'], 403 second: ['%Y/%m/%d %H:%M:%S', '%Y/%m/%d %H:%M:%S', '-%H:%M:%S'], 404 minute: ['%Y/%m/%d %H:%M', '%Y/%m/%d %H:%M', '-%H:%M'], 405 hour: ['%Y/%m/%d %H:%M', '%Y/%m/%d %H:%M', '-%H:%M'], 406 day: ['%Y/%m/%d', '%Y/%m/%d', '-%Y/%m/%d'], 407 week: ['%Y/%m/%d', '%Y/%m/%d', '-%Y/%m/%d'], 408 month: ['%B %Y', '%B', '-%B %Y'], 409 year: ['%Y', '%Y', '-%Y'] 410 } 411 } 412 }, 413 }, 414 rangeSelector: { 415 selected : 1, 416 inputDateFormat: '%Y/%m/%d', 417 inputEditDateFormat: '%Y/%m/%d', 418 buttons : [{ 419 type : 'day', 420 count : 90, 421 text : '3ヶ月' 422 }, { 423 type : 'day', 424 count : 180, 425 text : '6ヶ月' 426 }, { 427 type : 'year', 428 count : 1, 429 text : '1年' 430 }, { 431 type : 'year', 432 count : 2, 433 text : '2年' 434 }, { 435 type : 'year', 436 count : 3, 437 text : '3年' 438 }, { 439 type : 'all', 440 count : 1, 441 text : 'All' 442 }] 443 } 444 }, function (chart) { 445 // apply the date pickers 446 setTimeout(function () { 447 $('input.highcharts-range-selector', $(chart.container).parent()).datepicker();}, 0); 448 }); 449 450 // Set the datepicker's date format 451 $.datepicker.setDefaults({ 452 dateFormat: 'yy-mm-dd', 453 onSelect: function () { 454 this.onchange(); 455 this.onblur(); 456 } 457 }); 458 459 }); 460 })(jQuery); 461 </script> 462 463 <?php 464 } 465 466 function myplugin_response() { 467 $nonce_name = myplugin_get_nonce_name(); 468 check_ajax_referer( $nonce_name, 'security' ); 469 470 $ret = array(); 471 $args = array( 472 'meta_key' => 'created_total_time', 473 'order' => 'asc', 474 'posts_per_page' => -1 475 ); 476 $posts = get_posts( $args ); 477 foreach( $posts as $key => $post ) { 478 $time_stomp = get_post_meta($post->ID , 'created_total_time' ,true); 479 $time_stomp = intval($time_stomp); 480 $show_hor_time = floor($time_stomp / 3600); 481 $show_min_time = floor($time_stomp / 60); 482 483 $data_time = strtotime($post->post_date) * 1000; 484 485 $ret[$key] = array( 486 $data_time,$show_min_time 487 ); 488 } 489 header( 'Content-Type: application/json' ); 490 wp_send_json( $ret ); 491 } 492 237 493 238 494 ?>
Note: See TracChangeset
for help on using the changeset viewer.