Blog

Code Snippet: Oxygen Editor Hint

Version: 1.1.0 (Apr 17, 2023)

Introduction

Oxygen is a powerful plugin for WordPress that deactivates the WordPress theme, supports the creation of own templates with a visual builder and thus enables a fully individual design for your website.

Also page and posts can be designed with Oxygen Builder instead of Gutenberg editor.

Unfortunately, in the administration overview of pages and posts it is not immediately recognizable whether a page or post was created with Gutenberg or with Oxygen.

Solution

I developed a code snippet that shows a hint in the administration lists for pages and posts if Oxygen was used for design.

Download

The code snippet is available for download here:

ma-oxygen-editor-hint.code-snippets.json
Version 1.1.0, 2023-04-17

For installation and use of the downloaded JSON file you will need the plugin Code Snippets or Advanced Scripts.
You can install the JSON file using the "Import" function of the plugin. 
Don't forget to activate the snippet after import.

Alternative: At the end of this page you can view and copy the complete source code of the snippet.

New functionalities and bug fixes are documented in the change log.

Donation

I enjoy developing code snippets and solving requirements with them. I provide the snippets free of charge.

If you like, you can honor my many hours of work with a small coffee donation via PayPal.

  When clicking the button, a connection to PayPal is established.

Your donation will of course be taxed properly by me.

Disclaimer

I have developed and tested the code snippet to the best of my knowledge under

- WordPress 6.2
- Oxygen 4.5
- PHP 8.1

I provide the code snippet for free use.
I cannot give any guarantee for the functionality because of the countless possible variations in WordPress environments.
Download and use of this code snippet is at your own risk and responsibility.

Change Log

See "Version History" in Source Code

Source Code

<?php
/*
Plugin Name:	MA Oxygen Editor Hint
Description:	Show hint "Oxygen" as editor in posts/pages list
Author:			<a href="https://www.altmann.de/">Matthias Altmann</a>
Project:		Code Snippet: Oxygen Editor Hint
Version:		1.1.0
Plugin URI:		https://www.altmann.de/en/blog-en/
Description:	en: https://www.altmann.de/en/blog-en/code-snippet-oxygen-editor-hint/
				de: https://www.altmann.de/blog/code-snippet-oxygen-editor-hinweis/
Copyright:		© 2021-2023, Matthias Altmann

Version History:
Date		Version		Description
--------------------------------------------------------------------------------------------------------------
2023-04-17	1.1.0		Moved call to init after the class definition for compatibility with WPCodeBox 2
						Tested with PHP 8.1, WordPress 6.2, Oxygen 4.5, Code Snippets 3.3.0, WPCodeBox 2.0.0b3.0
2022-02-11				Tested with PHP 8.0, WordPress 5.9, Oxygen 4.0 beta 1
2021-05-16	1.0.0		Initial release as Code Snippet
						Tested with PHP 7.4, WordPress 5.7.2, Oxygen 3.7.1
--------------------------------------------------------------------------------------------------------------
*/


class MA_OxygenPostState {
	// ===== CONFIGURATION =====
	private static $post_types 		= ['post','page']; 	// post types to show new column "Editor" in posts list


	//-------------------------------------------------------------------------------------------------------------------
	public static function init() {
		foreach (self::$post_types as $post_type) {
			add_filter( 'display_post_states', array( __CLASS__, 'ma_editorcolumn_add_post_state' ), 1000, 2 );
		}
	}
	//-------------------------------------------------------------------------------------------------------------------
	public static function ma_editorcolumn_add_post_state($post_states, $post) {
		// Fix PHP 7+ warnings if another plugin returns unexpected type.
		$post_states = (array) $post_states;
		$post_meta = get_post_meta($post->ID,'',true);
		if (isset($post_meta['ct_builder_shortcodes']) && (trim(@$post_meta['ct_builder_shortcodes'][0]) != ''))  {
			// remove mis-leading editor hints from plugin "Classic Editor"
			unset($post_states['classic-editor-plugin']);
			// add "Oxygen" as editor hint
			$post_states['ma_editorcolumn'] = 'Oxygen';
		}
		return $post_states;
	}
}
if (is_admin() && !wp_doing_ajax() && !wp_doing_cron() ) {
	MA_OxygenPostState::init();
}
First published: May 16, 2021 on Code Snippet: Oxygen Editor Hint
magnifier