Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../themes/herald/core
File: mega-menu.php
<?php
[0] Fix | Delete
[1] Fix | Delete
add_action( 'init', 'herald_add_mega_menu_support' );
[2] Fix | Delete
[3] Fix | Delete
/* Add support for our built in mega menu system */
[4] Fix | Delete
if ( !function_exists( 'herald_add_mega_menu_support' ) ):
[5] Fix | Delete
function herald_add_mega_menu_support() {
[6] Fix | Delete
[7] Fix | Delete
if ( herald_get_option( 'mega_menu' ) ) {
[8] Fix | Delete
add_filter( 'wp_edit_nav_menu_walker', 'herald_edit_menu_walker', 10, 2 );
[9] Fix | Delete
add_filter( 'wp_setup_nav_menu_item', 'herald_add_custom_nav_fields' );
[10] Fix | Delete
add_action( 'wp_update_nav_menu_item', 'herald_update_custom_nav_fields', 10, 3 );
[11] Fix | Delete
add_filter( 'nav_menu_css_class', 'herald_add_class_to_menu', 10, 2 );
[12] Fix | Delete
}
[13] Fix | Delete
}
[14] Fix | Delete
endif;
[15] Fix | Delete
[16] Fix | Delete
/* Add custom fields to menu */
[17] Fix | Delete
if ( !function_exists( 'herald_add_custom_nav_fields' ) ):
[18] Fix | Delete
function herald_add_custom_nav_fields( $menu_item ) {
[19] Fix | Delete
$menu_item->mega_menu_cat = get_post_meta( $menu_item->ID, '_herald_mega_menu_cat', true ) ? 1 : 0;
[20] Fix | Delete
$menu_item->mega_menu = get_post_meta( $menu_item->ID, '_herald_mega_menu', true ) ? 1 : 0;
[21] Fix | Delete
return $menu_item;
[22] Fix | Delete
}
[23] Fix | Delete
endif;
[24] Fix | Delete
[25] Fix | Delete
[26] Fix | Delete
/* Save custom fiedls to menu */
[27] Fix | Delete
if ( !function_exists( 'herald_update_custom_nav_fields' ) ):
[28] Fix | Delete
function herald_update_custom_nav_fields( $menu_id, $menu_item_db_id, $args ) {
[29] Fix | Delete
[30] Fix | Delete
if ( $args['menu-item-object'] == 'category' ) {
[31] Fix | Delete
$value = isset( $_REQUEST['menu-item-mega-menu-cat'][$menu_item_db_id] ) ? 1 : 0;
[32] Fix | Delete
update_post_meta( $menu_item_db_id, '_herald_mega_menu_cat', $value );
[33] Fix | Delete
} else {
[34] Fix | Delete
$value = isset( $_REQUEST['menu-item-mega-menu'][$menu_item_db_id] ) ? 1 : 0;
[35] Fix | Delete
update_post_meta( $menu_item_db_id, '_herald_mega_menu', $value );
[36] Fix | Delete
}
[37] Fix | Delete
}
[38] Fix | Delete
endif;
[39] Fix | Delete
[40] Fix | Delete
[41] Fix | Delete
/* Display our fields in admin */
[42] Fix | Delete
if ( !function_exists( 'herald_edit_menu_walker' ) ):
[43] Fix | Delete
function herald_edit_menu_walker( $walker, $menu_id ) {
[44] Fix | Delete
[45] Fix | Delete
class herald_Walker_Nav_Menu_Edit extends Walker_Nav_Menu_Edit {
[46] Fix | Delete
[47] Fix | Delete
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
[48] Fix | Delete
$temp_output = '';
[49] Fix | Delete
$mega_menu_html = '';
[50] Fix | Delete
[51] Fix | Delete
if($depth == 0 ){
[52] Fix | Delete
if ( $item->object == 'category' ) {
[53] Fix | Delete
$mega_menu_html .= '<p class="field-custom description description-wide">
[54] Fix | Delete
<label for="edit-menu-item-mega-'.$item->db_id.'">
[55] Fix | Delete
<input type="checkbox" id="edit-menu-item-mega-'.$item->db_id.'" class="widefat code edit-menu-item-custom" name="menu-item-mega-menu-cat['.$item->db_id.']" value="1" '.checked( $item->mega_menu_cat, 1, false ). ' />
[56] Fix | Delete
'.esc_html__( 'Mega Menu (display posts from category)', 'herald' ).'</label>
[57] Fix | Delete
</p>';
[58] Fix | Delete
} else {
[59] Fix | Delete
$mega_menu_html .= '<p class="field-custom description description-wide">
[60] Fix | Delete
<label for="edit-menu-item-mega-'.$item->db_id.'">
[61] Fix | Delete
<input type="checkbox" id="edit-menu-item-mega-'.$item->db_id.'" class="widefat code edit-menu-item-custom" name="menu-item-mega-menu['.$item->db_id.']" value="1" '.checked( $item->mega_menu, 1, false ). ' />
[62] Fix | Delete
'.esc_html__( 'Mega Menu (classic)', 'herald' ).'
[63] Fix | Delete
</label></p>';
[64] Fix | Delete
}
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
parent::start_el( $temp_output, $item, $depth, $args, $id );
[68] Fix | Delete
[69] Fix | Delete
$temp_output = preg_replace( '/(?=<div.*submitbox)/', $mega_menu_html, $temp_output );
[70] Fix | Delete
[71] Fix | Delete
$output .= $temp_output;
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
return 'herald_Walker_Nav_Menu_Edit';
[77] Fix | Delete
}
[78] Fix | Delete
endif;
[79] Fix | Delete
[80] Fix | Delete
[81] Fix | Delete
/* Add class to menu item when mega menu is detected */
[82] Fix | Delete
if ( !function_exists( 'herald_add_class_to_menu' ) ):
[83] Fix | Delete
function herald_add_class_to_menu( $classes, $item ) {
[84] Fix | Delete
[85] Fix | Delete
if ( $item->object == 'category' && !$item->menu_item_parent && isset( $item->mega_menu_cat ) && $item->mega_menu_cat ) {
[86] Fix | Delete
$classes[] = 'herald-mega-menu';
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
if ( !$item->menu_item_parent && isset( $item->mega_menu ) && $item->mega_menu ) {
[90] Fix | Delete
$classes[] = 'herald-mega-menu';
[91] Fix | Delete
$classes[] = 'herald-mega-menu-classic';
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
return $classes;
[95] Fix | Delete
[96] Fix | Delete
}
[97] Fix | Delete
endif;
[98] Fix | Delete
[99] Fix | Delete
/* Output category mega menu */
[100] Fix | Delete
if ( !function_exists( 'herald_load_mega_menu' ) ) :
[101] Fix | Delete
[102] Fix | Delete
function herald_load_mega_menu( $cat_id ) {
[103] Fix | Delete
[104] Fix | Delete
global $wp_query;
[105] Fix | Delete
[106] Fix | Delete
$output = '';
[107] Fix | Delete
$ppp = herald_get_option('mega_menu_limit');
[108] Fix | Delete
$sub_cat_nav = herald_get_option('mega_menu_sub_cat');
[109] Fix | Delete
$layout = herald_get_option('mega_menu_layout');
[110] Fix | Delete
$sub_cats = array();
[111] Fix | Delete
[112] Fix | Delete
if ( $sub_cat_nav ) {
[113] Fix | Delete
$sub_cats = get_categories( array( 'parent' => $cat_id, 'hide_empty' => false ) );
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
$has_sub_cats = $sub_cat_nav && !empty($sub_cats) ? true : false;
[117] Fix | Delete
[118] Fix | Delete
$section_class = $has_sub_cats ? '' : 'herald-no-sid';
[119] Fix | Delete
$wrap_class = $has_sub_cats ? 'col-lg-9' : 'col-lg-12';
[120] Fix | Delete
[121] Fix | Delete
//html start
[122] Fix | Delete
$output .= '<li class="container herald-section '.$section_class.'"><div class="row">';
[123] Fix | Delete
[124] Fix | Delete
[125] Fix | Delete
//sub cats
[126] Fix | Delete
if( $has_sub_cats ){
[127] Fix | Delete
[128] Fix | Delete
$output .= '<div class="col-lg-3 herald-mega-menu-sub-cats"><ul>';
[129] Fix | Delete
[130] Fix | Delete
foreach ( $sub_cats as $cat ) {
[131] Fix | Delete
$cat_link = get_category_link( $cat );
[132] Fix | Delete
$output .= '<li><a href="'.esc_url( $cat_link ).'">'.$cat->name.'</a></li>';
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
$output .= '</ul></div>';
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
//posts
[139] Fix | Delete
$output .= '<div class="herald-module '.$wrap_class.'"><div class="row row-eq-height">';
[140] Fix | Delete
[141] Fix | Delete
if( $has_sub_cats ){
[142] Fix | Delete
herald_set_img_flag('sid');
[143] Fix | Delete
} else {
[144] Fix | Delete
herald_set_img_flag('full');
[145] Fix | Delete
}
[146] Fix | Delete
[147] Fix | Delete
$args = array(
[148] Fix | Delete
'post_type' => 'post',
[149] Fix | Delete
'cat' => $cat_id,
[150] Fix | Delete
'posts_per_page' => $ppp
[151] Fix | Delete
);
[152] Fix | Delete
[153] Fix | Delete
$wp_query = new WP_Query( $args );
[154] Fix | Delete
[155] Fix | Delete
ob_start();
[156] Fix | Delete
[157] Fix | Delete
if ( have_posts() ) :
[158] Fix | Delete
[159] Fix | Delete
while ( have_posts() ) : the_post();
[160] Fix | Delete
get_template_part( 'template-parts/layouts/content-'.$layout );
[161] Fix | Delete
endwhile;
[162] Fix | Delete
[163] Fix | Delete
endif;
[164] Fix | Delete
[165] Fix | Delete
wp_reset_query();
[166] Fix | Delete
[167] Fix | Delete
herald_set_img_flag('');
[168] Fix | Delete
[169] Fix | Delete
$output .= ob_get_clean();
[170] Fix | Delete
[171] Fix | Delete
$output .= '</div></div>';
[172] Fix | Delete
$output .= '</div></li>';
[173] Fix | Delete
[174] Fix | Delete
return $output;
[175] Fix | Delete
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
endif;
[179] Fix | Delete
[180] Fix | Delete
/* Mega menu walker */
[181] Fix | Delete
class herald_Menu_Walker extends Walker_Nav_menu
[182] Fix | Delete
{
[183] Fix | Delete
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
[184] Fix | Delete
[185] Fix | Delete
if ( herald_get_option( 'mega_menu' ) ) {
[186] Fix | Delete
[187] Fix | Delete
if ( $depth == 0 && ( $item->mega_menu_cat ) ) {
[188] Fix | Delete
[189] Fix | Delete
$output .= '<ul class="sub-menu">';
[190] Fix | Delete
$output .= herald_load_mega_menu( $item->object_id );
[191] Fix | Delete
$output .= '</ul>';
[192] Fix | Delete
[193] Fix | Delete
}
[194] Fix | Delete
}
[195] Fix | Delete
}
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
?>
[199] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function