Changeset 969174
- Timestamp:
- 08/20/2014 07:10:08 PM (12 years ago)
- Location:
- suggest-review
- Files:
-
- 2 added
- 2 edited
- 3 copied
-
assets/screenshot-6.png (added)
-
assets/screenshot-7.png (added)
-
tags/1.3.0 (copied) (copied from suggest-review/trunk)
-
tags/1.3.0/readme.txt (copied) (copied from suggest-review/trunk/readme.txt) (4 diffs)
-
tags/1.3.0/suggest-review.php (copied) (copied from suggest-review/trunk/suggest-review.php) (19 diffs)
-
trunk/readme.txt (modified) (4 diffs)
-
trunk/suggest-review.php (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
suggest-review/tags/1.3.0/readme.txt
r959971 r969174 4 4 Tags: 5 5 Requires at least: 3.5.2 6 Tested up to: 3.9. 17 Stable tag: 1. 2.56 Tested up to: 3.9.2 7 Stable tag: 1.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 21 21 * Can also be configured to put the last update date to the end of each post. 22 22 * 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) 23 24 24 25 Neither the mark for review button or last update date will appear on list of post pages or search results. … … 45 46 4. 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. 46 47 5. Options page. 48 6. Dashboard page to list flagged posts. 49 7. Admins see the settings and post list in the dashboard. 47 50 48 51 == 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). 49 56 50 57 = 1.2.5 = … … 81 88 == Upgrade Notice == 82 89 90 = 1.3.0 = 91 New features. Upgrade recommended, but not required. 92 83 93 = 1.2.5 = 84 94 Bug fix. Upgrade recommended. -
suggest-review/tags/1.3.0/suggest-review.php
r959971 r969174 2 2 /** 3 3 * @package Suggest_Review 4 * @version 1. 2.54 * @version 1.3.0 5 5 */ 6 6 /* … … 9 9 Description: Lets users suggest that content may need to be reviewed or re-examined. 10 10 Author: Michael George 11 Version: 1. 2.511 Version: 1.3.0 12 12 13 13 This program is free software; you can redistribute it and/or modify … … 51 51 ,'add_update_date_to_posts' => 1 // 1 for yes, 2 for yes if not excluded, 0 for no. Since 1.2.3 52 52 ,'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 53 54 ,'excluded_ids' => '' 54 55 ,'address_for_digest_email' => '' … … 80 81 $authoremail = get_the_author_meta('user_email'); 81 82 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 ) ); 84 85 } 85 86 return true; … … 135 136 $return .= ' on '; 136 137 $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>'; 140 144 //If not marked for review 141 145 } else { … … 327 331 } 328 332 329 //Prints out the admin page333 //Prints out the admin settings page 330 334 //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() { 332 337 333 338 $devOptions = $this->getAdminOptions(); … … 351 356 if ( isset($_POST['suggestReviewFooterAlignment']) ) { 352 357 $devOptions['footer_alignment'] = $_POST['suggestReviewFooterAlignment']; 358 } 359 if ( isset($_POST['suggestReviewShowComment']) ) { 360 $devOptions['show_comment'] = ( $_POST['suggestReviewShowComment'] == 'true' ? 1 : 0 ); 353 361 } 354 362 if ( isset($_POST['suggestReviewIDsToExclude']) ) { … … 397 405 <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> <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> <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> 398 406 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> 400 408 <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> <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> <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> <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> 401 412 402 413 <h3 style="margin-bottom:0">Page, post IDs to exclude</h3> … … 455 466 456 467 <?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 } 458 581 459 582 } … … 464 587 } 465 588 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() { 589 function suggestReview_addMarkresolveBox() { 480 590 add_meta_box( 481 591 'suggest_review_meta_box' 482 592 ,__( 'Resolve Suggest Review Flag' ) 483 ,' render_meta_box_content'593 ,'suggestReview_renderMetaBoxContent' 484 594 ,get_post_type( get_the_ID() ) 485 595 ,'side' … … 488 598 } 489 599 490 function render_meta_box_content( $post ) {600 function suggestReview_renderMetaBoxContent( $post ) { 491 601 global $svvsd_suggestReview; 492 602 $needsReview = get_post_meta( $post->ID, 'suggestreview_needed' ); … … 502 612 $excludedIDs = explode( ',', $devOptions['exclude_ids']); 503 613 $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"'; 505 615 if ( $excluded ) { 506 616 echo ' checked'; 507 617 } 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 '; 619 echo '<input type="radio" id="suggestReview_excludeflag_no" name="suggestReview_excludeflag" value="false"'; 510 620 if ( !$excluded ) { 511 621 echo ' checked'; 512 622 } 513 echo ' /> No</label></p>';623 echo ' />No</p>'; 514 624 return true; 515 625 } … … 557 667 } 558 668 559 function my_add_weekly( $schedules ) {669 function suggestReview_addWeeklySchedule( $schedules ) { 560 670 // add a 'weekly' schedule to the existing set 561 671 $schedules['weekly'] = array( … … 569 679 } 570 680 571 function digest_email() {681 function suggestReview_digestEmail() { 572 682 //Vars 573 683 global $wpdb; … … 590 700 if ( ! empty( $posts_for_digest ) ) { 591 701 //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 ); 593 703 $body_string .= ' 594 704 … … 597 707 foreach ( $posts_for_digest as $post ) { 598 708 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 ); 600 710 $body_string .= ' 601 711 … … 615 725 //Replaces token variables in email templates 616 726 //Since 1.1.0 617 function replaceTokens( $text, $post_id ) {727 function suggestReview_replaceTokens( $text, $post_id ) { 618 728 //Get meta 619 729 $marking_user_login = get_post_meta( $post_id, 'suggestreview_by'); … … 662 772 } 663 773 774 //Handy for monkeying with _GET parameters 775 function 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 664 806 //Actions and Filters 665 807 if ( isset( $svvsd_suggestReview ) ) { … … 669 811 //Filters 670 812 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' ); 672 814 add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . 'suggest-review.php' ), array( &$svvsd_suggestReview, 'settings_link' ) ); 673 815 674 816 //Actions 675 add_action( 'admin_menu', 'suggestReview_ap');817 add_action( 'admin_menu', array( &$svvsd_suggestReview, 'adminMenu' ) ); 676 818 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' ); 678 820 add_action( 'save_post', 'suggestReviewUpdatePost' ); 679 add_action( 'suggestreviewdigest', ' digest_email' );821 add_action( 'suggestreviewdigest', 'suggestReview_digestEmail' ); 680 822 add_action( 'admin_footer-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_admin_footer' ) ); 681 823 add_action( 'load-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_action' ) ); -
suggest-review/trunk/readme.txt
r959971 r969174 4 4 Tags: 5 5 Requires at least: 3.5.2 6 Tested up to: 3.9. 17 Stable tag: 1. 2.56 Tested up to: 3.9.2 7 Stable tag: 1.3.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 21 21 * Can also be configured to put the last update date to the end of each post. 22 22 * 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) 23 24 24 25 Neither the mark for review button or last update date will appear on list of post pages or search results. … … 45 46 4. 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. 46 47 5. Options page. 48 6. Dashboard page to list flagged posts. 49 7. Admins see the settings and post list in the dashboard. 47 50 48 51 == 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). 49 56 50 57 = 1.2.5 = … … 81 88 == Upgrade Notice == 82 89 90 = 1.3.0 = 91 New features. Upgrade recommended, but not required. 92 83 93 = 1.2.5 = 84 94 Bug fix. Upgrade recommended. -
suggest-review/trunk/suggest-review.php
r959971 r969174 2 2 /** 3 3 * @package Suggest_Review 4 * @version 1. 2.54 * @version 1.3.0 5 5 */ 6 6 /* … … 9 9 Description: Lets users suggest that content may need to be reviewed or re-examined. 10 10 Author: Michael George 11 Version: 1. 2.511 Version: 1.3.0 12 12 13 13 This program is free software; you can redistribute it and/or modify … … 51 51 ,'add_update_date_to_posts' => 1 // 1 for yes, 2 for yes if not excluded, 0 for no. Since 1.2.3 52 52 ,'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 53 54 ,'excluded_ids' => '' 54 55 ,'address_for_digest_email' => '' … … 80 81 $authoremail = get_the_author_meta('user_email'); 81 82 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 ) ); 84 85 } 85 86 return true; … … 135 136 $return .= ' on '; 136 137 $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>'; 140 144 //If not marked for review 141 145 } else { … … 327 331 } 328 332 329 //Prints out the admin page333 //Prints out the admin settings page 330 334 //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() { 332 337 333 338 $devOptions = $this->getAdminOptions(); … … 351 356 if ( isset($_POST['suggestReviewFooterAlignment']) ) { 352 357 $devOptions['footer_alignment'] = $_POST['suggestReviewFooterAlignment']; 358 } 359 if ( isset($_POST['suggestReviewShowComment']) ) { 360 $devOptions['show_comment'] = ( $_POST['suggestReviewShowComment'] == 'true' ? 1 : 0 ); 353 361 } 354 362 if ( isset($_POST['suggestReviewIDsToExclude']) ) { … … 397 405 <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> <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> <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> 398 406 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> 400 408 <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> <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> <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> <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> 401 412 402 413 <h3 style="margin-bottom:0">Page, post IDs to exclude</h3> … … 455 466 456 467 <?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 } 458 581 459 582 } … … 464 587 } 465 588 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() { 589 function suggestReview_addMarkresolveBox() { 480 590 add_meta_box( 481 591 'suggest_review_meta_box' 482 592 ,__( 'Resolve Suggest Review Flag' ) 483 ,' render_meta_box_content'593 ,'suggestReview_renderMetaBoxContent' 484 594 ,get_post_type( get_the_ID() ) 485 595 ,'side' … … 488 598 } 489 599 490 function render_meta_box_content( $post ) {600 function suggestReview_renderMetaBoxContent( $post ) { 491 601 global $svvsd_suggestReview; 492 602 $needsReview = get_post_meta( $post->ID, 'suggestreview_needed' ); … … 502 612 $excludedIDs = explode( ',', $devOptions['exclude_ids']); 503 613 $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"'; 505 615 if ( $excluded ) { 506 616 echo ' checked'; 507 617 } 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 '; 619 echo '<input type="radio" id="suggestReview_excludeflag_no" name="suggestReview_excludeflag" value="false"'; 510 620 if ( !$excluded ) { 511 621 echo ' checked'; 512 622 } 513 echo ' /> No</label></p>';623 echo ' />No</p>'; 514 624 return true; 515 625 } … … 557 667 } 558 668 559 function my_add_weekly( $schedules ) {669 function suggestReview_addWeeklySchedule( $schedules ) { 560 670 // add a 'weekly' schedule to the existing set 561 671 $schedules['weekly'] = array( … … 569 679 } 570 680 571 function digest_email() {681 function suggestReview_digestEmail() { 572 682 //Vars 573 683 global $wpdb; … … 590 700 if ( ! empty( $posts_for_digest ) ) { 591 701 //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 ); 593 703 $body_string .= ' 594 704 … … 597 707 foreach ( $posts_for_digest as $post ) { 598 708 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 ); 600 710 $body_string .= ' 601 711 … … 615 725 //Replaces token variables in email templates 616 726 //Since 1.1.0 617 function replaceTokens( $text, $post_id ) {727 function suggestReview_replaceTokens( $text, $post_id ) { 618 728 //Get meta 619 729 $marking_user_login = get_post_meta( $post_id, 'suggestreview_by'); … … 662 772 } 663 773 774 //Handy for monkeying with _GET parameters 775 function 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 664 806 //Actions and Filters 665 807 if ( isset( $svvsd_suggestReview ) ) { … … 669 811 //Filters 670 812 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' ); 672 814 add_filter( 'plugin_action_links_' . plugin_basename( plugin_dir_path( __FILE__ ) . 'suggest-review.php' ), array( &$svvsd_suggestReview, 'settings_link' ) ); 673 815 674 816 //Actions 675 add_action( 'admin_menu', 'suggestReview_ap');817 add_action( 'admin_menu', array( &$svvsd_suggestReview, 'adminMenu' ) ); 676 818 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' ); 678 820 add_action( 'save_post', 'suggestReviewUpdatePost' ); 679 add_action( 'suggestreviewdigest', ' digest_email' );821 add_action( 'suggestreviewdigest', 'suggestReview_digestEmail' ); 680 822 add_action( 'admin_footer-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_admin_footer' ) ); 681 823 add_action( 'load-edit.php', array( &$svvsd_suggestReview, 'custom_bulk_action' ) );
Note: See TracChangeset
for help on using the changeset viewer.