-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented widgets, fixed handling of namespaced internal links, bum…
…ped version number
- Loading branch information
Showing
8 changed files
with
134 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
class WikiDashboardWidget { | ||
function WikiDashboardWidget() { | ||
$this->WikiHelper = new WikiHelpers(); | ||
} | ||
|
||
function dashboard_widget_function() { | ||
global $wpdb; | ||
$posts = $wpdb->get_results($wpdb->prepare("select * from $wpdb->posts where ID in ( | ||
select post_id from $wpdb->postmeta where | ||
meta_key = 'wiki_page' and meta_value = 1) | ||
or post_type in ('wiki') order by post_modified desc limit 5")); | ||
include(WPWIKI_FILE_PATH.'/views/dashboard_widget.php'); | ||
} | ||
|
||
function dashboard_widget_hook() { | ||
wp_add_dashboard_widget( | ||
'wpw_dashboard_widget', | ||
'Recent contributions to Wiki', | ||
array($this,'dashboard_widget_function') | ||
); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
class WikiUserContribWidget extends WP_Widget { | ||
|
||
function WikiUserContribWidget() { | ||
$widget_ops = array( | ||
'classname' => 'widget_my_contributions', | ||
'description' => __( "My Contributions widget for WordPress Wiki Plugin") | ||
); | ||
$this->WP_Widget('wiki_user_contrib', 'Wiki User Contributions', $widget_ops); | ||
$this->WikiHelper = new WikiHelpers(); | ||
} | ||
|
||
function widget($args, $instance) { | ||
global $userdata; | ||
get_currentuserinfo(); | ||
if ($userdata->ID == 0 || trim($userdata->ID == "")) return; | ||
global $wpdb; | ||
extract($args); | ||
$title = apply_filters('widget_title', $instance['title']); | ||
get_currentuserinfo(); | ||
$nos = ($instance['nos'] <= 0) ? 10: $instance['nos']; | ||
$count = 0; | ||
$posts = $wpdb->get_results($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_author = %d and post_status = 'publish' and post_type in ('post','page','wiki')", $userdata->ID)); | ||
include(WPWIKI_FILE_PATH.'/views/user_contrib_widget.php'); | ||
} | ||
|
||
function update($new_instance, $old_instance) { | ||
$instance = $old_instance; | ||
$instance['title'] = strip_tags(stripslashes($new_instance["title"])); | ||
$instance['nos'] = strip_tags(stripslashes($new_instance["nos"])); | ||
return $instance; | ||
} | ||
|
||
function form($instance) { | ||
$title = esc_attr($instance['title']); | ||
$nos = ($instance['nos'] <= 0) ? 10: esc_attr($instance['nos']); | ||
include(WPWIKI_FILE_PATH.'/views/user_contrib_widget_form.php'); | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="wpw-dashboard"> | ||
<ul> | ||
<?php if (count($posts) > 0): | ||
foreach ($posts as $post): | ||
$name = $this->WikiHelper->get_author($post); | ||
?> | ||
|
||
<li> | ||
<a href = "<?php echo get_permalink($post->ID)?>"><?php echo $post->post_title ?></a> (<?php echo $name; ?>) </li> | ||
|
||
<?php endforeach; else: ?> | ||
|
||
<li><?php _e("No contributions yet.") ?></li> | ||
|
||
<?php endif; ?> | ||
|
||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
echo $before_widget; | ||
if ( $title ) | ||
echo $before_title . $title . $after_title; | ||
?> | ||
<ul> | ||
<?php foreach ($posts as $post): | ||
if ($this->WikiHelper->is_wiki('check_no_post',$post->ID)) { | ||
printf("<li><a href = '%s'>%s</a></li>", get_permalink($post->ID) ,$post->post_title); | ||
$count++; | ||
if ($count == $nos) { | ||
break; | ||
} | ||
} | ||
endforeach; | ||
|
||
if ($count == 0): | ||
?> | ||
<li> <?php _e("You have made no contributions"); ?> </li> | ||
<?php endif; ?> | ||
</ul> | ||
<?php echo $after_widget; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<p> | ||
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?><br /> | ||
<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /> | ||
</label> | ||
</p> | ||
<p> | ||
<label for="<?php echo $this->get_field_id('nos'); ?>"><?php _e('Number of posts to show:'); ?> | ||
<input name="<?php echo $this->get_field_name('nos'); ?>" id="<?php echo $this->get_field_id('nos'); ?>" class="widefat" type="text" size="3" maxlength="3" value="<?php echo $nos; ?>" /> | ||
</label> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters