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.../public_h.../wp-admin/js
File: customize-widgets.js
},
[2000] Fix | Delete
[2001] Fix | Delete
[2002] Fix | Delete
/***********************************************************************
[2003] Fix | Delete
* Begin public API methods
[2004] Fix | Delete
**********************************************************************/
[2005] Fix | Delete
[2006] Fix | Delete
/**
[2007] Fix | Delete
* Enable/disable the reordering UI
[2008] Fix | Delete
*
[2009] Fix | Delete
* @param {boolean} showOrHide to enable/disable reordering
[2010] Fix | Delete
*
[2011] Fix | Delete
* @todo We should have a reordering state instead and rename this to onChangeReordering
[2012] Fix | Delete
*/
[2013] Fix | Delete
toggleReordering: function( showOrHide ) {
[2014] Fix | Delete
var addNewWidgetBtn = this.$sectionContent.find( '.add-new-widget' ),
[2015] Fix | Delete
reorderBtn = this.container.find( '.reorder-toggle' ),
[2016] Fix | Delete
widgetsTitle = this.$sectionContent.find( '.widget-title' );
[2017] Fix | Delete
[2018] Fix | Delete
showOrHide = Boolean( showOrHide );
[2019] Fix | Delete
[2020] Fix | Delete
if ( showOrHide === this.$sectionContent.hasClass( 'reordering' ) ) {
[2021] Fix | Delete
return;
[2022] Fix | Delete
}
[2023] Fix | Delete
[2024] Fix | Delete
this.isReordering = showOrHide;
[2025] Fix | Delete
this.$sectionContent.toggleClass( 'reordering', showOrHide );
[2026] Fix | Delete
[2027] Fix | Delete
if ( showOrHide ) {
[2028] Fix | Delete
_( this.getWidgetFormControls() ).each( function( formControl ) {
[2029] Fix | Delete
formControl.collapse();
[2030] Fix | Delete
} );
[2031] Fix | Delete
[2032] Fix | Delete
addNewWidgetBtn.attr({ 'tabindex': '-1', 'aria-hidden': 'true' });
[2033] Fix | Delete
reorderBtn.attr( 'aria-label', l10n.reorderLabelOff );
[2034] Fix | Delete
wp.a11y.speak( l10n.reorderModeOn );
[2035] Fix | Delete
// Hide widget titles while reordering: title is already in the reorder controls.
[2036] Fix | Delete
widgetsTitle.attr( 'aria-hidden', 'true' );
[2037] Fix | Delete
} else {
[2038] Fix | Delete
addNewWidgetBtn.removeAttr( 'tabindex aria-hidden' );
[2039] Fix | Delete
reorderBtn.attr( 'aria-label', l10n.reorderLabelOn );
[2040] Fix | Delete
wp.a11y.speak( l10n.reorderModeOff );
[2041] Fix | Delete
widgetsTitle.attr( 'aria-hidden', 'false' );
[2042] Fix | Delete
}
[2043] Fix | Delete
},
[2044] Fix | Delete
[2045] Fix | Delete
/**
[2046] Fix | Delete
* Get the widget_form Customize controls associated with the current sidebar.
[2047] Fix | Delete
*
[2048] Fix | Delete
* @since 3.9.0
[2049] Fix | Delete
* @return {wp.customize.controlConstructor.widget_form[]}
[2050] Fix | Delete
*/
[2051] Fix | Delete
getWidgetFormControls: function() {
[2052] Fix | Delete
var formControls = [];
[2053] Fix | Delete
[2054] Fix | Delete
_( this.setting() ).each( function( widgetId ) {
[2055] Fix | Delete
var settingId = widgetIdToSettingId( widgetId ),
[2056] Fix | Delete
formControl = api.control( settingId );
[2057] Fix | Delete
if ( formControl ) {
[2058] Fix | Delete
formControls.push( formControl );
[2059] Fix | Delete
}
[2060] Fix | Delete
} );
[2061] Fix | Delete
[2062] Fix | Delete
return formControls;
[2063] Fix | Delete
},
[2064] Fix | Delete
[2065] Fix | Delete
/**
[2066] Fix | Delete
* @param {string} widgetId or an id_base for adding a previously non-existing widget.
[2067] Fix | Delete
* @return {Object|false} widget_form control instance, or false on error.
[2068] Fix | Delete
*/
[2069] Fix | Delete
addWidget: function( widgetId ) {
[2070] Fix | Delete
var self = this, controlHtml, $widget, controlType = 'widget_form', controlContainer, controlConstructor,
[2071] Fix | Delete
parsedWidgetId = parseWidgetId( widgetId ),
[2072] Fix | Delete
widgetNumber = parsedWidgetId.number,
[2073] Fix | Delete
widgetIdBase = parsedWidgetId.id_base,
[2074] Fix | Delete
widget = api.Widgets.availableWidgets.findWhere( {id_base: widgetIdBase} ),
[2075] Fix | Delete
settingId, isExistingWidget, widgetFormControl, sidebarWidgets, settingArgs, setting;
[2076] Fix | Delete
[2077] Fix | Delete
if ( ! widget ) {
[2078] Fix | Delete
return false;
[2079] Fix | Delete
}
[2080] Fix | Delete
[2081] Fix | Delete
if ( widgetNumber && ! widget.get( 'is_multi' ) ) {
[2082] Fix | Delete
return false;
[2083] Fix | Delete
}
[2084] Fix | Delete
[2085] Fix | Delete
// Set up new multi widget.
[2086] Fix | Delete
if ( widget.get( 'is_multi' ) && ! widgetNumber ) {
[2087] Fix | Delete
widget.set( 'multi_number', widget.get( 'multi_number' ) + 1 );
[2088] Fix | Delete
widgetNumber = widget.get( 'multi_number' );
[2089] Fix | Delete
}
[2090] Fix | Delete
[2091] Fix | Delete
controlHtml = $( '#widget-tpl-' + widget.get( 'id' ) ).html().trim();
[2092] Fix | Delete
if ( widget.get( 'is_multi' ) ) {
[2093] Fix | Delete
controlHtml = controlHtml.replace( /<[^<>]+>/g, function( m ) {
[2094] Fix | Delete
return m.replace( /__i__|%i%/g, widgetNumber );
[2095] Fix | Delete
} );
[2096] Fix | Delete
} else {
[2097] Fix | Delete
widget.set( 'is_disabled', true ); // Prevent single widget from being added again now.
[2098] Fix | Delete
}
[2099] Fix | Delete
[2100] Fix | Delete
$widget = $( controlHtml );
[2101] Fix | Delete
[2102] Fix | Delete
controlContainer = $( '<li/>' )
[2103] Fix | Delete
.addClass( 'customize-control' )
[2104] Fix | Delete
.addClass( 'customize-control-' + controlType )
[2105] Fix | Delete
.append( $widget );
[2106] Fix | Delete
[2107] Fix | Delete
// Remove icon which is visible inside the panel.
[2108] Fix | Delete
controlContainer.find( '> .widget-icon' ).remove();
[2109] Fix | Delete
[2110] Fix | Delete
if ( widget.get( 'is_multi' ) ) {
[2111] Fix | Delete
controlContainer.find( 'input[name="widget_number"]' ).val( widgetNumber );
[2112] Fix | Delete
controlContainer.find( 'input[name="multi_number"]' ).val( widgetNumber );
[2113] Fix | Delete
}
[2114] Fix | Delete
[2115] Fix | Delete
widgetId = controlContainer.find( '[name="widget-id"]' ).val();
[2116] Fix | Delete
[2117] Fix | Delete
controlContainer.hide(); // To be slid-down below.
[2118] Fix | Delete
[2119] Fix | Delete
settingId = 'widget_' + widget.get( 'id_base' );
[2120] Fix | Delete
if ( widget.get( 'is_multi' ) ) {
[2121] Fix | Delete
settingId += '[' + widgetNumber + ']';
[2122] Fix | Delete
}
[2123] Fix | Delete
controlContainer.attr( 'id', 'customize-control-' + settingId.replace( /\]/g, '' ).replace( /\[/g, '-' ) );
[2124] Fix | Delete
[2125] Fix | Delete
// Only create setting if it doesn't already exist (if we're adding a pre-existing inactive widget).
[2126] Fix | Delete
isExistingWidget = api.has( settingId );
[2127] Fix | Delete
if ( ! isExistingWidget ) {
[2128] Fix | Delete
settingArgs = {
[2129] Fix | Delete
transport: api.Widgets.data.selectiveRefreshableWidgets[ widget.get( 'id_base' ) ] ? 'postMessage' : 'refresh',
[2130] Fix | Delete
previewer: this.setting.previewer
[2131] Fix | Delete
};
[2132] Fix | Delete
setting = api.create( settingId, settingId, '', settingArgs );
[2133] Fix | Delete
setting.set( {} ); // Mark dirty, changing from '' to {}.
[2134] Fix | Delete
}
[2135] Fix | Delete
[2136] Fix | Delete
controlConstructor = api.controlConstructor[controlType];
[2137] Fix | Delete
widgetFormControl = new controlConstructor( settingId, {
[2138] Fix | Delete
settings: {
[2139] Fix | Delete
'default': settingId
[2140] Fix | Delete
},
[2141] Fix | Delete
content: controlContainer,
[2142] Fix | Delete
sidebar_id: self.params.sidebar_id,
[2143] Fix | Delete
widget_id: widgetId,
[2144] Fix | Delete
widget_id_base: widget.get( 'id_base' ),
[2145] Fix | Delete
type: controlType,
[2146] Fix | Delete
is_new: ! isExistingWidget,
[2147] Fix | Delete
width: widget.get( 'width' ),
[2148] Fix | Delete
height: widget.get( 'height' ),
[2149] Fix | Delete
is_wide: widget.get( 'is_wide' )
[2150] Fix | Delete
} );
[2151] Fix | Delete
api.control.add( widgetFormControl );
[2152] Fix | Delete
[2153] Fix | Delete
// Make sure widget is removed from the other sidebars.
[2154] Fix | Delete
api.each( function( otherSetting ) {
[2155] Fix | Delete
if ( otherSetting.id === self.setting.id ) {
[2156] Fix | Delete
return;
[2157] Fix | Delete
}
[2158] Fix | Delete
[2159] Fix | Delete
if ( 0 !== otherSetting.id.indexOf( 'sidebars_widgets[' ) ) {
[2160] Fix | Delete
return;
[2161] Fix | Delete
}
[2162] Fix | Delete
[2163] Fix | Delete
var otherSidebarWidgets = otherSetting().slice(),
[2164] Fix | Delete
i = _.indexOf( otherSidebarWidgets, widgetId );
[2165] Fix | Delete
[2166] Fix | Delete
if ( -1 !== i ) {
[2167] Fix | Delete
otherSidebarWidgets.splice( i );
[2168] Fix | Delete
otherSetting( otherSidebarWidgets );
[2169] Fix | Delete
}
[2170] Fix | Delete
} );
[2171] Fix | Delete
[2172] Fix | Delete
// Add widget to this sidebar.
[2173] Fix | Delete
sidebarWidgets = this.setting().slice();
[2174] Fix | Delete
if ( -1 === _.indexOf( sidebarWidgets, widgetId ) ) {
[2175] Fix | Delete
sidebarWidgets.push( widgetId );
[2176] Fix | Delete
this.setting( sidebarWidgets );
[2177] Fix | Delete
}
[2178] Fix | Delete
[2179] Fix | Delete
controlContainer.slideDown( function() {
[2180] Fix | Delete
if ( isExistingWidget ) {
[2181] Fix | Delete
widgetFormControl.updateWidget( {
[2182] Fix | Delete
instance: widgetFormControl.setting()
[2183] Fix | Delete
} );
[2184] Fix | Delete
}
[2185] Fix | Delete
} );
[2186] Fix | Delete
[2187] Fix | Delete
return widgetFormControl;
[2188] Fix | Delete
}
[2189] Fix | Delete
} );
[2190] Fix | Delete
[2191] Fix | Delete
// Register models for custom panel, section, and control types.
[2192] Fix | Delete
$.extend( api.panelConstructor, {
[2193] Fix | Delete
widgets: api.Widgets.WidgetsPanel
[2194] Fix | Delete
});
[2195] Fix | Delete
$.extend( api.sectionConstructor, {
[2196] Fix | Delete
sidebar: api.Widgets.SidebarSection
[2197] Fix | Delete
});
[2198] Fix | Delete
$.extend( api.controlConstructor, {
[2199] Fix | Delete
widget_form: api.Widgets.WidgetControl,
[2200] Fix | Delete
sidebar_widgets: api.Widgets.SidebarControl
[2201] Fix | Delete
});
[2202] Fix | Delete
[2203] Fix | Delete
/**
[2204] Fix | Delete
* Init Customizer for widgets.
[2205] Fix | Delete
*/
[2206] Fix | Delete
api.bind( 'ready', function() {
[2207] Fix | Delete
// Set up the widgets panel.
[2208] Fix | Delete
api.Widgets.availableWidgetsPanel = new api.Widgets.AvailableWidgetsPanelView({
[2209] Fix | Delete
collection: api.Widgets.availableWidgets
[2210] Fix | Delete
});
[2211] Fix | Delete
[2212] Fix | Delete
// Highlight widget control.
[2213] Fix | Delete
api.previewer.bind( 'highlight-widget-control', api.Widgets.highlightWidgetFormControl );
[2214] Fix | Delete
[2215] Fix | Delete
// Open and focus widget control.
[2216] Fix | Delete
api.previewer.bind( 'focus-widget-control', api.Widgets.focusWidgetFormControl );
[2217] Fix | Delete
} );
[2218] Fix | Delete
[2219] Fix | Delete
/**
[2220] Fix | Delete
* Highlight a widget control.
[2221] Fix | Delete
*
[2222] Fix | Delete
* @param {string} widgetId
[2223] Fix | Delete
*/
[2224] Fix | Delete
api.Widgets.highlightWidgetFormControl = function( widgetId ) {
[2225] Fix | Delete
var control = api.Widgets.getWidgetFormControlForWidget( widgetId );
[2226] Fix | Delete
[2227] Fix | Delete
if ( control ) {
[2228] Fix | Delete
control.highlightSectionAndControl();
[2229] Fix | Delete
}
[2230] Fix | Delete
},
[2231] Fix | Delete
[2232] Fix | Delete
/**
[2233] Fix | Delete
* Focus a widget control.
[2234] Fix | Delete
*
[2235] Fix | Delete
* @param {string} widgetId
[2236] Fix | Delete
*/
[2237] Fix | Delete
api.Widgets.focusWidgetFormControl = function( widgetId ) {
[2238] Fix | Delete
var control = api.Widgets.getWidgetFormControlForWidget( widgetId );
[2239] Fix | Delete
[2240] Fix | Delete
if ( control ) {
[2241] Fix | Delete
control.focus();
[2242] Fix | Delete
}
[2243] Fix | Delete
},
[2244] Fix | Delete
[2245] Fix | Delete
/**
[2246] Fix | Delete
* Given a widget control, find the sidebar widgets control that contains it.
[2247] Fix | Delete
* @param {string} widgetId
[2248] Fix | Delete
* @return {Object|null}
[2249] Fix | Delete
*/
[2250] Fix | Delete
api.Widgets.getSidebarWidgetControlContainingWidget = function( widgetId ) {
[2251] Fix | Delete
var foundControl = null;
[2252] Fix | Delete
[2253] Fix | Delete
// @todo This can use widgetIdToSettingId(), then pass into wp.customize.control( x ).getSidebarWidgetsControl().
[2254] Fix | Delete
api.control.each( function( control ) {
[2255] Fix | Delete
if ( control.params.type === 'sidebar_widgets' && -1 !== _.indexOf( control.setting(), widgetId ) ) {
[2256] Fix | Delete
foundControl = control;
[2257] Fix | Delete
}
[2258] Fix | Delete
} );
[2259] Fix | Delete
[2260] Fix | Delete
return foundControl;
[2261] Fix | Delete
};
[2262] Fix | Delete
[2263] Fix | Delete
/**
[2264] Fix | Delete
* Given a widget ID for a widget appearing in the preview, get the widget form control associated with it.
[2265] Fix | Delete
*
[2266] Fix | Delete
* @param {string} widgetId
[2267] Fix | Delete
* @return {Object|null}
[2268] Fix | Delete
*/
[2269] Fix | Delete
api.Widgets.getWidgetFormControlForWidget = function( widgetId ) {
[2270] Fix | Delete
var foundControl = null;
[2271] Fix | Delete
[2272] Fix | Delete
// @todo We can just use widgetIdToSettingId() here.
[2273] Fix | Delete
api.control.each( function( control ) {
[2274] Fix | Delete
if ( control.params.type === 'widget_form' && control.params.widget_id === widgetId ) {
[2275] Fix | Delete
foundControl = control;
[2276] Fix | Delete
}
[2277] Fix | Delete
} );
[2278] Fix | Delete
[2279] Fix | Delete
return foundControl;
[2280] Fix | Delete
};
[2281] Fix | Delete
[2282] Fix | Delete
/**
[2283] Fix | Delete
* Initialize Edit Menu button in Nav Menu widget.
[2284] Fix | Delete
*/
[2285] Fix | Delete
$( document ).on( 'widget-added', function( event, widgetContainer ) {
[2286] Fix | Delete
var parsedWidgetId, widgetControl, navMenuSelect, editMenuButton;
[2287] Fix | Delete
parsedWidgetId = parseWidgetId( widgetContainer.find( '> .widget-inside > .form > .widget-id' ).val() );
[2288] Fix | Delete
if ( 'nav_menu' !== parsedWidgetId.id_base ) {
[2289] Fix | Delete
return;
[2290] Fix | Delete
}
[2291] Fix | Delete
widgetControl = api.control( 'widget_nav_menu[' + String( parsedWidgetId.number ) + ']' );
[2292] Fix | Delete
if ( ! widgetControl ) {
[2293] Fix | Delete
return;
[2294] Fix | Delete
}
[2295] Fix | Delete
navMenuSelect = widgetContainer.find( 'select[name*="nav_menu"]' );
[2296] Fix | Delete
editMenuButton = widgetContainer.find( '.edit-selected-nav-menu > button' );
[2297] Fix | Delete
if ( 0 === navMenuSelect.length || 0 === editMenuButton.length ) {
[2298] Fix | Delete
return;
[2299] Fix | Delete
}
[2300] Fix | Delete
navMenuSelect.on( 'change', function() {
[2301] Fix | Delete
if ( api.section.has( 'nav_menu[' + navMenuSelect.val() + ']' ) ) {
[2302] Fix | Delete
editMenuButton.parent().show();
[2303] Fix | Delete
} else {
[2304] Fix | Delete
editMenuButton.parent().hide();
[2305] Fix | Delete
}
[2306] Fix | Delete
});
[2307] Fix | Delete
editMenuButton.on( 'click', function() {
[2308] Fix | Delete
var section = api.section( 'nav_menu[' + navMenuSelect.val() + ']' );
[2309] Fix | Delete
if ( section ) {
[2310] Fix | Delete
focusConstructWithBreadcrumb( section, widgetControl );
[2311] Fix | Delete
}
[2312] Fix | Delete
} );
[2313] Fix | Delete
} );
[2314] Fix | Delete
[2315] Fix | Delete
/**
[2316] Fix | Delete
* Focus (expand) one construct and then focus on another construct after the first is collapsed.
[2317] Fix | Delete
*
[2318] Fix | Delete
* This overrides the back button to serve the purpose of breadcrumb navigation.
[2319] Fix | Delete
*
[2320] Fix | Delete
* @param {wp.customize.Section|wp.customize.Panel|wp.customize.Control} focusConstruct - The object to initially focus.
[2321] Fix | Delete
* @param {wp.customize.Section|wp.customize.Panel|wp.customize.Control} returnConstruct - The object to return focus.
[2322] Fix | Delete
*/
[2323] Fix | Delete
function focusConstructWithBreadcrumb( focusConstruct, returnConstruct ) {
[2324] Fix | Delete
focusConstruct.focus();
[2325] Fix | Delete
function onceCollapsed( isExpanded ) {
[2326] Fix | Delete
if ( ! isExpanded ) {
[2327] Fix | Delete
focusConstruct.expanded.unbind( onceCollapsed );
[2328] Fix | Delete
returnConstruct.focus();
[2329] Fix | Delete
}
[2330] Fix | Delete
}
[2331] Fix | Delete
focusConstruct.expanded.bind( onceCollapsed );
[2332] Fix | Delete
}
[2333] Fix | Delete
[2334] Fix | Delete
/**
[2335] Fix | Delete
* @param {string} widgetId
[2336] Fix | Delete
* @return {Object}
[2337] Fix | Delete
*/
[2338] Fix | Delete
function parseWidgetId( widgetId ) {
[2339] Fix | Delete
var matches, parsed = {
[2340] Fix | Delete
number: null,
[2341] Fix | Delete
id_base: null
[2342] Fix | Delete
};
[2343] Fix | Delete
[2344] Fix | Delete
matches = widgetId.match( /^(.+)-(\d+)$/ );
[2345] Fix | Delete
if ( matches ) {
[2346] Fix | Delete
parsed.id_base = matches[1];
[2347] Fix | Delete
parsed.number = parseInt( matches[2], 10 );
[2348] Fix | Delete
} else {
[2349] Fix | Delete
// Likely an old single widget.
[2350] Fix | Delete
parsed.id_base = widgetId;
[2351] Fix | Delete
}
[2352] Fix | Delete
[2353] Fix | Delete
return parsed;
[2354] Fix | Delete
}
[2355] Fix | Delete
[2356] Fix | Delete
/**
[2357] Fix | Delete
* @param {string} widgetId
[2358] Fix | Delete
* @return {string} settingId
[2359] Fix | Delete
*/
[2360] Fix | Delete
function widgetIdToSettingId( widgetId ) {
[2361] Fix | Delete
var parsed = parseWidgetId( widgetId ), settingId;
[2362] Fix | Delete
[2363] Fix | Delete
settingId = 'widget_' + parsed.id_base;
[2364] Fix | Delete
if ( parsed.number ) {
[2365] Fix | Delete
settingId += '[' + parsed.number + ']';
[2366] Fix | Delete
}
[2367] Fix | Delete
[2368] Fix | Delete
return settingId;
[2369] Fix | Delete
}
[2370] Fix | Delete
[2371] Fix | Delete
})( window.wp, jQuery );
[2372] Fix | Delete
[2373] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function