WP: 3.3 JS Menus and Widgets Fix

Release-of-WordPress-3.3-Version
by Courtney Elizabeth · December 13, 2011 · Girl Geek ·

I know you’ve seen it.

The glaring yellow “WordPress 3.3 is available! Please update now.” notice at the top of your WordPress administration control panel.

Whether you like to keep things simple and hit the “Please update now.” for a quick automated update, or you’re like me and you like to do a clean wipe using FTP to ensure changes and rouge issues, you must be advised that you could encounter issues using the new Javascript (flyout) features such as Menus, drag and drop widgets, and Media Uploader.

Being that we installed this for a few clients, we actually had to back track and install the HotFix plugin for WordPress. Unfortunately, that wasn’t enough. We had to edit the hotfix.php file to include the 3.3 update for WordPress. We implemented the hotfix-patch found here.

So when you put it all together…

your hotfix.php file should read something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
Plugin Name: Hotfix
Description: Provides "hotfixes" for selected WordPress bugs, so you don't have to wait for the next WordPress core release. Keep the plugin updated!
Version: 0.7 (updated)
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
 
// This bootstraps everything
WP_Hotfix_Controller::init();
 
class WP_Hotfix_Controller {
function init() {
add_action( 'init', 'wp_hotfix_init' );
register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) );
register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) );
}
function activate() {
add_option( 'hotfix_version', '1' );
register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
}
function deactivate() {
delete_option( 'hotfix_version' );
}
function uninstall() {
self::deactivate(); // The same, for now
}
}
 
function wp_hotfix_init() {
global $wp_version;
 
$hotfixes = array();
 
switch ( $wp_version ) {
case '3.3' :
if ( !defined( 'CONCATENATE_SCRIPTS' ) )
define( 'CONCATENATE_SCRIPTS', false );
break;
case '3.1.3' :
$hotfixes = array( '313_post_status_query_string' );
break;
case '3.1' :
$hotfixes = array( '310_parsed_tax_query' );
break;
case '3.0.5' :
$hotfixes = array( '305_comment_text_kses' );
break;
}
 
$hotfixes = apply_filters( 'wp_hotfixes', $hotfixes );
 
foreach ( (array) $hotfixes as $hotfix ) {
call_user_func( 'wp_hotfix_' . $hotfix );
}
}
 
/* And now, the hotfixes */
 
function wp_hotfix_305_comment_text_kses() {
remove_filter( 'comment_text', 'wp_kses_data' );
if ( is_admin() )
add_filter( 'comment_text', 'wp_kses_post' );
}
 
function wp_hotfix_310_parsed_tax_query() {
add_filter( 'pre_get_posts', 'wp_hotfix_310_parsed_tax_query_pre_get_posts' );
}
 
function wp_hotfix_310_parsed_tax_query_pre_get_posts( $q ) {
@$q->parsed_tax_query = false; // Force it to be re-parsed.
return $q;
}
 
function wp_hotfix_313_post_status_query_string() {
add_filter( 'request', 'wp_hotfix_313_post_status_query_string_request' );
}
 
function wp_hotfix_313_post_status_query_string_request( $qvs ) {
if ( isset( $qvs['post_status'] ) && is_array( $qvs['post_status'] ) )
$qvs['post_status'] = implode( ',', $qvs['post_status'] );
return $qvs;
}
 
if ( ! function_exists( 'json_encode' ) ) {
function json_encode( $string ) {
global $wp_hotfix_json;
 
if ( ! is_a( $wp_hotfix_json, 'Services_JSON' ) ) {
require_once( dirname( __FILE__ ) . '/inc/class-json.php' );
$wp_hotfix_json = new Services_JSON();
}
 
return $wp_hotfix_json->encodeUnsafe( $string );
}
}
 
