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-conte.../themes/Divi/includes/builder/frontend.../theme-bu...
File: theme-builder.php
*/
[1500] Fix | Delete
function et_theme_builder_decorate_page_resource_slug( $post_id, $resource_slug ) {
[1501] Fix | Delete
if ( ! is_numeric( $post_id ) || ! is_singular() ) {
[1502] Fix | Delete
return $resource_slug;
[1503] Fix | Delete
}
[1504] Fix | Delete
[1505] Fix | Delete
$post_type = get_post_type( (int) $post_id );
[1506] Fix | Delete
[1507] Fix | Delete
if ( et_theme_builder_is_layout_post_type( $post_type ) ) {
[1508] Fix | Delete
$resource_slug .= '-tb-for-' . ET_Post_Stack::get_main_post_id();
[1509] Fix | Delete
} else {
[1510] Fix | Delete
$layout_types = et_theme_builder_get_layout_post_types();
[1511] Fix | Delete
$layouts = et_theme_builder_get_template_layouts();
[1512] Fix | Delete
[1513] Fix | Delete
foreach ( $layout_types as $type ) {
[1514] Fix | Delete
if ( ! isset( $layouts[ $type ] ) || ! $layouts[ $type ]['override'] ) {
[1515] Fix | Delete
continue;
[1516] Fix | Delete
}
[1517] Fix | Delete
[1518] Fix | Delete
$resource_slug .= '-tb-' . $layouts[ $type ]['id'];
[1519] Fix | Delete
}
[1520] Fix | Delete
}
[1521] Fix | Delete
[1522] Fix | Delete
return $resource_slug;
[1523] Fix | Delete
}
[1524] Fix | Delete
add_filter( 'et_builder_cache_post_type', 'et_theme_builder_cache_post_type' );
[1525] Fix | Delete
[1526] Fix | Delete
/**
[1527] Fix | Delete
* Clear cache of 3P caching plugins partially on the posts or all of them.
[1528] Fix | Delete
*
[1529] Fix | Delete
* @since 4.5.0
[1530] Fix | Delete
*
[1531] Fix | Delete
* @param string|array $post_ids 'all' or array of post IDs.
[1532] Fix | Delete
*
[1533] Fix | Delete
* @return void
[1534] Fix | Delete
*/
[1535] Fix | Delete
function et_theme_builder_clear_wp_cache( $post_ids = 'all' ) {
[1536] Fix | Delete
if ( ! et_pb_detect_cache_plugins() ) {
[1537] Fix | Delete
return;
[1538] Fix | Delete
}
[1539] Fix | Delete
[1540] Fix | Delete
if ( empty( $post_ids ) ) {
[1541] Fix | Delete
return;
[1542] Fix | Delete
}
[1543] Fix | Delete
[1544] Fix | Delete
if ( 'all' === $post_ids ) {
[1545] Fix | Delete
et_core_clear_wp_cache();
[1546] Fix | Delete
} else if ( is_array( $post_ids ) ) {
[1547] Fix | Delete
foreach( $post_ids as $post_id ) {
[1548] Fix | Delete
et_core_clear_wp_cache( $post_id );
[1549] Fix | Delete
}
[1550] Fix | Delete
}
[1551] Fix | Delete
}
[1552] Fix | Delete
[1553] Fix | Delete
/**
[1554] Fix | Delete
* Clear cache of 3P caching plugins fully or partially after TB layouts saved.
[1555] Fix | Delete
*
[1556] Fix | Delete
* Clear all the cache when the template updated is:
[1557] Fix | Delete
* - Default template
[1558] Fix | Delete
* - Used on archive, 404, or all posts
[1559] Fix | Delete
* - Non static homepage
[1560] Fix | Delete
*
[1561] Fix | Delete
* @since 4.5.0
[1562] Fix | Delete
*
[1563] Fix | Delete
* @param int $layout_id
[1564] Fix | Delete
*
[1565] Fix | Delete
* @return void
[1566] Fix | Delete
*/
[1567] Fix | Delete
function et_theme_builder_clear_wp_post_cache( $layout_id = '' ) {
[1568] Fix | Delete
$layout_type = get_post_type( $layout_id );
[1569] Fix | Delete
[1570] Fix | Delete
if ( ! et_theme_builder_is_layout_post_type( $layout_type ) ) {
[1571] Fix | Delete
return;
[1572] Fix | Delete
}
[1573] Fix | Delete
[1574] Fix | Delete
if ( ! et_pb_detect_cache_plugins() ) {
[1575] Fix | Delete
return;
[1576] Fix | Delete
}
[1577] Fix | Delete
[1578] Fix | Delete
// Get template of current TB layout.
[1579] Fix | Delete
$template = new WP_Query( array(
[1580] Fix | Delete
'post_type' => ET_THEME_BUILDER_TEMPLATE_POST_TYPE,
[1581] Fix | Delete
'post_status' => 'publish',
[1582] Fix | Delete
'posts_per_page' => 1,
[1583] Fix | Delete
'fields' => 'ids',
[1584] Fix | Delete
'no_found_rows' => true,
[1585] Fix | Delete
'update_post_meta_cache' => false,
[1586] Fix | Delete
'update_post_term_cache' => false,
[1587] Fix | Delete
'meta_query' => array(
[1588] Fix | Delete
'relation' => 'AND',
[1589] Fix | Delete
array(
[1590] Fix | Delete
'key' => "_et_enabled",
[1591] Fix | Delete
'value' => '1',
[1592] Fix | Delete
'compare' => '=',
[1593] Fix | Delete
),
[1594] Fix | Delete
array(
[1595] Fix | Delete
'key' => "_{$layout_type}_id",
[1596] Fix | Delete
'value' => $layout_id,
[1597] Fix | Delete
'compare' => '=',
[1598] Fix | Delete
),
[1599] Fix | Delete
array(
[1600] Fix | Delete
'key' => "_{$layout_type}_enabled",
[1601] Fix | Delete
'value' => '1',
[1602] Fix | Delete
'compare' => '=',
[1603] Fix | Delete
),
[1604] Fix | Delete
array(
[1605] Fix | Delete
'key' => '_et_theme_builder_marked_as_unused',
[1606] Fix | Delete
'compare' => 'NOT EXISTS',
[1607] Fix | Delete
),
[1608] Fix | Delete
)
[1609] Fix | Delete
) );
[1610] Fix | Delete
[1611] Fix | Delete
if ( ! $template->have_posts() ) {
[1612] Fix | Delete
return;
[1613] Fix | Delete
}
[1614] Fix | Delete
[1615] Fix | Delete
$_ = et_();
[1616] Fix | Delete
$template_id = $_->array_get( $template->posts, '0' );
[1617] Fix | Delete
$template_use_on = get_post_meta( $template_id, '_et_use_on', false );
[1618] Fix | Delete
$is_template_default = '1' === get_post_meta( $template_id, '_et_default', true );
[1619] Fix | Delete
[1620] Fix | Delete
// Unassigned Template - False or empty _et_use_on means it's unassigned.
[1621] Fix | Delete
if ( empty( $template_use_on ) ) {
[1622] Fix | Delete
// Clear All - If the template is 'default' because it's enabled globally.
[1623] Fix | Delete
if ( $is_template_default ) {
[1624] Fix | Delete
et_theme_builder_clear_wp_cache();
[1625] Fix | Delete
}
[1626] Fix | Delete
return;
[1627] Fix | Delete
}
[1628] Fix | Delete
[1629] Fix | Delete
$target_post_ids = array();
[1630] Fix | Delete
[1631] Fix | Delete
foreach( $template_use_on as $location ) {
[1632] Fix | Delete
$location_pieces = explode( ':', $location );
[1633] Fix | Delete
$location_first = $_->array_get( $location_pieces, '0' );
[1634] Fix | Delete
$location_last = end( $location_pieces );
[1635] Fix | Delete
[1636] Fix | Delete
if ( in_array( $location_first, array( 'archive', '404' ) ) || 'all' === $location_last ) {
[1637] Fix | Delete
// Path: archive:user:id:{user_id}, singular:post_type:{post_type_slug}:all,
[1638] Fix | Delete
// archive:taxonomy:{taxonomy_name}:all, etc.
[1639] Fix | Delete
// Clear All - If the template is being used on 'archive:' or ':all' posts.
[1640] Fix | Delete
$target_post_ids = 'all';
[1641] Fix | Delete
break;
[1642] Fix | Delete
} else if ( 'homepage' === $location_first ) {
[1643] Fix | Delete
// Path: homepage
[1644] Fix | Delete
$homepage_id = (int) get_option( 'page_on_front' );
[1645] Fix | Delete
$target_post_ids[] = $homepage_id;
[1646] Fix | Delete
if ( ! $homepage_id ) {
[1647] Fix | Delete
// Clear All - If the homepage is non static page.
[1648] Fix | Delete
$target_post_ids = 'all';
[1649] Fix | Delete
break;
[1650] Fix | Delete
}
[1651] Fix | Delete
} else if ( 'singular' === $location_first ) {
[1652] Fix | Delete
$singular_type = $_->array_get( $location_pieces, '3' );
[1653] Fix | Delete
[1654] Fix | Delete
if ( 'id' === $singular_type ) {
[1655] Fix | Delete
// Path: singular:post_type:{post_type_slug}:id:{post_id}
[1656] Fix | Delete
$target_post_ids[] = (int) $_->array_get( $location_pieces, '4' );
[1657] Fix | Delete
} else if ( 'children' === $singular_type ) {
[1658] Fix | Delete
// Path: singular:post_type:{post_type_slug}:children:id:{post_id}
[1659] Fix | Delete
$parent_id = (int) $_->array_get( $location_pieces, '5' );
[1660] Fix | Delete
$children_ids = get_children( array(
[1661] Fix | Delete
'posts_per_page' => -1,
[1662] Fix | Delete
'post_parent' => $parent_id,
[1663] Fix | Delete
'fields' => 'ids',
[1664] Fix | Delete
) );
[1665] Fix | Delete
$target_post_ids = array_merge( $target_post_ids, $children_ids );
[1666] Fix | Delete
} else if ( 'term' === $singular_type ) {
[1667] Fix | Delete
// Path: singular:taxonomy:{taxonomy_name}:term:id:{term_id}
[1668] Fix | Delete
$taxonomy = $_->array_get( $location_pieces, '2' );
[1669] Fix | Delete
$taxonomy_object = get_taxonomy( $taxonomy );
[1670] Fix | Delete
$taxonomy_type = ! empty( $taxonomy_object->object_type ) ? $_->array_get( $taxonomy_object->object_type, '0' ) : 'post';
[1671] Fix | Delete
$term_id = (int) $_->array_get( $location_pieces, '5' );
[1672] Fix | Delete
$posts_ids = get_posts( array(
[1673] Fix | Delete
'posts_per_page' => -1,
[1674] Fix | Delete
'fields' => 'ids',
[1675] Fix | Delete
'post_type' => $taxonomy_type,
[1676] Fix | Delete
'tax_query' => array(
[1677] Fix | Delete
array(
[1678] Fix | Delete
'taxonomy' => $taxonomy,
[1679] Fix | Delete
'field' => 'term_id',
[1680] Fix | Delete
'terms' => $term_id,
[1681] Fix | Delete
),
[1682] Fix | Delete
),
[1683] Fix | Delete
) );
[1684] Fix | Delete
$target_post_ids = array_merge( $target_post_ids, $posts_ids );
[1685] Fix | Delete
}
[1686] Fix | Delete
} else if ( 'woocommerce' === $location_first && et_is_woocommerce_plugin_active() && function_exists( 'wc_get_page_id' ) ) {
[1687] Fix | Delete
// Path: woocommerce:my_account, woocommerce:cart, etc.
[1688] Fix | Delete
$woocommerce_page = str_replace( '_', '', $_->array_get( $location_pieces, '1' ) );
[1689] Fix | Delete
$woocommerce_page_id = wc_get_page_id( $woocommerce_page );
[1690] Fix | Delete
if ( $woocommerce_page_id ) {
[1691] Fix | Delete
$target_post_ids[] = $woocommerce_page_id;
[1692] Fix | Delete
}
[1693] Fix | Delete
}
[1694] Fix | Delete
}
[1695] Fix | Delete
[1696] Fix | Delete
// Remove duplicate posts.
[1697] Fix | Delete
if ( is_array( $target_post_ids ) ) {
[1698] Fix | Delete
$target_post_ids = array_unique( $target_post_ids );
[1699] Fix | Delete
}
[1700] Fix | Delete
[1701] Fix | Delete
et_theme_builder_clear_wp_cache( $target_post_ids );
[1702] Fix | Delete
}
[1703] Fix | Delete
[1704] Fix | Delete
add_action( 'et_save_post', 'et_theme_builder_clear_wp_post_cache' );
[1705] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function