daily pastebin goal
31%
SHARE
TWEET

WooCommerce Functions Dazzling

a guest Apr 29th, 2015 614 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Dazzling functions and definitions
  4.  *
  5.  * @package dazzling
  6.  */
  7.  
  8. /**
  9.  * Set the content width based on the theme's design and stylesheet.
  10.  */
  11. if ( ! isset( $content_width ) ) {
  12.         $content_width = 730; /* pixels */
  13. }
  14.  
  15. /**
  16.  * Set the content width for full width pages with no sidebar.
  17.  */
  18. function dazzling_content_width() {
  19.   if ( is_page_template( 'page-fullwidth.php' ) || is_page_template( 'front-page.php' ) ) {
  20.     global $content_width;
  21.     $content_width = 1110; /* pixels */
  22.   }
  23. }
  24. add_action( 'template_redirect', 'dazzling_content_width' );
  25.  
  26. if ( ! function_exists( 'dazzling_setup' ) ) :
  27. /**
  28.  * Sets up theme defaults and registers support for various WordPress features.
  29.  *
  30.  * Note that this function is hooked into the after_setup_theme hook, which
  31.  * runs before the init hook. The init hook is too late for some features, such
  32.  * as indicating support for post thumbnails.
  33.  */
  34. function dazzling_setup() {
  35.  
  36.   /*
  37.    * Make theme available for translation.
  38.    * Translations can be filed in the /languages/ directory.
  39.    * If you're building a theme based on Dazzling, use a find and replace
  40.    * to change 'dazzling' to the name of your theme in all the template files
  41.    */
  42.   load_theme_textdomain( 'dazzling', get_template_directory() . '/languages' );
  43.  
  44.   // Add default posts and comments RSS feed links to head.
  45.   add_theme_support( 'automatic-feed-links' );
  46.  
  47.   /*
  48.    * Enable support for Post Thumbnails on posts and pages.
  49.    *
  50.    * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
  51.    */
  52.   add_theme_support( 'post-thumbnails' );
  53.  
  54.   add_image_size( 'dazzling-featured', 730, 410, true );
  55.   add_image_size( 'tab-small', 60, 60 , true); // Small Thumbnail
  56.  
  57.   // This theme uses wp_nav_menu() in one location.
  58.   register_nav_menus( array(
  59.     'primary'      => __( 'Primary Menu', 'dazzling' ),
  60.     'footer-links' => __( 'Footer Links', 'dazzling' ) // secondary menu in footer
  61.   ) );
  62.  
  63.   // Enable support for Post Formats.
  64.   add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link' ) );
  65.  
  66.   // Setup the WordPress core custom background feature.
  67.   add_theme_support( 'custom-background', apply_filters( 'dazzling_custom_background_args', array(
  68.         'default-color' => 'ffffff',
  69.         'default-image' => '',
  70.   ) ) );
  71.  
  72.   /*
  73.    * Let WordPress manage the document title.
  74.    * By adding theme support, we declare that this theme does not use a
  75.    * hard-coded <title> tag in the document head, and expect WordPress to
  76.    * provide it for us.
  77.    */
  78.   add_theme_support( 'title-tag' );
  79. }
  80. endif; // dazzling_setup
  81. add_action( 'after_setup_theme', 'dazzling_setup' );
  82.  
  83. /**
  84.  * Register widgetized area and update sidebar with default widgets.
  85.  */
  86. function dazzling_widgets_init() {
  87.   register_sidebar( array(
  88.     'name'          => __( 'Sidebar', 'dazzling' ),
  89.     'id'            => 'sidebar-1',
  90.     'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  91.     'after_widget'  => '</aside>',
  92.     'before_title'  => '<h3 class="widget-title">',
  93.     'after_title'   => '</h3>',
  94.   ) );
  95.   register_sidebar(array(
  96.     'id'            => 'home-widget-1',
  97.     'name'          => __( 'Homepage Widget 1', 'dazzling' ),
  98.     'description'   => __( 'Displays on the Home Page', 'dazzling' ),
  99.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  100.     'after_widget'  => '</div>',
  101.     'before_title'  => '<h3 class="widgettitle">',
  102.     'after_title'   => '</h3>',
  103.   ));
  104.  
  105.   register_sidebar(array(
  106.     'id'            => 'home-widget-2',
  107.     'name'          =>  __( 'Homepage Widget 2', 'dazzling' ),
  108.     'description'   => __( 'Displays on the Home Page', 'dazzling' ),
  109.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  110.     'after_widget'  => '</div>',
  111.     'before_title'  => '<h3 class="widgettitle">',
  112.     'after_title'   => '</h3>',
  113.   ));
  114.  
  115.   register_sidebar(array(
  116.     'id'            => 'home-widget-3',
  117.     'name'          =>  __( 'Homepage Widget 3', 'dazzling' ),
  118.     'description'   =>  __( 'Displays on the Home Page', 'dazzling' ),
  119.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  120.     'after_widget'  => '</div>',
  121.     'before_title'  => '<h3 class="widgettitle">',
  122.     'after_title'   => '</h3>',
  123.   ));
  124.  
  125.   register_sidebar(array(
  126.     'id'            => 'footer-widget-1',
  127.     'name'          =>  __( 'Footer Widget 1', 'dazzling' ),
  128.     'description'   =>  __( 'Used for footer widget area', 'dazzling' ),
  129.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  130.     'after_widget'  => '</div>',
  131.     'before_title'  => '<h3 class="widgettitle">',
  132.     'after_title'   => '</h3>',
  133.   ));
  134.  
  135.   register_sidebar(array(
  136.     'id'            => 'footer-widget-2',
  137.     'name'          =>  __( 'Footer Widget 2', 'dazzling' ),
  138.     'description'   =>  __( 'Used for footer widget area', 'dazzling' ),
  139.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  140.     'after_widget'  => '</div>',
  141.     'before_title'  => '<h3 class="widgettitle">',
  142.     'after_title'   => '</h3>',
  143.   ));
  144.  
  145.   register_sidebar(array(
  146.     'id'            => 'footer-widget-3',
  147.     'name'          =>  __( 'Footer Widget 3', 'dazzling' ),
  148.     'description'   =>  __( 'Used for footer widget area', 'dazzling' ),
  149.     'before_widget' => '<div id="%1$s" class="widget %2$s">',
  150.     'after_widget'  => '</div>',
  151.     'before_title'  => '<h3 class="widgettitle">',
  152.     'after_title'   => '</h3>',
  153.   ));
  154.  
  155.  
  156.   register_widget( 'dazzling_popular_posts_widget' );
  157. }
  158. add_action( 'widgets_init', 'dazzling_widgets_init' );
  159.  
  160. include(get_template_directory() . "/inc/popular-posts-widget.php");
  161.  
  162.  
  163. /**
  164.  * Enqueue scripts and styles.
  165.  */
  166. function dazzling_scripts() {
  167.  
  168.   wp_enqueue_style( 'dazzling-bootstrap', get_template_directory_uri() . '/inc/css/bootstrap.min.css' );
  169.  
  170.   wp_enqueue_style( 'dazzling-icons', get_template_directory_uri().'/inc/css/font-awesome.min.css' );
  171.  
  172.   wp_enqueue_style( 'ax-font', get_template_directory_uri().'/inc/css/axfont.css' );
  173.  
  174.  
  175.   if ( class_exists( 'jigoshop' ) ) { // Jigoshop specific styles loaded only when plugin is installed
  176.     wp_enqueue_style( 'jigoshop-css', get_template_directory_uri().'/inc/css/jigoshop.css' );
  177.   }
  178.  
  179.   wp_enqueue_style( 'dazzling-style', get_stylesheet_uri() );
  180.  
  181.   wp_enqueue_script('dazzling-bootstrapjs', get_template_directory_uri().'/inc/js/bootstrap.min.js', array('jquery') );
  182.  
  183.  
  184.   wp_enqueue_script( 'carousel', get_template_directory_uri() . '/inc/js/carousel.js', array('jquery'), '1.0', true );
  185.  
  186.   wp_enqueue_script( 'dazzling-main', get_template_directory_uri() . '/inc/js/main.js', array('jquery') );
  187.  
  188.   if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  189.         wp_enqueue_script( 'comment-reply' );
  190.   }
  191. }
  192.  
  193. add_action( 'wp_enqueue_scripts', 'dazzling_scripts' );
  194.  
  195. /**
  196.  * Add HTML5 shiv and Respond.js for IE8 support of HTML5 elements and media queries
  197.  */
  198. function dazzling_ie_support_header() {
  199.   echo '<!--[if lt IE 9]>'. "\n";
  200.   echo '<script src="' . esc_url( get_template_directory_uri() . '/inc/js/html5shiv.min.js' ) . '"></script>'. "\n";
  201.   echo '<script src="' . esc_url( get_template_directory_uri() . '/inc/js/respond.min.js' ) . '"></script>'. "\n";
  202.   echo '<![endif]-->'. "\n";
  203. }
  204. add_action( 'wp_head', 'dazzling_ie_support_header', 11 );
  205.  
  206. /*
  207.  * Removes products count after categories name
  208.  */
  209. add_filter( 'woocommerce_subcategory_count_html', 'woo_remove_category_products_count' );
  210.  
  211. function woo_remove_category_products_count() {
  212.   return;
  213. }
  214.  
  215. /**
  216.  * WooCommerce Extra Feature
  217.  * --------------------------
  218.  *
  219.  * Change number of related products on product page
  220.  * Set your own value for 'posts_per_page'
  221.  *
  222.  */
  223. function woo_related_products_limit() {
  224.   global $product;
  225.    
  226.     $args['posts_per_page'] = 6;
  227.     return $args;
  228. }
  229. add_filter( 'woocommerce_output_related_products_args', 'jk_related_products_args' );
  230.   function jk_related_products_args( $args ) {
  231.  
  232.     $args['posts_per_page'] = 4; // 4 related products
  233.     $args['columns'] = 4; // arranged in 2 columns
  234.     return $args;
  235. }
  236.  
  237. /*
  238.  * Loads the Options Panel
  239.  *
  240.  * If you're loading from a child theme use stylesheet_directory
  241.  * instead of template_directory
  242.  */
  243. define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/admin/' );
  244. require_once dirname( __FILE__ ) . '/inc/admin/options-framework.php';
  245. // Loads options.php from child or parent theme
  246. $optionsfile = locate_template( 'options.php' );
  247. load_template( $optionsfile );
  248.  
  249. /**
  250.  * Implement the Custom Header feature.
  251.  */
  252. require get_template_directory() . '/inc/custom-header.php';
  253.  
  254. /**
  255.  * Custom template tags for this theme.
  256.  */
  257. require get_template_directory() . '/inc/template-tags.php';
  258.  
  259. /**
  260.  * Custom functions that act independently of the theme templates.
  261.  */
  262. require get_template_directory() . '/inc/extras.php';
  263.  
  264. /**
  265.  * Customizer additions.
  266.  */
  267. require get_template_directory() . '/inc/customizer.php';
  268.  
  269. /**
  270.  * Load Jetpack compatibility file.
  271.  */
  272. require get_template_directory() . '/inc/jetpack.php';
  273.  
  274. /**
  275.  * Load custom nav walker
  276.  */
  277. require get_template_directory() . '/inc/navwalker.php';
  278.  
  279. if ( class_exists( 'woocommerce' ) ) {
  280. /**
  281.  * WooCommerce related functions
  282.  */
  283. require get_template_directory() . '/inc/woo-setup.php';
  284. }
  285.  
  286. if ( class_exists( 'jigoshop' ) ) {
  287. /**
  288.  * Jigoshop related functions
  289.  */
  290. require get_template_directory() . '/inc/jigoshop-setup.php';
  291. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top