Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 42 additions & 10 deletions post-selection-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,22 +296,54 @@

}

// get wordpress version
var wpVersion = null;
if ( parseInt( PostSelectionUI.wpVersion ) === 4 ) {

wpVersion = 4;

} else {

var versionSplit = PostSelectionUI.wpVersion.split('.');
wpVersion = parseFloat( parseInt( versionSplit[0] ) + ( parseInt( versionSplit[1] ) / 10 ) );

}

//work around for first creation of widget
if ( ( 'object' === typeof wpWidgets ) && ( 'function' === typeof wpWidgets.fixLabels ) ) {
if ( wpVersion >= 3.9 ) {

$( document ).on( 'widget-added widget-updated', initPostSelectionUIOnEvent );

} else {

var oldSave = __bind(wpWidgets, wpWidgets.fixLabels);
if ( ( 'object' === typeof wpWidgets ) && ( 'function' === typeof wpWidgets.appendTitle ) ) {

var oldAppendTitle = __bind(wpWidgets, wpWidgets.appendTitle);

wpWidgets.appendTitle = function(widget) {
oldAppendTitle(widget);
if ( ( 'object' === typeof widget ) && ( 'function' === typeof widget.find ) ) {
initPostSelectionUIOnEvent( null, widget );
}

};

wpWidgets.fixLabels = function(widget) {
oldSave(widget);
if(typeof console != 'undefined'){
console.log(widget);
}
initPostSelectionUIOnEvent( null, widget );
};

} else {
//work around for rebuilding of widget
if ( ( 'object' === typeof wpWidgets ) && ( 'function' === typeof wpWidgets.save ) ) {

$( document ).on( 'widget-added widget-updated', initPostSelectionUIOnEvent );
var oldSave = __bind(wpWidgets, wpWidgets.save);

wpWidgets.save = function (widget, del, animate, order) {
oldSave(widget, del, animate, order);
if (( 'object' === typeof widget ) && ( 'function' === typeof widget.find )) {
initPostSelectionUIOnEvent(null, widget);
}


};
}

}

Expand Down
1 change: 1 addition & 0 deletions post-selection-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static function admin_enqueue_scripts() {
'nonce' => wp_create_nonce( 'psu_search' ),
'spinner' => admin_url( 'images/wpspin_light.gif' ),
'clearConfirmMessage' => __( 'Are you sure you want to clear the selected items?' ),
'wpVersion' => get_bloginfo( 'version' )
) );

}
Expand Down