first commit
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
define('PK_THEME_WIDGETS', PK_FRAMEWORK.'/widgets');
|
||||
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_overrides.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_portfolio_categories.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_advertising_125_125.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_advertising_300_250.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_twitter.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_dribbble.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_twitter.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_flickr.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_google_maps.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_sub_navigation.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_featured_posts.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_popular_posts.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_recent_posts.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_related_posts.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_featured_works.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_popular_works.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_recent_works.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_related_works.php');
|
||||
require_once(PK_THEME_WIDGETS.'/pk_widgets_testimonials.php');
|
||||
|
||||
?>
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Advertising_125_125 extends WP_Widget {
|
||||
|
||||
function PK_Widget_Advertising_125_125() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_advertising_125_125', 'description' => __('Displays your 125 x 125 ads', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-advertising-125-125', __('Advertising 125 x 125', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
$instance_ad_title = array();
|
||||
$instance_ad_image = array();
|
||||
$instance_ad_link = array();
|
||||
|
||||
for ($i = 1; $i <= $number; $i++) {
|
||||
|
||||
$ad_title = 'ad_'.$i.'_title';
|
||||
$instance_ad_title[$i] = isset($instance[$ad_title]) ? $instance[$ad_title] : '';
|
||||
$ad_image = 'ad_'.$i.'_image';
|
||||
$instance_ad_image[$i] = isset($instance[$ad_image]) ? $instance[$ad_image] : '';
|
||||
$ad_link = 'ad_'.$i.'_link';
|
||||
$instance_ad_link[$i] = isset($instance[$ad_link]) ? $instance[$ad_link] : '';
|
||||
|
||||
}
|
||||
|
||||
echo '<!-- pk start pk-advertising-125-125 widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<?php for ($i = 1; $i <= $number; $i++) : ?>
|
||||
<a href="<?php echo $instance_ad_link[$i]; ?>" title="<?php echo $instance_ad_title[$i]; ?>"><img src="<?php echo $instance_ad_image[$i]; ?>" alt="<?php echo $instance_ad_title[$i]; ?>" /></a>
|
||||
<?php endfor; ?>
|
||||
<?php
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-advertising-125-125 widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = $new_instance['number'];
|
||||
|
||||
for ($i = 1; $i <= absint($instance['number']); $i++) {
|
||||
|
||||
$instance['ad_'.$i.'_title'] = strip_tags($new_instance['ad_'.$i.'_title']);
|
||||
$instance['ad_'.$i.'_image'] = strip_tags($new_instance['ad_'.$i.'_image']);
|
||||
$instance['ad_'.$i.'_link'] = strip_tags($new_instance['ad_'.$i.'_link']);
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 4;
|
||||
|
||||
$instance_ad_title = array();
|
||||
$instance_ad_image = array();
|
||||
$instance_ad_link = array();
|
||||
|
||||
for($i = 1; $i <= $number; $i++) {
|
||||
|
||||
$ad_title = 'ad_'.$i.'_title';
|
||||
$instance_ad_title[$i] = isset($instance[$ad_title]) ? $instance[$ad_title] : '';
|
||||
$ad_image = 'ad_'.$i.'_image';
|
||||
$instance_ad_image[$i] = isset($instance[$ad_image]) ? esc_attr($instance[$ad_image]) : '';
|
||||
$ad_link = 'ad_'.$i.'_link';
|
||||
$instance_ad_link[$i] = isset($instance[$ad_link]) ? esc_attr($instance[$ad_link]) : '';
|
||||
|
||||
}
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of ads to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
|
||||
<div>
|
||||
<?php for ($i = 1; $i <= $number; $i++) : $ad_title = 'ad_'.$i.'_title'; $ad_image = 'ad_'.$i.'_image'; $ad_link = 'ad_'.$i.'_link'; ?>
|
||||
<div>
|
||||
<p><strong><?php _e('Advertise', 'pk_translate'); ?> <?php echo $i; ?>:</strong></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($ad_title); ?>"><?php _e('Title:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($ad_title); ?>" name="<?php echo $this -> get_field_name($ad_title); ?>" type="text" value="<?php echo $instance_ad_title[$i]; ?>" /></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($ad_image); ?>"><?php _e('Image URL:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($ad_image); ?>" name="<?php echo $this -> get_field_name($ad_image); ?>" type="text" value="<?php echo $instance_ad_image[$i]; ?>" /></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($ad_link); ?>"><?php _e('Link:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($ad_link); ?>" name="<?php echo $this -> get_field_name($ad_link); ?>" type="text" value="<?php echo $instance_ad_link[$i]; ?>" /></p>
|
||||
</div>
|
||||
<?php endfor;?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_advertising_125_125() {
|
||||
|
||||
register_widget('PK_Widget_Advertising_125_125');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_advertising_125_125');
|
||||
|
||||
?>
|
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Advertising_300_250 extends WP_Widget {
|
||||
|
||||
function PK_Widget_Advertising_300_250() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_advertising_300_250', 'description' => __('Displays your 300 x 250 ads', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-advertising-300-250', __('Advertising 300 x 250', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
$instance_ad_title = array();
|
||||
$instance_ad_image = array();
|
||||
$instance_ad_link = array();
|
||||
|
||||
for ($i = 1; $i <= $number; $i++) {
|
||||
|
||||
$ad_title = 'ad_'.$i.'_title';
|
||||
$instance_ad_title[$i] = isset($instance[$ad_title]) ? $instance[$ad_title] : '';
|
||||
$ad_image = 'ad_'.$i.'_image';
|
||||
$instance_ad_image[$i] = isset($instance[$ad_image]) ? $instance[$ad_image] : '';
|
||||
$ad_link = 'ad_'.$i.'_link';
|
||||
$instance_ad_link[$i] = isset($instance[$ad_link]) ? $instance[$ad_link] : '';
|
||||
|
||||
}
|
||||
|
||||
echo '<!-- pk start pk-advertising-300-250 widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<?php for ($i = 1; $i <= $number; $i++) : ?>
|
||||
<a href="<?php echo $instance_ad_link[$i]; ?>" title="<?php echo $instance_ad_title[$i]; ?>"><img src="<?php echo $instance_ad_image[$i]; ?>" alt="<?php echo $instance_ad_title[$i]; ?>" style="width:100%;" /></a>
|
||||
<?php endfor; ?>
|
||||
<?php
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-advertising-300-250 widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = $new_instance['number'];
|
||||
|
||||
for ($i = 1; $i <= absint($instance['number']); $i++) {
|
||||
|
||||
$instance['ad_'.$i.'_title'] = strip_tags($new_instance['ad_'.$i.'_title']);
|
||||
$instance['ad_'.$i.'_image'] = strip_tags($new_instance['ad_'.$i.'_image']);
|
||||
$instance['ad_'.$i.'_link'] = strip_tags($new_instance['ad_'.$i.'_link']);
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 1;
|
||||
|
||||
$instance_ad_title = array();
|
||||
$instance_ad_image = array();
|
||||
$instance_ad_link = array();
|
||||
|
||||
for ($i = 1; $i <= $number; $i++) {
|
||||
|
||||
$ad_title = 'ad_'.$i.'_title';
|
||||
$instance_ad_title[$i] = isset($instance[$ad_title]) ? $instance[$ad_title] : '';
|
||||
$ad_image = 'ad_'.$i.'_image';
|
||||
$instance_ad_image[$i] = isset($instance[$ad_image]) ? esc_attr($instance[$ad_image]) : '';
|
||||
$ad_link = 'ad_'.$i.'_link';
|
||||
$instance_ad_link[$i] = isset($instance[$ad_link]) ? esc_attr($instance[$ad_link]) : '';
|
||||
|
||||
}
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of ads to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
|
||||
<div>
|
||||
<?php for ($i = 1; $i <= $number; $i++) : $ad_title = 'ad_'.$i.'_title'; $ad_image = 'ad_'.$i.'_image'; $ad_link = 'ad_'.$i.'_link'; ?>
|
||||
<div>
|
||||
<p><strong><?php _e('Advertise', 'pk_translate'); ?> <?php echo $i; ?>:</strong></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($ad_title); ?>"><?php _e('Title:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($ad_title); ?>" name="<?php echo $this -> get_field_name($ad_title); ?>" type="text" value="<?php echo $instance_ad_title[$i]; ?>" /></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($ad_image); ?>"><?php _e('Image URL:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($ad_image); ?>" name="<?php echo $this -> get_field_name($ad_image); ?>" type="text" value="<?php echo $instance_ad_image[$i]; ?>" /></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($ad_link); ?>"><?php _e('Link:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($ad_link); ?>" name="<?php echo $this -> get_field_name($ad_link); ?>" type="text" value="<?php echo $instance_ad_link[$i]; ?>" /></p>
|
||||
</div>
|
||||
<?php endfor;?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_advertising_300_250() {
|
||||
|
||||
register_widget('PK_Widget_Advertising_300_250');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_advertising_300_250');
|
||||
|
||||
?>
|
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Dribbble extends WP_Widget {
|
||||
|
||||
function PK_Widget_Dribbble(){
|
||||
|
||||
$widget_ops = array('classname' => 'widget_dribbble', 'description' => __('Display your Dribbble updates', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-dribbble', __('Dribbble', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$username = (isset($instance['username'])) ? urlencode($instance['username']) : '';
|
||||
|
||||
if (empty($username)) return;
|
||||
|
||||
$number = (isset($instance['number'])) ? absint($instance['number']) : 3;
|
||||
|
||||
$total = 0;
|
||||
|
||||
echo '<!-- pk start pk-dribbble widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
|
||||
require_once(ABSPATH.WPINC.'/feed.php');
|
||||
|
||||
$dribbble_feed_url = "http://dribbble.com/$username/shots.rss";
|
||||
|
||||
$transients = get_option('pk_dribbble_transients');
|
||||
$transients[] = $args['widget_id'];
|
||||
update_option('pk_dribbble_transients', array_unique($transients));
|
||||
|
||||
$cache = get_transient($args['widget_id']);
|
||||
|
||||
if ($cache) {
|
||||
|
||||
echo $cache;
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
$feed = fetch_feed($dribbble_feed_url);
|
||||
|
||||
}
|
||||
|
||||
if (!is_wp_error($feed)) {
|
||||
|
||||
$total = $feed -> get_item_quantity($number);
|
||||
$items = $feed -> get_items(0, $total);
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($total == 0) :
|
||||
|
||||
echo '<p>'.__('The Dribble feed is either empty or unavailable. Please check back later.', 'pk_translate').'</p>';
|
||||
|
||||
else :
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
foreach($items as $item) :
|
||||
|
||||
$author = $item -> get_author();
|
||||
$text = $item -> get_title();
|
||||
$link = $item -> get_permalink();
|
||||
$time = $item -> get_date('d F, Y');
|
||||
$description = $item -> get_description();
|
||||
|
||||
preg_match("/src=\"(http.*(jpg|jpeg|gif|png))/", $description, $image_url);
|
||||
$image = $image_url[1];
|
||||
?>
|
||||
<li>
|
||||
<?php
|
||||
if ($image) :
|
||||
?>
|
||||
<a href="<?php echo $link; ?>" title="<?php echo $text; ?>" rel="external nofollow">
|
||||
<img src="<?php echo $image; ?>" style="width:100%;" />
|
||||
</a>
|
||||
<h5><?php echo $text; ?></h5>
|
||||
<small><?php echo __('By:', 'pk_translate').' '.$username.' . '.$time; ?></small>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</li>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-dribbble widget -->
|
||||
|
||||
';
|
||||
|
||||
set_transient($args['widget_id'], ob_get_flush(), 3600);
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['username'] = $new_instance['username'];
|
||||
$instance['number'] = absint($new_instance['number']);
|
||||
|
||||
$transients = get_option('pk_dribbble_transients');
|
||||
|
||||
foreach ($transients as $transient) {
|
||||
|
||||
delete_transient($transient);
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$username = (isset($instance['username'])) ? $instance['username'] : '';
|
||||
$number = (isset($instance['number'])) ? absint($instance['number']) : 3;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('username'); ?>"><?php _e('Dribbble username:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('username'); ?>" name="<?php echo $this -> get_field_name('username'); ?>" type="text" value="<?php echo $username; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of updates to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_dribbble() {
|
||||
|
||||
register_widget('PK_Widget_Dribbble');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_dribbble');
|
||||
|
||||
?>
|
@ -0,0 +1,184 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Featured_Posts extends WP_Widget {
|
||||
|
||||
function PK_Widget_Featured_Posts() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_featured_posts', 'description' => __('Displays the featured posts', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-featured-posts', __('Featured Posts', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_featured_posts';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_featured_posts', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$selected_categories = (isset($instance['selected_categories']) && !empty($instance['selected_categories'])) ? $instance['selected_categories'] : array();
|
||||
$selected_order_by = (isset($instance['selected_order_by']) && !empty($instance['selected_order_by'])) ? $instance['selected_order_by'] : 'date';
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
$r = new WP_Query(array('post_type' => 'post', 'posts_per_page' => $number, 'category__in' => $selected_categories, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $selected_order_by, 'order' => 'DESC'));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-featured-posts widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-featured-posts widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_featured_posts', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
$instance['selected_categories'] = $new_instance['selected_categories'];
|
||||
$instance['selected_order_by'] = $new_instance['selected_order_by'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_featured_posts'])) {
|
||||
|
||||
delete_option('widget_featured_posts');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_featured_posts', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
$selected_categories = (isset($instance['selected_categories']) && !empty($instance['selected_categories'])) ? $instance['selected_categories'] : array();
|
||||
$selected_order_by = (isset($instance['selected_order_by']) && !empty($instance['selected_order_by'])) ? $instance['selected_order_by'] : 'date';
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('selected_categories'); ?>"><?php _e('Select categories:', 'pk_translate'); ?></label>
|
||||
<select class="widefat" id="<?php echo $this -> get_field_id('selected_categories'); ?>" name="<?php echo $this -> get_field_name('selected_categories'); ?>[]" multiple="multiple" style="height:auto"><?php
|
||||
|
||||
$categories = get_categories(array('hide_empty' => 1, 'hierarchical' => false, 'taxonomy' => 'category'));
|
||||
|
||||
if ($categories) {
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
if (in_array($category -> term_id, $selected_categories)) {
|
||||
|
||||
$selected_string = ' selected="selected"';
|
||||
|
||||
} else {
|
||||
|
||||
$selected_string = '';
|
||||
|
||||
}
|
||||
|
||||
echo '
|
||||
<option value="'.$category -> term_id.'"'.$selected_string.'>'.$category -> name.'</option>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?></select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('selected_order_by'); ?>"><?php _e('Order posts by:', 'pk_translate'); ?></label>
|
||||
<select class="widefat" id="<?php echo $this -> get_field_id('selected_order_by'); ?>" name="<?php echo $this -> get_field_name('selected_order_by'); ?>">
|
||||
<option value="date"<?php if ($selected_order_by == 'date') echo ' selected="selected"';?>><?php _e('Date', 'pk_translate'); ?></option>
|
||||
<option value="comment_count"<?php if ($selected_order_by == 'comment_count') echo ' selected="selected"';?>><?php _e('Comments Count', 'pk_translate'); ?></option>
|
||||
<option value="title"<?php if ($selected_order_by == 'title') echo ' selected="selected"';?>><?php _e('Title', 'pk_translate'); ?></option>
|
||||
<option value="author"<?php if ($selected_order_by == 'author') echo ' selected="selected"';?>><?php _e('Author', 'pk_translate'); ?></option>
|
||||
<option value="rand"<?php if ($selected_order_by == 'rand') echo ' selected="selected"';?>><?php _e('Random', 'pk_translate'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_featured_posts() {
|
||||
|
||||
register_widget('PK_Widget_Featured_Posts');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_featured_posts');
|
||||
|
||||
?>
|
@ -0,0 +1,185 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Featured_Works extends WP_Widget {
|
||||
|
||||
function PK_Widget_Featured_Works() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_featured_works', 'description' => __('Displays the featured works', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-featured-works', __('Featured Works', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_featured_works';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_featured_works', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$selected_portfolio_categories = (isset($instance['selected_portfolio_categories']) && !empty($instance['selected_portfolio_categories'])) ? $instance['selected_portfolio_categories'] : array();
|
||||
$selected_order_by = (isset($instance['selected_order_by']) && !empty($instance['selected_order_by'])) ? $instance['selected_order_by'] : 'date';
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
$r = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $number, 'tax_query' => array(array('taxonomy' => 'taxonomy_portfolio', 'terms' => $selected_portfolio_categories)), 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => $selected_order_by, 'order' => ($selected_order_by == 'menu_order') ? 'ASC' : 'DESC'));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-featured-works widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-featured-works widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_featured_works', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
$instance['selected_portfolio_categories'] = $new_instance['selected_portfolio_categories'];
|
||||
$instance['selected_order_by'] = $new_instance['selected_order_by'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_featured_works'])) {
|
||||
|
||||
delete_option('widget_featured_works');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_featured_works', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
$selected_portfolio_categories = (isset($instance['selected_portfolio_categories']) && !empty($instance['selected_portfolio_categories'])) ? $instance['selected_portfolio_categories'] : array();
|
||||
$selected_order_by = (isset($instance['selected_order_by']) && !empty($instance['selected_order_by'])) ? $instance['selected_order_by'] : 'date';
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of works to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('selected_portfolio_categories'); ?>"><?php _e('Select categories:', 'pk_translate'); ?></label>
|
||||
<select class="widefat" id="<?php echo $this -> get_field_id('selected_portfolio_categories'); ?>" name="<?php echo $this -> get_field_name('selected_portfolio_categories'); ?>[]" multiple="multiple" style="height:auto"><?php
|
||||
|
||||
$categories = get_categories(array('hide_empty' => 1, 'hierarchical' => false, 'taxonomy' => 'taxonomy_portfolio'));
|
||||
|
||||
if ($categories) {
|
||||
|
||||
foreach ($categories as $category) {
|
||||
|
||||
if (in_array($category -> term_id, $selected_portfolio_categories)) {
|
||||
|
||||
$selected_string = ' selected="selected"';
|
||||
|
||||
} else {
|
||||
|
||||
$selected_string = '';
|
||||
|
||||
}
|
||||
|
||||
echo '
|
||||
<option value="'.$category -> term_id.'"'.$selected_string.'>'.$category -> name.'</option>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?></select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('selected_order_by'); ?>"><?php _e('Order works by:', 'pk_translate'); ?></label>
|
||||
<select class="widefat" id="<?php echo $this -> get_field_id('selected_order_by'); ?>" name="<?php echo $this -> get_field_name('selected_order_by'); ?>">
|
||||
<option value="menu_order"<?php if ($selected_order_by == 'menu_order') echo ' selected="selected"';?>><?php _e('Manual Sort', 'pk_translate'); ?></option>
|
||||
<option value="date"<?php if ($selected_order_by == 'date') echo ' selected="selected"';?>><?php _e('Date', 'pk_translate'); ?></option>
|
||||
<option value="comment_count"<?php if ($selected_order_by == 'comment_count') echo ' selected="selected"';?>><?php _e('Comments Count', 'pk_translate'); ?></option>
|
||||
<option value="title"<?php if ($selected_order_by == 'title') echo ' selected="selected"';?>><?php _e('Title', 'pk_translate'); ?></option>
|
||||
<option value="author"<?php if ($selected_order_by == 'author') echo ' selected="selected"';?>><?php _e('Author', 'pk_translate'); ?></option>
|
||||
<option value="rand"<?php if ($selected_order_by == 'rand') echo ' selected="selected"';?>><?php _e('Random', 'pk_translate'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_featured_works() {
|
||||
|
||||
register_widget('PK_Widget_Featured_Works');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_featured_works');
|
||||
|
||||
?>
|
@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Flickr extends WP_Widget {
|
||||
|
||||
function PK_Widget_Flickr() {
|
||||
|
||||
$widget_ops=array('classname' => 'widget_flickr', 'description' => __('Display your Flickr photos feed', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-flickr', __('Flickr', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
$open_with_lightbox = (isset($instance['open_with_lightbox']) && $instance['open_with_lightbox']) ? 1 : 0;
|
||||
$feed = $instance['feed'];
|
||||
|
||||
if (empty($feed)) return;
|
||||
if ($feed != '') $feed .= '&format=rss_200';
|
||||
|
||||
require_once(ABSPATH.WPINC.'/feed.php');
|
||||
|
||||
echo '<!-- pk start pk-flickr widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
|
||||
$transients = get_option('pk_flickr_transients');
|
||||
$transients[] = $args['widget_id'];
|
||||
update_option('pk_flickr_transients', array_unique($transients));
|
||||
|
||||
$cache = get_transient($args['widget_id']);
|
||||
|
||||
if ($cache) {
|
||||
|
||||
echo $cache;
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
$feed = fetch_feed($feed);
|
||||
|
||||
}
|
||||
|
||||
if ($feed != '' && !is_wp_error($feed)) :
|
||||
|
||||
$items = $feed -> get_items(0, $number);
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
<div class="flickr_widget">
|
||||
<?php
|
||||
foreach ($items as $item) : $item_media = $item -> get_enclosures();
|
||||
|
||||
if ($open_with_lightbox) :
|
||||
?>
|
||||
<a class="flickr_image_<?php echo $args['widget_id']; ?>" href="<?php echo esc_attr($item_media[0] -> link); ?>" title="<?php echo $item -> get_title(); ?>">
|
||||
<img src="<?php echo esc_attr(str_replace(array('_t.','_m.','_z.'), '_s.', $item_media[0] -> thumbnails[0])); ?>" />
|
||||
</a>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<a href="<?php echo esc_attr($item -> get_permalink()); ?>" title="<?php echo $item -> get_title(); ?>">
|
||||
<img src="<?php echo esc_attr(str_replace(array('_t.','_m.','_z.'), '_s.', $item_media[0] -> thumbnails[0])); ?>" />
|
||||
</a>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
?>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery(".flickr_image_<?php echo $args['widget_id']; ?>").attr('rel', 'prettyPhoto[flickr_widget_<?php echo $args['widget_id']; ?>]').prettyPhoto(<?php echo PK_PRETTYPHOTO_PARAMS; ?>);
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
else :
|
||||
|
||||
echo '<p>'.__('The Flickr feed is either empty or unavailable. Please check back later.', 'pk_translate').'</p>';
|
||||
|
||||
endif;
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-flickr widget -->
|
||||
|
||||
';
|
||||
|
||||
set_transient($args['widget_id'], ob_get_flush(), 3600);
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = absint($new_instance['number']);
|
||||
$instance['open_with_lightbox'] = $new_instance['open_with_lightbox'] ? 1 : 0;
|
||||
$instance['feed'] = $new_instance['feed'];
|
||||
|
||||
$transients = get_option('pk_flickr_transients');
|
||||
|
||||
foreach ($transients as $transient) {
|
||||
|
||||
delete_transient($transient);
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 16;
|
||||
$open_with_lightbox = (isset($instance['open_with_lightbox']) && !empty($instance['open_with_lightbox'])) ? 'checked="checked"' : '';
|
||||
$feed = isset($instance['feed']) ? esc_attr($instance['feed']) : '';
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of thumbnails to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
|
||||
<p><input class="checkbox" type="checkbox" <?php echo $open_with_lightbox; ?> id="<?php echo $this -> get_field_id('open_with_lightbox'); ?>" name="<?php echo $this -> get_field_name('open_with_lightbox'); ?>" />
|
||||
<label for="<?php echo $this -> get_field_id('open_with_lightbox'); ?>"><?php _e('Open photos with lightbox', 'pk_translate'); ?></label><br />
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('feed'); ?>"><?php _e('Flickr RSS2 feed URL:', 'pk_translate', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('feed'); ?>" name="<?php echo $this -> get_field_name('feed'); ?>" type="text" value="<?php echo $feed; ?>" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_flickr() {
|
||||
|
||||
register_widget('PK_Widget_Flickr');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_flickr');
|
||||
|
||||
?>
|
@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Google_Maps extends WP_Widget {
|
||||
|
||||
function PK_Widget_Google_Maps() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_google_maps', 'description' => __('Displays Google Maps', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-google-maps', __('Google Maps', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$map_url = isset($instance['map_url']) ? esc_url($instance['map_url']) : '';
|
||||
$map_height = absint($instance['map_height']);
|
||||
|
||||
echo '<!-- pk start pk-google-maps widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="pk_widget_google_maps">
|
||||
<iframe src="<?php echo $map_url.'&output=embed'; ?>" style="width:100%; height:<?php echo $map_height; ?>px;"></iframe>
|
||||
</div>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-google-maps widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['map_url'] = esc_url($new_instance['map_url']);
|
||||
$instance['map_height'] = $new_instance['map_height'];
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? $instance['title'] : '';
|
||||
$map_url = isset($instance['map_url']) ? esc_url($instance['map_url']) : '';
|
||||
$map_height = isset($instance['map_height']) ? absint($instance['map_height']) : 300;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('map_url'); ?>"><?php _e('Map URL:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('map_url'); ?>" name="<?php echo $this -> get_field_name('map_url'); ?>" type="text" value="<?php echo $map_url; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('map_height'); ?>"><?php _e('Map height:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('map_height'); ?>" name="<?php echo $this -> get_field_name('map_height'); ?>" type="text" value="<?php echo $map_height; ?>" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_google_maps() {
|
||||
|
||||
register_widget('PK_Widget_Google_Maps');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_google_maps');
|
||||
|
||||
?>
|
@ -0,0 +1,721 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Links extends WP_Widget_Links {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args, EXTR_SKIP);
|
||||
|
||||
$show_description = isset($instance['description']) ? $instance['description'] : false;
|
||||
$show_name = isset($instance['name']) ? $instance['name'] : false;
|
||||
$show_rating = isset($instance['rating']) ? $instance['rating'] : false;
|
||||
$show_images = isset($instance['images']) ? $instance['images'] : true;
|
||||
$category = isset($instance['category']) ? $instance['category'] : false;
|
||||
|
||||
if (is_admin() && !$category) {
|
||||
|
||||
echo $before_widget.$before_title. __('All Links', 'pk_translate').$after_title.$after_widget;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
$before_widget = preg_replace('/id="[^"]*"/','id="%id"', $before_widget);
|
||||
|
||||
$before_widget = '<!-- pk start pk-links widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
$after_widget = $after_widget.'
|
||||
<!-- pk end pk-links widget -->
|
||||
';
|
||||
|
||||
$output = wp_list_bookmarks(apply_filters('widget_links_args', array(
|
||||
'title_before' => $before_title, 'title_after' => $after_title,
|
||||
'category_before' => $before_widget, 'category_after' => $after_widget,
|
||||
'show_images' => $show_images, 'show_description' => $show_description,
|
||||
'show_name' => $show_name, 'show_rating' => $show_rating,
|
||||
'category' => $category, 'class' => 'linkcat widget',
|
||||
'echo' => 0
|
||||
)));
|
||||
|
||||
echo str_replace(array("</a>\n", "\n</li>", "<li>", "\n\n\t"), array("</a>", "</li>", "\t\t<li>", "\n\t"), $output);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Calendar extends WP_Widget_Calendar {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? ' ' : $instance['title'], $instance, $this -> id_base);
|
||||
|
||||
echo '<!-- pk start pk-calendar widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
|
||||
echo '
|
||||
<div id="calendar_wrap" class="table rounded">
|
||||
';
|
||||
|
||||
get_calendar();
|
||||
|
||||
echo '
|
||||
</div>
|
||||
';
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-calendar widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Meta extends WP_Widget_Meta {
|
||||
|
||||
function PK_Widget_Meta() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_meta', 'description' => __('Log in/out, feed and WP links', 'pk_translate'));
|
||||
$this -> WP_Widget('meta', __('Meta', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Meta', 'pk_translate') : $instance['title'], $instance, $this -> id_base);
|
||||
|
||||
echo '<!-- pk start pk-meta widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
if (get_option('users_can_register') && !is_user_logged_in()) :
|
||||
?>
|
||||
<li><a href="#pk_register_form" class="pk_meta_register"><?php _e('Register', 'pk_translate'); ?></a></li>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
if (is_user_logged_in() || !get_option('users_can_register')) :
|
||||
?>
|
||||
<li><?php wp_loginout(); ?></li>
|
||||
<?php
|
||||
else :
|
||||
?>
|
||||
<li><a href="#pk_login_form" class="pk_meta_login"><?php _e('Log in', 'pk_translate'); ?></a></li>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php echo esc_attr(__('Syndicate this site using RSS 2.0', 'pk_translate')); ?>"><?php _e('Entries <abbr title="Really Simple Syndication">RSS</abbr>', 'pk_translate'); ?></a></li>
|
||||
<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php echo esc_attr(__('The latest comments to all posts in RSS', 'pk_translate')); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr>', 'pk_translate'); ?></a></li>
|
||||
<li><a href="http://wordpress.org/" title="<?php echo esc_attr(__('Powered by WordPress, state-of-the-art semantic personal publishing platform.', 'pk_translate')); ?>">WordPress.org</a></li>
|
||||
<?php
|
||||
wp_meta();
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-meta widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Categories extends WP_Widget_Categories {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Categories', 'pk_translate') : $instance['title'], $instance, $this -> id_base);
|
||||
$c = $instance['count'] ? '1' : '0';
|
||||
$h = $instance['hierarchical'] ? '1' : '0';
|
||||
$d = $instance['dropdown'] ? '1' : '0';
|
||||
|
||||
echo '<!-- pk start pk-categories widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
|
||||
$cat_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'echo' => 0);
|
||||
|
||||
if ($d) {
|
||||
|
||||
$cat_args['show_option_none'] = __('Select Category', 'pk_translate');
|
||||
|
||||
echo '
|
||||
'.str_replace(array("<select", "<option", "</select"), array("\t<select", "\t<option", "\t</select"), wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args)));
|
||||
?>
|
||||
<script type='text/javascript'>
|
||||
/* <![CDATA[ */
|
||||
var dropdown = document.getElementById("cat");
|
||||
function onCatChange() {
|
||||
if (dropdown.options[dropdown.selectedIndex].value > 0) {
|
||||
location.href = "<?php echo home_url(); ?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
|
||||
}
|
||||
}
|
||||
dropdown.onchange = onCatChange;
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
echo str_replace(array("\n</a>", "\n</li>", "<li"), array("</a>", "</li>", "\t<li"), wp_list_categories(apply_filters('widget_categories_args', $cat_args)));
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-categories widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Recent_Comments extends WP_Widget_Recent_Comments {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
global $comments, $comment;
|
||||
|
||||
$cache = wp_cache_get('widget_recent_comments', 'widget');
|
||||
|
||||
if (!is_array($cache)) $cache = array();
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
extract($args, EXTR_SKIP);
|
||||
|
||||
$output = '';
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Recent Comments', 'pk_translate') : $instance['title']);
|
||||
|
||||
if (!$number = absint($instance['number'])) $number = 5;
|
||||
|
||||
$comments = get_comments(array('number' => $number, 'status' => 'approve'));
|
||||
|
||||
$output .= '<!-- pk start pk-recent-comments widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) $output .= $before_title.$title.$after_title;
|
||||
|
||||
$output .= '
|
||||
<ul id="recentcomments">';
|
||||
|
||||
if ($comments) {
|
||||
|
||||
foreach ((array)$comments as $comment) {
|
||||
|
||||
$output .= '
|
||||
<li class="recentcomments">'.sprintf(__('%1$s on %2$s', 'pk_translate'), get_comment_author_link(), '<a href="'.esc_url(get_comment_link($comment -> comment_ID)).'">'.get_the_title($comment -> comment_post_ID).'</a>').'</li>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$output .= '
|
||||
</ul>
|
||||
';
|
||||
$output .= $after_widget.'
|
||||
<!-- pk end pk-recent-comments widget -->
|
||||
|
||||
';
|
||||
|
||||
echo $output;
|
||||
|
||||
$cache[$args['widget_id']] = $output;
|
||||
|
||||
wp_cache_set('widget_recent_comments', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Pages extends WP_Widget_Pages {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Pages', 'pk_translate') : $instance['title'], $instance, $this -> id_base);
|
||||
$sortby = empty($instance['sortby']) ? 'menu_order' : $instance['sortby'];
|
||||
$exclude = empty($instance['exclude']) ? '' : $instance['exclude'];
|
||||
|
||||
if ($sortby == 'menu_order') $sortby = 'menu_order, post_title';
|
||||
|
||||
$output = wp_list_pages(apply_filters('widget_pages_args', array('title_li' => '', 'echo' => 0, 'sort_column' => $sortby, 'exclude' => $exclude)));
|
||||
|
||||
if (!empty($output)) {
|
||||
|
||||
echo '<!-- pk start pk-pages widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
echo $output;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-pages widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$instance = wp_parse_args((array) $instance, array('sortby' => 'post_title', 'title' => '', 'exclude' => ''));
|
||||
$title = esc_attr($instance['title']);
|
||||
$exclude = empty($instance['exclude']) ? '' : esc_attr($instance['exclude']);
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('sortby'); ?>"><?php _e('Sort by:', 'pk_translate'); ?></label>
|
||||
<select name="<?php echo $this -> get_field_name('sortby'); ?>" id="<?php echo $this -> get_field_id('sortby'); ?>" class="widefat">
|
||||
<option value="menu_order"<?php selected($instance['sortby'], 'menu_order'); ?>><?php _e('Menu order', 'pk_translate'); ?></option>
|
||||
<option value="post_title"<?php selected($instance['sortby'], 'post_title'); ?>><?php _e('Page title', 'pk_translate'); ?></option>
|
||||
<option value="ID"<?php selected($instance['sortby'], 'ID'); ?>><?php _e('Page ID', 'pk_translate'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('exclude'); ?>"><?php _e('Exclude:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('exclude'); ?>" name="<?php echo $this -> get_field_name('exclude'); ?>" type="text" value="<?php echo $exclude; ?>" />
|
||||
<br /><small><?php _e('Page IDs, separated by commas.' ,'pk_translate'); ?></small>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Archives extends WP_Widget_Archives {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$c = $instance['count'] ? '1' : '0';
|
||||
$d = $instance['dropdown'] ? '1' : '0';
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? __('Archives', 'pk_translate') : $instance['title'], $instance, $this -> id_base);
|
||||
|
||||
echo '<!-- pk start pk-archives widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
|
||||
if ($d) {
|
||||
?>
|
||||
|
||||
<select name="archive-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'>
|
||||
<option value=""><?php echo esc_attr(__('Select Month', 'pk_translate')); ?></option>
|
||||
<?php
|
||||
echo str_replace(array("<option", "> ", " </"), array("\t<option", ">", "</"), wp_get_archives(apply_filters('widget_archives_dropdown_args', array('type' => 'monthly', 'format' => 'option', 'show_post_count' => $c, 'echo' => 0))));
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
echo str_replace("<li>", "\t<li>", wp_get_archives(apply_filters('widget_archives_args', array('type' => 'monthly', 'show_post_count' => $c, 'echo' => 0))));
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-archives widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Nav_Menu_Widget extends WP_Nav_Menu_Widget {
|
||||
|
||||
function PK_Nav_Menu_Widget() {
|
||||
|
||||
$widget_ops = array('description' => __('Add one of your custom menus', 'pk_translate'));
|
||||
parent::WP_Widget('nav_menu', __('Custom Menu', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$nav_menu = wp_get_nav_menu_object($instance['nav_menu']);
|
||||
|
||||
if (!$nav_menu) return;
|
||||
|
||||
$instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this -> id_base);
|
||||
|
||||
echo '<!-- pk start pk-custom-menu widget -->
|
||||
'.$args['before_widget'].'
|
||||
';
|
||||
|
||||
if (!empty($instance['title'])) echo $args['before_title'].$instance['title'].$args['after_title'].'
|
||||
';
|
||||
|
||||
wp_nav_menu(array('fallback_cb' => '', 'menu' => $nav_menu));
|
||||
|
||||
echo '
|
||||
'.$args['after_widget'].'
|
||||
<!-- pk end pk-custom-menu widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? $instance['title'] : '';
|
||||
$nav_menu = isset($instance['nav_menu']) ? $instance['nav_menu'] : '';
|
||||
|
||||
$menus = get_terms('nav_menu', array('hide_empty' => false));
|
||||
|
||||
if (!$menus) {
|
||||
|
||||
echo '<p>'. sprintf(__('No menus have been created yet. <a href="%s">Create some</a>.', 'pk_translate'), admin_url('nav-menus.php')) .'</p>';
|
||||
return;
|
||||
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate') ?></label>
|
||||
<input type="text" class="widefat" id="<?php echo $this -> get_field_id('title'); ?>" name="<?php echo $this -> get_field_name('title'); ?>" value="<?php echo $title; ?>" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('nav_menu'); ?>"><?php _e('Select Menu:', 'pk_translate'); ?></label>
|
||||
<select class="widefat" id="<?php echo $this -> get_field_id('nav_menu'); ?>" name="<?php echo $this -> get_field_name('nav_menu'); ?>">
|
||||
<?php
|
||||
foreach ($menus as $menu) {
|
||||
|
||||
$selected = $nav_menu == $menu -> term_id ? ' selected="selected"' : '';
|
||||
echo '<option'. $selected .' value="'. $menu -> term_id .'">'. $menu -> name .'</option>';
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Text extends WP_Widget_Text {
|
||||
|
||||
function PK_Widget_Text() {
|
||||
|
||||
$widget_ops = array('description' => __('Arbitrary text, shortcodes or HTML', 'pk_translate'));
|
||||
$control_ops = array('width' => 400, 'height' => 350);
|
||||
$this -> WP_Widget('text', __('Text', 'pk_translate'), $widget_ops, $control_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this -> id_base);
|
||||
$text = apply_filters('widget_text', $instance['text'], $instance);
|
||||
|
||||
echo '<!-- pk start pk-text widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if (!empty($title)) {
|
||||
|
||||
echo $before_title.$title.$after_title;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="textwidget">
|
||||
<?php echo (isset($instance['filter']) && $instance['filter']) ? wpautop($text) : $text; ?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-text widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
do_action('pk_ah_save_text_widget');
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
|
||||
if (current_user_can('unfiltered_html')) {
|
||||
|
||||
$instance['text'] = $new_instance['text'];
|
||||
|
||||
} else {
|
||||
|
||||
$instance['text'] = stripslashes(wp_filter_post_kses(addslashes($new_instance['text'])));
|
||||
|
||||
}
|
||||
|
||||
$instance['filter'] = isset($new_instance['filter']);
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$instance = wp_parse_args((array)$instance, array('title' => '', 'text' => ''));
|
||||
$title = strip_tags($instance['title']);
|
||||
$text = esc_textarea($instance['text']);
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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>
|
||||
|
||||
<textarea class="widefat" rows="16" cols="20" id="<?php echo $this -> get_field_id('text'); ?>" name="<?php echo $this -> get_field_name('text'); ?>"><?php echo $text; ?></textarea>
|
||||
|
||||
<p><input id="<?php echo $this -> get_field_id('filter'); ?>" name="<?php echo $this -> get_field_name('filter'); ?>" type="checkbox" <?php checked(isset($instance['filter']) ? $instance['filter'] : 0); ?> /> <label for="<?php echo $this -> get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs', 'pk_translate'); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Search extends WP_Widget_Search {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title'], $instance, $this -> id_base);
|
||||
|
||||
echo '<!-- pk start pk-search widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title.'
|
||||
';
|
||||
|
||||
get_search_form();
|
||||
|
||||
echo '
|
||||
'.$after_widget.'
|
||||
<!-- pk end pk-search widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_RSS extends WP_Widget_RSS {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
if (isset($instance['error']) && $instance['error']) return;
|
||||
|
||||
extract($args, EXTR_SKIP);
|
||||
|
||||
$url = $instance['url'];
|
||||
|
||||
while (stristr($url, 'http') != $url) $url = substr($url, 1);
|
||||
|
||||
if (empty($url)) return;
|
||||
|
||||
if ($url == site_url() || $url == home_url()) return;
|
||||
|
||||
$rss = fetch_feed($url);
|
||||
|
||||
$title = $instance['title'];
|
||||
|
||||
$desc = '';
|
||||
|
||||
$link = '';
|
||||
|
||||
if (!is_wp_error($rss)) {
|
||||
|
||||
$desc = esc_attr(strip_tags(@html_entity_decode($rss -> get_description(), ENT_QUOTES, get_option('blog_charset'))));
|
||||
|
||||
if (empty($title)) $title = esc_html(strip_tags($rss -> get_title()));
|
||||
|
||||
$link = esc_url(strip_tags($rss -> get_permalink()));
|
||||
|
||||
while (stristr($link, 'http') != $link) $link = substr($link, 1);
|
||||
|
||||
}
|
||||
|
||||
if (empty($title)) $title = empty($desc) ? __('Unknown Feed', 'pk_translate') : $desc;
|
||||
|
||||
$title = apply_filters('widget_title', $title, $instance, $this -> id_base);
|
||||
|
||||
$url = esc_url(strip_tags($url));
|
||||
|
||||
$icon = includes_url('images/rss.png');
|
||||
|
||||
if ($title) $title = "<a class='rsswidget' href='$url' title='".esc_attr__('Syndicate this content', 'pk_translate')."'><img style='border:0' width='14' height='14' src='$icon' alt='RSS' /></a><a class='rsswidget' href='$link' title='$desc'>$title</a>";
|
||||
|
||||
echo '<!-- pk start pk-rss widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
|
||||
wp_widget_rss_output($rss, $instance);
|
||||
|
||||
echo '
|
||||
'.$after_widget.'
|
||||
<!-- pk end pk-rss widget -->
|
||||
|
||||
';
|
||||
|
||||
if (!is_wp_error($rss)) $rss -> __destruct();
|
||||
|
||||
unset($rss);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PK_Widget_Tag_Cloud extends WP_Widget_Tag_Cloud {
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$current_taxonomy = $this -> _get_current_taxonomy($instance);
|
||||
|
||||
if (!empty($instance['title'])) {
|
||||
|
||||
$title = $instance['title'];
|
||||
|
||||
} else {
|
||||
|
||||
if ('post_tag' == $current_taxonomy) {
|
||||
|
||||
$title = __('Tags', 'pk_translate');
|
||||
|
||||
} else {
|
||||
|
||||
$tax = get_taxonomy($current_taxonomy);
|
||||
$title = $tax -> labels -> name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$title = apply_filters('widget_title', $title, $instance, $this -> id_base);
|
||||
|
||||
echo '<!-- pk start pk-tag-cloud widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
|
||||
echo '
|
||||
<div class="tagcloud">
|
||||
';
|
||||
|
||||
echo str_replace("<a", "\t\t<a", wp_tag_cloud(apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy, 'echo' => 0))));
|
||||
|
||||
echo '
|
||||
</div>
|
||||
';
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-tag-cloud widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_overrides() {
|
||||
|
||||
unregister_widget('WP_Widget_Calendar');
|
||||
unregister_widget('WP_Widget_Links');
|
||||
unregister_widget('WP_Widget_Meta');
|
||||
unregister_widget('WP_Widget_Categories');
|
||||
unregister_widget('WP_Widget_Recent_Comments');
|
||||
unregister_widget('WP_Widget_Pages');
|
||||
unregister_widget('WP_Widget_Archives');
|
||||
unregister_widget('WP_Nav_Menu_Widget');
|
||||
unregister_widget('WP_Widget_Text');
|
||||
unregister_widget('WP_Widget_Tag_Cloud');
|
||||
unregister_widget('WP_Widget_RSS');
|
||||
unregister_widget('WP_Widget_Search');
|
||||
|
||||
register_widget('PK_Widget_Calendar');
|
||||
register_widget('PK_Widget_Links');
|
||||
register_widget('PK_Widget_Meta');
|
||||
register_widget('PK_Widget_Categories');
|
||||
register_widget('PK_Widget_Recent_Comments');
|
||||
register_widget('PK_Widget_Pages');
|
||||
register_widget('PK_Widget_Archives');
|
||||
register_widget('PK_Nav_Menu_Widget');
|
||||
register_widget('PK_Widget_Text');
|
||||
register_widget('PK_Widget_Tag_Cloud');
|
||||
register_widget('PK_Widget_RSS');
|
||||
register_widget('PK_Widget_Search');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_overrides');
|
||||
|
||||
?>
|
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Popular_Posts extends WP_Widget {
|
||||
|
||||
function PK_Widget_Popular_Posts() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_popular_posts', 'description' => __('Displays the most popular posts', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-popular-posts', __('Popular Posts', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_popular_posts';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_popular_posts', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
$r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'order' => 'DESC'));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-popular-posts widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-popular-posts widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_popular_posts', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_popular_posts'])) {
|
||||
|
||||
delete_option('widget_popular_posts');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_popular_posts', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_popular_posts() {
|
||||
|
||||
register_widget('PK_Widget_Popular_Posts');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_popular_posts');
|
||||
|
||||
?>
|
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Popular_Works extends WP_Widget {
|
||||
|
||||
function PK_Widget_Popular_Works() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_popular_works', 'description' => __('Displays the most popular works.', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-popular-works', __('Popular Works', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_popular_works';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_popular_works', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
$r = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'order' => 'DESC'));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-popular-works widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-popular-works widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_popular_works', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_popular_works'])) {
|
||||
|
||||
delete_option('widget_popular_works');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_popular_works', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of works to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_popular_works() {
|
||||
|
||||
register_widget('PK_Widget_Popular_Works');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_popular_works');
|
||||
|
||||
?>
|
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Portfolio_Categories extends WP_Widget {
|
||||
|
||||
function PK_Widget_Portfolio_Categories() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_portfolio_categories', 'description' => __('A list or dropdown of portfolio categories', 'pk_translate'));
|
||||
$this -> WP_Widget('portfolio-categories', __('Portfolio Categories', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
$c = $instance['count'] ? '1' : '0';
|
||||
$h = $instance['hierarchical'] ? '1' : '0';
|
||||
$d = $instance['dropdown'] ? '1' : '0';
|
||||
|
||||
echo '<!-- pk start portfolio-categories widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
|
||||
$taxonomies_args = array('orderby' => 'name', 'show_count' => $c, 'hierarchical' => $h, 'taxonomy' => 'taxonomy_portfolio', 'echo' => 0);
|
||||
|
||||
if ($d) {
|
||||
|
||||
$terms = get_terms($taxonomy, $taxonomies_args);
|
||||
|
||||
echo '
|
||||
<select id="taxonomy_select_'.$widget_id.'" name="taxonomy_select_'.$widget_id.'" class="postform">';
|
||||
echo '
|
||||
<option value="">'.__('Select Category', 'pk_translate').'</option>';
|
||||
|
||||
foreach ($terms as $term) {
|
||||
|
||||
echo '
|
||||
<option value="'.get_term_link($term -> slug, $taxonomy).'">'.$term -> name.'</option>';
|
||||
|
||||
}
|
||||
|
||||
echo '
|
||||
</select>
|
||||
';
|
||||
?>
|
||||
<script type='text/javascript'>
|
||||
/* <![CDATA[ */
|
||||
document.getElementById("taxonomy_select_<?php echo $widget_id; ?>").onchange = function() {
|
||||
location.href = this.options[this.selectedIndex].value;
|
||||
}
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
$taxonomies_args['title_li'] = '';
|
||||
echo str_replace(array("\n</a>", "\n</li>", "<li"), array("</a>", "</li>", "\t<li"), wp_list_categories(apply_filters('widget_categories_args', $taxonomies_args)));
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end portfolio-categories widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['count'] = !empty($new_instance['count']) ? 1 : 0;
|
||||
$instance['hierarchical'] = !empty($new_instance['hierarchical']) ? 1 : 0;
|
||||
$instance['dropdown'] = !empty($new_instance['dropdown']) ? 1 : 0;
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$instance = wp_parse_args((array) $instance, array('title' => ''));
|
||||
$title = esc_attr($instance['title']);
|
||||
$count = isset($instance['count']) ? (bool) $instance['count'] : false;
|
||||
$hierarchical = isset($instance['hierarchical']) ? (bool) $instance['hierarchical'] : false;
|
||||
$dropdown = isset($instance['dropdown']) ? (bool) $instance['dropdown'] : false;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><input type="checkbox" class="checkbox" id="<?php echo $this -> get_field_id('dropdown'); ?>" name="<?php echo $this -> get_field_name('dropdown'); ?>"<?php checked($dropdown); ?> />
|
||||
<label for="<?php echo $this -> get_field_id('dropdown'); ?>"><?php _e('Display as dropdown', 'pk_translate'); ?></label><br />
|
||||
<input type="checkbox" class="checkbox" id="<?php echo $this -> get_field_id('count'); ?>" name="<?php echo $this -> get_field_name('count'); ?>"<?php checked($count); ?> />
|
||||
<label for="<?php echo $this -> get_field_id('count'); ?>"><?php _e('Show post counts', 'pk_translate'); ?></label><br />
|
||||
<input type="checkbox" class="checkbox" id="<?php echo $this -> get_field_id('hierarchical', 'pk_translate'); ?>" name="<?php echo $this -> get_field_name('hierarchical'); ?>"<?php checked($hierarchical); ?> />
|
||||
<label for="<?php echo $this -> get_field_id('hierarchical'); ?>"><?php _e('Show hierarchy', 'pk_translate'); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_taxonomies() {
|
||||
|
||||
register_widget('PK_Widget_Portfolio_Categories');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_taxonomies');
|
||||
|
||||
?>
|
@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Recent_Posts extends WP_Widget {
|
||||
|
||||
function PK_Widget_Recent_Posts() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_recent_posts', 'description' => __('Displays the recent posts', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-recent-posts', __('Recent Posts', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_recent_posts';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_recent_posts', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
$r = new WP_Query(array('posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-recent-posts widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-recent-posts widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_recent_posts', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_recent_posts'])) {
|
||||
|
||||
delete_option('widget_recent_posts');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_recent_posts', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
$list_icon = (isset($instance['list_icon']) && !empty($instance['list_icon'])) ? $instance['list_icon'] : '';
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_recent_posts() {
|
||||
|
||||
unregister_widget('WP_Widget_Recent_Posts');
|
||||
register_widget('PK_Widget_Recent_Posts');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_recent_posts');
|
||||
|
||||
?>
|
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Recent_Works extends WP_Widget {
|
||||
|
||||
function PK_Widget_Recent_Works() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_recent_works', 'description' => __('Displays the recent works', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-recent-works', __('Recent Works', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_recent_works';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_recent_works', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
$r = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-recent-works widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-recent-works widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_recent_works', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_recent_works'])) {
|
||||
|
||||
delete_option('widget_recent_works');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_recent_works', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of works to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_recent_works() {
|
||||
|
||||
register_widget('PK_Widget_Recent_Works');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_recent_works');
|
||||
|
||||
?>
|
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Related_Posts extends WP_Widget {
|
||||
|
||||
function PK_Widget_Related_Posts() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_related_posts', 'description' => __('Displays the related posts', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-related-posts', __('Related Posts', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_related_posts';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_related_posts', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
global $post;
|
||||
|
||||
if (isset($post) && $post -> post_type == 'post') {
|
||||
|
||||
$tags = wp_get_post_tags($post -> ID);
|
||||
$tag_ids = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($tags) && $tags) {
|
||||
|
||||
$tagcount = count($tags);
|
||||
|
||||
for ($i = 0; $i < $tagcount; $i++) {
|
||||
|
||||
$tag_ids[$i] = $tags[$i] -> term_id;
|
||||
|
||||
}
|
||||
|
||||
$r = new WP_Query(array('post_type' => $post -> post_type, 'posts_per_page' => $number, 'tag__in' => $tag_ids, 'post__not_in' => array($post -> ID), 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'order' => 'DESC'));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-related-posts widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-related-posts widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_related_posts', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_related_posts'])) {
|
||||
|
||||
delete_option('widget_related_posts');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_related_posts', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
$list_icon = (isset($instance['list_icon']) && !empty($instance['list_icon'])) ? $instance['list_icon'] : '';
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of posts to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_related_posts() {
|
||||
|
||||
register_widget('PK_Widget_Related_Posts');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_related_posts');
|
||||
|
||||
?>
|
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Related_Works extends WP_Widget {
|
||||
|
||||
function PK_Widget_Related_Works() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_related_works', 'description' => __('Displays the related works', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-related-works', __('Related Works', 'pk_translate'), $widget_ops);
|
||||
$this -> alt_option_name = 'widget_related_works';
|
||||
|
||||
add_action('save_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('deleted_post', array(&$this, 'flush_widget_cache'));
|
||||
add_action('switch_theme', array(&$this, 'flush_widget_cache'));
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
$cache = wp_cache_get('widget_related_works', 'widget');
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
|
||||
if (!is_array($cache)) {
|
||||
|
||||
$cache = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($cache[$args['widget_id']])) {
|
||||
|
||||
echo $cache[$args['widget_id']];
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
extract($args);
|
||||
|
||||
global $post;
|
||||
|
||||
if (isset($post) && $post -> post_type == 'portfolio') {
|
||||
|
||||
$terms = wp_get_post_terms($post -> ID, 'taxonomy_portfolio');
|
||||
|
||||
$terms_ids = array();
|
||||
$post_in = array();
|
||||
|
||||
}
|
||||
|
||||
if (isset($terms) && $terms) {
|
||||
|
||||
foreach ($terms as $term) {
|
||||
|
||||
$terms_ids[] = $term -> term_id;
|
||||
|
||||
}
|
||||
|
||||
$works_to_query = array_unique(get_objects_in_term($terms_ids, 'taxonomy_portfolio'));
|
||||
|
||||
$total_works_to_query = count($works_to_query);
|
||||
|
||||
for ($i = 0; $i < $total_works_to_query; $i++) {
|
||||
|
||||
if (isset($works_to_query[$i]) && $works_to_query[$i] != $post -> ID) {
|
||||
|
||||
$post_in[] = $works_to_query[$i];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$r = new WP_Query(array('post_type' => $post -> post_type, 'posts_per_page' => $number, 'post__in' => $post_in, 'nopaging' => 0, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'orderby' => 'comment_count', 'order' => 'DESC'));
|
||||
|
||||
if ($r -> have_posts()) :
|
||||
|
||||
echo '<!-- pk start pk-related-works widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) echo $before_title.$title.$after_title;
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
while ($r -> have_posts()) :
|
||||
|
||||
$r -> the_post();
|
||||
?>
|
||||
<li<?php if (!has_post_thumbnail()) echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (has_post_thumbnail()) the_post_thumbnail('thumb'); ?>
|
||||
|
||||
<div>
|
||||
<h5><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h5>
|
||||
<?php add_filter('excerpt_length', 'pk_widgets_excerpt_filter'); add_filter('excerpt_more', 'pk_excerpt_more'); the_excerpt(); ?>
|
||||
</div>
|
||||
</li>
|
||||
<?php
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-related-works widget -->
|
||||
|
||||
';
|
||||
|
||||
endif;
|
||||
|
||||
wp_reset_postdata();
|
||||
|
||||
$cache[$args['widget_id']] = ob_get_flush();
|
||||
|
||||
wp_cache_set('widget_related_works', $cache, 'widget');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = (int) $new_instance['number'];
|
||||
|
||||
$this -> flush_widget_cache();
|
||||
|
||||
$alloptions = wp_cache_get('alloptions', 'options');
|
||||
|
||||
if (isset($alloptions['widget_related_works'])) {
|
||||
|
||||
delete_option('widget_related_works');
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function flush_widget_cache() {
|
||||
|
||||
wp_cache_delete('widget_related_works', 'widget');
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 5;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of works to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" size="3" /></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_related_works() {
|
||||
|
||||
register_widget('PK_Widget_Related_Works');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_related_works');
|
||||
|
||||
?>
|
@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Sub_Navigation extends WP_Widget {
|
||||
|
||||
function PK_Widget_Sub_Navigation() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_sub_navigation', 'description' => __('Displays sub navigation', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-sub-navigation',__('Sub Navigation', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
global $post;
|
||||
|
||||
if (!isset($post)) return;
|
||||
|
||||
$children = wp_list_pages('echo=0&child_of=' . $post -> ID . '&title_li=');
|
||||
|
||||
if ($children) {
|
||||
|
||||
$parent = $post -> ID;
|
||||
|
||||
} else {
|
||||
|
||||
$parent = $post -> post_parent;
|
||||
|
||||
if (!$parent) {
|
||||
|
||||
$parent = $post -> ID;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$parent_title = get_the_title($parent);
|
||||
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? $parent_title : $instance['title'], $instance, $this -> id_base);
|
||||
$sortby = empty($instance['sortby']) ? 'menu_order' : $instance['sortby'];
|
||||
$exclude = empty($instance['exclude']) ? '' : $instance['exclude'];
|
||||
|
||||
$output = wp_list_pages(array('title_li' => '', 'echo' => 0, 'child_of' => $parent, 'sort_column' => $sortby, 'exclude' => $exclude, 'depth' => 1));
|
||||
|
||||
if (!empty($output)) {
|
||||
|
||||
echo '<!-- pk start pk-sub-navigation widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
echo str_replace("<li", "\t\t<li", $output);
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-sub-navigation widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
|
||||
if (in_array($new_instance['sortby'], array('post_title', 'menu_order', 'ID'))) {
|
||||
|
||||
$instance['sortby'] = $new_instance['sortby'];
|
||||
|
||||
} else {
|
||||
|
||||
$instance['sortby'] = 'menu_order';
|
||||
|
||||
}
|
||||
|
||||
$instance['exclude'] = strip_tags($new_instance['exclude']);
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$instance = wp_parse_args((array) $instance, array('sortby' => 'menu_order', 'title' => '', 'exclude' => ''));
|
||||
$title = esc_attr($instance['title']);
|
||||
$exclude = esc_attr($instance['exclude']);
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('sortby'); ?>"><?php _e('Sort by:', 'pk_translate'); ?></label>
|
||||
<select name="<?php echo $this -> get_field_name('sortby'); ?>" id="<?php echo $this -> get_field_id('sortby'); ?>" class="widefat">
|
||||
<option value="menu_order"<?php selected($instance['sortby'], 'menu_order'); ?>><?php _e('Menu order', 'pk_translate'); ?></option>
|
||||
<option value="post_title"<?php selected($instance['sortby'], 'post_title'); ?>><?php _e('Page title', 'pk_translate'); ?></option>
|
||||
<option value="ID"<?php selected($instance['sortby'], 'ID'); ?>><?php _e('Page ID', 'pk_translate'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label for="<?php echo $this -> get_field_id('exclude'); ?>"><?php _e('Exclude:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('exclude'); ?>" name="<?php echo $this -> get_field_name('exclude'); ?>" type="text" value="<?php echo $exclude; ?>" />
|
||||
<br /><small><?php _e('Page IDs, separated by commas.' ,'pk_translate'); ?></small>
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_sub_navigation() {
|
||||
|
||||
register_widget('PK_Widget_Sub_Navigation');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_sub_navigation');
|
@ -0,0 +1,145 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Testimonials extends WP_Widget {
|
||||
|
||||
function PK_Widget_Testimonials() {
|
||||
|
||||
$widget_ops = array('classname' => 'widget_testimonials', 'description' => __('Displays testimonials', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-testimonials', __('Testimonials', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$number = absint($instance['number']);
|
||||
$instance_testimonials_cite = array();
|
||||
$instance_testimonials_quote = array();
|
||||
|
||||
for ($i = 1; $i <= $number; $i++) {
|
||||
|
||||
$testimonials_thumb = 'testimonials_'.$i.'_thumb';
|
||||
$instance_testimonials_thumb[$i] = isset($instance[$testimonials_thumb]) ? $instance[$testimonials_thumb] : '';
|
||||
$testimonials_cite = 'testimonials_'.$i.'_cite';
|
||||
$instance_testimonials_cite[$i] = isset($instance[$testimonials_cite]) ? $instance[$testimonials_cite] : '';
|
||||
$testimonials_quote = 'testimonials_'.$i.'_quote';
|
||||
$instance_testimonials_quote[$i] = isset($instance[$testimonials_quote]) ? $instance[$testimonials_quote] : '';
|
||||
|
||||
}
|
||||
|
||||
echo '<!-- pk start pk-testimonials widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="pk_testimonials">
|
||||
<ul>
|
||||
<?php
|
||||
for ($i = 1; $i <= $number; $i++) :
|
||||
?>
|
||||
<li<?php if (trim($instance_testimonials_thumb[$i]) == '') echo ' class="pk_no_thumbnail"'; ?>>
|
||||
<?php if (trim($instance_testimonials_thumb[$i]) != '') : ?>
|
||||
<img src="<?php echo trim($instance_testimonials_thumb[$i]); ?>" alt="" />
|
||||
<?php endif; ?>
|
||||
<blockquote>
|
||||
<p><?php echo $instance_testimonials_quote[$i]; ?></p>
|
||||
<cite><?php echo $instance_testimonials_cite[$i];?></cite>
|
||||
</blockquote>
|
||||
</li>
|
||||
<?php
|
||||
endfor;
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-testimonials widget -->
|
||||
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['number'] = $new_instance['number'];
|
||||
for ($i = 1; $i <= absint($instance['number']); $i++) {
|
||||
|
||||
$instance['testimonials_'.$i.'_thumb'] = $new_instance['testimonials_'.$i.'_thumb'];
|
||||
$instance['testimonials_'.$i.'_cite'] = $new_instance['testimonials_'.$i.'_cite'];
|
||||
$instance['testimonials_'.$i.'_quote'] = $new_instance['testimonials_'.$i.'_quote'];
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$number = isset($instance['number']) ? absint($instance['number']) : 1;
|
||||
$instance_testimonials_thumb = array();
|
||||
$instance_testimonials_cite = array();
|
||||
$instance_testimonials_quote = array();
|
||||
|
||||
for ($i = 1; $i <= $number; $i++) {
|
||||
|
||||
$testimonials_thumb = 'testimonials_'.$i.'_thumb';
|
||||
$instance_testimonials_thumb[$i] = isset($instance[$testimonials_thumb]) ? $instance[$testimonials_thumb] : '';
|
||||
$testimonials_cite = 'testimonials_'.$i.'_cite';
|
||||
$instance_testimonials_cite[$i] = isset($instance[$testimonials_cite]) ? $instance[$testimonials_cite] : '';
|
||||
$testimonials_quote = 'testimonials_'.$i.'_quote';
|
||||
$instance_testimonials_quote[$i] = isset($instance[$testimonials_quote]) ? $instance[$testimonials_quote] : '';
|
||||
|
||||
}
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of testimonials to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
|
||||
<div>
|
||||
<?php for ($i = 1; $i <= $number; $i++) : $testimonials_thumb = 'testimonials_'.$i.'_thumb'; $testimonials_cite = 'testimonials_'.$i.'_cite'; $testimonials_quote = 'testimonials_'.$i.'_quote'; ?>
|
||||
<div>
|
||||
<p><strong><?php _e('Testimonial', 'pk_translate'); ?> <?php echo $i; ?>:</strong></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($testimonials_thumb); ?>"><?php _e('Thumbnail URL:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($testimonials_thumb); ?>" name="<?php echo $this -> get_field_name($testimonials_thumb); ?>" type="text" value="<?php echo $instance_testimonials_thumb[$i]; ?>" /></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($testimonials_cite); ?>"><?php _e('Cite:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id($testimonials_cite); ?>" name="<?php echo $this -> get_field_name($testimonials_cite); ?>" type="text" value="<?php echo $instance_testimonials_cite[$i]; ?>" /></p>
|
||||
<p><label for="<?php echo $this -> get_field_id($testimonials_quote); ?>"><?php _e('Quote:', 'pk_translate'); ?></label>
|
||||
<textarea class="widefat" rows="10" cols="10" id="<?php echo $this -> get_field_id($testimonials_quote); ?>" name="<?php echo $this -> get_field_name($testimonials_quote); ?>"><?php echo $instance_testimonials_quote[$i]; ?></textarea></p>
|
||||
</div>
|
||||
<?php endfor;?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_testimonials() {
|
||||
|
||||
register_widget('PK_Widget_Testimonials');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_testimonials');
|
||||
|
||||
?>
|
@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
class PK_Widget_Twitter extends WP_Widget {
|
||||
|
||||
function PK_Widget_Twitter(){
|
||||
|
||||
$widget_ops = array('classname' => 'widget_twitter', 'description' => __('Display your Twitter updates', 'pk_translate'));
|
||||
$this -> WP_Widget('pk-twitter', __('Twitter', 'pk_translate'), $widget_ops);
|
||||
|
||||
}
|
||||
|
||||
function widget($args, $instance) {
|
||||
|
||||
extract($args);
|
||||
|
||||
$title = apply_filters('widget_title', $instance['title']);
|
||||
|
||||
if (empty($title)) $title = false;
|
||||
|
||||
$username = (isset($instance['username'])) ? urlencode($instance['username']) : '';
|
||||
|
||||
if (empty($username)) return;
|
||||
|
||||
$number = (isset($instance['number'])) ? absint($instance['number']) : 5;
|
||||
|
||||
$show_follow = ($instance['show_follow'] == 1) ? true : false;
|
||||
|
||||
$total = 0;
|
||||
|
||||
echo '<!-- pk start pk-twitter widget -->
|
||||
'.$before_widget.'
|
||||
';
|
||||
|
||||
if ($title) {
|
||||
|
||||
echo $before_title;
|
||||
echo $title;
|
||||
echo $after_title;
|
||||
|
||||
}
|
||||
|
||||
require_once(ABSPATH.WPINC.'/feed.php');
|
||||
|
||||
$twitter_feed_url = "http://api.twitter.com/1/statuses/user_timeline.rss?screen_name=$username";
|
||||
|
||||
$transients = get_option('pk_twitter_transients');
|
||||
$transients[] = $args['widget_id'];
|
||||
update_option('pk_twitter_transients', array_unique($transients));
|
||||
|
||||
$cache = get_transient($args['widget_id']);
|
||||
|
||||
if ($cache) {
|
||||
|
||||
echo $cache;
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
$feed = fetch_feed($twitter_feed_url);
|
||||
|
||||
}
|
||||
|
||||
if (!is_wp_error($feed)) {
|
||||
|
||||
$total = $feed -> get_item_quantity($number);
|
||||
$items = $feed -> get_items(0, $total);
|
||||
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
||||
if ($total == 0) :
|
||||
|
||||
echo '<p>'.__('The Twitter feed is either empty or unavailable. Please check back later.', 'pk_translate').'</p>';
|
||||
|
||||
else:
|
||||
?>
|
||||
|
||||
<ul>
|
||||
<?php
|
||||
foreach ($items as $item) :
|
||||
|
||||
$text = $item -> get_title();
|
||||
$link = $item -> get_permalink();
|
||||
$time = $item -> get_date();
|
||||
|
||||
$text = strstr($text, ': ');
|
||||
$text = substr($text, 2);
|
||||
$text = make_clickable($text);
|
||||
$text = preg_replace_callback('/(^|\s)@(\w+)/', array($this, '_widget_twitter_username'), $text);
|
||||
$text = preg_replace_callback('/(^|\s)#(\w+)/', array($this, '_widget_twitter_hashtag'), $text);
|
||||
|
||||
$time = str_replace(' ', ' ', $time);
|
||||
?>
|
||||
<li><?php echo $text; ?> <small><a href="<?php echo $link; ?>" rel="external nofollow"><?php echo $time; ?></a></small></li>
|
||||
<?php
|
||||
endforeach;
|
||||
|
||||
if ($show_follow) :
|
||||
?>
|
||||
<li><a class="follow" href="http://twitter.com/#!/<?php echo $username ?>"><?php printf(__('Follow @%s on Twitter', 'pk_translate'), $username); ?></a></li>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</ul>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
echo $after_widget.'
|
||||
<!-- pk end pk-twitter widget -->
|
||||
|
||||
';
|
||||
|
||||
set_transient($args['widget_id'], ob_get_flush(), 3600);
|
||||
|
||||
}
|
||||
|
||||
function update($new_instance, $old_instance) {
|
||||
|
||||
$instance = $old_instance;
|
||||
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['username'] = $new_instance['username'];
|
||||
$instance['number'] = $new_instance['number'];
|
||||
$instance['show_follow'] = isset($new_instance['show_follow']) ? 1 : 0;
|
||||
|
||||
$transients = get_option('pk_twitter_transients');
|
||||
|
||||
foreach ($transients as $transient) {
|
||||
|
||||
delete_transient($transient);
|
||||
|
||||
}
|
||||
|
||||
return $instance;
|
||||
|
||||
}
|
||||
|
||||
function _widget_twitter_username($matches) {
|
||||
|
||||
return "$matches[1]@<a href='".esc_url('http://twitter.com/'.urlencode($matches[2]))."'>$matches[2]</a>";
|
||||
|
||||
}
|
||||
|
||||
function _widget_twitter_hashtag($matches) {
|
||||
|
||||
return "$matches[1]<a href='".esc_url('http://search.twitter.com/search?q=%23'.urlencode($matches[2]))."'>#$matches[2]</a>";
|
||||
|
||||
}
|
||||
|
||||
function form($instance) {
|
||||
|
||||
$title = isset($instance['title']) ? esc_attr($instance['title']) : '';
|
||||
$username = (isset($instance['username'])) ? $instance['username'] : '';
|
||||
$number = (isset($instance['number'])) ? absint($instance['number']) : 5;
|
||||
$show_follow = isset($instance['show_follow']) ? 1 : 0;
|
||||
?>
|
||||
<p><label for="<?php echo $this -> get_field_id('title'); ?>"><?php _e('Title:', 'pk_translate'); ?></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 $title; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('username'); ?>"><?php _e('Twitter username:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('username'); ?>" name="<?php echo $this -> get_field_name('username'); ?>" type="text" value="<?php echo $username; ?>" /></p>
|
||||
|
||||
<p><label for="<?php echo $this -> get_field_id('number'); ?>"><?php _e('Number of tweets to show:', 'pk_translate'); ?></label>
|
||||
<input class="widefat" id="<?php echo $this -> get_field_id('number'); ?>" name="<?php echo $this -> get_field_name('number'); ?>" type="text" value="<?php echo $number; ?>" /></p>
|
||||
|
||||
<p><input class="checkbox" type="checkbox" <?php checked($show_follow, true) ?> id="<?php echo $this -> get_field_id('show_follow'); ?>" name="<?php echo $this -> get_field_name('show_follow'); ?>" />
|
||||
<label for="<?php echo $this -> get_field_id('show_follow'); ?>"><?php _e('Show follow link', 'pk_translate'); ?></label></p>
|
||||
<?php
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function pk_widgets_twitter() {
|
||||
|
||||
register_widget('PK_Widget_Twitter');
|
||||
|
||||
}
|
||||
|
||||
add_action('widgets_init', 'pk_widgets_twitter');
|
||||
|
||||
?>
|
Reference in New Issue
Block a user