Viewing file: shortcodes.php (13.21 KB) -rw-rw-rw- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php // logooos Shortcode function logooos_shortcode($atts, $content=null) { extract(shortcode_atts( array( 'columns' => '5', 'itemsheightpercentage' => '0.65', 'backgroundcolor' => 'transparent', 'layout' => 'grid', 'num' => '-1', 'category' => '0', 'orderby' => 'date', 'order' => 'DESC', 'marginbetweenitems' =>'' , 'tooltip' => 'disabled', 'responsive' => 'enabled', 'grayscale' => 'disabled', 'border' => 'disabled', 'bordercolor' => 'transparent', 'borderradius' => 'logooos_no_radius', 'onclickaction' => 'openLink', 'detailsarea_padding' => '30px', 'detailsarea_bgcolor' => '#f6f6f6', 'detailsarea_closebtncolor' => '#777777', 'detailsarea_border' => 'enabled', 'detailsarea_bordercolor' => '#dcdcdc', 'detailsarea_logo' => 'enabled', 'detailsarea_logoborder' => 'enabled', 'detailsarea_logobordercolor' => '#dcdcdc', 'detailsarea_logobgcolor' => 'transparent', 'autoplay' => 'true', 'transitioneffect' => 'scroll', 'easingfunction' => 'quadratic', 'scrollduration' => '1000', 'pauseduration' => '900', 'buttonsbordercolor' => '#DCDCDC', 'buttonsbgcolor' => '#FFFFFF', 'buttonsarrowscolor' => 'lightgray', 'hovereffect' => '', 'hovereffectcolor' => '#DCDCDC', 'titlefontfamily' => '', 'titlefontcolor' => '#777777', 'titlefontsize' => '15px', 'titlefontweight' => 'bold', 'textfontfamily' => '', 'textfontcolor' => '#777777', 'textfontsize' => '12px', 'excerpttextlength' => '55', 'listborder' => 'enabled', 'listbordercolor' => '#DCDCDC', 'listborderstyle' => 'dashed', 'morelinktext' => '', 'morelinktextcolor' => '', 'wpml_current_lang' =>'' ), $atts)); $logooos_suppress_filters = false; // query posts if(function_exists('icl_object_id') && $wpml_current_lang != '') { global $sitepress; if(isset($sitepress)) { $sitepress->switch_lang($wpml_current_lang); } } if($category != '-1') { $logooos_suppress_filters = true; } $args = array ( 'post_type' => 'logooo', 'posts_per_page' => $num, 'orderby' => $orderby, 'order' => $order, 'suppress_filters' => $logooos_suppress_filters); if($category > 0) { $args['tax_query'] = array(array('taxonomy' => 'logooocategory','field' => 'id','terms' => $category )); } $logooos_query = new WP_Query( $args ); $html='';
if ($logooos_query->have_posts()) { // ======== Classes ======== // $classes=''; //layout if($layout=='grid') { $classes.='logooos_grid '; } else if($layout=='slider') { $classes.='logooos_slider '; } else if($layout=='list') { $classes.='logooos_list '; } //responsive if($responsive=='enabled') { $classes.='logooos_responsive '; } //tooltip if($layout!='list') { if($tooltip=='enabled') { $classes.='logooos_withtooltip '; } } //grayscale if($grayscale=='enabled') { $classes.='logooos_grayscale '; } //border if($border=='enabled') { $classes.='logooos_border '; } else { $classes.='logooos_no_border '; } //list border if($listborder=='enabled') { $classes.='logooos_listborder '; } //border radius $classes.=$borderradius.' '; //hover effect $classes.=$hovereffect.' '; //show details if($onclickaction=='showDetails') { $classes.='logooos_showdetails '; } // ======== Data ======== // $data= ''; //columns if($layout!='list') { $data='data-columns="'.$columns.'" '; } //margin between items if($layout!='list') { $data.='data-marginbetweenitems="'.$marginbetweenitems.'" '; } //items height percentage $data.='data-itemsheightpercentage="'.$itemsheightpercentage.'" '; //hover effect $data.='data-hovereffect="'.$hovereffect.'" '; //hover effect color $data.='data-hovereffectcolor="'.$hovereffectcolor.'" '; //border color $data.='data-bordercolor="'.$bordercolor.'" '; if($layout == 'slider') { // autoplay $data.='data-autoplay="'.$autoplay.'" '; // Transition Effect $data.='data-transitioneffect="'.$transitioneffect.'" '; //easing function $data.='data-easingfunction="'.$easingfunction.'" '; // scroll duration $data.='data-scrollduration="'.$scrollduration.'" '; // pause duration $data.='data-pauseduration="'.$pauseduration.'" '; // buttons border color $data.='data-buttonsbordercolor="'.$buttonsbordercolor.'" '; // buttons background color $data.='data-buttonsbgcolor="'.$buttonsbgcolor.'" '; // buttons arrows color if($buttonsarrowscolor == 'darkgray') { $data.='data-buttonsarrowscolor="logooos_darkgrayarrows" '; } else if($buttonsarrowscolor == 'lightgray') { $data.='data-buttonsarrowscolor="logooos_lightgrayarrows" '; } else if($buttonsarrowscolor == 'white') { $data.='data-buttonsarrowscolor="logooos_whitearrows" '; } } if($onclickaction == 'showDetails') { $data.='data-detailspageurl='.plugins_url( 'details_area.php', __FILE__ ).' '; } $html.='<div class="logooos_container logooos_notready"><div class="logooos '.$classes.'" '.$data.' >'; $detailsAreaStyle = ''; $detailsAreaClass = ''; $detailsArea_container_style =''; $detailsArea_logo_style = ''; $detailsArea_closeBtn_style = ''; $titleStyle=''; $textStyle=''; $detailsArea_html =''; if($onclickaction == 'showDetails' || $layout=='list') { // title style if($titlefontfamily !='') { $titleStyle.='font-family:'.$titlefontfamily.'; '; } if($titlefontcolor !='') { $titleStyle.='color:'.$titlefontcolor.'; '; } if($titlefontsize !='') { $titleStyle.='font-size:'.$titlefontsize.'; '; } if($titlefontweight !='') { $titleStyle.='font-weight:'.$titlefontweight.'; '; } // text style if($textfontfamily !='') { $textStyle.='font-family:'.$textfontfamily.'; '; } if($textfontcolor !='') { $textStyle.='color:'.$textfontcolor.'; '; } if($textfontsize !='') { $textStyle.='font-size:'.$textfontsize.'; '; }
} if($onclickaction == 'showDetails') { // Details Area Style if($marginbetweenitems != '') { $detailsAreaStyle .= 'margin:'.floor($marginbetweenitems/2).'px;'; } // Details Area Class if($borderradius!= '') { $detailsAreaClass .= $borderradius.' '; } if($detailsarea_logo == 'disabled') { $detailsAreaClass .= 'logooos_withoutLogo '; } // Details Area Container Style if($detailsarea_bgcolor != '') { $detailsArea_container_style .= 'background-color:'.$detailsarea_bgcolor.';'; } if($detailsarea_border == 'enabled' && $detailsarea_bordercolor !='') { $detailsArea_container_style .= 'border: 1px solid '.$detailsarea_bordercolor.';'; } if($detailsarea_padding != '') { $detailsArea_container_style .= 'padding: '.$detailsarea_padding.';'; } if($itemsheightpercentage != '' && $detailsarea_logo == 'enabled') { $detailsArea_container_style .= 'min-height: '.(200 * $itemsheightpercentage).'px;'; } // Details Area Logo Style if($detailsarea_logoborder == 'enabled' && $detailsarea_logobordercolor != '') { $detailsArea_logo_style .= 'border: 1px solid '.$detailsarea_logobordercolor.';'; } if($detailsarea_logobgcolor != '') { $detailsArea_logo_style .= 'background-color: '.$detailsarea_logobgcolor.';'; } if($itemsheightpercentage != '') { $detailsArea_logo_style .= 'height: '.(200 * $itemsheightpercentage).'px;'; } // Details Area Close Button Style if($detailsarea_padding != '') { $detailsArea_closeBtn_style .= 'top: '.$detailsarea_padding.';'; $detailsArea_closeBtn_style .= 'right: '.$detailsarea_padding.';'; } $detailsArea_html = '<div class="logooos_detailsarea '.$detailsAreaClass.'" style="'.$detailsAreaStyle.'"> <a class="logooos_detailsarea_closeBtn" href="#" style="'.$detailsArea_closeBtn_style.'" > <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="15px" height="15px" viewBox="0 0 15 15" enable-background="new 0 0 15 15" xml:space="preserve"> <g> <rect x="6.97" y="-2.576" transform="matrix(0.7071 -0.7071 0.7071 0.7071 -3.1068 7.5001)" fill="'.$detailsarea_closebtncolor.'" width="1.061" height="20.152"/> <rect x="6.97" y="-2.576" transform="matrix(-0.7069 -0.7073 0.7073 -0.7069 7.497 18.1068)" fill="'.$detailsarea_closebtncolor.'" width="1.061" height="20.152"/> </g> </svg> </a> <div class="logooos_detailsarea_container" style="'.$detailsArea_container_style.'"> <div class="logooos_detailsarea_img" style="'.$detailsArea_logo_style.'"></div> <div class="logooos_detailsarea_title" style="'.$titleStyle.'" ></div> <div class="logooos_detailsarea_text" style="'.$textStyle.'" ></div> </div> </div>'; if($layout == 'list') { $html.=$detailsArea_html; } } $i = 0; while ($i < $logooos_query->post_count) { $post = $logooos_query->posts; $thumbnailsrc=""; $href=''; $link =''; $imgSize='99%'; $bgSize='99%'; $link_target='_blank'; if(get_post_meta($post[$i]->ID, 'link', true)!='' && $onclickaction == 'openLink') { $link = get_post_meta($post[$i]->ID, 'link', true); if (strpos($link, 'http://') === false && strpos($link, 'https://') === false ) { $href='href="http://'.get_post_meta($post[$i]->ID, 'link', true).'"'; } else { $href='href="'.get_post_meta($post[$i]->ID, 'link', true).'"'; } } if(get_post_meta($post[$i]->ID, 'imageSize', true) !='' ) { $imgSize=get_post_meta($post[$i]->ID, 'imageSize', true); $bgSize='-webkit-background-size: '.$imgSize.'; -moz-background-size: '.$imgSize.'; background-size: '.$imgSize.';'; } // if has post thumbnail if ( has_post_thumbnail($post[$i]->ID)) { $thumbnailsrc = wp_get_attachment_url(get_post_meta($post[$i]->ID, '_thumbnail_id', true)); } if(get_post_meta($post[$i]->ID, 'link_target', true) !='' ) { $link_target=get_post_meta($post[$i]->ID, 'link_target', true); } $html.='<div class="logooos_item" data-id="'.$post[$i]->ID.'" data-title="'.$post[$i]->post_title.'" style="background-color:'.$backgroundcolor.'; border-color:'.$bordercolor.'"> <a '.$href.' target="'.$link_target.'" style="'.$bgSize.'background-image:url('.$thumbnailsrc.'); ">'; if($thumbnailsrc!='') { $html.='<img src="'.$thumbnailsrc.'" title="" style="max-width:'.$imgSize.' !important; max-height:'.$imgSize.' !important;" alt="'.$post[$i]->post_title.'" />'; } if($hovereffect=='effect2') { $html.='<span class="logooos_effectspan"></span>'; } $html.='</a>'; $html.='</div>'; if($layout=='list') { // text container style $textContainerStyle = ''; if($listborder =='enabled') { if($listbordercolor !='') { $textContainerStyle.='border-bottom-color:'.$listbordercolor.'; '; } if($listborderstyle !='') { $textContainerStyle.='border-bottom-style:'.$listborderstyle.'; '; } } $html.='<div class="logooos_textcontainer" style="'.$textContainerStyle.'"> <div class="logooos_title" style="'.$titleStyle.'">'.$post[$i]->post_title.'</div> <div class="logooos_text" style="'.$textStyle.'"><div>'.wp_trim_words(get_post_meta($post[$i]->ID, 'description', true), $excerpttextlength).'</div>'; if(($morelinktext!='' && get_post_meta($post[$i]->ID, 'link', true) !='' && $onclickaction == 'openLink') || ($onclickaction == 'showDetails' && $morelinktext!='')) { $linkColor =''; if($morelinktextcolor != '') { $linkColor ='color:'.$morelinktextcolor; } $html.= '<a '.$href.' target="'.$link_target.'" data-id="'.$post[$i]->ID.'" class="logooos_morelink" style="'.$linkColor.'" >'.$morelinktext.'</a>'; } $html.= ' </div> </div>'; } $i++; } if($onclickaction == 'showDetails' && $layout == 'grid') { $html.=$detailsArea_html; } $html.='</div>'; if($onclickaction == 'showDetails' && $layout == 'slider') { $html.=$detailsArea_html; } $html.='</div>'; } return $html;
} add_shortcode('logooos', 'logooos_shortcode'); // logooos_saved Shortcode function logooos_saved_shortcode( $atts ) { extract( shortcode_atts( array( 'id' => '' ), $atts ) ); $logooos_sc = ''; if($id != ''){ $logooos_sc = get_post($id); if(get_post_meta($logooos_sc->ID, 'shortcode', true) != '') { return do_shortcode( get_post_meta($logooos_sc->ID, 'shortcode', true) ); } } } add_shortcode( 'logooos_saved', 'logooos_saved_shortcode' ); ?>
|