Plugin Directory

Changeset 1437718


Ignore:
Timestamp:
06/16/2016 10:40:04 AM (10 years ago)
Author:
esiteq
Message:

Version 2.0.2

Location:
wp-report-post/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-report-post/trunk/css/style.css

    r1437537 r1437718  
    9696width:10%;
    9797}
    98 .reported_post #meta_value,
    9998.reported_post #post_author {
    10099width:15%;
  • wp-report-post/trunk/readme.txt

    r1437544 r1437718  
    2424* Supports AJAXly loaded posts, 'infinite scroll' posts, etc.
    2525* 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
    2629
    2730Plugin demo: http://wp.esiteq.com/wordpress-report-post-plugin-demo/
     
    6770== Upgrade Notice ==
    6871
     72= 2.0.1 =
     73New version imports reports created by version 0.X so they are available again.
     74
    6975= 2.0 =
    7076Be 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.
     
    7278== Changelog ==
    7379
     80= 2.0.2 =
     81Added 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
    7487= 2.0 =
    7588Completely remastered. Well, this is not an update of previous version of the plugin. This is a new plugin written from scratch.
    7689
    7790= 0.2.4 =
    78 
    7991Fixed bug with incorrect link to attached image
    8092
    8193= 0.2.2 =
    82 
    8394Fixed bug with duplicate reports
    8495
    8596= 0.2.1 =
    86 
    8797Removed engine and encoding from CREATE TABLE query - default values will be used (in case if InnoDB is not supported on your hosting)
    8898
    8999= 0.2 =
    90 
    91100* Perverted AJAX calls were replaced in a normal Wordpress way
    92101* Added email notifications for reported posts
     
    95104
    96105= 0.1 =
    97 
    98106* CSS buttons added
    99107* Fixed textarea width
  • wp-report-post/trunk/wp-report-post.php

    r1437534 r1437718  
    88 * Author: Alex Raven
    99 * Company: ESITEQ
    10  * Version: 2.0
     10 * Version: 2.0.2
    1111 * Updated 2016-06-12
    1212 * Created 2013-09-22
     
    2727    var $defaults = array
    2828    (
     29        'date_format'      => 'human',
     30        'date_format_options' => array('human' => 'Human (e.g 5 minutes ago)', 'date' => 'Date / Time'),
    2931        'require_login'    => '0',
    3032        'add_what_options' => array(''=>'Nothing', 'link'=>'Link', 'button'=>'Button'),
     
    6466        'text_error'       => 'Error reporting'
    6567    );
     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    //
    66114    function enqueue_scripts()
    67115    {
     
    256304    function reported_posts()
    257305    {
     306        $this->import_old();
    258307        $reports = new WP_Report_Post_List();
     308        $reports->options = $this->options;
     309        $reports->defaults = $this->defaults;
     310        $reports->DOMAIN = $this->DOMAIN;
    259311        $reports->prepare_items();
    260312?>
     
    293345    function get_option($name, $default='')
    294346    {
     347        if ($default == '') $default = $this->defaults[$name];
    295348        return (isset($this->options[$name])) ? $this->options[$name] : $default;
    296349    }
     
    303356    function update_options()
    304357    {
    305         update_option('wp_report_post_options', $this->options);
     358        return update_option('wp_report_post_options', $this->options);
    306359    }
    307360    //
     
    325378        <tr>
    326379            <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>&nbsp;&nbsp;(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>&nbsp;&nbsp;(Select Nothing if you want to add link or button manually - in template file)</span>
    328381            </td>
    329382        </tr>
    330383        <tr>
    331384            <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>
    333390        </tr>
    334391        <tr>
    335392            <th scope="row">&nbsp;</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>
    337394        </tr>
    338395    </table>
     
    412469                die();
    413470            }
    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            );
    415480            $reports = get_post_meta($_POST['report_post_id'], '_wp_report_post', true);
    416481            if (is_array($reports))
     
    563628{
    564629    var $DOMAIN;
     630    var $options, $defaults;
    565631    function __construct()
    566632    {
    567633        global $status, $page;
    568         $this->DOMAIN = $_wp_report_post_2->DOMAIN;
    569634        parent::__construct( array(
    570635            'singular'  => 'reported_posts',
     
    574639    }
    575640    //
     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    //
    576687    function format_reports($reports)
    577688    {
     
    582693            foreach ($rep as $row)
    583694            {
    584                 $html .= '<a href="#" title="Click to view report" class="report-user-row">'. $row['name']. ' &lt;'. $row['email']. '&gt;</a><br />';
     695                $html .= '<a href="#" title="Click to view report" class="report-user-row">'. $row['name']. ' &lt;'. $row['email']. '&gt;</a> ('. $this->format_timestamp($row['timestamp']). ')<br />';
    585696                $html .= '<div class="report-user-hidden">'. esc_html($row['msg']);
    586697                $html .= ' <a href="#" class="report-user-hide-link">Hide</a>';
     
    729840    {
    730841        global $wpdb;
    731         $per_page = 5;
     842        $per_page = 25;
    732843        $columns = $this->get_columns();
    733844        $hidden = array();
Note: See TracChangeset for help on using the changeset viewer.