Current File : /customers/3/5/c/campinoeksjo.se/httpd.www/wp-content/themes/MHreklam/functions.php |
<?php
/*
* Loads the Options Panel
*
* If you're loading from a child theme use stylesheet_directory
* instead of template_directory
*/
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
require_once get_template_directory() . '/options.php';
/*
* This is an example of how to add custom scripts to the options panel.
* This one shows/hides the an option when a checkbox is clicked.
*
* You can delete it if you not using that option
*/
add_action( 'optionsframework_custom_scripts', 'optionsframework_custom_scripts' );
function optionsframework_custom_scripts() { ?>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('#example_showhidden').click(function() {
jQuery('#section-example_text_hidden').fadeToggle(400);
});
if (jQuery('#example_showhidden:checked').val() !== undefined) {
jQuery('#section-example_text_hidden').show();
}
});
</script>
<?php
}
/**
* Proper way to enqueue scripts and styles
*/
/*
function namespace_theme_stylesheets()
{
wp_enqueue_style( 'bootstrap Min', get_template_directory_uri() .'/css/bootstrap.min.css', array(), null, 'all' );
wp_enqueue_style( 'Custom', get_template_directory_uri() .'/css/custom.css', array(), null, 'all' );
wp_enqueue_style( 'Font awesome', get_template_directory_uri() .'/css/font-awesome.min.css', array(), null, 'all' );
wp_enqueue_style( 'Owl Carousel', get_template_directory_uri() .'/css/owl.carousel.css', array(), null, 'all' );
wp_enqueue_script( 'jsscript', get_template_directory_uri() . '/js/jquery-3.3.1.min.js', array(), '1.0', true);
wp_enqueue_script( 'popper', get_template_directory_uri() . '/js/popper.min.js', array(), '1.0', true);
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '1.0', true);
wp_enqueue_script( 'carouselmin', get_template_directory_uri() . '/js/owl.carousel.min.js', array(), '1.0', true);
}
add_action( 'wp_enqueue_scripts', 'namespace_theme_stylesheets' );
function add_link_atts($atts) {
$atts['class'] = "nav-link";
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_link_atts');
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
function add_specific_menu_atts( $atts, $item, $args ) {
$menu_items = array(537);
if (in_array($item->ID, $menu_items)) {
$atts['class'] = "dropdown-toggle";
$atts['data-toggle'] = "dropdown";
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_specific_menu_atts', 10, 3 );
*/
add_theme_support( 'post-thumbnails' );
register_nav_menus( array(
'header_menu' => 'Header Menu',
'footer_menu' => 'Footer Menu'
) );
register_sidebar( array(
'name' => __( 'Sidebar', 'theme-slug' ),
'id' => 'sidebar',
'class'=> 'list_1',
'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),
'before_widget'=>'',
'after_widget'=>'',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Blog Sidebar', 'theme-slug' ),
'id' => 'sidebar-blog',
'class'=> 'list_1',
'description' => __( 'Widgets in this area will be shown on all pages of blog.', 'theme-slug' ),
'before_widget'=>'<div class="widget">',
'after_widget'=>'</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'News Sidebar', 'theme-slug' ),
'id' => 'sidebar-news',
'class'=> 'list_1',
'description' => __( 'Widgets in this area will be shown on all pages of news.', 'theme-slug' ),
'before_widget'=>'<div class="widget">',
'after_widget'=>'</div>',
'before_title' => '<h4>',
'after_title' => '</h4>',
) );
show_admin_bar(false);
function custom_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() ) {
return $title;
}
// Add the site name.
$title .= get_bloginfo( 'name', 'display' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) ) {
$title = "$title $sep $site_description";
}
// Add a page number if necessary.
if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
$title = "$title $sep " . sprintf( __( 'Page %s', 'custom' ), max( $paged, $page ) );
}
return $title;
}
add_filter( 'wp_title', 'custom_wp_title', 10, 2 );
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['reviews'] ); // Remove the reviews tab
return $tabs;
}
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
add_filter('use_block_editor_for_post', '__return_false', 10);
function pagination($pages = '', $range = 4)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class=\"pagination\"><span>Page ".$paged." of ".$pages."</span>";
if($paged > 0 || $paged > $range+1 || $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
if($paged > 0 || $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Prev</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"<a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a>";
}
}
if ($paged < $pages || $showitems < $pages) echo "<a href=\"".get_pagenum_link($paged + 1)."\">Next ›</a>";
if ($paged < $pages || $paged+$range < $pages || $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
echo "</div>\n";
}
}
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class ($classes, $item) {
if (in_array('current-menu-item', $classes) ){
$classes[] = 'active ';
}
return $classes;
}