first commit

This commit is contained in:
alazhar
2020-01-02 23:15:16 +07:00
commit eda9661806
3433 changed files with 595883 additions and 0 deletions

View File

@ -0,0 +1,101 @@
<?php
/**
* Plugin Name: 1/1 Goodlayers Banner Widget
* Plugin URI: http://goodlayers.com/
* Description: Full size banner widget
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'goodlayers_1_1_banner_init' );
function goodlayers_1_1_banner_init(){
register_widget('Goodlayers_1_1_Banner_widget');
}
class Goodlayers_1_1_Banner_widget extends WP_Widget{
// Initialize the widget
function Goodlayers_1_1_Banner_widget(){
parent::WP_Widget('goodlayers-1-1-banner-widget', __('1/1 Banner Widget (Goodlayers)','gdl_back_office'),
array('description' => __('Full size banner widget (266 px)', 'gdl_back_office')));
}
// Output of the widget
function widget($args, $instance) {
global $wpdb;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$image = apply_filters( 'widget_title', $instance['image'] );
$link = apply_filters( 'widget_title', $instance['link'] );
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
echo '<div class="under-banner-title"></div>';
}
echo '<div class="banner-widget1-1">';
echo '<a href="' . $link . '" target="_blank">';
echo '<img src="' . $image . '" alt="banner" />';
echo '</a>';
echo '</div>'; // 1-1 Banner Widget
echo $after_widget;
}
// Widget Form
function form($instance) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$image = esc_attr( $instance[ 'image' ] );
$link = esc_attr( $instance[ 'link' ] );
} else {
$title = '';
$image = '';
$link = '';
}
?>
<!-- Title -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Image -->
<p>
<label for="<?php echo $this->get_field_id('image'); ?>"><?php _e( 'Banner Image URL :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="text" value="<?php echo $image; ?>" />
</p>
<!-- Link -->
<p>
<label for="<?php echo $this->get_field_id('link'); ?>"><?php _e( 'Banner Link :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo $link; ?>" />
</p>
<?php
}
// Update the widget
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['image'] = strip_tags($new_instance['image']);
$instance['link'] = strip_tags($new_instance['link']);
return $instance;
}
}
?>

View File

@ -0,0 +1,149 @@
<?php
/**
* Plugin Name: 1/2 Goodlayers Banner Widget
* Plugin URI: http://goodlayers.com/
* Description: Half size banner widget
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'goodlayers_1_2_banner_init' );
function goodlayers_1_2_banner_init(){
register_widget('Goodlayers_1_2_Banner_widget');
}
class Goodlayers_1_2_Banner_widget extends WP_Widget{
// Initialize the widget
function Goodlayers_1_2_Banner_widget() {
parent::WP_Widget('goodlayers-1-2-banner-widget', __('1/2 Banner Widget (Goodlayers)','gdl_back_office'),
array('description' => __('Half size banner widget (116 px)', 'gdl_back_office')));
}
// Output of the widget
function widget($args, $instance) {
global $wpdb;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$image = apply_filters( 'widget_title', $instance['image'] );
$link = apply_filters( 'widget_title', $instance['link'] );
$image2 = apply_filters( 'widget_title', $instance['image2'] );
$link2 = apply_filters( 'widget_title', $instance['link2'] );
$bottom_margin = apply_filters( 'widget_title', $instance['bottom_margin'] );
if( empty($title) ){
echo '<div class="banner-widget1-2-outer-wrapper without-title">';
}else{
echo '<div class="banner-widget1-2-outer-wrapper">';
}
echo $before_widget;
// Open of title tag
if($title){
echo $before_title . $title . $after_title;
}
echo '<div class="clear"></div>';
echo '<div class="banner-widget1-2-wrapper mb' . $bottom_margin . '">';
echo '<div class="banner-widget1-2" >';
echo '<div class="left" >';
echo '<a href="' . $link . '" target="_blank">';
echo '<img src="' . $image . '" alt="banner" />';
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="banner-widget1-2" >';
echo '<div class="right" >';
echo '<a href="' . $link2 . '" target="_blank">';
echo '<img src="' . $image2 . '" alt="banner"/>';
echo '</a>';
echo '</div>';
echo '</div>';
echo '<div class="clear"></div>';
echo '</div>'; // 1-2 Banner Widget Wrapper
echo $after_widget;
echo '</div>';
}
// Widget Form
function form($instance) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$image = esc_attr( $instance[ 'image' ] );
$link = esc_attr( $instance[ 'link' ] );
$image2 = esc_attr( $instance[ 'image2' ] );
$link2 = esc_attr( $instance[ 'link2' ] );
$bottom_margin = esc_attr( $instance[ 'bottom_margin' ] );
} else {
$title = '';
$image = '';
$link = '';
$image2 = '';
$link2 = '';
$bottom_margin = 40;
}
?>
<!-- Title -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Image -->
<p>
<label for="<?php echo $this->get_field_id('image'); ?>"><?php _e( 'Banner Image URL :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('image'); ?>" name="<?php echo $this->get_field_name('image'); ?>" type="text" value="<?php echo $image; ?>" />
</p>
<!-- Link -->
<p>
<label for="<?php echo $this->get_field_id('link'); ?>"><?php _e( 'Banner Link :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('link'); ?>" name="<?php echo $this->get_field_name('link'); ?>" type="text" value="<?php echo $link; ?>" />
</p>
<!-- Image2 -->
<p>
<label for="<?php echo $this->get_field_id('image2'); ?>"><?php _e( 'Banner Image URL 2 :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('image2'); ?>" name="<?php echo $this->get_field_name('image2'); ?>" type="text" value="<?php echo $image2; ?>" />
</p>
<!-- Link2 -->
<p>
<label for="<?php echo $this->get_field_id('link2'); ?>"><?php _e( 'Banner Link 2 :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('link2'); ?>" name="<?php echo $this->get_field_name('link2'); ?>" type="text" value="<?php echo $link2; ?>" />
</p>
<!-- Bottom Margin -->
<p>
<label for="<?php echo $this->get_field_id('bottom_margin'); ?>"><?php _e( 'Bottom Margin :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('bottom_margin'); ?>" name="<?php echo $this->get_field_name('bottom_margin'); ?>" type="text" value="<?php echo $bottom_margin; ?>" />
</p>
<?php
}
// Update the widget
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['image'] = strip_tags($new_instance['image']);
$instance['link'] = strip_tags($new_instance['link']);
$instance['image2'] = strip_tags($new_instance['image2']);
$instance['link2'] = strip_tags($new_instance['link2']);
$instance['bottom_margin'] = strip_tags($new_instance['bottom_margin']);
return $instance;
}
}
?>

View File

@ -0,0 +1,134 @@
<?php
/**
* Plugin Name: Goodlayers Contact Widget
* Plugin URI: http://goodlayers.com/
* Description: A widget that show recent posts( Specified by category ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'contact_widget' );
function contact_widget() {
register_widget( 'Contact' );
}
class Contact extends WP_Widget {
// Initialize the widget
function Contact() {
parent::WP_Widget('contact-widget', __('Contact Form Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A contact form widget.', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$email = $instance['email'];
wp_reset_query();
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
global $gdl_admin_translator;
if( $gdl_admin_translator == 'enable' ){
$gdl_name_string = get_option(THEME_SHORT_NAME.'_translator_name_contact_form', 'Name');
$gdl_name_error_string = get_option(THEME_SHORT_NAME.'_translator_name_error_contact_form', 'Please enter your name');
$gdl_email_string = get_option(THEME_SHORT_NAME.'_translator_email_contact_form', 'Email');
$gdl_email_error_string = get_option(THEME_SHORT_NAME.'_translator_email_error_contact_form', 'Please enter a valid email address');
$gdl_message_string = get_option(THEME_SHORT_NAME.'_translator_message_contact_form', 'Message');
$gdl_message_error_string = get_option(THEME_SHORT_NAME.'_translator_message_error_contact_form', 'Please enter message');
$gdl_submit_button = get_option(THEME_SHORT_NAME.'_translator_submit_contact_form','Submit');
}else{
$gdl_name_string = __('Name','gdl_front_end');
$gdl_name_error_string = __('Please enter your name','gdl_front_end');
$gdl_email_string = __('Email','gdl_front_end');
$gdl_email_error_string = __('Please enter a valid email address','gdl_front_end');
$gdl_message_string = __('Message','gdl_front_end');
$gdl_message_error_string = __('Please enter message','gdl_front_end');
$gdl_submit_button = __('Submit','gdl_front_end');
}
?>
<div class="contact-form-wrapper">
<form class="gdl-contact-form">
<ol class="forms">
<li class="form-input">
<strong><?php echo $gdl_name_string; ?> *</strong>
<input type="text" name="name" class="require-field" />
<div class="error">* <?php echo $gdl_name_error_string; ?></div>
</li>
<li class="form-input">
<strong><?php echo $gdl_email_string; ?> *</strong>
<input type="text" name="email" class="require-field email" />
<div class="error">* <?php echo $gdl_email_error_string; ?></div>
</li>
<li class="form-textarea"><strong><?php echo $gdl_message_string; ?> *</strong>
<textarea name="message" class="require-field"></textarea>
<div class="error">* <?php echo $gdl_message_error_string; ?></div>
</li>
<li class="hidden"><input type="hidden" name="receiver" value="<?php echo $email; ?>"></li>
<li class="sending-result" id="sending-result" ><div class="message-box-wrapper green"></div></li>
<li class="buttons">
<button type="submit" class="contact-submit button"><?php echo $gdl_submit_button; ?></button>
<div class="contact-loading"></div>
</li>
</ol>
</form>
<div class="clear"></div>
</div>
<?php
// Closing of widget
echo $after_widget;
wp_deregister_script('contact-form');
wp_register_script('contact-form', GOODLAYERS_PATH.'/javascript/gdl-contactform.js', false, '1.0', true);
wp_localize_script( 'contact-form', 'MyAjax', array( 'ajaxurl' => AJAX_URL ) );
wp_enqueue_script('contact-form');
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$email = esc_attr( $instance[ 'email' ] );
} else {
$title = '';
$email = '';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('email'); ?>"><?php _e( 'Email :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" type="text" value="<?php echo $email; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['email'] = strip_tags( $new_instance['email'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,152 @@
<?php
/**
* Plugin Name: Goodlayers Recent Post
* Plugin URI: http://goodlayers.com/
* Description: A widget that show recent posts( Specified by category ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'recent_post_widget' );
function recent_post_widget() {
register_widget( 'Recent_Post' );
}
class Recent_Post extends WP_Widget {
// Initialize the widget
function Recent_Post() {
parent::WP_Widget('recent-post-widget', __('Recent Post Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show lastest posts', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format, $blog_port_widget_size;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$post_cat = $instance['post_cat'];
$show_num = $instance['show_num'];
if($post_cat == "All"){ $post_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
wp_reset_query();
$current_post = array(get_the_ID());
$custom_posts = get_posts( array('showposts'=>$show_num, 'category_name'=>$post_cat,
'post__not_in'=>$current_post) );
if( !empty($custom_posts) ){
echo "<div class='gdl-recent-post-widget'>";
foreach($custom_posts as $custom_post) {
?>
<div class="recent-post-widget">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $blog_port_widget_size );
if( $thumbnail_id ){
echo '<div class="recent-post-widget-thumbnail">';
echo '<a href="' . get_permalink( $custom_post->ID ) . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '</div>';
}
?>
<div class="recent-post-widget-context">
<h4 class="recent-post-widget-title">
<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
<?php _e( $custom_post->post_title, 'gdl_front_end'); ?>
</a>
</h4>
<div class="recent-post-widget-info">
<div class="recent-post-widget-date">
<?php
echo '<a href="' . get_day_link( get_the_time('Y', $custom_post->ID), get_the_time('m', $custom_post->ID), get_the_time('d', $custom_post->ID)) . '" >';
echo __('Posted On' , 'gdl_front_end');
echo get_the_time($gdl_widget_date_format, $custom_post->ID);
echo '</a>';
?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
echo "</div>";
}
// Closing of widget
echo $after_widget;
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$post_cat = esc_attr( $instance[ 'post_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$post_cat = '';
$show_num = '3';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Post Category -->
<p>
<label for="<?php echo $this->get_field_id( 'post_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'post_cat' ); ?>" id="<?php echo $this->get_field_id( 'post_cat' ); ?>">
<?php
$category_list = get_category_list( 'category' );
foreach($category_list as $category){
?>
<option value="<?php echo $category; ?>" <?php if ( $post_cat == $category ) echo ' selected="selected"'; ?>><?php echo $category; ?></option>
<?php } ?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['post_cat'] = strip_tags( $new_instance['post_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,208 @@
<?php
/**
* Plugin Name: Goodlayers News Widget
* Plugin URI: http://goodlayers.com/
* Description: Goodlayers News Widget that grab the latest post, popular post and latest comment.
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'goodlayers_news_widget_init' );
function goodlayers_news_widget_init(){
register_widget('Goodlayers_news_widget');
}
class Goodlayers_news_widget extends WP_Widget {
// Initialize the widget
function Goodlayers_news_widget() {
parent::WP_Widget('goodlayers-news-widget', __('Tab Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show lastest posts, popular post and latest comments', 'gdl_back_office')));
}
// Output of the widget
function widget($args, $instance) {
global $gdl_widget_date_format;;
extract( $args );
$num_fetch = $instance['num_fetch'];
$category = $instance['category'];
if($category == "All"){ $category = ''; }
echo $before_widget;
$query_arrays = array(
array('id'=>'gdl-widget-latest-post', 'title'=> __('RECENT','gdl_front_end'), 'type'=>'post',
'condition'=>'showposts=' . $num_fetch . '&category_name=' . $category),
array('id'=>'gdl-widget-popular-post', 'title'=> __('POPULAR','gdl_front_end'), 'type'=>'post',
'condition'=>'showposts=' . $num_fetch . '&category_name=' . $category . '&orderby=comment_count'),
array('id'=>'gdl-widget-latest-comment', 'title'=> __('COMMENTS','gdl_front_end'), 'type'=>'comment' )
);
echo '<div class="gdl-tab-widget-wrapper">';
// Tab header
$current_tab = ' active ';
echo '<div class="gdl-tab-widget-header-wrapper">';
foreach( $query_arrays as $query_array ){
echo '<h4 class="gdl-tab-widget-header-item">';
echo '<a class="' . $current_tab . '" data-id="' . $query_array['id'] . '">';
echo $query_array['title'];
echo '</a>';
echo '</h4>';
$current_tab = '';
}
echo '<div class="clear"></div>';
echo '</div>'; // gdl-tab-widget-header-wrapper
// Tab content
$current_tab = ' active ';
echo '<div class="gdl-tab-widget-content-wrapper">';
foreach( $query_arrays as $query_array ){
echo '<div class="gdl-tab-widget-content-item ' . $current_tab . '" data-id="' . $query_array['id'] . '">';
if( $query_array['type'] == 'post'){
$custom_posts = get_posts($query_array['condition']);
echo '<div class="gdl-recent-post-widget">';
foreach( $custom_posts as $custom_post ){
?>
<div class="recent-post-widget">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , '75x55' );
if( $thumbnail_id ){
echo '<div class="recent-post-widget-thumbnail">';
echo '<a href="' . get_permalink( $custom_post->ID ) . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '</div>';
}
?>
<div class="recent-post-widget-context">
<h4 class="recent-post-widget-title">
<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
<?php _e( $custom_post->post_title, 'gdl_front_end'); ?>
</a>
</h4>
<div class="recent-post-widget-info">
<div class="recent-post-widget-date">
<?php
echo '<a href="' . get_day_link( get_the_time('Y', $custom_post->ID), get_the_time('m', $custom_post->ID), get_the_time('d', $custom_post->ID)) . '" >';
echo __('Posted On' , 'gdl_front_end') . ' ';
echo get_the_time($gdl_widget_date_format, $custom_post->ID);
echo '</a>';
?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
echo '</div>';
}else{
$posts_in_cat = get_post_title_id($category);
$recent_comments = get_comments( array('post_id__in'=>$posts_in_cat, 'number'=>$num_fetch, 'status'=>'approve') );
echo '<div class="gdl-recent-comment-widget">';
foreach( $recent_comments as $recent_comment ){
$comment_permalink = get_permalink( $recent_comment->comment_post_ID ) . '#comment-' . $recent_comment->comment_ID
?>
<div class="recent-comment-widget" >
<div class="recent-comment-widget-thumbnail">
<a href="<?php echo $comment_permalink; ?>">
<?php echo get_avatar( $recent_comment->user_id, 55 ); ?>
</a>
</div>
<div class="recent-comment-widget-context">
<h4 class="recent-comment-widget-title">
<a href="<?php echo $comment_permalink; ?>">
<?php echo gdl_get_excerpt(45, '...', __($recent_comment->comment_content, 'gdl_front_end')); ?>
</a>
</h4>
<div class="recent-comment-widget-info">
<div class="recent-comment-widget-date">
<?php echo __('Posted On' , 'gdl_front_end'); ?>
<?php echo get_comment_date($gdl_widget_date_format, $recent_comment->comment_ID); ?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
echo '</div>';
}
echo '</div>';
$current_tab = '';
}
echo '</div>'; // gdl-tab-widget-content-wrapper
echo '<div class="clear"></div>';
echo '</div>'; // gdl-widget-tab
echo $after_widget;
wp_deregister_script('gdl-tab-widget');
wp_register_script('gdl-tab-widget', GOODLAYERS_PATH.'/javascript/gdl-tab-widget.js', false, '1.0', true);
wp_enqueue_script('gdl-tab-widget');
}
// Widget Form
function form($instance) {
if ( $instance ) {
$num_fetch = esc_attr( $instance[ 'num_fetch' ] );
$category = esc_attr( $instance[ 'category' ] );
} else {
$num_fetch = '3';
$category = '';
}
?>
<!-- Num Fetch -->
<p>
<label for="<?php echo $this->get_field_id('num_fetch'); ?>"><?php _e( 'Num Fetch :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('num_fetch'); ?>" name="<?php echo $this->get_field_name('num_fetch'); ?>" type="text" value="<?php echo $num_fetch; ?>" />
</p>
<!-- Post Category -->
<p>
<label for="<?php echo $this->get_field_id('category'); ?>"><?php _e( 'Category :', 'gdl_back_office' ); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" >
<?php
$category_lists = get_category_list('category');
foreach( $category_lists as $category_list ){
$selected = ( $category == $category_list )? 'selected': '';
echo '<option ' . $selected . '>' . $category_list . '</option>';
}
?>
</select>
</p>
<?php
}
// Update the widget
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['num_fetch'] = strip_tags($new_instance['num_fetch']);
$instance['category'] = strip_tags($new_instance['category']);
return $instance;
}
}
?>

View File

@ -0,0 +1,132 @@
<?php
/**
* Plugin Name: Goodlayers Recent Portfolio Widget 2
* Plugin URI: http://goodlayers.com/
* Description: A widget that show recent portfolio( Specified by portfolio-category ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'recent_port_widget2' );
function recent_port_widget2() {
register_widget( 'Recent_Port2' );
}
class Recent_Port2 extends WP_Widget {
// Initialize the widget
function Recent_Port2() {
parent::WP_Widget('recent-port-widget2', __('Recent Portfolio 2nd Style Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show last portfolio', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$port_cat = $instance['port_cat'];
$show_num = $instance['show_num'];
if($port_cat == "All"){ $port_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
wp_reset_query();
$current_post = array(get_the_ID());
$custom_posts = get_posts( array('post_type'=>'portfolio', 'suppress_filters' => 0, 'showposts'=>$show_num,
'portfolio-category'=>$port_cat, 'post__not_in'=>$current_post) );
if( !empty($custom_posts) ){
echo "<div class='gdl-recent-port-widget'>";
foreach($custom_posts as $custom_post) {
?>
<div class="recent-port-widget second-style">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , 'thumbnail' );
if( $thumbnail_id ){
echo '<div class="recent-port-widget-thumbnail">';
echo '<a href="' . get_permalink( $custom_post->ID ) . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '</div>';
}
?>
</div>
<?php
}
echo "<div class='clear'></div>";
echo "</div>";
}
// Closing of widget
echo $after_widget;
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$port_cat = esc_attr( $instance[ 'port_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$port_cat = '';
$show_num = '6';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Port Category -->
<p>
<label for="<?php echo $this->get_field_id( 'port_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'port_cat' ); ?>" id="<?php echo $this->get_field_id( 'port_cat' ); ?>">
<?php
$category_list = get_category_list( 'portfolio-category' );
foreach($category_list as $category){
?>
<option value="<?php echo $category; ?>" <?php if ( $port_cat == $category ) echo ' selected="selected"'; ?>><?php echo $category; ?></option>
<?php } ?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['port_cat'] = strip_tags( $new_instance['port_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,147 @@
<?php
/**
* Plugin Name: Goodlayers Recent Portfolio
* Plugin URI: http://goodlayers.com/
* Description: A widget that show recent portfolio( Specified by portfolio-category ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'recent_port_widget' );
function recent_port_widget() {
register_widget( 'Recent_Port' );
}
class Recent_Port extends WP_Widget {
// Initialize the widget
function Recent_Port() {
parent::WP_Widget('recent-port-widget', __('Recent Portfolio Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show last portfolio', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format, $blog_port_widget_size;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$port_cat = $instance['port_cat'];
$show_num = $instance['show_num'];
if($port_cat == "All"){ $port_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
wp_reset_query();
$current_post = array(get_the_ID());
$custom_posts = get_posts( array('post_type'=>'portfolio', 'suppress_filters' => 0, 'showposts'=>$show_num,
'portfolio-category'=>$port_cat, 'post__not_in'=>$current_post) );
if( !empty($custom_posts) ){
echo "<div class='gdl-recent-post-widget'>";
foreach($custom_posts as $custom_post) {
?>
<div class="recent-post-widget">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $blog_port_widget_size );
if( $thumbnail_id ){
echo '<div class="recent-post-widget-thumbnail">';
echo '<a href="' . get_permalink( $custom_post->ID ) . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '</div>';
}
?>
<div class="recent-post-widget-context">
<h4 class="recent-post-widget-title">
<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
<?php _e( $custom_post->post_title, 'gdl_front_end'); ?>
</a>
</h4>
<div class="recent-post-widget-info">
<div class="recent-post-widget-date">
<?php echo get_the_time($gdl_widget_date_format, $custom_post->ID); ?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
echo "</div>";
}
// Closing of widget
echo $after_widget;
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$port_cat = esc_attr( $instance[ 'port_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$port_cat = '';
$show_num = '3';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Port Category -->
<p>
<label for="<?php echo $this->get_field_id( 'port_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'port_cat' ); ?>" id="<?php echo $this->get_field_id( 'port_cat' ); ?>">
<?php
$category_list = get_category_list( 'portfolio-category' );
foreach($category_list as $category){
?>
<option value="<?php echo $category; ?>" <?php if ( $port_cat == $category ) echo ' selected="selected"'; ?>><?php echo $category; ?></option>
<?php } ?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['port_cat'] = strip_tags( $new_instance['port_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,114 @@
<?php
/**
* Plugin Name: Goodlayers Flickr Widget
* Plugin URI: http://goodlayers.com/
* Description: A widget that show photo from flickr
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'flickr_widget' );
function flickr_widget() {
register_widget( 'flickr' );
}
class flickr extends WP_Widget {
// Initialize the widget
function flickr() {
/* Widget settings. */
$widget_ops = array( 'classname' => 'flickr-widget', 'description' => __('A widget that show last flickr photo streams', 'gdl_back_office') );
/* Widget control settings. */
$control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'flickr-widget' );
/* Create the widget. */
$this->WP_Widget( 'flickr-widget', __('Flickr (Goodlayers)', 'gdl_back_office'), $widget_ops, $control_ops );
}
// Output of the widget
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters('widget_title', $instance['title'] );
$id = $instance['id'];
$how = $instance['how'];
$show_num = $instance['show_num'];
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
echo '<div class="flickr-widget">';
echo '<script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=' . $show_num . '&amp;display=' . $how . '&amp;size=s&amp;layout=x&amp;source=user&amp;user=' . $id . '"></script>';
echo '</div>';
echo '<div class="clear"></div>';
// Closing of widget
echo $after_widget;
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$id = esc_attr( $instance[ 'id' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
$how = esc_attr( $instance[ 'how' ] );
} else {
$title = '';
$id = '';
$show_num = '6';
$how = 'latest';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Flickr ID -->
<p>
<label for="<?php echo $this->get_field_id('id'); ?>"><?php _e( 'ID :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('id'); ?>" name="<?php echo $this->get_field_name('id'); ?>" type="text" value="<?php echo $id; ?>" />
</p>
<!-- Show Count -->
<p>
<label for="<?php echo $this->get_field_id('show_num'); ?>"><?php _e( 'Show Count ( up to 10 )', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('show_num'); ?>" name="<?php echo $this->get_field_name('show_num'); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<!-- How -->
<p>
<label for="<?php echo $this->get_field_id( 'how' ); ?>"><?php _e('Order By','gdl_back_office'); ?></label>
<select class="widefat" id="<?php echo $this->get_field_id( 'how' ); ?>" name="<?php echo $this->get_field_name( 'how' ); ?>">
<option <?php if ( 'latest' == $how ) echo 'selected="selected"'; ?> value="latest">latest</option>
<option <?php if ( 'random' == $how ) echo 'selected="selected"'; ?> value="random">random</option>
</select>
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['id'] = strip_tags( $new_instance['id'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
$instance['how'] = strip_tags( $new_instance['how'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,171 @@
<?php
/**
* Plugin Name: Goodlayers Full Post
* Plugin URI: http://goodlayers.com/
* Description: A widget that show posts with excerpt( Specified by category ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'full_post_widget' );
function full_post_widget() {
register_widget( 'Full_Post' );
}
class Full_Post extends WP_Widget {
// Initialize the widget
function Full_Post() {
parent::WP_Widget('full-post-widget', __('Full Post Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show lastest posts with excerpt', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format, $blog_full_widget_size;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$post_cat = $instance['post_cat'];
$show_num = $instance['show_num'];
$num_excerpt = $instance['num_excerpt'];
if($post_cat == "All"){ $post_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
$current_post = array(get_the_ID());
query_posts( array('showposts'=>$show_num, 'category_name'=>$post_cat,
'post__not_in'=>$current_post) );
if( have_posts() ){
echo "<div class='gdl-full-post-widget'>";
while( have_posts() ){ the_post();
?>
<div class="full-post-widget">
<?php
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $blog_full_widget_size );
if( $thumbnail_id ){
echo '<div class="full-post-widget-thumbnail">';
echo '<a href="' . get_permalink() . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '<div class="blog-comment"><i class="icon-comments"></i>';
comments_popup_link( __('0','gdl_front_end'),
__('1','gdl_front_end'),
__('%','gdl_front_end'), '',
__('Off','gdl_front_end') );
echo '</div>';
echo '</div>';
}
?>
<div class="full-post-widget-context">
<h4 class="full-post-widget-title">
<a href="<?php echo get_permalink(); ?>">
<?php echo get_the_title(); ?>
</a>
</h4>
<div class="full-post-widget-excerpt">
<?php echo gdl_get_excerpt($num_excerpt); ?>
</div>
<div class="full-post-widget-info">
<div class="full-post-widget-date">
<?php
echo __('Posted On' , 'gdl_front_end') . ' ';
echo get_the_time($gdl_widget_date_format);
?>
</div>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
echo "</div>";
}
// Closing of widget
echo $after_widget;
wp_reset_query();
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$post_cat = esc_attr( $instance[ 'post_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
$num_excerpt = esc_attr( $instance[ 'num_excerpt' ] );
} else {
$title = '';
$post_cat = '';
$show_num = '3';
$num_excerpt = 150;
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Post Category -->
<p>
<label for="<?php echo $this->get_field_id( 'post_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'post_cat' ); ?>" id="<?php echo $this->get_field_id( 'post_cat' ); ?>">
<?php
$category_list = get_category_list( 'category' );
foreach($category_list as $category){
?>
<option value="<?php echo $category; ?>" <?php if ( $post_cat == $category ) echo ' selected="selected"'; ?>><?php echo $category; ?></option>
<?php } ?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<!-- Num Excerpt -->
<p>
<label for="<?php echo $this->get_field_id( 'num_excerpt' ); ?>"><?php _e('Num Excerpt :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'num_excerpt' ); ?>" name="<?php echo $this->get_field_name( 'num_excerpt' ); ?>" type="text" value="<?php echo $num_excerpt; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['post_cat'] = strip_tags( $new_instance['post_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
$instance['num_excerpt'] = strip_tags( $new_instance['num_excerpt'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,167 @@
<?php
/**
* Plugin Name: Goodlayers Personnal Widget
* Plugin URI: http://goodlayers.com/
* Description: A widget that show personnal posts( Specified by cat-id ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'personnal_widget' );
function personnal_widget() {
register_widget( 'Goodlayers_Personnal' );
}
class Goodlayers_Personnal extends WP_Widget {
// Initialize the widget
function Goodlayers_Personnal() {
parent::WP_Widget('personnal-widget', __('Personnal Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show personnal information', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format, $personnal_widget_size;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$personnal_cat = $instance['personnal_cat'];
$show_num = $instance['show_num'];
if($personnal_cat == "All"){ $personnal_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title;
echo $title;
echo $after_title;
}
echo '<div class="personnal-widget-navigation">';
echo '<div class="personnal-widget-prev"></div>';
echo '<div class="personnal-widget-next"></div>';
echo '</div>';
// Widget Content
wp_reset_query();
$custom_posts = get_posts( array('post_type'=>'personnal', 'showposts'=>$show_num, 'personnal-category'=>$personnal_cat) );
if( !empty($custom_posts) ){
echo "<div class='gdl-personnal-widget'>";
foreach($custom_posts as $custom_post) {
?>
<div class="personnal-widget-item">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $personnal_widget_size );
if( $thumbnail_id ){
echo '<div class="personnal-widget-thumbnail">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</div>'; // personnal-widget-thumbnail
}
?>
<div class="personnal-widget-context">
<div class="personnal-widget-info">
<div class="personnal-name">
<span class="head"><?php _e('Name :','gdl_front_end'); ?></span>
<?php echo $custom_post->post_title; ?>
</div>
<?php
$personnal_position = get_post_meta( $custom_post->ID, 'personnal-option-position', true);
if( !empty( $personnal_position ) ){
echo '<div class="personnal-position">';
echo '<span class="head">' . __('Position :','gdl_front_end') . '</span> ';
echo _e( $personnal_position, 'gdl_front_end' );
echo '</div>';
}
?>
</div>
<div class="personnal-widget-content">
<?php
if( !empty( $custom_post->post_excerpt ) ){
echo do_shortcode( $custom_post->post_excerpt );
}else{
echo do_shortcode( apply_filters('the_content', $custom_post->post_content ) );
}
?>
</div>
</div>
<div class="clear"></div>
</div> <!-- personnal widget item -->
<?php
}
echo "</div>";
}
// Closing of widget
echo $after_widget;
wp_deregister_script('jquery-cycle');
wp_register_script('jquery-cycle', GOODLAYERS_PATH.'/javascript/jquery.cycle.js', false, '1.0', true);
wp_enqueue_script('jquery-cycle');
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$personnal_cat = esc_attr( $instance[ 'personnal_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$personnal_cat = '';
$show_num = '3';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Post Category -->
<p>
<label for="<?php echo $this->get_field_id( 'personnal_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'personnal_cat' ); ?>" id="<?php echo $this->get_field_id( 'personnal_cat' ); ?>">
<?php
$category_list = get_category_list( 'personnal-category' );
foreach($category_list as $category){
?>
<option value="<?php echo $category; ?>" <?php if ( $personnal_cat == $category ) echo ' selected="selected"'; ?>><?php echo $category; ?></option>
<?php } ?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['personnal_cat'] = strip_tags( $new_instance['personnal_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,155 @@
<?php
/**
* Plugin Name: Goodlayers Popular Post
* Plugin URI: http://goodlayers.com/
* Description: A widget that show popular posts( Based by comment ).
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'popular_post_widget' );
function popular_post_widget() {
register_widget( 'Popular_Post' );
}
class Popular_Post extends WP_Widget {
// Initialize the widget
function Popular_Post() {
parent::WP_Widget('popular-post-widget', __('Popular Post Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show popular posts base on the comment number', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format, $blog_port_widget_size;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$post_cat = $instance['post_cat'];
$show_num = $instance['show_num'];
if($post_cat == "All"){ $post_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
wp_reset_query();
$current_post = array(get_the_ID());
$custom_posts = get_posts( array('showposts'=>$show_num, 'category_name'=>$post_cat,
'orderby'=>'comment_count', 'post__not_in'=>$current_post) );
if( !empty($custom_posts) ){
echo "<div class='gdl-recent-post-widget'>";
foreach($custom_posts as $custom_post) {
?>
<div class="recent-post-widget">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $blog_port_widget_size );
if( $thumbnail_id ){
echo '<div class="recent-post-widget-thumbnail">';
echo '<a href="' . get_permalink( $custom_post->ID ) . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '</div>';
}
?>
<div class="recent-post-widget-context">
<h4 class="recent-post-widget-title">
<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
<?php _e( $custom_post->post_title, 'gdl_front_end'); ?>
</a>
</h4>
<div class="recent-post-widget-info">
<?php
$comments_num = get_comments_number( $custom_post->ID );
if( $comments_num > 1 ){
$output = str_replace( '%', number_format_i18n($comments_num), __('% Comments','gdl_front_end') );
echo $output;
}else if( $comments_num == 1 ){
_e('1 Comment','gdl_front_end');
}else{
_e('No Responses.','gdl_front_end');
}
?>
</div>
</div>
<div class="clear"></div>
</div>
<?php
}
echo "</div>";
}
// Closing of widget
echo $after_widget;
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$post_cat = esc_attr( $instance[ 'post_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$post_cat = '';
$show_num = '3';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Post Category -->
<p>
<label for="<?php echo $this->get_field_id( 'post_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'post_cat' ); ?>" id="<?php echo $this->get_field_id( 'post_cat' ); ?>">
<?php
$category_list = get_category_list( 'category' );
foreach($category_list as $category){
?>
<option value="<?php echo $category; ?>" <?php if ( $post_cat == $category ) echo ' selected="selected"'; ?>><?php echo $category; ?></option>
<?php } ?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['post_cat'] = strip_tags( $new_instance['post_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,153 @@
<?php
/**
* Plugin Name: Goodlayers Recent Post Slider
* Plugin URI: http://goodlayers.com/
* Description: A widget that show recent posts( Specified by category ) in slider.
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'recent_post_slider_widget' );
function recent_post_slider_widget() {
register_widget( 'Recent_Post_Slider' );
}
class Recent_Post_Slider extends WP_Widget {
// Initialize the widget
function Recent_Post_Slider() {
parent::WP_Widget('recent-post-slider-widget', __('Recent Post Slider Widget (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show lastest posts in slider', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
global $gdl_widget_date_format;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$post_cat = $instance['post_cat'];
$show_num = $instance['show_num'];
if($post_cat == "All"){ $post_cat = ''; }
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
// Widget Content
wp_reset_query();
$current_post = array(get_the_ID());
$custom_posts = get_posts( array('showposts'=>$show_num, 'category_name'=>$post_cat,
'post__not_in'=>$current_post) );
if( !empty($custom_posts) ){
echo "<div class='gdl-recent-post-slider-widget-wrapper'>";
echo "<div class='gdl-recent-post-slider-widget'>";
foreach($custom_posts as $custom_post) {
?>
<div class="recent-post-slider-widget">
<?php
$thumbnail_id = get_post_thumbnail_id( $custom_post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , '400x270' );
if( $thumbnail_id ){
echo '<div class="recent-post-slider-thumbnail">';
echo '<a href="' . get_permalink( $custom_post->ID ) . '">';
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
if( !empty($thumbnail) ){
echo '<img src="' . $thumbnail[0] . '" alt="'. $alt_text .'"/>';
}
echo '</a>';
echo '</div>';
}
?>
<div class="recent-post-slider-caption">
<h4 class="recent-post-slider-title">
<a href="<?php echo get_permalink( $custom_post->ID ); ?>">
<?php _e( $custom_post->post_title, 'gdl_front_end'); ?>
</a>
</h4>
</div>
<div class="clear"></div>
</div>
<?php
}
echo '</div>'; // gdl-recent-post-slider-widget
echo '<div class="recent-post-slider-nav" >';
echo '<a class="prev"></a>';
echo '<a class="next"></a>';
echo '</div>'; // recent-post-slider-nav
echo '</div>'; // gdl-recent-post-slider-widget-wrapper
}
// Closing of widget
echo $after_widget;
wp_deregister_script('jquery-cycle');
wp_register_script('jquery-cycle', GOODLAYERS_PATH.'/javascript/jquery.cycle.js', false, '1.0', true);
wp_enqueue_script('jquery-cycle');
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$post_cat = esc_attr( $instance[ 'post_cat' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
} else {
$title = '';
$post_cat = '';
$show_num = '3';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Post Category -->
<p>
<label for="<?php echo $this->get_field_id( 'post_cat' ); ?>"><?php _e('Category :', 'gdl_back_office'); ?></label>
<select class="widefat" name="<?php echo $this->get_field_name( 'post_cat' ); ?>" id="<?php echo $this->get_field_id( 'post_cat' ); ?>">
<?php
$category_lists = get_category_list( 'category' );
foreach( $category_lists as $category_list ){
$selected = ( $post_cat == $category_list )? 'selected': '';
echo '<option ' . $selected . '>' . $category_list . '</option>';
}
?>
</select>
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['post_cat'] = strip_tags( $new_instance['post_cat'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
return $instance;
}
}
?>

View File

@ -0,0 +1,95 @@
<?php
function get_url_contents($url){
$crl = curl_init();
$timeout = 5;
curl_setopt ($crl, CURLOPT_URL,$url);
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
class SubscriberStats{
public $twitter, $rss, $facebook;
public $services = array();
public function __construct($arr){
$this->services = $arr;
if(trim($arr['twitterName'])) {
$connection = getConnectionWithAccessToken($arr['consumer_key'], $arr['consumer_secret'], $arr['access_token'], $arr['access_token_secret']);
$tweets = $connection->get('http://api.twitter.com/1.1/users/show.json?screen_name='.$arr['twitterName']) or die('Couldn\'t retrieve tweets! Wrong username?');
if(!empty($tweets->errors)){
if($tweets->errors[0]->message == 'Invalid or expired token'){
echo '<strong>'.$tweets->errors[0]->message.'!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
}else{
echo '<strong>'.$tweets->errors[0]->message.'</strong>' . $after_widget;
}
return;
}
$new_twitter = $tweets->followers_count;
if( empty($new_twitter) || $new_twitter == 0 || $new_twitter == '0' ){
$this->twitter = $arr['twitter'];
}else{
$this->twitter = $new_twitter;
}
}
if(trim($arr['facebookFanPageURL'])) {
$fb_id = basename($arr['facebookFanPageURL']);
$query = 'http://graph.facebook.com/'.urlencode($fb_id);
$result = json_decode(get_url_contents($query));
$new_facebook = $result->likes;
if( empty($new_facebook) || $new_facebook == 0 || $new_facebook == '0' ){
$this->facebook = $arr['facebook'];
}else{
$this->facebook = $new_facebook;
}
}
}
public function generate(){
$gdl_icon_type = get_option(THEME_SHORT_NAME.'_icon_type','dark');
?>
<div class="social-counter-widget-wrapper">
<?php if($this->services['twitterName']) { ?>
<a class="social-counter-widget facebook" href="http://twitter.com/<?php echo $this->services['twitterName']?>" target="_blank">
<span class="icon"><img class="gdl-no-preload" src="<?php echo GOODLAYERS_PATH . '/images/icon/' . $gdl_icon_type . '/social-widget-twitter.png'; ?>" alt="" /></span>
<span class="count"><?php echo number_format($this->twitter); ?></span>
<span class="title"><?php _e('Followers', 'gdl_front_end'); ?></span>
</a>
<?php } ?>
<?php if($this->services['facebookFanPageURL']) { ?>
<a class="social-counter-widget twitter" href="<?php echo $this->services['facebookFanPageURL']?>" target="_blank" >
<span class="icon"><img class="gdl-no-preload" src="<?php echo GOODLAYERS_PATH . '/images/icon/' . $gdl_icon_type . '/social-widget-facebook.png'; ?>" alt="" /></span>
<span class="count"><?php echo number_format($this->facebook); ?></span>
<span class="title"><?php _e('Fans', 'gdl_front_end'); ?></span>
</a>
<?php } ?>
<?php if($this->services['feedBurnerURL']) { ?>
<a class="social-counter-widget rss" href="<?php echo $this->services['feedBurnerURL']; ?>" target="_blank">
<span class="icon"><img class="gdl-no-preload" src="<?php echo GOODLAYERS_PATH . '/images/icon/' . $gdl_icon_type . '/social-widget-rss.png'; ?>" alt="" /></span>
<span class="count"><?php _e('RSS', 'gdl_front_end'); ?></span>
<span class="title"><?php _e('Subscribers', 'gdl_front_end'); ?></span>
</a>
<?php } ?>
<div class="clear"></div>
</div>
<?php
}
}
?>

View File

@ -0,0 +1,165 @@
<?php
/**
* Plugin Name: Social Counter Widget
* Plugin URI: http://goodlayers.com/
* Description: This widget will display your RSS subscribers, Twitter followers and Facebook fans in one nice looking box.
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
require "scw_stats.class.php";
add_action('widgets_init', 'gdl_social_widget');
function gdl_social_widget() {
register_widget( 'SC_widget' );
}
class SC_widget extends WP_Widget {
// Initialize the widget
function SC_widget() {
parent::WP_Widget(false, $name = 'Social Counter Widget');
$this->cacheFileName = WP_CONTENT_DIR."/sc_cache.txt";
}
// Output of the widget
function widget($args, $instance) {
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$facebook_id = $instance['facebook_id'];
$twitter_id = $instance['twitter_id'];
$feedburner_id = $instance['feedburner_id'];
$consumer_key = $instance[ 'consumer_key' ];
$consumer_secret = $instance[ 'consumer_secret' ];
$access_token = $instance[ 'access_token' ];
$access_token_secret = $instance[ 'access_token_secret' ];
$cacheFileName = $this->cacheFileName;
if( file_exists($cacheFileName) && ((time() - filemtime($cacheFileName)) < 30*60) ){
$stats = unserialize(file_get_contents($cacheFileName));
}else if( file_exists($cacheFileName) ){
$old_stats = unserialize(file_get_contents($cacheFileName));
}
if(!$stats){
$stats = new SubscriberStats(array(
'facebookFanPageURL' => $facebook_id,
'feedBurnerURL' => $feedburner_id,
'twitterName' => $twitter_id,
'consumer_key' => $consumer_key,
'consumer_secret' => $consumer_secret,
'access_token' => $access_token,
'access_token_secret' => $access_token_secret,
'rss' => $old_stats->rss,
'twitter' => $old_stats->twitter,
'facebook' => $old_stats->facebook
));
file_put_contents($cacheFileName, serialize($stats));
}
if ( $title ){
echo '<div class="gdl-social-counter-title">';
echo $before_title . $title . $after_title;
echo '</div>';
}
echo '<div class="gdl-social-counter-widget-wrapper">';
echo $before_widget;
echo '<div class="gdl-social-counter-widget">';
echo '<div class="clear"></div>';
$stats->generate();
echo '<div class="clear"></div>';
echo '</div>';
echo $after_widget;
echo '</div>'; // gdl-social-counter-widget-wrapper
}
// Widget Form
function form($instance) {
$title = esc_attr( $instance[ 'title' ] );
$twitter_id = esc_attr($instance['twitter_id']);
$facebook_id = esc_attr($instance['facebook_id']);
$feedburner_id = esc_attr($instance['feedburner_id']);
$consumer_key = esc_attr( $instance[ 'consumer_key' ] );
$consumer_secret = esc_attr( $instance[ 'consumer_secret' ] );
$access_token = esc_attr( $instance[ 'access_token' ] );
$access_token_secret = esc_attr( $instance[ 'access_token_secret' ] );
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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('facebook_id'); ?>"><?php _e('Facebook page URL (not ID !):', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('facebook_id'); ?>" name="<?php echo $this->get_field_name('facebook_id'); ?>" type="text" value="<?php echo $facebook_id; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('feedburner_id'); ?>"><?php _e('Feedburner URL (not ID !):', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('feedburner_id'); ?>" name="<?php echo $this->get_field_name('feedburner_id'); ?>" type="text" value="<?php echo $feedburner_id; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('twitter_id'); ?>"><?php _e('Twitter ID:', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('twitter_id'); ?>" name="<?php echo $this->get_field_name('twitter_id'); ?>" type="text" value="<?php echo $twitter_id; ?>" />
</p>
<!-- Consumer Key -->
<p>
<label for="<?php echo $this->get_field_id( 'consumer_key' ); ?>"><?php _e('Consumer Key :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'consumer_key' ); ?>" name="<?php echo $this->get_field_name( 'consumer_key' ); ?>" type="text" value="<?php echo $consumer_key; ?>" />
</p>
<!-- Consumer Secret -->
<p>
<label for="<?php echo $this->get_field_id( 'consumer_secret' ); ?>"><?php _e('Consumer Secret :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'consumer_secret' ); ?>" name="<?php echo $this->get_field_name( 'consumer_secret' ); ?>" type="text" value="<?php echo $consumer_secret; ?>" />
</p>
<!-- Access Token -->
<p>
<label for="<?php echo $this->get_field_id( 'access_token' ); ?>"><?php _e('Access Token :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'access_token' ); ?>" name="<?php echo $this->get_field_name( 'access_token' ); ?>" type="text" value="<?php echo $access_token; ?>" />
</p>
<!-- Access Token Secret -->
<p>
<label for="<?php echo $this->get_field_id( 'access_token_secret' ); ?>"><?php _e('Access Token Secret :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'access_token_secret' ); ?>" name="<?php echo $this->get_field_name( 'access_token_secret' ); ?>" type="text" value="<?php echo $access_token_secret; ?>" />
</p>
<?php
}
// Update the widget
function update($new_instance, $old_instance) {
if($new_instance != $old_instance) unlink($this->cacheFileName);
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['twitter_id'] = strip_tags($new_instance['twitter_id']);
$instance['facebook_id'] = strip_tags($new_instance['facebook_id']);
$instance['feedburner_id'] = strip_tags($new_instance['feedburner_id']);
$instance['consumer_key'] = strip_tags( $new_instance['consumer_key'] );
$instance['consumer_secret'] = strip_tags( $new_instance['consumer_secret'] );
$instance['access_token'] = strip_tags( $new_instance['access_token'] );
$instance['access_token_secret'] = strip_tags( $new_instance['access_token_secret'] );
return $instance;
}
} // SC_widget
?>

View File

@ -0,0 +1,181 @@
<?php
/**
* Plugin Name: Goodlayers Twitter Widget
* Plugin URI: http://goodlayers.com/
* Description: A widget that show feeds from twitter.
* Version: 1.0
* Author: Goodlayers
* Author URI: http://www.goodlayers.com
*
*/
add_action( 'widgets_init', 'twitter_widget' );
function twitter_widget() {
register_widget( 'Twitter' );
}
class Twitter extends WP_Widget {
// Initialize the widget
function Twitter() {
parent::WP_Widget('twitter-widget', __('Twitter (Goodlayers)','gdl_back_office'),
array('description' => __('A widget that show Twitter feeds.', 'gdl_back_office')));
}
// Output of the widget
function widget( $args, $instance ) {
extract( $args );
$title = apply_filters('widget_title', $instance['title'] );
$twitter_username = $instance['twitter_username'];
$show_num = $instance['show_num'];
$consumer_key = $instance['consumer_key'];
$consumer_secret = $instance['consumer_secret'];
$access_token = $instance['access_token'];
$access_token_secret = $instance['access_token_secret'];
$cache_time = $instance['cache_time'];
// Opening of widget
echo $before_widget;
// Open of title tag
if ( $title ){
echo $before_title . $title . $after_title;
}
$last_cache_time = get_option('gdl_twitter_widget_last_cache_time', 0);
$diff = time() - $last_cache_time;
$crt = $cache_time * 3600;
if(empty($last_cache_time) || $diff >= $crt){
$connection = getConnectionWithAccessToken($consumer_key, $consumer_secret, $access_token, $access_token_secret);
$tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitter_username."&count=" . $show_num) or die('Couldn\'t retrieve tweets! Wrong username?');
if(!empty($tweets->errors)){
if($tweets->errors[0]->message == 'Invalid or expired token'){
echo '<strong>'.$tweets->errors[0]->message.'!</strong><br />You\'ll need to regenerate it <a href="https://dev.twitter.com/apps" target="_blank">here</a>!' . $after_widget;
}else{
echo '<strong>'.$tweets->errors[0]->message.'</strong>' . $after_widget;
}
return;
}
$tweets_data = array();
for($i = 0;$i <= count($tweets); $i++){
if(!empty($tweets[$i])){
$tweets_data[$i]['created_at'] = $tweets[$i]->created_at;
$tweets_data[$i]['text'] = $tweets[$i]->text;
$tweets_data[$i]['status_id'] = $tweets[$i]->id_str;
}
}
update_option('gdl_twitter_widget_tweets',serialize($tweets_data));
update_option('gdl_twitter_widget_last_cache_time',time());
}else{
$tweets_data = maybe_unserialize(get_option('gdl_twitter_widget_tweets'));
}
echo '<div class="twitter-whole">';
echo '<ul id="twitter_update_list">';
foreach( $tweets_data as $each_tweet ){
echo '<li>';
echo '<span>' . convert_links($each_tweet['text']) . '</span>';
echo '<a target="_blank" href="http://twitter.com/'.$twitter_username.'/statuses/'.$each_tweet['status_id'].'">'.relative_time($each_tweet['created_at']).'</a>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
// Closing of widget
echo $after_widget;
}
// Widget Form
function form( $instance ) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$twitter_username = esc_attr( $instance[ 'twitter_username' ] );
$show_num = esc_attr( $instance[ 'show_num' ] );
$consumer_key = esc_attr( $instance[ 'consumer_key' ] );
$consumer_secret = esc_attr( $instance[ 'consumer_secret' ] );
$access_token = esc_attr( $instance[ 'access_token' ] );
$access_token_secret = esc_attr( $instance[ 'access_token_secret' ] );
$cache_time = esc_attr( $instance[ 'cache_time' ] );
} else {
$title = '';
$twitter_username = '';
$show_num = '5';
$consumer_key = '';
$consumer_secret = '';
$access_token = '';
$cache_time = '1';
}
?>
<!-- Text Input -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Twitter Username -->
<p>
<label for="<?php echo $this->get_field_id('twitter_username'); ?>"><?php _e( 'Twitter username :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('twitter_username'); ?>" name="<?php echo $this->get_field_name('twitter_username'); ?>" type="text" value="<?php echo $twitter_username; ?>" />
</p>
<!-- Show Num -->
<p>
<label for="<?php echo $this->get_field_id( 'show_num' ); ?>"><?php _e('Show Count :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'show_num' ); ?>" name="<?php echo $this->get_field_name( 'show_num' ); ?>" type="text" value="<?php echo $show_num; ?>" />
</p>
<!-- Consumer Key -->
<p>
<label for="<?php echo $this->get_field_id( 'consumer_key' ); ?>"><?php _e('Consumer Key :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'consumer_key' ); ?>" name="<?php echo $this->get_field_name( 'consumer_key' ); ?>" type="text" value="<?php echo $consumer_key; ?>" />
</p>
<!-- Consumer Secret -->
<p>
<label for="<?php echo $this->get_field_id( 'consumer_secret' ); ?>"><?php _e('Consumer Secret :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'consumer_secret' ); ?>" name="<?php echo $this->get_field_name( 'consumer_secret' ); ?>" type="text" value="<?php echo $consumer_secret; ?>" />
</p>
<!-- Access Token -->
<p>
<label for="<?php echo $this->get_field_id( 'access_token' ); ?>"><?php _e('Access Token :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'access_token' ); ?>" name="<?php echo $this->get_field_name( 'access_token' ); ?>" type="text" value="<?php echo $access_token; ?>" />
</p>
<!-- Access Token Secret -->
<p>
<label for="<?php echo $this->get_field_id( 'access_token_secret' ); ?>"><?php _e('Access Token Secret :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'access_token_secret' ); ?>" name="<?php echo $this->get_field_name( 'access_token_secret' ); ?>" type="text" value="<?php echo $access_token_secret; ?>" />
</p>
<!-- Cache Time -->
<p>
<label for="<?php echo $this->get_field_id( 'cache_time' ); ?>"><?php _e('Cache Time (hour) :', 'gdl_back_office'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'cache_time' ); ?>" name="<?php echo $this->get_field_name( 'cache_time' ); ?>" type="text" value="<?php echo $cache_time; ?>" />
</p>
<?php
}
// Update the widget
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
$instance['twitter_username'] = strip_tags( $new_instance['twitter_username'] );
$instance['show_num'] = strip_tags( $new_instance['show_num'] );
$instance['consumer_key'] = strip_tags( $new_instance['consumer_key'] );
$instance['consumer_secret'] = strip_tags( $new_instance['consumer_secret'] );
$instance['access_token'] = strip_tags( $new_instance['access_token'] );
$instance['access_token_secret'] = strip_tags( $new_instance['access_token_secret'] );
$instance['cache_time'] = strip_tags( $new_instance['cache_time'] );
return $instance;
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
<?php
/*
Plugin Name: Bangkok Press Video Widget
Plugin URI: http://goodlayers.com/
Description: Bangkokpress title widget
Author: Goodlayers
Version: 1
Author URI: http://goodlayers.com/
*/
add_action( 'widgets_init', 'goodlayers_1_1_video_init' );
function goodlayers_1_1_video_init(){
register_widget('Goodlayers_1_1_Video_Widget');
}
class Goodlayers_1_1_Video_Widget extends WP_Widget{
// Initialize the widget
function Goodlayers_1_1_Video_Widget() {
parent::WP_Widget('goodlayers-1-1-video-widget', __('1/1 Video Widget (Goodlayers)','gdl_back_office'),
array('description' => __('Full size video widget (300 px width)', 'gdl_back_office')));
}
// Output of the widget
function widget($args, $instance) {
global $wpdb;
extract( $args );
$title = apply_filters( 'widget_title', $instance['title'] );
$source = apply_filters( 'widget_title', $instance['source'] );
$height = apply_filters( 'widget_title', $instance['height'] );
echo $before_widget;
// Widget Title
echo $before_title . $title . $after_title;
echo '<div class="video-widget1-1">';
get_video($source, 300, $height);
echo '</div>'; // 1-1 Video Widget
echo $after_widget;
}
// Widget Form
function form($instance) {
if ( $instance ) {
$title = esc_attr( $instance[ 'title' ] );
$source = esc_attr( $instance[ 'source' ] );
$height = esc_attr( $instance[ 'height' ] );
} else {
$title = '';
$source = '';
$height = 266;
}
?>
<!-- Title -->
<p>
<label for="<?php echo $this->get_field_id('title'); ?>"><?php _e( 'Title :', 'gdl_back_office' ); ?></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>
<!-- Source -->
<p>
<label for="<?php echo $this->get_field_id('source'); ?>"><?php _e( 'Video URL( Vimeo/Youtube ) :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('source'); ?>" name="<?php echo $this->get_field_name('source'); ?>" type="text" value="<?php echo $source; ?>" />
</p>
<!-- Height -->
<p>
<label for="<?php echo $this->get_field_id('height'); ?>"><?php _e( 'Video Height :', 'gdl_back_office' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo $height; ?>" />
</p>
<?php
}
// Update the widget
function update($new_instance, $old_instance){
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
$instance['source'] = strip_tags($new_instance['source']);
$instance['height'] = strip_tags($new_instance['height']);
return $instance;
}
}
?>