if ( ! function_exists( 'json_decode' ) && ! function_exists( '_json_decode_object_helper' ) ) {
function json_decode( $string, $assoc_array = false ) {
global $wp_hotfix_json;
 
if ( ! is_a( $wp_hotfix_json, 'Services_JSON' ) ) {
require_once( dirname( __FILE__ ) . '/inc/class-json.php' );
$wp_hotfix_json = new Services_JSON();
}
 
$res = $wp_hotfix_json->decode( $string );
if ( $assoc_array )
$res = _json_decode_object_helper( $res );
return $res;
}
function _json_decode_object_helper($data) {
if ( is_object($data) )
$data = get_object_vars($data);
return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
}
}
/*
Plugin Name: Hotfix
Description: Provides "hotfixes" for selected WordPress bugs, so you don't have to wait for the next WordPress core release. Keep the plugin updated!
Version: 0.7 (updated)
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/

// This bootstraps everything
WP_Hotfix_Controller::init();

class WP_Hotfix_Controller {
function init() {
add_action( 'init', 'wp_hotfix_init' );
register_activation_hook( __FILE__, array( __CLASS__, 'activate' ) );
register_deactivation_hook( __FILE__, array( __CLASS__, 'deactivate' ) );
}
function activate() {
add_option( 'hotfix_version', '1' );
register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
}
function deactivate() {
delete_option( 'hotfix_version' );
}
function uninstall() {
self::deactivate(); // The same, for now
}
}

function wp_hotfix_init() {
global $wp_version;

$hotfixes = array();

switch ( $wp_version ) {
case '3.3' :
if ( !defined( 'CONCATENATE_SCRIPTS' ) )
define( 'CONCATENATE_SCRIPTS', false );
break;
case '3.1.3' :
$hotfixes = array( '313_post_status_query_string' );
break;
case '3.1' :
$hotfixes = array( '310_parsed_tax_query' );
break;
case '3.0.5' :
$hotfixes = array( '305_comment_text_kses' );
break;
}

$hotfixes = apply_filters( 'wp_hotfixes', $hotfixes );

foreach ( (array) $hotfixes as $hotfix ) {
call_user_func( 'wp_hotfix_' . $hotfix );
}
}

/* And now, the hotfixes */

function wp_hotfix_305_comment_text_kses() {
remove_filter( 'comment_text', 'wp_kses_data' );
if ( is_admin() )
add_filter( 'comment_text', 'wp_kses_post' );
}

function wp_hotfix_310_parsed_tax_query() {
add_filter( 'pre_get_posts', 'wp_hotfix_310_parsed_tax_query_pre_get_posts' );
}

function wp_hotfix_310_parsed_tax_query_pre_get_posts( $q ) {
@$q->parsed_tax_query = false; // Force it to be re-parsed.
return $q;
}

function wp_hotfix_313_post_status_query_string() {
add_filter( 'request', 'wp_hotfix_313_post_status_query_string_request' );
}

function wp_hotfix_313_post_status_query_string_request( $qvs ) {
if ( isset( $qvs['post_status'] ) && is_array( $qvs['post_status'] ) )
$qvs['post_status'] = implode( ',', $qvs['post_status'] );
return $qvs;
}

if ( ! function_exists( 'json_encode' ) ) {
function json_encode( $string ) {
global $wp_hotfix_json;

if ( ! is_a( $wp_hotfix_json, 'Services_JSON' ) ) {
require_once( dirname( __FILE__ ) . '/inc/class-json.php' );
$wp_hotfix_json = new Services_JSON();
}

return $wp_hotfix_json->encodeUnsafe( $string );
}
}

if ( ! function_exists( 'json_decode' ) && ! function_exists( '_json_decode_object_helper' ) ) {
function json_decode( $string, $assoc_array = false ) {
global $wp_hotfix_json;

if ( ! is_a( $wp_hotfix_json, 'Services_JSON' ) ) {
require_once( dirname( __FILE__ ) . '/inc/class-json.php' );
$wp_hotfix_json = new Services_JSON();
}

$res = $wp_hotfix_json->decode( $string );
if ( $assoc_array )
$res = _json_decode_object_helper( $res );
return $res;
}
function _json_decode_object_helper($data) {
if ( is_object($data) )
$data = get_object_vars($data);
return is_array($data) ? array_map(__FUNCTION__, $data) : $data;
}
}

Fix your WordPress 3.3 Javascript Menus and Widgets Panel:

  1. Download WordPress HotFix Plugin
  2. Replace the hotfix.php file with the above code, or with the code found here: Hotfix.php file (25)

Gallery


Related Posts...(possibly)


Be Social