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/clone/wp-conte.../themes/Divi/includes/builder
File: core.php
[1500] Fix | Delete
// wpautop does its "thing"
[1501] Fix | Delete
$post_content = wpautop( $post_content );
[1502] Fix | Delete
[1503] Fix | Delete
// undo prep
[1504] Fix | Delete
$post_content = et_pb_unprep_code_module_for_wpautop( $post_content );
[1505] Fix | Delete
}
[1506] Fix | Delete
[1507] Fix | Delete
$global_shortcode['shortcode'] = et_core_intentionally_unescaped( $post_content, 'html' );
[1508] Fix | Delete
$excluded_global_options = get_post_meta( $post_id, '_et_pb_excluded_global_options' );
[1509] Fix | Delete
$selective_sync_status = empty( $excluded_global_options ) ? '' : 'updated';
[1510] Fix | Delete
[1511] Fix | Delete
$global_shortcode['sync_status'] = et_core_intentionally_unescaped( $selective_sync_status, 'fixed_string' );
[1512] Fix | Delete
// excluded_global_options is an array with single value which is json string, so just `sanitize_text_field`, because `esc_html` converts quotes and breaks the json string.
[1513] Fix | Delete
$global_shortcode['excluded_options'] = $utils->esc_array( $excluded_global_options, 'sanitize_text_field' );
[1514] Fix | Delete
}
[1515] Fix | Delete
}
[1516] Fix | Delete
[1517] Fix | Delete
if ( empty( $global_shortcode ) ) {
[1518] Fix | Delete
$global_shortcode['error'] = 'nothing';
[1519] Fix | Delete
}
[1520] Fix | Delete
[1521] Fix | Delete
$json_post_data = wp_json_encode( $global_shortcode );
[1522] Fix | Delete
[1523] Fix | Delete
die( et_core_esc_previously( $json_post_data ) );
[1524] Fix | Delete
}
[1525] Fix | Delete
add_action( 'wp_ajax_et_pb_get_global_module', 'et_pb_get_global_module' );
[1526] Fix | Delete
[1527] Fix | Delete
function et_pb_update_layout() {
[1528] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1529] Fix | Delete
die( -1 );
[1530] Fix | Delete
}
[1531] Fix | Delete
[1532] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1533] Fix | Delete
die( -1 );
[1534] Fix | Delete
}
[1535] Fix | Delete
[1536] Fix | Delete
$post_id = isset( $_POST['et_template_post_id'] ) ? absint( $_POST['et_template_post_id'] ) : '';
[1537] Fix | Delete
$new_content = isset( $_POST['et_layout_content'] ) ? $_POST['et_layout_content'] : '';
[1538] Fix | Delete
$layout_type = isset( $_POST['et_layout_type'] ) ? sanitize_text_field( $_POST['et_layout_type'] ) : '';
[1539] Fix | Delete
[1540] Fix | Delete
if ( empty( $post_id ) || ! current_user_can( 'edit_post', $post_id ) ) {
[1541] Fix | Delete
die( -1 );
[1542] Fix | Delete
}
[1543] Fix | Delete
[1544] Fix | Delete
$update = array(
[1545] Fix | Delete
'ID' => $post_id,
[1546] Fix | Delete
'post_content' => $new_content,
[1547] Fix | Delete
);
[1548] Fix | Delete
[1549] Fix | Delete
$result = wp_update_post( $update );
[1550] Fix | Delete
[1551] Fix | Delete
if ( ! $result || is_wp_error( $result ) ) {
[1552] Fix | Delete
wp_send_json_error();
[1553] Fix | Delete
}
[1554] Fix | Delete
[1555] Fix | Delete
ET_Core_PageResource::remove_static_resources( 'all', 'all' );
[1556] Fix | Delete
[1557] Fix | Delete
if ( 'module' === $layout_type && isset( $_POST['et_unsynced_options'] ) ) {
[1558] Fix | Delete
$unsynced_options = sanitize_text_field( stripslashes( $_POST['et_unsynced_options'] ) );
[1559] Fix | Delete
[1560] Fix | Delete
update_post_meta( $post_id, '_et_pb_excluded_global_options', $unsynced_options );
[1561] Fix | Delete
}
[1562] Fix | Delete
[1563] Fix | Delete
die();
[1564] Fix | Delete
}
[1565] Fix | Delete
add_action( 'wp_ajax_et_pb_update_layout', 'et_pb_update_layout' );
[1566] Fix | Delete
[1567] Fix | Delete
[1568] Fix | Delete
function et_pb_load_layout() {
[1569] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1570] Fix | Delete
die( -1 );
[1571] Fix | Delete
}
[1572] Fix | Delete
[1573] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1574] Fix | Delete
die( -1 );
[1575] Fix | Delete
}
[1576] Fix | Delete
[1577] Fix | Delete
$layout_id = ! empty( $_POST['et_layout_id'] ) ? (int) $_POST['et_layout_id'] : 0;
[1578] Fix | Delete
[1579] Fix | Delete
if ( empty( $layout_id ) || ! current_user_can( 'edit_post', $layout_id ) ) {
[1580] Fix | Delete
die( -1 );
[1581] Fix | Delete
}
[1582] Fix | Delete
[1583] Fix | Delete
// sanitize via allowlisting
[1584] Fix | Delete
$replace_content = isset( $_POST['et_replace_content'] ) && 'on' === $_POST['et_replace_content'] ? 'on' : 'off';
[1585] Fix | Delete
[1586] Fix | Delete
set_theme_mod( 'et_pb_replace_content', $replace_content );
[1587] Fix | Delete
[1588] Fix | Delete
$layout = get_post( $layout_id );
[1589] Fix | Delete
[1590] Fix | Delete
if ( $layout ) {
[1591] Fix | Delete
echo et_core_esc_previously( $layout->post_content );
[1592] Fix | Delete
}
[1593] Fix | Delete
[1594] Fix | Delete
die();
[1595] Fix | Delete
}
[1596] Fix | Delete
add_action( 'wp_ajax_et_pb_load_layout', 'et_pb_load_layout' );
[1597] Fix | Delete
[1598] Fix | Delete
function et_pb_delete_layout() {
[1599] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1600] Fix | Delete
die( -1 );
[1601] Fix | Delete
}
[1602] Fix | Delete
[1603] Fix | Delete
$layout_id = ! empty( $_POST['et_layout_id'] ) ? (int) $_POST['et_layout_id'] : '';
[1604] Fix | Delete
[1605] Fix | Delete
if ( empty( $layout_id ) ) {
[1606] Fix | Delete
die( -1 );
[1607] Fix | Delete
}
[1608] Fix | Delete
[1609] Fix | Delete
if ( ! current_user_can( 'delete_post', $layout_id ) ) {
[1610] Fix | Delete
die( -1 );
[1611] Fix | Delete
}
[1612] Fix | Delete
[1613] Fix | Delete
wp_delete_post( $layout_id );
[1614] Fix | Delete
[1615] Fix | Delete
die();
[1616] Fix | Delete
}
[1617] Fix | Delete
add_action( 'wp_ajax_et_pb_delete_layout', 'et_pb_delete_layout' );
[1618] Fix | Delete
[1619] Fix | Delete
/**
[1620] Fix | Delete
* Enables zlib compression if needed/supported.
[1621] Fix | Delete
*/
[1622] Fix | Delete
function et_builder_enable_zlib_compression() {
[1623] Fix | Delete
// If compression is already enabled, do nothing
[1624] Fix | Delete
if ( 1 === intval( @ini_get( 'zlib.output_compression' ) ) ) {
[1625] Fix | Delete
return;
[1626] Fix | Delete
}
[1627] Fix | Delete
[1628] Fix | Delete
// We need to be sure no content has been pushed yet before enabling compression
[1629] Fix | Delete
// to avoid decoding errors. To do so, we flush buffer and then check header_sent
[1630] Fix | Delete
while ( ob_get_level() ) {
[1631] Fix | Delete
ob_end_flush();
[1632] Fix | Delete
}
[1633] Fix | Delete
[1634] Fix | Delete
if ( headers_sent() ) {
[1635] Fix | Delete
// Something has been sent already, could be PHP notices or other plugin output
[1636] Fix | Delete
return;
[1637] Fix | Delete
}
[1638] Fix | Delete
[1639] Fix | Delete
// We use ob_gzhandler because less prone to errors with WP
[1640] Fix | Delete
if ( function_exists( 'ob_gzhandler' ) ) {
[1641] Fix | Delete
// Faster compression, requires less cpu/memory
[1642] Fix | Delete
@ini_set( 'zlib.output_compression_level', 1 );
[1643] Fix | Delete
[1644] Fix | Delete
ob_start( 'ob_gzhandler' );
[1645] Fix | Delete
}
[1646] Fix | Delete
}
[1647] Fix | Delete
[1648] Fix | Delete
function et_pb_get_backbone_templates() {
[1649] Fix | Delete
if ( ! wp_verify_nonce( $_POST['et_admin_load_nonce'], 'et_admin_load_nonce' ) ) {
[1650] Fix | Delete
die( -1 );
[1651] Fix | Delete
}
[1652] Fix | Delete
[1653] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1654] Fix | Delete
die( -1 );
[1655] Fix | Delete
}
[1656] Fix | Delete
[1657] Fix | Delete
$post_type = isset( $_POST['et_post_type'] ) ? sanitize_text_field( $_POST['et_post_type'] ) : '';
[1658] Fix | Delete
$start_from = isset( $_POST['et_templates_start_from'] ) ? sanitize_text_field( $_POST['et_templates_start_from'] ) : 0;
[1659] Fix | Delete
$amount = ET_BUILDER_AJAX_TEMPLATES_AMOUNT;
[1660] Fix | Delete
[1661] Fix | Delete
// Enable zlib compression
[1662] Fix | Delete
et_builder_enable_zlib_compression();
[1663] Fix | Delete
// get the portion of templates
[1664] Fix | Delete
$result = wp_json_encode( ET_Builder_Element::output_templates( $post_type, $start_from, $amount ) );
[1665] Fix | Delete
[1666] Fix | Delete
die( et_core_intentionally_unescaped( $result, 'html' ) );
[1667] Fix | Delete
}
[1668] Fix | Delete
add_action( 'wp_ajax_et_pb_get_backbone_templates', 'et_pb_get_backbone_templates' );
[1669] Fix | Delete
[1670] Fix | Delete
/**
[1671] Fix | Delete
* Determine if a post is built by a certain builder.
[1672] Fix | Delete
*
[1673] Fix | Delete
* @param int $post_id The post_id to check.
[1674] Fix | Delete
* @param string $built_by_builder The builder to check if the post is built by. Allowed values: fb, bb.
[1675] Fix | Delete
*
[1676] Fix | Delete
* @return bool
[1677] Fix | Delete
*/
[1678] Fix | Delete
function et_builder_is_builder_built( $post_id, $built_by_builder ) {
[1679] Fix | Delete
$_post = get_post( $post_id );
[1680] Fix | Delete
[1681] Fix | Delete
// a autosave could be passed as $post_id, and an autosave will not have post_meta and then et_pb_is_pagebuilder_used() will always return false.
[1682] Fix | Delete
$parent_post = wp_is_post_autosave( $post_id ) ? get_post( $_post->post_parent ) : $_post;
[1683] Fix | Delete
[1684] Fix | Delete
if ( ! $post_id || ! $_post || ! is_object( $_post ) || ! et_pb_is_pagebuilder_used( $parent_post->ID ) ) {
[1685] Fix | Delete
return false;
[1686] Fix | Delete
}
[1687] Fix | Delete
[1688] Fix | Delete
// ensure this is an allowed builder post_type
[1689] Fix | Delete
if ( ! in_array( $parent_post->post_type, et_builder_get_builder_post_types() ) ) {
[1690] Fix | Delete
return false;
[1691] Fix | Delete
}
[1692] Fix | Delete
[1693] Fix | Delete
// allowlist the builder slug
[1694] Fix | Delete
$built_by_builder = in_array( $built_by_builder, array( 'fb', 'bb' ) ) ? $built_by_builder : '';
[1695] Fix | Delete
[1696] Fix | Delete
// the built by slug prepended to the first section automatically, in this format: fb_built="1"
[1697] Fix | Delete
$pattern = '/^\[et_pb_section ' . $built_by_builder . '_built="1"/s';
[1698] Fix | Delete
[1699] Fix | Delete
return preg_match( $pattern, $_post->post_content );
[1700] Fix | Delete
}
[1701] Fix | Delete
[1702] Fix | Delete
/**
[1703] Fix | Delete
* @return bool
[1704] Fix | Delete
*/
[1705] Fix | Delete
function et_is_builder_available_cookie_set() {
[1706] Fix | Delete
static $builder_available = null;
[1707] Fix | Delete
[1708] Fix | Delete
if ( null !== $builder_available ) {
[1709] Fix | Delete
return $builder_available;
[1710] Fix | Delete
}
[1711] Fix | Delete
[1712] Fix | Delete
foreach( (array) $_COOKIE as $cookie => $value ) {
[1713] Fix | Delete
if ( 0 === strpos( $cookie, 'et-editor-available-post-' ) ) {
[1714] Fix | Delete
$builder_available = true;
[1715] Fix | Delete
[1716] Fix | Delete
return $builder_available;
[1717] Fix | Delete
}
[1718] Fix | Delete
}
[1719] Fix | Delete
[1720] Fix | Delete
$builder_available = false;
[1721] Fix | Delete
[1722] Fix | Delete
return $builder_available;
[1723] Fix | Delete
}
[1724] Fix | Delete
[1725] Fix | Delete
function et_builder_heartbeat_interval() {
[1726] Fix | Delete
return apply_filters( 'et_builder_heartbeat_interval', 30 );
[1727] Fix | Delete
}
[1728] Fix | Delete
[1729] Fix | Delete
function et_builder_ensure_heartbeat_interval( $response, $screen_id ) {
[1730] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1731] Fix | Delete
return $response;
[1732] Fix | Delete
}
[1733] Fix | Delete
[1734] Fix | Delete
if ( ! isset( $response['heartbeat_interval'] ) ) {
[1735] Fix | Delete
return $response;
[1736] Fix | Delete
}
[1737] Fix | Delete
[1738] Fix | Delete
if ( et_builder_heartbeat_interval() === $response['heartbeat_interval'] ) {
[1739] Fix | Delete
return $response;
[1740] Fix | Delete
}
[1741] Fix | Delete
[1742] Fix | Delete
if ( ! et_is_builder_available_cookie_set() ) {
[1743] Fix | Delete
return $response;
[1744] Fix | Delete
}
[1745] Fix | Delete
[1746] Fix | Delete
$response['heartbeat_interval'] = et_builder_heartbeat_interval();
[1747] Fix | Delete
[1748] Fix | Delete
return $response;
[1749] Fix | Delete
}
[1750] Fix | Delete
add_filter( 'heartbeat_send', 'et_builder_ensure_heartbeat_interval', 100, 2 );
[1751] Fix | Delete
[1752] Fix | Delete
function et_pb_heartbeat_post_modified( $response ) {
[1753] Fix | Delete
et_core_nonce_verified_previously();
[1754] Fix | Delete
[1755] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1756] Fix | Delete
return $response;
[1757] Fix | Delete
}
[1758] Fix | Delete
[1759] Fix | Delete
if ( empty( $_POST['data'] ) ) {
[1760] Fix | Delete
return $response;
[1761] Fix | Delete
}
[1762] Fix | Delete
[1763] Fix | Delete
$heartbeat_data = $_POST['data'];
[1764] Fix | Delete
$has_focus = isset( $_POST['has_focus'] ) && 'true' === $_POST['has_focus'] ? true : false;
[1765] Fix | Delete
$heartbeat_data_et = !empty( $heartbeat_data['et'] ) ? $heartbeat_data['et'] : false;
[1766] Fix | Delete
[1767] Fix | Delete
if ( ! empty( $heartbeat_data_et ) ) {
[1768] Fix | Delete
$post_id = ! empty( $heartbeat_data_et['post_id'] ) ? absint( $heartbeat_data_et['post_id'] ) : '';
[1769] Fix | Delete
[1770] Fix | Delete
if ( empty( $heartbeat_data_et['post_id'] ) || ! current_user_can( 'edit_post', $post_id ) ) {
[1771] Fix | Delete
return $response;
[1772] Fix | Delete
}
[1773] Fix | Delete
[1774] Fix | Delete
$last_post_modified = sanitize_text_field( $heartbeat_data_et['last_post_modified'] );
[1775] Fix | Delete
$built_by = sanitize_text_field( $heartbeat_data_et['built_by'] );
[1776] Fix | Delete
$force_check = isset( $heartbeat_data_et['force_check'] ) && 'true' === $heartbeat_data_et['force_check'] ? true : false;
[1777] Fix | Delete
$force_autosave = isset( $heartbeat_data_et['force_autosave'] ) && 'true' === $heartbeat_data_et['force_autosave'] ? true : false;
[1778] Fix | Delete
$current_user_id = get_current_user_id();
[1779] Fix | Delete
[1780] Fix | Delete
$_post = get_post( $post_id );
[1781] Fix | Delete
[1782] Fix | Delete
if ( ! $post_id || ! $_post || ! is_object( $_post ) ) {
[1783] Fix | Delete
return $response;
[1784] Fix | Delete
}
[1785] Fix | Delete
[1786] Fix | Delete
// minimum sucessful response
[1787] Fix | Delete
$response['et'] = array(
[1788] Fix | Delete
'received' => true,
[1789] Fix | Delete
'force_check' => $force_check,
[1790] Fix | Delete
'force_autosave' => $force_autosave,
[1791] Fix | Delete
);
[1792] Fix | Delete
[1793] Fix | Delete
// the editor in focus is not going to be receiving an update from the other editor
[1794] Fix | Delete
// so we can return early
[1795] Fix | Delete
if ( $has_focus && !$force_check ) {
[1796] Fix | Delete
$response['et']['action'] = 'No actions since this editor has focus'; // dev use
[1797] Fix | Delete
return $response;
[1798] Fix | Delete
}
[1799] Fix | Delete
[1800] Fix | Delete
if ( $force_autosave ) {
[1801] Fix | Delete
$response['et']['action'] = 'No actions since this is a force autosave request'; // dev use
[1802] Fix | Delete
return $response;
[1803] Fix | Delete
}
[1804] Fix | Delete
[1805] Fix | Delete
// from here down we know that the following logic applies to the editor
[1806] Fix | Delete
// currently *not* in focus, i.e. the one eligable for a potential sync update
[1807] Fix | Delete
[1808] Fix | Delete
// sync builder settings
[1809] Fix | Delete
$builder_settings_autosave = get_post_meta( $post_id, "_et_builder_settings_autosave_{$current_user_id}", true );
[1810] Fix | Delete
if ( ! empty( $builder_settings_autosave ) ) {
[1811] Fix | Delete
$response['et']['builder_settings_autosave'] = $builder_settings_autosave;
[1812] Fix | Delete
}
[1813] Fix | Delete
[1814] Fix | Delete
$post_content = $_post->post_content;
[1815] Fix | Delete
$post_modified = $_post->post_modified;
[1816] Fix | Delete
[1817] Fix | Delete
$autosave = wp_get_post_autosave( $post_id, $current_user_id );
[1818] Fix | Delete
[1819] Fix | Delete
$post_post_modified = date( 'U', strtotime( $post_modified ) );
[1820] Fix | Delete
$response['et']['post_post_modified'] = $_post->post_modified;
[1821] Fix | Delete
[1822] Fix | Delete
if ( !empty( $autosave ) ) {
[1823] Fix | Delete
$response['et']['autosave_exists'] = true;
[1824] Fix | Delete
$autosave_post_modified = date( 'U', strtotime( $autosave->post_modified ) );
[1825] Fix | Delete
$response['et']['autosave_post_modified'] = $autosave->post_modified;
[1826] Fix | Delete
} else {
[1827] Fix | Delete
$response['et']['autosave_exists'] = false;
[1828] Fix | Delete
}
[1829] Fix | Delete
[1830] Fix | Delete
if ( !empty( $autosave ) && $autosave_post_modified > $post_post_modified ) {
[1831] Fix | Delete
$response['et']['used_autosave'] = true;
[1832] Fix | Delete
$post_id = $autosave->ID;
[1833] Fix | Delete
$post_content = $autosave->post_content;
[1834] Fix | Delete
$post_modified = $autosave->post_modified;
[1835] Fix | Delete
} else {
[1836] Fix | Delete
$response['et']['used_autosave'] = false;
[1837] Fix | Delete
}
[1838] Fix | Delete
[1839] Fix | Delete
$response['et']['post_id'] = $post_id;
[1840] Fix | Delete
$response['et']['last_post_modified'] = $last_post_modified;
[1841] Fix | Delete
$response['et']['post_modified'] = $post_modified;
[1842] Fix | Delete
[1843] Fix | Delete
// security short circuit
[1844] Fix | Delete
$_post = get_post( $post_id );
[1845] Fix | Delete
[1846] Fix | Delete
// $post_id could be an autosave
[1847] Fix | Delete
$parent_post = wp_is_post_autosave( $post_id ) ? get_post( $_post->post_parent ) : $_post;
[1848] Fix | Delete
[1849] Fix | Delete
if ( ! et_pb_is_pagebuilder_used( $parent_post->ID ) || ! in_array( $parent_post->post_type, et_builder_get_builder_post_types() ) ) {
[1850] Fix | Delete
return $response;
[1851] Fix | Delete
}
[1852] Fix | Delete
// end security short circuit
[1853] Fix | Delete
[1854] Fix | Delete
if ( $last_post_modified !== $post_modified ) {
[1855] Fix | Delete
[1856] Fix | Delete
// check if the newly modified was made by opposite builder,
[1857] Fix | Delete
// and if so, send it back in the response
[1858] Fix | Delete
if ( 'bb' === $built_by ) {
[1859] Fix | Delete
// backend builder in use and in focus
[1860] Fix | Delete
[1861] Fix | Delete
$response['et']['is_built_by_fb'] = et_builder_is_builder_built( $post_id, 'fb' );
[1862] Fix | Delete
// check if latest post_content is built by fb
[1863] Fix | Delete
if ( et_builder_is_builder_built( $post_id, 'fb' ) ) {
[1864] Fix | Delete
if ( et_builder_bfb_enabled() ) {
[1865] Fix | Delete
$post_content_obj = et_fb_process_shortcode( $post_content );
[1866] Fix | Delete
$response['et']['post_content_obj'] = $post_content_obj;
[1867] Fix | Delete
} else {
[1868] Fix | Delete
$response['et']['post_content'] = $post_content;
[1869] Fix | Delete
}
[1870] Fix | Delete
$response['et']['action'] = 'current editor is bb, updated to content that was built by fb'; // dev use
[1871] Fix | Delete
} else {
[1872] Fix | Delete
$response['et']['action'] = 'current editor is bb, content wasnt updated by fb'; // dev use
[1873] Fix | Delete
}
[1874] Fix | Delete
} else {
[1875] Fix | Delete
// frontend builder in use and in focus
[1876] Fix | Delete
[1877] Fix | Delete
$response['et']['is_built_by_bb'] = et_builder_is_builder_built( $post_id, 'bb' );
[1878] Fix | Delete
// check if latest post_content is built by bb
[1879] Fix | Delete
if ( et_builder_is_builder_built( $post_id, et_builder_bfb_enabled() ? 'fb' : 'bb' ) ) {
[1880] Fix | Delete
$post_content_obj = et_fb_process_shortcode( $post_content );
[1881] Fix | Delete
[1882] Fix | Delete
$response['et']['post_content_obj'] = $post_content_obj;
[1883] Fix | Delete
$response['et']['action'] = 'current editor is fb, updated to content that was built by bb'; // dev use
[1884] Fix | Delete
} else {
[1885] Fix | Delete
$response['et']['action'] = 'current editor is fb, content wasnt updated by bb'; // dev use
[1886] Fix | Delete
}
[1887] Fix | Delete
}
[1888] Fix | Delete
[1889] Fix | Delete
$global_presets_manager = ET_Builder_Global_Presets_Settings::instance();
[1890] Fix | Delete
$response['et']['global_presets'] = $global_presets_manager->get_global_presets();
[1891] Fix | Delete
} else {
[1892] Fix | Delete
$response['et']['post_not_modified'] = true;
[1893] Fix | Delete
$response['et']['action'] = 'post content not modified externally'; // dev use
[1894] Fix | Delete
}
[1895] Fix | Delete
}
[1896] Fix | Delete
[1897] Fix | Delete
return $response;
[1898] Fix | Delete
}
[1899] Fix | Delete
add_filter( 'heartbeat_send', 'et_pb_heartbeat_post_modified' );
[1900] Fix | Delete
[1901] Fix | Delete
/**
[1902] Fix | Delete
* Save a post submitted via ETBuilder Heartbeat.
[1903] Fix | Delete
*
[1904] Fix | Delete
* Adapted from WordPress
[1905] Fix | Delete
*
[1906] Fix | Delete
* @copyright 2016 by the WordPress contributors.
[1907] Fix | Delete
* This program is free software; you can redistribute it and/or modify
[1908] Fix | Delete
* it under the terms of the GNU General Public License as published by
[1909] Fix | Delete
* the Free Software Foundation; either version 2 of the License, or
[1910] Fix | Delete
* (at your option) any later version.
[1911] Fix | Delete
*
[1912] Fix | Delete
* This program is distributed in the hope that it will be useful,
[1913] Fix | Delete
* but WITHOUT ANY WARRANTY; without even the implied warranty of
[1914] Fix | Delete
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[1915] Fix | Delete
* GNU General Public License for more details.
[1916] Fix | Delete
*
[1917] Fix | Delete
* You should have received a copy of the GNU General Public License
[1918] Fix | Delete
* along with this program; if not, write to the Free Software
[1919] Fix | Delete
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
[1920] Fix | Delete
*
[1921] Fix | Delete
* This program incorporates work covered by the following copyright and
[1922] Fix | Delete
* permission notices:
[1923] Fix | Delete
*
[1924] Fix | Delete
* b2 is (c) 2001, 2002 Michel Valdrighi - m@tidakada.com - http://tidakada.com
[1925] Fix | Delete
*
[1926] Fix | Delete
* b2 is released under the GPL
[1927] Fix | Delete
*
[1928] Fix | Delete
* WordPress - Web publishing software
[1929] Fix | Delete
*
[1930] Fix | Delete
* Copyright 2003-2010 by the contributors
[1931] Fix | Delete
*
[1932] Fix | Delete
* WordPress is released under the GPL
[1933] Fix | Delete
*
[1934] Fix | Delete
* @param array $post_data Associative array of the submitted post data.
[1935] Fix | Delete
* @return mixed The value 0 or WP_Error on failure. The saved post ID on success.
[1936] Fix | Delete
* The ID can be the draft post_id or the autosave revision post_id.
[1937] Fix | Delete
*/
[1938] Fix | Delete
[1939] Fix | Delete
function et_fb_autosave( $post_data ) {
[1940] Fix | Delete
if ( ! defined( 'DOING_AUTOSAVE' ) ) {
[1941] Fix | Delete
define( 'DOING_AUTOSAVE', true );
[1942] Fix | Delete
}
[1943] Fix | Delete
[1944] Fix | Delete
$post_id = (int) $post_data['post_id'];
[1945] Fix | Delete
$post_data['ID'] = $post_data['post_ID'] = $post_id;
[1946] Fix | Delete
[1947] Fix | Delete
if ( false === wp_verify_nonce( $post_data['et_fb_autosave_nonce'], 'et_fb_autosave_nonce' ) ) {
[1948] Fix | Delete
return new WP_Error( 'invalid_nonce', __( 'Error while saving.', 'et_builder' ) );
[1949] Fix | Delete
}
[1950] Fix | Delete
[1951] Fix | Delete
$_post = get_post( $post_id );
[1952] Fix | Delete
$current_user_id = get_current_user_id();
[1953] Fix | Delete
[1954] Fix | Delete
if ( ! et_fb_current_user_can_save( $post_id ) ) {
[1955] Fix | Delete
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.', 'et_builder' ) );
[1956] Fix | Delete
}
[1957] Fix | Delete
[1958] Fix | Delete
// NOTE, no stripslashes() needed first as it's already been done on the POST'ed $post_data prior
[1959] Fix | Delete
$shortcode_data = json_decode( $post_data['content'], true );
[1960] Fix | Delete
[1961] Fix | Delete
$options = array(
[1962] Fix | Delete
'post_type' => sanitize_text_field( $post_data['post_type'] ),
[1963] Fix | Delete
);
[1964] Fix | Delete
$post_data['content'] = et_fb_process_to_shortcode( $shortcode_data, $options );
[1965] Fix | Delete
[1966] Fix | Delete
if ( 'auto-draft' === $_post->post_status ) {
[1967] Fix | Delete
$post_data['post_status'] = 'draft';
[1968] Fix | Delete
}
[1969] Fix | Delete
[1970] Fix | Delete
if ( ! wp_check_post_lock( $_post->ID ) && get_current_user_id() === $_post->post_author && ( 'auto-draft' === $_post->post_status || 'draft' === $_post->post_status ) ) {
[1971] Fix | Delete
// Drafts and auto-drafts are just overwritten by autosave for the same user if the post is not locked
[1972] Fix | Delete
return edit_post( wp_slash( $post_data ) );
[1973] Fix | Delete
} else {
[1974] Fix | Delete
// Non drafts or other users drafts are not overwritten. The autosave is stored in a special post revision for each user.
[1975] Fix | Delete
return wp_create_post_autosave( wp_slash( $post_data ) );
[1976] Fix | Delete
}
[1977] Fix | Delete
}
[1978] Fix | Delete
[1979] Fix | Delete
function et_pb_autosave_builder_settings( $post_id, $builder_settings ) {
[1980] Fix | Delete
$current_user_id = get_current_user_id();
[1981] Fix | Delete
// Builder settings autosave
[1982] Fix | Delete
if ( !empty( $builder_settings ) ) {
[1983] Fix | Delete
[1984] Fix | Delete
// Data is coming from `wp_ajax_heartbeat` which ran `wp_unslash` on it,
[1985] Fix | Delete
// `update_post_meta` will do the same, resulting in legit slashes being removed
[1986] Fix | Delete
// from page settings.
[1987] Fix | Delete
// The solution is to add those slashes back before updating metas.
[1988] Fix | Delete
$builder_settings = wp_slash( $builder_settings );
[1989] Fix | Delete
[1990] Fix | Delete
// Pseudo activate AB Testing for VB draft/builder-sync interface
[1991] Fix | Delete
if ( isset( $builder_settings['et_pb_use_ab_testing'] ) ) {
[1992] Fix | Delete
// Save autosave/draft AB Testing status
[1993] Fix | Delete
update_post_meta(
[1994] Fix | Delete
$post_id,
[1995] Fix | Delete
'_et_pb_use_ab_testing_draft',
[1996] Fix | Delete
sanitize_text_field( $builder_settings['et_pb_use_ab_testing'] )
[1997] Fix | Delete
);
[1998] Fix | Delete
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function