Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-admin/js/widgets
File: media-widgets.js
'default': 0
[1000] Fix | Delete
},
[1001] Fix | Delete
url: {
[1002] Fix | Delete
type: 'string',
[1003] Fix | Delete
'default': ''
[1004] Fix | Delete
}
[1005] Fix | Delete
},
[1006] Fix | Delete
[1007] Fix | Delete
/**
[1008] Fix | Delete
* Get default attribute values.
[1009] Fix | Delete
*
[1010] Fix | Delete
* @return {Object} Mapping of property names to their default values.
[1011] Fix | Delete
*/
[1012] Fix | Delete
defaults: function() {
[1013] Fix | Delete
var defaults = {};
[1014] Fix | Delete
_.each( this.schema, function( fieldSchema, field ) {
[1015] Fix | Delete
defaults[ field ] = fieldSchema['default'];
[1016] Fix | Delete
});
[1017] Fix | Delete
return defaults;
[1018] Fix | Delete
},
[1019] Fix | Delete
[1020] Fix | Delete
/**
[1021] Fix | Delete
* Set attribute value(s).
[1022] Fix | Delete
*
[1023] Fix | Delete
* This is a wrapped version of Backbone.Model#set() which allows us to
[1024] Fix | Delete
* cast the attribute values from the hidden inputs' string values into
[1025] Fix | Delete
* the appropriate data types (integers or booleans).
[1026] Fix | Delete
*
[1027] Fix | Delete
* @param {string|Object} key - Attribute name or attribute pairs.
[1028] Fix | Delete
* @param {mixed|Object} [val] - Attribute value or options object.
[1029] Fix | Delete
* @param {Object} [options] - Options when attribute name and value are passed separately.
[1030] Fix | Delete
* @return {wp.mediaWidgets.MediaWidgetModel} This model.
[1031] Fix | Delete
*/
[1032] Fix | Delete
set: function set( key, val, options ) {
[1033] Fix | Delete
var model = this, attrs, opts, castedAttrs; // eslint-disable-line consistent-this
[1034] Fix | Delete
if ( null === key ) {
[1035] Fix | Delete
return model;
[1036] Fix | Delete
}
[1037] Fix | Delete
if ( 'object' === typeof key ) {
[1038] Fix | Delete
attrs = key;
[1039] Fix | Delete
opts = val;
[1040] Fix | Delete
} else {
[1041] Fix | Delete
attrs = {};
[1042] Fix | Delete
attrs[ key ] = val;
[1043] Fix | Delete
opts = options;
[1044] Fix | Delete
}
[1045] Fix | Delete
[1046] Fix | Delete
castedAttrs = {};
[1047] Fix | Delete
_.each( attrs, function( value, name ) {
[1048] Fix | Delete
var type;
[1049] Fix | Delete
if ( ! model.schema[ name ] ) {
[1050] Fix | Delete
castedAttrs[ name ] = value;
[1051] Fix | Delete
return;
[1052] Fix | Delete
}
[1053] Fix | Delete
type = model.schema[ name ].type;
[1054] Fix | Delete
if ( 'array' === type ) {
[1055] Fix | Delete
castedAttrs[ name ] = value;
[1056] Fix | Delete
if ( ! _.isArray( castedAttrs[ name ] ) ) {
[1057] Fix | Delete
castedAttrs[ name ] = castedAttrs[ name ].split( /,/ ); // Good enough for parsing an ID list.
[1058] Fix | Delete
}
[1059] Fix | Delete
if ( model.schema[ name ].items && 'integer' === model.schema[ name ].items.type ) {
[1060] Fix | Delete
castedAttrs[ name ] = _.filter(
[1061] Fix | Delete
_.map( castedAttrs[ name ], function( id ) {
[1062] Fix | Delete
return parseInt( id, 10 );
[1063] Fix | Delete
},
[1064] Fix | Delete
function( id ) {
[1065] Fix | Delete
return 'number' === typeof id;
[1066] Fix | Delete
}
[1067] Fix | Delete
) );
[1068] Fix | Delete
}
[1069] Fix | Delete
} else if ( 'integer' === type ) {
[1070] Fix | Delete
castedAttrs[ name ] = parseInt( value, 10 );
[1071] Fix | Delete
} else if ( 'boolean' === type ) {
[1072] Fix | Delete
castedAttrs[ name ] = ! ( ! value || '0' === value || 'false' === value );
[1073] Fix | Delete
} else {
[1074] Fix | Delete
castedAttrs[ name ] = value;
[1075] Fix | Delete
}
[1076] Fix | Delete
});
[1077] Fix | Delete
[1078] Fix | Delete
return Backbone.Model.prototype.set.call( this, castedAttrs, opts );
[1079] Fix | Delete
},
[1080] Fix | Delete
[1081] Fix | Delete
/**
[1082] Fix | Delete
* Get props which are merged on top of the model when an embed is chosen (as opposed to an attachment).
[1083] Fix | Delete
*
[1084] Fix | Delete
* @return {Object} Reset/override props.
[1085] Fix | Delete
*/
[1086] Fix | Delete
getEmbedResetProps: function getEmbedResetProps() {
[1087] Fix | Delete
return {
[1088] Fix | Delete
id: 0
[1089] Fix | Delete
};
[1090] Fix | Delete
}
[1091] Fix | Delete
});
[1092] Fix | Delete
[1093] Fix | Delete
/**
[1094] Fix | Delete
* Collection of all widget model instances.
[1095] Fix | Delete
*
[1096] Fix | Delete
* @memberOf wp.mediaWidgets
[1097] Fix | Delete
*
[1098] Fix | Delete
* @type {Backbone.Collection}
[1099] Fix | Delete
*/
[1100] Fix | Delete
component.modelCollection = new ( Backbone.Collection.extend( {
[1101] Fix | Delete
model: component.MediaWidgetModel
[1102] Fix | Delete
}) )();
[1103] Fix | Delete
[1104] Fix | Delete
/**
[1105] Fix | Delete
* Mapping of widget ID to instances of MediaWidgetControl subclasses.
[1106] Fix | Delete
*
[1107] Fix | Delete
* @memberOf wp.mediaWidgets
[1108] Fix | Delete
*
[1109] Fix | Delete
* @type {Object.<string, wp.mediaWidgets.MediaWidgetControl>}
[1110] Fix | Delete
*/
[1111] Fix | Delete
component.widgetControls = {};
[1112] Fix | Delete
[1113] Fix | Delete
/**
[1114] Fix | Delete
* Handle widget being added or initialized for the first time at the widget-added event.
[1115] Fix | Delete
*
[1116] Fix | Delete
* @memberOf wp.mediaWidgets
[1117] Fix | Delete
*
[1118] Fix | Delete
* @param {jQuery.Event} event - Event.
[1119] Fix | Delete
* @param {jQuery} widgetContainer - Widget container element.
[1120] Fix | Delete
*
[1121] Fix | Delete
* @return {void}
[1122] Fix | Delete
*/
[1123] Fix | Delete
component.handleWidgetAdded = function handleWidgetAdded( event, widgetContainer ) {
[1124] Fix | Delete
var fieldContainer, syncContainer, widgetForm, idBase, ControlConstructor, ModelConstructor, modelAttributes, widgetControl, widgetModel, widgetId, animatedCheckDelay = 50, renderWhenAnimationDone;
[1125] Fix | Delete
widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); // Note: '.form' appears in the customizer, whereas 'form' on the widgets admin screen.
[1126] Fix | Delete
idBase = widgetForm.find( '> .id_base' ).val();
[1127] Fix | Delete
widgetId = widgetForm.find( '> .widget-id' ).val();
[1128] Fix | Delete
[1129] Fix | Delete
// Prevent initializing already-added widgets.
[1130] Fix | Delete
if ( component.widgetControls[ widgetId ] ) {
[1131] Fix | Delete
return;
[1132] Fix | Delete
}
[1133] Fix | Delete
[1134] Fix | Delete
ControlConstructor = component.controlConstructors[ idBase ];
[1135] Fix | Delete
if ( ! ControlConstructor ) {
[1136] Fix | Delete
return;
[1137] Fix | Delete
}
[1138] Fix | Delete
[1139] Fix | Delete
ModelConstructor = component.modelConstructors[ idBase ] || component.MediaWidgetModel;
[1140] Fix | Delete
[1141] Fix | Delete
/*
[1142] Fix | Delete
* Create a container element for the widget control (Backbone.View).
[1143] Fix | Delete
* This is inserted into the DOM immediately before the .widget-content
[1144] Fix | Delete
* element because the contents of this element are essentially "managed"
[1145] Fix | Delete
* by PHP, where each widget update cause the entire element to be emptied
[1146] Fix | Delete
* and replaced with the rendered output of WP_Widget::form() which is
[1147] Fix | Delete
* sent back in Ajax request made to save/update the widget instance.
[1148] Fix | Delete
* To prevent a "flash of replaced DOM elements and re-initialized JS
[1149] Fix | Delete
* components", the JS template is rendered outside of the normal form
[1150] Fix | Delete
* container.
[1151] Fix | Delete
*/
[1152] Fix | Delete
fieldContainer = $( '<div></div>' );
[1153] Fix | Delete
syncContainer = widgetContainer.find( '.widget-content:first' );
[1154] Fix | Delete
syncContainer.before( fieldContainer );
[1155] Fix | Delete
[1156] Fix | Delete
/*
[1157] Fix | Delete
* Sync the widget instance model attributes onto the hidden inputs that widgets currently use to store the state.
[1158] Fix | Delete
* In the future, when widgets are JS-driven, the underlying widget instance data should be exposed as a model
[1159] Fix | Delete
* from the start, without having to sync with hidden fields. See <https://core.trac.wordpress.org/ticket/33507>.
[1160] Fix | Delete
*/
[1161] Fix | Delete
modelAttributes = {};
[1162] Fix | Delete
syncContainer.find( '.media-widget-instance-property' ).each( function() {
[1163] Fix | Delete
var input = $( this );
[1164] Fix | Delete
modelAttributes[ input.data( 'property' ) ] = input.val();
[1165] Fix | Delete
});
[1166] Fix | Delete
modelAttributes.widget_id = widgetId;
[1167] Fix | Delete
[1168] Fix | Delete
widgetModel = new ModelConstructor( modelAttributes );
[1169] Fix | Delete
[1170] Fix | Delete
widgetControl = new ControlConstructor({
[1171] Fix | Delete
el: fieldContainer,
[1172] Fix | Delete
syncContainer: syncContainer,
[1173] Fix | Delete
model: widgetModel
[1174] Fix | Delete
});
[1175] Fix | Delete
[1176] Fix | Delete
/*
[1177] Fix | Delete
* Render the widget once the widget parent's container finishes animating,
[1178] Fix | Delete
* as the widget-added event fires with a slideDown of the container.
[1179] Fix | Delete
* This ensures that the container's dimensions are fixed so that ME.js
[1180] Fix | Delete
* can initialize with the proper dimensions.
[1181] Fix | Delete
*/
[1182] Fix | Delete
renderWhenAnimationDone = function() {
[1183] Fix | Delete
if ( ! widgetContainer.hasClass( 'open' ) ) {
[1184] Fix | Delete
setTimeout( renderWhenAnimationDone, animatedCheckDelay );
[1185] Fix | Delete
} else {
[1186] Fix | Delete
widgetControl.render();
[1187] Fix | Delete
}
[1188] Fix | Delete
};
[1189] Fix | Delete
renderWhenAnimationDone();
[1190] Fix | Delete
[1191] Fix | Delete
/*
[1192] Fix | Delete
* Note that the model and control currently won't ever get garbage-collected
[1193] Fix | Delete
* when a widget gets removed/deleted because there is no widget-removed event.
[1194] Fix | Delete
*/
[1195] Fix | Delete
component.modelCollection.add( [ widgetModel ] );
[1196] Fix | Delete
component.widgetControls[ widgetModel.get( 'widget_id' ) ] = widgetControl;
[1197] Fix | Delete
};
[1198] Fix | Delete
[1199] Fix | Delete
/**
[1200] Fix | Delete
* Setup widget in accessibility mode.
[1201] Fix | Delete
*
[1202] Fix | Delete
* @memberOf wp.mediaWidgets
[1203] Fix | Delete
*
[1204] Fix | Delete
* @return {void}
[1205] Fix | Delete
*/
[1206] Fix | Delete
component.setupAccessibleMode = function setupAccessibleMode() {
[1207] Fix | Delete
var widgetForm, widgetId, idBase, widgetControl, ControlConstructor, ModelConstructor, modelAttributes, fieldContainer, syncContainer;
[1208] Fix | Delete
widgetForm = $( '.editwidget > form' );
[1209] Fix | Delete
if ( 0 === widgetForm.length ) {
[1210] Fix | Delete
return;
[1211] Fix | Delete
}
[1212] Fix | Delete
[1213] Fix | Delete
idBase = widgetForm.find( '.id_base' ).val();
[1214] Fix | Delete
[1215] Fix | Delete
ControlConstructor = component.controlConstructors[ idBase ];
[1216] Fix | Delete
if ( ! ControlConstructor ) {
[1217] Fix | Delete
return;
[1218] Fix | Delete
}
[1219] Fix | Delete
[1220] Fix | Delete
widgetId = widgetForm.find( '> .widget-control-actions > .widget-id' ).val();
[1221] Fix | Delete
[1222] Fix | Delete
ModelConstructor = component.modelConstructors[ idBase ] || component.MediaWidgetModel;
[1223] Fix | Delete
fieldContainer = $( '<div></div>' );
[1224] Fix | Delete
syncContainer = widgetForm.find( '> .widget-inside' );
[1225] Fix | Delete
syncContainer.before( fieldContainer );
[1226] Fix | Delete
[1227] Fix | Delete
modelAttributes = {};
[1228] Fix | Delete
syncContainer.find( '.media-widget-instance-property' ).each( function() {
[1229] Fix | Delete
var input = $( this );
[1230] Fix | Delete
modelAttributes[ input.data( 'property' ) ] = input.val();
[1231] Fix | Delete
});
[1232] Fix | Delete
modelAttributes.widget_id = widgetId;
[1233] Fix | Delete
[1234] Fix | Delete
widgetControl = new ControlConstructor({
[1235] Fix | Delete
el: fieldContainer,
[1236] Fix | Delete
syncContainer: syncContainer,
[1237] Fix | Delete
model: new ModelConstructor( modelAttributes )
[1238] Fix | Delete
});
[1239] Fix | Delete
[1240] Fix | Delete
component.modelCollection.add( [ widgetControl.model ] );
[1241] Fix | Delete
component.widgetControls[ widgetControl.model.get( 'widget_id' ) ] = widgetControl;
[1242] Fix | Delete
[1243] Fix | Delete
widgetControl.render();
[1244] Fix | Delete
};
[1245] Fix | Delete
[1246] Fix | Delete
/**
[1247] Fix | Delete
* Sync widget instance data sanitized from server back onto widget model.
[1248] Fix | Delete
*
[1249] Fix | Delete
* This gets called via the 'widget-updated' event when saving a widget from
[1250] Fix | Delete
* the widgets admin screen and also via the 'widget-synced' event when making
[1251] Fix | Delete
* a change to a widget in the customizer.
[1252] Fix | Delete
*
[1253] Fix | Delete
* @memberOf wp.mediaWidgets
[1254] Fix | Delete
*
[1255] Fix | Delete
* @param {jQuery.Event} event - Event.
[1256] Fix | Delete
* @param {jQuery} widgetContainer - Widget container element.
[1257] Fix | Delete
*
[1258] Fix | Delete
* @return {void}
[1259] Fix | Delete
*/
[1260] Fix | Delete
component.handleWidgetUpdated = function handleWidgetUpdated( event, widgetContainer ) {
[1261] Fix | Delete
var widgetForm, widgetContent, widgetId, widgetControl, attributes = {};
[1262] Fix | Delete
widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' );
[1263] Fix | Delete
widgetId = widgetForm.find( '> .widget-id' ).val();
[1264] Fix | Delete
[1265] Fix | Delete
widgetControl = component.widgetControls[ widgetId ];
[1266] Fix | Delete
if ( ! widgetControl ) {
[1267] Fix | Delete
return;
[1268] Fix | Delete
}
[1269] Fix | Delete
[1270] Fix | Delete
// Make sure the server-sanitized values get synced back into the model.
[1271] Fix | Delete
widgetContent = widgetForm.find( '> .widget-content' );
[1272] Fix | Delete
widgetContent.find( '.media-widget-instance-property' ).each( function() {
[1273] Fix | Delete
var property = $( this ).data( 'property' );
[1274] Fix | Delete
attributes[ property ] = $( this ).val();
[1275] Fix | Delete
});
[1276] Fix | Delete
[1277] Fix | Delete
// Suspend syncing model back to inputs when syncing from inputs to model, preventing infinite loop.
[1278] Fix | Delete
widgetControl.stopListening( widgetControl.model, 'change', widgetControl.syncModelToInputs );
[1279] Fix | Delete
widgetControl.model.set( attributes );
[1280] Fix | Delete
widgetControl.listenTo( widgetControl.model, 'change', widgetControl.syncModelToInputs );
[1281] Fix | Delete
};
[1282] Fix | Delete
[1283] Fix | Delete
/**
[1284] Fix | Delete
* Initialize functionality.
[1285] Fix | Delete
*
[1286] Fix | Delete
* This function exists to prevent the JS file from having to boot itself.
[1287] Fix | Delete
* When WordPress enqueues this script, it should have an inline script
[1288] Fix | Delete
* attached which calls wp.mediaWidgets.init().
[1289] Fix | Delete
*
[1290] Fix | Delete
* @memberOf wp.mediaWidgets
[1291] Fix | Delete
*
[1292] Fix | Delete
* @return {void}
[1293] Fix | Delete
*/
[1294] Fix | Delete
component.init = function init() {
[1295] Fix | Delete
var $document = $( document );
[1296] Fix | Delete
$document.on( 'widget-added', component.handleWidgetAdded );
[1297] Fix | Delete
$document.on( 'widget-synced widget-updated', component.handleWidgetUpdated );
[1298] Fix | Delete
[1299] Fix | Delete
/*
[1300] Fix | Delete
* Manually trigger widget-added events for media widgets on the admin
[1301] Fix | Delete
* screen once they are expanded. The widget-added event is not triggered
[1302] Fix | Delete
* for each pre-existing widget on the widgets admin screen like it is
[1303] Fix | Delete
* on the customizer. Likewise, the customizer only triggers widget-added
[1304] Fix | Delete
* when the widget is expanded to just-in-time construct the widget form
[1305] Fix | Delete
* when it is actually going to be displayed. So the following implements
[1306] Fix | Delete
* the same for the widgets admin screen, to invoke the widget-added
[1307] Fix | Delete
* handler when a pre-existing media widget is expanded.
[1308] Fix | Delete
*/
[1309] Fix | Delete
$( function initializeExistingWidgetContainers() {
[1310] Fix | Delete
var widgetContainers;
[1311] Fix | Delete
if ( 'widgets' !== window.pagenow ) {
[1312] Fix | Delete
return;
[1313] Fix | Delete
}
[1314] Fix | Delete
widgetContainers = $( '.widgets-holder-wrap:not(#available-widgets)' ).find( 'div.widget' );
[1315] Fix | Delete
widgetContainers.one( 'click.toggle-widget-expanded', function toggleWidgetExpanded() {
[1316] Fix | Delete
var widgetContainer = $( this );
[1317] Fix | Delete
component.handleWidgetAdded( new jQuery.Event( 'widget-added' ), widgetContainer );
[1318] Fix | Delete
});
[1319] Fix | Delete
[1320] Fix | Delete
// Accessibility mode.
[1321] Fix | Delete
if ( document.readyState === 'complete' ) {
[1322] Fix | Delete
// Page is fully loaded.
[1323] Fix | Delete
component.setupAccessibleMode();
[1324] Fix | Delete
} else {
[1325] Fix | Delete
// Page is still loading.
[1326] Fix | Delete
$( window ).on( 'load', function() {
[1327] Fix | Delete
component.setupAccessibleMode();
[1328] Fix | Delete
});
[1329] Fix | Delete
}
[1330] Fix | Delete
});
[1331] Fix | Delete
};
[1332] Fix | Delete
[1333] Fix | Delete
return component;
[1334] Fix | Delete
})( jQuery );
[1335] Fix | Delete
[1336] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function