Changeset 7378 for trunk/src/includes/replies/functions.php
- Timestamp:
- 11/22/2025 06:05:25 AM (7 months ago)
- File:
-
- 1 edited
-
trunk/src/includes/replies/functions.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/replies/functions.php
r7374 r7378 25 25 26 26 // Parse arguments against default values 27 $reply_data = bbp_parse_args( $reply_data, array( 28 'post_parent' => 0, // topic ID 29 'post_type' => bbp_get_reply_post_type(), 30 'post_author' => bbp_get_current_user_id(), 31 'post_password' => '', 32 'post_content' => '', 33 'post_title' => '', 34 'menu_order' => bbp_get_topic_reply_count( $reply_data['post_parent'], true ) + 1, 35 'comment_status' => 'closed' 36 ), 'insert_reply' ); 27 $reply_data = bbp_parse_args( 28 $reply_data, 29 array( 30 'post_parent' => 0, // topic ID 31 'post_type' => bbp_get_reply_post_type(), 32 'post_author' => bbp_get_current_user_id(), 33 'post_password' => '', 34 'post_content' => '', 35 'post_title' => '', 36 'menu_order' => bbp_get_topic_reply_count( $reply_data['post_parent'], true ) + 1, 37 'comment_status' => 'closed' 38 ), 39 'insert_reply' 40 ); 37 41 38 42 // Possibly override status based on parent topic … … 50 54 51 55 // Parse arguments against default values 52 $reply_meta = bbp_parse_args( $reply_meta, array( 53 'author_ip' => bbp_current_author_ip(), 54 'forum_id' => 0, 55 'topic_id' => 0, 56 'reply_to' => 0 57 ), 'insert_reply_meta' ); 56 $reply_meta = bbp_parse_args( 57 $reply_meta, 58 array( 59 'author_ip' => bbp_current_author_ip(), 60 'forum_id' => 0, 61 'topic_id' => 0, 62 'reply_to' => 0 63 ), 64 'insert_reply_meta' 65 ); 58 66 59 67 // Insert reply meta … … 395 403 // Add the content of the form to $reply_data as an array 396 404 // Just in time manipulation of reply data before being created 397 $reply_data = apply_filters( 'bbp_new_reply_pre_insert', array( 398 'post_author' => $reply_author, 399 'post_title' => $reply_title, 400 'post_content' => $reply_content, 401 'post_status' => $reply_status, 402 'post_parent' => $topic_id, 403 'post_type' => bbp_get_reply_post_type(), 404 'comment_status' => 'closed', 405 'menu_order' => bbp_get_topic_reply_count( $topic_id, true ) + 1 406 ) ); 405 $reply_data = apply_filters( 406 'bbp_new_reply_pre_insert', 407 array( 408 'post_author' => $reply_author, 409 'post_title' => $reply_title, 410 'post_content' => $reply_content, 411 'post_status' => $reply_status, 412 'post_parent' => $topic_id, 413 'post_type' => bbp_get_reply_post_type(), 414 'comment_status' => 'closed', 415 'menu_order' => bbp_get_topic_reply_count( $topic_id, true ) + 1 416 ) 417 ); 407 418 408 419 // Insert reply … … 737 748 // Add the content of the form to $reply_data as an array 738 749 // Just in time manipulation of reply data before being edited 739 $reply_data = apply_filters( 'bbp_edit_reply_pre_insert', array( 740 'ID' => $reply_id, 741 'post_title' => $reply_title, 742 'post_content' => $reply_content, 743 'post_status' => $reply_status, 744 'post_parent' => $topic_id, 745 'post_author' => $reply_author, 746 'post_type' => bbp_get_reply_post_type() 747 ) ); 750 $reply_data = apply_filters( 751 'bbp_edit_reply_pre_insert', 752 array( 753 'ID' => $reply_id, 754 'post_title' => $reply_title, 755 'post_content' => $reply_content, 756 'post_status' => $reply_status, 757 'post_parent' => $topic_id, 758 'post_author' => $reply_author, 759 'post_type' => bbp_get_reply_post_type() 760 ) 761 ); 748 762 749 763 // Toggle revisions to avoid duplicates … … 793 807 $revision_id = wp_save_post_revision( $reply_id ); 794 808 if ( ! empty( $revision_id ) ) { 795 bbp_update_reply_revision_log( array( 796 'reply_id' => $reply_id, 797 'revision_id' => $revision_id, 798 'author_id' => bbp_get_current_user_id(), 799 'reason' => $reply_edit_reason 800 ) ); 809 bbp_update_reply_revision_log( 810 array( 811 'reply_id' => $reply_id, 812 'revision_id' => $revision_id, 813 'author_id' => bbp_get_current_user_id(), 814 'reason' => $reply_edit_reason 815 ) 816 ); 801 817 } 802 818 } … … 987 1003 988 1004 // Reply meta relating to most recent reply 1005 // phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedIf 989 1006 if ( bbp_is_reply( $ancestor ) ) { 990 1007 // @todo - hierarchical replies … … 1198 1215 1199 1216 // Get parent reply 1217 // phpcs:ignore Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition 1200 1218 while ( $ancestor = bbp_get_reply( $id ) ) { 1201 1219 … … 1232 1250 1233 1251 // Parse arguments against default values 1234 $r = bbp_parse_args( $args, array( 1235 'reason' => '', 1236 'reply_id' => 0, 1237 'author_id' => 0, 1238 'revision_id' => 0 1239 ), 'update_reply_revision_log' ); 1252 $r = bbp_parse_args( 1253 $args, 1254 array( 1255 'reason' => '', 1256 'reply_id' => 0, 1257 'author_id' => 0, 1258 'revision_id' => 0 1259 ), 1260 'update_reply_revision_log' 1261 ); 1240 1262 1241 1263 // Populate the variables … … 1358 1380 1359 1381 // Update the reply 1360 wp_update_post( array( 1361 'ID' => $move_reply->ID, 1362 'post_title' => '', 1363 'post_name' => false, // will be automatically generated 1364 'post_parent' => $destination_topic->ID, 1365 'menu_order' => $reply_position, 1366 'guid' => '' 1367 ) ); 1382 wp_update_post( 1383 array( 1384 'ID' => $move_reply->ID, 1385 'post_title' => '', 1386 'post_name' => false, // will be automatically generated 1387 'post_parent' => $destination_topic->ID, 1388 'menu_order' => $reply_position, 1389 'guid' => '' 1390 ) 1391 ); 1368 1392 1369 1393 // Adjust reply meta values … … 1390 1414 1391 1415 // Update the topic 1392 $destination_topic_id = wp_update_post( array( 1393 'ID' => $move_reply->ID, 1394 'post_title' => $destination_topic_title, 1395 'post_name' => false, 1396 'post_type' => bbp_get_topic_post_type(), 1397 'post_parent' => $source_topic->post_parent, 1398 'guid' => '' 1399 ) ); 1416 $destination_topic_id = wp_update_post( 1417 array( 1418 'ID' => $move_reply->ID, 1419 'post_title' => $destination_topic_title, 1420 'post_name' => false, 1421 'post_type' => bbp_get_topic_post_type(), 1422 'post_parent' => $source_topic->post_parent, 1423 'guid' => '' 1424 ) 1425 ); 1426 1427 // Get the topic 1400 1428 $destination_topic = bbp_get_topic( $destination_topic_id ); 1401 1429 … … 1433 1461 1434 1462 // Set destination topic post_date to 1 second before from reply 1463 // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date 1435 1464 $destination_post_date = date( 'Y-m-d H:i:s', strtotime( $move_reply->post_date ) - 1 ); 1436 1465 1437 1466 // Update destination topic 1438 wp_update_post( array( 1439 'ID' => $destination_topic_id, 1440 'post_date' => $destination_post_date, 1441 'post_date_gmt' => get_gmt_from_date( $destination_post_date ) 1442 ) ); 1467 wp_update_post( 1468 array( 1469 'ID' => $destination_topic_id, 1470 'post_date' => $destination_post_date, 1471 'post_date_gmt' => get_gmt_from_date( $destination_post_date ) 1472 ) 1473 ); 1443 1474 } 1444 1475 … … 1451 1482 1452 1483 // Fix orphaned children 1453 $children = get_posts( array( 1454 'post_type' => bbp_get_reply_post_type(), 1455 'meta_key' => '_bbp_reply_to', 1456 'meta_type' => 'NUMERIC', 1457 'meta_value' => $move_reply->ID, 1458 ) ); 1484 $children = get_posts( 1485 array( 1486 'post_type' => bbp_get_reply_post_type(), 1487 'meta_key' => '_bbp_reply_to', 1488 'meta_type' => 'NUMERIC', 1489 'meta_value' => $move_reply->ID, 1490 ) 1491 ); 1492 1459 1493 foreach ( $children as $child ) { 1460 1494 bbp_update_reply_to( $child->ID, $parent ); … … 1577 1611 1578 1612 // Do the reply toggling 1579 $retval = bbp_toggle_reply( array( 1580 'id' => $reply_id, 1581 'action' => $action, 1582 'sub_action' => $sub_action, 1583 'data' => $post_data 1584 ) ); 1613 $retval = bbp_toggle_reply( 1614 array( 1615 'id' => $reply_id, 1616 'action' => $action, 1617 'sub_action' => $sub_action, 1618 'data' => $post_data 1619 ) 1620 ); 1585 1621 1586 1622 // Do additional reply toggle actions … … 1613 1649 1614 1650 // Parse the arguments 1615 $r = bbp_parse_args( $args, array( 1616 'id' => 0, 1617 'action' => '', 1618 'sub_action' => '', 1619 'data' => array() 1620 ) ); 1651 $r = bbp_parse_args( 1652 $args, 1653 array( 1654 'id' => 0, 1655 'action' => '', 1656 'sub_action' => '', 1657 'data' => array() 1658 ) 1659 ); 1621 1660 1622 1661 // Build the nonce suffix … … 1713 1752 1714 1753 // Filter & return 1715 return (array) apply_filters( 'bbp_get_reply_statuses', array( 1716 bbp_get_public_status_id() => _x( 'Publish', 'Publish the reply', 'bbpress' ), 1717 bbp_get_spam_status_id() => _x( 'Spam', 'Spam the reply', 'bbpress' ), 1718 bbp_get_trash_status_id() => _x( 'Trash', 'Trash the reply', 'bbpress' ), 1719 bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' ) 1720 ), $reply_id ); 1754 return (array) apply_filters( 1755 'bbp_get_reply_statuses', 1756 array( 1757 bbp_get_public_status_id() => _x( 'Publish', 'Publish the reply', 'bbpress' ), 1758 bbp_get_spam_status_id() => _x( 'Spam', 'Spam the reply', 'bbpress' ), 1759 bbp_get_trash_status_id() => _x( 'Trash', 'Trash the reply', 'bbpress' ), 1760 bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' ) 1761 ), 1762 $reply_id 1763 ); 1721 1764 } 1722 1765 … … 1733 1776 1734 1777 // Filter & return 1735 return (array) apply_filters( 'bbp_get_toggle_reply_actions', array( 1736 'bbp_toggle_reply_spam', 1737 'bbp_toggle_reply_trash', 1738 'bbp_toggle_reply_approve' 1739 ), $reply_id ); 1778 return (array) apply_filters( 1779 'bbp_get_toggle_reply_actions', 1780 array( 1781 'bbp_toggle_reply_spam', 1782 'bbp_toggle_reply_trash', 1783 'bbp_toggle_reply_approve' 1784 ), 1785 $reply_id 1786 ); 1740 1787 } 1741 1788 … … 2230 2277 <link><?php self_link(); ?></link> 2231 2278 <description><?php //?></description><?php // phpcs:ignore ?> 2232 <lastBuildDate><?php echo date( 'r' ); ?></lastBuildDate>2279 <lastBuildDate><?php echo get_feed_build_date( 'r' ); ?></lastBuildDate> 2233 2280 <generator><?php echo esc_url_raw( 'https://bbpress.org/?v=' . convert_chars( bbp_get_version() ) ); ?></generator> 2234 2281 <language><?php bloginfo_rss( 'language' ); ?></language> … … 2255 2302 __( 'Replies: %s', 'bbpress' ), 2256 2303 bbp_get_topic_reply_count() 2257 );2304 ); 2258 2305 ?> 2259 2306 </p> … … 2420 2467 // Reverse replies array and search for current reply position 2421 2468 $topic_replies = array_reverse( $topic_replies ); 2422 $reply_position = array_search( (string) $reply_id, $topic_replies);2469 $reply_position = array_search( $reply_id, $topic_replies, true ); 2423 2470 2424 2471 // Bump the position to compensate for the lead topic post 2425 $reply_position++;2472 ++$reply_position; 2426 2473 } 2427 2474 } … … 2476 2523 2477 2524 // Parse arguments 2478 $r = bbp_parse_args( $args, array( 2479 'walker' => new BBP_Walker_Reply(), 2480 'max_depth' => bbp_thread_replies_depth(), 2481 'style' => 'ul', 2482 'callback' => null, 2483 'end_callback' => null, 2484 'page' => 1, 2485 'per_page' => -1 2486 ), 'list_replies' ); 2525 $r = bbp_parse_args( 2526 $args, 2527 array( 2528 'walker' => new BBP_Walker_Reply(), 2529 'max_depth' => bbp_thread_replies_depth(), 2530 'style' => 'ul', 2531 'callback' => null, 2532 'end_callback' => null, 2533 'page' => 1, 2534 'per_page' => -1 2535 ), 2536 'list_replies' 2537 ); 2487 2538 2488 2539 // Allowed styles (supported by BBP_Walker_Reply)
Note: See TracChangeset
for help on using the changeset viewer.