Edit File by line
/home/barbar84/www/wp-inclu...
File: comment.php
delete_metadata_by_mid( 'comment', $mid );
[1500] Fix | Delete
}
[1501] Fix | Delete
[1502] Fix | Delete
if ( ! $wpdb->delete( $wpdb->comments, array( 'comment_ID' => $comment->comment_ID ) ) ) {
[1503] Fix | Delete
return false;
[1504] Fix | Delete
}
[1505] Fix | Delete
[1506] Fix | Delete
/**
[1507] Fix | Delete
* Fires immediately after a comment is deleted from the database.
[1508] Fix | Delete
*
[1509] Fix | Delete
* @since 2.9.0
[1510] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1511] Fix | Delete
*
[1512] Fix | Delete
* @param int $comment_id The comment ID.
[1513] Fix | Delete
* @param WP_Comment $comment The deleted comment.
[1514] Fix | Delete
*/
[1515] Fix | Delete
do_action( 'deleted_comment', $comment->comment_ID, $comment );
[1516] Fix | Delete
[1517] Fix | Delete
$post_id = $comment->comment_post_ID;
[1518] Fix | Delete
if ( $post_id && 1 == $comment->comment_approved ) {
[1519] Fix | Delete
wp_update_comment_count( $post_id );
[1520] Fix | Delete
}
[1521] Fix | Delete
[1522] Fix | Delete
clean_comment_cache( $comment->comment_ID );
[1523] Fix | Delete
[1524] Fix | Delete
/** This action is documented in wp-includes/comment.php */
[1525] Fix | Delete
do_action( 'wp_set_comment_status', $comment->comment_ID, 'delete' );
[1526] Fix | Delete
[1527] Fix | Delete
wp_transition_comment_status( 'delete', $comment->comment_approved, $comment );
[1528] Fix | Delete
[1529] Fix | Delete
return true;
[1530] Fix | Delete
}
[1531] Fix | Delete
[1532] Fix | Delete
/**
[1533] Fix | Delete
* Moves a comment to the Trash
[1534] Fix | Delete
*
[1535] Fix | Delete
* If Trash is disabled, comment is permanently deleted.
[1536] Fix | Delete
*
[1537] Fix | Delete
* @since 2.9.0
[1538] Fix | Delete
*
[1539] Fix | Delete
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
[1540] Fix | Delete
* @return bool True on success, false on failure.
[1541] Fix | Delete
*/
[1542] Fix | Delete
function wp_trash_comment( $comment_id ) {
[1543] Fix | Delete
if ( ! EMPTY_TRASH_DAYS ) {
[1544] Fix | Delete
return wp_delete_comment( $comment_id, true );
[1545] Fix | Delete
}
[1546] Fix | Delete
[1547] Fix | Delete
$comment = get_comment( $comment_id );
[1548] Fix | Delete
if ( ! $comment ) {
[1549] Fix | Delete
return false;
[1550] Fix | Delete
}
[1551] Fix | Delete
[1552] Fix | Delete
/**
[1553] Fix | Delete
* Fires immediately before a comment is sent to the Trash.
[1554] Fix | Delete
*
[1555] Fix | Delete
* @since 2.9.0
[1556] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1557] Fix | Delete
*
[1558] Fix | Delete
* @param int $comment_id The comment ID.
[1559] Fix | Delete
* @param WP_Comment $comment The comment to be trashed.
[1560] Fix | Delete
*/
[1561] Fix | Delete
do_action( 'trash_comment', $comment->comment_ID, $comment );
[1562] Fix | Delete
[1563] Fix | Delete
if ( wp_set_comment_status( $comment, 'trash' ) ) {
[1564] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
[1565] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
[1566] Fix | Delete
add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
[1567] Fix | Delete
add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() );
[1568] Fix | Delete
[1569] Fix | Delete
/**
[1570] Fix | Delete
* Fires immediately after a comment is sent to Trash.
[1571] Fix | Delete
*
[1572] Fix | Delete
* @since 2.9.0
[1573] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1574] Fix | Delete
*
[1575] Fix | Delete
* @param int $comment_id The comment ID.
[1576] Fix | Delete
* @param WP_Comment $comment The trashed comment.
[1577] Fix | Delete
*/
[1578] Fix | Delete
do_action( 'trashed_comment', $comment->comment_ID, $comment );
[1579] Fix | Delete
[1580] Fix | Delete
return true;
[1581] Fix | Delete
}
[1582] Fix | Delete
[1583] Fix | Delete
return false;
[1584] Fix | Delete
}
[1585] Fix | Delete
[1586] Fix | Delete
/**
[1587] Fix | Delete
* Removes a comment from the Trash
[1588] Fix | Delete
*
[1589] Fix | Delete
* @since 2.9.0
[1590] Fix | Delete
*
[1591] Fix | Delete
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
[1592] Fix | Delete
* @return bool True on success, false on failure.
[1593] Fix | Delete
*/
[1594] Fix | Delete
function wp_untrash_comment( $comment_id ) {
[1595] Fix | Delete
$comment = get_comment( $comment_id );
[1596] Fix | Delete
if ( ! $comment ) {
[1597] Fix | Delete
return false;
[1598] Fix | Delete
}
[1599] Fix | Delete
[1600] Fix | Delete
/**
[1601] Fix | Delete
* Fires immediately before a comment is restored from the Trash.
[1602] Fix | Delete
*
[1603] Fix | Delete
* @since 2.9.0
[1604] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1605] Fix | Delete
*
[1606] Fix | Delete
* @param int $comment_id The comment ID.
[1607] Fix | Delete
* @param WP_Comment $comment The comment to be untrashed.
[1608] Fix | Delete
*/
[1609] Fix | Delete
do_action( 'untrash_comment', $comment->comment_ID, $comment );
[1610] Fix | Delete
[1611] Fix | Delete
$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
[1612] Fix | Delete
if ( empty( $status ) ) {
[1613] Fix | Delete
$status = '0';
[1614] Fix | Delete
}
[1615] Fix | Delete
[1616] Fix | Delete
if ( wp_set_comment_status( $comment, $status ) ) {
[1617] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
[1618] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
[1619] Fix | Delete
[1620] Fix | Delete
/**
[1621] Fix | Delete
* Fires immediately after a comment is restored from the Trash.
[1622] Fix | Delete
*
[1623] Fix | Delete
* @since 2.9.0
[1624] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1625] Fix | Delete
*
[1626] Fix | Delete
* @param int $comment_id The comment ID.
[1627] Fix | Delete
* @param WP_Comment $comment The untrashed comment.
[1628] Fix | Delete
*/
[1629] Fix | Delete
do_action( 'untrashed_comment', $comment->comment_ID, $comment );
[1630] Fix | Delete
[1631] Fix | Delete
return true;
[1632] Fix | Delete
}
[1633] Fix | Delete
[1634] Fix | Delete
return false;
[1635] Fix | Delete
}
[1636] Fix | Delete
[1637] Fix | Delete
/**
[1638] Fix | Delete
* Marks a comment as Spam
[1639] Fix | Delete
*
[1640] Fix | Delete
* @since 2.9.0
[1641] Fix | Delete
*
[1642] Fix | Delete
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
[1643] Fix | Delete
* @return bool True on success, false on failure.
[1644] Fix | Delete
*/
[1645] Fix | Delete
function wp_spam_comment( $comment_id ) {
[1646] Fix | Delete
$comment = get_comment( $comment_id );
[1647] Fix | Delete
if ( ! $comment ) {
[1648] Fix | Delete
return false;
[1649] Fix | Delete
}
[1650] Fix | Delete
[1651] Fix | Delete
/**
[1652] Fix | Delete
* Fires immediately before a comment is marked as Spam.
[1653] Fix | Delete
*
[1654] Fix | Delete
* @since 2.9.0
[1655] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1656] Fix | Delete
*
[1657] Fix | Delete
* @param int $comment_id The comment ID.
[1658] Fix | Delete
* @param WP_Comment $comment The comment to be marked as spam.
[1659] Fix | Delete
*/
[1660] Fix | Delete
do_action( 'spam_comment', $comment->comment_ID, $comment );
[1661] Fix | Delete
[1662] Fix | Delete
if ( wp_set_comment_status( $comment, 'spam' ) ) {
[1663] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
[1664] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
[1665] Fix | Delete
add_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', $comment->comment_approved );
[1666] Fix | Delete
add_comment_meta( $comment->comment_ID, '_wp_trash_meta_time', time() );
[1667] Fix | Delete
[1668] Fix | Delete
/**
[1669] Fix | Delete
* Fires immediately after a comment is marked as Spam.
[1670] Fix | Delete
*
[1671] Fix | Delete
* @since 2.9.0
[1672] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1673] Fix | Delete
*
[1674] Fix | Delete
* @param int $comment_id The comment ID.
[1675] Fix | Delete
* @param WP_Comment $comment The comment marked as spam.
[1676] Fix | Delete
*/
[1677] Fix | Delete
do_action( 'spammed_comment', $comment->comment_ID, $comment );
[1678] Fix | Delete
[1679] Fix | Delete
return true;
[1680] Fix | Delete
}
[1681] Fix | Delete
[1682] Fix | Delete
return false;
[1683] Fix | Delete
}
[1684] Fix | Delete
[1685] Fix | Delete
/**
[1686] Fix | Delete
* Removes a comment from the Spam
[1687] Fix | Delete
*
[1688] Fix | Delete
* @since 2.9.0
[1689] Fix | Delete
*
[1690] Fix | Delete
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object.
[1691] Fix | Delete
* @return bool True on success, false on failure.
[1692] Fix | Delete
*/
[1693] Fix | Delete
function wp_unspam_comment( $comment_id ) {
[1694] Fix | Delete
$comment = get_comment( $comment_id );
[1695] Fix | Delete
if ( ! $comment ) {
[1696] Fix | Delete
return false;
[1697] Fix | Delete
}
[1698] Fix | Delete
[1699] Fix | Delete
/**
[1700] Fix | Delete
* Fires immediately before a comment is unmarked as Spam.
[1701] Fix | Delete
*
[1702] Fix | Delete
* @since 2.9.0
[1703] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1704] Fix | Delete
*
[1705] Fix | Delete
* @param int $comment_id The comment ID.
[1706] Fix | Delete
* @param WP_Comment $comment The comment to be unmarked as spam.
[1707] Fix | Delete
*/
[1708] Fix | Delete
do_action( 'unspam_comment', $comment->comment_ID, $comment );
[1709] Fix | Delete
[1710] Fix | Delete
$status = (string) get_comment_meta( $comment->comment_ID, '_wp_trash_meta_status', true );
[1711] Fix | Delete
if ( empty( $status ) ) {
[1712] Fix | Delete
$status = '0';
[1713] Fix | Delete
}
[1714] Fix | Delete
[1715] Fix | Delete
if ( wp_set_comment_status( $comment, $status ) ) {
[1716] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_status' );
[1717] Fix | Delete
delete_comment_meta( $comment->comment_ID, '_wp_trash_meta_time' );
[1718] Fix | Delete
[1719] Fix | Delete
/**
[1720] Fix | Delete
* Fires immediately after a comment is unmarked as Spam.
[1721] Fix | Delete
*
[1722] Fix | Delete
* @since 2.9.0
[1723] Fix | Delete
* @since 4.9.0 Added the `$comment` parameter.
[1724] Fix | Delete
*
[1725] Fix | Delete
* @param int $comment_id The comment ID.
[1726] Fix | Delete
* @param WP_Comment $comment The comment unmarked as spam.
[1727] Fix | Delete
*/
[1728] Fix | Delete
do_action( 'unspammed_comment', $comment->comment_ID, $comment );
[1729] Fix | Delete
[1730] Fix | Delete
return true;
[1731] Fix | Delete
}
[1732] Fix | Delete
[1733] Fix | Delete
return false;
[1734] Fix | Delete
}
[1735] Fix | Delete
[1736] Fix | Delete
/**
[1737] Fix | Delete
* The status of a comment by ID.
[1738] Fix | Delete
*
[1739] Fix | Delete
* @since 1.0.0
[1740] Fix | Delete
*
[1741] Fix | Delete
* @param int|WP_Comment $comment_id Comment ID or WP_Comment object
[1742] Fix | Delete
* @return string|false Status might be 'trash', 'approved', 'unapproved', 'spam'. False on failure.
[1743] Fix | Delete
*/
[1744] Fix | Delete
function wp_get_comment_status( $comment_id ) {
[1745] Fix | Delete
$comment = get_comment( $comment_id );
[1746] Fix | Delete
if ( ! $comment ) {
[1747] Fix | Delete
return false;
[1748] Fix | Delete
}
[1749] Fix | Delete
[1750] Fix | Delete
$approved = $comment->comment_approved;
[1751] Fix | Delete
[1752] Fix | Delete
if ( null == $approved ) {
[1753] Fix | Delete
return false;
[1754] Fix | Delete
} elseif ( '1' == $approved ) {
[1755] Fix | Delete
return 'approved';
[1756] Fix | Delete
} elseif ( '0' == $approved ) {
[1757] Fix | Delete
return 'unapproved';
[1758] Fix | Delete
} elseif ( 'spam' === $approved ) {
[1759] Fix | Delete
return 'spam';
[1760] Fix | Delete
} elseif ( 'trash' === $approved ) {
[1761] Fix | Delete
return 'trash';
[1762] Fix | Delete
} else {
[1763] Fix | Delete
return false;
[1764] Fix | Delete
}
[1765] Fix | Delete
}
[1766] Fix | Delete
[1767] Fix | Delete
/**
[1768] Fix | Delete
* Call hooks for when a comment status transition occurs.
[1769] Fix | Delete
*
[1770] Fix | Delete
* Calls hooks for comment status transitions. If the new comment status is not the same
[1771] Fix | Delete
* as the previous comment status, then two hooks will be ran, the first is
[1772] Fix | Delete
* {@see 'transition_comment_status'} with new status, old status, and comment data.
[1773] Fix | Delete
* The next action called is {@see 'comment_$old_status_to_$new_status'}. It has
[1774] Fix | Delete
* the comment data.
[1775] Fix | Delete
*
[1776] Fix | Delete
* The final action will run whether or not the comment statuses are the same.
[1777] Fix | Delete
* The action is named {@see 'comment_$new_status_$comment->comment_type'}.
[1778] Fix | Delete
*
[1779] Fix | Delete
* @since 2.7.0
[1780] Fix | Delete
*
[1781] Fix | Delete
* @param string $new_status New comment status.
[1782] Fix | Delete
* @param string $old_status Previous comment status.
[1783] Fix | Delete
* @param WP_Comment $comment Comment object.
[1784] Fix | Delete
*/
[1785] Fix | Delete
function wp_transition_comment_status( $new_status, $old_status, $comment ) {
[1786] Fix | Delete
/*
[1787] Fix | Delete
* Translate raw statuses to human-readable formats for the hooks.
[1788] Fix | Delete
* This is not a complete list of comment status, it's only the ones
[1789] Fix | Delete
* that need to be renamed.
[1790] Fix | Delete
*/
[1791] Fix | Delete
$comment_statuses = array(
[1792] Fix | Delete
0 => 'unapproved',
[1793] Fix | Delete
'hold' => 'unapproved', // wp_set_comment_status() uses "hold".
[1794] Fix | Delete
1 => 'approved',
[1795] Fix | Delete
'approve' => 'approved', // wp_set_comment_status() uses "approve".
[1796] Fix | Delete
);
[1797] Fix | Delete
if ( isset( $comment_statuses[ $new_status ] ) ) {
[1798] Fix | Delete
$new_status = $comment_statuses[ $new_status ];
[1799] Fix | Delete
}
[1800] Fix | Delete
if ( isset( $comment_statuses[ $old_status ] ) ) {
[1801] Fix | Delete
$old_status = $comment_statuses[ $old_status ];
[1802] Fix | Delete
}
[1803] Fix | Delete
[1804] Fix | Delete
// Call the hooks.
[1805] Fix | Delete
if ( $new_status != $old_status ) {
[1806] Fix | Delete
/**
[1807] Fix | Delete
* Fires when the comment status is in transition.
[1808] Fix | Delete
*
[1809] Fix | Delete
* @since 2.7.0
[1810] Fix | Delete
*
[1811] Fix | Delete
* @param int|string $new_status The new comment status.
[1812] Fix | Delete
* @param int|string $old_status The old comment status.
[1813] Fix | Delete
* @param WP_Comment $comment Comment object.
[1814] Fix | Delete
*/
[1815] Fix | Delete
do_action( 'transition_comment_status', $new_status, $old_status, $comment );
[1816] Fix | Delete
/**
[1817] Fix | Delete
* Fires when the comment status is in transition from one specific status to another.
[1818] Fix | Delete
*
[1819] Fix | Delete
* The dynamic portions of the hook name, `$old_status`, and `$new_status`,
[1820] Fix | Delete
* refer to the old and new comment statuses, respectively.
[1821] Fix | Delete
*
[1822] Fix | Delete
* @since 2.7.0
[1823] Fix | Delete
*
[1824] Fix | Delete
* @param WP_Comment $comment Comment object.
[1825] Fix | Delete
*/
[1826] Fix | Delete
do_action( "comment_{$old_status}_to_{$new_status}", $comment );
[1827] Fix | Delete
}
[1828] Fix | Delete
/**
[1829] Fix | Delete
* Fires when the status of a specific comment type is in transition.
[1830] Fix | Delete
*
[1831] Fix | Delete
* The dynamic portions of the hook name, `$new_status`, and `$comment->comment_type`,
[1832] Fix | Delete
* refer to the new comment status, and the type of comment, respectively.
[1833] Fix | Delete
*
[1834] Fix | Delete
* Typical comment types include an empty string (standard comment), 'pingback',
[1835] Fix | Delete
* or 'trackback'.
[1836] Fix | Delete
*
[1837] Fix | Delete
* @since 2.7.0
[1838] Fix | Delete
*
[1839] Fix | Delete
* @param int $comment_ID The comment ID.
[1840] Fix | Delete
* @param WP_Comment $comment Comment object.
[1841] Fix | Delete
*/
[1842] Fix | Delete
do_action( "comment_{$new_status}_{$comment->comment_type}", $comment->comment_ID, $comment );
[1843] Fix | Delete
}
[1844] Fix | Delete
[1845] Fix | Delete
/**
[1846] Fix | Delete
* Clear the lastcommentmodified cached value when a comment status is changed.
[1847] Fix | Delete
*
[1848] Fix | Delete
* Deletes the lastcommentmodified cache key when a comment enters or leaves
[1849] Fix | Delete
* 'approved' status.
[1850] Fix | Delete
*
[1851] Fix | Delete
* @since 4.7.0
[1852] Fix | Delete
* @access private
[1853] Fix | Delete
*
[1854] Fix | Delete
* @param string $new_status The new comment status.
[1855] Fix | Delete
* @param string $old_status The old comment status.
[1856] Fix | Delete
*/
[1857] Fix | Delete
function _clear_modified_cache_on_transition_comment_status( $new_status, $old_status ) {
[1858] Fix | Delete
if ( 'approved' === $new_status || 'approved' === $old_status ) {
[1859] Fix | Delete
foreach ( array( 'server', 'gmt', 'blog' ) as $timezone ) {
[1860] Fix | Delete
wp_cache_delete( "lastcommentmodified:$timezone", 'timeinfo' );
[1861] Fix | Delete
}
[1862] Fix | Delete
}
[1863] Fix | Delete
}
[1864] Fix | Delete
[1865] Fix | Delete
/**
[1866] Fix | Delete
* Get current commenter's name, email, and URL.
[1867] Fix | Delete
*
[1868] Fix | Delete
* Expects cookies content to already be sanitized. User of this function might
[1869] Fix | Delete
* wish to recheck the returned array for validity.
[1870] Fix | Delete
*
[1871] Fix | Delete
* @see sanitize_comment_cookies() Use to sanitize cookies
[1872] Fix | Delete
*
[1873] Fix | Delete
* @since 2.0.4
[1874] Fix | Delete
*
[1875] Fix | Delete
* @return array {
[1876] Fix | Delete
* An array of current commenter variables.
[1877] Fix | Delete
*
[1878] Fix | Delete
* @type string $comment_author The name of the current commenter, or an empty string.
[1879] Fix | Delete
* @type string $comment_author_email The email address of the current commenter, or an empty string.
[1880] Fix | Delete
* @type string $comment_author_url The URL address of the current commenter, or an empty string.
[1881] Fix | Delete
* }
[1882] Fix | Delete
*/
[1883] Fix | Delete
function wp_get_current_commenter() {
[1884] Fix | Delete
// Cookies should already be sanitized.
[1885] Fix | Delete
[1886] Fix | Delete
$comment_author = '';
[1887] Fix | Delete
if ( isset( $_COOKIE[ 'comment_author_' . COOKIEHASH ] ) ) {
[1888] Fix | Delete
$comment_author = $_COOKIE[ 'comment_author_' . COOKIEHASH ];
[1889] Fix | Delete
}
[1890] Fix | Delete
[1891] Fix | Delete
$comment_author_email = '';
[1892] Fix | Delete
if ( isset( $_COOKIE[ 'comment_author_email_' . COOKIEHASH ] ) ) {
[1893] Fix | Delete
$comment_author_email = $_COOKIE[ 'comment_author_email_' . COOKIEHASH ];
[1894] Fix | Delete
}
[1895] Fix | Delete
[1896] Fix | Delete
$comment_author_url = '';
[1897] Fix | Delete
if ( isset( $_COOKIE[ 'comment_author_url_' . COOKIEHASH ] ) ) {
[1898] Fix | Delete
$comment_author_url = $_COOKIE[ 'comment_author_url_' . COOKIEHASH ];
[1899] Fix | Delete
}
[1900] Fix | Delete
[1901] Fix | Delete
/**
[1902] Fix | Delete
* Filters the current commenter's name, email, and URL.
[1903] Fix | Delete
*
[1904] Fix | Delete
* @since 3.1.0
[1905] Fix | Delete
*
[1906] Fix | Delete
* @param array $comment_author_data {
[1907] Fix | Delete
* An array of current commenter variables.
[1908] Fix | Delete
*
[1909] Fix | Delete
* @type string $comment_author The name of the current commenter, or an empty string.
[1910] Fix | Delete
* @type string $comment_author_email The email address of the current commenter, or an empty string.
[1911] Fix | Delete
* @type string $comment_author_url The URL address of the current commenter, or an empty string.
[1912] Fix | Delete
* }
[1913] Fix | Delete
*/
[1914] Fix | Delete
return apply_filters( 'wp_get_current_commenter', compact( 'comment_author', 'comment_author_email', 'comment_author_url' ) );
[1915] Fix | Delete
}
[1916] Fix | Delete
[1917] Fix | Delete
/**
[1918] Fix | Delete
* Get unapproved comment author's email.
[1919] Fix | Delete
*
[1920] Fix | Delete
* Used to allow the commenter to see their pending comment.
[1921] Fix | Delete
*
[1922] Fix | Delete
* @since 5.1.0
[1923] Fix | Delete
* @since 5.7.0 The window within which the author email for an unapproved comment
[1924] Fix | Delete
* can be retrieved was extended to 10 minutes.
[1925] Fix | Delete
*
[1926] Fix | Delete
* @return string The unapproved comment author's email (when supplied).
[1927] Fix | Delete
*/
[1928] Fix | Delete
function wp_get_unapproved_comment_author_email() {
[1929] Fix | Delete
$commenter_email = '';
[1930] Fix | Delete
[1931] Fix | Delete
if ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
[1932] Fix | Delete
$comment_id = (int) $_GET['unapproved'];
[1933] Fix | Delete
$comment = get_comment( $comment_id );
[1934] Fix | Delete
[1935] Fix | Delete
if ( $comment && hash_equals( $_GET['moderation-hash'], wp_hash( $comment->comment_date_gmt ) ) ) {
[1936] Fix | Delete
// The comment will only be viewable by the comment author for 10 minutes.
[1937] Fix | Delete
$comment_preview_expires = strtotime( $comment->comment_date_gmt . '+10 minutes' );
[1938] Fix | Delete
[1939] Fix | Delete
if ( time() < $comment_preview_expires ) {
[1940] Fix | Delete
$commenter_email = $comment->comment_author_email;
[1941] Fix | Delete
}
[1942] Fix | Delete
}
[1943] Fix | Delete
}
[1944] Fix | Delete
[1945] Fix | Delete
if ( ! $commenter_email ) {
[1946] Fix | Delete
$commenter = wp_get_current_commenter();
[1947] Fix | Delete
$commenter_email = $commenter['comment_author_email'];
[1948] Fix | Delete
}
[1949] Fix | Delete
[1950] Fix | Delete
return $commenter_email;
[1951] Fix | Delete
}
[1952] Fix | Delete
[1953] Fix | Delete
/**
[1954] Fix | Delete
* Inserts a comment into the database.
[1955] Fix | Delete
*
[1956] Fix | Delete
* @since 2.0.0
[1957] Fix | Delete
* @since 4.4.0 Introduced the `$comment_meta` argument.
[1958] Fix | Delete
* @since 5.5.0 Default value for `$comment_type` argument changed to `comment`.
[1959] Fix | Delete
*
[1960] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[1961] Fix | Delete
*
[1962] Fix | Delete
* @param array $commentdata {
[1963] Fix | Delete
* Array of arguments for inserting a new comment.
[1964] Fix | Delete
*
[1965] Fix | Delete
* @type string $comment_agent The HTTP user agent of the `$comment_author` when
[1966] Fix | Delete
* the comment was submitted. Default empty.
[1967] Fix | Delete
* @type int|string $comment_approved Whether the comment has been approved. Default 1.
[1968] Fix | Delete
* @type string $comment_author The name of the author of the comment. Default empty.
[1969] Fix | Delete
* @type string $comment_author_email The email address of the `$comment_author`. Default empty.
[1970] Fix | Delete
* @type string $comment_author_IP The IP address of the `$comment_author`. Default empty.
[1971] Fix | Delete
* @type string $comment_author_url The URL address of the `$comment_author`. Default empty.
[1972] Fix | Delete
* @type string $comment_content The content of the comment. Default empty.
[1973] Fix | Delete
* @type string $comment_date The date the comment was submitted. To set the date
[1974] Fix | Delete
* manually, `$comment_date_gmt` must also be specified.
[1975] Fix | Delete
* Default is the current time.
[1976] Fix | Delete
* @type string $comment_date_gmt The date the comment was submitted in the GMT timezone.
[1977] Fix | Delete
* Default is `$comment_date` in the site's GMT timezone.
[1978] Fix | Delete
* @type int $comment_karma The karma of the comment. Default 0.
[1979] Fix | Delete
* @type int $comment_parent ID of this comment's parent, if any. Default 0.
[1980] Fix | Delete
* @type int $comment_post_ID ID of the post that relates to the comment, if any.
[1981] Fix | Delete
* Default 0.
[1982] Fix | Delete
* @type string $comment_type Comment type. Default 'comment'.
[1983] Fix | Delete
* @type array $comment_meta Optional. Array of key/value pairs to be stored in commentmeta for the
[1984] Fix | Delete
* new comment.
[1985] Fix | Delete
* @type int $user_id ID of the user who submitted the comment. Default 0.
[1986] Fix | Delete
* }
[1987] Fix | Delete
* @return int|false The new comment's ID on success, false on failure.
[1988] Fix | Delete
*/
[1989] Fix | Delete
function wp_insert_comment( $commentdata ) {
[1990] Fix | Delete
global $wpdb;
[1991] Fix | Delete
$data = wp_unslash( $commentdata );
[1992] Fix | Delete
[1993] Fix | Delete
$comment_author = ! isset( $data['comment_author'] ) ? '' : $data['comment_author'];
[1994] Fix | Delete
$comment_author_email = ! isset( $data['comment_author_email'] ) ? '' : $data['comment_author_email'];
[1995] Fix | Delete
$comment_author_url = ! isset( $data['comment_author_url'] ) ? '' : $data['comment_author_url'];
[1996] Fix | Delete
$comment_author_IP = ! isset( $data['comment_author_IP'] ) ? '' : $data['comment_author_IP'];
[1997] Fix | Delete
[1998] Fix | Delete
$comment_date = ! isset( $data['comment_date'] ) ? current_time( 'mysql' ) : $data['comment_date'];
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function