Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-admin/includes
File: post.php
}
[1500] Fix | Delete
$permalink = str_replace( '%pagename%', "{$uri}%pagename%", $permalink );
[1501] Fix | Delete
}
[1502] Fix | Delete
[1503] Fix | Delete
/** This filter is documented in wp-admin/edit-tag-form.php */
[1504] Fix | Delete
$permalink = array( $permalink, apply_filters( 'editable_slug', $post->post_name, $post ) );
[1505] Fix | Delete
$post->post_status = $original_status;
[1506] Fix | Delete
$post->post_date = $original_date;
[1507] Fix | Delete
$post->post_name = $original_name;
[1508] Fix | Delete
$post->filter = $original_filter;
[1509] Fix | Delete
[1510] Fix | Delete
/**
[1511] Fix | Delete
* Filters the sample permalink.
[1512] Fix | Delete
*
[1513] Fix | Delete
* @since 4.4.0
[1514] Fix | Delete
*
[1515] Fix | Delete
* @param array $permalink {
[1516] Fix | Delete
* Array containing the sample permalink with placeholder for the post name, and the post name.
[1517] Fix | Delete
*
[1518] Fix | Delete
* @type string $0 The permalink with placeholder for the post name.
[1519] Fix | Delete
* @type string $1 The post name.
[1520] Fix | Delete
* }
[1521] Fix | Delete
* @param int $post_id Post ID.
[1522] Fix | Delete
* @param string $title Post title.
[1523] Fix | Delete
* @param string $name Post name (slug).
[1524] Fix | Delete
* @param WP_Post $post Post object.
[1525] Fix | Delete
*/
[1526] Fix | Delete
return apply_filters( 'get_sample_permalink', $permalink, $post->ID, $title, $name, $post );
[1527] Fix | Delete
}
[1528] Fix | Delete
[1529] Fix | Delete
/**
[1530] Fix | Delete
* Returns the HTML of the sample permalink slug editor.
[1531] Fix | Delete
*
[1532] Fix | Delete
* @since 2.5.0
[1533] Fix | Delete
*
[1534] Fix | Delete
* @param int|WP_Post $post Post ID or post object.
[1535] Fix | Delete
* @param string|null $new_title Optional. New title. Default null.
[1536] Fix | Delete
* @param string|null $new_slug Optional. New slug. Default null.
[1537] Fix | Delete
* @return string The HTML of the sample permalink slug editor.
[1538] Fix | Delete
*/
[1539] Fix | Delete
function get_sample_permalink_html( $post, $new_title = null, $new_slug = null ) {
[1540] Fix | Delete
$post = get_post( $post );
[1541] Fix | Delete
[1542] Fix | Delete
if ( ! $post ) {
[1543] Fix | Delete
return '';
[1544] Fix | Delete
}
[1545] Fix | Delete
[1546] Fix | Delete
list($permalink, $post_name) = get_sample_permalink( $post->ID, $new_title, $new_slug );
[1547] Fix | Delete
[1548] Fix | Delete
$view_link = false;
[1549] Fix | Delete
$preview_target = '';
[1550] Fix | Delete
[1551] Fix | Delete
if ( current_user_can( 'read_post', $post->ID ) ) {
[1552] Fix | Delete
if ( 'draft' === $post->post_status || empty( $post->post_name ) ) {
[1553] Fix | Delete
$view_link = get_preview_post_link( $post );
[1554] Fix | Delete
$preview_target = " target='wp-preview-{$post->ID}'";
[1555] Fix | Delete
} else {
[1556] Fix | Delete
if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) {
[1557] Fix | Delete
$view_link = get_permalink( $post );
[1558] Fix | Delete
} else {
[1559] Fix | Delete
// Allow non-published (private, future) to be viewed at a pretty permalink, in case $post->post_name is set.
[1560] Fix | Delete
$view_link = str_replace( array( '%pagename%', '%postname%' ), $post->post_name, $permalink );
[1561] Fix | Delete
}
[1562] Fix | Delete
}
[1563] Fix | Delete
}
[1564] Fix | Delete
[1565] Fix | Delete
// Permalinks without a post/page name placeholder don't have anything to edit.
[1566] Fix | Delete
if ( ! str_contains( $permalink, '%postname%' ) && ! str_contains( $permalink, '%pagename%' ) ) {
[1567] Fix | Delete
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
[1568] Fix | Delete
[1569] Fix | Delete
if ( false !== $view_link ) {
[1570] Fix | Delete
$display_link = urldecode( $view_link );
[1571] Fix | Delete
$return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . esc_html( $display_link ) . "</a>\n";
[1572] Fix | Delete
} else {
[1573] Fix | Delete
$return .= '<span id="sample-permalink">' . $permalink . "</span>\n";
[1574] Fix | Delete
}
[1575] Fix | Delete
[1576] Fix | Delete
// Encourage a pretty permalink setting.
[1577] Fix | Delete
if ( ! get_option( 'permalink_structure' ) && current_user_can( 'manage_options' )
[1578] Fix | Delete
&& ! ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID )
[1579] Fix | Delete
) {
[1580] Fix | Delete
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small">' . __( 'Change Permalink Structure' ) . "</a></span>\n";
[1581] Fix | Delete
}
[1582] Fix | Delete
} else {
[1583] Fix | Delete
if ( mb_strlen( $post_name ) > 34 ) {
[1584] Fix | Delete
$post_name_abridged = mb_substr( $post_name, 0, 16 ) . '&hellip;' . mb_substr( $post_name, -16 );
[1585] Fix | Delete
} else {
[1586] Fix | Delete
$post_name_abridged = $post_name;
[1587] Fix | Delete
}
[1588] Fix | Delete
[1589] Fix | Delete
$post_name_html = '<span id="editable-post-name">' . esc_html( $post_name_abridged ) . '</span>';
[1590] Fix | Delete
$display_link = str_replace( array( '%pagename%', '%postname%' ), $post_name_html, esc_html( urldecode( $permalink ) ) );
[1591] Fix | Delete
[1592] Fix | Delete
$return = '<strong>' . __( 'Permalink:' ) . "</strong>\n";
[1593] Fix | Delete
$return .= '<span id="sample-permalink"><a href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $display_link . "</a></span>\n";
[1594] Fix | Delete
$return .= '&lrm;'; // Fix bi-directional text display defect in RTL languages.
[1595] Fix | Delete
$return .= '<span id="edit-slug-buttons"><button type="button" class="edit-slug button button-small hide-if-no-js" aria-label="' . __( 'Edit permalink' ) . '">' . __( 'Edit' ) . "</button></span>\n";
[1596] Fix | Delete
$return .= '<span id="editable-post-name-full">' . esc_html( $post_name ) . "</span>\n";
[1597] Fix | Delete
}
[1598] Fix | Delete
[1599] Fix | Delete
/**
[1600] Fix | Delete
* Filters the sample permalink HTML markup.
[1601] Fix | Delete
*
[1602] Fix | Delete
* @since 2.9.0
[1603] Fix | Delete
* @since 4.4.0 Added `$post` parameter.
[1604] Fix | Delete
*
[1605] Fix | Delete
* @param string $return Sample permalink HTML markup.
[1606] Fix | Delete
* @param int $post_id Post ID.
[1607] Fix | Delete
* @param string|null $new_title New sample permalink title.
[1608] Fix | Delete
* @param string|null $new_slug New sample permalink slug.
[1609] Fix | Delete
* @param WP_Post $post Post object.
[1610] Fix | Delete
*/
[1611] Fix | Delete
$return = apply_filters( 'get_sample_permalink_html', $return, $post->ID, $new_title, $new_slug, $post );
[1612] Fix | Delete
[1613] Fix | Delete
return $return;
[1614] Fix | Delete
}
[1615] Fix | Delete
[1616] Fix | Delete
/**
[1617] Fix | Delete
* Returns HTML for the post thumbnail meta box.
[1618] Fix | Delete
*
[1619] Fix | Delete
* @since 2.9.0
[1620] Fix | Delete
*
[1621] Fix | Delete
* @param int|null $thumbnail_id Optional. Thumbnail attachment ID. Default null.
[1622] Fix | Delete
* @param int|WP_Post|null $post Optional. The post ID or object associated
[1623] Fix | Delete
* with the thumbnail. Defaults to global $post.
[1624] Fix | Delete
* @return string The post thumbnail HTML.
[1625] Fix | Delete
*/
[1626] Fix | Delete
function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
[1627] Fix | Delete
$_wp_additional_image_sizes = wp_get_additional_image_sizes();
[1628] Fix | Delete
[1629] Fix | Delete
$post = get_post( $post );
[1630] Fix | Delete
$post_type_object = get_post_type_object( $post->post_type );
[1631] Fix | Delete
$set_thumbnail_link = '<p class="hide-if-no-js"><a href="%s" id="set-post-thumbnail"%s class="thickbox">%s</a></p>';
[1632] Fix | Delete
$upload_iframe_src = get_upload_iframe_src( 'image', $post->ID );
[1633] Fix | Delete
[1634] Fix | Delete
$content = sprintf(
[1635] Fix | Delete
$set_thumbnail_link,
[1636] Fix | Delete
esc_url( $upload_iframe_src ),
[1637] Fix | Delete
'', // Empty when there's no featured image set, `aria-describedby` attribute otherwise.
[1638] Fix | Delete
esc_html( $post_type_object->labels->set_featured_image )
[1639] Fix | Delete
);
[1640] Fix | Delete
[1641] Fix | Delete
if ( $thumbnail_id && get_post( $thumbnail_id ) ) {
[1642] Fix | Delete
$size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 );
[1643] Fix | Delete
[1644] Fix | Delete
/**
[1645] Fix | Delete
* Filters the size used to display the post thumbnail image in the 'Featured image' meta box.
[1646] Fix | Delete
*
[1647] Fix | Delete
* Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
[1648] Fix | Delete
* image size is registered, which differs from the 'thumbnail' image size
[1649] Fix | Delete
* managed via the Settings > Media screen.
[1650] Fix | Delete
*
[1651] Fix | Delete
* @since 4.4.0
[1652] Fix | Delete
*
[1653] Fix | Delete
* @param string|int[] $size Requested image size. Can be any registered image size name, or
[1654] Fix | Delete
* an array of width and height values in pixels (in that order).
[1655] Fix | Delete
* @param int $thumbnail_id Post thumbnail attachment ID.
[1656] Fix | Delete
* @param WP_Post $post The post object associated with the thumbnail.
[1657] Fix | Delete
*/
[1658] Fix | Delete
$size = apply_filters( 'admin_post_thumbnail_size', $size, $thumbnail_id, $post );
[1659] Fix | Delete
[1660] Fix | Delete
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
[1661] Fix | Delete
[1662] Fix | Delete
if ( ! empty( $thumbnail_html ) ) {
[1663] Fix | Delete
$content = sprintf(
[1664] Fix | Delete
$set_thumbnail_link,
[1665] Fix | Delete
esc_url( $upload_iframe_src ),
[1666] Fix | Delete
' aria-describedby="set-post-thumbnail-desc"',
[1667] Fix | Delete
$thumbnail_html
[1668] Fix | Delete
);
[1669] Fix | Delete
$content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>';
[1670] Fix | Delete
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
[1671] Fix | Delete
}
[1672] Fix | Delete
}
[1673] Fix | Delete
[1674] Fix | Delete
$content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr( $thumbnail_id ? $thumbnail_id : '-1' ) . '" />';
[1675] Fix | Delete
[1676] Fix | Delete
/**
[1677] Fix | Delete
* Filters the admin post thumbnail HTML markup to return.
[1678] Fix | Delete
*
[1679] Fix | Delete
* @since 2.9.0
[1680] Fix | Delete
* @since 3.5.0 Added the `$post_id` parameter.
[1681] Fix | Delete
* @since 4.6.0 Added the `$thumbnail_id` parameter.
[1682] Fix | Delete
*
[1683] Fix | Delete
* @param string $content Admin post thumbnail HTML markup.
[1684] Fix | Delete
* @param int $post_id Post ID.
[1685] Fix | Delete
* @param int|null $thumbnail_id Thumbnail attachment ID, or null if there isn't one.
[1686] Fix | Delete
*/
[1687] Fix | Delete
return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id );
[1688] Fix | Delete
}
[1689] Fix | Delete
[1690] Fix | Delete
/**
[1691] Fix | Delete
* Determines whether the post is currently being edited by another user.
[1692] Fix | Delete
*
[1693] Fix | Delete
* @since 2.5.0
[1694] Fix | Delete
*
[1695] Fix | Delete
* @param int|WP_Post $post ID or object of the post to check for editing.
[1696] Fix | Delete
* @return int|false ID of the user with lock. False if the post does not exist, post is not locked,
[1697] Fix | Delete
* the user with lock does not exist, or the post is locked by current user.
[1698] Fix | Delete
*/
[1699] Fix | Delete
function wp_check_post_lock( $post ) {
[1700] Fix | Delete
$post = get_post( $post );
[1701] Fix | Delete
[1702] Fix | Delete
if ( ! $post ) {
[1703] Fix | Delete
return false;
[1704] Fix | Delete
}
[1705] Fix | Delete
[1706] Fix | Delete
$lock = get_post_meta( $post->ID, '_edit_lock', true );
[1707] Fix | Delete
[1708] Fix | Delete
if ( ! $lock ) {
[1709] Fix | Delete
return false;
[1710] Fix | Delete
}
[1711] Fix | Delete
[1712] Fix | Delete
$lock = explode( ':', $lock );
[1713] Fix | Delete
$time = $lock[0];
[1714] Fix | Delete
$user = isset( $lock[1] ) ? (int) $lock[1] : (int) get_post_meta( $post->ID, '_edit_last', true );
[1715] Fix | Delete
[1716] Fix | Delete
if ( ! get_userdata( $user ) ) {
[1717] Fix | Delete
return false;
[1718] Fix | Delete
}
[1719] Fix | Delete
[1720] Fix | Delete
/** This filter is documented in wp-admin/includes/ajax-actions.php */
[1721] Fix | Delete
$time_window = apply_filters( 'wp_check_post_lock_window', 150 );
[1722] Fix | Delete
[1723] Fix | Delete
if ( $time && $time > time() - $time_window && get_current_user_id() !== $user ) {
[1724] Fix | Delete
return $user;
[1725] Fix | Delete
}
[1726] Fix | Delete
[1727] Fix | Delete
return false;
[1728] Fix | Delete
}
[1729] Fix | Delete
[1730] Fix | Delete
/**
[1731] Fix | Delete
* Marks the post as currently being edited by the current user.
[1732] Fix | Delete
*
[1733] Fix | Delete
* @since 2.5.0
[1734] Fix | Delete
*
[1735] Fix | Delete
* @param int|WP_Post $post ID or object of the post being edited.
[1736] Fix | Delete
* @return array|false {
[1737] Fix | Delete
* Array of the lock time and user ID. False if the post does not exist, or there
[1738] Fix | Delete
* is no current user.
[1739] Fix | Delete
*
[1740] Fix | Delete
* @type int $0 The current time as a Unix timestamp.
[1741] Fix | Delete
* @type int $1 The ID of the current user.
[1742] Fix | Delete
* }
[1743] Fix | Delete
*/
[1744] Fix | Delete
function wp_set_post_lock( $post ) {
[1745] Fix | Delete
$post = get_post( $post );
[1746] Fix | Delete
[1747] Fix | Delete
if ( ! $post ) {
[1748] Fix | Delete
return false;
[1749] Fix | Delete
}
[1750] Fix | Delete
[1751] Fix | Delete
$user_id = get_current_user_id();
[1752] Fix | Delete
[1753] Fix | Delete
if ( 0 === $user_id ) {
[1754] Fix | Delete
return false;
[1755] Fix | Delete
}
[1756] Fix | Delete
[1757] Fix | Delete
$now = time();
[1758] Fix | Delete
$lock = "$now:$user_id";
[1759] Fix | Delete
[1760] Fix | Delete
update_post_meta( $post->ID, '_edit_lock', $lock );
[1761] Fix | Delete
[1762] Fix | Delete
return array( $now, $user_id );
[1763] Fix | Delete
}
[1764] Fix | Delete
[1765] Fix | Delete
/**
[1766] Fix | Delete
* Outputs the HTML for the notice to say that someone else is editing or has taken over editing of this post.
[1767] Fix | Delete
*
[1768] Fix | Delete
* @since 2.8.5
[1769] Fix | Delete
*/
[1770] Fix | Delete
function _admin_notice_post_locked() {
[1771] Fix | Delete
$post = get_post();
[1772] Fix | Delete
[1773] Fix | Delete
if ( ! $post ) {
[1774] Fix | Delete
return;
[1775] Fix | Delete
}
[1776] Fix | Delete
[1777] Fix | Delete
$user = null;
[1778] Fix | Delete
$user_id = wp_check_post_lock( $post->ID );
[1779] Fix | Delete
[1780] Fix | Delete
if ( $user_id ) {
[1781] Fix | Delete
$user = get_userdata( $user_id );
[1782] Fix | Delete
}
[1783] Fix | Delete
[1784] Fix | Delete
if ( $user ) {
[1785] Fix | Delete
/**
[1786] Fix | Delete
* Filters whether to show the post locked dialog.
[1787] Fix | Delete
*
[1788] Fix | Delete
* Returning false from the filter will prevent the dialog from being displayed.
[1789] Fix | Delete
*
[1790] Fix | Delete
* @since 3.6.0
[1791] Fix | Delete
*
[1792] Fix | Delete
* @param bool $display Whether to display the dialog. Default true.
[1793] Fix | Delete
* @param WP_Post $post Post object.
[1794] Fix | Delete
* @param WP_User $user The user with the lock for the post.
[1795] Fix | Delete
*/
[1796] Fix | Delete
if ( ! apply_filters( 'show_post_locked_dialog', true, $post, $user ) ) {
[1797] Fix | Delete
return;
[1798] Fix | Delete
}
[1799] Fix | Delete
[1800] Fix | Delete
$locked = true;
[1801] Fix | Delete
} else {
[1802] Fix | Delete
$locked = false;
[1803] Fix | Delete
}
[1804] Fix | Delete
[1805] Fix | Delete
$sendback = wp_get_referer();
[1806] Fix | Delete
if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) {
[1807] Fix | Delete
[1808] Fix | Delete
$sendback_text = __( 'Go back' );
[1809] Fix | Delete
} else {
[1810] Fix | Delete
$sendback = admin_url( 'edit.php' );
[1811] Fix | Delete
[1812] Fix | Delete
if ( 'post' !== $post->post_type ) {
[1813] Fix | Delete
$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
[1814] Fix | Delete
}
[1815] Fix | Delete
[1816] Fix | Delete
$sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
[1817] Fix | Delete
}
[1818] Fix | Delete
[1819] Fix | Delete
$hidden = $locked ? '' : ' hidden';
[1820] Fix | Delete
[1821] Fix | Delete
?>
[1822] Fix | Delete
<div id="post-lock-dialog" class="notification-dialog-wrap<?php echo $hidden; ?>">
[1823] Fix | Delete
<div class="notification-dialog-background"></div>
[1824] Fix | Delete
<div class="notification-dialog">
[1825] Fix | Delete
<?php
[1826] Fix | Delete
[1827] Fix | Delete
if ( $locked ) {
[1828] Fix | Delete
$query_args = array();
[1829] Fix | Delete
if ( get_post_type_object( $post->post_type )->public ) {
[1830] Fix | Delete
if ( 'publish' === $post->post_status || $user->ID !== (int) $post->post_author ) {
[1831] Fix | Delete
// Latest content is in autosave.
[1832] Fix | Delete
$nonce = wp_create_nonce( 'post_preview_' . $post->ID );
[1833] Fix | Delete
$query_args['preview_id'] = $post->ID;
[1834] Fix | Delete
$query_args['preview_nonce'] = $nonce;
[1835] Fix | Delete
}
[1836] Fix | Delete
}
[1837] Fix | Delete
[1838] Fix | Delete
$preview_link = get_preview_post_link( $post->ID, $query_args );
[1839] Fix | Delete
[1840] Fix | Delete
/**
[1841] Fix | Delete
* Filters whether to allow the post lock to be overridden.
[1842] Fix | Delete
*
[1843] Fix | Delete
* Returning false from the filter will disable the ability
[1844] Fix | Delete
* to override the post lock.
[1845] Fix | Delete
*
[1846] Fix | Delete
* @since 3.6.0
[1847] Fix | Delete
*
[1848] Fix | Delete
* @param bool $override Whether to allow the post lock to be overridden. Default true.
[1849] Fix | Delete
* @param WP_Post $post Post object.
[1850] Fix | Delete
* @param WP_User $user The user with the lock for the post.
[1851] Fix | Delete
*/
[1852] Fix | Delete
$override = apply_filters( 'override_post_lock', true, $post, $user );
[1853] Fix | Delete
$tab_last = $override ? '' : ' wp-tab-last';
[1854] Fix | Delete
[1855] Fix | Delete
?>
[1856] Fix | Delete
<div class="post-locked-message">
[1857] Fix | Delete
<div class="post-locked-avatar"><?php echo get_avatar( $user->ID, 64 ); ?></div>
[1858] Fix | Delete
<p class="currently-editing wp-tab-first" tabindex="0">
[1859] Fix | Delete
<?php
[1860] Fix | Delete
if ( $override ) {
[1861] Fix | Delete
/* translators: %s: User's display name. */
[1862] Fix | Delete
printf( __( '%s is currently editing this post. Do you want to take over?' ), esc_html( $user->display_name ) );
[1863] Fix | Delete
} else {
[1864] Fix | Delete
/* translators: %s: User's display name. */
[1865] Fix | Delete
printf( __( '%s is currently editing this post.' ), esc_html( $user->display_name ) );
[1866] Fix | Delete
}
[1867] Fix | Delete
?>
[1868] Fix | Delete
</p>
[1869] Fix | Delete
<?php
[1870] Fix | Delete
/**
[1871] Fix | Delete
* Fires inside the post locked dialog before the buttons are displayed.
[1872] Fix | Delete
*
[1873] Fix | Delete
* @since 3.6.0
[1874] Fix | Delete
* @since 5.4.0 The $user parameter was added.
[1875] Fix | Delete
*
[1876] Fix | Delete
* @param WP_Post $post Post object.
[1877] Fix | Delete
* @param WP_User $user The user with the lock for the post.
[1878] Fix | Delete
*/
[1879] Fix | Delete
do_action( 'post_locked_dialog', $post, $user );
[1880] Fix | Delete
?>
[1881] Fix | Delete
<p>
[1882] Fix | Delete
<a class="button" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a>
[1883] Fix | Delete
<?php if ( $preview_link ) { ?>
[1884] Fix | Delete
<a class="button<?php echo $tab_last; ?>" href="<?php echo esc_url( $preview_link ); ?>"><?php _e( 'Preview' ); ?></a>
[1885] Fix | Delete
<?php
[1886] Fix | Delete
}
[1887] Fix | Delete
[1888] Fix | Delete
// Allow plugins to prevent some users overriding the post lock.
[1889] Fix | Delete
if ( $override ) {
[1890] Fix | Delete
?>
[1891] Fix | Delete
<a class="button button-primary wp-tab-last" href="<?php echo esc_url( add_query_arg( 'get-post-lock', '1', wp_nonce_url( get_edit_post_link( $post->ID, 'url' ), 'lock-post_' . $post->ID ) ) ); ?>"><?php _e( 'Take over' ); ?></a>
[1892] Fix | Delete
<?php
[1893] Fix | Delete
}
[1894] Fix | Delete
[1895] Fix | Delete
?>
[1896] Fix | Delete
</p>
[1897] Fix | Delete
</div>
[1898] Fix | Delete
<?php
[1899] Fix | Delete
} else {
[1900] Fix | Delete
?>
[1901] Fix | Delete
<div class="post-taken-over">
[1902] Fix | Delete
<div class="post-locked-avatar"></div>
[1903] Fix | Delete
<p class="wp-tab-first" tabindex="0">
[1904] Fix | Delete
<span class="currently-editing"></span><br />
[1905] Fix | Delete
<span class="locked-saving hidden"><img src="<?php echo esc_url( admin_url( 'images/spinner-2x.gif' ) ); ?>" width="16" height="16" alt="" /> <?php _e( 'Saving revision&hellip;' ); ?></span>
[1906] Fix | Delete
<span class="locked-saved hidden"><?php _e( 'Your latest changes were saved as a revision.' ); ?></span>
[1907] Fix | Delete
</p>
[1908] Fix | Delete
<?php
[1909] Fix | Delete
/**
[1910] Fix | Delete
* Fires inside the dialog displayed when a user has lost the post lock.
[1911] Fix | Delete
*
[1912] Fix | Delete
* @since 3.6.0
[1913] Fix | Delete
*
[1914] Fix | Delete
* @param WP_Post $post Post object.
[1915] Fix | Delete
*/
[1916] Fix | Delete
do_action( 'post_lock_lost_dialog', $post );
[1917] Fix | Delete
?>
[1918] Fix | Delete
<p><a class="button button-primary wp-tab-last" href="<?php echo esc_url( $sendback ); ?>"><?php echo $sendback_text; ?></a></p>
[1919] Fix | Delete
</div>
[1920] Fix | Delete
<?php
[1921] Fix | Delete
}
[1922] Fix | Delete
[1923] Fix | Delete
?>
[1924] Fix | Delete
</div>
[1925] Fix | Delete
</div>
[1926] Fix | Delete
<?php
[1927] Fix | Delete
}
[1928] Fix | Delete
[1929] Fix | Delete
/**
[1930] Fix | Delete
* Creates autosave data for the specified post from `$_POST` data.
[1931] Fix | Delete
*
[1932] Fix | Delete
* @since 2.6.0
[1933] Fix | Delete
*
[1934] Fix | Delete
* @param array|int $post_data Associative array containing the post data, or integer post ID.
[1935] Fix | Delete
* If a numeric post ID is provided, will use the `$_POST` superglobal.
[1936] Fix | Delete
* @return int|WP_Error The autosave revision ID. WP_Error or 0 on error.
[1937] Fix | Delete
*/
[1938] Fix | Delete
function wp_create_post_autosave( $post_data ) {
[1939] Fix | Delete
if ( is_numeric( $post_data ) ) {
[1940] Fix | Delete
$post_id = $post_data;
[1941] Fix | Delete
$post_data = $_POST;
[1942] Fix | Delete
} else {
[1943] Fix | Delete
$post_id = (int) $post_data['post_ID'];
[1944] Fix | Delete
}
[1945] Fix | Delete
[1946] Fix | Delete
$post_data = _wp_translate_postdata( true, $post_data );
[1947] Fix | Delete
if ( is_wp_error( $post_data ) ) {
[1948] Fix | Delete
return $post_data;
[1949] Fix | Delete
}
[1950] Fix | Delete
$post_data = _wp_get_allowed_postdata( $post_data );
[1951] Fix | Delete
[1952] Fix | Delete
$post_author = get_current_user_id();
[1953] Fix | Delete
[1954] Fix | Delete
// Store one autosave per author. If there is already an autosave, overwrite it.
[1955] Fix | Delete
$old_autosave = wp_get_post_autosave( $post_id, $post_author );
[1956] Fix | Delete
if ( $old_autosave ) {
[1957] Fix | Delete
$new_autosave = _wp_post_revision_data( $post_data, true );
[1958] Fix | Delete
$new_autosave['ID'] = $old_autosave->ID;
[1959] Fix | Delete
$new_autosave['post_author'] = $post_author;
[1960] Fix | Delete
[1961] Fix | Delete
$post = get_post( $post_id );
[1962] Fix | Delete
[1963] Fix | Delete
// If the new autosave has the same content as the post, delete the autosave.
[1964] Fix | Delete
$autosave_is_different = false;
[1965] Fix | Delete
foreach ( array_intersect( array_keys( $new_autosave ), array_keys( _wp_post_revision_fields( $post ) ) ) as $field ) {
[1966] Fix | Delete
if ( normalize_whitespace( $new_autosave[ $field ] ) !== normalize_whitespace( $post->$field ) ) {
[1967] Fix | Delete
$autosave_is_different = true;
[1968] Fix | Delete
break;
[1969] Fix | Delete
}
[1970] Fix | Delete
}
[1971] Fix | Delete
[1972] Fix | Delete
if ( ! $autosave_is_different ) {
[1973] Fix | Delete
wp_delete_post_revision( $old_autosave->ID );
[1974] Fix | Delete
return 0;
[1975] Fix | Delete
}
[1976] Fix | Delete
[1977] Fix | Delete
/**
[1978] Fix | Delete
* Fires before an autosave is stored.
[1979] Fix | Delete
*
[1980] Fix | Delete
* @since 4.1.0
[1981] Fix | Delete
* @since 6.4.0 The `$is_update` parameter was added to indicate if the autosave is being updated or was newly created.
[1982] Fix | Delete
*
[1983] Fix | Delete
* @param array $new_autosave Post array - the autosave that is about to be saved.
[1984] Fix | Delete
* @param bool $is_update Whether this is an existing autosave.
[1985] Fix | Delete
*/
[1986] Fix | Delete
do_action( 'wp_creating_autosave', $new_autosave, true );
[1987] Fix | Delete
return wp_update_post( $new_autosave );
[1988] Fix | Delete
}
[1989] Fix | Delete
[1990] Fix | Delete
// _wp_put_post_revision() expects unescaped.
[1991] Fix | Delete
$post_data = wp_unslash( $post_data );
[1992] Fix | Delete
[1993] Fix | Delete
// Otherwise create the new autosave as a special post revision.
[1994] Fix | Delete
$revision = _wp_put_post_revision( $post_data, true );
[1995] Fix | Delete
[1996] Fix | Delete
if ( ! is_wp_error( $revision ) && 0 !== $revision ) {
[1997] Fix | Delete
[1998] Fix | Delete
/** This action is documented in wp-admin/includes/post.php */
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function