Ask your WordPress questions! Pay money and get answers fast! (more info)

WYSIWYG Editor - 'HTML' is disabled/inactive?

  • SOLVED

Hi,

I am having an issue with the WYSIWYG editor for pages/posts. The Visual editor works fine but the 'HTML' button seems to be disabled. I am unable to switch to HTML view.

Any help is greatly appreciated.

Cheers.

Answers (5)

2010-09-01

Ashfame answers:

I think you have loaded jquery 1.4.2 on admin side. To load it only on the front-end use this :

add_action ( 'init' , 'jquery_cdn' );
function jquery_cdn()
{
if ( !is_admin() )
{
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' );
wp_enqueue_script( 'jquery' );
}
}


WP Answers comments:

Hi There,

Please see my code below. This is the code I am using to call in my scripts. Can you please tell me how to adjust this so the jquery won't be loaded in admin? (note: 'THEME_JS' simply points to a specific folder within my theme.

Thanks a lot.


<?php
function my_init_method() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', THEME_JS .'/jquery.min.js');
}

add_action('init', 'my_init_method');

function THEME_scripts() {
wp_enqueue_script( 'jquery');
wp_enqueue_script( 'jquery-cycle', THEME_JS .'/jquery.cycle.all.2.74.js', array('jquery'));
wp_enqueue_script( 'home-modules', THEME_JS .'/home_modules.js', array('jquery'));
wp_enqueue_script( 'THEME-custom', THEME_JS .'/THEME-custom.js', array('jquery'));
}

add_action('wp_print_scripts', 'THEME_scripts');
?>


WP Answers comments:

Any ideas? If you need a higher prize to provide me the answer just let me know and i'll bump it up. Cheers.

2010-09-01

flashingcursor answers:

<?php


add_action('init', 'my_init_method');

function my_init_method() {

if (!is_admin) {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', THEME_JS .'/jquery.min.js');
}
}



add_action('wp_print_scripts', 'THEME_scripts');

function THEME_scripts() {

if (!is_admin) {
wp_enqueue_script( 'jquery');
wp_enqueue_script( 'jquery-cycle', THEME_JS .'/jquery.cycle.all.2.74.js', array('jquery'));
wp_enqueue_script( 'home-modules', THEME_JS .'/home_modules.js', array('jquery'));
wp_enqueue_script( 'THEME-custom', THEME_JS .'/THEME-custom.js', array('jquery'));
}
}
?>


That should do it.


WP Answers comments:

Hi There,

Thank you for this code, however when I use the above code, the scripts no longer get loaded into the head of my main site. This does fix the HTML issue in the admin, but it breaks the javascript on the main site. Any ideas why this is so?


WP Answers comments:

Any ideas? If you need a higher prize to provide me the answer just let me know and i'll bump it up. Cheers.


flashingcursor comments:

Doh, yeah -- those is_admin's should be is_admin() ...

2010-09-01

Milan Petrovic answers:

I can't give you exact answer without seeing what's going on, but if you can't switch editors, you have JavaScript error on the page. When you fix that, it will work again. Use Firefox and Firebug to see it.


WP Answers comments:

Thanks Milan. I do indeed see a JS error:

Error: jQuery is not defined
Source File: http://www.mywebsite.com/wp-admin/load-scripts.php?c=1&load=utils,quicktags,editor&ver=6cf722b1fbb67daeae8c19b58b98d018
Line: 3

Can you please see my reply in the answer above. Would you know how to modify my script so that my jquery script does not load into admin?


WP Answers comments:

Any ideas? If you need a higher prize to provide me the answer just let me know and i'll bump it up. Cheers.

2010-09-01

Roberto Mas answers:

install TinyMCE advances it has way more options


Roberto Mas comments:

did you recently install or updated a plugin? try disabeling plugins one by one to see if one of them creates a conflict

2010-09-01

Denzel Chia answers:

Hi try this.

function my_init_method() {
if(!is_admin()){
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', THEME_JS.'/jquery.min.js');
}
}

add_action('init', 'my_init_method');

function THEME_scripts(){
if(!is_admin()){

wp_register_script( 'jquery-cycle', THEME_JS .'/jquery.cycle.all.2.74.js', array('jquery'));

wp_register_script( 'home-modules', THEME_JS .'/home_modules.js', array('jquery'));

wp_register_script( 'THEME-custom', THEME_JS .'/THEME-custom.js', array('jquery'));


wp_enqueue_script( 'jquery-cycle', THEME_JS .'/jquery.cycle.all.2.74.js', array('jquery'));

wp_enqueue_script( 'home-modules', THEME_JS .'/home_modules.js', array('jquery'));

wp_enqueue_script( 'THEME-custom', THEME_JS .'/THEME-custom.js', array('jquery'));
}
}

//add script to theme <head>
add_action('init', 'THEME_scripts');



Please note that is_admin() is a function, to check whether it is admin or not.
And secondly you got it correct by registering jquery after deregistering.
As for other scripts, you need to register them all, before enqueuing them into the <head> of web page.
And please note, you do not need to enqueue jQuery before enqueuing other scripts,
As the code already states that the new scripts are dependent on jQuery.
So WordPress will load jQuery first follow by other scripts you registered and enqueued.


My script may have syntax error, as I did not verify on my computer.

Hope this helps.

Thanks.