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
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/Divi/includes/builder/plugin-c...
File: the-events-calendar.php
<?php
[0] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[1] Fix | Delete
// Exit if accessed directly.
[2] Fix | Delete
exit;
[3] Fix | Delete
}
[4] Fix | Delete
[5] Fix | Delete
/**
[6] Fix | Delete
* Compatibility for The Events Calendar plugin.
[7] Fix | Delete
*
[8] Fix | Delete
* @since 3.10
[9] Fix | Delete
*
[10] Fix | Delete
* @link https://wordpress.org/plugins/the-events-calendar/
[11] Fix | Delete
*/
[12] Fix | Delete
class ET_Builder_Plugin_Compat_The_Events_Calendar extends ET_Builder_Plugin_Compat_Base {
[13] Fix | Delete
public $actual_post_query;
[14] Fix | Delete
public $spoofed_post_query;
[15] Fix | Delete
[16] Fix | Delete
/**
[17] Fix | Delete
* Constructor.
[18] Fix | Delete
*
[19] Fix | Delete
* @since 3.10
[20] Fix | Delete
*/
[21] Fix | Delete
public function __construct() {
[22] Fix | Delete
$this->plugin_id = 'the-events-calendar/the-events-calendar.php';
[23] Fix | Delete
$this->init_hooks();
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Hook methods to WordPress.
[28] Fix | Delete
* Latest plugin version: 4.6.19
[29] Fix | Delete
*
[30] Fix | Delete
* @todo once this issue is fixed in future version, run version_compare() to limit the scope of the hooked fix
[31] Fix | Delete
*
[32] Fix | Delete
* @since 3.10
[33] Fix | Delete
* @since 4.4.6 Bump loop_start hook priority to cover post hijacking issue.
[34] Fix | Delete
*
[35] Fix | Delete
* @return void
[36] Fix | Delete
*/
[37] Fix | Delete
public function init_hooks() {
[38] Fix | Delete
// Bail if there's no version found.
[39] Fix | Delete
if ( ! $this->get_plugin_version() ) {
[40] Fix | Delete
return;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
add_action( 'wp', array( $this, 'register_spoofed_post_fix' ) );
[44] Fix | Delete
add_action( 'loop_start', array( $this, 'maybe_disable_post_spoofing' ), 1001 );
[45] Fix | Delete
add_filter( 'wp_insert_post_empty_content', array( $this, 'maybe_allow_save_empty_content' ), 10, 2 );
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* The Events Calendar register Tribe__Events__Templates::maybeSpoofQuery() on wp_head (100) hook
[50] Fix | Delete
* which modifies global $posts. This modified post object breaks anything that came after wp_head
[51] Fix | Delete
* until the spoofed post is fixed. Anything that relies on $post global value on body_class is affected
[52] Fix | Delete
* (ie Divi's hide nav until scroll because it adds classname to <body> to work)
[53] Fix | Delete
*
[54] Fix | Delete
* @since 3.10
[55] Fix | Delete
*
[56] Fix | Delete
* @return void
[57] Fix | Delete
*/
[58] Fix | Delete
function register_spoofed_post_fix() {
[59] Fix | Delete
// Bail if global $post doesn't exist for some reason. Just to be safe.
[60] Fix | Delete
if ( ! isset( $GLOBALS['post'] ) ) {
[61] Fix | Delete
return;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
// Only apply spoofed post fix if builder is used in custom post type page
[65] Fix | Delete
if ( ! et_builder_post_is_of_custom_post_type( get_the_ID() ) || ! et_pb_is_pagebuilder_used( get_the_ID() ) ) {
[66] Fix | Delete
return;
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
// Get actual $post query before Tribe__Events__Templates::maybeSpoofQuery() modifies it
[70] Fix | Delete
$this->actual_post_query = $GLOBALS['post'];
[71] Fix | Delete
[72] Fix | Delete
// Return spoofed $post into its actual post then re-return it into spoofed post object
[73] Fix | Delete
add_action( 'et_layout_body_class_before', array( $this, 'fix_post_query' ) );
[74] Fix | Delete
add_action( 'et_layout_body_class_after', array( $this, 'respoofed_post_query' ) );
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
/**
[78] Fix | Delete
* Return spoofed $post into its actual post so anything that relies to $post object works as expected
[79] Fix | Delete
*
[80] Fix | Delete
* @since 3.10
[81] Fix | Delete
*
[82] Fix | Delete
* @return void
[83] Fix | Delete
*/
[84] Fix | Delete
function fix_post_query() {
[85] Fix | Delete
// Bail if global $post doesn't exist for some reason. Just to be safe.
[86] Fix | Delete
if ( ! isset( $GLOBALS['post'] ) ) {
[87] Fix | Delete
return;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
$this->spoofed_post_query = $GLOBALS['post'];
[91] Fix | Delete
[92] Fix | Delete
$GLOBALS['post'] = $this->actual_post_query; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
/**
[96] Fix | Delete
* Re-return actual $post object into spoofed post so The Event Calendar works as expected
[97] Fix | Delete
*
[98] Fix | Delete
* @since 3.10
[99] Fix | Delete
*
[100] Fix | Delete
* @return void
[101] Fix | Delete
*/
[102] Fix | Delete
function respoofed_post_query() {
[103] Fix | Delete
$GLOBALS['post'] = $this->spoofed_post_query; // phpcs:ignore WordPress.Variables.GlobalVariables.OverrideProhibited
[104] Fix | Delete
}
[105] Fix | Delete
[106] Fix | Delete
/**
[107] Fix | Delete
* Maybe disable post spoofing when a TB body layout is used.
[108] Fix | Delete
*
[109] Fix | Delete
* @since 4.2.2
[110] Fix | Delete
* @since 4.4.6 Maybe disable post hijacking on Page Template v2.
[111] Fix | Delete
*/
[112] Fix | Delete
function maybe_disable_post_spoofing() {
[113] Fix | Delete
if ( et_theme_builder_overrides_layout( ET_THEME_BUILDER_BODY_LAYOUT_POST_TYPE ) ) {
[114] Fix | Delete
remove_action( 'the_post', array( 'Tribe__Events__Templates', 'spoof_the_post' ) );
[115] Fix | Delete
[116] Fix | Delete
// Ensure to check the class and tribe() method exists. Method tribe() is used
[117] Fix | Delete
// to return an instance of the class and resolve the object.
[118] Fix | Delete
if ( class_exists( '\Tribe\Events\Views\V2\Template\Page' ) && function_exists( 'tribe' ) ) {
[119] Fix | Delete
$page = tribe( \Tribe\Events\Views\V2\Template\Page::class );
[120] Fix | Delete
remove_action( 'the_post', array( $page, 'hijack_the_post' ), 25 );
[121] Fix | Delete
}
[122] Fix | Delete
}
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Allow event with empty title to update post and trigger save_post action when
[127] Fix | Delete
* activating BFB for the first time. So, event post meta can be saved as well.
[128] Fix | Delete
*
[129] Fix | Delete
* @since 4.4.4
[130] Fix | Delete
*
[131] Fix | Delete
* @param bool $maybe_empty Original status.
[132] Fix | Delete
* @param array $postarr Array of post data.
[133] Fix | Delete
*/
[134] Fix | Delete
public function maybe_allow_save_empty_content( $maybe_empty, $postarr ) {
[135] Fix | Delete
$post_action = et_()->array_get( $postarr, 'action' );
[136] Fix | Delete
$post_id = et_()->array_get( $postarr, 'post_ID', 0 );
[137] Fix | Delete
$post_status = et_()->array_get( $postarr, 'post_status' );
[138] Fix | Delete
$post_origin_status = et_()->array_get( $postarr, 'original_post_status' );
[139] Fix | Delete
$post_type = et_()->array_get( $postarr, 'post_type' );
[140] Fix | Delete
[141] Fix | Delete
// Ensure to override the status only on very first BFB activation and
[142] Fix | Delete
// limited for tribe_events post type only.
[143] Fix | Delete
$is_edit_action = 'editpost' === $post_action;
[144] Fix | Delete
$is_builder_used = et_pb_is_pagebuilder_used( $post_id );
[145] Fix | Delete
$is_post_draft = 'draft' === $post_status && 'auto-draft' === $post_origin_status;
[146] Fix | Delete
$is_post_event = 'tribe_events' === $post_type;
[147] Fix | Delete
if ( $is_edit_action && $is_builder_used && $is_post_draft && $is_post_event ) {
[148] Fix | Delete
return false;
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
return $maybe_empty;
[152] Fix | Delete
}
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
new ET_Builder_Plugin_Compat_The_Events_Calendar;
[156] Fix | Delete
[157] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function