'fff',
'default-image' => '',
'default-repeat' => '',
'default-position-x' => '',
'default-attachment' => '',
'wp-head-callback' => array($this, 'change_custom_background_cb'),
'admin-head-callback' => '',
'admin-preview-callback' => ''
);
add_theme_support( 'custom-background', $background_defaults );
$header_defaults = array(
'default-image' => get_template_directory_uri() . '/assets/images/default.jpg',
'width' => 1000,
'height' => 250,
'random-default' => false,
'flex-width' => true,
'flex-height' => true,
'default-text-color' => 'fff',
'header-text' => true,
'uploads' => true,
'wp-head-callback' => '',
'admin-head-callback' => '',
'admin-preview-callback' => '',
);
add_theme_support( 'custom-header', $header_defaults );
require( get_template_directory() . '/inc/megamenu-nav-walker.php' );
require( get_template_directory() . '/inc/megamenu-widget-nav-walker.php' );
require( get_template_directory() . '/inc/megamenu-bottom-nav-walker.php' );
require( get_template_directory() . '/inc/comment-walker.php' );
require( get_template_directory() . '/inc/customizer.php' );
}
/**
* 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.
*/
public function setup() {
// Make theme available for translation.
load_theme_textdomain( 'free-template', 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( 'customize-selective-refresh-widgets' );
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'wc-product-gallery-zoom' );
// 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',
) );
/*
* Enable support for Post Formats.
* See: https://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
'gallery',
'audio',
'status',
'chat',
) );
// Add theme support for Custom Logo.
//https://make.wordpress.org/core/2016/03/10/custom-logo/
//https://codex.wordpress.org/Theme_Logo
add_theme_support( 'custom-logo', array(
'width' => 80,
'height' => 80,
'flex-width' => true,
'flex-height' => false,
// Classes(s) of elements to hide.
// It can pass an array of class names here for all elements constituting header text that could be replaced by a logo.
//'header-text' => array( 'site-title', 'site-description' ),
) );
// This theme uses wp_nav_menu() in two locations.
register_nav_menus( array(
'primary' => esc_html__( 'Top Menu', 'free-template' ),
'header' => esc_html__( 'Bottom of Header', 'free-template' ),
'header-right' => esc_html__( 'Bottom of Header - Right', 'free-template' ),
'bottom' => esc_html__( 'Bottom of Site', 'free-template' ),
) );
add_image_size( 'dedidata-template-featured-image', 2000, 1200, true );
add_image_size( 'dedidata-template-thumbnail-avatar', 90, 90, true );
// Set the default content width.
$GLOBALS['content_width'] = 525;
// This theme styles the visual editor to resemble the theme style, specifically font, colors, and column width.
add_editor_style( 'assets/css/editor-style.css' );
}
/**
* Register widget area.
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
public function widgets_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'free-template' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here to appear in your sidebar.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Frontend Content Top', 'free-template' ),
'id' => 'frontend-content-top',
'description' => esc_html__( 'Add widgets here to appear in your top of content in Frontpage.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Frontend Content Bottom', 'free-template' ),
'id' => 'frontend-content-bottom',
'description' => esc_html__( 'Add widgets here to appear in your bottom of content in Frontpage.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Content Top', 'free-template' ),
'id' => 'content-top',
'description' => esc_html__( 'Add widgets here to appear in your top of content.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Content Bottom', 'free-template' ),
'id' => 'content-bottom',
'description' => esc_html__( 'Add widgets here to appear in your bottom of content.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Column 1', 'free-template' ),
'id' => 'footer-column-1',
'description' => esc_html__( 'Add widgets here to appear in your footer column 1.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Column 2', 'free-template' ),
'id' => 'footer-column-2',
'description' => esc_html__( 'Add widgets here to appear in your footer column 2.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Column 3', 'free-template' ),
'id' => 'footer-column-3',
'description' => esc_html__( 'Add widgets here to appear in your footer column 3.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Column 4', 'free-template' ),
'id' => 'footer-column-4',
'description' => esc_html__( 'Add widgets here to appear in your footer column 4.', 'free-template' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '
',
'after_title' => '
',
) );
register_sidebar( array(
'name' => esc_html__( 'Popup Window', 'free-template' ),
'id' => 'popup-modal',
'description' => esc_html__( 'Add widgets here to appear in automatic popup window when your site loads in first view.', 'free-template' ),
'before_widget' => '
',
esc_url( get_permalink( get_the_ID() ) ),
get_the_title()
);
return ' … ' . $link;
}
/**
* Filter wp_link_pages to wrap current page
*
* @param $link
* @return string
*/
public function bs_link_pages( $link ) {
if ( ctype_digit( $link ) ) {
return '
' . $link . '
';
}
return '
' . $link . '
';
}
// Add prev and next links to a numbered page link list
public function wp_link_pages_args_prevnext_add($args){
global $page, $numpages, $more, $pagenow;
if (!$args['next_or_number'] == 'next_and_number')
return $args; # exit early
$args['next_or_number'] = 'number'; # keep numbering for the main part
if (!$more)
return $args; # exit early
//
',
);
return $fields;
}
public function bootstrap3_comment_form( $args ) {
$args['comment_field'] = '
';
$args['class_submit'] = 'btn btn-default'; // since WP 4.1
return $args;
}
public function add_div_nav_widget( $args ) {
$args['menu_class'] = 'nav nav-stacked';
//$args['fallback_cb'] = 'WP_Bootstrap_Navwalker::fallback';
$args['walker'] = new WP_Bootstrap_Widget_Navwalker();
return $args;
}
/**
* Adds custom classes to the array of body classes.
*
* @param array $classes Classes for the body element.
* @return array
*/
public function body_classes( $classes ) {
// Add class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
}
// Add class of hfeed to non-singular pages.
if ( ! is_singular() ) {
$classes[] = 'hfeed';
}
// Add class if we're viewing the Customizer for easier styling of theme options.
if ( is_customize_preview() ) {
$classes[] = 'dedidata-template-customizer';
}
return $classes;
}
/**
* Filter attributes for the current gallery image tag.
*
* @param array $atts Gallery image tag attributes.
* @param WP_Post $attachment WP_Post object for the attachment.
* @return array (maybe) filtered gallery image tag attributes.
*/
public function image_item_add_title( $atts, $attachment ) {
if($atts['alt'] !== ''){
$atts['title'] = $atts['alt'];
}
return $atts;
}
/**
* Filter the except length to 45 words.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
public function custom_excerpt_length( $length ) {
return 75;
}
public function order_by_stock_status($posts_clauses){
global $wpdb;
// only change query on WooCommerce loops
if (is_product_category() || is_product_tag()) {
$posts_clauses['join'] .= " INNER JOIN $wpdb->postmeta istockstatus ON ($wpdb->posts.ID = istockstatus.post_id) ";
$posts_clauses['orderby'] = " istockstatus.meta_value ASC, " . $posts_clauses['orderby'];
$posts_clauses['where'] = " AND istockstatus.meta_key = '_stock_status' AND istockstatus.meta_value <> '' " . $posts_clauses['where'];
}
return $posts_clauses;
}
/* change custom background */
public function change_custom_background_cb() {
$background = get_background_image();
$color = get_background_color();
$head_txt_color = get_header_textcolor();
if ( ! $background && ! $color )
return;
$style = $color ? "background-color: #$color !important;" : '';
if ( $background ) {
$image = " background-image: url('$background') !important;";
$repeat = get_theme_mod( 'background_repeat', 'repeat' );
if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) )
$repeat = 'repeat';
$repeat = " background-repeat: $repeat !important;";
$position = get_theme_mod( 'background_position_x', 'left' );
if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) )
$position = 'left';
$position = " background-position: top $position !important;";
$attachment = get_theme_mod( 'background_attachment', 'scroll' );
if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) )
$attachment = 'scroll';
$attachment = " background-attachment: $attachment !important;";
$style .= $image . $repeat . $position . $attachment;
}
?>
max_num_pages > 1 ) {
$args = wp_parse_args( $args, array(
'mid_size' => 1,
'prev_text' => esc_html__( 'Previous', 'free-template' ),
'next_text' => esc_html__( 'Next', 'free-template' ),
) );
// Make sure we get a string back. Plain is the next best thing.
if ( isset( $args['type'] ) && 'array' == $args['type'] ) {
$args['type'] = 'plain';
}
// Set up paginated links.
$links = paginate_links( $args );
if ( $links ) {
$navigation = _navigation_markup( $links, 'posts-pagination', '' );
}
}
$navigation = str_replace("ul class='" , "ul class='pagination ", $navigation);
$navigation = str_replace("
',
esc_html__('Edit ', 'free-template') . get_the_title(),
get_the_title()
),
'',
''
);
return false;
}
// Prints HTML with meta information for the current post-date/time and author.
public static function posted_on() {
$time_string = '';
$time_string = sprintf( $time_string,
get_the_date( DATE_W3C ),
get_the_date()
);
// Finally, let's write all of this to the page.
?>
%2$s';
$time_string = sprintf( $time_string,
get_the_modified_date( DATE_W3C ),
get_the_modified_date()
);
// Finally, let's write all of this to the page.
?>
/i', $post->post_content, $matches);
$image_url = (isset($matches [1][0]))? $matches [1][0] : get_template_directory_uri() . "/assets/images/content-image.png";
}
return esc_url($image_url);
}
}
new Dedidata_Template;