<?php
global $mf_options;
function mf_main_menu() {
        $menu = wp_nav_menu(
        array(
        'theme_location' => 'main-menu',
        'echo' => 0,
        'menu_class' => 'menu nav-top',

        'link_before'    => '<span class="admi"></span><span class="txt">',
        'link_after'     => '</span><i class="right di fa fa-angle-right"></i><i class="down di fa fa-angle-down"></i>',
        'container' => 'div',
        'container_class' => 'header-menu desk-menu nz-clearfix',
        'walker' => new nz_scm_walker,
        'fallback_cb' => '')
        );
        $menu = str_replace("\n", "", $menu);
        $menu = str_replace("\r", "", $menu);
        echo $menu;
        }

function mf_mobile_menu() {
        $menu = wp_nav_menu(
        array(
        'theme_location' => 'main-menu',
        'echo' => 0,
        'menu_class' => 'menu',
        'menu_id'        => 'mob-header-menu',
        'link_before'    => '<span class="admi"></span><span class="txt">',
        'link_after'     => '</span><i class="di fa fa-angle-down"></i>',
        'container' => 'nav',
        'container_class' => 'mob-menu nz-clearfix',
        'walker' => new ad_mobile_walker,
        'fallback_cb' => '')
        );
        $menu = str_replace("\n", "", $menu);
        $menu = str_replace("\r", "", $menu);
        echo $menu;
        }


 function mf_top_menu() {
        $menu = wp_nav_menu(
        array(
        'theme_location' => 'top-menu',
        'echo' => 0,
        'menu_class' => 'list-inline',
        'walker' => new mf_Sublevel_Walker,
        'fallback_cb' => '')
        );
        $menu = str_replace("\n", "", $menu);
        $menu = str_replace("\r", "", $menu);
        echo $menu;
        }

function mf_footer_menu() {
$menu = wp_nav_menu(
array(
'theme_location' => 'footer-menu',
'echo' => 0,
'menu_class' => 'list-inline footer-nav',
'container_id' => '',
'fallback_cb' => '')
);
$menu = str_replace("\n", "", $menu);
$menu = str_replace("\r", "", $menu);
echo $menu;
}

function mf_left_menu() {
        $menu = wp_nav_menu(
        array(
        'theme_location' => 'left-menu',
        'echo' => 0,
        'menu_class' => 'menu',
        'menu_id'        => 'mob-header-menu',
        'link_before'    => '<span class="admi"></span><span class="txt">',
        'link_after'     => '</span><i class="di fa fa-angle-down"></i>',
        'container' => 'nav',
        'container_class' => 'mob-menu nz-clearfix',
        'walker' => new ad_mobile_walker,
        'fallback_cb' => '')
        );
        $menu = str_replace("\n", "", $menu);
        $menu = str_replace("\r", "", $menu);
        echo $menu;
        }


function mf_comments( $comment, $args, $depth ) {
    $GLOBALS['comment'] = $comment;
    switch( $comment->comment_type ) :
        case 'pingback' :
        case 'trackback' : ?>
            <li <?php comment_class(); ?> id="comment<?php comment_ID(); ?>">
            <div class="back-link"><?php comment_author_link(); ?></div>
            </li>
        <?php break;
        default : ?>
            <li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
                <div <?php comment_class('box'); ?>>
          <div class="img-box">
            <?php echo get_avatar( $comment, $args['avatar_size'] ); ?>
            <?php
                            comment_reply_link( array_merge( $args, array(
                                'reply_text' => '<i class="fa fa-reply"></i> <span class="txt-over">'.esc_html__('Reply','mf').'</span>',
                                'before' => '',
                                'depth' => $depth,
                            ) ) ); ?>
          </div>
          <div class="hoder">
            <strong class="title"><?php comment_author(); ?></strong>
            <time datetime="<?php comment_time( 'c' ); ?>"><?php comment_date(); echo ' '.esc_html__('at','mf').' '; comment_time(); ?></time>
            <?php comment_text(); ?>
          </div>

                </div>
            </li>
        <?php // End the default styling of comment
        break;
    endswitch;
}


// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] );    // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] );     // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] );    // Remove the smallscreen optimisation
return $enqueue_styles;
}
// Or just remove them all in one line
add_filter( 'woocommerce_enqueue_styles', '__return_false' );

function tp_remove_metabox_from_page_types() {
if( is_admin() && current_user_can('manage_options') ) {
$args = array(
'public'   => true,
'name'     => 'page',
);
$output = 'names'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
$post_types = get_post_types( $args, $output, $operator ); 
foreach ( $post_types  as $post_type ) {
remove_meta_box('eg-meta-box', $post_type, 'normal');
remove_meta_box('mymetabox_revslider_0', $post_type, 'normal');
}
}
}
add_action('add_meta_boxes', 'tp_remove_metabox_from_page_types', 999);
function tp_remove_metabox_from_post_types() {
if( is_admin() && current_user_can('manage_options') ) {
$args = array(
'public'   => true,
'name'     => 'post',
);
$output = 'names'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
$post_types = get_post_types( $args, $output, $operator ); 
foreach ( $post_types  as $post_type ) {
remove_meta_box('eg-meta-box', $post_type, 'normal');
remove_meta_box('mymetabox_revslider_0', $post_type, 'normal');
}
}
}
add_action('add_meta_boxes', 'tp_remove_metabox_from_post_types', 999);

function mf_global_variables(){
        global $mf_options, $woocommerce, $post, $product,$wp_query, $query_string;
    }
function mf_substring(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 200);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
return $excerpt;
}


// One Click Demo Import
function ocdi_import_files() {
  return array(
    array(
      'import_file_name'             => 'Demo Import 1',
      'categories'                   => array( 'Category 1', 'Category 2' ),
      'local_import_file'            => trailingslashit( get_template_directory() ) . 'assets/demo-data/demo-content.xml',
      'local_import_widget_file'     => trailingslashit( get_template_directory() ) . 'assets/demo-data/widgets.json',
      'import_preview_image_url'     => 'https://www.mfdsgn.com/mf/wp-content/uploads/2016/12/business1.jpg',
      'import_notice'                => __( 'Read First Requirements at wp-admin >> MF Options >> Start Here section.<br>After you import this demo, you will have to setup the slider separately. Sliders are located at mf-all-files > Demo Data > slider-revolution folder.', 'mf' ),
      'preview_url'                  => 'https://www.mfdsgn.com/mf/home/business-1/',
    ),

  );
}
add_filter( 'pt-ocdi/import_files', 'ocdi_import_files' );



function ocdi_after_import_setup() {
	// Assign menus to their locations.
	$main_menu = get_term_by( 'name', 'Main', 'nav_menu' );
	$top_menu = get_term_by( 'name', 'Top', 'nav_menu' );	
	$left_menu = get_term_by( 'name', 'Left', 'nav_menu' );	
	$footer_menu = get_term_by( 'name', 'Footer', 'nav_menu' );	

	set_theme_mod( 'nav_menu_locations', array(
			'main-menu' => $main_menu->term_id,
			'top-menu' => $top_menu->term_id,
			'left-menu' => $left_menu->term_id,
			'footer-menu' => $footer_menu->term_id,
		)
	);

	// Assign front page and posts page (blog page).
	$front_page_id = get_page_by_title( 'Business 1' );
	//$blog_page_id  = get_page_by_title( 'Blog' );

	update_option( 'show_on_front', 'page' );
	update_option( 'page_on_front', $front_page_id->ID );
	//update_option( 'page_for_posts', $blog_page_id->ID );

}


add_action( 'pt-ocdi/after_import', 'ocdi_after_import_setup' );

add_filter( 'pt-ocdi/disable_pt_branding', '__return_true' );


