Changeset 1437718
- Timestamp:
- 06/16/2016 10:40:04 AM (10 years ago)
- Location:
- wp-report-post/trunk
- Files:
-
- 3 edited
-
css/style.css (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
wp-report-post.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-report-post/trunk/css/style.css
r1437537 r1437718 96 96 width:10%; 97 97 } 98 .reported_post #meta_value,99 98 .reported_post #post_author { 100 99 width:15%; -
wp-report-post/trunk/readme.txt
r1437544 r1437718 24 24 * Supports AJAXly loaded posts, 'infinite scroll' posts, etc. 25 25 * Does not use additional databases / tables anymore. All reports are stored in postmeta. 26 * Modal window instead of expandable form (works with AJAXly loaded posts!) 27 * Bulk Unpublish, Publish, Delete Posts, Delete Reports 28 * All texts displayed in front end are customizable via Options 26 29 27 30 Plugin demo: http://wp.esiteq.com/wordpress-report-post-plugin-demo/ … … 67 70 == Upgrade Notice == 68 71 72 = 2.0.1 = 73 New version imports reports created by version 0.X so they are available again. 74 69 75 = 2.0 = 70 76 Be aware when upgrading from 0.X to 2.0. Old report database is not supported anymore. It means that all reports made with previous version of the plugin will be lost. … … 72 78 == Changelog == 73 79 80 = 2.0.2 = 81 Added report date in two formats: Human (e.g 3 minutes ago) and Date / Time 82 83 = 2.0.1 = 84 * Fixed posts per page in admin section, set to 25 85 * Added import of reports created by version 0.X 86 74 87 = 2.0 = 75 88 Completely remastered. Well, this is not an update of previous version of the plugin. This is a new plugin written from scratch. 76 89 77 90 = 0.2.4 = 78 79 91 Fixed bug with incorrect link to attached image 80 92 81 93 = 0.2.2 = 82 83 94 Fixed bug with duplicate reports 84 95 85 96 = 0.2.1 = 86 87 97 Removed engine and encoding from CREATE TABLE query - default values will be used (in case if InnoDB is not supported on your hosting) 88 98 89 99 = 0.2 = 90 91 100 * Perverted AJAX calls were replaced in a normal Wordpress way 92 101 * Added email notifications for reported posts … … 95 104 96 105 = 0.1 = 97 98 106 * CSS buttons added 99 107 * Fixed textarea width -
wp-report-post/trunk/wp-report-post.php
r1437534 r1437718 8 8 * Author: Alex Raven 9 9 * Company: ESITEQ 10 * Version: 2.0 10 * Version: 2.0.2 11 11 * Updated 2016-06-12 12 12 * Created 2013-09-22 … … 27 27 var $defaults = array 28 28 ( 29 'date_format' => 'human', 30 'date_format_options' => array('human' => 'Human (e.g 5 minutes ago)', 'date' => 'Date / Time'), 29 31 'require_login' => '0', 30 32 'add_what_options' => array(''=>'Nothing', 'link'=>'Link', 'button'=>'Button'), … … 64 66 'text_error' => 'Error reporting' 65 67 ); 68 function import_old() 69 { 70 global $wpdb; 71 if (get_option('wp_report_post_import_v0') == '1') { return false; } 72 $sql = $wpdb->prepare("SELECT *, UNIX_TIMESTAMP(`dt`) AS ts FROM {$wpdb->prefix}reported_posts LEFT JOIN {$wpdb->posts} ON {$wpdb->prefix}reported_posts.post_id={$wpdb->posts}.ID", 1); 73 $reports = $wpdb->get_results($sql, ARRAY_A); 74 foreach ($reports as $row) 75 { 76 if ($row['ID']) 77 { 78 $data = array 79 ( 80 'user_id' => $row['user_id'], 81 'email' => $row['user_email'], 82 'name' => $row['user_name'], 83 'msg' => $row['message'], 84 'post_id' => $row['post_id'], 85 'timestamp' => $row['ts'] 86 ); 87 $rep = get_post_meta($row['post_id'], '_wp_report_post', true); 88 if (is_array($rep)) 89 { 90 $exist = false; 91 foreach ($rep as $rrow) 92 { 93 if ($rrow['email'] == $data['email']) 94 { 95 $exist = true; 96 } 97 } 98 if (!$exist) 99 { 100 $rep[] = $data; 101 } 102 } 103 else 104 { 105 $rep[] = $data; 106 } 107 update_post_meta($row['post_id'], '_wp_report_post', $rep); 108 } 109 } 110 update_option('wp_report_post_import_v0', '1'); 111 return true; 112 } 113 // 66 114 function enqueue_scripts() 67 115 { … … 256 304 function reported_posts() 257 305 { 306 $this->import_old(); 258 307 $reports = new WP_Report_Post_List(); 308 $reports->options = $this->options; 309 $reports->defaults = $this->defaults; 310 $reports->DOMAIN = $this->DOMAIN; 259 311 $reports->prepare_items(); 260 312 ?> … … 293 345 function get_option($name, $default='') 294 346 { 347 if ($default == '') $default = $this->defaults[$name]; 295 348 return (isset($this->options[$name])) ? $this->options[$name] : $default; 296 349 } … … 303 356 function update_options() 304 357 { 305 update_option('wp_report_post_options', $this->options);358 return update_option('wp_report_post_options', $this->options); 306 359 } 307 360 // … … 325 378 <tr> 326 379 <th scope="row">Automatically add</th> 327 <td><?php $this->select('add_what', $this->defaults['add_what_options'], $this->get_option('add_what' , $this->defaults['add_what_option'])); ?><span> (Select Nothing if you want to add link or button manually - in template file)</span>380 <td><?php $this->select('add_what', $this->defaults['add_what_options'], $this->get_option('add_what')); ?><span> (Select Nothing if you want to add link or button manually - in template file)</span> 328 381 </td> 329 382 </tr> 330 383 <tr> 331 384 <th scope="row">Add after element</th> 332 <td><?php $this->input('add_after', $this->get_option('add_after', $this->defaults['add_after_option'])); ?></td> 385 <td><?php $this->input('add_after', $this->get_option('add_after')); ?></td> 386 </tr> 387 <tr> 388 <th scope="row">Date / Time format</th> 389 <td><?php $this->select('date_format', $this->defaults['date_format_options'], $this->get_option('date_format')); ?></td> 333 390 </tr> 334 391 <tr> 335 392 <th scope="row"> </th> 336 <td><label for="require_login"><? $this->checkbox('require_login', $this->get_option('require_login' , $this->defaults['require_login'])); ?> Require user to be logged in to report</label></td>393 <td><label for="require_login"><? $this->checkbox('require_login', $this->get_option('require_login')); ?> Require user to be logged in to report</label></td> 337 394 </tr> 338 395 </table> … … 412 469 die(); 413 470 } 414 $data = array('user_id'=>get_current_user_id(), 'email'=>$_POST['report_post_email'], 'name'=>$_POST['report_post_name'], 'msg'=>$_POST['report_post_msg'], 'post_id'=>$_POST['report_post_id']); 471 $data = array 472 ( 473 'user_id'=>get_current_user_id(), 474 'email' => $_POST['report_post_email'], 475 'name' => $_POST['report_post_name'], 476 'msg' => $_POST['report_post_msg'], 477 'post_id' => $_POST['report_post_id'], 478 'timestamp' => current_time('timestamp') 479 ); 415 480 $reports = get_post_meta($_POST['report_post_id'], '_wp_report_post', true); 416 481 if (is_array($reports)) … … 563 628 { 564 629 var $DOMAIN; 630 var $options, $defaults; 565 631 function __construct() 566 632 { 567 633 global $status, $page; 568 $this->DOMAIN = $_wp_report_post_2->DOMAIN;569 634 parent::__construct( array( 570 635 'singular' => 'reported_posts', … … 574 639 } 575 640 // 641 function time_elapsed_string($ptime) 642 { 643 $etime = current_time('timestamp') - $ptime; 644 if ($etime < 1) 645 { 646 return 'just now'; 647 } 648 $a = array 649 ( 650 365 * 24 * 60 * 60 => 'year', 651 30 * 24 * 60 * 60 => 'month', 652 24 * 60 * 60 => 'day', 653 60 * 60 => 'hour', 654 60 => 'minute', 655 1 => 'second' 656 ); 657 $a_plural = array 658 ( 659 'year' => 'years', 660 'month' => 'months', 661 'day' => 'days', 662 'hour' => 'hours', 663 'minute' => 'minutes', 664 'second' => 'seconds' 665 ); 666 foreach ($a as $secs => $str) 667 { 668 $d = $etime / $secs; 669 if ($d >= 1) 670 { 671 $r = round($d); 672 return $r . ' ' . ($r > 1 ? $a_plural[$str] : $str) . ' ago'; 673 } 674 } 675 } 676 // 677 function format_timestamp($ts) 678 { 679 $date_format = isset($this->options['date_format']) ? $this->options['date_format'] : $this->defaults['date_format']; 680 if ($date_format == 'human') 681 { 682 return $this->time_elapsed_string($ts); 683 } 684 return date(get_option('date_format'). ', '. get_option('time_format'), intval($ts)); 685 } 686 // 576 687 function format_reports($reports) 577 688 { … … 582 693 foreach ($rep as $row) 583 694 { 584 $html .= '<a href="#" title="Click to view report" class="report-user-row">'. $row['name']. ' <'. $row['email']. '></a> <br />';695 $html .= '<a href="#" title="Click to view report" class="report-user-row">'. $row['name']. ' <'. $row['email']. '></a> ('. $this->format_timestamp($row['timestamp']). ')<br />'; 585 696 $html .= '<div class="report-user-hidden">'. esc_html($row['msg']); 586 697 $html .= ' <a href="#" class="report-user-hide-link">Hide</a>'; … … 729 840 { 730 841 global $wpdb; 731 $per_page = 5;842 $per_page = 25; 732 843 $columns = $this->get_columns(); 733 844 $hidden = array();
Note: See TracChangeset
for help on using the changeset viewer.