67 '<p>' . __('When changing themes, there is often some variation in the number and setup of widget areas/sidebars and sometimes these conflicts make the transition a bit less smooth. If you changed themes and seem to be missing widgets, scroll down on this screen to the Inactive Widgets area, where all of your widgets and their settings will have been saved.') . '</p>' |
68 '<p>' . __('When changing themes, there is often some variation in the number and setup of widget areas/sidebars and sometimes these conflicts make the transition a bit less smooth. If you changed themes and seem to be missing widgets, scroll down on this screen to the Inactive Widgets area, where all of your widgets and their settings will have been saved.') . '</p>' |
68 ) ); |
69 ) ); |
69 |
70 |
70 get_current_screen()->set_help_sidebar( |
71 get_current_screen()->set_help_sidebar( |
71 '<p><strong>' . __('For more information:') . '</strong></p>' . |
72 '<p><strong>' . __('For more information:') . '</strong></p>' . |
72 '<p>' . __('<a href="http://codex.wordpress.org/Appearance_Widgets_Screen" target="_blank">Documentation on Widgets</a>') . '</p>' . |
73 '<p>' . __('<a href="https://codex.wordpress.org/Appearance_Widgets_Screen" target="_blank">Documentation on Widgets</a>') . '</p>' . |
73 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
74 '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' |
74 ); |
75 ); |
75 |
76 |
76 if ( ! current_theme_supports( 'widgets' ) ) { |
77 if ( ! current_theme_supports( 'widgets' ) ) { |
77 wp_die( __( 'The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="http://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ) ); |
78 wp_die( __( 'The theme you are currently using isn’t widget-aware, meaning that it has no sidebars that you are able to change. For information on making your theme widget-aware, please <a href="https://codex.wordpress.org/Widgetizing_Themes">follow these instructions</a>.' ) ); |
78 } |
79 } |
79 |
80 |
80 // These are the widgets grouped by sidebar |
81 // These are the widgets grouped by sidebar |
81 $sidebars_widgets = wp_get_sidebars_widgets(); |
82 $sidebars_widgets = wp_get_sidebars_widgets(); |
82 |
83 |
221 if ( !isset($multi_number) ) |
222 if ( !isset($multi_number) ) |
222 $multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : ''; |
223 $multi_number = isset($control['params'][0]['number']) ? $control['params'][0]['number'] : ''; |
223 |
224 |
224 $id_base = isset($control['id_base']) ? $control['id_base'] : $control['id']; |
225 $id_base = isset($control['id_base']) ? $control['id_base'] : $control['id']; |
225 |
226 |
226 // show the widget form |
227 // Show the widget form. |
227 $width = ' style="width:' . max($control['width'], 350) . 'px"'; |
228 $width = ' style="width:' . max($control['width'], 350) . 'px"'; |
228 $key = isset($_GET['key']) ? (int) $_GET['key'] : 0; |
229 $key = isset($_GET['key']) ? (int) $_GET['key'] : 0; |
229 |
230 |
230 require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
231 require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
231 <div class="wrap"> |
232 <div class="wrap"> |
232 <?php screen_icon(); ?> |
|
233 <h2><?php echo esc_html( $title ); ?></h2> |
233 <h2><?php echo esc_html( $title ); ?></h2> |
234 <div class="editwidget"<?php echo $width; ?>> |
234 <div class="editwidget"<?php echo $width; ?>> |
235 <h3><?php printf( __( 'Widget %s' ), $name ); ?></h3> |
235 <h3><?php printf( __( 'Widget %s' ), $name ); ?></h3> |
236 |
236 |
237 <form action="widgets.php" method="post"> |
237 <form action="widgets.php" method="post"> |
308 ); |
308 ); |
309 |
309 |
310 require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
310 require_once( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
311 |
311 |
312 <div class="wrap"> |
312 <div class="wrap"> |
313 <?php screen_icon(); ?> |
313 <h2> |
314 <h2><?php echo esc_html( $title ); ?></h2> |
314 <?php |
|
315 echo esc_html( $title ); |
|
316 if ( current_user_can( 'customize' ) ) { |
|
317 printf( |
|
318 ' <a class="add-new-h2 hide-if-no-customize" href="%1$s">%2$s</a>', |
|
319 esc_url( add_query_arg( |
|
320 array( |
|
321 array( 'autofocus' => array( 'panel' => 'widgets' ) ), |
|
322 'return' => urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ) |
|
323 ), |
|
324 admin_url( 'customize.php' ) |
|
325 ) ), |
|
326 __( 'Manage in Customizer' ) |
|
327 ); |
|
328 } |
|
329 ?> |
|
330 </h2> |
315 |
331 |
316 <?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?> |
332 <?php if ( isset($_GET['message']) && isset($messages[$_GET['message']]) ) { ?> |
317 <div id="message" class="updated"><p><?php echo $messages[$_GET['message']]; ?></p></div> |
333 <div id="message" class="updated notice is-dismissible"><p><?php echo $messages[$_GET['message']]; ?></p></div> |
318 <?php } ?> |
334 <?php } ?> |
319 <?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?> |
335 <?php if ( isset($_GET['error']) && isset($errors[$_GET['error']]) ) { ?> |
320 <div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div> |
336 <div id="message" class="error"><p><?php echo $errors[$_GET['error']]; ?></p></div> |
321 <?php } ?> |
337 <?php } ?> |
322 |
338 |
330 |
346 |
331 <div class="widget-liquid-left"> |
347 <div class="widget-liquid-left"> |
332 <div id="widgets-left"> |
348 <div id="widgets-left"> |
333 <div id="available-widgets" class="widgets-holder-wrap"> |
349 <div id="available-widgets" class="widgets-holder-wrap"> |
334 <div class="sidebar-name"> |
350 <div class="sidebar-name"> |
335 <div class="sidebar-name-arrow"><br /></div> |
351 <div class="sidebar-name-arrow"><br /></div> |
336 <h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3></div> |
352 <h3><?php _e('Available Widgets'); ?> <span id="removing-widget"><?php _ex('Deactivate', 'removing-widget'); ?> <span></span></span></h3> |
|
353 </div> |
337 <div class="widget-holder"> |
354 <div class="widget-holder"> |
338 <p class="description"><?php _e('Drag widgets from here to a sidebar on the right to activate them. Drag widgets back here to deactivate them and delete their settings.'); ?></p> |
355 <div class="sidebar-description"> |
339 <div id="widget-list"> |
356 <p class="description"><?php _e('To activate a widget drag it to a sidebar or click on it. To deactivate a widget and delete its settings, drag it back.'); ?></p> |
340 <?php wp_list_widgets(); ?> |
357 </div> |
341 </div> |
358 <div id="widget-list"> |
342 <br class='clear' /> |
359 <?php wp_list_widgets(); ?> |
|
360 </div> |
|
361 <br class='clear' /> |
343 </div> |
362 </div> |
344 <br class="clear" /> |
363 <br class="clear" /> |
345 </div> |
364 </div> |
346 |
365 |
347 <?php |
366 <?php |
|
367 |
|
368 $theme_sidebars = array(); |
348 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) { |
369 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) { |
349 if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) { |
370 if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) { |
350 $wrap_class = 'widgets-holder-wrap'; |
371 $wrap_class = 'widgets-holder-wrap'; |
351 if ( !empty( $registered_sidebar['class'] ) ) |
372 if ( !empty( $registered_sidebar['class'] ) ) |
352 $wrap_class .= ' ' . $registered_sidebar['class']; |
373 $wrap_class .= ' ' . $registered_sidebar['class']; |
353 |
374 |
354 ?> |
375 ?> |
355 |
|
356 <div class="<?php echo esc_attr( $wrap_class ); ?>"> |
376 <div class="<?php echo esc_attr( $wrap_class ); ?>"> |
357 <div class="sidebar-name"> |
|
358 <div class="sidebar-name-arrow"><br /></div> |
|
359 <h3><?php echo esc_html( $registered_sidebar['name'] ); ?> |
|
360 <span class="spinner"></span> |
|
361 </h3> |
|
362 </div> |
|
363 <div class="widget-holder inactive"> |
377 <div class="widget-holder inactive"> |
364 <?php wp_list_widget_controls( $registered_sidebar['id'] ); ?> |
378 <?php wp_list_widget_controls( $registered_sidebar['id'], $registered_sidebar['name'] ); ?> |
365 <div class="clear"></div> |
379 <div class="clear"></div> |
366 </div> |
380 </div> |
367 </div> |
381 </div> |
368 <?php |
382 <?php |
369 } |
383 |
370 } |
384 } else { |
|
385 $theme_sidebars[$sidebar] = $registered_sidebar; |
|
386 } |
|
387 } |
|
388 |
371 ?> |
389 ?> |
372 |
390 </div> |
373 </div> |
391 </div> |
374 </div> |
392 <?php |
375 |
393 |
|
394 $i = $split = 0; |
|
395 $single_sidebar_class = ''; |
|
396 $sidebars_count = count( $theme_sidebars ); |
|
397 |
|
398 if ( $sidebars_count > 1 ) { |
|
399 $split = ceil( $sidebars_count / 2 ); |
|
400 } else { |
|
401 $single_sidebar_class = ' class="single-sidebar"'; |
|
402 } |
|
403 |
|
404 ?> |
376 <div class="widget-liquid-right"> |
405 <div class="widget-liquid-right"> |
377 <div id="widgets-right"> |
406 <div id="widgets-right"<?php echo $single_sidebar_class; ?>> |
378 <?php |
407 <div class="sidebars-column-1"> |
379 $i = 0; |
408 <?php |
380 foreach ( $wp_registered_sidebars as $sidebar => $registered_sidebar ) { |
409 |
381 if ( false !== strpos( $registered_sidebar['class'], 'inactive-sidebar' ) || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) |
410 foreach ( $theme_sidebars as $sidebar => $registered_sidebar ) { |
382 continue; |
|
383 |
|
384 $wrap_class = 'widgets-holder-wrap'; |
411 $wrap_class = 'widgets-holder-wrap'; |
385 if ( !empty( $registered_sidebar['class'] ) ) |
412 if ( !empty( $registered_sidebar['class'] ) ) |
386 $wrap_class .= ' sidebar-' . $registered_sidebar['class']; |
413 $wrap_class .= ' sidebar-' . $registered_sidebar['class']; |
387 |
414 |
388 if ( $i ) |
415 if ( $i > 0 ) |
389 $wrap_class .= ' closed'; ?> |
416 $wrap_class .= ' closed'; |
390 |
417 |
|
418 if ( $split && $i == $split ) { |
|
419 ?> |
|
420 </div><div class="sidebars-column-2"> |
|
421 <?php |
|
422 } |
|
423 |
|
424 ?> |
391 <div class="<?php echo esc_attr( $wrap_class ); ?>"> |
425 <div class="<?php echo esc_attr( $wrap_class ); ?>"> |
392 <div class="sidebar-name"> |
426 <?php wp_list_widget_controls( $sidebar, $registered_sidebar['name'] ); // Show the control forms for each of the widgets in this sidebar ?> |
393 <div class="sidebar-name-arrow"><br /></div> |
427 </div> |
394 <h3><?php echo esc_html( $registered_sidebar['name'] ); ?> |
428 <?php |
395 <span class="spinner"></span></h3></div> |
429 |
396 <?php wp_list_widget_controls( $sidebar ); // Show the control forms for each of the widgets in this sidebar ?> |
|
397 </div> |
|
398 <?php |
|
399 $i++; |
430 $i++; |
400 } ?> |
431 } |
401 </div> |
432 |
402 </div> |
433 ?> |
403 <form action="" method="post"> |
434 </div> |
|
435 </div> |
|
436 </div> |
|
437 <form method="post"> |
404 <?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?> |
438 <?php wp_nonce_field( 'save-sidebar-widgets', '_wpnonce_widgets', false ); ?> |
405 </form> |
439 </form> |
406 <br class="clear" /> |
440 <br class="clear" /> |
|
441 </div> |
|
442 |
|
443 <div class="widgets-chooser"> |
|
444 <ul class="widgets-chooser-sidebars"></ul> |
|
445 <div class="widgets-chooser-actions"> |
|
446 <button class="button-secondary"><?php _e( 'Cancel' ); ?></button> |
|
447 <button class="button-primary"><?php _e( 'Add Widget' ); ?></button> |
|
448 </div> |
407 </div> |
449 </div> |
408 |
450 |
409 <?php |
451 <?php |
410 |
452 |
411 /** |
453 /** |