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: functions.php
$slug_post_type = ! empty( $options['post_type'] ) ? $options['post_type'] : 'page';
[1500] Fix | Delete
$valid_slugs = ET_Builder_Element::get_module_slugs_by_post_type( $slug_post_type );
[1501] Fix | Delete
}
[1502] Fix | Delete
[1503] Fix | Delete
foreach ( $_object as $item ) {
[1504] Fix | Delete
// do not proceed if $item is empty
[1505] Fix | Delete
if ( empty( $item ) ) {
[1506] Fix | Delete
continue;
[1507] Fix | Delete
}
[1508] Fix | Delete
$attributes = '';
[1509] Fix | Delete
$content = '';
[1510] Fix | Delete
$type = sanitize_text_field( $item['type'] );
[1511] Fix | Delete
$type = esc_attr( $type );
[1512] Fix | Delete
[1513] Fix | Delete
// if option enabled, reject invalid slugs
[1514] Fix | Delete
if ( $options['force_valid_slugs'] ) {
[1515] Fix | Delete
if ( ! in_array( $type, $valid_slugs ) ) {
[1516] Fix | Delete
continue;
[1517] Fix | Delete
}
[1518] Fix | Delete
}
[1519] Fix | Delete
[1520] Fix | Delete
if ( ! empty( $item['raw_child_content'] ) ) {
[1521] Fix | Delete
$content = stripslashes( $item['raw_child_content'] );
[1522] Fix | Delete
}
[1523] Fix | Delete
[1524] Fix | Delete
if ( $options['apply_global_presets'] ) {
[1525] Fix | Delete
$module_type = $global_presets_manager->maybe_convert_module_type( $type, $item['attrs'] );
[1526] Fix | Delete
$module_global_presets = $global_presets_manager->get_module_presets_settings( $module_type, $item['attrs'] );
[1527] Fix | Delete
$item['attrs'] = array_merge( $module_global_presets, $item['attrs'] );
[1528] Fix | Delete
}
[1529] Fix | Delete
[1530] Fix | Delete
foreach ( $item['attrs'] as $attribute => $value ) {
[1531] Fix | Delete
// ignore computed fields
[1532] Fix | Delete
if ( '__' === substr( $attribute, 0, 2 ) ) {
[1533] Fix | Delete
continue;
[1534] Fix | Delete
}
[1535] Fix | Delete
[1536] Fix | Delete
// Sanitize attribute
[1537] Fix | Delete
$attribute = sanitize_text_field( $attribute );
[1538] Fix | Delete
[1539] Fix | Delete
// Sanitize input properly
[1540] Fix | Delete
if ( isset( $font_icon_fields[ $item['type'] ][ $attribute ] ) ) {
[1541] Fix | Delete
$value = esc_attr( $value );
[1542] Fix | Delete
}
[1543] Fix | Delete
[1544] Fix | Delete
// handle content
[1545] Fix | Delete
if ( in_array( $attribute, array('content', 'raw_content') ) ) {
[1546] Fix | Delete
// do not override the content if item has raw_child_content
[1547] Fix | Delete
if ( empty( $item['raw_child_content'] ) ) {
[1548] Fix | Delete
$content = $value;
[1549] Fix | Delete
[1550] Fix | Delete
$content = trim( $content );
[1551] Fix | Delete
[1552] Fix | Delete
if ( ! empty( $content ) && 'content' === $attribute ) {
[1553] Fix | Delete
$content = "\n\n" . $content . "\n\n";
[1554] Fix | Delete
}
[1555] Fix | Delete
}
[1556] Fix | Delete
} else {
[1557] Fix | Delete
// Since WordPress version 5.1, any links in the content that
[1558] Fix | Delete
// has "target" attribute will be automatically added
[1559] Fix | Delete
// rel="noreferrer noopener" attribute. This attribute added
[1560] Fix | Delete
// after the shortcode processed in et_fb_process_to_shortcode
[1561] Fix | Delete
// function. This become an issue for the builder while parsing the shortcode attributes
[1562] Fix | Delete
// because the double quote that wrapping the "rel" attribute value is not encoded.
[1563] Fix | Delete
// So we need to manipulate "target" attribute here before storing the content by renaming
[1564] Fix | Delete
// is as "data-et-target-link". Later in "et_pb_fix_shortcodes" function
[1565] Fix | Delete
// we will turn it back as "target"
[1566] Fix | Delete
$value = str_replace( ' target=', ' data-et-target-link=', $value );
[1567] Fix | Delete
[1568] Fix | Delete
$is_include_attr = false;
[1569] Fix | Delete
[1570] Fix | Delete
if ( '' === $value
[1571] Fix | Delete
&& $attribute !== et_pb_hover_options()->get_field_base_name( $attribute )
[1572] Fix | Delete
&& et_pb_hover_options()->is_enabled( et_pb_hover_options()->get_field_base_name( $attribute ), $item['attrs'] ) ) {
[1573] Fix | Delete
$is_include_attr = true;
[1574] Fix | Delete
}
[1575] Fix | Delete
[1576] Fix | Delete
if ( '' === $value
[1577] Fix | Delete
&& $attribute !== et_pb_responsive_options()->get_field_base_name( $attribute )
[1578] Fix | Delete
&& et_pb_responsive_options()->is_enabled( et_pb_responsive_options()->get_field_base_name( $attribute ), $item['attrs'] ) ) {
[1579] Fix | Delete
$is_include_attr = true;
[1580] Fix | Delete
}
[1581] Fix | Delete
[1582] Fix | Delete
if ( '' !== $value ) {
[1583] Fix | Delete
$is_include_attr = true;
[1584] Fix | Delete
}
[1585] Fix | Delete
[1586] Fix | Delete
if ( $is_include_attr ) {
[1587] Fix | Delete
// TODO, should we check for and handle default here? probably done in FB alredy...
[1588] Fix | Delete
[1589] Fix | Delete
// Make sure double quotes are encoded, before adding values to shortcode
[1590] Fix | Delete
$value = str_ireplace('"', '%22', $value);
[1591] Fix | Delete
[1592] Fix | Delete
// Make sure single backslash is encoded, before adding values to Shortcode.
[1593] Fix | Delete
if ( 'breadcrumb_separator' === $attribute ) {
[1594] Fix | Delete
$value = str_ireplace( '\\', '%5c', $value );
[1595] Fix | Delete
}
[1596] Fix | Delete
[1597] Fix | Delete
// Encode backslash for custom CSS-related and json attributes.
[1598] Fix | Delete
$json_attributes = array( 'checkbox_options', 'radio_options', 'select_options' );
[1599] Fix | Delete
if ( 0 === strpos( $attribute, 'custom_css_' ) || in_array( $attribute, $json_attributes ) ) {
[1600] Fix | Delete
$value = str_ireplace('\\', '%92', $value);
[1601] Fix | Delete
[1602] Fix | Delete
} else if ( et_builder_parse_dynamic_content( $value )->is_dynamic() ) {
[1603] Fix | Delete
$value = str_replace( '\\', '%92', $value );
[1604] Fix | Delete
}
[1605] Fix | Delete
[1606] Fix | Delete
$attributes .= ' ' . esc_attr( $attribute ) . '="' . et_core_esc_previously( $value ) . '"';
[1607] Fix | Delete
}
[1608] Fix | Delete
}
[1609] Fix | Delete
}
[1610] Fix | Delete
[1611] Fix | Delete
$attributes = str_replace( array( '[', ']' ), array( '%91', '%93' ), $attributes );
[1612] Fix | Delete
[1613] Fix | Delete
// prefix sections with a fb_built attr flag
[1614] Fix | Delete
if ( 'et_pb_section' === $type ) {
[1615] Fix | Delete
$attributes = ' fb_built="1"' . $attributes;
[1616] Fix | Delete
}
[1617] Fix | Delete
[1618] Fix | Delete
// build shortcode
[1619] Fix | Delete
// start the opening tag
[1620] Fix | Delete
$output .= '[' . $type . $attributes;
[1621] Fix | Delete
[1622] Fix | Delete
// close the opening tag, depending on self closing
[1623] Fix | Delete
if ( empty( $content ) && ! isset( $item['content'] ) && ! in_array( $type, $structure_types ) ) {
[1624] Fix | Delete
$open_tag_only = true;
[1625] Fix | Delete
$output .= ' /]';
[1626] Fix | Delete
} else {
[1627] Fix | Delete
$open_tag_only = false;
[1628] Fix | Delete
$output .= ']';
[1629] Fix | Delete
}
[1630] Fix | Delete
[1631] Fix | Delete
// if applicable, add inner content and close tag
[1632] Fix | Delete
if ( ! $open_tag_only ) {
[1633] Fix | Delete
if ( 'et_pb_section' === $type && isset( $item['attrs'] ) && isset( $item['attrs']['fullwidth'] ) && 'on' !== $item['attrs']['fullwidth'] && isset( $item['attrs']['specialty'] ) && 'on' !== $item['attrs']['specialty'] && ( ! isset( $item['content'] ) || ! is_array( $item['content'] ) ) ) {
[1634] Fix | Delete
// insert empty row if saving empty Regular section to make it work correctly in BB
[1635] Fix | Delete
$output .= '[et_pb_row admin_label="Row"][/et_pb_row]';
[1636] Fix | Delete
} else if ( isset( $item['content'] ) && is_array( $item['content'] ) ) {
[1637] Fix | Delete
$output .= et_fb_process_to_shortcode( $item['content'], $options, '', $escape_content_slashes );
[1638] Fix | Delete
} else {
[1639] Fix | Delete
if ( !empty( $content ) ) {
[1640] Fix | Delete
if ( et_is_builder_plugin_active() && in_array( $type, ET_Builder_Element::get_has_content_modules() ) ) {
[1641] Fix | Delete
// Wrap content in autop to avoid tagless content on FE due to content is edited on html editor and only
[1642] Fix | Delete
// have one-line without newline wrap which prevent `the_content`'s wpautop filter to properly wrap it
[1643] Fix | Delete
$content = wpautop( $content );
[1644] Fix | Delete
}
[1645] Fix | Delete
[1646] Fix | Delete
$output .= $content;
[1647] Fix | Delete
} else {
[1648] Fix | Delete
if ( isset( $item['content'] ) ) {
[1649] Fix | Delete
$_content = $item['content'];
[1650] Fix | Delete
[1651] Fix | Delete
if ( $escape_content_slashes ) {
[1652] Fix | Delete
$_content = str_replace( '\\', '\\\\', $_content );
[1653] Fix | Delete
}
[1654] Fix | Delete
[1655] Fix | Delete
if ( et_is_builder_plugin_active() && in_array( $type, ET_Builder_Element::get_has_content_modules() ) ) {
[1656] Fix | Delete
// Wrap content in autop to avoid tagless content on FE due to content is edited on html editor and only
[1657] Fix | Delete
// have one-line without newline wrap which prevent `the_content`'s wpautop filter to properly wrap it
[1658] Fix | Delete
$_content = wpautop( $_content );
[1659] Fix | Delete
}
[1660] Fix | Delete
[1661] Fix | Delete
$output .= $_content;
[1662] Fix | Delete
} else {
[1663] Fix | Delete
$output .= '';
[1664] Fix | Delete
}
[1665] Fix | Delete
[1666] Fix | Delete
}
[1667] Fix | Delete
}
[1668] Fix | Delete
[1669] Fix | Delete
// add the closing tag
[1670] Fix | Delete
$output .= '[/' . $type . ']';
[1671] Fix | Delete
}
[1672] Fix | Delete
}
[1673] Fix | Delete
[1674] Fix | Delete
return $output;
[1675] Fix | Delete
}
[1676] Fix | Delete
[1677] Fix | Delete
function et_fb_ajax_render_shortcode() {
[1678] Fix | Delete
if ( !isset( $_POST['et_pb_render_shortcode_nonce'] ) || !wp_verify_nonce( $_POST['et_pb_render_shortcode_nonce'], 'et_pb_render_shortcode_nonce' ) ) {
[1679] Fix | Delete
wp_send_json_error();
[1680] Fix | Delete
}
[1681] Fix | Delete
[1682] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1683] Fix | Delete
wp_send_json_error();
[1684] Fix | Delete
}
[1685] Fix | Delete
[1686] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[1687] Fix | Delete
[1688] Fix | Delete
global $et_pb_predefined_module_index;
[1689] Fix | Delete
[1690] Fix | Delete
$et_pb_predefined_module_index = isset( $_POST['et_fb_module_index'] ) && 'default' !== $_POST['et_fb_module_index'] ? sanitize_text_field( $_POST['et_fb_module_index'] ) : false;
[1691] Fix | Delete
[1692] Fix | Delete
$options = isset( $_POST['options'] ) ? $utils->sanitize_text_fields( $_POST['options'] ) : array();
[1693] Fix | Delete
[1694] Fix | Delete
// enforce valid module slugs only
[1695] Fix | Delete
// shortcode slugs need to be allowlisted so as to prevent malicious shortcodes from being generated and run through do_shortcode().
[1696] Fix | Delete
$options['force_valid_slugs'] = true;
[1697] Fix | Delete
[1698] Fix | Delete
// convert shortcode array to shortcode string.
[1699] Fix | Delete
$shortcode = et_fb_process_to_shortcode( $_POST['object'], $options );
[1700] Fix | Delete
[1701] Fix | Delete
// take shortcode string and ensure it's properly sanitized for the purposes of this function.
[1702] Fix | Delete
$shortcode = et_pb_enforce_builder_shortcode( $shortcode );
[1703] Fix | Delete
[1704] Fix | Delete
$output = do_shortcode( $shortcode );
[1705] Fix | Delete
[1706] Fix | Delete
$styles = ET_Builder_Element::get_style();
[1707] Fix | Delete
[1708] Fix | Delete
if ( ! empty( $styles ) ) {
[1709] Fix | Delete
$output .= sprintf(
[1710] Fix | Delete
'<style type="text/css" class="et-builder-advanced-style">
[1711] Fix | Delete
%1$s
[1712] Fix | Delete
</style>',
[1713] Fix | Delete
$styles
[1714] Fix | Delete
);
[1715] Fix | Delete
}
[1716] Fix | Delete
[1717] Fix | Delete
wp_send_json_success( $output );
[1718] Fix | Delete
}
[1719] Fix | Delete
add_action( 'wp_ajax_et_fb_ajax_render_shortcode', 'et_fb_ajax_render_shortcode' );
[1720] Fix | Delete
[1721] Fix | Delete
function et_fb_current_user_can_save( $post_id, $status = '' ) {
[1722] Fix | Delete
if ( is_page( $post_id ) ) {
[1723] Fix | Delete
if ( ! current_user_can( 'edit_pages' ) ) {
[1724] Fix | Delete
return false;
[1725] Fix | Delete
}
[1726] Fix | Delete
[1727] Fix | Delete
if ( ! current_user_can( 'publish_pages' ) && 'publish' === $status ) {
[1728] Fix | Delete
return false;
[1729] Fix | Delete
}
[1730] Fix | Delete
[1731] Fix | Delete
if ( ! current_user_can( 'edit_published_pages' ) && 'publish' === get_post_status( $post_id ) ) {
[1732] Fix | Delete
return false;
[1733] Fix | Delete
}
[1734] Fix | Delete
[1735] Fix | Delete
if ( ! current_user_can( 'edit_others_pages' ) && ! current_user_can( 'edit_page', $post_id ) ) {
[1736] Fix | Delete
return false;
[1737] Fix | Delete
}
[1738] Fix | Delete
} else {
[1739] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[1740] Fix | Delete
return false;
[1741] Fix | Delete
}
[1742] Fix | Delete
[1743] Fix | Delete
if ( ! current_user_can( 'publish_posts' ) && 'publish' === $status ) {
[1744] Fix | Delete
return false;
[1745] Fix | Delete
}
[1746] Fix | Delete
[1747] Fix | Delete
if ( ! current_user_can( 'edit_published_posts' ) && 'publish' === get_post_status( $post_id ) ) {
[1748] Fix | Delete
return false;
[1749] Fix | Delete
}
[1750] Fix | Delete
[1751] Fix | Delete
if ( ! current_user_can( 'edit_others_posts' ) && ! current_user_can( 'edit_post', $post_id ) ) {
[1752] Fix | Delete
return false;
[1753] Fix | Delete
}
[1754] Fix | Delete
}
[1755] Fix | Delete
[1756] Fix | Delete
return true;
[1757] Fix | Delete
}
[1758] Fix | Delete
[1759] Fix | Delete
function et_fb_ajax_drop_autosave() {
[1760] Fix | Delete
if ( !isset( $_POST['et_fb_drop_autosave_nonce'] ) || !wp_verify_nonce( $_POST['et_fb_drop_autosave_nonce'], 'et_fb_drop_autosave_nonce' ) ) {
[1761] Fix | Delete
wp_send_json_error();
[1762] Fix | Delete
}
[1763] Fix | Delete
[1764] Fix | Delete
$post_id = absint( $_POST['post_id'] );
[1765] Fix | Delete
[1766] Fix | Delete
if ( ! et_fb_current_user_can_save( $post_id ) ) {
[1767] Fix | Delete
wp_send_json_error();
[1768] Fix | Delete
}
[1769] Fix | Delete
[1770] Fix | Delete
$post_author = get_current_user_id();
[1771] Fix | Delete
$autosave = wp_get_post_autosave( $post_id, $post_author );
[1772] Fix | Delete
[1773] Fix | Delete
$autosave_deleted = false;
[1774] Fix | Delete
[1775] Fix | Delete
// delete builder settings autosave
[1776] Fix | Delete
delete_post_meta( $post_id, "_et_builder_settings_autosave_{$post_author}" );
[1777] Fix | Delete
[1778] Fix | Delete
if ( !empty( $autosave ) ) {
[1779] Fix | Delete
wp_delete_post_revision( $autosave->ID );
[1780] Fix | Delete
$autosave = wp_get_post_autosave( $post_id, $post_author );
[1781] Fix | Delete
if ( empty( $autosave ) ) {
[1782] Fix | Delete
$autosave_deleted = true;
[1783] Fix | Delete
}
[1784] Fix | Delete
} else {
[1785] Fix | Delete
$autosave_deleted = true;
[1786] Fix | Delete
}
[1787] Fix | Delete
[1788] Fix | Delete
if ( $autosave_deleted ) {
[1789] Fix | Delete
wp_send_json_success();
[1790] Fix | Delete
} else {
[1791] Fix | Delete
wp_send_json_error();
[1792] Fix | Delete
}
[1793] Fix | Delete
}
[1794] Fix | Delete
add_action( 'wp_ajax_et_fb_ajax_drop_autosave', 'et_fb_ajax_drop_autosave' );
[1795] Fix | Delete
[1796] Fix | Delete
function et_fb_ajax_save() {
[1797] Fix | Delete
if ( !isset( $_POST['et_fb_save_nonce'] ) || !wp_verify_nonce( $_POST['et_fb_save_nonce'], 'et_fb_save_nonce' ) ) {
[1798] Fix | Delete
wp_send_json_error();
[1799] Fix | Delete
}
[1800] Fix | Delete
[1801] Fix | Delete
$post_id = absint( $_POST['post_id'] );
[1802] Fix | Delete
[1803] Fix | Delete
if ( ! et_fb_current_user_can_save( $post_id, $_POST['options']['status'] ) ) {
[1804] Fix | Delete
wp_send_json_error();
[1805] Fix | Delete
}
[1806] Fix | Delete
[1807] Fix | Delete
$update = false;
[1808] Fix | Delete
[1809] Fix | Delete
$utils = ET_Core_Data_Utils::instance();
[1810] Fix | Delete
[1811] Fix | Delete
$layout_type = isset( $_POST['layout_type'] ) ? sanitize_text_field( $_POST['layout_type'] ) : '';
[1812] Fix | Delete
[1813] Fix | Delete
if ( ! isset( $_POST['skip_post_update'] ) ) {
[1814] Fix | Delete
$is_layout_block_preview = sanitize_text_field( $utils->array_get( $_POST, 'options.conditional_tags.is_layout_block', '' ) );
[1815] Fix | Delete
$block_id = sanitize_title( $utils->array_get( $_POST, 'options.current_page.blockId', '' ) );
[1816] Fix | Delete
$shortcode_data = json_decode( stripslashes( $_POST['modules'] ), true );
[1817] Fix | Delete
[1818] Fix | Delete
// Cast as bool if falsey; blockId is retrieved from ajax request, and
[1819] Fix | Delete
// already return empty string (falsey) if no value found. Nevertheless let's be more safe.
[1820] Fix | Delete
if ( ! $block_id ) {
[1821] Fix | Delete
$block_id = false;
[1822] Fix | Delete
}
[1823] Fix | Delete
[1824] Fix | Delete
// Cast as bool if falsey; is_layout_block_preview is retrieved from ajax request, and
[1825] Fix | Delete
// already return empty string (falsey) if no value found. Nevertheless let's be more safe.
[1826] Fix | Delete
if ( ! $is_layout_block_preview ) {
[1827] Fix | Delete
$is_layout_block_preview = false;
[1828] Fix | Delete
}
[1829] Fix | Delete
[1830] Fix | Delete
if ( ! $built_for_type = get_post_meta( $post_id, '_et_pb_built_for_post_type', true ) && ! $is_layout_block_preview ) {
[1831] Fix | Delete
update_post_meta( $post_id, '_et_pb_built_for_post_type', 'page' );
[1832] Fix | Delete
}
[1833] Fix | Delete
[1834] Fix | Delete
$post_content = et_fb_process_to_shortcode( $shortcode_data, $_POST['options'], $layout_type );
[1835] Fix | Delete
[1836] Fix | Delete
// Store a copy of the sanitized post content in case wpkses alters it since that
[1837] Fix | Delete
// would cause our check at the end of this function to fail.
[1838] Fix | Delete
$sanitized_content = sanitize_post_field( 'post_content', $post_content, $post_id, 'db' );
[1839] Fix | Delete
[1840] Fix | Delete
// Exit early for layout block update; builder should not actually save post content in this scenario
[1841] Fix | Delete
// Update post meta and let it is being used to update layoutContent on editor
[1842] Fix | Delete
if ( $is_layout_block_preview && $block_id ) {
[1843] Fix | Delete
$layout_preview_meta_key = "_et_block_layout_preview_{$block_id}";
[1844] Fix | Delete
$saved_layout = get_post_meta( $post_id, $layout_preview_meta_key, true );
[1845] Fix | Delete
[1846] Fix | Delete
// If saved layout is identical to the the layout sent via AJAX, return send json success;
[1847] Fix | Delete
// this is needed because update_post_meta() returns false if the saved layout is identical
[1848] Fix | Delete
// to the the one given as param
[1849] Fix | Delete
if ( ! empty( $saved_layout ) && $saved_layout === $post_content ) {
[1850] Fix | Delete
wp_send_json_success( array(
[1851] Fix | Delete
'save_verification' => true,
[1852] Fix | Delete
) );
[1853] Fix | Delete
[1854] Fix | Delete
wp_die();
[1855] Fix | Delete
}
[1856] Fix | Delete
[1857] Fix | Delete
$update = update_post_meta( $post_id, $layout_preview_meta_key, $post_content );
[1858] Fix | Delete
[1859] Fix | Delete
if ( $update ) {
[1860] Fix | Delete
wp_send_json_success( array(
[1861] Fix | Delete
'save_verification' => true,
[1862] Fix | Delete
) );
[1863] Fix | Delete
} else {
[1864] Fix | Delete
wp_send_json_error();
[1865] Fix | Delete
}
[1866] Fix | Delete
[1867] Fix | Delete
wp_die();
[1868] Fix | Delete
}
[1869] Fix | Delete
[1870] Fix | Delete
$update = wp_update_post( array(
[1871] Fix | Delete
'ID' => $post_id,
[1872] Fix | Delete
'post_content' => $post_content,
[1873] Fix | Delete
'post_status' => sanitize_text_field( $_POST['options']['status'] ),
[1874] Fix | Delete
) );
[1875] Fix | Delete
}
[1876] Fix | Delete
[1877] Fix | Delete
// update Global modules with selective sync
[1878] Fix | Delete
if ( 'module' === $layout_type && isset( $_POST['unsyncedGlobalSettings'] ) && 'none' !== $_POST['unsyncedGlobalSettings'] ) {
[1879] Fix | Delete
$unsynced_options = stripslashes( $_POST['unsyncedGlobalSettings'] );
[1880] Fix | Delete
update_post_meta( $post_id, '_et_pb_excluded_global_options', sanitize_text_field( $unsynced_options ) );
[1881] Fix | Delete
}
[1882] Fix | Delete
[1883] Fix | Delete
// check if there is an autosave that is newer
[1884] Fix | Delete
$post_author = get_current_user_id();
[1885] Fix | Delete
// Store one autosave per author. If there is already an autosave, overwrite it.
[1886] Fix | Delete
$autosave = wp_get_post_autosave( $post_id, $post_author );
[1887] Fix | Delete
[1888] Fix | Delete
if ( !empty( $autosave ) ) {
[1889] Fix | Delete
wp_delete_post_revision( $autosave->ID );
[1890] Fix | Delete
}
[1891] Fix | Delete
[1892] Fix | Delete
if ( isset($_POST['settings'] ) && is_array( $_POST['settings'] ) ) {
[1893] Fix | Delete
et_builder_update_settings( $_POST['settings'], $post_id );
[1894] Fix | Delete
}
[1895] Fix | Delete
[1896] Fix | Delete
if ( isset($_POST['preferences'] ) && is_array( $_POST['preferences'] ) ) {
[1897] Fix | Delete
$app_preferences = et_fb_app_preferences_settings();
[1898] Fix | Delete
$limited_prefix = ! empty( $_POST['et_builder_mode'] ) && 'limited' === $_POST['et_builder_mode'] ? 'limited_' : '';
[1899] Fix | Delete
[1900] Fix | Delete
foreach( $app_preferences as $preference_key => $preference_data ) {
[1901] Fix | Delete
[1902] Fix | Delete
$preference_value = isset( $_POST['preferences'][ $preference_key ] ) && isset( $_POST['preferences'][ $preference_key ]['value'] ) ? $_POST['preferences'][ $preference_key ]['value'] : $preference_data['default'];
[1903] Fix | Delete
[1904] Fix | Delete
// sanitize based on type
[1905] Fix | Delete
switch ( $preference_data['type'] ) {
[1906] Fix | Delete
case 'int':
[1907] Fix | Delete
$preference_value = absint( $preference_value );
[1908] Fix | Delete
break;
[1909] Fix | Delete
case 'bool':
[1910] Fix | Delete
$preference_value = $preference_value === 'true' ? 'true' : 'false';
[1911] Fix | Delete
break;
[1912] Fix | Delete
default:
[1913] Fix | Delete
$preference_value = sanitize_text_field( $preference_value );
[1914] Fix | Delete
break;
[1915] Fix | Delete
}
[1916] Fix | Delete
[1917] Fix | Delete
$preference_value_max_length = et_()->array_get( $preference_data, 'max_length', 0 );
[1918] Fix | Delete
[1919] Fix | Delete
if ( $preference_value && is_numeric( $preference_value_max_length ) && $preference_value_max_length > 0 ) {
[1920] Fix | Delete
$preference_value = substr( $preference_value, 0, $preference_value_max_length );
[1921] Fix | Delete
}
[1922] Fix | Delete
[1923] Fix | Delete
$option_name = 'et_fb_pref_' . $preference_key;
[1924] Fix | Delete
[1925] Fix | Delete
if ( in_array( $preference_key, et_fb_unsynced_preferences() ) ) {
[1926] Fix | Delete
$option_name = 'et_fb_pref_' . $limited_prefix . $preference_key;
[1927] Fix | Delete
}
[1928] Fix | Delete
[1929] Fix | Delete
et_update_option( $option_name, $preference_value );
[1930] Fix | Delete
}
[1931] Fix | Delete
}
[1932] Fix | Delete
[1933] Fix | Delete
// Clear AB Testing stats & transient data
[1934] Fix | Delete
if ( isset( $_POST['ab_testing'] ) && isset( $_POST['ab_testing']['is_clear_stats'] ) && 'true' === $_POST['ab_testing']['is_clear_stats'] && et_pb_is_allowed( 'ab_testing' ) ) {
[1935] Fix | Delete
et_pb_ab_remove_stats( $post_id );
[1936] Fix | Delete
et_pb_ab_clear_cache_handler( $post_id );
[1937] Fix | Delete
}
[1938] Fix | Delete
[1939] Fix | Delete
do_action( 'et_save_post', $post_id );
[1940] Fix | Delete
[1941] Fix | Delete
if ( $update ) {
[1942] Fix | Delete
if ( ! empty( $_POST['et_builder_version'] ) ) {
[1943] Fix | Delete
update_post_meta( $post_id, '_et_builder_version', sanitize_text_field( $_POST['et_builder_version'] ) );
[1944] Fix | Delete
}
[1945] Fix | Delete
[1946] Fix | Delete
// Get saved post, verify its content against the one that is being sent
[1947] Fix | Delete
$saved_post = get_post( $update );
[1948] Fix | Delete
$saved_post_content = $saved_post->post_content;
[1949] Fix | Delete
$builder_post_content = stripslashes( $sanitized_content );
[1950] Fix | Delete
[1951] Fix | Delete
// Get rendered post content only if it's needed.
[1952] Fix | Delete
$return_rendered_content = sanitize_text_field( $utils->array_get( $_POST, 'options.return_rendered_content', 'false' ) );
[1953] Fix | Delete
$rendered_post_content = 'true' === $return_rendered_content ? do_shortcode( $saved_post_content ) : '';
[1954] Fix | Delete
[1955] Fix | Delete
// If `post_content` column on wp_posts table doesn't use `utf8mb4` charset, the saved post
[1956] Fix | Delete
// content's emoji will be encoded which means the check of saved post_content vs
[1957] Fix | Delete
// builder's post_content will be false; Thus check the charset of `post_content` column
[1958] Fix | Delete
// first then encode the builder's post_content if needed
[1959] Fix | Delete
// @see https://make.wordpress.org/core/2015/04/02/omg-emoji-%f0%9f%98%8e/
[1960] Fix | Delete
// @see https://make.wordpress.org/core/2015/04/02/the-utf8mb4-upgrade/
[1961] Fix | Delete
global $wpdb;
[1962] Fix | Delete
[1963] Fix | Delete
if ( 'utf8' === $wpdb->get_col_charset( $wpdb->posts, 'post_content' ) ) {
[1964] Fix | Delete
$builder_post_content = wp_encode_emoji( $builder_post_content );
[1965] Fix | Delete
}
[1966] Fix | Delete
[1967] Fix | Delete
$saved_verification = $saved_post_content === $builder_post_content;
[1968] Fix | Delete
[1969] Fix | Delete
if ( $saved_verification ) {
[1970] Fix | Delete
// Strip non-printable characters to ensure preg_match_all operation work properly.
[1971] Fix | Delete
$post_content_cleaned = preg_replace('/[\x00-\x1F\x7F]/u', '', $saved_post->post_content);
[1972] Fix | Delete
[1973] Fix | Delete
preg_match_all( '/\[et_pb_section(.*?)?\]\[et_pb_row(.*?)?\]\[et_pb_column(.*?)?\](.+?)\[\/et_pb_column\]\[\/et_pb_row\]\[\/et_pb_section\]/m', $post_content_cleaned, $matches );
[1974] Fix | Delete
if ( isset( $matches[4] ) && ! empty( $matches[4] ) ) {
[1975] Fix | Delete
// Set page creation flow to off.
[1976] Fix | Delete
update_post_meta( $post_id, '_et_pb_show_page_creation', 'off' );
[1977] Fix | Delete
} else {
[1978] Fix | Delete
delete_post_meta( $post_id, '_et_pb_show_page_creation' );
[1979] Fix | Delete
}
[1980] Fix | Delete
}
[1981] Fix | Delete
[1982] Fix | Delete
/**
[1983] Fix | Delete
* Hook triggered when the Post is updated.
[1984] Fix | Delete
*
[1985] Fix | Delete
* @param int $post_id Post ID.
[1986] Fix | Delete
*
[1987] Fix | Delete
* @since 3.29
[1988] Fix | Delete
*/
[1989] Fix | Delete
do_action( 'et_update_post', $post_id );
[1990] Fix | Delete
[1991] Fix | Delete
wp_send_json_success( array(
[1992] Fix | Delete
'status' => get_post_status( $update ),
[1993] Fix | Delete
'save_verification' => apply_filters( 'et_fb_ajax_save_verification_result', $saved_verification ),
[1994] Fix | Delete
'rendered_content' => $rendered_post_content,
[1995] Fix | Delete
) );
[1996] Fix | Delete
} else if( isset( $_POST['skip_post_update'] ) ) {
[1997] Fix | Delete
wp_send_json_success();
[1998] Fix | Delete
} else {
[1999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function