$args The post type args. * * @return array */ public function custom_post_type_args( $args ) { if ( $this->is_bricks_editor() ) { $args['publicly_queryable'] = true; } return $args; } /** * Disable asset caching for Bricks editor. * * @param mixed $value The default value. * @param string $key The option key. * * @return mixed */ public function disable_asset_caching( $value, $key ) { if ( $this->is_bricks_editor_canvas() && 'disable_asset_caching' === $key ) { return true; } return $value; } /** * Check if the current page is the Bricks editor canvas. * * @return bool */ public function is_bricks_editor_canvas() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return $this->is_bricks_editor() && isset( $_GET['brickspreview'] ); } /** * Check if the current page is the Bricks editor preview. * * @return bool */ public function is_bricks_editor_preview() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return isset( $_GET['bricks_preview'] ); } /** * Check if the current page is the Bricks editor. * * @return bool */ public function is_bricks_editor() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return isset( $_GET['bricks'] ) && 'run' === sanitize_key( wp_unslash( $_GET['bricks'] ) ); } /** * Custom template for the Bricks editor. * * @param string $template The template path. * * @return string */ public function custom_template( $template ) { if ( is_singular( 'popup' ) ) { // Define the path to your custom template file within your plugin $custom_template = Popup_Maker::$DIR . 'templates/single-popup.php'; if ( $this->is_bricks_editor() && ! $this->is_bricks_editor_canvas() ) { remove_action( 'wp_footer', [ 'PUM_Site_Popups', 'render_popups' ] ); } // Check if the file exists, then use it as the template if ( file_exists( $custom_template ) ) { return $custom_template; } } // If not singular 'popup', return the default template return $template; } /** * Modify the CSS selector for the Bricks editor. * * @param string $css_selector The CSS selector. * @param int $theme_id The theme ID. * @param string $element The element type. * * @return string */ public function custom_css_selector( $css_selector, $theme_id, $element ) { if ( $this->is_bricks_editor_canvas() ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $popup_id = isset( $_GET['p'] ) ? intval( $_GET['p'] ) : false; if ( ! $popup_id ) { return $css_selector; } $popup = pum_get_popup( $popup_id ); $popup_theme = $popup->get_theme_id(); if ( $popup_theme !== $theme_id ) { return $css_selector; } if ( 'overlay' === $element ) { $css_selector = ', #brx-body.postid-' . $popup_id; } elseif ( 'container' === $element ) { $css_selector = '#bricks-blank-canvas, #brx-content'; } } return $css_selector; } /** * Render custom editor scripts for the Bricks editor. * * @return void */ public function render_custom_editor_scripts() { if ( ! $this->is_bricks_editor_canvas() ) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended $popup_id = isset( $_GET['p'] ) ? intval( $_GET['p'] ) : false; if ( ! $popup_id ) { return; } ?>