if ( ! function_exists( 'mvf_setup' ) ) :
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
$theme = wp_get_theme();
define( 'THEME_VERSION', $theme->get('Version') );
function mvf_setup() {
/*
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on mvf, use a find and replace
* to change 'mvf' to the name of your theme in all the template files.
*/
load_theme_textdomain( 'marketingvoorfotografen', get_template_directory() . '/languages' );
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded
tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
// add_theme_support(
// 'custom-logo',
// array(
// 'height' => 100,
// 'width' => 350,
// 'flex-height' => true,
// 'flex-width' => true,
// )
// );
add_image_size('header', 3840, 3840, false);
add_image_size('banner', 1200, 400, true);
add_image_size('item', 800, 800, false);
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'header-menu' => __( 'Header Menu', 'marketingvoorfotografen' )
) );
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/*
* WooCommerce.
*/
$hook_result = apply_filters_deprecated( 'mvf_theme_add_woocommerce_support', [ true ], '2.0', 'mvf_add_woocommerce_support' );
if ( apply_filters( 'mvf_add_woocommerce_support', $hook_result ) ) {
// WooCommerce in general.
add_theme_support( 'woocommerce' );
// Enabling WooCommerce product gallery features (are off by default since WC 3.0.0).
// zoom.
add_theme_support( 'wc-product-gallery-zoom' );
// lightbox.
add_theme_support( 'wc-product-gallery-lightbox' );
// swipe.
add_theme_support( 'wc-product-gallery-slider' );
}
}
endif;
add_action( 'after_setup_theme', 'mvf_setup' );
// Add jquery
//add_action( 'wp_enqueue_scripts', 'add_my_script' );
//function add_my_script() {
// wp_enqueue_script(
// // 'your-script', // name your script so that you can attach other scripts and de-register, etc.
// // get_template_directory_uri() . '/js/your-script.js', // this is the location of your script file
// array('jquery') // this array lists the scripts upon which your script depends
// );
//}
function mytheme_enqueue_style() {
wp_enqueue_style( 'mytheme-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'mytheme_enqueue_style' );
//function wpb_adding_styles() {
// wp_register_style('my_stylesheet', plugins_url('my-stylesheet.css', __FILE__));
// wp_enqueue_style('my_stylesheet');
//}
//add_action( 'wp_enqueue_scripts', 'wpb_adding_styles' );
//
function wpb_adding_scripts() {
wp_register_script('my_amazing_script', get_template_directory_uri() . '/assets/js/swiper.js', array('jquery'),'1.1', true);
wp_enqueue_script('my_amazing_script');
}
add_action( 'wp_enqueue_scripts', 'wpb_adding_scripts' );
// Menus
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => __( 'Header Menu' )
)
);
}
add_action( 'init', 'register_my_menus' );
// Custom class on Nav link
function add_specific_menu_location_atts( $atts, $item, $args ) {
// check if the item is in the primary menu
if( $args->theme_location == 'header-menu' ) {
// add the desired attributes:
$atts['class'] = 'Nav-link';
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_specific_menu_location_atts', 10, 3 );
// Register our sidebars and widgetized areas.
function arphabet_widgets_init() {
register_sidebar( array(
'name' => 'Overall sidebar',
'id' => 'sidebar-overall',
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );
// Custom widget
add_filter('widget_text', 'do_shortcode');
// Remove 'category' from archive title
add_filter( 'get_the_archive_title', function ($title) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '' . get_the_author() . '' ;
} elseif ( is_tax() ) { //for custom post types
$title = sprintf( __( '%1$s' ), single_term_title( '', false ) );
} elseif (is_post_type_archive()) {
$title = post_type_archive_title( '', false );
}
return $title;
});
/**
* Change number of products that are displayed per page (shop page)
*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options –> Reading
// Return the number of products you wanna show per page.
$cols = 24;
return $cols;
}
// voor mvf
//add_filter( 'get_edit_user_link', function( $link, $user_id ) {
// $link = "https://www.marketingvoorfotografen.nl/mijn-profiel";
// return $link;
//}, 30, 2 );
// backup snippets mvf
//add_filter( 'wp_email_from', function( $from_email ) {
// if ($from_email == "precio1q@ssd41.totaalholding.nl")
// {
// return "info@marketingvoorfotografen.nl";
// }
// return $from_email;
//});
function prefix_woocommerce_sale_flash( $text ) {
$text = ''. __( 'Black Friday actie!', 'text_domain' ). '';
return $text;
}
add_filter( 'woocommerce_sale_flash', 'prefix_woocommerce_sale_flash' );
add_filter('woocommerce_default_catalog_orderby', 'misha_default_catalog_orderby');
function misha_default_catalog_orderby( $sort_by ) {
return 'menu_order';
}
?>
Newborn – Jills photography