first commit
This commit is contained in:
442
wp-content/themes/worldwide-v1-01/include/plugin/blog-item.php
Normal file
442
wp-content/themes/worldwide-v1-01/include/plugin/blog-item.php
Normal file
@ -0,0 +1,442 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Goodlayers Blog Item File
|
||||
* ---------------------------------------------------------------------
|
||||
* @version 1.0
|
||||
* @author Goodlayers
|
||||
* @link http://goodlayers.com
|
||||
* @copyright Copyright (c) Goodlayers
|
||||
* ---------------------------------------------------------------------
|
||||
* This file contains the function that can print each blog item due to
|
||||
* different conditions.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Print blog item
|
||||
function print_blog_item($item_xml){
|
||||
$additional = ''; $additional_html = '';
|
||||
|
||||
$offset = find_xml_value($item_xml, 'offset');
|
||||
$pagination = find_xml_value($item_xml, "pagination");
|
||||
$view_all_blog = find_xml_value($item_xml, 'read-the-blog');
|
||||
if( !empty($view_all_blog) && $view_all_blog != 'None' ){
|
||||
global $gdl_admin_translator;
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_view = get_option(THEME_SHORT_NAME.'_translator_read_the_blog', 'Read All News');
|
||||
}else{
|
||||
$translator_view = __('Read All News','gdl_front_end');
|
||||
}
|
||||
$additional_html = '<a href="' . get_permalink(get_page_by_path($view_all_blog));
|
||||
$additional_html = $additional_html . '" class="view-all-projects">';
|
||||
$additional_html = $additional_html . $translator_view . '</a>';
|
||||
}
|
||||
|
||||
print_item_header( find_xml_value($item_xml, 'header'), $additional, $additional_html );
|
||||
global $paged, $sidebar_type, $blog_div_size_num_class;
|
||||
|
||||
if(empty($paged)){ $paged = (get_query_var('page')) ? get_query_var('page') : 1; }
|
||||
if($pagination == "No"){ $paged = 1; }
|
||||
if($paged != '1'){ $offset = 0; }
|
||||
|
||||
// get the item class and size from array
|
||||
$item_type = find_xml_value($item_xml, 'item-size');
|
||||
$item_class = $blog_div_size_num_class[$item_type]['class'];
|
||||
$item_size = $blog_div_size_num_class[$item_type][$sidebar_type];
|
||||
|
||||
// get the blog meta value
|
||||
$num_fetch = find_xml_value($item_xml, 'num-fetch');
|
||||
$num_excerpt = find_xml_value($item_xml, 'num-excerpt');
|
||||
$full_content = find_xml_value($item_xml, 'show-full-blog-post');
|
||||
|
||||
$category = find_xml_value($item_xml, 'category', false);
|
||||
$category = ( $category == 'All' )? '': $category;
|
||||
|
||||
$order = find_xml_value($item_xml, 'order');
|
||||
$orderby = find_xml_value($item_xml, 'orderby');
|
||||
|
||||
// start fetching database
|
||||
query_posts(array('post_type'=>'post', 'paged'=>$paged, 'order'=>$order, 'orderby'=>$orderby,
|
||||
'category_name'=>$category, 'posts_per_page'=>$num_fetch, 'offset'=>$offset ));
|
||||
|
||||
// printing each blog function
|
||||
echo '<div class="blog-item-holder">';
|
||||
if( $item_type == '1/4 Blog Grid' || $item_type == '1/3 Blog Grid' ||
|
||||
$item_type == '1/2 Blog Grid' || $item_type == '1/1 Blog Grid'){
|
||||
|
||||
print_blog_grid($item_class, $item_size, $num_excerpt, $full_content, $item_type);
|
||||
}else if( $item_type == '1/1 Blog List' ){
|
||||
print_blog_list($item_class, $item_size);
|
||||
}else if( $item_type == '1/4 Blog Grid List' || $item_type == '1/3 Blog Grid List' ||
|
||||
$item_type == '1/2 Blog Grid List' || $item_type == '1/1 Blog Grid List'){
|
||||
|
||||
$list_size = $blog_div_size_num_class['1/1 Blog List'][$sidebar_type];
|
||||
print_blog_grid_list($item_class, $item_size, $list_size, $num_excerpt, $full_content, $item_type);
|
||||
}else if( $item_type == '1/1 Medium Thumbnail' ){
|
||||
print_blog_medium($item_class, $item_size, $num_excerpt, $full_content);
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
if( $pagination == "Yes" ){
|
||||
pagination();
|
||||
}
|
||||
|
||||
wp_reset_query();
|
||||
}
|
||||
|
||||
// print the blog thumbnail
|
||||
function print_blog_thumbnail( $post_id, $item_size, $enable_comment = false ){
|
||||
if( empty($item_size) ){ return ''; }
|
||||
|
||||
$thumbnail_types = get_post_meta( $post_id, 'post-option-thumbnail-types', true);
|
||||
if( $thumbnail_types == "Image" || empty($thumbnail_types) ){
|
||||
$thumbnail_id = get_post_thumbnail_id( $post_id );
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
if( !empty($thumbnail) ){
|
||||
echo '<div class="blog-media-wrapper gdl-image">';
|
||||
echo '<a href="' . get_permalink() . '"><img src="' . $thumbnail[0] .'" alt="'. $alt_text .'"/></a>';
|
||||
|
||||
if( $enable_comment ){
|
||||
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>'; // blog-media-wrapper
|
||||
}
|
||||
}else if( $thumbnail_types == "Video" ){
|
||||
$video_link = get_post_meta( $post_id, 'post-option-thumbnail-video', true);
|
||||
echo '<div class="blog-media-wrapper gdl-video">';
|
||||
echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}else if ( $thumbnail_types == "Slider" ){
|
||||
$slider_xml = get_post_meta( $post_id, 'post-option-thumbnail-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
$slider_xml_dom->loadXML($slider_xml);
|
||||
echo '<div class="blog-media-wrapper gdl-slider">';
|
||||
echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}else if ( $thumbnail_types == "HTML5 Video" ){
|
||||
$video = get_post_meta( $post_id, 'post-option-thumbnail-html5-video', true);
|
||||
echo '<div class="blog-media-wrapper gdl-html5-video">';
|
||||
get_html5_video($video);
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}
|
||||
}
|
||||
|
||||
// print the blog thumbnail
|
||||
function print_single_blog_thumbnail( $post_id, $item_size ){
|
||||
$thumbnail_types = get_post_meta( $post_id, 'post-option-inside-thumbnail-types', true);
|
||||
if( $thumbnail_types == "Image" || empty($thumbnail_types) ){
|
||||
$thumbnail_id = get_post_meta( $post_id, 'post-option-inside-thumbnial-image', true);
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$thumbnail_full = wp_get_attachment_image_src( $thumbnail_id , 'full' );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
if( !empty($thumbnail) ){
|
||||
echo '<div class="blog-media-wrapper gdl-image">';
|
||||
echo '<a href="' . $thumbnail_full[0] . '" data-rel="fancybox" title="' . get_the_title() . '">';
|
||||
echo '<img src="' . $thumbnail[0] .'" alt="'. $alt_text .'"/>';
|
||||
echo '</a>';
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}
|
||||
}else if( $thumbnail_types == "Video" ){
|
||||
$video_link = get_post_meta( $post_id, 'post-option-inside-thumbnail-video', true);
|
||||
echo '<div class="blog-media-wrapper gdl-video">';
|
||||
echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}else if ( $thumbnail_types == "Slider" ){
|
||||
$slider_xml = get_post_meta( $post_id, 'post-option-inside-thumbnail-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
$slider_xml_dom->loadXML($slider_xml);
|
||||
echo '<div class="blog-media-wrapper gdl-slider">';
|
||||
echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}else if ( $thumbnail_types == "HTML5 Video" ){
|
||||
$video = get_post_meta( $post_id, 'post-option-inside-thumbnail-html5-video', true);
|
||||
echo '<div class="blog-media-wrapper gdl-html5-video">';
|
||||
get_html5_video($video);
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}
|
||||
}
|
||||
|
||||
// print blog widget type
|
||||
function print_blog_grid( $item_class, $item_size, $num_excerpt, $full_content, $blog_size ){
|
||||
global $more, $gdl_date_format, $gdl_admin_translator;
|
||||
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_continue_reading = get_option(THEME_SHORT_NAME.'_translator_continue_reading', 'Continue Reading');
|
||||
}else{
|
||||
$translator_continue_reading = __('Continue Reading ','gdl_front_end');
|
||||
}
|
||||
|
||||
if( $full_content == 'Yes' ){ $more = 0; }
|
||||
|
||||
$blog_row_size = 0;
|
||||
$blog_size = str_replace(' Blog Grid', '', $blog_size);
|
||||
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
$blog_row_size = print_item_size($blog_size, $blog_row_size, $item_class . '');
|
||||
|
||||
// blog content
|
||||
echo '<div class="blog-content-wrapper">';
|
||||
|
||||
// blog thumbnail
|
||||
print_blog_thumbnail( get_the_ID(), $item_size, true );
|
||||
|
||||
echo '<h2 class="blog-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
|
||||
echo '<div class="blog-content">';
|
||||
if( $full_content == "No" ){
|
||||
echo gdl_get_excerpt( $num_excerpt, '... ' );
|
||||
}else{
|
||||
the_content($translator_continue_reading);
|
||||
}
|
||||
|
||||
// blog information
|
||||
echo '<div class="blog-info-wrapper">';
|
||||
echo '<div class="blog-date">';
|
||||
echo '<span class="head">' . __('Posted On' , 'gdl_front_end') . '</span> ';
|
||||
echo '<a href="' . get_day_link( get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" >';
|
||||
echo get_the_time($gdl_date_format);
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="blog-author">';
|
||||
echo '<span class="separator">, </span>';
|
||||
echo '<span class="head">' . __('By' , 'gdl_front_end') . '</span> ';
|
||||
echo the_author_posts_link();
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // blog information
|
||||
|
||||
echo '</div>'; // blog content
|
||||
echo '</div>'; // blog content wrapper
|
||||
|
||||
echo '</div>'; // item_class
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close row
|
||||
}
|
||||
|
||||
// print blog list
|
||||
function print_blog_list( $item_class, $item_size ){
|
||||
global $gdl_date_format, $gdl_admin_translator;
|
||||
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
// blog content
|
||||
echo '<div class="' . $item_class . '">';
|
||||
|
||||
// blog thumbnail
|
||||
print_blog_thumbnail( get_the_ID(), $item_size );
|
||||
|
||||
echo '<div class="blog-content-wrapper">';
|
||||
echo '<h2 class="blog-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
|
||||
// blog information
|
||||
echo '<div class="blog-info-wrapper">';
|
||||
echo '<div class="blog-date">';
|
||||
echo '<span class="head">' . __('Posted On' , 'gdl_front_end') . '</span> ';
|
||||
echo '<a href="' . get_day_link( get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" >';
|
||||
echo get_the_time($gdl_date_format);
|
||||
echo '</a>';
|
||||
echo'</div>';
|
||||
|
||||
echo '<div class="blog-author">';
|
||||
echo '<span class="separator">, </span>';
|
||||
echo '<span class="head">' . __('By' , 'gdl_front_end') . '</span> ';
|
||||
echo the_author_posts_link();
|
||||
echo '</div>';
|
||||
|
||||
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 class="clear"></div>';
|
||||
echo '</div>'; // blog info wrapper
|
||||
|
||||
echo '</div>'; // blog content wrapper
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // item class
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// print blog widget type
|
||||
function print_blog_grid_list( $item_class, $item_size, $list_size, $num_excerpt, $full_content, $blog_size ){
|
||||
global $more, $gdl_date_format, $gdl_admin_translator;
|
||||
$gdl_num_post = 0;
|
||||
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_continue_reading = get_option(THEME_SHORT_NAME.'_translator_continue_reading', 'Continue Reading');
|
||||
}else{
|
||||
$translator_continue_reading = __('Continue Reading ','gdl_front_end');
|
||||
}
|
||||
|
||||
if( $full_content == 'Yes' ){ $more = 0; }
|
||||
|
||||
$blog_row_size = 0;
|
||||
$blog_size = str_replace(' Blog Grid List', '', $blog_size);
|
||||
|
||||
// $item_class
|
||||
|
||||
while( have_posts() ){
|
||||
the_post(); $gdl_num_post++;
|
||||
|
||||
if( $gdl_num_post <= 1 ){
|
||||
echo '<div class="gdl-blog-grid" >';
|
||||
|
||||
// blog content
|
||||
echo '<div class="blog-content-wrapper">';
|
||||
|
||||
// blog thumbnail
|
||||
print_blog_thumbnail( get_the_ID(), $item_size, true );
|
||||
|
||||
echo '<h2 class="blog-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
|
||||
echo '<div class="blog-content">';
|
||||
if( $full_content == "No" ){
|
||||
echo gdl_get_excerpt( $num_excerpt, '... ' );
|
||||
}else{
|
||||
the_content($translator_continue_reading);
|
||||
}
|
||||
|
||||
// blog information
|
||||
echo '<div class="blog-info-wrapper">';
|
||||
echo '<div class="blog-date">';
|
||||
echo '<span class="head">' . __('Posted On' , 'gdl_front_end') . '</span> ';
|
||||
echo '<a href="' . get_day_link( get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" >';
|
||||
echo get_the_time($gdl_date_format);
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="blog-author">';
|
||||
echo '<span class="separator">, </span>';
|
||||
echo '<span class="head">' . __('By' , 'gdl_front_end') . '</span> ';
|
||||
echo the_author_posts_link();
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // blog information
|
||||
|
||||
echo '</div>'; // blog content
|
||||
echo '</div>'; // blog content wrapper
|
||||
|
||||
echo '</div>'; // gdl blog grid
|
||||
}else{
|
||||
|
||||
// blog content
|
||||
echo '<div class="' . $item_class . '">';
|
||||
|
||||
// blog thumbnail
|
||||
print_blog_thumbnail( get_the_ID(), $list_size );
|
||||
|
||||
echo '<div class="blog-content-wrapper">';
|
||||
echo '<h2 class="blog-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
|
||||
// blog information
|
||||
echo '<div class="blog-info-wrapper">';
|
||||
echo '<div class="blog-date">';
|
||||
echo '<span class="head">' . __('Posted On' , 'gdl_front_end') . '</span> ';
|
||||
echo '<a href="' . get_day_link( get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" >';
|
||||
echo get_the_time($gdl_date_format);
|
||||
echo '</a>';
|
||||
echo'</div>';
|
||||
|
||||
echo '<div class="blog-author">';
|
||||
echo '<span class="separator">, </span>';
|
||||
echo '<span class="head">' . __('By' , 'gdl_front_end') . '</span> ';
|
||||
echo the_author_posts_link();
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // blog info wrapper
|
||||
|
||||
echo '</div>'; // blog content wrapper
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // item class
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// print blog medium thumbnail type
|
||||
function print_blog_medium( $item_class, $item_size, $num_excerpt, $full_content ){
|
||||
global $gdl_admin_translator, $more, $gdl_date_format;
|
||||
|
||||
if( $full_content == 'Yes' ){ $more = 0; }
|
||||
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_continue_reading = get_option(THEME_SHORT_NAME.'_translator_continue_reading', 'Continue Reading');
|
||||
}else{
|
||||
$translator_continue_reading = __('Continue Reading ','gdl_front_end');
|
||||
}
|
||||
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
echo '<div class="' . $item_class . '">';
|
||||
|
||||
echo '<div class="blog-content-wrapper">';
|
||||
|
||||
// blog thumbnail
|
||||
echo '<div class="blog-medium-media-wrapper">';
|
||||
print_blog_thumbnail( get_the_ID(), $item_size, true );
|
||||
echo '</div>'; // blog-medium-media-wrapper
|
||||
|
||||
echo '<div class="blog-context-wrapper">';
|
||||
|
||||
// blog title
|
||||
echo '<h2 class="blog-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
|
||||
// blog content
|
||||
echo '<div class="blog-content">';
|
||||
if( $full_content == "No" ){
|
||||
echo gdl_get_excerpt( $num_excerpt, '... ' );
|
||||
}else{
|
||||
the_content($translator_continue_reading);
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
// blog information
|
||||
echo '<div class="blog-info-wrapper">';
|
||||
echo '<div class="blog-date">';
|
||||
echo '<span class="head">' . __('Posted On' , 'gdl_front_end') . '</span> ';
|
||||
echo '<a href="' . get_day_link( get_the_time('Y'), get_the_time('m'), get_the_time('d')) . '" >';
|
||||
echo get_the_time($gdl_date_format);
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="blog-author">';
|
||||
echo '<span class="separator">, </span>';
|
||||
echo '<span class="head">' . __('By' , 'gdl_front_end') . '</span> ';
|
||||
echo the_author_posts_link();
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // blog information
|
||||
|
||||
echo '</div>'; // blog-context-wrapper
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // blog-content-wrapper
|
||||
|
||||
echo '</div>'; // blog-item
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
57
wp-content/themes/worldwide-v1-01/include/plugin/comment.php
Normal file
57
wp-content/themes/worldwide-v1-01/include/plugin/comment.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Goodlayers Comment File
|
||||
* ---------------------------------------------------------------------
|
||||
* @version 1.0
|
||||
* @author Goodlayers
|
||||
* @link http://goodlayers.com
|
||||
* @copyright Copyright (c) Goodlayers
|
||||
* ---------------------------------------------------------------------
|
||||
* This file return the comment list to selected the post_type
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function get_comment_list( $comment, $args, $depth ) {
|
||||
|
||||
$GLOBALS['comment'] = $comment;
|
||||
|
||||
switch ( $comment->comment_type ) :
|
||||
case 'pingback' :
|
||||
case 'trackback' :
|
||||
?>
|
||||
<li class="post pingback">
|
||||
<p>
|
||||
<?php _e( 'Pingback:', 'gdl_back_office'); ?>
|
||||
<?php comment_author_link(); ?>
|
||||
<?php edit_comment_link( __('(Edit)', 'gdl_back_office'), ' ' ); ?>
|
||||
</p>
|
||||
<?php
|
||||
break;
|
||||
|
||||
default :
|
||||
?>
|
||||
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
|
||||
<div class="comment-body">
|
||||
<div class="comment-avartar">
|
||||
<?php echo get_avatar( $comment, 60 ); ?>
|
||||
</div>
|
||||
<div class="comment-context">
|
||||
<div class="comment-head">
|
||||
<span class="comment-author"><?php echo get_comment_author_link(); ?></span>
|
||||
<span class="comment-date post-info-color"><?php echo get_comment_date();?></span>
|
||||
<span class="comment-date post-info-color"> <?php _e('at','gdl_front_end'); ?> <?php echo get_comment_time();?></span>
|
||||
<span class="comment-reply">
|
||||
<?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'], 'reply_text' => __('Reply' ,'gdl_front_end')) ) ); ?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="comment-content"><?php comment_text(); ?></div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div><!-- end of comment body -->
|
||||
<?php
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
}
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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 . '&display=' . $how . '&size=s&layout=x&source=user&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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -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
|
||||
|
||||
?>
|
@ -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
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,253 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Dropdown Menus
|
||||
Plugin URI: http://interconnectit.com/?p=2190
|
||||
Description: Outputs WordPress Menus as a dropdown. Use the widget or the function <code>dropdown_menu();</code> with the same arguments as <code>wp_nav_menu();</code>.
|
||||
Author: Robert O'Rourke @ interconnect/it
|
||||
Version: 0.5
|
||||
Author URI: http://interconnectit.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Changelog:
|
||||
|
||||
0.5:
|
||||
improved backwards compat with getElementsByClassName. Works back to IE 5.5. Thanks to Rob Nyman http://code.google.com/p/getelementsbyclassname/
|
||||
|
||||
0.4:
|
||||
added the use of the menu name as the blank item text
|
||||
fixed it for when the menu object wasn't present if called via theme_location
|
||||
changed white space to reflect coding guidelines
|
||||
|
||||
0.3:
|
||||
added an argument to alter the blanking text, empty to not have it all together, and an improved filter that passes $args
|
||||
changed widget class name
|
||||
|
||||
*/
|
||||
|
||||
// pretty useless without this
|
||||
if ( ! function_exists( 'wp_nav_menu' ) )
|
||||
return false;
|
||||
|
||||
|
||||
/**
|
||||
* Tack on the blank option for urls not in the menu
|
||||
*/
|
||||
add_filter( 'wp_nav_menu_items', 'dropdown_add_blank_item', 10, 2 );
|
||||
function dropdown_add_blank_item( $items, $args ) {
|
||||
if ( isset( $args->walker ) && is_object( $args->walker ) && method_exists( $args->walker, 'is_dropdown' ) ) {
|
||||
if ( ( ! isset( $args->menu ) || empty( $args->menu ) ) && isset( $args->theme_location ) ) {
|
||||
$theme_locations = get_nav_menu_locations();
|
||||
$args->menu = wp_get_nav_menu_object( $theme_locations[ $args->theme_location ] );
|
||||
}
|
||||
$title = isset( $args->dropdown_title ) ? wptexturize( $args->dropdown_title ) : '— ' . $args->menu->name . ' —';
|
||||
if ( ! empty( $title ) )
|
||||
$items = '<option value="" class="blank">' . apply_filters( 'dropdown_blank_item_text', $title, $args ) . '</option>' . $items;
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove empty options created in the sub levels output
|
||||
*/
|
||||
add_filter( 'wp_nav_menu_items', 'dropdown_remove_empty_items', 10, 2 );
|
||||
function dropdown_remove_empty_items( $items, $args ) {
|
||||
if ( isset( $args->walker ) && is_object( $args->walker ) && method_exists( $args->walker, 'is_dropdown' ) )
|
||||
$items = str_replace( "<option></option>", "", $items );
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Script to make it go (no jquery! (for once))
|
||||
*/
|
||||
add_action( 'wp_footer', 'dropdown_javascript' );
|
||||
function dropdown_javascript() {
|
||||
if ( is_admin() ) return; ?>
|
||||
<script>
|
||||
var getElementsByClassName=function(a,b,c){if(document.getElementsByClassName){getElementsByClassName=function(a,b,c){c=c||document;var d=c.getElementsByClassName(a),e=b?new RegExp("\\b"+b+"\\b","i"):null,f=[],g;for(var h=0,i=d.length;h<i;h+=1){g=d[h];if(!e||e.test(g.nodeName)){f.push(g)}}return f}}else if(document.evaluate){getElementsByClassName=function(a,b,c){b=b||"*";c=c||document;var d=a.split(" "),e="",f="http://www.w3.org/1999/xhtml",g=document.documentElement.namespaceURI===f?f:null,h=[],i,j;for(var k=0,l=d.length;k<l;k+=1){e+="[contains(concat(' ', @class, ' '), ' "+d[k]+" ')]"}try{i=document.evaluate(".//"+b+e,c,g,0,null)}catch(m){i=document.evaluate(".//"+b+e,c,null,0,null)}while(j=i.iterateNext()){h.push(j)}return h}}else{getElementsByClassName=function(a,b,c){b=b||"*";c=c||document;var d=a.split(" "),e=[],f=b==="*"&&c.all?c.all:c.getElementsByTagName(b),g,h=[],i;for(var j=0,k=d.length;j<k;j+=1){e.push(new RegExp("(^|\\s)"+d[j]+"(\\s|$)"))}for(var l=0,m=f.length;l<m;l+=1){g=f[l];i=false;for(var n=0,o=e.length;n<o;n+=1){i=e[n].test(g.className);if(!i){break}}if(i){h.push(g)}}return h}}return getElementsByClassName(a,b,c)},
|
||||
dropdowns = getElementsByClassName( 'dropdown-menu' );
|
||||
for ( i=0; i<dropdowns.length; i++ )
|
||||
dropdowns[i].onchange = function(){ if ( this.value != '' ) window.location.href = this.value; }
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overrides the walker argument and container argument then calls wp_nav_menu
|
||||
*/
|
||||
function dropdown_menu( $args ) {
|
||||
// enforce these arguments so it actually works
|
||||
$args[ 'walker' ] = new DropDown_Nav_Menu();
|
||||
$args[ 'items_wrap' ] = '<select id="%1$s" class="%2$s dropdown-menu">%3$s</select>';
|
||||
|
||||
// custom args for controlling indentation of sub menu items
|
||||
$args[ 'indent_string' ] = isset( $args[ 'indent_string' ] ) ? $args[ 'indent_string' ] : '– ';
|
||||
$args[ 'indent_after' ] = isset( $args[ 'indent_after' ] ) ? $args[ 'indent_after' ] : '';
|
||||
|
||||
wp_nav_menu( $args );
|
||||
}
|
||||
|
||||
|
||||
class DropDown_Nav_Menu extends Walker_Nav_Menu {
|
||||
|
||||
// easy way to check it's this walker we're using to mod the output
|
||||
function is_dropdown() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Walker::start_lvl()
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of page. Used for padding.
|
||||
*/
|
||||
function start_lvl( &$output, $depth ) {
|
||||
$output .= "</option>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Walker::end_lvl()
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param int $depth Depth of page. Used for padding.
|
||||
*/
|
||||
function end_lvl( &$output, $depth ) {
|
||||
$output .= "<option>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Walker::start_el()
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $item Menu item data object.
|
||||
* @param int $depth Depth of menu item. Used for padding.
|
||||
* @param int $current_page Menu item ID.
|
||||
* @param object $args
|
||||
*/
|
||||
function start_el( &$output, $item, $depth, $args ) {
|
||||
global $wp_query;
|
||||
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
|
||||
|
||||
$class_names = $value = '';
|
||||
|
||||
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
|
||||
$classes[] = 'menu-item-' . $item->ID;
|
||||
$classes[] = 'menu-item-depth-' . $depth;
|
||||
|
||||
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_unique( array_filter( $classes ) ), $item, $args ) );
|
||||
$class_names = ' class="' . esc_attr( $class_names ) . '"';
|
||||
|
||||
// select current item
|
||||
$selected = in_array( 'current-menu-item', $classes ) ? ' selected="selected"' : '';
|
||||
|
||||
$output .= $indent . '<option' . $class_names .' value="'. $item->url .'"'. $selected .'>';
|
||||
|
||||
// push sub-menu items in as we can't nest optgroups
|
||||
$indent_string = str_repeat( apply_filters( 'dropdown_menus_indent_string', $args->indent_string, $item, $depth, $args ), ( $depth ) ? $depth : 0 );
|
||||
$indent_string .= !empty( $indent_string ) ? apply_filters( 'dropdown_menus_indent_after', $args->indent_after, $item, $depth, $args ) : '';
|
||||
|
||||
$gdl_menu_title = strip_tags(apply_filters( 'the_title', $item->title, $item->ID ));
|
||||
$gdl_menu_title = (!empty($gdl_menu_title))? $gdl_menu_title: $item->attr_title;
|
||||
|
||||
|
||||
$item_output = $args->before . $indent_string;
|
||||
$item_output .= $args->link_before . $gdl_menu_title . $args->link_after;
|
||||
$item_output .= $args->after;
|
||||
|
||||
$output .= apply_filters( 'walker_nav_menu_dropdown_start_el', $item_output, $item, $depth, $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Walker::end_el()
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param string $output Passed by reference. Used to append additional content.
|
||||
* @param object $item Page data object. Not used.
|
||||
* @param int $depth Depth of page. Not Used.
|
||||
*/
|
||||
function end_el( &$output, $item, $depth ) {
|
||||
$output .= apply_filters( 'walker_nav_menu_dropdown_end_el', "</option>\n", $item, $depth);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigation DropDown Menu widget class
|
||||
*/
|
||||
class DropDown_Menu_Widget extends WP_Widget {
|
||||
|
||||
function __construct() {
|
||||
$widget_ops = array( 'classname' => 'dropdown-menu-widget', 'description' => __( 'Use this widget to add one of your custom menus as a dropdown.', 'gdl_back_office') );
|
||||
parent::__construct( 'dropdown_menu', __('Dropdown Menu', 'gdl_back_office'), $widget_ops );
|
||||
}
|
||||
|
||||
function widget( $args, $instance ) {
|
||||
// Get menu
|
||||
$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 $args[ 'before_widget' ];
|
||||
|
||||
if ( ! empty( $instance[ 'title' ] ) )
|
||||
echo $args[ 'before_title' ] . $instance[ 'title' ] . $args[ 'after_title' ];
|
||||
|
||||
dropdown_menu( array( 'fallback_cb' => '', 'menu' => $nav_menu ) );
|
||||
|
||||
echo $args[ 'after_widget' ];
|
||||
}
|
||||
|
||||
function update( $new_instance, $old_instance ) {
|
||||
$instance[ 'title' ] = strip_tags( stripslashes( $new_instance[ 'title' ] ) );
|
||||
$instance[ 'nav_menu' ] = (int) $new_instance[ 'nav_menu' ];
|
||||
return $instance;
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$title = isset( $instance[ 'title' ] ) ? $instance[ 'title' ] : '';
|
||||
$nav_menu = isset( $instance[ 'nav_menu' ] ) ? $instance[ 'nav_menu' ] : '';
|
||||
|
||||
// Get menus
|
||||
$menus = get_terms( 'nav_menu', array( 'hide_empty' => false ) );
|
||||
|
||||
// If no menus exists, direct the user to go and create some.
|
||||
if ( ! $menus ) {
|
||||
echo '<p>'. sprintf( __( 'No menus have been created yet. <a href="%s">Create some</a>.' ), admin_url( 'nav-menus.php' ) ) .'</p>';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'gdl_back_office' ) ?></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:', 'gdl_back_office' ); ?></label>
|
||||
<select 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
|
||||
}
|
||||
|
||||
function init() {
|
||||
register_widget( __CLASS__ );
|
||||
}
|
||||
}
|
||||
|
||||
// add widget
|
||||
// add_action( 'widgets_init', array( 'DropDown_Menu_Widget', 'init' ) );
|
||||
|
||||
?>
|
@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: Custom Image Sizes
|
||||
Plugin URI: http://ilfilosofo.com/blog/wordpress-plugins/filosofo-custom-image-sizes/
|
||||
Description: A plugin that creates custom image sizes for image attachments.
|
||||
Author: Austin Matzko
|
||||
Author URI: http://ilfilosofo.com
|
||||
Version: 1.0
|
||||
*/
|
||||
|
||||
|
||||
add_action('init', 'initialize_custom_image_sizes');
|
||||
function initialize_custom_image_sizes(){ new Filosofo_Custom_Image_Sizes; }
|
||||
|
||||
class Filosofo_Custom_Image_Sizes{
|
||||
|
||||
public function __construct(){
|
||||
add_filter('image_downsize', array(&$this, 'filter_image_downsize'), 99, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for the "image_downsize" filter.
|
||||
*
|
||||
* @param bool $ignore A value meant to discard unfiltered info returned from this filter.
|
||||
* @param int $attachment_id The ID of the attachment for which we want a certain size.
|
||||
* @param string $size_name The name of the size desired.
|
||||
*/
|
||||
public function filter_image_downsize($ignore = false, $attachment_id = 0, $size_name = 'thumbnail'){
|
||||
global $_wp_additional_image_sizes;
|
||||
|
||||
$attachment_id = (int) $attachment_id;
|
||||
|
||||
// Return the full size for 0x0
|
||||
if( $size_name == '0x0' ){ $size_name = 'full'; }
|
||||
|
||||
// Check to see if the image is already resized, if then, get the full image from database
|
||||
if( $size_name == 'full' ){
|
||||
$backup_sizes = get_post_meta( $attachment_id, '_wp_attachment_backup_sizes', true );
|
||||
if( !empty($backup_sizes) ){
|
||||
$thumbnail_size = $backup_sizes['full-orig'];
|
||||
$thumbnail_full = get_posts('post_type=attachment&numberposts=1&attachment_id=' . $attachment_id);
|
||||
if( !empty($thumbnail_full) ){
|
||||
return array( $thumbnail_full[0]->guid, $thumbnail_size['width'], $thumbnail_size['height'], '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change the size format to be widthxheight
|
||||
if( !is_array($size_name) ){
|
||||
$size_name = trim($size_name);
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
||||
$meta = wp_get_attachment_metadata($attachment_id);
|
||||
|
||||
// If the requested size does not yet exist for this attachment, $is_resized = true
|
||||
$is_resized = false;
|
||||
if( !empty($meta['sizes']) && !empty($meta['sizes'][$size_name]) && !empty($meta['file']) ){
|
||||
$path_parts = pathinfo($meta['file']);
|
||||
$norm_file = $path_parts['filename'] . '-' . $size_name;
|
||||
|
||||
$path_parts = pathinfo($meta['sizes'][$size_name]['file']);
|
||||
$cur_file = $path_parts['filename'];
|
||||
|
||||
if( $cur_file == $norm_file ){ $is_resized = true; }
|
||||
}
|
||||
|
||||
// If the requested size does not exists
|
||||
if ( empty($meta['sizes']) || empty($meta['sizes'][$size_name]) || !$is_resized ) {
|
||||
|
||||
// let's first see if this is a registered size
|
||||
if ( isset($_wp_additional_image_sizes[$size_name]) ){
|
||||
$height = (int) $_wp_additional_image_sizes[$size_name]['height'];
|
||||
$width = (int) $_wp_additional_image_sizes[$size_name]['width'];
|
||||
$crop = $_wp_additional_image_sizes[$size_name]['crop'];
|
||||
|
||||
// if not, see if name is of form [width]x[height] and use that to crop ( can use auto as a width/height )
|
||||
}else if( preg_match('#^(\d+)x(\d+)$#', $size_name, $matches) ) {
|
||||
$height = (int) $matches[2];
|
||||
$width = (int) $matches[1];
|
||||
$crop = true;
|
||||
}
|
||||
|
||||
// resize the image if width/height is set
|
||||
if ( isset($height) && isset($width) ) {
|
||||
$resized_path = $this->generate_attachment($attachment_id, $width, $height, $crop);
|
||||
|
||||
if ( !empty($resized_path) ) {
|
||||
if( function_exists('wp_basename') ){
|
||||
$file_name = wp_basename($resized_path);
|
||||
$fullsize_url = wp_get_attachment_url($attachment_id);
|
||||
$new_url = str_replace(wp_basename($fullsize_url), $file_name, $fullsize_url);
|
||||
}else{
|
||||
$file_name = basename($resized_path);
|
||||
$fullsize_url = wp_get_attachment_url($attachment_id);
|
||||
$new_url = str_replace(basename($fullsize_url), $file_name, $fullsize_url);
|
||||
}
|
||||
|
||||
$meta['sizes'][$size_name] = array('file' => $file_name, 'width' => $width, 'height' => $height);
|
||||
wp_update_attachment_metadata($attachment_id, $meta);
|
||||
|
||||
return array( $new_url, $width, $height, true );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a cropped version of an image for a given attachment ID.
|
||||
*
|
||||
* @param int $attachment_id The attachment for which to generate a cropped image.
|
||||
* @param int $width The width of the cropped image in pixels.
|
||||
* @param int $height The height of the cropped image in pixels.
|
||||
* @param bool $crop Whether to crop the generated image.
|
||||
* @return string The full path to the cropped image. Empty if failed.
|
||||
*/
|
||||
private function generate_attachment($attachment_id = 0, $width = 0, $height = 0, $crop = true){
|
||||
$attachment_id = (int) $attachment_id;
|
||||
$width = (int) $width;
|
||||
$height = (int) $height;
|
||||
$crop = (bool) $crop;
|
||||
|
||||
$original_path = get_attached_file($attachment_id);
|
||||
|
||||
// for wordpress 3.5 and above
|
||||
if( function_exists('wp_get_image_editor') ){
|
||||
add_filter('image_resize_dimensions', 'gdl_filter_image_resize_dimensions', 99, 6);
|
||||
|
||||
$orig_info = pathinfo($original_path);
|
||||
$dir = $orig_info['dirname'];
|
||||
$ext = $orig_info['extension'];
|
||||
|
||||
$suffix = "{$width}x{$height}";
|
||||
if( function_exists('wp_basename') ){
|
||||
$name = wp_basename($original_path, ".{$ext}");
|
||||
}else{
|
||||
$name = basename($original_path, ".{$ext}");
|
||||
}
|
||||
$destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
|
||||
|
||||
$cropped_image = wp_get_image_editor($original_path);
|
||||
if ( !is_wp_error($cropped_image) ) {
|
||||
$cropped_image->resize( $width, $height, true );
|
||||
$cropped_image->save( $destfilename );
|
||||
|
||||
return $destfilename;
|
||||
}
|
||||
|
||||
// for wordpress 3.4 and below
|
||||
}else{
|
||||
|
||||
// fix a WP bug up to 2.9.2
|
||||
if ( !function_exists('wp_load_image') ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/image.php';
|
||||
}
|
||||
|
||||
$resized_path = @gdl_image_resize($original_path, $width, $height, $crop);
|
||||
if ( !is_wp_error($resized_path) && !is_array($resized_path)) {
|
||||
return $resized_path;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function gdl_image_resize( $file, $max_w, $max_h, $crop = false, $suffix = null, $dest_path = null, $jpeg_quality = 100 ) {
|
||||
|
||||
$image = wp_load_image( $file );
|
||||
if ( !is_resource( $image ) )
|
||||
return new WP_Error( 'error_loading_image', $image, $file );
|
||||
|
||||
$size = @getimagesize( $file );
|
||||
if ( !$size )
|
||||
return new WP_Error('invalid_image', __('Could not read image size','gdl_back_office'), $file);
|
||||
list($orig_w, $orig_h, $orig_type) = $size;
|
||||
|
||||
$dims = gdl_image_resize_dimensions($orig_w, $orig_h, $max_w, $max_h, $crop);
|
||||
if ( !$dims )
|
||||
return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions','gdl_back_office') );
|
||||
list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims;
|
||||
|
||||
$newimage = wp_imagecreatetruecolor( $dst_w, $dst_h );
|
||||
|
||||
imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
|
||||
|
||||
// convert from full colors to index colors, like original PNG.
|
||||
if ( IMAGETYPE_PNG == $orig_type && function_exists('imageistruecolor') && !imageistruecolor( $image ) )
|
||||
imagetruecolortopalette( $newimage, false, imagecolorstotal( $image ) );
|
||||
|
||||
// we don't need the original in memory anymore
|
||||
imagedestroy( $image );
|
||||
|
||||
// $suffix will be appended to the destination filename, just before the extension
|
||||
if ( !$suffix )
|
||||
$suffix = "{$max_w}x{$max_h}";
|
||||
|
||||
$info = pathinfo($file);
|
||||
$dir = $info['dirname'];
|
||||
$ext = $info['extension'];
|
||||
if( function_exists('wp_basename') ){
|
||||
$name = wp_basename($file, ".$ext");
|
||||
}else{
|
||||
$name = basename($file, ".{$ext}");
|
||||
}
|
||||
|
||||
if ( !is_null($dest_path) and $_dest_path = realpath($dest_path) )
|
||||
$dir = $_dest_path;
|
||||
$destfilename = "{$dir}/{$name}-{$suffix}.{$ext}";
|
||||
|
||||
if ( IMAGETYPE_GIF == $orig_type ) {
|
||||
if ( !imagegif( $newimage, $destfilename ) )
|
||||
return new WP_Error('resize_path_invalid', __( 'Resize path invalid','gdl_back_office'));
|
||||
} elseif ( IMAGETYPE_PNG == $orig_type ) {
|
||||
if ( !imagepng( $newimage, $destfilename ) )
|
||||
return new WP_Error('resize_path_invalid', __( 'Resize path invalid','gdl_back_office'));
|
||||
} else {
|
||||
// all other formats are converted to jpg
|
||||
if ( 'jpg' != $ext && 'jpeg' != $ext )
|
||||
$destfilename = "{$dir}/{$name}-{$suffix}.jpg";
|
||||
if ( !imagejpeg( $newimage, $destfilename, apply_filters( 'jpeg_quality', $jpeg_quality, 'image_resize' ) ) )
|
||||
return new WP_Error('resize_path_invalid', __( 'Resize path invalid','gdl_back_office'));
|
||||
}
|
||||
|
||||
imagedestroy( $newimage );
|
||||
|
||||
// Set correct file permissions
|
||||
$stat = stat( dirname( $destfilename ));
|
||||
$perms = $stat['mode'] & 0000666; //same permissions as parent folder, strip off the executable bits
|
||||
@ chmod( $destfilename, $perms );
|
||||
|
||||
return $destfilename;
|
||||
}
|
||||
|
||||
function gdl_filter_image_resize_dimensions($ignore = false, $orig_w, $orig_h, $dest_w, $dest_h, $crop = false){
|
||||
return gdl_image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop);
|
||||
}
|
||||
function gdl_image_resize_dimensions($orig_w, $orig_h, $dest_w, $dest_h, $crop = false){
|
||||
|
||||
if ($orig_w <= 0 || $orig_h <= 0)
|
||||
return false;
|
||||
|
||||
if ($dest_w <= 0 && $dest_h <= 0)
|
||||
return false;
|
||||
|
||||
if ( $crop ) {
|
||||
// crop the largest possible portion of the original image that we can size to $dest_w x $dest_h
|
||||
$aspect_ratio = $orig_w / $orig_h;
|
||||
$new_w = $dest_w;
|
||||
$new_h = $dest_h;
|
||||
|
||||
if ( !$new_w ) {
|
||||
$new_w = intval($new_h * $aspect_ratio);
|
||||
}
|
||||
|
||||
if ( !$new_h ) {
|
||||
$new_h = intval($new_w / $aspect_ratio);
|
||||
}
|
||||
|
||||
$size_ratio = max($new_w / $orig_w, $new_h / $orig_h);
|
||||
|
||||
$crop_w = round($new_w / $size_ratio);
|
||||
$crop_h = round($new_h / $size_ratio);
|
||||
|
||||
$s_x = floor( ($orig_w - $crop_w) / 2 );
|
||||
$s_y = floor( ($orig_h - $crop_h) / 2 );
|
||||
} else {
|
||||
// don't crop, just resize using $dest_w x $dest_h as a maximum bounding box
|
||||
$crop_w = $orig_w;
|
||||
$crop_h = $orig_h;
|
||||
|
||||
$s_x = 0;
|
||||
$s_y = 0;
|
||||
|
||||
list( $new_w, $new_h ) = wp_constrain_dimensions( $orig_w, $orig_h, $dest_w, $dest_h );
|
||||
}
|
||||
|
||||
// if the resulting image would be the same size we don't want to resize it
|
||||
if ( $new_w == $orig_w && $new_h == $orig_h )
|
||||
return false;
|
||||
|
||||
// the return array matches the parameters to imagecopyresampled()
|
||||
// int dst_x, int dst_y, int src_x, int src_y, int dst_w, int dst_h, int src_w, int src_h
|
||||
return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
|
||||
|
||||
}
|
||||
|
||||
add_action('delete_attachment', 'gdl_delete_filosofo_image', 10, 1);
|
||||
function gdl_delete_filosofo_image($post_id){
|
||||
$uploadpath = wp_upload_dir();
|
||||
|
||||
$meta = wp_get_attachment_metadata($post_id);
|
||||
if( !empty($meta) ){
|
||||
$path_parts = pathinfo($meta['file']);
|
||||
|
||||
$all_size = $meta['sizes'];
|
||||
if( !empty($all_size) ){
|
||||
foreach( $all_size as $each_size => $each_data ){
|
||||
if(preg_match('#^(\d+)x(\d+)$#', $each_size)){
|
||||
@ unlink( path_join($uploadpath['basedir'], $path_parts['dirname'] . '/' . $each_data['file']) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
288
wp-content/themes/worldwide-v1-01/include/plugin/fontloader.php
Normal file
288
wp-content/themes/worldwide-v1-01/include/plugin/fontloader.php
Normal file
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Goodlayers Fontloader File
|
||||
* ---------------------------------------------------------------------
|
||||
* @version 1.0
|
||||
* @author Goodlayers
|
||||
* @link http://goodlayers.com
|
||||
* @copyright Copyright (c) Goodlayers
|
||||
* ---------------------------------------------------------------------
|
||||
* This file manage all fonts in this framework including Cufon and
|
||||
* Google font ( in google-font.php file )
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// all fonts array in this framework ( at first will be only cufon in the array )
|
||||
$all_font = array();
|
||||
|
||||
// get custom upload font from the goodlayers panel
|
||||
get_uploaded_font();
|
||||
function get_uploaded_font(){
|
||||
|
||||
global $all_font;
|
||||
global $goodlayers_element;
|
||||
$upload_font_xml = get_option(THEME_SHORT_NAME.'_upload_font');
|
||||
$all_font['Custom Font'] = array('status'=>'disabled','type'=>'Cufon','is-used'=>false);
|
||||
|
||||
if(!empty($upload_font_xml)){
|
||||
|
||||
$xml = new DOMDocument();
|
||||
$xml->loadXML($upload_font_xml);
|
||||
|
||||
foreach( $xml->documentElement->childNodes as $each_font ){
|
||||
$all_font[find_xml_value($each_font, 'name')] = array('status'=>'enabled','type'=>'Cufon','is-used'=>false,
|
||||
'path'=>wp_get_attachment_url(find_xml_value($each_font, 'file')) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
$all_font = array_merge($all_font, array(
|
||||
'Cufon' => array(
|
||||
'status'=>'disabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon.js'),
|
||||
|
||||
'Aller' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Aller_400.font.js'),
|
||||
|
||||
'Bebas' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Bebas_400.font.js'),
|
||||
|
||||
'Cabin Cufon' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Cabin_400.font.js'),
|
||||
|
||||
'Cantarell Cufon' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/cantarell.js'),
|
||||
|
||||
'Cicle Gordita' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Cicle_Gordita_700.font.js'),
|
||||
|
||||
'Colaborate Light' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/ColaborateLight_400.font.js'),
|
||||
|
||||
'Gnuolane Free' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Gnuolane_Free_400.font.js'),
|
||||
|
||||
'Josefin Sans Cufon' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Josefin_Sans_Std_300.font.js'),
|
||||
|
||||
'Luxi Serif' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Luxi_Serif_400.font.js'),
|
||||
|
||||
'Museo Sans' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Museo_Sans_500.font.js'),
|
||||
|
||||
'Nobile Cufon' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Nobile_400.font.js'),
|
||||
|
||||
'Oswald Cufon' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Oswald_400.font.js'),
|
||||
|
||||
'Quicksand Book' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Quicksand_Book_400.font.js'),
|
||||
|
||||
'Samba' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Samba_400.font.js'),
|
||||
|
||||
'Sansation' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Sansation_400.font.js'),
|
||||
|
||||
'Yanone Kaffeesatz Cufon' => array(
|
||||
'status'=>'enabled',
|
||||
'type'=>'Cufon',
|
||||
'is-used'=>false,
|
||||
'path'=>GOODLAYERS_PATH.'/javascript/cufon/Yanone_Kaffeesatz_400.font.js'),
|
||||
));
|
||||
|
||||
// get google font from file and added to all_font array
|
||||
get_google_font();
|
||||
function get_google_font(){
|
||||
|
||||
include_once('google-font.php');
|
||||
|
||||
global $all_font;
|
||||
$all_font['Google Font'] = array('status'=>'disabled','type'=>'Cufon','is-used'=>false);
|
||||
$google_fonts = get_google_font_array();
|
||||
|
||||
foreach($google_fonts as $google_font){
|
||||
|
||||
$all_font[$google_font['family']] = array('status'=>'enabled','type'=>'Google Font','is-used'=>false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// this is a function that return all_font arrays to use with <select> element
|
||||
function get_font_array( $type = '' ){
|
||||
global $all_font;
|
||||
$fonts = array('- default -' => '');
|
||||
|
||||
foreach($all_font as $font_name => $font_value){
|
||||
|
||||
if( empty($type) || $type == $font_value['type'] ){
|
||||
$fonts[$font_name] = $font_value['status'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
|
||||
}
|
||||
|
||||
// check and marked if font is being used
|
||||
add_action('init', 'is_font_used');
|
||||
function is_font_used(){
|
||||
global $all_font, $goodlayers_element;
|
||||
|
||||
foreach($goodlayers_element['gdl_panel_font'] as $field){
|
||||
|
||||
$used_font = get_option($field['name']);
|
||||
|
||||
if(!empty($used_font)){
|
||||
|
||||
$used_font = substr($used_font, 2);
|
||||
|
||||
if($used_font != "default -"){
|
||||
|
||||
$all_font[$used_font]['is-used'] = true;
|
||||
|
||||
if($all_font[$used_font]['type'] == 'Cufon'){
|
||||
|
||||
$all_font['Cufon']['is-used'] = true;
|
||||
|
||||
}else if($field['type'] == 'Google Font'){
|
||||
|
||||
$all_font['Google Font'] = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$all_font['Droid Serif']['is-used'] = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// include all used font into the website
|
||||
add_action('init', 'include_used_font');
|
||||
function include_used_font(){
|
||||
if(is_admin()) return;
|
||||
|
||||
global $all_font;
|
||||
$google_font_family = '';
|
||||
|
||||
$font_weight = get_option(THEME_SHORT_NAME.'_google_font_weight', 'n,i,b,bi');
|
||||
$font_subset = get_option(THEME_SHORT_NAME.'_google_font_subset', 'latin');
|
||||
|
||||
foreach($all_font as $font_name => $font){
|
||||
|
||||
if($font['is-used']){
|
||||
|
||||
if($font['type'] == 'Cufon'){
|
||||
|
||||
wp_deregister_script($font_name);
|
||||
if( $font_name == 'Cufon'){
|
||||
wp_register_script($font_name, $font['path'], false, '1.0', false);
|
||||
}else{
|
||||
wp_register_script($font_name, $font['path'], false, '1.0', true);
|
||||
}
|
||||
wp_enqueue_script($font_name);
|
||||
|
||||
}else if($font['type'] == 'Google Font'){
|
||||
$temp_font_name = str_replace(' ', '+' , $font_name);
|
||||
$google_font_family = $temp_font_name . ':' . $font_weight . '&subset=' . $font_subset;
|
||||
wp_enqueue_style('Google-Font-' . $temp_font_name,'http://fonts.googleapis.com/css?family=' . $google_font_family);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Ajax to include font infomation
|
||||
add_action('wp_ajax_get_gdl_font_url','get_gdl_font_url');
|
||||
function get_gdl_font_url(){
|
||||
|
||||
global $all_font;
|
||||
$recieve_font = $_POST['font'];
|
||||
|
||||
if($all_font[$recieve_font]['type'] == 'Cufon'){
|
||||
|
||||
$font_url = array('type'=>$all_font[$recieve_font]['type'], 'url'=>$all_font[$recieve_font]['path']);
|
||||
|
||||
}else if($all_font[$recieve_font]['type'] == "Google Font"){
|
||||
|
||||
$font_url = array('type'=>$all_font[$recieve_font]['type'], 'url'=>'http://fonts.googleapis.com/css?family=' . str_replace(' ', '+' , $recieve_font));
|
||||
|
||||
}else{
|
||||
|
||||
die(-1);
|
||||
|
||||
}
|
||||
|
||||
die(json_encode($font_url));
|
||||
|
||||
}
|
||||
|
||||
// Ajax to get cufon information
|
||||
add_action('wp_ajax_get_cufon_position','get_cufon_position');
|
||||
function get_cufon_position(){
|
||||
|
||||
|
||||
}
|
||||
?>
|
7282
wp-content/themes/worldwide-v1-01/include/plugin/google-font.php
Normal file
7282
wp-content/themes/worldwide-v1-01/include/plugin/google-font.php
Normal file
File diff suppressed because it is too large
Load Diff
452
wp-content/themes/worldwide-v1-01/include/plugin/misc.php
Normal file
452
wp-content/themes/worldwide-v1-01/include/plugin/misc.php
Normal file
@ -0,0 +1,452 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Goodlayers Misc File
|
||||
* ---------------------------------------------------------------------
|
||||
* @version 1.0
|
||||
* @author Goodlayers
|
||||
* @link http://goodlayers.com
|
||||
* @copyright Copyright (c) Goodlayers
|
||||
* ---------------------------------------------------------------------
|
||||
* This file contains all of the necessary function for the front-end to
|
||||
* easily used. You can see the description of each function below.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Get sidebar size array
|
||||
function gdl_get_sidebar_size( $sidebar = ''){
|
||||
global $sidebar_type;
|
||||
|
||||
$sidebar_type = 'no-sidebar';
|
||||
$sidebar_array = array('sidebar_class'=>'','page_left_class'=>'twelve columns', 'page_item_class'=>'twelve columns');
|
||||
if( $sidebar == "right-sidebar" || $sidebar == "left-sidebar" ){
|
||||
$sidebar_type = 'one-sidebar';
|
||||
$sidebar_array['sidebar_class'] = "single-sidebar right-sidebar";
|
||||
$sidebar_array['page_left_class'] = "page-left-right-sidebar";
|
||||
$sidebar_array['page_item_class'] = "twelve columns";
|
||||
}else if( $sidebar == "both-sidebar" || $sidebar == "both-sidebar-reverse" ){
|
||||
$sidebar_type = 'both-sidebar';
|
||||
$sidebar_array['sidebar_class'] = "both-sidebar";
|
||||
$sidebar_array['page_left_class'] = "page-left-both-sidebar";
|
||||
$sidebar_array['page_item_class'] = "nine columns";
|
||||
}
|
||||
|
||||
return $sidebar_array;
|
||||
}
|
||||
|
||||
// Check if url is from which type of video
|
||||
function get_video($url, $width = 640, $height = 360){
|
||||
if( empty($width) && empty($height) ){ $width = 640; $height = 360; }
|
||||
|
||||
if(strpos($url,'youtube')){
|
||||
get_youtube($url, $width, $height);
|
||||
}else if(strpos($url,'youtu.be')){
|
||||
get_youtube($url, $width, $height, 'youtu.be');
|
||||
}else if(strpos($url,'vimeo')){
|
||||
get_vimeo($url, $width, $height);
|
||||
}
|
||||
}
|
||||
|
||||
// Print HTML5 Video
|
||||
function get_html5_video($video){
|
||||
if( class_exists('JWP6_Shortcode') ){
|
||||
echo JWP6_Shortcode::the_content_filter($video);
|
||||
}
|
||||
}
|
||||
|
||||
// Print youtube video
|
||||
function get_youtube($url, $width = 640, $height = 360, $type = 'youtube', $return = false){
|
||||
if( $type == 'youtube' ){
|
||||
preg_match('/[\\?\\&]v=([^\\?\\&]+)/',$url,$id);
|
||||
}else{
|
||||
preg_match('/youtu.be\/([^\\?\\&]+)/', $url, $id);
|
||||
}
|
||||
|
||||
$attr = "";
|
||||
if( strpos($url, 'autoplay=1') > 0 ) $attr = "&autoplay=1";
|
||||
if( strpos($url, 'rel=0') > 0 ) $attr = $attr . "&rel=0";
|
||||
|
||||
if( !$return ){
|
||||
echo '<iframe src="http://www.youtube.com/embed/' . $id[1] . '?wmode=transparent' . $attr . '" width="' . $width . '" height="' . $height . '" ></iframe>';
|
||||
}else{
|
||||
return '<iframe src="http://www.youtube.com/embed/' . $id[1] . '?wmode=transparent' . $attr . '" width="' . $width . '" height="' . $height . '" ></iframe>';
|
||||
}
|
||||
}
|
||||
|
||||
// Print vimeo video
|
||||
function get_vimeo($url, $width = 640, $height = 360, $return = false){
|
||||
preg_match('/https?:\/\/vimeo.com\/(\d+)$/', $url, $id);
|
||||
|
||||
if( !$return ){
|
||||
echo '<iframe src="http://player.vimeo.com/video/' . $id[1] . '?title=0&byline=0&portrait=0" width="' . $width . '" height="' . $height . '"></iframe>';
|
||||
}else{
|
||||
return '<iframe src="http://player.vimeo.com/video/' . $id[1] . '?title=0&byline=0&portrait=0" width="' . $width . '" height="' . $height . '"></iframe>';
|
||||
}
|
||||
}
|
||||
|
||||
// Print nivo slider
|
||||
function print_nivo_slider($slider_xml, $size='940x360'){
|
||||
if( empty($slider_xml) ) return;
|
||||
|
||||
global $gdl_element_id;
|
||||
|
||||
$caption_array = array();
|
||||
$caption_num = 0;
|
||||
|
||||
echo '<div class="nivoSliderWrapper">';
|
||||
echo '<div class="nivoSlider gdl-slider">';
|
||||
foreach($slider_xml->childNodes as $slider){
|
||||
$title = find_xml_value($slider, 'title');
|
||||
$caption = html_entity_decode(find_xml_value($slider, 'caption'));
|
||||
$link = find_xml_value($slider, 'link');
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$comment = find_xml_value($slider, 'comment');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $size);
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
if($link_type == 'Lightbox'){
|
||||
$image_full_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full_url[0] . '" title="' . $alt_text . '">';
|
||||
}else if($link_type == 'Link to Video'){
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $link . '" title="' . $alt_text . '">';
|
||||
}else if($link_type != 'No Link'){
|
||||
echo '<a href="' . $link . '" >';
|
||||
}
|
||||
|
||||
echo '<img class="gdl-no-preload" src="' . $image_url[0];
|
||||
if ( !empty($title) || !empty($caption)){
|
||||
$caption_array[$caption_num]['title'] = $title;
|
||||
$caption_array[$caption_num]['caption'] = $caption;
|
||||
$caption_array[$caption_num]['comment'] = $comment;
|
||||
echo '" title="#nivo-caption' . $caption_num;
|
||||
$caption_num++;
|
||||
}
|
||||
echo '" alt="' . $alt_text . '" />';
|
||||
|
||||
if($link_type != 'No Link'){
|
||||
echo '</a>';
|
||||
}
|
||||
}
|
||||
echo "</div>"; // nivo slider
|
||||
echo "</div>"; // nivo slider wrapper
|
||||
|
||||
for( $i=0; $i<$caption_num; $i++ ){
|
||||
echo "<div class='nivo-caption' id='nivo-caption" . $i . "' >";
|
||||
$comment_class = (!empty($caption_array[$i]['comment']))? 'comment-on': '';
|
||||
|
||||
echo '<div class="gdl-slider-caption-wrapper ' . $comment_class . '">';
|
||||
if( !empty($caption_array[$i]['title']) ){
|
||||
echo "<h2 class='gdl-slider-title'><span>" . $caption_array[$i]['title'] . "</span></h2>";
|
||||
}
|
||||
if( !empty($caption_array[$i]['caption']) ){
|
||||
echo "<div class='gdl-slider-caption'>" . $caption_array[$i]['caption'] . "</div>";
|
||||
}
|
||||
echo "</div>"; // gdl-slider-caption-wrapper
|
||||
if( !empty($caption_array[$i]['comment']) ){
|
||||
echo '<div class="post-slider-comment" >';
|
||||
echo '<i class="icon-comments"></i>';
|
||||
echo $caption_array[$i]['comment'];
|
||||
echo '</div>';
|
||||
}
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
$gdl_element_id++;
|
||||
}
|
||||
|
||||
// Print flex slider
|
||||
function print_flex_slider($slider_xml, $size="940x360"){
|
||||
if( empty($slider_xml) ) return;
|
||||
|
||||
global $gdl_element_id;
|
||||
|
||||
echo '<div class="flexslider gdl-slider" >';
|
||||
echo '<ul class="slides">';
|
||||
foreach($slider_xml->childNodes as $slider){
|
||||
|
||||
$title = find_xml_value($slider, 'title');
|
||||
$caption = html_entity_decode(find_xml_value($slider, 'caption'));
|
||||
$link = find_xml_value($slider, 'link');
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$comment = find_xml_value($slider, 'comment');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $size);
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
echo '<li>';
|
||||
if($link_type == 'Lightbox'){
|
||||
$image_full_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full_url[0] . '" title="' . $alt_text . '">';
|
||||
}else if($link_type == 'Link to Video'){
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $link . '" title="' . $alt_text . '">';
|
||||
}else if($link_type != 'No Link'){
|
||||
echo '<a href="' . $link . '" >';
|
||||
}
|
||||
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
if( !empty($title) || !empty($caption) ){
|
||||
$comment_class = (!empty($comment))? 'comment-on': '';
|
||||
|
||||
echo '<div class="flex-caption">';
|
||||
echo '<div class="gdl-slider-caption-wrapper ' . $comment_class . '">';
|
||||
if( !empty($title) ){
|
||||
echo '<h2 class="gdl-slider-title"><span>' . $title . '</span></h2>';
|
||||
}
|
||||
if( !empty($caption) ){
|
||||
echo '<div class="gdl-slider-caption">'. $caption . '</div>';
|
||||
}
|
||||
echo '</div>'; // gdl-slider-caption-wrapper
|
||||
if( !empty($comment) ){
|
||||
echo '<div class="post-slider-comment" >';
|
||||
echo '<i class="icon-comments"></i>';
|
||||
echo $comment;
|
||||
echo '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if($link_type != 'No Link'){
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</li>';
|
||||
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
$gdl_element_id++;
|
||||
echo "</div>"; // flex slider
|
||||
}
|
||||
|
||||
// Print Stack Images
|
||||
function print_stack_images($slider_xml, $size="940x360"){
|
||||
if( empty($slider_xml) ) return;
|
||||
|
||||
global $gdl_element_id;
|
||||
|
||||
echo '<div class="stack-images-wrapper" >';
|
||||
foreach($slider_xml->childNodes as $slider){
|
||||
|
||||
$title = find_xml_value($slider, 'title');
|
||||
$caption = html_entity_decode(find_xml_value($slider, 'caption'));
|
||||
$link = find_xml_value($slider, 'link');
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $size);
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
echo '<div class="stack-images-single">';
|
||||
if($link_type == 'Lightbox'){
|
||||
$image_full_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full_url[0] . '" title="' . $alt_text . '">';
|
||||
}else if($link_type == 'Link to Video'){
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $link . '" title="' . $alt_text . '">';
|
||||
}else if($link_type != 'No Link'){
|
||||
echo '<a href="' . $link . '" >';
|
||||
}
|
||||
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
if( !empty($title) || !empty($caption) ){
|
||||
echo '<div class="stack-images-caption">';
|
||||
if( !empty($title) ){
|
||||
echo '<h2 class="gdl-slider-title">' . $title . '</h2>';
|
||||
echo "<div class='clear'></div>";
|
||||
}
|
||||
if( !empty($caption) ){
|
||||
echo '<div class="gdl-slider-caption"><div class="gdl-slider-inner-caption">'. $caption . '</div></div>';
|
||||
echo "<div class='clear'></div>";
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if($link_type != 'No Link'){
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
$gdl_element_id++;
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo "</div>"; // stack-images-wrapper
|
||||
}
|
||||
|
||||
// Print carousel slider
|
||||
function print_carousel_slider($slider_xml, $size="940x360"){
|
||||
if( empty($slider_xml) ) return;
|
||||
|
||||
global $gdl_element_id;
|
||||
|
||||
echo '<div class="flexslider gdl-slider carousel-included" ';
|
||||
echo 'data-width="' . gdl_get_width($size) . '" >';
|
||||
echo '<ul class="slides">';
|
||||
foreach($slider_xml->childNodes as $slider){
|
||||
|
||||
$title = find_xml_value($slider, 'title');
|
||||
$caption = html_entity_decode(find_xml_value($slider, 'caption'));
|
||||
$link = find_xml_value($slider, 'link');
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$comment = find_xml_value($slider, 'comment');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $size);
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
echo '<li>';
|
||||
if($link_type == 'Lightbox'){
|
||||
$image_full_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full_url[0] . '" title="' . $alt_text . '">';
|
||||
}else if($link_type == 'Link to Video'){
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $link . '" title="' . $alt_text . '">';
|
||||
}else if($link_type != 'No Link'){
|
||||
echo '<a href="' . $link . '" >';
|
||||
}
|
||||
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
if( !empty($title) || !empty($caption) ){
|
||||
echo '<div class="gdl-caption-overlay" ></div>';
|
||||
if( !empty($comment) ){
|
||||
echo '<div class="post-slider-comment" >';
|
||||
echo '<i class="icon-comments"></i>';
|
||||
echo $comment;
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="flex-caption">';
|
||||
echo '<div class="gdl-slider-caption-wrapper">';
|
||||
if( !empty($title) ){
|
||||
echo '<h2 class="gdl-slider-title">' . $title . '</h2>';
|
||||
}
|
||||
if( !empty($caption) ){
|
||||
echo '<div class="gdl-slider-caption">'. $caption . '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
if($link_type != 'No Link'){
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</li>';
|
||||
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
$gdl_element_id++;
|
||||
echo "</div>"; // flex slider
|
||||
|
||||
}
|
||||
|
||||
// Print anything slider
|
||||
function print_anything_slider($slider_xml, $size='940x360'){
|
||||
if( empty($slider_xml) ) return;
|
||||
|
||||
global $gdl_element_id;
|
||||
|
||||
echo '<ul id="slider" class="anythingSlider gdl-slider" style="width:' . gdl_get_width($size) . 'px; height:' . gdl_get_height($size). 'px;">';
|
||||
foreach($slider_xml->childNodes as $slider){
|
||||
|
||||
$title = find_xml_value($slider, 'title');
|
||||
$caption = html_entity_decode(find_xml_value($slider, 'caption'));
|
||||
$link = find_xml_value($slider, 'link');
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $size);
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
echo '<li>';
|
||||
|
||||
if($link_type == 'Link to Video'){
|
||||
echo get_video($link, gdl_get_width($size), gdl_get_height($size));
|
||||
}else{
|
||||
|
||||
if($link_type == 'Lightbox'){
|
||||
$image_full_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full_url[0] . '" title="' . $alt_text . '">';
|
||||
}else if($link_type != 'No Link'){
|
||||
echo '<a href="' . $link . '" alt="" >';
|
||||
}
|
||||
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
if(!empty($title) || !empty($caption)){
|
||||
echo '<div class="anything-caption">';
|
||||
if( !empty($title) ){
|
||||
echo '<h2 class="gdl-slider-title">' . $title . '</h2>';
|
||||
echo "<div class='clear'></div>";
|
||||
}
|
||||
if( !empty($caption) ){
|
||||
echo '<div class="gdl-slider-caption"><div class="gdl-slider-inner-caption">' . $caption . '</div></div>';
|
||||
echo "<div class='clear'></div>";
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
};
|
||||
|
||||
if($link_type != 'No Link'){
|
||||
echo '</a>';
|
||||
}
|
||||
}
|
||||
echo '</li>';
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
$gdl_element_id ++;
|
||||
}
|
||||
|
||||
// send contact form email
|
||||
add_action('wp_ajax_submit_contact_form','gdl_submit_contact_form');
|
||||
add_action('wp_ajax_nopriv_submit_contact_form','gdl_submit_contact_form');
|
||||
function gdl_submit_contact_form(){
|
||||
|
||||
global $gdl_admin_translator;
|
||||
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$gdl_send_complete = get_option(THEME_SHORT_NAME.'_translator_contact_send_complete', 'The e-mail was sent successfully');
|
||||
$gdl_send_error = get_option(THEME_SHORT_NAME.'_translator_contact_send_error', 'Message cannot be sent to destination');
|
||||
}else{
|
||||
$gdl_send_complete = __('The e-mail was sent successfully','gdl_front_end');
|
||||
$gdl_send_error = __('Message cannot be sent to destination','gdl_front_end');
|
||||
}
|
||||
|
||||
$return_data = array('success'=>'0');
|
||||
|
||||
if(empty($_POST)){
|
||||
$return_data['value'] = 'Cannot send email to destination. No parameter receive form AJAX call.';
|
||||
die ( json_encode($return_data) );
|
||||
}
|
||||
|
||||
$name = $_POST['name'];
|
||||
if(empty($name)){
|
||||
$return_data['value'] = 'Please enter your name.';
|
||||
die ( json_encode($return_data) );
|
||||
}
|
||||
|
||||
$email = $_POST['email'];
|
||||
if(empty($email)){
|
||||
$return_data['value'] = 'Please enter a valid email address.';
|
||||
die ( json_encode($return_data) );
|
||||
}
|
||||
|
||||
$message = $_POST['message'];
|
||||
if(empty($message)){
|
||||
$return_data['value'] = 'Please enter message.';
|
||||
die ( json_encode($return_data) );
|
||||
}
|
||||
|
||||
$receiver = $_POST['receiver'];
|
||||
|
||||
$messages = "You have received a new contact form message. \n";
|
||||
$messages = $messages . 'Name : ' . $name . " \n";
|
||||
$messages = $messages . 'Email : ' . $email . " \n";
|
||||
$messages = $messages . 'Message : ' . $message;
|
||||
|
||||
$header = "From: " . $name . " <" . $email . "> \r\n";
|
||||
$header = $header . "To: " . $receiver . " \r\n";
|
||||
$header = $header . 'Content-Type: text/plain; charset=UTF-8 ' . " \r\n";
|
||||
|
||||
if( wp_mail($receiver, 'New contact form received', $messages, $header) ){
|
||||
$return_data['success'] = '1';
|
||||
$return_data['value'] = $gdl_send_complete;
|
||||
die( json_encode($return_data) );
|
||||
}else{
|
||||
$return_data['value'] = $gdl_send_error;
|
||||
die( json_encode($return_data) );
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
726
wp-content/themes/worldwide-v1-01/include/plugin/page-item.php
Normal file
726
wp-content/themes/worldwide-v1-01/include/plugin/page-item.php
Normal file
@ -0,0 +1,726 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Goodlayers Page Item File
|
||||
* ---------------------------------------------------------------------
|
||||
* @version 1.0
|
||||
* @author Goodlayers
|
||||
* @link http://goodlayers.com
|
||||
* @copyright Copyright (c) Goodlayers
|
||||
* ---------------------------------------------------------------------
|
||||
* This file contains the function that can print each page item due to
|
||||
* different conditions.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
$gdl_div_size_num_class = array(
|
||||
"1/6" => "two columns ", "element1-6" => "two columns ",
|
||||
"1/5" => "one-fifth column ", "element1-5" => "one-fifth column ",
|
||||
"1/4" => "three columns ", "element1-4" => "three columns ",
|
||||
"1/3" => "four columns ", "element1-3" => "four columns ",
|
||||
"1/2" => "six columns ", "element1-2" => "six columns ",
|
||||
"2/3" => "eight columns ", "element2-3" => "eight columns ",
|
||||
"3/4" => "nine columns ", "element3-4" => "nine columns ",
|
||||
"1/1" => "twelve columns ", "element1-1" => "twelve columns " );
|
||||
$gdl_class_to_num = array(
|
||||
"element1-6" => 1/6, "1/6"=>1/6,
|
||||
"element1-5" => 1/5, "1/5"=>1/5,
|
||||
"element1-4" => 1/4, "1/4"=>1/4,
|
||||
"element1-3" => 1/3, "1/3"=>1/3,
|
||||
"element1-2" => 0.5, "1/2"=>0.5,
|
||||
"element2-3" => 2/3, "2/3"=>2/3,
|
||||
"element3-4" => 3/4, "3/4"=>3/4,
|
||||
"element1-1" => 1, "1/1" => 1 );
|
||||
|
||||
// Print the item size <div> with it's class
|
||||
function print_item_size($item_size, $item_row_size = '0', $addition_class='',
|
||||
$html_row_tag = 'div', $html_col_tag = 'div', $additional_style=''){
|
||||
global $gdl_div_size_num_class, $gdl_class_to_num;
|
||||
|
||||
// init the first row
|
||||
if( empty($item_row_size) ){
|
||||
echo '<' . $html_row_tag .' class="row">';
|
||||
}
|
||||
|
||||
$gdl_row_class = $gdl_div_size_num_class[$item_size] . $addition_class;
|
||||
$gdl_item_size = $gdl_class_to_num[$item_size];
|
||||
$item_row_size = $item_row_size + $gdl_item_size;
|
||||
|
||||
if($item_row_size > 1){
|
||||
$item_row_size = $gdl_item_size;
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close row
|
||||
echo '<' . $html_row_tag . ' class="row">'; // open new row
|
||||
}
|
||||
|
||||
if( empty($additional_style) ){
|
||||
echo '<' . $html_col_tag . ' class="' . $gdl_row_class . '">';
|
||||
}else{
|
||||
echo '<' . $html_col_tag . ' class="' . $gdl_row_class . '" style="' . $additional_style . '">';
|
||||
}
|
||||
|
||||
return $item_row_size;
|
||||
}
|
||||
|
||||
// Print the item size <div> with it's class
|
||||
function return_item_size($item_size, $item_row_size = '0', $addition_class='', $html_row_tag = 'div', $html_col_tag = 'div'){
|
||||
global $gdl_div_size_num_class, $gdl_class_to_num;
|
||||
|
||||
$return = "";
|
||||
|
||||
// init the first row
|
||||
if( empty($item_row_size) ){
|
||||
$return = $return . '<' . $html_row_tag .' class="row">';
|
||||
}
|
||||
|
||||
$gdl_row_class = $gdl_div_size_num_class[$item_size] . $addition_class;
|
||||
$gdl_item_size = $gdl_class_to_num[$item_size];
|
||||
$item_row_size = $item_row_size + $gdl_item_size;
|
||||
|
||||
if($item_row_size > 1){
|
||||
$item_row_size = $gdl_item_size;
|
||||
$return = $return . '<div class="clear"></div>';
|
||||
$return = $return . '</div>'; // close row
|
||||
$return = $return . '<' . $html_row_tag . ' class="row">'; // open new row
|
||||
}
|
||||
|
||||
$return = $return . '<' . $html_col_tag . ' class="' . $gdl_row_class . '">';
|
||||
|
||||
return array( 'row-size'=>$item_row_size, 'return'=>$return);
|
||||
}
|
||||
|
||||
// Print page header
|
||||
function print_page_header( $header, $caption = '' ){
|
||||
echo '<div class="page-header-wrapper gdl-container-color boxed-style gdl-border-x bottom">';
|
||||
echo '<div class="page-header-container container">';
|
||||
|
||||
echo '<div class="page-header-inner-wrapper ">';
|
||||
echo '<h1 class="page-header-title">' . $header . '</h1>';
|
||||
if( !empty($caption) ){
|
||||
echo '<div class="page-header-caption"><span class="head">//</span>' . $caption . '</div>';
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // page header inner wrapper
|
||||
|
||||
echo '</div>'; // page header container
|
||||
echo '</div>'; // page header wrapper
|
||||
}
|
||||
|
||||
// Print header of each item
|
||||
function print_item_header( $header, $addition_class = '', $additional_html = '' ){
|
||||
if(!empty($header)){
|
||||
echo '<div class="gdl-header-wrapper ' . $addition_class . '">';
|
||||
echo '<h3 class="gdl-header-title">' . $header . '</h3><i class="icon-double-angle-right"></i>';
|
||||
echo $additional_html;
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Print accordion
|
||||
function print_accordion_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
$gdl_active = 'active';
|
||||
$tab_xml = find_xml_node($item_xml, 'tab-item');
|
||||
echo "<ul class='gdl-accordion'>";
|
||||
foreach($tab_xml->childNodes as $accordion){
|
||||
echo '<li class="' . $gdl_active . '">';
|
||||
echo '<h2 class="accordion-title"><span class="accordion-icon"></span>' . find_xml_value($accordion, 'title') . '</h2>';
|
||||
echo '<div class="accordion-content" >';
|
||||
echo do_shortcode(find_xml_value($accordion, 'caption')) . '</div>';
|
||||
echo '</li>';
|
||||
|
||||
if( !empty($gdl_active) ) $gdl_active = '';
|
||||
}
|
||||
echo "</ul>";
|
||||
}
|
||||
|
||||
// Print column
|
||||
function print_column_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
echo '<div class="gdl-column-item">';
|
||||
echo do_shortcode(html_entity_decode(find_xml_value($item_xml,'column-text')));
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// Print Content Item
|
||||
function print_content_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
wp_reset_query();
|
||||
if(have_posts()){
|
||||
while(have_posts()){
|
||||
the_post();
|
||||
the_content();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print Divider
|
||||
function print_divider($item_xml){
|
||||
echo '<div class="gdl-divider-wrapper">';
|
||||
echo '<div class="scroll-top">';
|
||||
echo find_xml_value($item_xml, 'text');
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="gdl-divider"></div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// Print gallery
|
||||
function print_gallery_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
global $gallery_div_size_num_class, $sidebar_type, $gdl_element_id;
|
||||
|
||||
$gallery_row_size = 0;
|
||||
$gallery_page = find_xml_value($item_xml, 'page');
|
||||
$gallery_size = find_xml_value($item_xml, 'item-size');
|
||||
$item_size = $gallery_div_size_num_class[$gallery_size][$sidebar_type];
|
||||
|
||||
$gallery_post = get_posts(array('post_type' => 'gdl-gallery', 'name'=>$gallery_page, 'numberposts'=> 1));
|
||||
|
||||
echo '<div class="gdl-gallery-item">';
|
||||
|
||||
$slider_xml_string = get_post_meta($gallery_post[0]->ID,'post-option-gallery-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
if( !empty( $slider_xml_string ) ){
|
||||
$slider_xml_dom->loadXML($slider_xml_string);
|
||||
foreach( $slider_xml_dom->documentElement->childNodes as $slider ){
|
||||
$gallery_row_size = print_item_size($gallery_size, $gallery_row_size, 'mb40');
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $item_size);
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
echo '<div class="gdl-gallery-image">';
|
||||
if( $link_type == 'Link to URL' ){
|
||||
$link = find_xml_value( $slider, 'link');
|
||||
echo '<a href="' . $link . '" title="' . $link . '" target="_blank">';
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
echo '</a>';
|
||||
}else if( $link_type == 'Lightbox' ){
|
||||
$image_full = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
echo '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full[0] . '" title="' . $alt_text . '">';
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
echo '</a>';
|
||||
}else{
|
||||
echo '<img src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
}
|
||||
echo '</div>'; // gallery-thumbnail-image
|
||||
|
||||
echo '</div>'; // print item size
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // end row
|
||||
$gdl_element_id++;
|
||||
}
|
||||
|
||||
echo '</div>'; // gdl gallery item
|
||||
}
|
||||
|
||||
// Print Message Box
|
||||
function print_message_box($item_xml){
|
||||
$box_color = find_xml_value($item_xml, 'color');
|
||||
$box_title = find_xml_value($item_xml, 'title');
|
||||
$box_content = html_entity_decode(find_xml_value($item_xml, 'content'));
|
||||
echo '<div class="message-box-wrapper ' . $box_color . '">';
|
||||
echo '<div class="message-box-title">' . $box_title . '</div>';
|
||||
echo '<div class="message-box-content">' . do_shortcode($box_content) . '</div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// Print personnal item
|
||||
function print_personnal_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
global $personnal_div_size_num_class, $sidebar_type;
|
||||
|
||||
$num_fetch = find_xml_value($item_xml, 'num-fetch');
|
||||
$category = find_xml_value($item_xml, 'category', false);
|
||||
$category = ( $category == 'All' )? '': $category;
|
||||
|
||||
$personnal_size = find_xml_value($item_xml, 'item-size');
|
||||
$personnal_row_size = 0;
|
||||
$item_size = $personnal_div_size_num_class[$personnal_size][$sidebar_type];
|
||||
|
||||
$post_temp = query_posts(array('post_type'=>'personnal',
|
||||
'personnal-category'=>$category, 'posts_per_page'=>$num_fetch));
|
||||
|
||||
echo '<div class="personnal-item-holder">';
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
$personnal_row_size = print_item_size($personnal_size, $personnal_row_size, 'personnal-item-wrapper');
|
||||
|
||||
echo '<div class="personnal-item">';
|
||||
|
||||
$thumbnail_id = get_post_thumbnail_id();
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
if( !empty($thumbnail) ){
|
||||
echo '<div class="personnal-thumbnail"><img src="' . $thumbnail[0] . '" alt="' . $alt_text . '"></div>';
|
||||
}
|
||||
|
||||
echo '<div class="personnal-title">';
|
||||
the_title();
|
||||
echo '</div>';
|
||||
|
||||
$position = get_post_meta( get_the_ID(), 'personnal-option-position', true );
|
||||
if( !empty($position) ){
|
||||
echo '<div class="personnal-position">' . $position . "</div>";
|
||||
}
|
||||
|
||||
echo '<div class="personnal-content">';
|
||||
the_content();
|
||||
echo '</div>';
|
||||
|
||||
$social_info = get_post_meta( get_the_ID(), 'personnal-option-social-info', true );
|
||||
if( !empty($social_info) ){
|
||||
echo '<div class="personnal-social-info">';
|
||||
echo do_shortcode($social_info);
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // personnal item
|
||||
echo '</div>'; //close print_item_size
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; //close row
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
// Print price item
|
||||
function print_price_item($item_xml){
|
||||
global $gdl_admin_translator;
|
||||
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_read_more = get_option(THEME_SHORT_NAME.'_translator_read_more_price', 'BUY NOW');
|
||||
}else{
|
||||
$translator_read_more = __('BUY NOW','gdl_front_end');
|
||||
}
|
||||
|
||||
$price_item_row_size = 0;
|
||||
$price_item_number = find_xml_value($item_xml, 'item-number');
|
||||
$price_item_category = find_xml_value($item_xml, 'category', false);
|
||||
$price_item_category = ($price_item_category == 'All')? '': $price_item_category;
|
||||
|
||||
$price_posts = get_posts(array('post_type'=>'price_table', 'price-table-category'=>$price_item_category,
|
||||
'numberposts'=>$price_item_number));
|
||||
|
||||
echo '<div class="price-table-wrapper">';
|
||||
foreach($price_posts as $price_post){
|
||||
$best_price = get_post_meta( $price_post->ID, 'price-table-best-price', true );
|
||||
$best_price = ($best_price == 'Yes')? ' best-price':'';
|
||||
|
||||
$price_item_row_size = print_item_size('1/' . $price_item_number,
|
||||
$price_item_row_size, 'price-item-wrapper wrapper mb0' . $best_price);
|
||||
echo '<div class="price-item-inner-wrapper">';
|
||||
echo '<div class="price-item">';
|
||||
echo '<div class="price-title-wrapper">';
|
||||
echo '<div class="price-title" >' . $price_post->post_title . '</div>';
|
||||
|
||||
echo '<div class="price-tag">';
|
||||
_e(get_post_meta( $price_post->ID, 'price-table-price-tag', true ), 'gdl_front_end');
|
||||
$suffix = __(get_post_meta( $price_post->ID, 'price-table-price-suffix', true ), 'gdl_front_end');
|
||||
if( !empty($suffix) ){ echo '<span class="price-suffix">' . $suffix . '</span>'; }
|
||||
echo '</div>';
|
||||
echo '</div>'; // price-title-wrapper
|
||||
|
||||
echo '<div class="price-content">';
|
||||
echo apply_filters('the_content', $price_post->post_content);
|
||||
echo '</div>';
|
||||
|
||||
$price_url = __(get_post_meta( $price_post->ID, 'price-table-option-url', true ), 'gdl_front_end');
|
||||
if( !empty($price_url) ){
|
||||
echo '<div class="price-button-wrapper">';
|
||||
echo '<a class="gdl-button" target="_blank" href="' . $price_url . '">' . $translator_read_more . '</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // price item
|
||||
echo '</div>'; // price item inner wrapper
|
||||
echo '</div>'; // print item size
|
||||
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // end row
|
||||
echo '</div>'; // price table wrapper
|
||||
}
|
||||
|
||||
// Print postslider item
|
||||
function print_post_slider_item($item_xml){
|
||||
global $gdl_date_format;
|
||||
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
$num_fetch = find_xml_value($item_xml, 'num-fetch');
|
||||
$num_excerpt = find_xml_value($item_xml, 'num-excerpt');
|
||||
$show_caption = find_xml_value($item_xml, 'show-caption');
|
||||
|
||||
$category = find_xml_value($item_xml, 'category', false);
|
||||
$category = ($category == 'All')? '': $category;
|
||||
|
||||
$postslider_xml = "<single-item><Post-Slider>";
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('size', find_xml_value($item_xml, 'size'));
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('width', find_xml_value($item_xml, 'width'));
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('height', find_xml_value($item_xml, 'height'));
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('slider-type', find_xml_value($item_xml, 'slider-type'));
|
||||
$postslider_xml = $postslider_xml . "<slider-item>";
|
||||
|
||||
query_posts(array('post_type'=>'post', 'category_name'=>$category, 'posts_per_page'=>$num_fetch ));
|
||||
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
$postslider_xml = $postslider_xml . "<slider>";
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('image', get_post_thumbnail_id(get_the_ID()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('linktype', 'Link to URL' );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('link', htmlspecialchars(get_permalink()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('comment', get_comments_number(get_the_ID()) );
|
||||
if( $show_caption == "Yes" ){
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('title', htmlspecialchars(get_the_title()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('caption', htmlspecialchars(gdl_get_excerpt($num_excerpt)) );
|
||||
}else if( $show_caption == "Show Date" ){
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('title', htmlspecialchars(get_the_title()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('caption', __('Posted on ', 'gdl_front_end') . get_the_time($gdl_date_format) );
|
||||
}
|
||||
$postslider_xml = $postslider_xml . "</slider>";
|
||||
|
||||
}
|
||||
|
||||
$postslider_xml = $postslider_xml . "</slider-item>";
|
||||
$postslider_xml = $postslider_xml . "</Post-Slider></single-item>";
|
||||
|
||||
$slider_xml_val = new DOMDocument();
|
||||
$slider_xml_val->loadXML($postslider_xml);
|
||||
foreach( $slider_xml_val->documentElement->childNodes as $slider_item_xml){
|
||||
print_slider_item($slider_item_xml);
|
||||
}
|
||||
|
||||
wp_reset_query();
|
||||
}
|
||||
|
||||
// Print postslider item
|
||||
function print_top_post_slider_item($category, $num_fetch, $width, $height){
|
||||
global $gdl_date_format;
|
||||
|
||||
$category = ($category == 'All')? '': $category;
|
||||
|
||||
$postslider_xml = "<single-item><Post-Slider>";
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('width', $width);
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('height', $height);
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('slider-type', 'Carousel Slider');
|
||||
$postslider_xml = $postslider_xml . "<slider-item>";
|
||||
|
||||
query_posts(array('post_type'=>'post', 'category_name'=>$category, 'posts_per_page'=>$num_fetch ));
|
||||
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
$postslider_xml = $postslider_xml . "<slider>";
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('image', get_post_thumbnail_id(get_the_ID()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('linktype', 'Link to URL' );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('link', htmlspecialchars(get_permalink()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('title', htmlspecialchars(get_the_title()) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('caption', __('Posted on ', 'gdl_front_end') . get_the_time($gdl_date_format) );
|
||||
$postslider_xml = $postslider_xml . create_xml_tag('comment', get_comments_number(get_the_ID()) );
|
||||
$postslider_xml = $postslider_xml . "</slider>";
|
||||
|
||||
}
|
||||
|
||||
$postslider_xml = $postslider_xml . "</slider-item>";
|
||||
$postslider_xml = $postslider_xml . "</Post-Slider></single-item>";
|
||||
|
||||
$slider_xml_val = new DOMDocument();
|
||||
$slider_xml_val->loadXML($postslider_xml);
|
||||
foreach( $slider_xml_val->documentElement->childNodes as $slider_item_xml){
|
||||
print_slider_item($slider_item_xml);
|
||||
}
|
||||
|
||||
wp_reset_query();
|
||||
}
|
||||
|
||||
// Print stunning text
|
||||
function print_stunning_text($item_xml){
|
||||
|
||||
$title = find_xml_value($item_xml, 'title');
|
||||
$caption = html_entity_decode(find_xml_value($item_xml, 'caption'));
|
||||
$shadow = (find_xml_value($item_xml, 'shadow') != 'No')? 'shadow-on': '';
|
||||
|
||||
echo '<div class="stunning-text-wrapper gdl-border-x top ' . $shadow . '">';
|
||||
echo '<div class="stunning-text-inner-wrapper gdl-border-x bottom">';
|
||||
|
||||
echo '<div class="stunning-text-content">';
|
||||
echo '<h1 class="stunning-text-title">' . $title . '</h1>';
|
||||
echo '<div class="stunning-text-caption">' . do_shortcode($caption) . '</div>';
|
||||
echo '</div>'; // stunning text content
|
||||
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; //stunning-text-inner-wrapper
|
||||
|
||||
if( !empty($shadow) ){
|
||||
echo '<div class="stunning-text-shadow"></div>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
// Print Tab
|
||||
function print_tab_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
$num = 0;
|
||||
$tab_title = array();
|
||||
$tab_content = array();
|
||||
|
||||
$tab_xml = find_xml_node($item_xml, 'tab-item');
|
||||
foreach($tab_xml->childNodes as $toggle_box){
|
||||
$tab_title[$num] = find_xml_value($toggle_box, 'title');
|
||||
$tab_content[$num] = html_entity_decode(find_xml_value($toggle_box, 'caption'));
|
||||
$num++;
|
||||
}
|
||||
|
||||
echo '<div class="gdl-tab">';
|
||||
|
||||
// tab title
|
||||
echo '<ul class="gdl-tab-title">';
|
||||
for($i=0; $i<$num; $i++){
|
||||
echo '<li><a data-tab="tab-' . $i . '" ';
|
||||
echo ( $i == 0 )? 'class="active" ':'';
|
||||
echo ' >' . $tab_title[$i] . '</a></li>';
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
// tab content
|
||||
echo '<div class="clear"></div>';
|
||||
echo "<ul class='gdl-tab-content'>";
|
||||
for($i=0; $i<$num; $i++){
|
||||
echo '<li data-tab="tab-' . $i . '" ';
|
||||
echo ( $i == 0 )? 'class="active"':'';
|
||||
echo ' >' . do_shortcode($tab_content[$i]) . '</li>';
|
||||
}
|
||||
echo "</ul>";
|
||||
|
||||
echo '</div>'; // gdl tab
|
||||
}
|
||||
|
||||
// Print Testimonial
|
||||
function print_testimonial($item_xml){
|
||||
$display_type = find_xml_value($item_xml, 'display-type');
|
||||
if( $display_type == 'Carousel Testimonial' ){
|
||||
$additional = 'navigation-on';
|
||||
}else{
|
||||
$additional = '';
|
||||
}
|
||||
|
||||
print_item_header( find_xml_value($item_xml, 'header'), $additional );
|
||||
|
||||
$num_fetch = find_xml_value($item_xml, 'num-fetch');
|
||||
$orderby = find_xml_value($item_xml, 'orderby');
|
||||
$order = find_xml_value($item_xml, 'order');
|
||||
|
||||
$category = find_xml_value($item_xml, 'category', false);
|
||||
$category = ( $category == 'All' )? '': $category;
|
||||
|
||||
$item_size = find_xml_value($item_xml, 'item-size');
|
||||
$testimonial_row_size = 0;
|
||||
|
||||
query_posts(array( 'post_type'=>'testimonial', 'orderby'=>$orderby, 'posts_per_page'=>$num_fetch,
|
||||
'order'=>$order, 'testimonial-category'=>$category ));
|
||||
|
||||
if( $display_type == 'Static Testimonial' ){
|
||||
echo '<div class="gdl-static-testimonial">';
|
||||
if( have_posts() ){
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
$testimonial_row_size = print_item_size($item_size, $testimonial_row_size, 'mb20');
|
||||
echo '<div class="testimonial-item">';
|
||||
|
||||
// testimonial content
|
||||
echo '<div class="testimonial-content">';
|
||||
the_content();
|
||||
echo '</div>';
|
||||
|
||||
// testimonial author
|
||||
$author = get_the_title();
|
||||
$position = get_post_meta( get_the_ID(), "testimonial-option-author-position", true );
|
||||
echo '<div class="testimonial-info">';
|
||||
echo '<span class="testimonial-author">' . $author . '</span>';
|
||||
if( !empty($position) ){
|
||||
echo ',<span class="testimonial-position"> ' . $position . '</span>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>'; // testimonial item
|
||||
echo '</div>'; // close print_item_size
|
||||
}
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close row
|
||||
echo '</div>'; // gdl static testimonial
|
||||
}else if( $display_type == 'Carousel Testimonial' ){
|
||||
echo '<div class="gdl-carousel-testimonial">';
|
||||
|
||||
// navigation
|
||||
echo '<div class="testimonial-navigation">';
|
||||
echo '<a class="testimonial-prev"></a>';
|
||||
echo '<a class="testimonial-next"></a>';
|
||||
echo '</div>';
|
||||
|
||||
// content
|
||||
echo '<div class="testimonial-item-wrapper">';
|
||||
if( have_posts() ){
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
echo '<div class="testimonial-item">';
|
||||
|
||||
// testimonial content
|
||||
echo '<div class="testimonial-content"><div class="testimonial-icon"></div>';
|
||||
echo '<div class="testimonial-inner-content">';
|
||||
the_content();
|
||||
echo '</div>';
|
||||
echo '</div>';
|
||||
|
||||
// testimonial author
|
||||
$author = get_the_title();
|
||||
$position = get_post_meta( get_the_ID(), "testimonial-option-author-position", true );
|
||||
echo '<div class="testimonial-info">';
|
||||
echo '<span class="testimonial-author">' . $author . '</span>';
|
||||
if( !empty($position) ){
|
||||
echo ',<span class="testimonial-position"> ' . $position . '</span>';
|
||||
}
|
||||
echo '</div>';
|
||||
|
||||
echo '</div>'; // testimonial item
|
||||
|
||||
}
|
||||
}
|
||||
echo '</div>'; //testimonial-item-wrapper
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
wp_reset_query();
|
||||
}
|
||||
|
||||
// Print Toggle Box
|
||||
function print_toggle_box_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
$tab_xml = find_xml_node($item_xml, 'tab-item');
|
||||
echo "<ul class='gdl-toggle-box'>";
|
||||
foreach($tab_xml->childNodes as $toggle_box){
|
||||
$active = ( find_xml_value($toggle_box, 'active') == 'Yes' )? 'active': '';
|
||||
|
||||
echo '<li class="' . $active . '">';
|
||||
echo '<h2 class="toggle-box-title"><span class="toggle-box-icon"></span>' . find_xml_value($toggle_box, 'title') . '</h2>';
|
||||
echo '<div class="toggle-box-content">';
|
||||
echo do_shortcode(html_entity_decode(find_xml_value($toggle_box, 'caption'))) . '</div>';
|
||||
echo '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
// Print the slider item
|
||||
function print_slider_item($item_xml){
|
||||
|
||||
$xml_size = find_xml_value($item_xml, 'size');
|
||||
if( $xml_size == 'full-width' ){
|
||||
echo '<div class="gdl-slider-wrapper fullwidth">';
|
||||
}else{
|
||||
echo '<div class="gdl-slider-wrapper">';
|
||||
}
|
||||
|
||||
$slider_width = find_xml_value($item_xml, 'width');
|
||||
$slider_height = find_xml_value($item_xml, 'height');
|
||||
if( !empty($slider_width) && !empty($slider_height) ){
|
||||
$xml_size = $slider_width . 'x' . $slider_height;
|
||||
}else if( $xml_size == 'full-width' ){
|
||||
$xml_size = 'full';
|
||||
}else{
|
||||
$xml_size = '980x360';
|
||||
}
|
||||
|
||||
switch(find_xml_value($item_xml,'slider-type')){
|
||||
|
||||
case 'Anything Slider':
|
||||
print_anything_slider(find_xml_node($item_xml,'slider-item'), $xml_size);
|
||||
break;
|
||||
|
||||
case 'Nivo Slider':
|
||||
print_nivo_slider(find_xml_node($item_xml,'slider-item'), $xml_size);
|
||||
break;
|
||||
|
||||
case 'Flex Slider':
|
||||
print_flex_slider(find_xml_node($item_xml,'slider-item'), $xml_size);
|
||||
break;
|
||||
|
||||
case 'Carousel Slider':
|
||||
print_carousel_slider(find_xml_node($item_xml,'slider-item'), $xml_size);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
// Print contact form
|
||||
function print_contact_form($item_xml){
|
||||
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 find_xml_value($item_xml, '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">
|
||||
</li>
|
||||
</ol>
|
||||
</form>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
if( !function_exists('pagination') ){
|
||||
function pagination($pages = '', $range = 3){
|
||||
$showitems = ($range * 2)+1;
|
||||
|
||||
global $paged;
|
||||
if(empty($paged)){ $paged = 1; }
|
||||
|
||||
if(empty($pages)){
|
||||
global $wp_query;
|
||||
|
||||
$pages = $wp_query->max_num_pages;
|
||||
if(!$pages){ $pages = 1; }
|
||||
}
|
||||
|
||||
if(1 != $pages){
|
||||
echo "<div class=\"gdl-pagination\">";
|
||||
|
||||
// first page
|
||||
if($paged > 2 && $paged > $range+1 && $showitems < $pages){
|
||||
echo '<a href="' . get_pagenum_link(1) . '">';
|
||||
_e('« First', 'gdl_front_end');
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
// previous page
|
||||
if($paged > 1 && $showitems < $pages){
|
||||
echo '<a href="' . get_pagenum_link($paged - 1) . '">';
|
||||
_e('‹ Previous', 'gdl_front_end');
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
// middle page
|
||||
for ($i=1; $i <= $pages; $i++){
|
||||
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )){
|
||||
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
|
||||
}
|
||||
}
|
||||
|
||||
// next page
|
||||
if ($paged < $pages && $showitems < $pages){
|
||||
echo '<a href="' . get_pagenum_link($paged + 1) . '">';
|
||||
_e('Next ›', 'gdl_front_end');
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
// last page
|
||||
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages){
|
||||
echo '<a href="' . get_pagenum_link($pages) . '">';
|
||||
_e('Last »', 'gdl_front_end');
|
||||
echo '</a>';
|
||||
}
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // gdl pagination
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -0,0 +1,464 @@
|
||||
<?php
|
||||
// Print portfolio
|
||||
function print_portfolio($item_xml){
|
||||
$header = find_xml_value($item_xml, 'header');
|
||||
$view_all_port = find_xml_value($item_xml, 'view-all-portfolio');
|
||||
if( !empty($view_all_port) && $view_all_port != 'None' ){
|
||||
global $gdl_admin_translator;
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_view = get_option(THEME_SHORT_NAME.'_translator_view_all_portfolio', 'View All Portfolio');
|
||||
}else{
|
||||
$translator_view = __('View All Portfolio','gdl_front_end');
|
||||
}
|
||||
|
||||
$additional_html = '<a href="' . get_permalink(get_page_by_path($view_all_port));
|
||||
$additional_html = $additional_html . '" class="view-all-projects">';
|
||||
$additional_html = $additional_html . $translator_view . '</a>';
|
||||
}
|
||||
|
||||
$portfolio_type = find_xml_value($item_xml, 'portfolio-type');
|
||||
$additional = '';
|
||||
print_item_header( $header, $additional, $additional_html );
|
||||
|
||||
global $paged, $gdl_element_id;
|
||||
|
||||
if(empty($paged)){ $paged = (get_query_var('page')) ? get_query_var('page') : 1; }
|
||||
|
||||
// get the portfolio meta value
|
||||
$num_fetch = find_xml_value($item_xml, 'num-fetch');
|
||||
$port_size = find_xml_value($item_xml, 'item-size');
|
||||
$show_title = (find_xml_value($item_xml, "show-title") == "Yes")? true: false;
|
||||
$show_tag = (find_xml_value($item_xml, "show-tag") == "Yes")? true: false;
|
||||
$num_excerpt = find_xml_value($item_xml, "num-excerpt");
|
||||
|
||||
$category = find_xml_value($item_xml, 'category', false);
|
||||
$category = ( $category == 'All' )? '': $category;
|
||||
|
||||
$filter_cat = empty($_GET['filter'])? $category: $_GET['filter'];
|
||||
|
||||
$order = find_xml_value($item_xml, 'order');
|
||||
$orderby = find_xml_value($item_xml, 'orderby');
|
||||
|
||||
query_posts(array('post_type'=>'portfolio', 'paged'=>$paged, 'order'=>$order, 'orderby'=>$orderby,
|
||||
'portfolio-category'=>$filter_cat, 'posts_per_page'=>$num_fetch));
|
||||
|
||||
// get the item class and size from array
|
||||
if($portfolio_type == 'Portfolio'){
|
||||
print_normal_portfolio( $port_size, $show_title, $show_tag, $num_excerpt );
|
||||
}else if($portfolio_type == 'Filter Portfolio'){
|
||||
print_filter_portfolio( $port_size, $show_title, $show_tag, $category, $header, $num_excerpt);
|
||||
}else if($portfolio_type == 'jQuery Filter Portfolio'){
|
||||
print_jquery_filter_portfolio( $port_size, $show_title, $show_tag, $category, $header, $num_excerpt);
|
||||
}
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
if( find_xml_value($item_xml, "pagination") == "Yes" ){
|
||||
echo '<div class="portfolio-pagination">';
|
||||
pagination();
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
$gdl_element_id++;
|
||||
wp_reset_query();
|
||||
}
|
||||
|
||||
// Print portfolio thumbnail
|
||||
function print_portfolio_thumbnail( $post_id, $item_size ){
|
||||
global $gdl_element_id;
|
||||
|
||||
$thumbnail_types = get_post_meta( $post_id, 'post-option-thumbnail-types', true);
|
||||
if( $thumbnail_types == "Image" ){
|
||||
$attribute = "";
|
||||
$thumbnail_id = get_post_thumbnail_id();
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
|
||||
$image_type = get_post_meta( $post_id, 'post-option-featured-image-type', true);
|
||||
if( $image_type == "Link to Current Post" || empty($image_type) ){
|
||||
$hover_thumb = "hover-link";
|
||||
$permalink = get_permalink();
|
||||
}else if( $image_type == "Link to URL"){
|
||||
$hover_thumb = "hover-link";
|
||||
$attribute = ' target="_blank"';
|
||||
$permalink = __(get_post_meta( $post_id, 'post-option-featured-image-url', true ), 'gdl_front_end');
|
||||
}else if( $image_type == "Lightbox to Current Thumbnail" ){
|
||||
$hover_thumb = "hover-zoom";
|
||||
$attribute = ' data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" ';
|
||||
$permalink = wp_get_attachment_image_src( $thumbnail_id, 'full' );
|
||||
$permalink = $permalink[0];
|
||||
}else if( $image_type == "Lightbox to Picture" ){
|
||||
$hover_thumb = "hover-zoom";
|
||||
$attribute = ' data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" ';
|
||||
$permalink = __(get_post_meta( $post_id, 'post-option-featured-image-url', true ), 'gdl_front_end');
|
||||
}else{
|
||||
$hover_thumb = "hover-video";
|
||||
$attribute = ' data-rel="fancybox" data-fancybox-type="iframe" ';
|
||||
$permalink = __(get_post_meta( $post_id, 'post-option-featured-image-url', true ), 'gdl_front_end');
|
||||
}
|
||||
|
||||
if( !empty($thumbnail[0]) ){
|
||||
echo '<div class="portfolio-media-wrapper gdl-image">';
|
||||
echo '<a class="hover-wrapper" href="' . $permalink . '" ' . $attribute . ' title="' . get_the_title() . '">';
|
||||
echo '<span class="portfolio-thumbnail-image-hover"></span>';
|
||||
echo '<span class="' . $hover_thumb . ' hover-icon"></span>';
|
||||
echo '</a>';
|
||||
echo '<img src="' . $thumbnail[0] .'" alt="'. $alt_text .'"/>';
|
||||
echo '</div>';
|
||||
}
|
||||
}else if( $thumbnail_types == "Video" ){
|
||||
$video_link = get_post_meta( $post_id, 'post-option-thumbnail-video', true);
|
||||
echo '<div class="portfolio-media-wrapper gdl-video">';
|
||||
echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
|
||||
echo '</div>';
|
||||
}else if ( $thumbnail_types == "Slider" ){
|
||||
$slider_xml = get_post_meta( $post_id, 'post-option-thumbnail-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
$slider_xml_dom->loadXML($slider_xml);
|
||||
echo '<div class="portfolio-media-wrapper gdl-slider">';
|
||||
echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
|
||||
echo '</div>';
|
||||
}else if ( $thumbnail_types == "HTML5 Video" ){
|
||||
$video = get_post_meta( $post_id, 'post-option-thumbnail-html5-video', true);
|
||||
echo '<div class="portfolio-media-wrapper gdl-html5-video">';
|
||||
echo get_html5_video($video);
|
||||
echo '</div>'; // blog-media-wrapper
|
||||
}
|
||||
}
|
||||
|
||||
// print the port thumbnail
|
||||
function print_single_port_thumbnail( $post_id, $item_size ){
|
||||
$thumbnail_types = get_post_meta( $post_id, 'post-option-inside-thumbnail-types', true);
|
||||
|
||||
if( $thumbnail_types == "Image" || empty($thumbnail_types) ){
|
||||
$thumbnail_id = get_post_meta( $post_id, 'post-option-inside-thumbnial-image', true);
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$thumbnail_full = wp_get_attachment_image_src( $thumbnail_id , 'full' );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
if( !empty($thumbnail) ){
|
||||
echo '<div class="port-media-wrapper gdl-image">';
|
||||
echo '<a href="' . $thumbnail_full[0] . '" data-rel="fancybox" title="' . get_the_title() . '">';
|
||||
echo '<img src="' . $thumbnail[0] .'" alt="'. $alt_text .'"/>';
|
||||
echo '</a>';
|
||||
echo '</div>'; // port-media-wrapper
|
||||
}
|
||||
}else if( $thumbnail_types == "Video" ){
|
||||
$video_link = get_post_meta( $post_id, 'post-option-inside-thumbnail-video', true);
|
||||
echo '<div class="port-media-wrapper gdl-video">';
|
||||
echo get_video($video_link, gdl_get_width($item_size), gdl_get_height($item_size));
|
||||
echo '</div>'; // port-media-wrapper
|
||||
}else if ( $thumbnail_types == "Slider" ){
|
||||
$slider_xml = get_post_meta( $post_id, 'post-option-inside-thumbnail-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
$slider_xml_dom->loadXML($slider_xml);
|
||||
echo '<div class="port-media-wrapper gdl-slider">';
|
||||
echo print_flex_slider($slider_xml_dom->documentElement, $item_size);
|
||||
echo '</div>'; // port-media-wrapper
|
||||
}else if ( $thumbnail_types == "Stack Images" ){
|
||||
$slider_xml = get_post_meta( $post_id, 'post-option-inside-thumbnail-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
$slider_xml_dom->loadXML($slider_xml);
|
||||
echo '<div class="port-media-wrapper gdl-stack-images">';
|
||||
echo print_stack_images($slider_xml_dom->documentElement, $item_size);
|
||||
echo '</div>'; // port-media-wrapper
|
||||
}else if ( $thumbnail_types == "HTML5 Video" ){
|
||||
$video = get_post_meta( $post_id, 'post-option-inside-thumbnail-html5-video', true);
|
||||
echo '<div class="port-media-wrapper gdl-html5-video">';
|
||||
get_html5_video($video);
|
||||
echo '</div>'; // port-media-wrapper
|
||||
}
|
||||
}
|
||||
|
||||
// Print normal portfolio
|
||||
function print_normal_portfolio( $port_size = "1/4", $show_title = true, $show_tag = true, $num_excerpt = 0 ){
|
||||
global $port_div_size_num_class, $sidebar_type;
|
||||
global $gdl_admin_translator;
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_continue_reading = get_option(THEME_SHORT_NAME.'_translator_continue_reading', 'Continue Reading');
|
||||
}else{
|
||||
$translator_continue_reading = __('Continue Reading ','gdl_front_end');
|
||||
}
|
||||
|
||||
$portfolio_row_size = 0;
|
||||
$item_size = $port_div_size_num_class[$port_size][$sidebar_type];
|
||||
|
||||
echo '<div class="portfolio-item-holder row">';
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
print_item_size($port_size, 0.1, 'portfolio-item mb40');
|
||||
|
||||
print_portfolio_thumbnail( get_the_ID(), $item_size );
|
||||
|
||||
// portfolio context
|
||||
if( $show_title || $show_tag ){
|
||||
echo '<div class="portfolio-context">';
|
||||
if( $show_title ){
|
||||
echo '<h2 class="portfolio-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
}
|
||||
if( $show_tag ){
|
||||
$portfolio_tag = get_the_term_list( get_the_ID(), 'portfolio-tag', '', ', ', '' );
|
||||
echo '<div class="portfolio-tag">';
|
||||
echo $portfolio_tag;
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="port-bottom-border"></div>';
|
||||
echo '</div>'; // close portfolio context
|
||||
|
||||
if( !empty($num_excerpt) ){
|
||||
echo '<div class="portfolio-excerpt">';
|
||||
echo gdl_get_excerpt($num_excerpt);
|
||||
echo '<a class="port-continue-reading" href="' . get_permalink() . '">' . $translator_continue_reading . '</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close print_item_size
|
||||
}
|
||||
echo '</div>'; // portfolio item holder
|
||||
}
|
||||
|
||||
// Print filter portfolio
|
||||
function print_filter_portfolio( $port_size = "1/4", $show_title = true, $show_tag = true, $parent_category, $header, $num_excerpt = 0){
|
||||
global $port_div_size_num_class, $sidebar_type;
|
||||
global $gdl_admin_translator;
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_all = get_option(THEME_SHORT_NAME.'_translator_all', 'All');
|
||||
$translator_continue_reading = get_option(THEME_SHORT_NAME.'_translator_continue_reading', 'Continue Reading');
|
||||
}else{
|
||||
$translator_all = __('All','gdl_front_end');
|
||||
$translator_continue_reading = __('Continue Reading ','gdl_front_end');
|
||||
}
|
||||
|
||||
$item_size = $port_div_size_num_class[$port_size][$sidebar_type];
|
||||
$current_filter = empty($_GET['filter'])? 'All': $_GET['filter'];
|
||||
$active = empty($_GET['filter'])? 'active': '';
|
||||
|
||||
// filter portfolio button
|
||||
$category_lists = get_category_list('portfolio-category', $parent_category);
|
||||
|
||||
$has_header = !empty($header)? 'has-header': 'no-header';
|
||||
echo '<div class="portfolio-filter-wrapper ' . $has_header . '">';
|
||||
echo '<ul class="portfolio-item-filter">';
|
||||
foreach($category_lists as $category){
|
||||
if( $category == 'All'){
|
||||
if( $current_filter == $category ) $active = 'active';
|
||||
echo '<li><span> / </span><a href="' . get_permalink() . '" class="' . $active . '">' . $translator_all . '</a></li>';
|
||||
}else{
|
||||
if( $current_filter == $category ) $active = 'active';
|
||||
$current_cat = get_term_by('slug', $category, 'portfolio-category');
|
||||
echo '<li><span> / </span><a href="' . add_query_arg(array('filter'=>$category)) . '" class="' . $active . '">';
|
||||
echo $current_cat->name;
|
||||
echo '</a></li>';
|
||||
}
|
||||
$active = '';
|
||||
}
|
||||
echo "</ul>";
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>';
|
||||
|
||||
|
||||
// start portfolio looping
|
||||
echo '<div class="portfolio-item-holder row">';
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
print_item_size($port_size, 0.1, 'portfolio-item mb40');
|
||||
|
||||
print_portfolio_thumbnail( get_the_ID(), $item_size );
|
||||
|
||||
// portfolio context
|
||||
if( $show_title || $show_tag ){
|
||||
echo '<div class="portfolio-context">';
|
||||
if( $show_title ){
|
||||
echo '<h2 class="portfolio-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
}
|
||||
if( $show_tag ){
|
||||
$portfolio_tag = get_the_term_list( get_the_ID(), 'portfolio-tag', '', ', ', '' );
|
||||
echo '<div class="portfolio-tag">';
|
||||
echo $portfolio_tag;
|
||||
echo '</div>';
|
||||
}
|
||||
if( !empty($num_excerpt) ){
|
||||
echo '<div class="portfolio-excerpt">';
|
||||
echo gdl_get_excerpt($num_excerpt);
|
||||
echo '<a class="port-continue-reading" href="' . get_permalink() . '">' . $translator_continue_reading . '</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="port-bottom-border"></div>';
|
||||
echo '</div>'; // close portfolio context
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close print_item_size - portfolio_item
|
||||
}
|
||||
echo '</div>'; // portfolio item holder
|
||||
}
|
||||
|
||||
// Print jquery filter portfolio
|
||||
function print_jquery_filter_portfolio( $port_size = "1/4", $show_title = true, $show_tag = true, $parent_category, $header, $num_excerpt = 0){
|
||||
global $port_div_size_num_class, $sidebar_type;
|
||||
global $gdl_admin_translator;
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_all = get_option(THEME_SHORT_NAME.'_translator_all', 'All');
|
||||
$translator_continue_reading = get_option(THEME_SHORT_NAME.'_translator_continue_reading', 'Continue Reading');
|
||||
}else{
|
||||
$translator_all = __('All','gdl_front_end');
|
||||
$translator_continue_reading = __('Continue Reading ','gdl_front_end');
|
||||
}
|
||||
|
||||
$item_size = $port_div_size_num_class[$port_size][$sidebar_type];
|
||||
|
||||
// filter portfolio button
|
||||
$category_lists = get_category_list('portfolio-category', $parent_category);
|
||||
$category_check = array();
|
||||
foreach( $category_lists as $category ){ $category_check[$category] = false; }
|
||||
if( empty( $parent_category) ){
|
||||
$category_check = array('All'=>$translator_all);
|
||||
}else{
|
||||
$first_category = get_term_by('slug', $parent_category, 'portfolio-category');
|
||||
$category_check[$parent_category] = $first_category->name;
|
||||
}
|
||||
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
$post_categories = get_the_terms( get_the_ID(), 'portfolio-category' );
|
||||
if(!empty($post_categories)){
|
||||
foreach( $post_categories as $category ){
|
||||
$category_check[$category->slug] = $category->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
$is_first = 'active';
|
||||
|
||||
$has_header = !empty($header)? 'has-header': 'no-header';
|
||||
echo '<div class="portfolio-filter-wrapper ' . $has_header . '">';
|
||||
echo '<ul class="portfolio-item-filter">';
|
||||
foreach($category_lists as $category){
|
||||
if( empty($category_check[$category]) ) continue;
|
||||
if( $is_first ){
|
||||
$cat_name = 'All';
|
||||
}else{
|
||||
$cat_name = $category;
|
||||
}
|
||||
|
||||
echo '<li><span> / </span><a href="#" class="' . $is_first . '" data-value="' . $cat_name . '">';
|
||||
echo $category_check[$category];
|
||||
echo '</a></li>';
|
||||
|
||||
$is_first = '';
|
||||
}
|
||||
echo "</ul>";
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>';
|
||||
|
||||
// start portfolio looping
|
||||
rewind_posts();
|
||||
echo '<div class="portfolio-item-holder row">';
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
$portfolio_slug = "";
|
||||
$post_categories = get_the_terms( get_the_ID(), 'portfolio-category' );
|
||||
if(!empty($post_categories)){
|
||||
foreach( $post_categories as $category ){
|
||||
$portfolio_slug = $portfolio_slug . $category->slug . ' ';
|
||||
}
|
||||
}
|
||||
|
||||
print_item_size($port_size, 0.1, 'portfolio-item mb40 ' . $portfolio_slug);
|
||||
|
||||
print_portfolio_thumbnail( get_the_ID(), $item_size );
|
||||
|
||||
// portfolio context
|
||||
if( $show_title || $show_tag ){
|
||||
echo '<div class="portfolio-context">';
|
||||
if( $show_title ){
|
||||
echo '<h2 class="portfolio-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
}
|
||||
if( $show_tag ){
|
||||
$portfolio_tag = get_the_term_list( get_the_ID(), 'portfolio-tag', '', ', ', '' );
|
||||
echo '<div class="portfolio-tag">';
|
||||
echo $portfolio_tag;
|
||||
echo '</div>';
|
||||
}
|
||||
if( !empty($num_excerpt) ){
|
||||
echo '<div class="portfolio-excerpt">';
|
||||
echo gdl_get_excerpt($num_excerpt);
|
||||
echo '<a class="port-continue-reading" href="' . get_permalink() . '">' . $translator_continue_reading . '</a>';
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="port-bottom-border"></div>';
|
||||
echo '</div>'; // close portfolio context
|
||||
}
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close print_item_size - portfolio_item
|
||||
}
|
||||
echo '</div>'; // portfolio item holder
|
||||
}
|
||||
|
||||
// Print nested page
|
||||
function print_page_item($item_xml){
|
||||
print_item_header( find_xml_value($item_xml, 'header') );
|
||||
|
||||
global $paged, $gdl_element_id, $port_div_size_num_class, $sidebar_type;
|
||||
|
||||
if(empty($paged)){ $paged = (get_query_var('page')) ? get_query_var('page') : 1; }
|
||||
|
||||
// get the page meta value
|
||||
$port_size = find_xml_value($item_xml, 'item-size');
|
||||
$item_size = $port_div_size_num_class[$port_size][$sidebar_type];
|
||||
|
||||
$num_fetch = find_xml_value($item_xml, 'num-fetch');
|
||||
$num_excerpt = find_xml_value($item_xml, 'num-excerpt');
|
||||
|
||||
query_posts(array('post_type'=>'page', 'paged'=>$paged, 'orderby'=>'menu_order', 'order'=>'asc',
|
||||
'post_parent'=>get_the_ID(), 'posts_per_page'=>$num_fetch ));
|
||||
|
||||
echo '<div class="portfolio-item-holder row">';
|
||||
while( have_posts() ){
|
||||
the_post();
|
||||
|
||||
print_item_size($port_size, 0.1, 'portfolio-item mb40');
|
||||
|
||||
$thumbnail_id = get_post_thumbnail_id();
|
||||
if( !empty($thumbnail_id) ){
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
|
||||
echo '<div class="portfolio-media-wrapper gdl-image">';
|
||||
echo '<a class="hover-wrapper" href="' . get_permalink() . '" >';
|
||||
echo '<span class="portfolio-thumbnail-image-hover">';
|
||||
echo '<span class="hover-link"></span>';
|
||||
echo '</span>';
|
||||
echo '</a>';
|
||||
echo '<img src="' . $thumbnail[0] .'" alt="'. $alt_text .'"/>';
|
||||
echo '</div>'; //portfolio thumbnail image
|
||||
}
|
||||
|
||||
$show_title = (find_xml_value($item_xml, "show-title") == "Yes")? true: false;
|
||||
$show_excerpt = (find_xml_value($item_xml, "show-excerpt") == "Yes")? true: false;
|
||||
if( $show_title || $show_excerpt ){
|
||||
echo '<div class="page-context">';
|
||||
if( $show_title){
|
||||
echo '<h2 class="page-item-title"><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
|
||||
}
|
||||
if( $show_excerpt ){
|
||||
echo '<div class="page-item-content">' . gdl_get_excerpt($num_excerpt) . '</div>';
|
||||
}
|
||||
echo '</div>'; // port-thumbnail-contxt
|
||||
}
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
echo '</div>'; // close print_item_size
|
||||
|
||||
}
|
||||
echo "</div>"; // portfolio-item-holder
|
||||
|
||||
echo '<div class="clear"></div>';
|
||||
if( find_xml_value($item_xml, "pagination") == "Yes" ){
|
||||
pagination();
|
||||
}
|
||||
|
||||
wp_reset_query();
|
||||
}
|
||||
?>
|
@ -0,0 +1,674 @@
|
||||
<?php
|
||||
// shortcode for price list
|
||||
add_shortcode('price_list', 'gdl_price_list_shortcode');
|
||||
function gdl_price_list_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array(), $atts) );
|
||||
$price_list = '<div class="shortcode-price-list">' . $content . '</div>';
|
||||
return $price_list;
|
||||
}
|
||||
|
||||
// shortcode for price content
|
||||
add_shortcode('price_content', 'gdl_price_content_shortcode');
|
||||
function gdl_price_content_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array(), $atts) );
|
||||
$price_list = '<div class="shortcode-price-content">' . $content . '</div>';
|
||||
return $price_list;
|
||||
}
|
||||
|
||||
// shortcode for column_service
|
||||
add_shortcode('column_service', 'gdl_column_service_shortcode');
|
||||
function gdl_column_service_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("head_image"=>"", "head_image_width"=>"", "title"=>"", "caption"=>"", "background_color"=>"", "color"=>""), $atts) );
|
||||
|
||||
$column_service = '<div class="bottom-column-service-wrapper" style="color: ' . $color . '; background-color: ' . $background_color . '" >';
|
||||
|
||||
if( !empty($head_image) ){
|
||||
$column_service = (!empty($head_image_width))? $column_service . '<div class="bottom-column-service-head" style="max-width: ' . $head_image_width . 'px;">': $column_service . '<div class="bottom-column-service-head">';
|
||||
$column_service = $column_service . '<img src="' . $head_image . '" alt="" />';
|
||||
$column_service = $column_service . '</div>';
|
||||
$column_service = $column_service . '<div class="bottom-column-service-head-separator" style="background-color: ' . $color . ';"></div>';
|
||||
}
|
||||
|
||||
$column_service = $column_service . '<div class="bottom-column-service-title">' . __(do_shortcode($title)) . '</div>';
|
||||
$column_service = $column_service . '<div class="bottom-column-service-content">' . __(do_shortcode($content)) . '</div>';
|
||||
$column_service = $column_service . '</div>';
|
||||
|
||||
return $column_service;
|
||||
}
|
||||
|
||||
$accordion_active = '';
|
||||
// shortcode for accordion
|
||||
add_shortcode('accordion', 'gdl_accordion_shortcode');
|
||||
function gdl_accordion_shortcode( $atts, $content = null ){
|
||||
global $accordion_active;
|
||||
$accordion_active = 'class="active"';
|
||||
|
||||
$accordion = "<ul class='gdl-accordion'>";
|
||||
$accordion = $accordion . do_shortcode($content);
|
||||
$accordion = $accordion . "</ul>";
|
||||
return $accordion;
|
||||
}
|
||||
add_shortcode('acc_item', 'gdl_acc_item_shortcode');
|
||||
function gdl_acc_item_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("title" => ''), $atts) );
|
||||
|
||||
global $accordion_active;
|
||||
|
||||
$acc_item = '<li ' . $accordion_active . '>';
|
||||
$acc_item = $acc_item . "<h2 class='accordion-title'><span class='accordion-icon'></span>" . $title . "</h2>";
|
||||
$acc_item = $acc_item . "<div class='accordion-content'>" . do_shortcode($content) . "</div>";
|
||||
$acc_item = $acc_item . "</li>";
|
||||
|
||||
$accordion_active = '';
|
||||
return $acc_item;
|
||||
}
|
||||
|
||||
// block quote
|
||||
add_shortcode('quote', 'gdl_quote_shortcode');
|
||||
function gdl_quote_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("align" => 'center'), $atts) );
|
||||
|
||||
return '<blockquote class="' . $align . '">' . $content . '</blockquote>';
|
||||
}
|
||||
|
||||
// shortcode for button
|
||||
add_shortcode('button', 'gdl_button_shortcode');
|
||||
function gdl_button_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("color" => '', "background" => '', "size" => 'large', "src"=> '#', 'target'=>'_self'), $atts) );
|
||||
|
||||
$css_attr = (!empty($color))? 'color:' . $color . '; ': '';
|
||||
$css_attr = (!empty($background))? $css_attr . 'background-color:' . $background . '; ': $css_attr;
|
||||
$css_attr = (!empty($background))? $css_attr . 'border-color:' . gdl_hex_darker( $background, 20 ) . '; ': $css_attr;
|
||||
|
||||
return '<a href="' . $src . '" target="' . $target . '" class="gdl-button ' . $size . '" style="' . $css_attr . '">' . $content . '</a>';
|
||||
}
|
||||
|
||||
// for code section
|
||||
add_shortcode('code', 'gdl_hilighter_shortcode');
|
||||
function gdl_hilighter_shortcode( $atts, $content = null){
|
||||
extract( shortcode_atts(array(), $atts) );
|
||||
|
||||
$content = str_replace('[', '[', htmlspecialchars($content));
|
||||
|
||||
$hilighter = "<div class='gdl-code'>";
|
||||
$hilighter = $hilighter . $content;
|
||||
$hilighter = $hilighter . "</div>";
|
||||
|
||||
return $hilighter;
|
||||
}
|
||||
|
||||
// shortcode for column
|
||||
add_shortcode('column', 'gdl_column_shortcode');
|
||||
function gdl_column_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("col" => '1/1', 'last'=>false), $atts) );
|
||||
if( $last && $last != 'false' ){
|
||||
$last = 'last';
|
||||
$clear = '<div class="clear"></div>';
|
||||
}else{
|
||||
$last = '';
|
||||
$clear = '';
|
||||
}
|
||||
|
||||
return '<div class="shortcode' . str_replace('/', '-', $col) . ' ' . $last . '">' . do_shortcode($content) . '</div>' . $clear;
|
||||
switch($col){
|
||||
case '1/4': return '<div class="shortcode1-4 ' . $last . '">' . do_shortcode($content) . '</div>' . $clear;
|
||||
case '1/3': return '<div class="shortcode1-3 ' . $last . '">' . do_shortcode($content) . '</div>' . $clear;
|
||||
case '1/2': return '<div class="shortcode1-2 ' . $last . '">' . do_shortcode($content) . '</div>' . $clear;
|
||||
case '2/3': return '<div class="shortcode2-3 ' . $last . '">' . do_shortcode($content) . '</div>' . $clear;
|
||||
case '3/4': return '<div class="shortcode3-4 ' . $last . '">' . do_shortcode($content) . '</div>' . $clear;
|
||||
case '1/1': return '<div class="shortcode1">' . do_shortcode($content) . '</div>';
|
||||
default : return;
|
||||
}
|
||||
}
|
||||
|
||||
// shortcode for divider
|
||||
add_shortcode('divider', 'gdl_divider_shortcode');
|
||||
function gdl_divider_shortcode( $atts ){
|
||||
extract( shortcode_atts(array("scroll_text" => ''), $atts) );
|
||||
|
||||
$divider = '<div class="clear"></div>';
|
||||
$divider = $divider . '<div class="gdl-divider gdl-border-x top">';
|
||||
$divider = $divider . '<div class="scroll-top">' . $scroll_text . '</div>';
|
||||
$divider = $divider . '</div>';
|
||||
|
||||
return $divider;
|
||||
}
|
||||
|
||||
// dropcap shortcode
|
||||
add_shortcode('dropcap', 'gdl_dropcap_shortcode');
|
||||
function gdl_dropcap_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("type" => '', "color" => '', "background"=> ''), $atts) );
|
||||
|
||||
return '<div class="shortcode-dropcap ' . $type . '" style="color:'. $color .'; background-color:' . $background . ';">' . $content . '</div>';
|
||||
}
|
||||
|
||||
// shortcode for gallery
|
||||
add_shortcode('gdl_gallery', 'gdl_gallery_shortcode');
|
||||
function gdl_gallery_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array('title'=>'', 'width'=>'200', 'height'=>'200', 'type'=>''), $atts) );
|
||||
|
||||
global $gdl_element_id;
|
||||
|
||||
$gdl_gallery = "";
|
||||
$gallery_post = get_posts(array('post_type' => 'gdl-gallery', 'name'=>$title, 'numberposts'=> 1));
|
||||
$slider_xml_string = get_post_meta($gallery_post[0]->ID,'post-option-gallery-xml', true);
|
||||
$slider_xml_dom = new DOMDocument();
|
||||
if( !empty( $slider_xml_string ) ){
|
||||
$slider_xml_dom->loadXML($slider_xml_string);
|
||||
|
||||
// Normal gallery type
|
||||
if( empty($type) ){
|
||||
foreach( $slider_xml_dom->documentElement->childNodes as $slider ){
|
||||
$link_type = find_xml_value($slider, 'linktype');
|
||||
$image_url = wp_get_attachment_image_src(find_xml_value($slider, 'image'), $width . 'x' . $height );
|
||||
$alt_text = get_post_meta(find_xml_value($slider, 'image') , '_wp_attachment_image_alt', true);
|
||||
|
||||
$gdl_gallery = $gdl_gallery . '<div class="gdl-gallery-image shortcode">';
|
||||
if( $link_type == 'Link to URL' ){
|
||||
$link = find_xml_value( $slider, 'link');
|
||||
$gdl_gallery = $gdl_gallery . '<a href="' . $link . '" title="' . $link . '" target="_blank" >';
|
||||
$gdl_gallery = $gdl_gallery . '<img class="gdl-gallery-image" src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
$gdl_gallery = $gdl_gallery . '</a>';
|
||||
}else if( $link_type == 'Lightbox' ){
|
||||
$image_full = wp_get_attachment_image_src(find_xml_value($slider, 'image'), 'full');
|
||||
$gdl_gallery = $gdl_gallery . '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full[0] . '" title="' . $alt_text . '">';
|
||||
$gdl_gallery = $gdl_gallery . '<img class="gdl-gallery-image" src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
$gdl_gallery = $gdl_gallery . '</a>';
|
||||
}else{
|
||||
$gdl_gallery = $gdl_gallery . '<img class="gdl-gallery-image" src="' . $image_url[0] . '" alt="' . $alt_text . '" />';
|
||||
}
|
||||
$gdl_gallery = $gdl_gallery . '</div>'; // gallery-thumbnail-image
|
||||
}
|
||||
$gdl_gallery = $gdl_gallery . '<div class="clear"></div>';
|
||||
|
||||
// Thumbnail gallery type
|
||||
}else{
|
||||
$thumbnail_id = get_post_thumbnail_id($gallery_post[0]->ID);
|
||||
$thumbnail_full = wp_get_attachment_image_src($thumbnail_id, 'full');
|
||||
$thumbnail_url = wp_get_attachment_image_src($thumbnail_id, $width . 'x' . $height );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
|
||||
$gdl_gallery = $gdl_gallery . '<div class="gdl-gallery-image shortcode">';
|
||||
$gdl_gallery = $gdl_gallery . '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $thumbnail_full[0] . '" title="' . $alt_text . '" >';
|
||||
$gdl_gallery = $gdl_gallery . '<img src="' . $thumbnail_url[0] . '" alt="' . $alt_text . '" />';
|
||||
$gdl_gallery = $gdl_gallery . '</a>';
|
||||
|
||||
foreach( $slider_xml_dom->documentElement->childNodes as $slider ){
|
||||
$thumbnail_id = find_xml_value($slider, 'image');
|
||||
$image_full = wp_get_attachment_image_src($thumbnail_id, 'full');
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
$gdl_gallery = $gdl_gallery . '<a data-rel="fancybox" data-fancybox-group="gal' . $gdl_element_id . '" href="' . $image_full[0] . '" title="' . $alt_text . '"></a>';
|
||||
}
|
||||
|
||||
$gdl_gallery = $gdl_gallery . '</div>';
|
||||
}
|
||||
$gdl_element_id++;
|
||||
}
|
||||
|
||||
return $gdl_gallery;
|
||||
}
|
||||
|
||||
// list shortcode
|
||||
$gdl_type = '';
|
||||
add_shortcode('list', 'gdl_list_shortcode');
|
||||
function gdl_list_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("type" => 'icon-angle-right'), $atts) );
|
||||
global $gdl_type; $gdl_type = $type;
|
||||
return '<ul class="shortcode-list">' . do_shortcode($content) . '</ul>';
|
||||
}
|
||||
add_shortcode('li', 'gdl_li_shortcode');
|
||||
function gdl_li_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array(), $atts) );
|
||||
global $gdl_type;
|
||||
|
||||
return '<li><i class="' . $gdl_type . '"></i>' . $content . '</li>';
|
||||
}
|
||||
|
||||
// list shortcode
|
||||
add_shortcode('gdl_icon', 'gdl_icon_shortcode');
|
||||
function gdl_icon_shortcode( $atts ){
|
||||
extract( shortcode_atts(array('type'=>'', 'color'=>'#333', 'size'=>'13px'), $atts) );
|
||||
|
||||
$extra_style = !empty($color)? 'color:' . $color . ';' :'';
|
||||
$extra_style .= !empty($size)? 'font-size:' . $size . ';' :'';
|
||||
|
||||
return '<i class="gdl-icon-shortcode ' . $type . '" style="' . $extra_style . '"></i>';
|
||||
}
|
||||
|
||||
// message box shortcode
|
||||
add_shortcode('message_box', 'gdl_message_box_shortcode');
|
||||
function gdl_message_box_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("title"=>'', "color"=>'red'), $atts) );
|
||||
|
||||
$message_box = '<div class="message-box-wrapper ' . $color . '">';
|
||||
$message_box = $message_box . '<div class="message-box-title">' . $title . '</div>';
|
||||
$message_box = $message_box . '<div class="message-box-content">' . do_shortcode($content) . '</div>';
|
||||
$message_box = $message_box . '</div>';
|
||||
|
||||
return $message_box;
|
||||
}
|
||||
|
||||
// personnel shortcode
|
||||
add_shortcode('personnel', 'gdl_personnal_shortcode');
|
||||
function gdl_personnal_shortcode( $atts ){
|
||||
extract( shortcode_atts(array("size"=>'1/4', 'num_fetch'=>4, "category"=>''), $atts) );
|
||||
|
||||
global $personnal_div_size_num_class, $sidebar_type;
|
||||
$personnal = '';
|
||||
$personnal_row_size = 0;
|
||||
$item_size = $personnal_div_size_num_class[$size][$sidebar_type];
|
||||
|
||||
$post_temp = query_posts(array('post_type'=>'personnal',
|
||||
'personnal-category'=>$category, 'posts_per_page'=>$num_fetch));
|
||||
|
||||
$personnal = $personnal . '<div class="personnal-item-holder">';
|
||||
while( have_posts() ){ the_post();
|
||||
|
||||
$ret_size = return_item_size($size, $personnal_row_size, 'personnal-item-wrapper');
|
||||
$personnal_row_size = $ret_size['row-size'];
|
||||
$personnal = $personnal . $ret_size['return'];
|
||||
$personnal = $personnal . '<div class="personnal-item">';
|
||||
|
||||
$thumbnail_id = get_post_thumbnail_id();
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , $item_size );
|
||||
$alt_text = get_post_meta($thumbnail_id , '_wp_attachment_image_alt', true);
|
||||
if( !empty($thumbnail) ){
|
||||
$personnal = $personnal . '<div class="personnal-thumbnail"><img src="' . $thumbnail[0] . '" alt="' . $alt_text . '"></div>';
|
||||
}
|
||||
|
||||
$personnal = $personnal . '<div class="personnal-title">';
|
||||
$personnal = $personnal . get_the_title();
|
||||
$personnal = $personnal . '</div>';
|
||||
|
||||
$position = get_post_meta( get_the_ID(), 'personnal-option-position', true );
|
||||
if( !empty($position) ){
|
||||
$personnal = $personnal . '<div class="personnal-position">' . $position . "</div>";
|
||||
}
|
||||
|
||||
$personnal = $personnal . '<div class="personnal-content">';
|
||||
$personnal = $personnal . do_shortcode( get_the_content() );
|
||||
$personnal = $personnal . '</div>';
|
||||
|
||||
$social_info = get_post_meta( get_the_ID(), 'personnal-option-social-info', true );
|
||||
if( !empty($social_info) ){
|
||||
$personnal = $personnal . '<div class="personnal-social-info">';
|
||||
$personnal = $personnal . do_shortcode($social_info);
|
||||
$personnal = $personnal . '<div class="clear"></div>';
|
||||
$personnal = $personnal . '</div>';
|
||||
}
|
||||
|
||||
$personnal = $personnal . '<div class="clear"></div>';
|
||||
$personnal = $personnal . '</div>'; // personnal item
|
||||
$personnal = $personnal . '</div>'; //close print_item_size
|
||||
}
|
||||
$personnal = $personnal . '<div class="clear"></div>';
|
||||
$personnal = $personnal . '</div>'; //close row
|
||||
$personnal = $personnal . '</div>';
|
||||
|
||||
wp_reset_query();
|
||||
|
||||
return $personnal;
|
||||
}
|
||||
|
||||
// price item shortcode
|
||||
add_shortcode('price-item', 'gdl_price_item_shortcode');
|
||||
function gdl_price_item_shortcode( $atts ){
|
||||
extract( shortcode_atts(array("item_number"=>'6', "category"=>''), $atts) );
|
||||
|
||||
global $gdl_admin_translator;
|
||||
|
||||
$price_item_row_size = 0;
|
||||
if( $gdl_admin_translator == 'enable' ){
|
||||
$translator_read_more = get_option(THEME_SHORT_NAME.'_translator_read_more_price', 'Read More');
|
||||
}else{
|
||||
$translator_read_more = __('Read More','gdl_front_end');
|
||||
}
|
||||
|
||||
$price_posts = get_posts(array('post_type'=>'price_table', 'price-table-category'=>$category,
|
||||
'numberposts'=>$item_number));
|
||||
|
||||
$price_item = '<div class="price-table-wrapper">';
|
||||
foreach($price_posts as $price_post){
|
||||
$best_price = get_post_meta( $price_post->ID, 'price-table-best-price', true );
|
||||
$best_price = ($best_price == 'Yes')? ' best-price':'';
|
||||
|
||||
$ret_size = return_item_size('1/' . $item_number, $price_item_row_size, 'price-item-wrapper wrapper mb0' . $best_price);
|
||||
$price_item_row_size = $ret_size['row-size'];
|
||||
$price_item = $price_item . $ret_size['return'];
|
||||
$price_item = $price_item . '<div class="price-item-inner-wrapper">';
|
||||
$price_item = $price_item . '<div class="price-item">';
|
||||
$price_item = $price_item . '<div class="price-title-wrapper">';
|
||||
$price_item = $price_item . '<div class="price-title">' . $price_post->post_title . '</div>';
|
||||
|
||||
$price_item = $price_item . '<div class="price-tag">';
|
||||
$price_item = $price_item . __(get_post_meta( $price_post->ID, 'price-table-price-tag', true ), 'gdl_front_end');
|
||||
|
||||
$suffix = __(get_post_meta( $price_post->ID, 'price-table-price-suffix', true ), 'gdl_front_end');
|
||||
if( !empty($suffix) ){
|
||||
$price_item = $price_item . '<span class="price-suffix">' . $suffix . '</span>';
|
||||
}
|
||||
|
||||
$price_item = $price_item . '</div>';
|
||||
$price_item = $price_item . '</div>'; // price-title-wrapper
|
||||
|
||||
$price_item = $price_item . '<div class="price-content">';
|
||||
$price_item = $price_item . do_shortcode( $price_post->post_content );
|
||||
$price_item = $price_item . '</div>';
|
||||
|
||||
$price_url = __(get_post_meta( $price_post->ID, 'price-table-option-url', true ), 'gdl_front_end');
|
||||
if( !empty($price_url) ){
|
||||
$price_item = $price_item . '<div class="price-button-wrapper">';
|
||||
$price_item = $price_item . '<a class="gdl-button" target="_blank" href="' . $price_url . '">' . $translator_read_more . '</a>';
|
||||
$price_item = $price_item . '</div>';
|
||||
}
|
||||
|
||||
$price_item = $price_item . '<div class="clear"></div>';
|
||||
$price_item = $price_item . '</div>'; // price item
|
||||
$price_item = $price_item . '</div>'; // price item inner wrapper
|
||||
$price_item = $price_item . '</div>'; // print item size
|
||||
|
||||
}
|
||||
$price_item = $price_item . '<div class="clear"></div>';
|
||||
$price_item = $price_item . '</div>'; // end row
|
||||
$price_item = $price_item . '</div>'; // price table wrapper
|
||||
|
||||
return $price_item;
|
||||
}
|
||||
|
||||
// social shortcode
|
||||
add_shortcode('progress_bar', 'gdl_progress_bar');
|
||||
function gdl_progress_bar( $atts ){
|
||||
extract( shortcode_atts(array("percent" => "80", "text"=>"" ), $atts) );
|
||||
|
||||
$progress = '<div class="progress-bar-wrapper">';
|
||||
$progress = $progress . '<div class="progress-bar" style="width: ' . $percent . '%;">';
|
||||
$progress = $progress . '<div class="progress-bar-inner">';
|
||||
$progress = $progress . '<span class="title">' . $text . '</span>';
|
||||
$progress = $progress . '<span class="percent">' . $percent . '%</span>';
|
||||
$progress = $progress . '<div class="clear"></div>';
|
||||
$progress = $progress . '</div>'; // progress-bar-inner
|
||||
$progress = $progress . '</div>'; // progress-bar
|
||||
$progress = $progress . '</div>';
|
||||
return $progress;
|
||||
}
|
||||
|
||||
// social shortcode
|
||||
add_shortcode('social', 'gdl_social_shortcode');
|
||||
function gdl_social_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("type" => 'facebook'), $atts) );
|
||||
|
||||
$social = '<div class="shortcode-social-icon"><a href="' . $content . '">';
|
||||
$social = $social . '<img class="no-preload" src="' . GOODLAYERS_PATH . '/images/icon/social-icon/' . $type . '.png' . '" width="32" height="32" alt="' . $type . '"></a></div>';
|
||||
return $social;
|
||||
}
|
||||
|
||||
// shortcode for space
|
||||
add_shortcode('space', 'gdl_space_shortcode');
|
||||
function gdl_space_shortcode( $atts ){
|
||||
extract( shortcode_atts(array("height" => '20'), $atts) );
|
||||
|
||||
return '<div class="clear" style=" height:' . $height . 'px;" ></div>';
|
||||
}
|
||||
|
||||
// shortcode for tab
|
||||
$gdl_tab_array = array();
|
||||
add_shortcode('tab', 'gdl_tab_shortcode');
|
||||
function gdl_tab_shortcode( $atts, $content = null ){
|
||||
global $gdl_tab_array;
|
||||
$gdl_tab_array = array();
|
||||
|
||||
do_shortcode($content);
|
||||
|
||||
$num = sizeOf($gdl_tab_array);
|
||||
$tab = '<div class="gdl-tab">';
|
||||
|
||||
// tab title
|
||||
$tab = $tab . '<ul class="gdl-tab-title">';
|
||||
for($i=0; $i<$num; $i++){
|
||||
$active = ( $i == 0 )? 'class="active" ' : '';
|
||||
|
||||
$tab = $tab . '<li><a data-tab="tab-' . $i . '" ' . $active;
|
||||
$tab = $tab . '>' . $gdl_tab_array[$i]["title"] . '</a></li>';
|
||||
}
|
||||
$tab = $tab . '</ul>';
|
||||
|
||||
// tab content
|
||||
$tab = $tab . '<div class="clear"></div>';
|
||||
$tab = $tab . '<ul class="gdl-tab-content">';
|
||||
for($i=0; $i<$num; $i++){
|
||||
$active = ( $i == 0 )? 'class="active" ' : '';
|
||||
|
||||
$tab = $tab . '<li data-tab="tab-' . $i . '" ' . $active;
|
||||
$tab = $tab . '>' . $gdl_tab_array[$i]["content"] . '</li>';
|
||||
}
|
||||
$tab = $tab . "</ul>"; // gdl-tab-content
|
||||
|
||||
$tab = $tab . "</div>"; // gdl-tab
|
||||
|
||||
return $tab;
|
||||
}
|
||||
add_shortcode('tab_item', 'gdl_tab_item_shortcode');
|
||||
function gdl_tab_item_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("title" => ''), $atts) );
|
||||
|
||||
global $gdl_tab_array;
|
||||
|
||||
$gdl_tab_array[] = array("title" => $title , "content" => do_shortcode($content));
|
||||
}
|
||||
|
||||
// testimonial shortcode
|
||||
add_shortcode('testimonial', 'gdl_testimonial_shortcode');
|
||||
function gdl_testimonial_shortcode( $atts ){
|
||||
extract( shortcode_atts(array('category' => '', 'type'=>'static', 'size'=>'1/1'), $atts) );
|
||||
|
||||
$temp = '';
|
||||
$testimonial_row_size = 0;
|
||||
$testimonials = get_posts(array('post_type' => 'testimonial', 'testimonial-category'=>$category,
|
||||
'numberposts'=> 100));
|
||||
|
||||
if( $type == 'static' ){
|
||||
$temp = '<div class="gdl-static-testimonial">';
|
||||
foreach( $testimonials as $testimonial ){
|
||||
$return_size = return_item_size($size, $testimonial_row_size, 'mb20');
|
||||
$testimonial_row_size = $return_size['row-size'];
|
||||
|
||||
$temp = $temp . $return_size['return'];
|
||||
$temp = $temp . '<div class="testimonial-item">';
|
||||
|
||||
// testimonial content
|
||||
$temp = $temp . '<div class="testimonial-content">';
|
||||
$temp = $temp . do_shortcode( $testimonial->post_content );
|
||||
$temp = $temp . '</div>';
|
||||
|
||||
// testimonial author
|
||||
$author = $testimonial->post_title;
|
||||
$position = get_post_meta( $testimonial->ID, "testimonial-option-author-position", true );
|
||||
$temp = $temp . '<div class="testimonial-info">';
|
||||
$temp = $temp . '<span class="testimonial-author">' . $author . '</span>';
|
||||
if( !empty($position) ){
|
||||
$temp = $temp . '<span class="testimonial-position">, ' . $position . '</span>';
|
||||
}
|
||||
$temp = $temp . '</div>';
|
||||
|
||||
$temp = $temp . '</div>'; // testimonial item
|
||||
$temp = $temp . '</div>'; // clost print item size
|
||||
}
|
||||
$temp = $temp . '<div class="clear"></div>';
|
||||
$temp = $temp . '</div>'; // close row
|
||||
$temp = $temp . '</div>'; // gdl-static-testimonial
|
||||
}else{
|
||||
$temp = $temp . '<div class="gdl-carousel-testimonial gdl-shortcode">';
|
||||
|
||||
// navigation
|
||||
$temp = $temp . '<div class="testimonial-navigation">';
|
||||
$temp = $temp . '<a class="testimonial-prev"></a>';
|
||||
$temp = $temp . '<a class="testimonial-next"></a>';
|
||||
$temp = $temp . '</div>';
|
||||
|
||||
// content
|
||||
$temp = $temp . '<div class="testimonial-item-wrapper">';
|
||||
foreach( $testimonials as $testimonial ){
|
||||
$temp = $temp . '<div class="testimonial-item">';
|
||||
|
||||
// testimonial content
|
||||
$temp = $temp . '<div class="testimonial-content"><div class="testimonial-icon"></div>';
|
||||
$temp = $temp . '<div class="testimonial-inner-content">';
|
||||
$temp = $temp . do_shortcode( $testimonial->post_content );
|
||||
$temp = $temp . '</div>';
|
||||
$temp = $temp . '</div>';
|
||||
|
||||
// testimonial author
|
||||
$author = $testimonial->post_title;
|
||||
$position = get_post_meta( $testimonial->ID, "testimonial-option-author-position", true );
|
||||
$temp = $temp . '<div class="testimonial-info">';
|
||||
$temp = $temp . '<span class="testimonial-author">- ' . $author . '</span>';
|
||||
if( !empty($position) ){
|
||||
$temp = $temp . '<span class="testimonial-position">, ' . $position . '</span>';
|
||||
}
|
||||
$temp = $temp . '</div>';
|
||||
|
||||
$temp = $temp . '</div>'; // testimonial item
|
||||
}
|
||||
$temp = $temp . '</div>'; //testimonial-item-wrapper
|
||||
$temp = $temp . '</div>';
|
||||
|
||||
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');
|
||||
}
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
// shortcode for toggle box
|
||||
add_shortcode('toggle_box', 'gdl_toggle_box_shortcode');
|
||||
function gdl_toggle_box_shortcode( $atts, $content = null ){
|
||||
$toggle_box = "<ul class='gdl-toggle-box'>";
|
||||
$toggle_box = $toggle_box . do_shortcode($content);
|
||||
$toggle_box = $toggle_box . "</ul>";
|
||||
return $toggle_box;
|
||||
}
|
||||
add_shortcode('toggle_item', 'gdl_toggle_item_shortcode');
|
||||
function gdl_toggle_item_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("title" => '', "active" => 'false'), $atts) );
|
||||
|
||||
$active = ( $active == "true" )? " active": '';
|
||||
$toggle_item = "<li class='" . $active . "'>";
|
||||
$toggle_item = $toggle_item . "<h2 class='toggle-box-title'><span class='toggle-box-icon'></span>" . $title . "</h2>";
|
||||
$toggle_item = $toggle_item . "<div class='toggle-box-content'>" . do_shortcode($content) . "</div>";
|
||||
$toggle_item = $toggle_item . "</li>";
|
||||
|
||||
return $toggle_item;
|
||||
}
|
||||
|
||||
// shortcode for vimeo
|
||||
add_shortcode('vimeo', 'gdl_vimeo_shortcode');
|
||||
function gdl_vimeo_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("height" => '', "width" => ''), $atts) );
|
||||
|
||||
$vimeo = '<div style="max-width:' . $width . 'px;" >';
|
||||
$vimeo = $vimeo . get_vimeo($content, $width, $height, true);
|
||||
$vimeo = $vimeo . '</div>';
|
||||
|
||||
return $vimeo;
|
||||
}
|
||||
|
||||
// shortcode for youtube
|
||||
add_shortcode('youtube', 'gdl_youtube_shortcode');
|
||||
function gdl_youtube_shortcode( $atts, $content = null ){
|
||||
extract( shortcode_atts(array("height" => '', "width" => ''), $atts) );
|
||||
|
||||
$youtube = '<div style="max-width:' . $width . 'px;" >';
|
||||
$youtube = $youtube . get_youtube($content, $width, $height, 'youtube', true);
|
||||
$youtube = $youtube . '</div>';
|
||||
|
||||
return $youtube;
|
||||
}
|
||||
|
||||
// Add button to visual editor
|
||||
add_action('init', 'add_shortcode_button');
|
||||
function add_shortcode_button(){
|
||||
|
||||
if ( current_user_can('edit_posts') || current_user_can('edit_pages') ){
|
||||
add_filter('mce_external_plugins', 'add_shortcode_plugin');
|
||||
add_filter('mce_buttons_3', 'register_shortcode_button');
|
||||
}
|
||||
|
||||
}
|
||||
function register_shortcode_button($buttons){
|
||||
array_push($buttons, "column" , "separator");
|
||||
array_push($buttons, "accordion", "tab", "toggle_box", "price_item", "separator");
|
||||
array_push($buttons, "testimonial", "message_box", "button", "separator");
|
||||
array_push($buttons, "youtube", "vimeo", "gdl_gallery", "social", "separator");
|
||||
array_push($buttons, "list", "quote", "dropcap", "separator");
|
||||
array_push($buttons, "divider", "space", "separator");
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
function add_shortcode_plugin($plugin_array) {
|
||||
$plugin_array['column'] = GOODLAYERS_PATH . '/include/javascript/shortcode/column.js';
|
||||
$plugin_array['accordion'] = GOODLAYERS_PATH . '/include/javascript/shortcode/accordion.js';
|
||||
$plugin_array['toggle_box'] = GOODLAYERS_PATH . '/include/javascript/shortcode/toggle-box.js';
|
||||
$plugin_array['price_item'] = GOODLAYERS_PATH . '/include/javascript/shortcode/price-item.js';
|
||||
$plugin_array['tab'] = GOODLAYERS_PATH . '/include/javascript/shortcode/tab.js';
|
||||
$plugin_array['divider'] = GOODLAYERS_PATH . '/include/javascript/shortcode/divider.js';
|
||||
$plugin_array['space'] = GOODLAYERS_PATH . '/include/javascript/shortcode/space.js';
|
||||
$plugin_array['youtube'] = GOODLAYERS_PATH . '/include/javascript/shortcode/youtube.js';
|
||||
$plugin_array['vimeo'] = GOODLAYERS_PATH . '/include/javascript/shortcode/vimeo.js';
|
||||
$plugin_array['gdl_gallery'] = GOODLAYERS_PATH . '/include/javascript/shortcode/gdl-gallery.js';
|
||||
$plugin_array['button'] = GOODLAYERS_PATH . '/include/javascript/shortcode/button.js';
|
||||
$plugin_array['message_box'] = GOODLAYERS_PATH . '/include/javascript/shortcode/message-box.js';
|
||||
$plugin_array['list'] = GOODLAYERS_PATH . '/include/javascript/shortcode/list.js';
|
||||
$plugin_array['social'] = GOODLAYERS_PATH . '/include/javascript/shortcode/social.js';
|
||||
$plugin_array['quote'] = GOODLAYERS_PATH . '/include/javascript/shortcode/quote.js';
|
||||
$plugin_array['dropcap'] = GOODLAYERS_PATH . '/include/javascript/shortcode/dropcap.js';
|
||||
$plugin_array['testimonial'] = GOODLAYERS_PATH . '/include/javascript/shortcode/testimonial.js';
|
||||
return $plugin_array;
|
||||
}
|
||||
|
||||
function fix_shortcodes($content){
|
||||
global $shortcode_tags;
|
||||
|
||||
// Backup current registered shortcodes and clear them all out
|
||||
$orig_shortcode_tags = $shortcode_tags;
|
||||
remove_all_shortcodes();
|
||||
|
||||
add_shortcode('accordion', 'gdl_accordion_shortcode');
|
||||
add_shortcode('acc_item', 'gdl_acc_item_shortcode');
|
||||
add_shortcode('quote', 'gdl_quote_shortcode');
|
||||
add_shortcode('button', 'gdl_button_shortcode');
|
||||
add_shortcode('column', 'gdl_column_shortcode');
|
||||
add_shortcode('code', 'gdl_hilighter_shortcode');
|
||||
add_shortcode('divider', 'gdl_divider_shortcode');
|
||||
add_shortcode('dropcap', 'gdl_dropcap_shortcode');
|
||||
add_shortcode('gdl_gallery', 'gdl_gallery_shortcode');
|
||||
add_shortcode('list', 'gdl_list_shortcode');
|
||||
add_shortcode('li', 'gdl_li_shortcode');
|
||||
add_shortcode('message_box', 'gdl_message_box_shortcode');
|
||||
add_shortcode('personnel', 'gdl_personnal_shortcode');
|
||||
add_shortcode('price-item', 'gdl_price_item_shortcode');
|
||||
add_shortcode('price_list', 'gdl_price_list_shortcode');
|
||||
add_shortcode('price_content', 'gdl_price_content_shortcode');
|
||||
add_shortcode('progress_bar', 'gdl_progress_bar');
|
||||
add_shortcode('social', 'gdl_social_shortcode');
|
||||
add_shortcode('space', 'gdl_space_shortcode');
|
||||
add_shortcode('tab', 'gdl_tab_shortcode');
|
||||
add_shortcode('tab_item', 'gdl_tab_item_shortcode');
|
||||
add_shortcode('testimonial', 'gdl_testimonial_shortcode');
|
||||
add_shortcode('toggle_box', 'gdl_toggle_box_shortcode');
|
||||
add_shortcode('toggle_item', 'gdl_toggle_item_shortcode');
|
||||
add_shortcode('vimeo', 'gdl_vimeo_shortcode');
|
||||
add_shortcode('youtube', 'gdl_youtube_shortcode');
|
||||
add_shortcode('jwplayer', 'gdl_jw_player_shortcode');
|
||||
|
||||
// Do the shortcode (only the one above is registered)
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
// Put the original shortcodes back
|
||||
$shortcode_tags = $orig_shortcode_tags;
|
||||
|
||||
return $content;
|
||||
}
|
||||
add_filter('the_content', 'fix_shortcodes', 7);
|
||||
|
||||
?>
|
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
function gdl_social_share_title(){
|
||||
$title = str_replace(' ', '%20', get_the_title());
|
||||
$title = str_replace('{', '%7B', $title);
|
||||
$title = str_replace('}', '%7D', $title);
|
||||
return $title;
|
||||
}
|
||||
|
||||
function include_social_shares(){
|
||||
global $gdl_icon_type;
|
||||
|
||||
$currentUrl = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
|
||||
if( !empty($_SERVER['HTTPS']) ){
|
||||
$currentUrl = "https://" . $currentUrl;
|
||||
}else{
|
||||
$currentUrl = "http://" . $currentUrl;
|
||||
}
|
||||
|
||||
echo '<div class="social-shares">';
|
||||
echo '<ul>';
|
||||
|
||||
if( get_option(THEME_SHORT_NAME.'_facebook_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://www.facebook.com/share.php?u=<?php echo $currentUrl;?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/facebook.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_twitter_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://twitter.com/share?url=<?php echo $currentUrl;?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/twitter.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_stumble_upon_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://www.stumbleupon.com/submit?url=<?php echo $currentUrl;?>&title=<?php echo gdl_social_share_title();?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/stumble-upon.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_my_space_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://www.myspace.com/Modules/PostTo/Pages/?u=<?php echo $currentUrl;?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/my-space.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_digg_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://digg.com/submit?url=<?php echo $currentUrl;?>&title=<?php echo gdl_social_share_title();?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/digg.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_reddit_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://reddit.com/submit?url=<?php echo $currentUrl;?>&title=<?php echo gdl_social_share_title();?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/reddit.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_linkedin_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo $currentUrl;?>&title=<?php echo gdl_social_share_title(); ?>" target="_blank">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/linkedin.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
if( get_option(THEME_SHORT_NAME.'_google_plus_share') == 'enable'){
|
||||
?>
|
||||
<li>
|
||||
<a href="https://plus.google.com/share?url=<?php echo $currentUrl;?>" onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/google-plus.png" alt="google-share" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
if( get_option(THEME_SHORT_NAME.'_pinterest_share') == 'enable'){
|
||||
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
|
||||
$thumbnail = wp_get_attachment_image_src( $thumbnail_id , 'full' );
|
||||
?>
|
||||
<li>
|
||||
<a href="http://pinterest.com/pin/create/button/?url=<?php echo $currentUrl;?>&media=<?php echo $thumbnail[0]; ?>" class="pin-it-button" count-layout="horizontal" onclick="javascript:window.open(this.href,'', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600');return false;">
|
||||
<img class="no-preload" src="<?php echo GOODLAYERS_PATH;?>/images/icon/social-icon-m/pinterest.png" width="32" height="32" />
|
||||
</a>
|
||||
</li>
|
||||
<?php
|
||||
}
|
||||
|
||||
echo '</ul>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
?>
|
289
wp-content/themes/worldwide-v1-01/include/plugin/utility.php
Normal file
289
wp-content/themes/worldwide-v1-01/include/plugin/utility.php
Normal file
@ -0,0 +1,289 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Goodlayers Utility File
|
||||
* ---------------------------------------------------------------------
|
||||
* @version 1.0
|
||||
* @author Goodlayers
|
||||
* @link http://goodlayers.com
|
||||
* @copyright Copyright (c) Goodlayers
|
||||
* ---------------------------------------------------------------------
|
||||
* This file contains all of the necessary function for the front-end and
|
||||
* back-end to use. You can see the description of each function below.
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
// Find the XML value from XML Object
|
||||
function find_xml_value($xml, $field, $translate = true, $return = ''){
|
||||
if(!empty($xml)){
|
||||
foreach($xml->childNodes as $xmlChild){
|
||||
if($xmlChild->nodeName == $field){
|
||||
if( is_admin() || !$translate ){
|
||||
return $xmlChild->nodeValue;
|
||||
}else{
|
||||
return __($xmlChild->nodeValue, 'gdl_front_end');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
// Find the XML node from XML Object
|
||||
function find_xml_node($xml, $node){
|
||||
if(!empty($xml)){
|
||||
foreach($xml->childNodes as $xmlChild){
|
||||
if($xmlChild->nodeName == $node){
|
||||
return $xmlChild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// Create tag string from nodename and value
|
||||
function create_xml_tag($node, $value){
|
||||
return '<' . $node . '>' . $value . '</' . $node . '>';
|
||||
}
|
||||
|
||||
// Get array of sidebar name
|
||||
function get_sidebar_name(){
|
||||
$exclude_array = array('Footer 1', 'Footer 2', 'Footer 3', 'Footer 4', 'Site Map 1', 'Site Map 2', 'Site Map 3');
|
||||
|
||||
$sidebar_all = array();
|
||||
|
||||
foreach ( $GLOBALS['wp_registered_sidebars'] as $sidebar ) {
|
||||
if( !in_array( $sidebar['name'] , $exclude_array ) ){
|
||||
$sidebar_all[] = $sidebar['name'];
|
||||
}
|
||||
}
|
||||
|
||||
return $sidebar_all;
|
||||
}
|
||||
|
||||
// get width and height from string WIDTHxHEIGHT
|
||||
function gdl_get_width( $size ){
|
||||
$size_array = explode('x', $size);
|
||||
if( !empty($size_array[0]) ) return $size_array[0];
|
||||
return '';
|
||||
}
|
||||
function gdl_get_height( $size ){
|
||||
$size_array = explode('x', $size);
|
||||
if( !empty($size_array[1]) ) return $size_array[1];
|
||||
return '';
|
||||
}
|
||||
|
||||
// use ajax to print all of media image for using with slider selection
|
||||
add_action('wp_ajax_get_media_image','get_media_image');
|
||||
function get_media_image(){
|
||||
$image_width = 70;
|
||||
$image_height = 70;
|
||||
|
||||
$paged = (isset($_POST['page']))? $_POST['page'] : 1;
|
||||
if($paged == ''){ $paged = 1; }
|
||||
|
||||
$statement = array('post_type' => 'attachment',
|
||||
'post_mime_type' =>'image',
|
||||
'post_status' => 'inherit',
|
||||
'posts_per_page' => 12,
|
||||
'paged' => $paged);
|
||||
$media_query = new WP_Query($statement);
|
||||
|
||||
?>
|
||||
|
||||
<div class="media-title">
|
||||
<label><?php _e('SELECT MEDIA','gdl_back_office'); ?></label>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo '<div class="media-gallery-nav" id="media-gallery-nav">';
|
||||
echo '<ul>';
|
||||
echo '<a><li class="nav-first" rel="1" ></li></a>';
|
||||
|
||||
for( $i=1 ; $i<=$media_query->max_num_pages; $i++){
|
||||
if($i == $paged){
|
||||
echo '<li rel="' . $i . '">' . $i . '</li>';
|
||||
}else if( ($i <= $paged+2 && $i >= $paged-2) || $i%10 == 0){
|
||||
echo '<a><li rel="' . $i . '">' . $i . '</li></a>';
|
||||
}
|
||||
}
|
||||
echo '<a><li class="nav-last" rel="' . $media_query->max_num_pages . '"></li></a>';
|
||||
echo '</ul>';
|
||||
echo '</div><div class=clear></div>';
|
||||
|
||||
echo '<ul>';
|
||||
foreach( $media_query->posts as $image ){
|
||||
|
||||
$thumb_src = wp_get_attachment_image_src( $image->ID, 'thumbnail');
|
||||
$thumb_src_preview = wp_get_attachment_image_src( $image->ID, 'thumbnail');
|
||||
echo '<li><img src="' . $thumb_src[0] .'" title="' . $image->post_title . '" attid="' . $image->ID . '" rel="' . $thumb_src_preview[0] . '"/></li>';
|
||||
|
||||
}
|
||||
echo '</ul><div class=clear></div>';
|
||||
|
||||
if(isset($_POST['page'])){ die(''); }
|
||||
}
|
||||
|
||||
// return the slider option array to use with javascript file
|
||||
function get_gdl_slider_option_array($slider_option){
|
||||
$slider_setting = array();
|
||||
|
||||
foreach($slider_option as $value){
|
||||
$set_value = get_option($value['name']);
|
||||
|
||||
if(isset($value['oldname']) && $set_value){
|
||||
$slider_setting[$value['oldname']] = $set_value;
|
||||
}
|
||||
}
|
||||
|
||||
return $slider_setting;
|
||||
}
|
||||
|
||||
// return the array of category
|
||||
function get_category_list( $category_name, $parent='' ){
|
||||
|
||||
if( empty($parent) ){
|
||||
$get_category = get_categories( array( 'taxonomy' => $category_name, 'hide_empty' => 0 ));
|
||||
|
||||
$category_list = array( '0' =>'All');
|
||||
if( !empty($get_category) ){
|
||||
foreach( $get_category as $category ){
|
||||
$category_list[] = urldecode($category->slug);
|
||||
}
|
||||
}
|
||||
|
||||
return $category_list;
|
||||
}else{
|
||||
$parent_id = get_term_by('slug', $parent, $category_name);
|
||||
$get_category = get_categories( array( 'taxonomy' => $category_name, 'child_of' => $parent_id->term_id, 'hide_empty' => 0 ));
|
||||
$category_list = array( '0' => $parent );
|
||||
|
||||
if( !empty($get_category) ){
|
||||
foreach( $get_category as $category ){
|
||||
$category_list[] = urldecode($category->slug);
|
||||
}
|
||||
}
|
||||
|
||||
return $category_list;
|
||||
}
|
||||
}
|
||||
|
||||
// return the slug list of each post
|
||||
function get_post_slug_list( $post_type ){
|
||||
|
||||
$posts = get_posts(array('post_type' => $post_type, 'numberposts'=>100));
|
||||
|
||||
$posts_title = array();
|
||||
foreach ($posts as $post) {
|
||||
$posts_title[] = urldecode($post->post_name);
|
||||
}
|
||||
|
||||
return $posts_title;
|
||||
|
||||
}
|
||||
|
||||
// return the title id of each category (in post)
|
||||
function get_post_title_id( $category ){
|
||||
$posts_title = array();
|
||||
$posts = get_posts(array('category_name' => $category, 'numberposts'=>100));
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$posts_title[] = $post->ID;
|
||||
}
|
||||
|
||||
return $posts_title;
|
||||
}
|
||||
|
||||
// cut excerpt by word or character
|
||||
function gdl_get_excerpt( $charlength = 180, $postscript = '', $excerpt_text = ''){
|
||||
global $gdl_word_excerpt;
|
||||
|
||||
if( $charlength == 0 ) return;
|
||||
if( empty($excerpt_text) ){
|
||||
if( $gdl_word_excerpt ){
|
||||
$excerpt = get_the_excerpt();
|
||||
$charlength++;
|
||||
|
||||
if ( strlen( $excerpt ) > $charlength ) {
|
||||
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
|
||||
$exwords = explode( ' ', $subex );
|
||||
$excut = - ( strlen( $exwords[ count( $exwords ) - 1 ] ) );
|
||||
if ( $excut < 0 ) {
|
||||
return mb_substr( $subex, 0, $excut - 1 ) . $postscript;
|
||||
} else {
|
||||
return mb_substr( $subex, 0, -1 ) . $postscript;
|
||||
}
|
||||
} else {
|
||||
return $excerpt;
|
||||
}
|
||||
}else{
|
||||
return mb_substr( get_the_excerpt(), 0, $charlength );
|
||||
}
|
||||
}else{
|
||||
$excerpt = $excerpt_text;
|
||||
$charlength++;
|
||||
|
||||
if ( strlen( $excerpt ) > $charlength ) {
|
||||
$subex = mb_substr( $excerpt, 0, $charlength - 5 );
|
||||
$exwords = explode( ' ', $subex );
|
||||
$excut = - ( strlen( $exwords[ count( $exwords ) - 1 ] ) );
|
||||
if ( $excut < 0 ) {
|
||||
return mb_substr( $subex, 0, $excut - 1 ) . $postscript;
|
||||
} else {
|
||||
return mb_substr( $subex, 0, -1 ) . $postscript;
|
||||
}
|
||||
} else {
|
||||
return $excerpt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function gdl_hex_lighter($hex, $factor = 40) {
|
||||
$new_hex = '';
|
||||
|
||||
$base['R'] = hexdec($hex{1}.$hex{2});
|
||||
$base['G'] = hexdec($hex{3}.$hex{4});
|
||||
$base['B'] = hexdec($hex{5}.$hex{6});
|
||||
|
||||
foreach ($base as $k => $v)
|
||||
{
|
||||
$amount = 255 - $v;
|
||||
$amount = $amount / 100;
|
||||
$amount = round($amount * $factor);
|
||||
$new_decimal = $v + $amount;
|
||||
|
||||
$new_hex_component = dechex($new_decimal);
|
||||
if(strlen($new_hex_component) < 2)
|
||||
{ $new_hex_component = "0".$new_hex_component; }
|
||||
$new_hex .= $new_hex_component;
|
||||
}
|
||||
|
||||
return '#' . $new_hex;
|
||||
}
|
||||
|
||||
function gdl_hex_darker($hex, $factor = 30){
|
||||
$new_hex = '';
|
||||
|
||||
$base['R'] = hexdec($hex{1}.$hex{2});
|
||||
$base['G'] = hexdec($hex{3}.$hex{4});
|
||||
$base['B'] = hexdec($hex{5}.$hex{6});
|
||||
|
||||
foreach ($base as $k => $v)
|
||||
{
|
||||
$amount = $v / 100;
|
||||
$amount = round($amount * $factor);
|
||||
$new_decimal = $v - $amount;
|
||||
|
||||
$new_hex_component = dechex($new_decimal);
|
||||
if(strlen($new_hex_component) < 2)
|
||||
{ $new_hex_component = "0".$new_hex_component; }
|
||||
$new_hex .= $new_hex_component;
|
||||
}
|
||||
|
||||
return '#' . $new_hex;
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user