Skip to content

Instantly share code, notes, and snippets.

@FrancoStino
Created November 7, 2024 16:26
Show Gist options
  • Save FrancoStino/1d0cb0d31463a164335825d741449c58 to your computer and use it in GitHub Desktop.
Save FrancoStino/1d0cb0d31463a164335825d741449c58 to your computer and use it in GitHub Desktop.
This code snippet adds an INCI meta box to a post. It retrieves the product and content, sets up settings for this document URL using Tinymce's editor class with specific parameters such as quicktags, textarea rows, media buttons, and wp_editor functions

Add InCI Meta Box to Post

Preview:
public function add_INCI_meta_box( $post )
    {
        $product  = wc_get_product( $post->ID );
        $content  = $product->get_meta( '_INCI_specs' );
        $settings = array(
            'tinymce'       => array(
                'setup' => 'function (ed) {
            tinymce.documentBaseURL = "' . get_admin_url() . '";
        }',
            ),
            'quicktags'     => TRUE,
            'editor_class'  => 'product_INCI_specs',
            'textarea_rows' => 10,
            'media_buttons' => TRUE,
        );

        wp_editor( $content, '_INCI_specs', $settings );
    }
Associated Context
Type Code Snippet ( .php )
Associated Tags add_INCI_meta_box wc_get_product get_meta tinymce setup quicktags editor_class textarea_rows media_buttons wp_editor
💡 Smart Description This code snippet adds an INCI meta box to a post. It retrieves the product and content, sets up settings for this document URL using Tinymce's editor class with specific parameters such as quicktags, textarea rows, media buttons, and wp_editor functions
🔎 Suggested Searches PHP function to add inCI meta box
How to get the content of an INCI_specs post using wp_editor and wp_editor
Code snippet for creating a document URL with Tinymce's setup method on Post ID
PHP code example for setting up tinymce editor class based on Content-Type field
How to use wp_editor as WPEditor object
Related Links https://www.tutorialrepublic.com/php-tutorial/php-sessions.php
https://www.php.net/manual/en/function.session-set-save-handler.php
https://www.tutorialrepublic.com/php-tutorial/php-mysql-insert-query.php
Related People Davide Ladisa
Sensitive Information No Sensitive Information Detected
Shareable Link No Shareable Link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment