Advertisement
Guest User

functions.php

a guest
Dec 15th, 2013
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.14 KB | None | 0 0
  1. <?php
  2. // theme admin
  3. include('functions/theme-admin.php');
  4.  
  5. //Remove WordPress Version For Security Reasons
  6. remove_action('wp_head', 'wp_generator');
  7. // get scripts
  8. add_action('wp_enqueue_scripts','my_theme_scripts_function');
  9.  
  10. function my_theme_scripts_function() {
  11.    
  12. wp_deregister_script('jquery');
  13. wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '');
  14. wp_enqueue_script('jquery');
  15.  }
  16. if ( !is_admin() ) {
  17. function my_init_method() {
  18. wp_deregister_script( 'l10n' );
  19. }
  20. add_action('init', 'my_init_method');
  21. }
  22. add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );
  23.  
  24. function my_deregister_javascript() {
  25.     if (is_front_page() || is_archive() || is_page()) {
  26.     wp_deregister_script( 'lightbox' );
  27.     wp_deregister_script( 'stt-common' );
  28.     wp_deregister_script( 'jquerylazyload' );
  29.     wp_deregister_script( 'jquery' );
  30. }
  31. }
  32. function control_wp_script_versioning($src)
  33. {
  34.     $src = remove_query_arg( 'ver', $src );
  35.     return $src;
  36. }
  37. function control_wp_style_versioning($src)
  38. {
  39.     $src = remove_query_arg( 'ver', $src );
  40.     return $src;
  41. }
  42. add_filter('script_loader_src', 'control_wp_script_versioning', 15);
  43. add_filter('style_loader_src', 'control_wp_style_versioning', 15);
  44. function new_excerpt_length($length) {
  45.     return 20;
  46. }
  47. add_filter('excerpt_length', 'new_excerpt_length');
  48.  
  49. //Replace Excerpt Link
  50. function new_excerpt_more($more) {
  51.        global $post;
  52.     return '...';
  53. }
  54. add_filter('excerpt_more', 'new_excerpt_more');
  55.  
  56. if ( function_exists( 'add_theme_support' ) )
  57. add_theme_support( 'post-thumbnails' );
  58.  
  59. // featured image sizes
  60. if ( function_exists( 'add_image_size' ) ) {
  61. add_image_size( 'shadows-full-size',  9999, 9999, false );
  62. add_image_size( 'shadows-post-image',  140, 140, true );
  63. add_image_size( 'shadows-single-image',  140, 140, true );
  64. add_image_size( 'shadows-related-image',  190, 130, true );
  65. add_image_size( 'shadows-featured-image',  230, 120, true );
  66. }
  67.  
  68. // Enable Custom Background
  69. add_custom_background();
  70.  
  71. // Register Navigation Menus
  72. register_nav_menus(
  73.     array(
  74.     'primary'=>__('Menu'),
  75.     )
  76. );
  77.  
  78. //Register Sidebars
  79. if ( function_exists('register_sidebar') )
  80. register_sidebar(array(
  81. 'name' => 'ستون کناری',
  82. 'before_widget' => '<div class="sidebar-box">',
  83. 'after_widget' => '</div>',
  84. 'before_title' => '<h4>',
  85. 'after_title' => '</h4>',
  86. ));
  87. if ( function_exists('register_sidebar') )
  88. register_sidebar(array(
  89. 'name' => 'فوتر ۱',
  90. 'before_widget' => '<div class="footer-box">',
  91. 'after_widget' => '</div>',
  92. 'before_title' => '<h4>',
  93. 'after_title' => '</h4>',
  94. ));
  95. if ( function_exists('register_sidebar') )
  96. register_sidebar(array(
  97. 'name' => 'فوتر ۲',
  98. 'before_widget' => '<div class="footer-box">',
  99. 'after_widget' => '</div>',
  100. 'before_title' => '<h4>',
  101. 'after_title' => '</h4>',
  102. ));
  103. if ( function_exists('register_sidebar') )
  104. register_sidebar(array(
  105. 'name' => 'فوتر ۳',
  106. 'before_widget' => '<div class="footer-box">',
  107. 'after_widget' => '</div>',
  108. 'before_title' => '<h4>',
  109. 'after_title' => '</h4>',
  110. ));
  111. if ( function_exists('register_sidebar') )
  112. register_sidebar(array(
  113. 'name' => 'فوتر ۴',
  114. 'description' => 'Widgets in this area will be shown in the footer - right side.',
  115. 'before_widget' => '<div class="footer-box">',
  116. 'after_widget' => '</div>',
  117. 'before_title' => '<h4>',
  118. 'after_title' => '</h4>',
  119. ));
  120.  
  121. define('EDD_SLUG', 'product');
  122.  
  123.  
  124. add_filter('widget_text', 'do_shortcode');
  125.  
  126.  
  127. // This is used for top menu  
  128. register_nav_menus( array(  
  129. 'top_menu' => __( 'Top Menu', 'your_theme_name' )
  130. ) );
  131.  
  132. /**
  133.  * Modifies submenu li
  134.  */
  135. add_filter('wpmenucart_submenu_items', 'mod_wpmenucart_submenu_item_li', 1, 1);
  136. function mod_wpmenucart_submenu_item_li($wpmenucart_submenu_items){
  137. global $wpMenuCart;
  138. $submenu_data = $wpMenuCart->shop->submenu_items();
  139. $cart_submenu_item_li = '';
  140. foreach ( $submenu_data as $submenu_item_data ) {
  141.     // Format submenu item content (without permalink or li yet!)
  142.                    
  143.                     // The thumbnail
  144.                     $cart_submenu_item_content = '<span class="wpmenucart-thumbnail">'.$submenu_item_data['item_thumbnail'].'</span>';
  145.  
  146.                     // Item info wrapper
  147.                     $cart_submenu_item_content .= '<span class="wpmenucart-order-item-info">';
  148.                         // Product Name
  149.                        
  150.                         // strip out / truncate $item_name
  151.                         if (strlen($submenu_item_data['item_name']) > apply_filters( 'wpmenucart_submenu_name_truncate', '20') ) {
  152.                             $submenu_item_data['item_name'] = $submenu_item_data['item_name'];
  153.                         }
  154.    
  155.     $cart_submenu_item_content .= '<span class="wpmenucart-product-name">'.$submenu_item_data['item_name'].'</span>';
  156.  
  157.                         // Quantity x price
  158.                         $cart_submenu_item_content .= '<span class="wpmenucart-product-quantity-price">';
  159.                         $cart_submenu_item_content .=  $submenu_item_data['item_price'];
  160.                         $cart_submenu_item_content .= '</span>';
  161.                         $cart_submenu_item_content .= '</span>';
  162.                
  163.                     // Permalink wrap
  164.                     if ( $submenu_item_data['item_permalink'] != '' )
  165.                         $cart_submenu_item_content = sprintf('<a href="%s" class="clearfix">%s</a>', $submenu_item_data['item_permalink'], $cart_submenu_item_content );
  166.     $cart_submenu_item_li = '<li class="menu-item wpmenucart-submenu-item clearfix">'.$cart_submenu_item_content.'</li>';
  167.     return $wpmenucart_submenu_items;
  168. }
  169.  
  170. }
  171. /**
  172.  * Modify the content of the wpmenucart-content <a> tag
  173.  */
  174. add_filter('wpmenucart_menu_item_a_content', 'add_wpmenucart_menu_item_a_content', 1, 1);
  175. function add_wpmenucart_menu_item_a_content ($content) {
  176.     global $wpMenuCart;
  177.     $item_data = $wpMenuCart->shop->menu_item();
  178.     $cart_contents = sprintf(_n('%d item', '%d items', $item_data['cart_contents_count'], 'wpmenucart'), $item_data['cart_contents_count']);
  179.     $content = '';
  180.     $content .= '<i class="wpmenucart-icon-shopping-cart-'.$wpMenuCart->options['cart_icon'].'"></i>';
  181.     $content .= '<span class="cartcontents another class">'.$cart_contents.'</span><span class="amount">'.$item_data['cart_total'].'</span>';
  182.     return $content;
  183. }
  184.  
  185. add_filter('wpmenucart_submenu_name_truncate', 'add_wpmenucart_submenu_name_truncate', 1, 1);
  186. function add_wpmenucart_submenu_name_truncate ($truncate) {
  187. $truncate = 50;
  188. return $truncate;
  189. }
  190.  
  191. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement