Support » Plugins » Using TinyMCE in plugin causes edit page problem

  • Alright here’s the deal. I am using the visual editor with one of my themes. The theme creates menus and sub menus as well as a dashboard widget to make editing parts of the theme simple and to the point. the theme has a testimonial section and for this, i am using the visual editor. however, i just want to add a new page and no matter what i put in for content, it isn’t there.

    if i disable the tinymce editor in my theme options, it works great and i can update the page content as i please. but with it enabled, it does not update the page content at all.

    screenshot of admin area:

    function calling wp_tiny_mce:

    function add_tinymce() {
        if (function_exists('wp_tiny_mce')) wp_tiny_mce();

    and using the editor. the is a pretty big function so i tried to document it some to help you better understand it. it works great but like i said, the editing a page is messed up.

    function best_care_random_tips()
        // check for form submission
        if ($_POST['best_care_action'] == 'save')
            if( isset( $_POST['bc_edit_tips'] ) ) // if editing a tip, overwrite instead of creating new.
                $this->options['tips'][ $_POST['bc_edit_tips'] ] = $_POST['content'];
            else // add new tip
                $this->options["tips"][] = $_POST['content'];
            update_option('best_care', $this->options); // make changes to wp_options.
            echo '<div class="updated fade" id="message" style="background-color: rgb(255, 251, 204);"><p>Settings <strong>saved</strong>.</p></div>';
        if( $_GET['action'] == 'delete' && isset( $_GET['tid'] ) ) // delete tip
            unset( $this->options['tips'][ $_GET['tid'] ] );
            update_option('best_care', $this->options);
            echo '<div class="updated fade" id="message" style="background-color: rgb(255, 251, 204);"><p>tips <strong>Deleted</strong>.</p></div>';
        <div class="wrap">
            <form action="admin.php?page=random_tips" method="post">
                <input type="hidden" id="best_care_action" name="best_care_action" value="save" />
                    if( $_GET['action'] == 'edit' && isset( $_GET['id'] ) ) // if editing, include hidden field with id.
                        echo '<input type="hidden" name="bc_edit_tips" value="'.$_GET['id'].'" />';
                <h2>Best Care Theme Control Panel</h2>
                <h3>Tips &amp; Tricks</h3>
                <p>You can add, delete, and modify your tips &amp; tricks here. A random tip will appear on the front page of your website.</p>
                    if( sizeof( $this->options['tips'] ) > 0 ) // show current tips and tricks if any exist.
                        echo '<h2>Current Tips &amp; Tricks</h2>';
                        $x = 0;
                        foreach( $this->options['tips'] as $k => $tips )
                            echo '<h3>tip #' . ( ++$x ) . ' <a href="'.$_SERVER['PHP_SELF'].'?page=random_tips&action=edit&id='.$k.'">edit</a> <a href="'.$_SERVER['PHP_SELF'].'?page=random_tips&action=delete&tid='.$k.'">delete</a>';
                            echo '</h3>';
                            echo '<p>' . apply_filters('the_content', stripslashes( $tips ) ) . '</p>';
                            echo '<div style="clear:both;"></div>';
                <h2><?php echo ( $_GET['action'] == 'edit' && isset( $_GET['id'] ) ) ? 'Tips Editor' : 'Add a Tip'; ?></h2>
                <table class="form-table">
                        <td colspan="2">
                            <div id="poststuff">
                                    if( $_GET['action'] == 'edit' && isset( $_GET['id'] ) ) // if editing, load content into editor with filters and formatting applied.
                                        the_editor( apply_filters( 'the_content', stripslashes( $this->options['tips'][ $_GET['id'] ] ) ) );
                                    else // load new editor.
                <p class="submit">
                    <input type="submit" class="button-primary" name="wbe_config_submit" value="<?php echo ( $_GET['action'] == 'edit' && isset( $_GET['id'] ) ) ? 'Submit Changes' : 'Add Tip/Trick'; ?>" /><?php if( $_GET['action'] == 'edit' && isset( $_GET['id'] ) ) : ?> <input type="button" value="Cancel" onclick="javascript:location.href = '<?php bloginfo('url'); ?>/wp-admin/admin.php?page=tipss';" /> <?php endif; ?>

    any ideas why using the visual editor in my theme options might make editing pages not work?

    also, another thing i am looking to do is simply remove dashboard widgets without using the screen options. i would like to have my theme automatically remove them temporarily while it is active. less is better as my client is not very good with computers and i dont want anything confusing for him. i will be hiding the screen options so removing them through there is not an option.

    hopefully someone will have some input on this. this may belong in the advanced section but you cant post there 🙂

Viewing 1 replies (of 1 total)
  • alright well i think i solved that issue by only having my theme load the visual editor on the pages that i wanted it on. i think because it tried to load the visual editor on all the pages it was causing the errors. so i only load it on the pages i want now.

    if( isset( $_GET['page'] ) && $_GET['page'] == 'testimonials' || $_GET['page'] == 'random_tips' )
            add_filter('admin_head', array( &$this, 'add_tinymce' ) );

    still lost on the removing widgets though. any ideas?

Viewing 1 replies (of 1 total)
  • The topic ‘Using TinyMCE in plugin causes edit page problem’ is closed to new replies.