title = __("Fancy Widgets","dagsopt"); $this->pluginname = $ns->pluginname; $this->file = $ns->file; $this->ns = $ns; } function start() { if(get_option($this->pluginname."_widgets") == "on"){ add_action( 'widgets_init', create_function('', 'return register_widget("DisplayPageWidget");' )); add_action( 'widgets_init', create_function('', 'return register_widget("dags_subpageswidget");' )); add_action( 'widgets_init', create_function('', 'return register_widget("DisplayPageChildrenWidget");' )); } } function help(){ ?>
Display Page Widget
Subpages Widget
dagsopt['plug_widgets'] = $plug_widgets; } class DisplayPageChildrenWidget extends WP_Widget { function DisplayPageChildrenWidget() { $widget_ops = array('classname' => 'DisplayPageChildrenWidget', 'description' => 'Show Page Children Widget' ); $this->WP_Widget('DisplayPageChildrenWidget', 'Page Children Widget', $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '','page_id'=>'' ) ); $title = $instance['title']; $pageid = $instance['page_id']; ?>

0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => $instance['page_id'], 'exclude' => '', 'include' => '', 'title_li' => '', 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '', 'walker' => '', 'post_type' => 'page', 'post_status' => 'publish' ); wp_list_pages( $args ); /* query_posts('post_type=page&post_parent='.$instance['page_id'].'&orderby=menu_order&order=ASC'); if (have_posts()) : while (have_posts()) : the_post(); echo "
  • ".get_the_title(); echo "
  • "; endwhile; endif; wp_reset_query(); */ echo $after_widget; } } class DisplayPageWidget extends WP_Widget { function DisplayPageWidget() { $widget_ops = array('classname' => 'DisplayPageWidget', 'description' => 'Show Page as Widget' ); $this->WP_Widget('DisplayPageWidget', 'Display Page Widget', $widget_ops); } function form($instance) { $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'page_id'=>'' ) ); $title = $instance['title']; $pageid = $instance['page_id']; ?>

    '); echo apply_filters('the_content',$page->post_content); echo(''); echo $after_widget; } } class dags_subpageswidget extends WP_Widget { public function __construct() { parent::__construct( 'dags_subpageswidget', // Base ID 'DAGS_subpageswidget', // Name array( 'description' => __( 'Widget which shows child pages', 'dagsopt' ), ) // Args ); } public function widget( $args, $instance ) { $child_of = 0 ; if ( is_page() ) $child_of = get_the_ID() ; $childs = array( 'title_li' => '', 'child_of' => $child_of, 'depth' => 1, 'echo' => 0, 'exclude' => $instance['exclude'] ) ; $brothers = array_merge( $childs, array( 'child_of' => $GLOBALS['post']->post_parent ) ) ; $wp_list_pages = wp_list_pages($childs); $page = $child_of; $parent = $GLOBALS['post']->post_parent; $grandparent = get_post( $parent)->post_parent; if($grandparent === 0){ }else{ $wp_list_pages = wp_list_pages($brothers); } extract( $args ); $title = apply_filters( 'widget_title', $instance['title'] ); echo $before_widget; if ( ! empty( $title ) ) echo $before_title . $title . $after_title; echo $wp_list_pages. $after_widget; } public function update( $new_instance, $old_instance ) { $instance = array(); $instance['title'] = strip_tags( $new_instance['title'] ); $instance['exclude'] = implode( ',', array_unique( array_filter( array_map( 'trim', preg_split( '/(\s)*,(\s)*/', $new_instance['exclude'] ) ), 'is_numeric' ) ) ) ; return $instance; } public function form( $instance ) { $title = '' ; if ( isset( $instance[ 'title' ] ) ) $title = $instance[ 'title' ]; $exclude = '' ; if ( isset( $instance[ 'exclude' ] ) ) $exclude = $instance[ 'exclude' ]; $exclude_id = $this->get_field_id( 'exclude' ) ; $select_name = $this->get_field_id( 'page_id' ) ; ?>


    __('-- select --', 'dagsopt'), 'name' => $select_name ) ) ; ?>