//Social Media
function mf_social_media() {
global $mf_options;
$facebook = $mf_options['soc_face'];
$twitter = $mf_options['soc_twitter'];
$google = $mf_options['soc_goplus'];
$instagram = $mf_options['soc_instagram'];
$linkedin = $mf_options['soc_linkedin'];
$pinterest = $mf_options['soc_pinterest'];
$youtube= $mf_options['soc_youtube'];
$xing= $mf_options['soc_xing'];
$android= $mf_options['soc_android'];
$apple= $mf_options['soc_apple'];
$vimeo= $mf_options['soc_vimeo'];
$flickr= $mf_options['soc_flickr'];
$yelp= $mf_options['soc_yelp'];
$telegram= $mf_options['soc_telegram'];
$medium= $mf_options['soc_medium'];
$reddit= $mf_options['soc_reddit'];
$github= $mf_options['soc_github'];
$bitcointalk= $mf_options['soc_bitcointalk'];
$wechat= $mf_options['soc_wechat'];
$soundcloud= $mf_options['soc_soundcloud'];

if ($facebook != '') { ?>
<li><a href="<?php echo esc_url($facebook); ?>" target="_blank">
  <i class="fa fa-facebook">
  </i>
</a></li>
<?php }else {};?>
<?php if ($twitter != '') { ?>
<li><a href="<?php echo esc_url($twitter); ?>" target="_blank">
  <i class="fa fa-twitter">
  </i>
</a></li>
<?php }else {};?>
<?php if ($google != '') { ?>
<li><a href="<?php echo esc_url($google); ?>" target="_blank">
  <i class="fa fa-google-plus">
  </i>
</a></li>
<?php }else {};?>
<?php if ($instagram != '') { ?>
<li><a href="<?php echo esc_url($instagram); ?>" target="_blank">
  <i class="fa fa-instagram">
  </i>
</a></li>
<?php }else {};?>
<?php if ($linkedin != '') { ?>
<li><a href="<?php echo esc_url($linkedin); ?>" target="_blank">
  <i class="fa fa-linkedin">
  </i>
</a></li>
<?php }else {};?>
<?php if ($pinterest != '') { ?>
<li><a href="<?php echo esc_url($pinterest); ?>" target="_blank">
  <i class="fa fa-pinterest">
  </i>
</a></li>
<?php }else {};?>
<?php if ($youtube != '') { ?>
<li><a href="<?php echo esc_url($youtube); ?>" target="_blank">
  <i class="fa fa-youtube">
  </i>
</a></li>
<?php }else {};?>
<?php if ($xing != '') { ?>
<li><a href="<?php echo esc_url($xing); ?>" target="_blank">
  <i class="fa fa-xing">
  </i>
</a></li>
<?php }else {};?>
<?php if ($android != '') { ?>
<li><a href="<?php echo esc_url($android); ?>" target="_blank">
  <i class="fa fa-android">
  </i>
</a></li>
<?php }else {};?>
<?php if ($apple != '') { ?>
<li><a href="<?php echo esc_url($apple); ?>" target="_blank">
  <i class="fa fa-apple">
  </i>
</a></li>
<?php }else {};?>
<?php if ($vimeo != '') { ?>
<li><a href="<?php echo esc_url($vimeo); ?>" target="_blank">
  <i class="fa fa-vimeo-square">
  </i>
</a></li>
<?php }else {};?>
<?php if ($yelp != '') { ?>
<li><a href="<?php echo esc_url($yelp); ?>" target="_blank">
  <i class="fa fa-yelp">
  </i>
</a></li>
<?php }else {};?>
<?php if ($flickr != '') { ?>
<li><a href="<?php echo esc_url($flickr); ?>" target="_blank">
  <i class="fa fa-flickr">
  </i>
</a></li>
<?php }else {};?>
<?php if ($telegram != '') { ?>
<li><a href="<?php echo esc_url($telegram); ?>" target="_blank">
  <i class="fa fa-telegram">
  </i>
</a></li>
<?php }else {};?>
<?php if ($medium != '') { ?>
<li><a href="<?php echo esc_url($medium); ?>" target="_blank">
  <i class="fa fa-medium">
  </i>
</a></li>
<?php }else {};?>
<?php if ($reddit != '') { ?>
<li><a href="<?php echo esc_url($reddit); ?>" target="_blank">
  <i class="fa fa-reddit">
  </i>
</a></li>
<?php }else {};?>
<?php if ($github != '') { ?>
<li><a href="<?php echo esc_url($github); ?>" target="_blank">
  <i class="fa fa-github">
  </i>
</a></li>
<?php }else {};?>
<?php if ($bitcointalk != '') { ?>
<li><a href="<?php echo esc_url($bitcointalk); ?>" target="_blank">
  <i class="fa fa-btc">
  </i>
</a></li>
<?php }else {};?>
<?php if ($wechat != '') { ?>
<li><a href="<?php echo esc_url($wechat); ?>" target="_blank">
  <i class="fa fa-weixin">
  </i>
</a></li>
<?php }else {};?>
<?php if ($soundcloud != '') { ?>
<li><a href="<?php echo esc_url($soundcloud); ?>" target="_blank">
  <i class="fa fa-soundcloud">
  </i>
</a></li>
<?php }else {};?>
<?php } ?>