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/feature
File: BlockEditorIntegration.php
$ids = preg_match_all( '/data-id="(\d+)"/i', $gallery, $matches ) ? $matches[1] : array();
[500] Fix | Delete
$columns = preg_match( '/<ul class="wp-block-gallery columns-(\d)[^"]*?">/i', $gallery, $matches ) ? $matches[1] : 3;
[501] Fix | Delete
$shortcode = sprintf(
[502] Fix | Delete
'[gallery columns="%s" ids="%s"]',
[503] Fix | Delete
intval( $columns ),
[504] Fix | Delete
implode( ',', array_map( 'intval', $ids ) )
[505] Fix | Delete
);
[506] Fix | Delete
[507] Fix | Delete
return $shortcode;
[508] Fix | Delete
}
[509] Fix | Delete
[510] Fix | Delete
/**
[511] Fix | Delete
* Convert all GB galleries to shortcodes.
[512] Fix | Delete
*
[513] Fix | Delete
* @param string $content Post content
[514] Fix | Delete
*
[515] Fix | Delete
* @return string
[516] Fix | Delete
*/
[517] Fix | Delete
public function gb_galleries_to_shortcodes( $content ) {
[518] Fix | Delete
return preg_replace_callback(
[519] Fix | Delete
$this->gb_gallery_regexp,
[520] Fix | Delete
array( $this, 'gb_gallery_to_shortcode' ),
[521] Fix | Delete
$content
[522] Fix | Delete
);
[523] Fix | Delete
}
[524] Fix | Delete
[525] Fix | Delete
/**
[526] Fix | Delete
* Check a specified post's content for GB gallery and, if present, return the first
[527] Fix | Delete
*
[528] Fix | Delete
* @param string $gallery Gallery data and srcs parsed from the expanded shortcode.
[529] Fix | Delete
* @param int|WP_Post $post Post ID or object.
[530] Fix | Delete
*
[531] Fix | Delete
* @return string|array Gallery data and srcs parsed from the expanded shortcode.
[532] Fix | Delete
*/
[533] Fix | Delete
public function get_post_gallery( $gallery, $post ) {
[534] Fix | Delete
if ( $gallery ) {
[535] Fix | Delete
return $gallery;
[536] Fix | Delete
}
[537] Fix | Delete
[538] Fix | Delete
$content = get_post_field( 'post_content', $post );
[539] Fix | Delete
if ( empty( $content ) ) {
[540] Fix | Delete
return $gallery;
[541] Fix | Delete
}
[542] Fix | Delete
[543] Fix | Delete
if ( preg_match( $this->gb_gallery_regexp, $content, $matches ) ) {
[544] Fix | Delete
// Found a GB gallery
[545] Fix | Delete
if ( apply_filters( 'et_gb_gallery_to_shortcode', true ) ) {
[546] Fix | Delete
// Return as shortcode
[547] Fix | Delete
return do_shortcode( $this->gb_gallery_to_shortcode( $matches[0] ) );
[548] Fix | Delete
}
[549] Fix | Delete
// Return it as is
[550] Fix | Delete
return $matches[0];
[551] Fix | Delete
}
[552] Fix | Delete
[553] Fix | Delete
return $gallery;
[554] Fix | Delete
}
[555] Fix | Delete
[556] Fix | Delete
/**
[557] Fix | Delete
* Delete first GB gallery in content
[558] Fix | Delete
*
[559] Fix | Delete
* @param string $content Content.
[560] Fix | Delete
* @param bool $deleted Whether a gallery has been already deleted or not.;
[561] Fix | Delete
* @return string
[562] Fix | Delete
*/
[563] Fix | Delete
public function et_delete_post_gallery( $content, $deleted ) {
[564] Fix | Delete
if ( $deleted ) {
[565] Fix | Delete
// If a gallery was already removed, do nothing
[566] Fix | Delete
return $content;
[567] Fix | Delete
}
[568] Fix | Delete
return preg_replace( $this->gb_gallery_regexp, '', $content, 1 );
[569] Fix | Delete
}
[570] Fix | Delete
[571] Fix | Delete
/**
[572] Fix | Delete
* Remove custom style from our metabox when GB is showing it.
[573] Fix | Delete
*
[574] Fix | Delete
* @param string $post_type Post type.
[575] Fix | Delete
*
[576] Fix | Delete
* @return void
[577] Fix | Delete
*/
[578] Fix | Delete
public function add_meta_boxes( $post_type ) {
[579] Fix | Delete
$is_block_editor_page = $this->_is_block_editor_page();
[580] Fix | Delete
$is_metabox_exist = function_exists( 'et_single_settings_meta_box' );
[581] Fix | Delete
$is_builder_enabled = et_builder_enabled_for_post_type( $post_type );
[582] Fix | Delete
$is_metabox_allowed = et_pb_is_allowed( 'page_options' );
[583] Fix | Delete
[584] Fix | Delete
if ( $is_block_editor_page && $is_metabox_exist && $is_builder_enabled && $is_metabox_allowed ) {
[585] Fix | Delete
// Change our metabox id so that no custom style is applied.
[586] Fix | Delete
remove_meta_box( 'et_settings_meta_box', $post_type, 'side' );
[587] Fix | Delete
add_meta_box(
[588] Fix | Delete
'et_settings_meta_box_gutenberg',
[589] Fix | Delete
esc_html__( 'Divi Page Settings', 'Divi' ),
[590] Fix | Delete
'et_single_settings_meta_box',
[591] Fix | Delete
$post_type,
[592] Fix | Delete
'side',
[593] Fix | Delete
'high'
[594] Fix | Delete
);
[595] Fix | Delete
}
[596] Fix | Delete
}
[597] Fix | Delete
[598] Fix | Delete
/**
[599] Fix | Delete
* Hook into REST API page call.
[600] Fix | Delete
*
[601] Fix | Delete
* @return void
[602] Fix | Delete
*/
[603] Fix | Delete
public function rest_insert_page() {
[604] Fix | Delete
add_filter( 'update_post_metadata', array( $this, 'update_post_metadata' ), 10, 4 );
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
/**
[608] Fix | Delete
* Custom auth function for meta updates via REST API.
[609] Fix | Delete
*
[610] Fix | Delete
* @param boolean $allowed True if allowed to view the meta field by default, false if else.
[611] Fix | Delete
* @param string $meta_key The meta key.
[612] Fix | Delete
* @param int $id Post ID.
[613] Fix | Delete
*
[614] Fix | Delete
* @return bool
[615] Fix | Delete
*/
[616] Fix | Delete
public function meta_auth( $allowed, $meta_key, $id ) {
[617] Fix | Delete
return current_user_can( 'edit_post', $id );
[618] Fix | Delete
}
[619] Fix | Delete
[620] Fix | Delete
/**
[621] Fix | Delete
* Hook methods to WordPress
[622] Fix | Delete
* Latest plugin version: 1.5
[623] Fix | Delete
* @return void
[624] Fix | Delete
*/
[625] Fix | Delete
public function init_hooks() {
[626] Fix | Delete
if ( is_admin() ) {
[627] Fix | Delete
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ), 4 );
[628] Fix | Delete
add_action( 'admin_print_scripts-edit.php', array( $this, 'add_new_button' ), 10 );
[629] Fix | Delete
add_action( 'admin_init', array( $this, 'add_edit_link_filters' ) );
[630] Fix | Delete
[631] Fix | Delete
// Only need to add this filter is the nonce is present in the url request
[632] Fix | Delete
// nonce value will be checked in the filter itself.
[633] Fix | Delete
if ( isset( $_GET['et_fb_new_vb_nonce'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.NoNonceVerification
[634] Fix | Delete
add_action( 'new_to_auto-draft', array( $this, 'auto_draft' ), 1 );
[635] Fix | Delete
}
[636] Fix | Delete
add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 );
[637] Fix | Delete
} else {
[638] Fix | Delete
// If "Enable Divi Gallery" option is enabled
[639] Fix | Delete
if ( apply_filters( 'et_gb_gallery_to_shortcode', false ) === true ) {
[640] Fix | Delete
// Converts GB galleries to shortcodes
[641] Fix | Delete
add_filter( 'the_content', array( $this, 'gb_galleries_to_shortcodes' ), 1 );
[642] Fix | Delete
}
[643] Fix | Delete
if ( apply_filters( 'et_gb_gallery_include_in_get_post_gallery', false ) === true ) {
[644] Fix | Delete
// Makes sure `get_post_gallery` returns a GB gallery if no shortcode is found
[645] Fix | Delete
add_filter( 'get_post_gallery', array( $this, 'get_post_gallery' ), 10, 2 );
[646] Fix | Delete
}
[647] Fix | Delete
// This filter gets called when Divi removes first gallery shortcode from
[648] Fix | Delete
// a gallery post (as in post format). We hook into that to ensure that the first GB gallery
[649] Fix | Delete
// is deleted if nothing else was
[650] Fix | Delete
add_filter( 'et_delete_post_gallery', array( $this, 'et_delete_post_gallery' ), 10, 2 );
[651] Fix | Delete
// Provide other code a simple way to access the conversion function via this custom filter
[652] Fix | Delete
add_filter( 'et_gb_galleries_to_shortcodes', array( $this, 'gb_galleries_to_shortcodes' ) );
[653] Fix | Delete
}
[654] Fix | Delete
[655] Fix | Delete
add_filter( 'et_fb_load_raw_post_content', array( $this, 'et_fb_load_raw_post_content' ) );
[656] Fix | Delete
add_filter( 'init', array( $this, 'ensure_post_type_supports' ), 999999 );
[657] Fix | Delete
[658] Fix | Delete
// This is one of the most idiot things I had to do ever and its due to
[659] Fix | Delete
// a 10 month old-yet not fixed WP bug: https://core.trac.wordpress.org/ticket/42069
[660] Fix | Delete
// TLDR: when updating a post with meta via WP REST API, `update_metadata` should only
[661] Fix | Delete
// be called for metas whose value changed.
[662] Fix | Delete
// However, the equality check is fooled by values including characters that are
[663] Fix | Delete
// slashed or converted to entities, like " or <.
[664] Fix | Delete
// `update_metadata` is then called and returns `false` (because value didn't change) which results
[665] Fix | Delete
// in REST API page update to abort with a 500 error code....
[666] Fix | Delete
// To fix the issue, we hook into REST API page update and force `update_metadata` to return `true`
[667] Fix | Delete
// when value didn't change (only applied to our own meta keys)
[668] Fix | Delete
add_action( 'rest_insert_page', array( $this, 'rest_insert_page' ) );
[669] Fix | Delete
[670] Fix | Delete
// Need to deal with our metabox styling when inside GB
[671] Fix | Delete
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 1 );
[672] Fix | Delete
[673] Fix | Delete
// To register the post metas is needed because we want to change their value within our custom GB blocks
[674] Fix | Delete
// Editing a post meta via REST API is allowed by default unless its key is protected (starts with `_`)
[675] Fix | Delete
// which is the case here so we also need to create a custom auth function.
[676] Fix | Delete
$auth = array( $this, 'meta_auth' );
[677] Fix | Delete
register_meta( 'post', '_et_pb_use_builder', array(
[678] Fix | Delete
'auth_callback' => $auth,
[679] Fix | Delete
'show_in_rest' => true,
[680] Fix | Delete
'single' => true,
[681] Fix | Delete
'type' => 'string',
[682] Fix | Delete
) );
[683] Fix | Delete
register_meta( 'post', '_et_pb_old_content', array(
[684] Fix | Delete
'auth_callback' => $auth,
[685] Fix | Delete
'show_in_rest' => true,
[686] Fix | Delete
'single' => true,
[687] Fix | Delete
'type' => 'string',
[688] Fix | Delete
) );
[689] Fix | Delete
register_meta( 'post', '_et_gb_content_width', array(
[690] Fix | Delete
'auth_callback' => $auth,
[691] Fix | Delete
'show_in_rest' => true,
[692] Fix | Delete
'single' => true,
[693] Fix | Delete
'type' => 'string',
[694] Fix | Delete
) );
[695] Fix | Delete
}
[696] Fix | Delete
}
[697] Fix | Delete
[698] Fix | Delete
[699] Fix | Delete
if ( et_core_is_gutenberg_active() ) {
[700] Fix | Delete
new ET_Builder_Block_Editor_Integration;
[701] Fix | Delete
}
[702] Fix | Delete
[703] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function