Voici un plugin wordpress qui permet d’inserer le contenu d’une page wordpress dans une zone widgetisée.
Ce plugin est basé sur le plugin de Paul Tero
Ma version permet de spécifier un Titre pour le widget
Code du fichier: wp-content/plugins/insert-a-page.php
<?php /* Plugin Name: Insert a Page Widget Plugin URI: http://cvallee.com/plugin-wordpress-insert-a-page-widget/ Description: Insert a page's contents into a sidebar. This is a substitute for a WYSIWYG or HTML editing widget. Author: Paul Tero and Christian Vallee Version: 1.1 Author URI: http://www.cvallee.com/ */ class Widget_Insert_Page extends WP_Widget { function Widget_Insert_Page() { $widget_ops = array('classname' => 'widget_insert_page', 'description' => 'Insert the contents of a page into a sidebar'); $this->WP_Widget ('insert-page', 'Insert a page', $widget_ops); } function widget( $args, $instance ) { extract( $args ); $title = apply_filters( 'widget_title', $instance['title'] ); echo $before_widget; if ( ! empty( $title ) ) echo $before_title . $title . $after_title; $pageid = empty ($instance['pageid']) ? 0 : $instance['pageid']; //From 13/2/2012 also apply filters to the inserted content. Uncomment the first line, and remove the second, if you don't want this. //if ($pageid && ($pages = get_pages ("include=$pageid"))) echo $before_widget . $pages[0]->post_content . $after_widget; if ($pageid && ($pages = get_pages ("include=$pageid"))) echo apply_filters ('the_content', $pages[0]->post_content); echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $title = $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : ''; $pageid = $instance['pageid'] = intval ($new_instance['pageid']); return $instance; } function form( $instance ) { $instance = wp_parse_args( (array) $instance, array( 'pageid' => '', 'title' => '') ); //This is filled by the title of the page, so it will appear after the widget name $title = esc_attr( $instance['title'] ); $pageid = esc_attr( $instance['pageid'] ); //Get the list of pages and turn it into a select list $pages = wp_list_pages( apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0))); //list of pages with <li> tags $pages = preg_replace ('/<li class="\D*(\d+)">/', '<option value="\\1">', $pages); $pages = preg_replace ('/value="' . $pageid . '"/', '\\0 selected="yes"', $pages); $pages = preg_replace ('/<\/li>/', '</option>', $pages); ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /> </p> <p><select class="widefat" id="<?php echo $this->get_field_id('pageid'); ?>" name="<?php echo $this->get_field_name('pageid'); ?>" onchange="this.form['<?php echo $this->get_field_name('title'); ?>'].value = this.options[this.selectedIndex].text;"> <option value="0">choose a page</option><?= $pages?> </select> <?php } function RegisterMe() {register_widget ('Widget_Insert_Page');} } //Register this widget add_action ('widgets_init', array ('Widget_Insert_Page', 'RegisterMe'));