'WPBakery', 'et_pb_' => 'Divi', 'fusion_' => 'Avada', 'cs_section' => 'Cornerstone', 'themify_' => 'Themify', ); public function id() { return 'classic'; } public function name() { return 'Classic editor'; } public function available() { return true; } public function detect( \WP_Post $post ) { if ( ! post_type_supports( $post->post_type, 'editor' ) ) { return false; } if ( function_exists( 'has_blocks' ) && has_blocks( $post->post_content ) ) { return false; } return 'builder' !== get_post_meta( $post->ID, '_elementor_edit_mode', true ); } public function list_fields( \WP_Post $post ) { $note = 'The page body as HTML. Change only the part you mean to; keep everything else exactly as it is.'; $builder = self::shortcode_builder( $post->post_content ); if ( $builder ) { $note = "Built with $builder: the layout is made of [shortcodes]. Change only the text between them and keep every [shortcode] and its attributes exactly as they are."; } return array( array( 'locator' => 'html', 'label' => 'Body', 'type' => 'html', 'value' => $post->post_content, 'writable' => true, 'whole_column' => true, 'note' => $note, ), ); } public static function shortcode_builder( $content ) { foreach ( self::SHORTCODE_BUILDERS as $needle => $name ) { if ( false !== strpos( $content, '[' . $needle ) ) { return $name; } } return ''; } public function post_column( $locator ) { return 'post_content'; } public function read( \WP_Post $post, $locator ) { return 'html' === $locator ? $this->list_fields( $post )[0] : null; } public function write( \WP_Post $post, $locator, $value ) { if ( 'html' !== $locator ) { throw new Tool_Error( esc_html( "classic:$locator doesn't exist." ) ); } $result = wp_update_post( wp_slash( array( 'ID' => $post->ID, 'post_content' => $value, ) ), true ); if ( is_wp_error( $result ) ) { throw new Tool_Error( esc_html( 'WordPress refused the change: ' . $result->get_error_message() ) ); } } }