Changeset 684513
- Timestamp:
- 03/20/2013 12:53:56 AM (13 years ago)
- Location:
- child-page-navigation
- Files:
-
- 3 added
- 10 edited
- 4 copied
-
tags/1.1.1/trunk (copied) (copied from child-page-navigation/trunk)
-
tags/1.1.1/trunk/child-page-navigation.php (modified) (2 diffs)
-
tags/1.1.1/trunk/readme.txt (modified) (2 diffs)
-
tags/1.2.1/trunk (copied) (copied from child-page-navigation/trunk)
-
tags/1.2.1/trunk/child-page-navigation.php (modified) (2 diffs)
-
tags/1.2.1/trunk/readme.txt (modified) (2 diffs)
-
tags/1.2/trunk (copied) (copied from child-page-navigation/trunk)
-
tags/1.2/trunk/child-page-navigation.php (modified) (2 diffs)
-
tags/1.2/trunk/readme.txt (modified) (2 diffs)
-
tags/1.3 (added)
-
tags/1.3/child-page-navigation.php (added)
-
tags/1.3/readme.txt (added)
-
tags/trunk (copied) (copied from child-page-navigation/trunk)
-
tags/trunk/child-page-navigation.php (modified) (2 diffs)
-
tags/trunk/readme.txt (modified) (2 diffs)
-
trunk/child-page-navigation.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
child-page-navigation/tags/1.1.1/trunk/child-page-navigation.php
r564328 r684513 6 6 Author: ITS Alaska 7 7 Author URI: http://ITSCanFixThat.com/ 8 Version: 1.2. 18 Version: 1.2.2 9 9 10 10 This program is free software: you can redistribute it and/or modify … … 22 22 */ 23 23 24 class theme_navigation extends WP_Widget { 25 function theme_navigation() { 26 parent::WP_Widget('theme_navigation', 'Child Page Navigation', array('description' => '', 'class' => 'theme-navigation')); 27 } 28 function form($instance) { 29 $default = array( 'title' => __('Navigation') ); 30 $instance = wp_parse_args( (array) $instance, $default ); 31 $field_id = $this->get_field_id('title'); 32 $field_name = $this->get_field_name('title'); 33 echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['title'] ).'" /><label></p>'; 34 $field_id = $this->get_field_id('page'); 35 } 36 function update($new_instance, $old_instance) { 37 $instance = $old_instance; 38 $instance['title'] = strip_tags($new_instance['title']); 39 return $instance; 40 } 41 function widget($args, $instance) { 42 extract($args, EXTR_SKIP); 43 global $post; 44 $pages = get_pages(array( 45 'child_of' => $post->ID, 46 'parent' => $post->ID, 47 'sort_column' => 'menu_order' 48 )); 49 50 // Check if the current page has a parent 51 if ($post -> post_parent) { 52 // Get sibling pages 53 $siblings = get_pages(array( 54 'child_of' => $post -> post_parent, 55 'parent' => $post -> post_parent, 56 'sort_column' => 'menu_order' 57 )); 58 } 59 60 if(count($pages)){ 61 echo $before_widget; 62 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 63 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 64 echo "<ul>"; 65 foreach($pages as $page){ 66 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 67 } 68 echo "</ul>"; 69 echo $after_widget; 70 }elseif($post -> post_parent) { // Show the sibling pages if there are no children 71 if(count($siblings)) { 72 echo $before_widget; 73 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 74 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 75 echo "<ul>"; 76 foreach($siblings as $page){ 77 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 78 } 79 echo "</ul>"; 80 echo $after_widget; 81 } 82 } 83 } 84 } 85 function register_theme_navigation_widget(){ 86 register_widget('theme_navigation'); 87 } 88 add_action('widgets_init','register_theme_navigation_widget'); 24 class theme_navigation extends WP_Widget { 25 public function __construct() { 26 parent::__construct( 27 'theme_navigation', // Base ID 28 'Child Page Navigation', // Name 29 array('description' => '') // Args 30 ); 31 } 89 32 90 ?> 33 function form(){ 34 $opts = get_option('widget_theme_navigation'); 35 ?> 36 <p>Title: <input name="cpn_title" id="cpn_title" type="text" <?php if(isset($opts[2]['title']) && $opts[2]['title'] != "") echo 'value="'.$opts[2]['title'].'"'; ?> /></p> 37 <p>Sort by Sort Order? <input name="cpn_sort" id="cpn_sort" type="checkbox" <?php if(isset($opts[2]['sort']) && $opts[2]['sort']) echo 'checked="checked"'; ?> value="1" /></p> 38 <?php } 39 40 function update(){ 41 if(!isset($_POST['cpn_sort'])) 42 $_POST['cpn_sort'] = 0; 43 44 foreach($_POST as $field => $val){ 45 if(substr($field,0,4) != "cpn_") 46 continue; 47 48 $opts[substr($field,4)] = attribute_escape($_POST[$field]); 49 unset($_POST[$field]); 50 } 51 52 return $opts; 53 } 54 55 function widget($args){ 56 global $post; 57 $opts = get_option('widget_theme_navigation'); 58 59 $page_arr = array('child_of' => $post->ID, 'parent' => $post->ID); 60 61 if($opts[2]['sort']) 62 $page_arr['sort_column'] = 'menu_order'; 63 64 $pages = get_pages($page_arr); 65 66 if($post->post_parent && !count($pages)) 67 $page_arr['child_of'] = $page_arr['parent'] = $post->post_parent; 68 $pages = get_pages($page_arr); 69 70 if(!count($pages)) 71 return; 72 73 echo $args['before_widget']; 74 75 if(isset($opts[2]['title']) && $opts[2]['title'] != "") 76 echo $args['before_title'].$opts[2]['title'].$args['after_title']; 77 78 echo "<ul>"; 79 80 foreach($pages as $page){ 81 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 82 } 83 84 echo "</ul>".$args['after_widget']; 85 } 86 } 87 88 add_action( 'widgets_init', create_function( '', 'register_widget( "theme_navigation" );' ) ); -
child-page-navigation/tags/1.1.1/trunk/readme.txt
r564328 r684513 1 1 === Child Page Navigation === 2 2 Contributors: itsalaska 3 Tags: child, page, widget, navigation 3 Tags: child, page, widget, navigation, nav, children, sub 4 4 Requires at least: 2.0.2 5 Tested up to: 3. 45 Tested up to: 3.5.1 6 6 License: GPLv3 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 16 16 17 17 1. Upload `child-page-navigation.zip` to the `/wp-content/plugins/` directory 18 1. Activate the plugin through the `Plugins` menu in WordPress19 1. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress18 2. Activate the plugin through the `Plugins` menu in WordPress 19 3. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress 20 20 21 21 == Changelog == 22 23 = 1.3 = 24 * Added option in widget to sort by page sort order 25 * Recoded ~ File size went from 4,152 byts to 2,893 bytes 22 26 23 27 = 1.2.1 = -
child-page-navigation/tags/1.2.1/trunk/child-page-navigation.php
r564328 r684513 6 6 Author: ITS Alaska 7 7 Author URI: http://ITSCanFixThat.com/ 8 Version: 1.2. 18 Version: 1.2.2 9 9 10 10 This program is free software: you can redistribute it and/or modify … … 22 22 */ 23 23 24 class theme_navigation extends WP_Widget { 25 function theme_navigation() { 26 parent::WP_Widget('theme_navigation', 'Child Page Navigation', array('description' => '', 'class' => 'theme-navigation')); 27 } 28 function form($instance) { 29 $default = array( 'title' => __('Navigation') ); 30 $instance = wp_parse_args( (array) $instance, $default ); 31 $field_id = $this->get_field_id('title'); 32 $field_name = $this->get_field_name('title'); 33 echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['title'] ).'" /><label></p>'; 34 $field_id = $this->get_field_id('page'); 35 } 36 function update($new_instance, $old_instance) { 37 $instance = $old_instance; 38 $instance['title'] = strip_tags($new_instance['title']); 39 return $instance; 40 } 41 function widget($args, $instance) { 42 extract($args, EXTR_SKIP); 43 global $post; 44 $pages = get_pages(array( 45 'child_of' => $post->ID, 46 'parent' => $post->ID, 47 'sort_column' => 'menu_order' 48 )); 49 50 // Check if the current page has a parent 51 if ($post -> post_parent) { 52 // Get sibling pages 53 $siblings = get_pages(array( 54 'child_of' => $post -> post_parent, 55 'parent' => $post -> post_parent, 56 'sort_column' => 'menu_order' 57 )); 58 } 59 60 if(count($pages)){ 61 echo $before_widget; 62 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 63 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 64 echo "<ul>"; 65 foreach($pages as $page){ 66 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 67 } 68 echo "</ul>"; 69 echo $after_widget; 70 }elseif($post -> post_parent) { // Show the sibling pages if there are no children 71 if(count($siblings)) { 72 echo $before_widget; 73 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 74 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 75 echo "<ul>"; 76 foreach($siblings as $page){ 77 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 78 } 79 echo "</ul>"; 80 echo $after_widget; 81 } 82 } 83 } 84 } 85 function register_theme_navigation_widget(){ 86 register_widget('theme_navigation'); 87 } 88 add_action('widgets_init','register_theme_navigation_widget'); 24 class theme_navigation extends WP_Widget { 25 public function __construct() { 26 parent::__construct( 27 'theme_navigation', // Base ID 28 'Child Page Navigation', // Name 29 array('description' => '') // Args 30 ); 31 } 89 32 90 ?> 33 function form(){ 34 $opts = get_option('widget_theme_navigation'); 35 ?> 36 <p>Title: <input name="cpn_title" id="cpn_title" type="text" <?php if(isset($opts[2]['title']) && $opts[2]['title'] != "") echo 'value="'.$opts[2]['title'].'"'; ?> /></p> 37 <p>Sort by Sort Order? <input name="cpn_sort" id="cpn_sort" type="checkbox" <?php if(isset($opts[2]['sort']) && $opts[2]['sort']) echo 'checked="checked"'; ?> value="1" /></p> 38 <?php } 39 40 function update(){ 41 if(!isset($_POST['cpn_sort'])) 42 $_POST['cpn_sort'] = 0; 43 44 foreach($_POST as $field => $val){ 45 if(substr($field,0,4) != "cpn_") 46 continue; 47 48 $opts[substr($field,4)] = attribute_escape($_POST[$field]); 49 unset($_POST[$field]); 50 } 51 52 return $opts; 53 } 54 55 function widget($args){ 56 global $post; 57 $opts = get_option('widget_theme_navigation'); 58 59 $page_arr = array('child_of' => $post->ID, 'parent' => $post->ID); 60 61 if($opts[2]['sort']) 62 $page_arr['sort_column'] = 'menu_order'; 63 64 $pages = get_pages($page_arr); 65 66 if($post->post_parent && !count($pages)) 67 $page_arr['child_of'] = $page_arr['parent'] = $post->post_parent; 68 $pages = get_pages($page_arr); 69 70 if(!count($pages)) 71 return; 72 73 echo $args['before_widget']; 74 75 if(isset($opts[2]['title']) && $opts[2]['title'] != "") 76 echo $args['before_title'].$opts[2]['title'].$args['after_title']; 77 78 echo "<ul>"; 79 80 foreach($pages as $page){ 81 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 82 } 83 84 echo "</ul>".$args['after_widget']; 85 } 86 } 87 88 add_action( 'widgets_init', create_function( '', 'register_widget( "theme_navigation" );' ) ); -
child-page-navigation/tags/1.2.1/trunk/readme.txt
r564328 r684513 1 1 === Child Page Navigation === 2 2 Contributors: itsalaska 3 Tags: child, page, widget, navigation 3 Tags: child, page, widget, navigation, nav, children, sub 4 4 Requires at least: 2.0.2 5 Tested up to: 3. 45 Tested up to: 3.5.1 6 6 License: GPLv3 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 16 16 17 17 1. Upload `child-page-navigation.zip` to the `/wp-content/plugins/` directory 18 1. Activate the plugin through the `Plugins` menu in WordPress19 1. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress18 2. Activate the plugin through the `Plugins` menu in WordPress 19 3. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress 20 20 21 21 == Changelog == 22 23 = 1.3 = 24 * Added option in widget to sort by page sort order 25 * Recoded ~ File size went from 4,152 byts to 2,893 bytes 22 26 23 27 = 1.2.1 = -
child-page-navigation/tags/1.2/trunk/child-page-navigation.php
r564328 r684513 6 6 Author: ITS Alaska 7 7 Author URI: http://ITSCanFixThat.com/ 8 Version: 1.2. 18 Version: 1.2.2 9 9 10 10 This program is free software: you can redistribute it and/or modify … … 22 22 */ 23 23 24 class theme_navigation extends WP_Widget { 25 function theme_navigation() { 26 parent::WP_Widget('theme_navigation', 'Child Page Navigation', array('description' => '', 'class' => 'theme-navigation')); 27 } 28 function form($instance) { 29 $default = array( 'title' => __('Navigation') ); 30 $instance = wp_parse_args( (array) $instance, $default ); 31 $field_id = $this->get_field_id('title'); 32 $field_name = $this->get_field_name('title'); 33 echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['title'] ).'" /><label></p>'; 34 $field_id = $this->get_field_id('page'); 35 } 36 function update($new_instance, $old_instance) { 37 $instance = $old_instance; 38 $instance['title'] = strip_tags($new_instance['title']); 39 return $instance; 40 } 41 function widget($args, $instance) { 42 extract($args, EXTR_SKIP); 43 global $post; 44 $pages = get_pages(array( 45 'child_of' => $post->ID, 46 'parent' => $post->ID, 47 'sort_column' => 'menu_order' 48 )); 49 50 // Check if the current page has a parent 51 if ($post -> post_parent) { 52 // Get sibling pages 53 $siblings = get_pages(array( 54 'child_of' => $post -> post_parent, 55 'parent' => $post -> post_parent, 56 'sort_column' => 'menu_order' 57 )); 58 } 59 60 if(count($pages)){ 61 echo $before_widget; 62 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 63 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 64 echo "<ul>"; 65 foreach($pages as $page){ 66 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 67 } 68 echo "</ul>"; 69 echo $after_widget; 70 }elseif($post -> post_parent) { // Show the sibling pages if there are no children 71 if(count($siblings)) { 72 echo $before_widget; 73 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 74 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 75 echo "<ul>"; 76 foreach($siblings as $page){ 77 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 78 } 79 echo "</ul>"; 80 echo $after_widget; 81 } 82 } 83 } 84 } 85 function register_theme_navigation_widget(){ 86 register_widget('theme_navigation'); 87 } 88 add_action('widgets_init','register_theme_navigation_widget'); 24 class theme_navigation extends WP_Widget { 25 public function __construct() { 26 parent::__construct( 27 'theme_navigation', // Base ID 28 'Child Page Navigation', // Name 29 array('description' => '') // Args 30 ); 31 } 89 32 90 ?> 33 function form(){ 34 $opts = get_option('widget_theme_navigation'); 35 ?> 36 <p>Title: <input name="cpn_title" id="cpn_title" type="text" <?php if(isset($opts[2]['title']) && $opts[2]['title'] != "") echo 'value="'.$opts[2]['title'].'"'; ?> /></p> 37 <p>Sort by Sort Order? <input name="cpn_sort" id="cpn_sort" type="checkbox" <?php if(isset($opts[2]['sort']) && $opts[2]['sort']) echo 'checked="checked"'; ?> value="1" /></p> 38 <?php } 39 40 function update(){ 41 if(!isset($_POST['cpn_sort'])) 42 $_POST['cpn_sort'] = 0; 43 44 foreach($_POST as $field => $val){ 45 if(substr($field,0,4) != "cpn_") 46 continue; 47 48 $opts[substr($field,4)] = attribute_escape($_POST[$field]); 49 unset($_POST[$field]); 50 } 51 52 return $opts; 53 } 54 55 function widget($args){ 56 global $post; 57 $opts = get_option('widget_theme_navigation'); 58 59 $page_arr = array('child_of' => $post->ID, 'parent' => $post->ID); 60 61 if($opts[2]['sort']) 62 $page_arr['sort_column'] = 'menu_order'; 63 64 $pages = get_pages($page_arr); 65 66 if($post->post_parent && !count($pages)) 67 $page_arr['child_of'] = $page_arr['parent'] = $post->post_parent; 68 $pages = get_pages($page_arr); 69 70 if(!count($pages)) 71 return; 72 73 echo $args['before_widget']; 74 75 if(isset($opts[2]['title']) && $opts[2]['title'] != "") 76 echo $args['before_title'].$opts[2]['title'].$args['after_title']; 77 78 echo "<ul>"; 79 80 foreach($pages as $page){ 81 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 82 } 83 84 echo "</ul>".$args['after_widget']; 85 } 86 } 87 88 add_action( 'widgets_init', create_function( '', 'register_widget( "theme_navigation" );' ) ); -
child-page-navigation/tags/1.2/trunk/readme.txt
r564328 r684513 1 1 === Child Page Navigation === 2 2 Contributors: itsalaska 3 Tags: child, page, widget, navigation 3 Tags: child, page, widget, navigation, nav, children, sub 4 4 Requires at least: 2.0.2 5 Tested up to: 3. 45 Tested up to: 3.5.1 6 6 License: GPLv3 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 16 16 17 17 1. Upload `child-page-navigation.zip` to the `/wp-content/plugins/` directory 18 1. Activate the plugin through the `Plugins` menu in WordPress19 1. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress18 2. Activate the plugin through the `Plugins` menu in WordPress 19 3. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress 20 20 21 21 == Changelog == 22 23 = 1.3 = 24 * Added option in widget to sort by page sort order 25 * Recoded ~ File size went from 4,152 byts to 2,893 bytes 22 26 23 27 = 1.2.1 = -
child-page-navigation/tags/trunk/child-page-navigation.php
r564328 r684513 6 6 Author: ITS Alaska 7 7 Author URI: http://ITSCanFixThat.com/ 8 Version: 1.2. 18 Version: 1.2.2 9 9 10 10 This program is free software: you can redistribute it and/or modify … … 22 22 */ 23 23 24 class theme_navigation extends WP_Widget { 25 function theme_navigation() { 26 parent::WP_Widget('theme_navigation', 'Child Page Navigation', array('description' => '', 'class' => 'theme-navigation')); 27 } 28 function form($instance) { 29 $default = array( 'title' => __('Navigation') ); 30 $instance = wp_parse_args( (array) $instance, $default ); 31 $field_id = $this->get_field_id('title'); 32 $field_name = $this->get_field_name('title'); 33 echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['title'] ).'" /><label></p>'; 34 $field_id = $this->get_field_id('page'); 35 } 36 function update($new_instance, $old_instance) { 37 $instance = $old_instance; 38 $instance['title'] = strip_tags($new_instance['title']); 39 return $instance; 40 } 41 function widget($args, $instance) { 42 extract($args, EXTR_SKIP); 43 global $post; 44 $pages = get_pages(array( 45 'child_of' => $post->ID, 46 'parent' => $post->ID, 47 'sort_column' => 'menu_order' 48 )); 49 50 // Check if the current page has a parent 51 if ($post -> post_parent) { 52 // Get sibling pages 53 $siblings = get_pages(array( 54 'child_of' => $post -> post_parent, 55 'parent' => $post -> post_parent, 56 'sort_column' => 'menu_order' 57 )); 58 } 59 60 if(count($pages)){ 61 echo $before_widget; 62 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 63 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 64 echo "<ul>"; 65 foreach($pages as $page){ 66 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 67 } 68 echo "</ul>"; 69 echo $after_widget; 70 }elseif($post -> post_parent) { // Show the sibling pages if there are no children 71 if(count($siblings)) { 72 echo $before_widget; 73 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 74 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 75 echo "<ul>"; 76 foreach($siblings as $page){ 77 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 78 } 79 echo "</ul>"; 80 echo $after_widget; 81 } 82 } 83 } 84 } 85 function register_theme_navigation_widget(){ 86 register_widget('theme_navigation'); 87 } 88 add_action('widgets_init','register_theme_navigation_widget'); 24 class theme_navigation extends WP_Widget { 25 public function __construct() { 26 parent::__construct( 27 'theme_navigation', // Base ID 28 'Child Page Navigation', // Name 29 array('description' => '') // Args 30 ); 31 } 89 32 90 ?> 33 function form(){ 34 $opts = get_option('widget_theme_navigation'); 35 ?> 36 <p>Title: <input name="cpn_title" id="cpn_title" type="text" <?php if(isset($opts[2]['title']) && $opts[2]['title'] != "") echo 'value="'.$opts[2]['title'].'"'; ?> /></p> 37 <p>Sort by Sort Order? <input name="cpn_sort" id="cpn_sort" type="checkbox" <?php if(isset($opts[2]['sort']) && $opts[2]['sort']) echo 'checked="checked"'; ?> value="1" /></p> 38 <?php } 39 40 function update(){ 41 if(!isset($_POST['cpn_sort'])) 42 $_POST['cpn_sort'] = 0; 43 44 foreach($_POST as $field => $val){ 45 if(substr($field,0,4) != "cpn_") 46 continue; 47 48 $opts[substr($field,4)] = attribute_escape($_POST[$field]); 49 unset($_POST[$field]); 50 } 51 52 return $opts; 53 } 54 55 function widget($args){ 56 global $post; 57 $opts = get_option('widget_theme_navigation'); 58 59 $page_arr = array('child_of' => $post->ID, 'parent' => $post->ID); 60 61 if($opts[2]['sort']) 62 $page_arr['sort_column'] = 'menu_order'; 63 64 $pages = get_pages($page_arr); 65 66 if($post->post_parent && !count($pages)) 67 $page_arr['child_of'] = $page_arr['parent'] = $post->post_parent; 68 $pages = get_pages($page_arr); 69 70 if(!count($pages)) 71 return; 72 73 echo $args['before_widget']; 74 75 if(isset($opts[2]['title']) && $opts[2]['title'] != "") 76 echo $args['before_title'].$opts[2]['title'].$args['after_title']; 77 78 echo "<ul>"; 79 80 foreach($pages as $page){ 81 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 82 } 83 84 echo "</ul>".$args['after_widget']; 85 } 86 } 87 88 add_action( 'widgets_init', create_function( '', 'register_widget( "theme_navigation" );' ) ); -
child-page-navigation/tags/trunk/readme.txt
r564328 r684513 1 1 === Child Page Navigation === 2 2 Contributors: itsalaska 3 Tags: child, page, widget, navigation 3 Tags: child, page, widget, navigation, nav, children, sub 4 4 Requires at least: 2.0.2 5 Tested up to: 3. 45 Tested up to: 3.5.1 6 6 License: GPLv3 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 16 16 17 17 1. Upload `child-page-navigation.zip` to the `/wp-content/plugins/` directory 18 1. Activate the plugin through the `Plugins` menu in WordPress19 1. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress18 2. Activate the plugin through the `Plugins` menu in WordPress 19 3. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress 20 20 21 21 == Changelog == 22 23 = 1.3 = 24 * Added option in widget to sort by page sort order 25 * Recoded ~ File size went from 4,152 byts to 2,893 bytes 22 26 23 27 = 1.2.1 = -
child-page-navigation/trunk/child-page-navigation.php
r564328 r684513 6 6 Author: ITS Alaska 7 7 Author URI: http://ITSCanFixThat.com/ 8 Version: 1.2. 18 Version: 1.2.2 9 9 10 10 This program is free software: you can redistribute it and/or modify … … 22 22 */ 23 23 24 class theme_navigation extends WP_Widget { 25 function theme_navigation() { 26 parent::WP_Widget('theme_navigation', 'Child Page Navigation', array('description' => '', 'class' => 'theme-navigation')); 27 } 28 function form($instance) { 29 $default = array( 'title' => __('Navigation') ); 30 $instance = wp_parse_args( (array) $instance, $default ); 31 $field_id = $this->get_field_id('title'); 32 $field_name = $this->get_field_name('title'); 33 echo "\r\n".'<p><label for="'.$field_id.'">'.__('Title').': <input type="text" class="widefat" id="'.$field_id.'" name="'.$field_name.'" value="'.attribute_escape( $instance['title'] ).'" /><label></p>'; 34 $field_id = $this->get_field_id('page'); 35 } 36 function update($new_instance, $old_instance) { 37 $instance = $old_instance; 38 $instance['title'] = strip_tags($new_instance['title']); 39 return $instance; 40 } 41 function widget($args, $instance) { 42 extract($args, EXTR_SKIP); 43 global $post; 44 $pages = get_pages(array( 45 'child_of' => $post->ID, 46 'parent' => $post->ID, 47 'sort_column' => 'menu_order' 48 )); 49 50 // Check if the current page has a parent 51 if ($post -> post_parent) { 52 // Get sibling pages 53 $siblings = get_pages(array( 54 'child_of' => $post -> post_parent, 55 'parent' => $post -> post_parent, 56 'sort_column' => 'menu_order' 57 )); 58 } 59 60 if(count($pages)){ 61 echo $before_widget; 62 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 63 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 64 echo "<ul>"; 65 foreach($pages as $page){ 66 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 67 } 68 echo "</ul>"; 69 echo $after_widget; 70 }elseif($post -> post_parent) { // Show the sibling pages if there are no children 71 if(count($siblings)) { 72 echo $before_widget; 73 $title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']); 74 if ( !empty( $title ) ) { echo $before_title . $title . $after_title; } 75 echo "<ul>"; 76 foreach($siblings as $page){ 77 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 78 } 79 echo "</ul>"; 80 echo $after_widget; 81 } 82 } 83 } 84 } 85 function register_theme_navigation_widget(){ 86 register_widget('theme_navigation'); 87 } 88 add_action('widgets_init','register_theme_navigation_widget'); 24 class theme_navigation extends WP_Widget { 25 public function __construct() { 26 parent::__construct( 27 'theme_navigation', // Base ID 28 'Child Page Navigation', // Name 29 array('description' => '') // Args 30 ); 31 } 89 32 90 ?> 33 function form(){ 34 $opts = get_option('widget_theme_navigation'); 35 ?> 36 <p>Title: <input name="cpn_title" id="cpn_title" type="text" <?php if(isset($opts[2]['title']) && $opts[2]['title'] != "") echo 'value="'.$opts[2]['title'].'"'; ?> /></p> 37 <p>Sort by Sort Order? <input name="cpn_sort" id="cpn_sort" type="checkbox" <?php if(isset($opts[2]['sort']) && $opts[2]['sort']) echo 'checked="checked"'; ?> value="1" /></p> 38 <?php } 39 40 function update(){ 41 if(!isset($_POST['cpn_sort'])) 42 $_POST['cpn_sort'] = 0; 43 44 foreach($_POST as $field => $val){ 45 if(substr($field,0,4) != "cpn_") 46 continue; 47 48 $opts[substr($field,4)] = attribute_escape($_POST[$field]); 49 unset($_POST[$field]); 50 } 51 52 return $opts; 53 } 54 55 function widget($args){ 56 global $post; 57 $opts = get_option('widget_theme_navigation'); 58 59 $page_arr = array('child_of' => $post->ID, 'parent' => $post->ID); 60 61 if($opts[2]['sort']) 62 $page_arr['sort_column'] = 'menu_order'; 63 64 $pages = get_pages($page_arr); 65 66 if($post->post_parent && !count($pages)) 67 $page_arr['child_of'] = $page_arr['parent'] = $post->post_parent; 68 $pages = get_pages($page_arr); 69 70 if(!count($pages)) 71 return; 72 73 echo $args['before_widget']; 74 75 if(isset($opts[2]['title']) && $opts[2]['title'] != "") 76 echo $args['before_title'].$opts[2]['title'].$args['after_title']; 77 78 echo "<ul>"; 79 80 foreach($pages as $page){ 81 echo "<li><a href='".get_permalink($page->ID)."'>".get_the_title($page->ID)."</a></li>"; 82 } 83 84 echo "</ul>".$args['after_widget']; 85 } 86 } 87 88 add_action( 'widgets_init', create_function( '', 'register_widget( "theme_navigation" );' ) ); -
child-page-navigation/trunk/readme.txt
r564328 r684513 1 1 === Child Page Navigation === 2 2 Contributors: itsalaska 3 Tags: child, page, widget, navigation 3 Tags: child, page, widget, navigation, nav, children, sub 4 4 Requires at least: 2.0.2 5 Tested up to: 3. 45 Tested up to: 3.5.1 6 6 License: GPLv3 or later 7 7 License URI: http://www.gnu.org/licenses/gpl-3.0.txt … … 16 16 17 17 1. Upload `child-page-navigation.zip` to the `/wp-content/plugins/` directory 18 1. Activate the plugin through the `Plugins` menu in WordPress19 1. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress18 2. Activate the plugin through the `Plugins` menu in WordPress 19 3. Add the widget to your sidebar through the `Appearance -> Widgets` menu in WordPress 20 20 21 21 == Changelog == 22 23 = 1.3 = 24 * Added option in widget to sort by page sort order 25 * Recoded ~ File size went from 4,152 byts to 2,893 bytes 22 26 23 27 = 1.2.1 =
Note: See TracChangeset
for help on using the changeset viewer.