Resolve Media Uploader WordPress 3.4.2 ( fixing Bug.)

Resolving about media uploader on some theme options or options page on your wordpress version 3.4.2, I have some case along day ago , but i was solving this problem without edit the core WordPress CMS.

You know how big the risk if you change or editing the core or system WordPress CMS, you will lose the default and security of wordpress, not close the possibility your website will be broken if you have the wrong type and add some code to the wordpress core.
As an explanation in this case is a notification appears:
Cheatin uh? and also “undefined index capabilties blablabla bla bla bla …”


Resolving Cheatin uh? WordPress Debug

some tips and tricks about resolving this problem is , editing the media-upload.php on wordpress core directories,  the place is on directory :
wp-admin directories or wp-admin/media-upload.php , and try to comment the php script or remove the php script on line 125 ,  code is :

(wp_die( _(  ’Cheatin’ uh? ) ) ;

so why ??? if your remove those code , WordPress security is decrease and also make your WordPress is how..???

in older version of WordPress the function of media uploader on your options page is normally , so why on new version of WordPress your Custom Media Uploader is Broken and not Function?

This is about your Custom Uploader javascript , yap.. just Javascript . Your Options Page Javascript is Incompatible with New version of WordPress, and So? how to Resolve those Problem? and Which the Real Javascript?

Open your Cutom Uploader Javascript, name of file are different , depending on their respective themes or plugins installed on your WordPress.

Some Exam again, if you make the theme junkie Theme of old version you will be have same case about media upload on your theme options, Replace your javascript with some code below.

  1. if your code have the javascript code like below :
    formfield = jQuery('#upload_image').attr('name');
    post_id = jQuery('#post_ID').val();
    tb_show('', 'media-upload.php?post_id='+post_id+'&type=image&TB_iframe=true');
    return false;

    the problem is your code on Red color above, so .. you just remove the Red Color Code , and your code being like this :

    formfield = jQuery('.upload_image').attr('name');
    tb_show('', 'media-upload.php?type=image&TB_iframe=true');
    return false;

    just it , and try your media uploader.

  2. This is the Javascript on ThemeJunkie Theme, But i Dont know themejunkie staff now havebeen this problem or not , but much website have Themes from themejunkie with version of wordpress before 3.4.2.open your custom_uploader.js, the common place on theme junkie is on :your theme directory –> functions –> js –> custom_uploader.jsyou will be seeing the javascript code like this :
    jQuery(document).ready(function() {
    var fileInput = '';
    
    jQuery('.upload_image_button').click(function() {
    fileInput = jQuery(this).parent().prev('input.uploadfield');
    //console.log(fileInput);
    formfield = jQuery('#upload_image').attr('name');
    post_id = jQuery('#post_ID').val();
    tb_show('', 'media-upload.php?post_id='+post_id+'&type=image&TB_iframe=true');
    return false;
    });
    
    jQuery('.upload_image_reset').click(function() {
    jQuery(this).parent().prev('input.uploadfield').val('');
    });
    
    // user inserts file into post. only run custom if user started process using the above process
    // window.send_to_editor(html) is how wp would normally handle the received data
    
    window.original_send_to_editor = window.send_to_editor;
    window.send_to_editor = function(html){
    
    if (fileInput) {
    fileurl = jQuery('img',html).attr('src');
    
    fileInput.val(fileurl);
    
    tb_remove();
    
    } else {
    window.original_send_to_editor(html);
    }
    };
    
    });

    select your all code of javascript ( ctrl + A ) , And replace your javascript with this code :

    jQuery(document).ready(function() {
    var fileInput = '';
    
    jQuery('.upload_image_button').click(function() {
    fileInput = jQuery(this).parent().prev('input.uploadfield');
    formfield = jQuery('.upload_image').attr('name');
    tb_show('', 'media-upload.php?type=image&TB_iframe=true');
    return false;
    });
    
    jQuery('.upload_image_reset').click(function() {
    jQuery(this).parent().prev('input.uploadfield').val('');
    });
    
    // user inserts file into post. only run custom if user started process using the above process
    // window.send_to_editor(html) is how wp would normally handle the received data
    
    window.original_send_to_editor = window.send_to_editor;
    window.send_to_editor = function(html){
    
    if (fileInput) {
    fileurl = jQuery('img',html).attr('src');
    
    fileInput.val(fileurl);
    
    tb_remove();
    
    } else {
    window.original_send_to_editor(html);
    }
    };
    });
    function getXMLHttp()
    {
      var xmlHttp
    
      try
      {
     //Firefox, Opera 8.0+, Safari
     xmlHttp = new XMLHttpRequest();
     }
     catch(e)
     {
     //Internet Explorer
     try
     {
     xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
     }
     catch(e)
     {
     try
     {
     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
     }
     catch(e)
     {
     alert("Your browser does not support AJAX!")
     return false;
     }
     }
     }
     return xmlHttp;
    }

And save, try your options page media uploader now 🙂 , and the green font color just additional when browser does not support AJAX , warning notice will be shown on your browser about notice :).

if you confuse about editing the javascript you could download this javascript 🙂 for themejunkie.

http://www.inforiatif.com/wp-content/uploads/downloads/2012/11/custom_uploader.js

.

Happy blogging 😀 , give me FB like and follow my Twitter if Resolving your problem 🙂