Plugin Directory

Changeset 969174


Ignore:
Timestamp:
08/20/2014 07:10:08 PM (12 years ago)
Author:
george_michael
Message:

adding v 1.3 with new features and screenshots

Location:
suggest-review
Files:
2 added
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • suggest-review/tags/1.3.0/readme.txt

    r959971 r969174  
    44Tags:
    55Requires at least: 3.5.2
    6 Tested up to: 3.9.1
    7 Stable tag: 1.2.5
     6Tested up to: 3.9.2
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2121* Can also be configured to put the last update date to the end of each post.
    2222* Exclude the suggest review button by IDs of pages, posts
     23* There is a page in the dashboard that lists all of the content that has been flagged for review (that the current user can access)
    2324
    2425Neither the mark for review button or last update date will appear on list of post pages or search results.
     
    45464. When editing a post, if it has been suggested for review, this meta box will appear. The checkbox is automatically checked; the assumption is that you are editing the content to resolve a review suggestion. Also note the radio button that allows you to exclude a post while you are editing, rather than entering them directly into the admin options.
    46475. Options page.
     486. Dashboard page to list flagged posts.
     497. Admins see the settings and post list in the dashboard.
    4750
    4851== Changelog ==
     52
     53= 1.3.0 =
     54* Added option to not display comment on posts.
     55* Added dashboard page that lists all flagged posts (that the current user has access to).
    4956
    5057= 1.2.5 =
     
    8188== Upgrade Notice ==
    8289
     90= 1.3.0 =
     91New features. Upgrade recommended, but not required.
     92
    8393= 1.2.5 =
    8494Bug fix. Upgrade recommended.
  • suggest-review/tags/1.3.0/suggest-review.php

    r959971 r969174  
    22/**
    33 * @package Suggest_Review
    4  * @version 1.2.5
     4 * @version 1.3.0
    55 */
    66/*
     
    99Description: Lets users suggest that content may need to be reviewed or re-examined.
    1010Author: Michael George
    11 Version: 1.2.5
     11Version: 1.3.0
    1212
    1313    This program is free software; you can redistribute it and/or modify
     
    5151                ,'add_update_date_to_posts' => 1 // 1 for yes, 2 for yes if not excluded, 0 for no. Since 1.2.3
    5252                ,'footer_alignment' => 'left' // since 1.2.4
     53                ,'show_comment' => 1 // since 1.3.0. Whether or not to show comments on post when flagged
    5354                ,'excluded_ids' => ''
    5455                ,'address_for_digest_email' => ''
     
    8081                $authoremail = get_the_author_meta('user_email');
    8182                wp_mail( $authoremail
    82                     ,replaceTokens( $devOptions['subject_for_email_to_author'], $post_id )
    83                     ,replaceTokens( $devOptions['body_for_email_to_author'], $post_id ) );
     83                    ,suggestReview_replaceTokens( $devOptions['subject_for_email_to_author'], $post_id )
     84                    ,suggestReview_replaceTokens( $devOptions['body_for_email_to_author'], $post_id ) );
    8485            }
    8586            return true;
     
    135136                    $return .= ' on ';
    136137                    $return .= $markedbydate[0];
    137                     $return .= '<br>Comment: <em>';
    138                     $return .= $markedbycomment[0];
    139                     $return .= '</em></p>';
     138                    if ( $devOptions['show_comment'] ) {
     139                        $return .= '<br>Comment: <em>';
     140                        $return .= $markedbycomment[0];
     141                        $return .= '</em>';
     142                    }
     143                    $return .= '</p>';
    140144                //If not marked for review
    141145                } else {
     
    327331        }
    328332
    329         //Prints out the admin page
     333        //Prints out the admin settings page
    330334        //Since 1.0.0
    331         function printAdminPage() {
     335        //Renamed in 1.3.0 from printAdminPage to printSettingsPage as there are now 2 admin pages
     336        function printSettingsPage() {
    332337
    333338            $devOptions = $this->getAdminOptions();
     
    351356                if ( isset($_POST['suggestReviewFooterAlignment']) ) {
    352357                    $devOptions['footer_alignment'] = $_POST['suggestReviewFooterAlignment'];
     358                }
     359                if ( isset($_POST['suggestReviewShowComment']) ) {
     360                    $devOptions['show_comment'] = ( $_POST['suggestReviewShowComment'] == 'true' ? 1 : 0 );
    353361                }
    354362                if ( isset($_POST['suggestReviewIDsToExclude']) ) {
     
    397405    <p style="margin-top:0"><label for="suggestReviewAddUpdateDate_yes"><input type="radio" id="suggestReviewAddUpdateDate_yes" name="suggestReviewAddUpdateDate" value="1" <?php if ($devOptions['add_update_date_to_posts'] == 1) { _e('checked="checked"', "SuggestReview"); }?> /> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewAddUpdateDate_yesifnot"><input type="radio" id="suggestReviewAddUpdateDate_yesifnot" name="suggestReviewAddUpdateDate" value="2" <?php if ($devOptions['add_update_date_to_posts'] == 2) { _e('checked="checked"', "SuggestReview"); }?> /> Yes, if not in exclusion list</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewAddUpdateDate_no"><input type="radio" id="suggestReviewAddUpdateDate_no" name="suggestReviewAddUpdateDate" value="0" <?php if ($devOptions['add_update_date_to_posts'] == 0) { _e('checked="checked"', "SuggestReview"); }?>/> No</label></p>
    398406
    399     <h3 style="margin-bottom:0">Footer Alignment (affects last update date and button)</h3>
     407    <h3 style="margin-bottom:0">Footer alignment (affects last update date and button)</h3>
    400408    <p style="margin-top:0"><label for="suggestReviewFooterAlignment_left"><input type="radio" id="suggestReviewFooterAlignment_left" name="suggestReviewFooterAlignment" value="left" <?php if ($devOptions['footer_alignment'] == 'left') { _e('checked="checked"', "SuggestReview"); }?> /> Left</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewFooterAlignment_center"><input type="radio" id="suggestReviewFooterAlignment_center" name="suggestReviewFooterAlignment" value="center" <?php if ($devOptions['footer_alignment'] == 'center') { _e('checked="checked"', "SuggestReview"); }?> /> Center</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewFooterAlignment_right"><input type="radio" id="suggestReviewFooterAlignment_right" name="suggestReviewFooterAlignment" value="right" <?php if ($devOptions['footer_alignment'] == 'right') { _e('checked="checked"', "SuggestReview"); }?>/> Right</label></p>
     409
     410    <h3 style="margin-bottom:0">Show comment on post when flagged</h3>
     411    <p style="margin-top:0"><label for="suggestReviewShowComment_yes"><input type="radio" id="suggestReviewShowComment_yes" name="suggestReviewShowComment" value="true" <?php if ($devOptions['show_comment'] ) { _e('checked="checked"', "SuggestReview"); }?> /> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewShowComment_no"><input type="radio" id="suggestReviewShowComment_no" name="suggestReviewShowComment" value="false" <?php if ( ! $devOptions['show_comment'] ) { _e('checked="checked"', "SuggestReview"); }?>/> No</label></p>
    401412
    402413    <h3 style="margin-bottom:0">Page, post IDs to exclude</h3>
     
    455466
    456467                    <?php
    457         }//End function printAdminPage()
     468        }//End function printSettingsPage()
     469
     470        //Display the flagged posts page, which shows a user all the posts they have edit
     471        //access to that have been suggested for review
     472        //Since 1.3.0
     473        function printFlaggedPostsPage() {
     474            global $wpdb;
     475            $orderbyoptions = array( "postdate", "author", "srby", "srdate" );
     476            $orderby = ( isset( $_GET['srfporderby'] ) && in_array( $_GET['srfporderby'], $orderbyoptions ) ? $_GET['srfporderby'] : 'postdate' );
     477            $orderdir = ( isset( $_GET['srfporderdir'] ) && in_array( $_GET['srfporderdir'], array( "asc", "desc" ) ) ? $_GET['srfporderdir'] : 'desc' );
     478            $args = array(
     479                'orderby' => 'date'
     480                ,'order' => 'ASC'
     481                ,'meta_query' => array(
     482                    array(
     483                        'key' => 'suggestreview_needed'
     484                        ,'value' => 'true'
     485                        ,'compare' => 'LIKE'
     486                        )
     487                    )
     488                );
     489            $rows = query_posts( $args );
     490            if ( $rows ) {
     491                //echo "<!-- " . print_r( $rows, true ) . " -->\r";
     492                //Main array for holding results, others for sorting
     493                $sortedposts = array();
     494
     495                //building the array from the posts. makes for quick sorting later
     496                foreach ( $rows as $post ) {
     497                    setup_postdata( $post );
     498                    if ( current_user_can( 'edit_post', $post->ID ) ) {
     499                        $sortedposts[] = array(
     500                                "ID" => $post->ID
     501                                ,"post_title" => $post->post_title
     502                                ,"post_date" => strtotime( $post->post_date )
     503                                ,"author" => get_user_by( 'id', $post->post_author )->user_login
     504                                ,"srby" => get_post_meta( $post->ID, 'suggestreview_by', true )
     505                                ,"srcom" => get_post_meta( $post->ID, 'suggestreview_comment', true )
     506                                ,"srdate" => strtotime( get_post_meta( $post->ID, 'suggestreview_date', true ) )
     507                                );
     508                    }
     509                }
     510
     511                //Sort it. Why not sort in the query you ask? Well, some of the meta data doesn't exist
     512                //at that point, so we can't.
     513                $postdates = array();
     514                $authors = array();
     515                $srbys = array();
     516                $srdates = array();
     517                foreach ( $sortedposts as $key => $row ) {
     518                    $postdates[$key] = $row['post_date'];
     519                    $authors[$key] = $row['author'];
     520                    $srbys[$key] = $row['srby'];
     521                    $srdates[$key] = $row['srdate'];
     522                }
     523                array_multisort( ( $orderby == 'postdate' ? $postdates :
     524                                    ( $orderby == 'author' ? $authors :
     525                                        ( $orderby == 'srby' ? $srbys :
     526                                            ( $orderby == 'srdate' ? $srdates : $postdates ) ) ) )
     527                                ,( $orderdir == 'asc' ? SORT_ASC : SORT_DESC )
     528                                ,$sortedposts );
     529            }
     530
     531            //Build the page, including the table of posts
     532            if ( count( $sortedposts ) > 0 ) {
     533                $baseURL = suggestReview_delArgFromURL( $_SERVER['REQUEST_URI'], array( 'srfporderby', 'srfporderdir' ) );
     534                echo "\r\t<div id='suggestreview_flaggedposts'>\r";
     535                echo "\t<style>\r";
     536                echo "\t\ttable { border-collapse: collapse; border: 1px solid black; }\r";
     537                echo "\t\ttable th, td { padding: 3px; }\r";
     538                echo "\t\t.tablerow { background-color: white; }\r";
     539                echo "\t\t.tablerowalt { background-color: #F0F0F0; }\r";
     540                echo "\t</style>\r";
     541                echo "\t\t<h2>Posts Flagged for Review</h2>\r";
     542                echo "\t\t<p>This page lists all of the posts you have access to that have been suggested for a review of their content.</p>\r";
     543                echo "\t\t<table border=1>\r";
     544                echo "\t\t\t<thead>\r";
     545                echo "\t\t\t\t<tr class='tablerow'><th style='text-align: left;'>Title</th>" .
     546                    "<th><a href='" . $baseURL . "&srfporderby=author&srfporderdir=" . ( $orderby == 'author' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Author</a>" . ( $orderby == 'author' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th>" .
     547                    "<th><a href='" . $baseURL . "&srfporderby=postdate&srfporderdir=" . ( $orderby == 'postdate' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Post Date</a>" . ( $orderby == 'postdate' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th>" .
     548                    "<th><a href='" . $baseURL . "&srfporderby=srby&srfporderdir=" . ( $orderby == 'srby' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Flagged By</a>" . ( $orderby == 'srby' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th>" .
     549                    "<th><a href='" . $baseURL . "&srfporderby=srdate&srfporderdir=" . ( $orderby == 'srdate' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Flagged On</a>" . ( $orderby == 'srdate' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th><tr>\r";
     550                echo "\t\t\t</thead>\r";
     551                echo "\t\t\t<tbody>\r";
     552                $i = 0;
     553                foreach ( $sortedposts as $post ) {
     554                    echo "\t\t\t\t<tr class='tablerow" . ( $i % 2 == 0 ? "alt" : "" ) . "'>" .
     555                        "<td><a href='" . get_permalink( $post['ID'] ) . "'>" . $post['post_title'] . "</a><br></td>" .
     556                        "<td>" . $post['author'] . "</td>" .
     557                        "<td>" . date( 'Y/m/d', $post['post_date'] ) . "</td>" .
     558                        "<td>" . $post['srby'] . "</td>" .
     559                        "<td>" . date( 'Y/m/d', $post['srdate'] ) . "</td></tr>\r";
     560                    $i++;
     561                }
     562                echo "\t\t\t</tbody>\r";
     563                echo "\t\t</table>\r";
     564                echo "\t</div>\r";
     565            }
     566
     567        }
     568
     569        //Add admin page(s) to dashboard
     570        //Since 1.3.0
     571        function adminMenu() {
     572            //If user is an admin, show all the options, otherwise just show the flagged posts page
     573            if ( current_user_can( 'manage_options' ) ) {
     574                add_menu_page( 'Suggest Review Settings', 'Suggest Review', 'manage_options', 'suggestreview_settings', array( $this, 'printSettingsPage' ), 'dashicons-flag' );
     575                add_submenu_page( 'suggestreview_settings', 'Suggest Review Settings', 'Settings', 'manage_options', 'suggestreview_settings', array( $this, 'printSettingsPage' ) );
     576                add_submenu_page( 'suggestreview_settings', 'Posts Suggested for Review', 'Flagged Posts', 'edit_posts', 'suggestreview_posts', array( $this, 'printFlaggedPostsPage' ) );
     577            } else {
     578                add_menu_page( 'Posts Suggested for Review', 'SR Flagged Posts', 'edit_posts', 'suggestreview_posts', array( $this, 'printFlaggedPostsPage' ), 'dashicons-flag' );
     579            }
     580        }
    458581
    459582    }
     
    464587}
    465588
    466 //Initialize the admin panel
    467 if ( ! function_exists( "suggestReview_ap" ) ) {
    468     function suggestReview_ap() {
    469         global $svvsd_suggestReview;
    470         if ( ! isset( $svvsd_suggestReview ) ) {
    471             return;
    472         }
    473         if ( function_exists( 'add_options_page' ) ) {
    474     add_options_page( 'Suggest Review', 'Suggest Review', 9, basename( __FILE__ ), array( &$svvsd_suggestReview, 'printAdminPage' ) );
    475         }
    476     }   
    477 }
    478 
    479 function add_markresolve_box() {
     589function suggestReview_addMarkresolveBox() {
    480590    add_meta_box(
    481591            'suggest_review_meta_box'
    482592            ,__( 'Resolve Suggest Review Flag' )
    483             ,'render_meta_box_content'
     593            ,'suggestReview_renderMetaBoxContent'
    484594            ,get_post_type( get_the_ID() )
    485595            ,'side'
     
    488598}
    489599
    490 function render_meta_box_content( $post ) {
     600function suggestReview_renderMetaBoxContent( $post ) {
    491601    global $svvsd_suggestReview;
    492602    $needsReview = get_post_meta( $post->ID, 'suggestreview_needed' );
     
    502612    $excludedIDs = explode( ',', $devOptions['exclude_ids']);
    503613    $excluded = in_array( $post->ID, $excludedIDs);
    504     echo '<p>Exclude from suggest review <label for="suggestReview_excludeflag_yes"><input type="radio" id="suggestReview_excludeflag_yes" name="suggestReview_excludeflag" value="true"';
     614    echo '<p>Exclude from SR? <input type="radio" id="suggestReview_excludeflag_yes" name="suggestReview_excludeflag" value="true"';
    505615    if ( $excluded ) {
    506616        echo ' checked';
    507617    }
    508     echo ' /> Yes </label>';
    509     echo '<label for="suggestReview_excludeflag_no"><input type="radio" id="suggestReview_excludeflag_no" name="suggestReview_excludeflag" value="false"';
     618    echo ' />Yes&nbsp;&nbsp;';
     619    echo '<input type="radio" id="suggestReview_excludeflag_no" name="suggestReview_excludeflag" value="false"';
    510620    if ( !$excluded ) {
    511621        echo ' checked';
    512622    }
    513     echo ' /> No</label></p>';
     623    echo ' />No</p>';
    514624    return true;
    515625}
     
    557667}
    558668
    559 function my_add_weekly( $schedules ) {
     669function suggestReview_addWeeklySchedule( $schedules ) {
    560670    // add a 'weekly' schedule to the existing set
    561671    $schedules['weekly'] = array(
     
    569679}
    570680
    571 function digest_email() {
     681function suggestReview_digestEmail() {
    572682    //Vars
    573683    global $wpdb;
     
    590700    if ( ! empty( $posts_for_digest ) ) {
    591701        //First part of body comes from options
    592         $body_string = replaceTokens( $devOptions['body_for_digest_email'], $post->ID );
     702        $body_string = suggestReview_replaceTokens( $devOptions['body_for_digest_email'], $post->ID );
    593703        $body_string .= '
    594704
     
    597707        foreach ( $posts_for_digest as $post ) {
    598708            setup_postdata( $post );
    599             $body_string .= replaceTokens( $devOptions['item_for_digest_email'], $post->ID );
     709            $body_string .= suggestReview_replaceTokens( $devOptions['item_for_digest_email'], $post->ID );
    600710            $body_string .= '
    601711
     
    615725//Replaces token variables in email templates
    616726//Since 1.1.0
    617 function replaceTokens( $text, $post_id ) {
     727function suggestReview_replaceTokens( $text, $post_id ) {
    618728    //Get meta
    619729    $marking_user_login = get_post_meta( $post_id, 'suggestreview_by');
     
    662772}
    663773
     774//Handy for monkeying with _GET parameters
     775function suggestReview_delArgFromURL ( $url, $in_arg ) {
     776    if ( ! is_array( $in_arg ) ) {
     777        $args = array( $in_arg );
     778    } else {
     779        $args = $in_arg;
     780    }
     781
     782    $pos = strrpos( $url, "?" ); // get the position of the last ? in the url
     783    $query_string_parts = array();
     784
     785    if ( $pos !== false ) {
     786        foreach ( explode( "&", substr( $url, $pos + 1 ) ) as $q ) {
     787            list( $key, $val ) = explode( "=", $q );
     788            //echo "<!-- key: $key value: $val -->\r";
     789            if ( ! in_array( $key, $args ) ) {
     790                // keep track of the parts that don't have arg3 as the key
     791                $query_string_parts[] = "$key=$val";
     792            }
     793        }
     794
     795        // rebuild the url
     796        $url = substr( $url, 0, $pos + 1 ) . join( $query_string_parts, '&' );
     797
     798        if ( strrpos( $url, "?" ) == strlen( $url ) - 1 ) {
     799            $url = strstr( $url, '?', true );
     800        }
     801    }
     802    //echo "<!-- result from delArgFromURL: $url -->\r";
     803    return $url;
     804}
     805
    664806//Actions and Filters
    665807if ( isset( $svvsd_suggestReview ) ) {
     
    669811    //Filters
    670812    add_filter( 'the_content', array( &$svvsd_suggestReview, 'content_insertion' ), 10 );
    671     add_filter( 'cron_schedules', 'my_add_weekly' );
     813    add_filter( 'cron_schedules', 'suggestReview_addWeeklySchedule' );
    672814    add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . 'suggest-review.php' ), array( &$svvsd_suggestReview, 'settings_link' ) );
    673815
    674816    //Actions
    675     add_action( 'admin_menu', 'suggestReview_ap' );
     817    add_action( 'admin_menu', array( &$svvsd_suggestReview, 'adminMenu' ) );
    676818    add_action( 'activate_suggest_review/suggest-review.php',  array( &$svvsd_suggestReview, 'init' ) );
    677     add_action( 'add_meta_boxes', 'add_markresolve_box' );
     819    add_action( 'add_meta_boxes', 'suggestReview_addMarkresolveBox' );
    678820    add_action( 'save_post', 'suggestReviewUpdatePost' );
    679     add_action( 'suggestreviewdigest', 'digest_email' );
     821    add_action( 'suggestreviewdigest', 'suggestReview_digestEmail' );
    680822    add_action( 'admin_footer-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_admin_footer' ) );
    681823    add_action( 'load-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_action' ) );
  • suggest-review/trunk/readme.txt

    r959971 r969174  
    44Tags:
    55Requires at least: 3.5.2
    6 Tested up to: 3.9.1
    7 Stable tag: 1.2.5
     6Tested up to: 3.9.2
     7Stable tag: 1.3.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2121* Can also be configured to put the last update date to the end of each post.
    2222* Exclude the suggest review button by IDs of pages, posts
     23* There is a page in the dashboard that lists all of the content that has been flagged for review (that the current user can access)
    2324
    2425Neither the mark for review button or last update date will appear on list of post pages or search results.
     
    45464. When editing a post, if it has been suggested for review, this meta box will appear. The checkbox is automatically checked; the assumption is that you are editing the content to resolve a review suggestion. Also note the radio button that allows you to exclude a post while you are editing, rather than entering them directly into the admin options.
    46475. Options page.
     486. Dashboard page to list flagged posts.
     497. Admins see the settings and post list in the dashboard.
    4750
    4851== Changelog ==
     52
     53= 1.3.0 =
     54* Added option to not display comment on posts.
     55* Added dashboard page that lists all flagged posts (that the current user has access to).
    4956
    5057= 1.2.5 =
     
    8188== Upgrade Notice ==
    8289
     90= 1.3.0 =
     91New features. Upgrade recommended, but not required.
     92
    8393= 1.2.5 =
    8494Bug fix. Upgrade recommended.
  • suggest-review/trunk/suggest-review.php

    r959971 r969174  
    22/**
    33 * @package Suggest_Review
    4  * @version 1.2.5
     4 * @version 1.3.0
    55 */
    66/*
     
    99Description: Lets users suggest that content may need to be reviewed or re-examined.
    1010Author: Michael George
    11 Version: 1.2.5
     11Version: 1.3.0
    1212
    1313    This program is free software; you can redistribute it and/or modify
     
    5151                ,'add_update_date_to_posts' => 1 // 1 for yes, 2 for yes if not excluded, 0 for no. Since 1.2.3
    5252                ,'footer_alignment' => 'left' // since 1.2.4
     53                ,'show_comment' => 1 // since 1.3.0. Whether or not to show comments on post when flagged
    5354                ,'excluded_ids' => ''
    5455                ,'address_for_digest_email' => ''
     
    8081                $authoremail = get_the_author_meta('user_email');
    8182                wp_mail( $authoremail
    82                     ,replaceTokens( $devOptions['subject_for_email_to_author'], $post_id )
    83                     ,replaceTokens( $devOptions['body_for_email_to_author'], $post_id ) );
     83                    ,suggestReview_replaceTokens( $devOptions['subject_for_email_to_author'], $post_id )
     84                    ,suggestReview_replaceTokens( $devOptions['body_for_email_to_author'], $post_id ) );
    8485            }
    8586            return true;
     
    135136                    $return .= ' on ';
    136137                    $return .= $markedbydate[0];
    137                     $return .= '<br>Comment: <em>';
    138                     $return .= $markedbycomment[0];
    139                     $return .= '</em></p>';
     138                    if ( $devOptions['show_comment'] ) {
     139                        $return .= '<br>Comment: <em>';
     140                        $return .= $markedbycomment[0];
     141                        $return .= '</em>';
     142                    }
     143                    $return .= '</p>';
    140144                //If not marked for review
    141145                } else {
     
    327331        }
    328332
    329         //Prints out the admin page
     333        //Prints out the admin settings page
    330334        //Since 1.0.0
    331         function printAdminPage() {
     335        //Renamed in 1.3.0 from printAdminPage to printSettingsPage as there are now 2 admin pages
     336        function printSettingsPage() {
    332337
    333338            $devOptions = $this->getAdminOptions();
     
    351356                if ( isset($_POST['suggestReviewFooterAlignment']) ) {
    352357                    $devOptions['footer_alignment'] = $_POST['suggestReviewFooterAlignment'];
     358                }
     359                if ( isset($_POST['suggestReviewShowComment']) ) {
     360                    $devOptions['show_comment'] = ( $_POST['suggestReviewShowComment'] == 'true' ? 1 : 0 );
    353361                }
    354362                if ( isset($_POST['suggestReviewIDsToExclude']) ) {
     
    397405    <p style="margin-top:0"><label for="suggestReviewAddUpdateDate_yes"><input type="radio" id="suggestReviewAddUpdateDate_yes" name="suggestReviewAddUpdateDate" value="1" <?php if ($devOptions['add_update_date_to_posts'] == 1) { _e('checked="checked"', "SuggestReview"); }?> /> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewAddUpdateDate_yesifnot"><input type="radio" id="suggestReviewAddUpdateDate_yesifnot" name="suggestReviewAddUpdateDate" value="2" <?php if ($devOptions['add_update_date_to_posts'] == 2) { _e('checked="checked"', "SuggestReview"); }?> /> Yes, if not in exclusion list</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewAddUpdateDate_no"><input type="radio" id="suggestReviewAddUpdateDate_no" name="suggestReviewAddUpdateDate" value="0" <?php if ($devOptions['add_update_date_to_posts'] == 0) { _e('checked="checked"', "SuggestReview"); }?>/> No</label></p>
    398406
    399     <h3 style="margin-bottom:0">Footer Alignment (affects last update date and button)</h3>
     407    <h3 style="margin-bottom:0">Footer alignment (affects last update date and button)</h3>
    400408    <p style="margin-top:0"><label for="suggestReviewFooterAlignment_left"><input type="radio" id="suggestReviewFooterAlignment_left" name="suggestReviewFooterAlignment" value="left" <?php if ($devOptions['footer_alignment'] == 'left') { _e('checked="checked"', "SuggestReview"); }?> /> Left</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewFooterAlignment_center"><input type="radio" id="suggestReviewFooterAlignment_center" name="suggestReviewFooterAlignment" value="center" <?php if ($devOptions['footer_alignment'] == 'center') { _e('checked="checked"', "SuggestReview"); }?> /> Center</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewFooterAlignment_right"><input type="radio" id="suggestReviewFooterAlignment_right" name="suggestReviewFooterAlignment" value="right" <?php if ($devOptions['footer_alignment'] == 'right') { _e('checked="checked"', "SuggestReview"); }?>/> Right</label></p>
     409
     410    <h3 style="margin-bottom:0">Show comment on post when flagged</h3>
     411    <p style="margin-top:0"><label for="suggestReviewShowComment_yes"><input type="radio" id="suggestReviewShowComment_yes" name="suggestReviewShowComment" value="true" <?php if ($devOptions['show_comment'] ) { _e('checked="checked"', "SuggestReview"); }?> /> Yes</label>&nbsp;&nbsp;&nbsp;&nbsp;<label for="suggestReviewShowComment_no"><input type="radio" id="suggestReviewShowComment_no" name="suggestReviewShowComment" value="false" <?php if ( ! $devOptions['show_comment'] ) { _e('checked="checked"', "SuggestReview"); }?>/> No</label></p>
    401412
    402413    <h3 style="margin-bottom:0">Page, post IDs to exclude</h3>
     
    455466
    456467                    <?php
    457         }//End function printAdminPage()
     468        }//End function printSettingsPage()
     469
     470        //Display the flagged posts page, which shows a user all the posts they have edit
     471        //access to that have been suggested for review
     472        //Since 1.3.0
     473        function printFlaggedPostsPage() {
     474            global $wpdb;
     475            $orderbyoptions = array( "postdate", "author", "srby", "srdate" );
     476            $orderby = ( isset( $_GET['srfporderby'] ) && in_array( $_GET['srfporderby'], $orderbyoptions ) ? $_GET['srfporderby'] : 'postdate' );
     477            $orderdir = ( isset( $_GET['srfporderdir'] ) && in_array( $_GET['srfporderdir'], array( "asc", "desc" ) ) ? $_GET['srfporderdir'] : 'desc' );
     478            $args = array(
     479                'orderby' => 'date'
     480                ,'order' => 'ASC'
     481                ,'meta_query' => array(
     482                    array(
     483                        'key' => 'suggestreview_needed'
     484                        ,'value' => 'true'
     485                        ,'compare' => 'LIKE'
     486                        )
     487                    )
     488                );
     489            $rows = query_posts( $args );
     490            if ( $rows ) {
     491                //echo "<!-- " . print_r( $rows, true ) . " -->\r";
     492                //Main array for holding results, others for sorting
     493                $sortedposts = array();
     494
     495                //building the array from the posts. makes for quick sorting later
     496                foreach ( $rows as $post ) {
     497                    setup_postdata( $post );
     498                    if ( current_user_can( 'edit_post', $post->ID ) ) {
     499                        $sortedposts[] = array(
     500                                "ID" => $post->ID
     501                                ,"post_title" => $post->post_title
     502                                ,"post_date" => strtotime( $post->post_date )
     503                                ,"author" => get_user_by( 'id', $post->post_author )->user_login
     504                                ,"srby" => get_post_meta( $post->ID, 'suggestreview_by', true )
     505                                ,"srcom" => get_post_meta( $post->ID, 'suggestreview_comment', true )
     506                                ,"srdate" => strtotime( get_post_meta( $post->ID, 'suggestreview_date', true ) )
     507                                );
     508                    }
     509                }
     510
     511                //Sort it. Why not sort in the query you ask? Well, some of the meta data doesn't exist
     512                //at that point, so we can't.
     513                $postdates = array();
     514                $authors = array();
     515                $srbys = array();
     516                $srdates = array();
     517                foreach ( $sortedposts as $key => $row ) {
     518                    $postdates[$key] = $row['post_date'];
     519                    $authors[$key] = $row['author'];
     520                    $srbys[$key] = $row['srby'];
     521                    $srdates[$key] = $row['srdate'];
     522                }
     523                array_multisort( ( $orderby == 'postdate' ? $postdates :
     524                                    ( $orderby == 'author' ? $authors :
     525                                        ( $orderby == 'srby' ? $srbys :
     526                                            ( $orderby == 'srdate' ? $srdates : $postdates ) ) ) )
     527                                ,( $orderdir == 'asc' ? SORT_ASC : SORT_DESC )
     528                                ,$sortedposts );
     529            }
     530
     531            //Build the page, including the table of posts
     532            if ( count( $sortedposts ) > 0 ) {
     533                $baseURL = suggestReview_delArgFromURL( $_SERVER['REQUEST_URI'], array( 'srfporderby', 'srfporderdir' ) );
     534                echo "\r\t<div id='suggestreview_flaggedposts'>\r";
     535                echo "\t<style>\r";
     536                echo "\t\ttable { border-collapse: collapse; border: 1px solid black; }\r";
     537                echo "\t\ttable th, td { padding: 3px; }\r";
     538                echo "\t\t.tablerow { background-color: white; }\r";
     539                echo "\t\t.tablerowalt { background-color: #F0F0F0; }\r";
     540                echo "\t</style>\r";
     541                echo "\t\t<h2>Posts Flagged for Review</h2>\r";
     542                echo "\t\t<p>This page lists all of the posts you have access to that have been suggested for a review of their content.</p>\r";
     543                echo "\t\t<table border=1>\r";
     544                echo "\t\t\t<thead>\r";
     545                echo "\t\t\t\t<tr class='tablerow'><th style='text-align: left;'>Title</th>" .
     546                    "<th><a href='" . $baseURL . "&srfporderby=author&srfporderdir=" . ( $orderby == 'author' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Author</a>" . ( $orderby == 'author' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th>" .
     547                    "<th><a href='" . $baseURL . "&srfporderby=postdate&srfporderdir=" . ( $orderby == 'postdate' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Post Date</a>" . ( $orderby == 'postdate' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th>" .
     548                    "<th><a href='" . $baseURL . "&srfporderby=srby&srfporderdir=" . ( $orderby == 'srby' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Flagged By</a>" . ( $orderby == 'srby' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th>" .
     549                    "<th><a href='" . $baseURL . "&srfporderby=srdate&srfporderdir=" . ( $orderby == 'srdate' && $orderdir == 'asc' ? "desc" : "asc" ) . "'>Flagged On</a>" . ( $orderby == 'srdate' ? "<div class='dashicons dashicons-arrow-" . ( $orderdir == 'asc' ? "down" : "up" ) . "'></div>" : "" ) . "</th><tr>\r";
     550                echo "\t\t\t</thead>\r";
     551                echo "\t\t\t<tbody>\r";
     552                $i = 0;
     553                foreach ( $sortedposts as $post ) {
     554                    echo "\t\t\t\t<tr class='tablerow" . ( $i % 2 == 0 ? "alt" : "" ) . "'>" .
     555                        "<td><a href='" . get_permalink( $post['ID'] ) . "'>" . $post['post_title'] . "</a><br></td>" .
     556                        "<td>" . $post['author'] . "</td>" .
     557                        "<td>" . date( 'Y/m/d', $post['post_date'] ) . "</td>" .
     558                        "<td>" . $post['srby'] . "</td>" .
     559                        "<td>" . date( 'Y/m/d', $post['srdate'] ) . "</td></tr>\r";
     560                    $i++;
     561                }
     562                echo "\t\t\t</tbody>\r";
     563                echo "\t\t</table>\r";
     564                echo "\t</div>\r";
     565            }
     566
     567        }
     568
     569        //Add admin page(s) to dashboard
     570        //Since 1.3.0
     571        function adminMenu() {
     572            //If user is an admin, show all the options, otherwise just show the flagged posts page
     573            if ( current_user_can( 'manage_options' ) ) {
     574                add_menu_page( 'Suggest Review Settings', 'Suggest Review', 'manage_options', 'suggestreview_settings', array( $this, 'printSettingsPage' ), 'dashicons-flag' );
     575                add_submenu_page( 'suggestreview_settings', 'Suggest Review Settings', 'Settings', 'manage_options', 'suggestreview_settings', array( $this, 'printSettingsPage' ) );
     576                add_submenu_page( 'suggestreview_settings', 'Posts Suggested for Review', 'Flagged Posts', 'edit_posts', 'suggestreview_posts', array( $this, 'printFlaggedPostsPage' ) );
     577            } else {
     578                add_menu_page( 'Posts Suggested for Review', 'SR Flagged Posts', 'edit_posts', 'suggestreview_posts', array( $this, 'printFlaggedPostsPage' ), 'dashicons-flag' );
     579            }
     580        }
    458581
    459582    }
     
    464587}
    465588
    466 //Initialize the admin panel
    467 if ( ! function_exists( "suggestReview_ap" ) ) {
    468     function suggestReview_ap() {
    469         global $svvsd_suggestReview;
    470         if ( ! isset( $svvsd_suggestReview ) ) {
    471             return;
    472         }
    473         if ( function_exists( 'add_options_page' ) ) {
    474     add_options_page( 'Suggest Review', 'Suggest Review', 9, basename( __FILE__ ), array( &$svvsd_suggestReview, 'printAdminPage' ) );
    475         }
    476     }   
    477 }
    478 
    479 function add_markresolve_box() {
     589function suggestReview_addMarkresolveBox() {
    480590    add_meta_box(
    481591            'suggest_review_meta_box'
    482592            ,__( 'Resolve Suggest Review Flag' )
    483             ,'render_meta_box_content'
     593            ,'suggestReview_renderMetaBoxContent'
    484594            ,get_post_type( get_the_ID() )
    485595            ,'side'
     
    488598}
    489599
    490 function render_meta_box_content( $post ) {
     600function suggestReview_renderMetaBoxContent( $post ) {
    491601    global $svvsd_suggestReview;
    492602    $needsReview = get_post_meta( $post->ID, 'suggestreview_needed' );
     
    502612    $excludedIDs = explode( ',', $devOptions['exclude_ids']);
    503613    $excluded = in_array( $post->ID, $excludedIDs);
    504     echo '<p>Exclude from suggest review <label for="suggestReview_excludeflag_yes"><input type="radio" id="suggestReview_excludeflag_yes" name="suggestReview_excludeflag" value="true"';
     614    echo '<p>Exclude from SR? <input type="radio" id="suggestReview_excludeflag_yes" name="suggestReview_excludeflag" value="true"';
    505615    if ( $excluded ) {
    506616        echo ' checked';
    507617    }
    508     echo ' /> Yes </label>';
    509     echo '<label for="suggestReview_excludeflag_no"><input type="radio" id="suggestReview_excludeflag_no" name="suggestReview_excludeflag" value="false"';
     618    echo ' />Yes&nbsp;&nbsp;';
     619    echo '<input type="radio" id="suggestReview_excludeflag_no" name="suggestReview_excludeflag" value="false"';
    510620    if ( !$excluded ) {
    511621        echo ' checked';
    512622    }
    513     echo ' /> No</label></p>';
     623    echo ' />No</p>';
    514624    return true;
    515625}
     
    557667}
    558668
    559 function my_add_weekly( $schedules ) {
     669function suggestReview_addWeeklySchedule( $schedules ) {
    560670    // add a 'weekly' schedule to the existing set
    561671    $schedules['weekly'] = array(
     
    569679}
    570680
    571 function digest_email() {
     681function suggestReview_digestEmail() {
    572682    //Vars
    573683    global $wpdb;
     
    590700    if ( ! empty( $posts_for_digest ) ) {
    591701        //First part of body comes from options
    592         $body_string = replaceTokens( $devOptions['body_for_digest_email'], $post->ID );
     702        $body_string = suggestReview_replaceTokens( $devOptions['body_for_digest_email'], $post->ID );
    593703        $body_string .= '
    594704
     
    597707        foreach ( $posts_for_digest as $post ) {
    598708            setup_postdata( $post );
    599             $body_string .= replaceTokens( $devOptions['item_for_digest_email'], $post->ID );
     709            $body_string .= suggestReview_replaceTokens( $devOptions['item_for_digest_email'], $post->ID );
    600710            $body_string .= '
    601711
     
    615725//Replaces token variables in email templates
    616726//Since 1.1.0
    617 function replaceTokens( $text, $post_id ) {
     727function suggestReview_replaceTokens( $text, $post_id ) {
    618728    //Get meta
    619729    $marking_user_login = get_post_meta( $post_id, 'suggestreview_by');
     
    662772}
    663773
     774//Handy for monkeying with _GET parameters
     775function suggestReview_delArgFromURL ( $url, $in_arg ) {
     776    if ( ! is_array( $in_arg ) ) {
     777        $args = array( $in_arg );
     778    } else {
     779        $args = $in_arg;
     780    }
     781
     782    $pos = strrpos( $url, "?" ); // get the position of the last ? in the url
     783    $query_string_parts = array();
     784
     785    if ( $pos !== false ) {
     786        foreach ( explode( "&", substr( $url, $pos + 1 ) ) as $q ) {
     787            list( $key, $val ) = explode( "=", $q );
     788            //echo "<!-- key: $key value: $val -->\r";
     789            if ( ! in_array( $key, $args ) ) {
     790                // keep track of the parts that don't have arg3 as the key
     791                $query_string_parts[] = "$key=$val";
     792            }
     793        }
     794
     795        // rebuild the url
     796        $url = substr( $url, 0, $pos + 1 ) . join( $query_string_parts, '&' );
     797
     798        if ( strrpos( $url, "?" ) == strlen( $url ) - 1 ) {
     799            $url = strstr( $url, '?', true );
     800        }
     801    }
     802    //echo "<!-- result from delArgFromURL: $url -->\r";
     803    return $url;
     804}
     805
    664806//Actions and Filters
    665807if ( isset( $svvsd_suggestReview ) ) {
     
    669811    //Filters
    670812    add_filter( 'the_content', array( &$svvsd_suggestReview, 'content_insertion' ), 10 );
    671     add_filter( 'cron_schedules', 'my_add_weekly' );
     813    add_filter( 'cron_schedules', 'suggestReview_addWeeklySchedule' );
    672814    add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . 'suggest-review.php' ), array( &$svvsd_suggestReview, 'settings_link' ) );
    673815
    674816    //Actions
    675     add_action( 'admin_menu', 'suggestReview_ap' );
     817    add_action( 'admin_menu', array( &$svvsd_suggestReview, 'adminMenu' ) );
    676818    add_action( 'activate_suggest_review/suggest-review.php',  array( &$svvsd_suggestReview, 'init' ) );
    677     add_action( 'add_meta_boxes', 'add_markresolve_box' );
     819    add_action( 'add_meta_boxes', 'suggestReview_addMarkresolveBox' );
    678820    add_action( 'save_post', 'suggestReviewUpdatePost' );
    679     add_action( 'suggestreviewdigest', 'digest_email' );
     821    add_action( 'suggestreviewdigest', 'suggestReview_digestEmail' );
    680822    add_action( 'admin_footer-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_admin_footer' ) );
    681823    add_action( 'load-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_action' ) );
Note: See TracChangeset for help on using the changeset viewer.