Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * List JNews Widget Items
- */
- add_action(
- 'plugins_loaded',
- function() {
- if ( isset( $_GET['page'] ) && 'widget-importer-exporter' === $_GET['page'] ) {
- add_filter( 'jnews_load_register_widget', '__return_true' );
- }
- },
- 1
- );
- /**
- * Import JNews Widget Areas
- */
- add_filter(
- 'wie_import_data',
- function( $value ) {
- $new_widget_area = array_keys( get_object_vars( $value ) );
- $widget_area_key = 'jnews-widget-list';
- $current_location = get_option( $widget_area_key );
- if ( is_array( $current_location ) ) {
- $new_location = array_merge( $current_location, $new_widget_area );
- } else {
- $new_location = $new_widget_area;
- }
- foreach ( $new_location as $widget ) {
- register_sidebar(
- array(
- 'id' => sanitize_title( $widget ),
- 'name' => $widget,
- 'before_widget' => '<div class="widget %2$s" id="%1$s">',
- 'before_title' => '',
- 'after_title' => '',
- 'after_widget' => '</div>',
- )
- );
- }
- update_option( $widget_area_key, $new_location );
- return $value;
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement