flush_rules(); } add_action('init', 'nc_no_category_base_permastruct'); function nc_no_category_base_permastruct() { global $wp_rewrite, $wp_version; if (version_compare($wp_version, '3.4', '<')) { // For pre-3.4 support $wp_rewrite -> extra_permastructs['category'][0] = '%category%'; } else { $wp_rewrite -> extra_permastructs['category']['struct'] = '%category%'; } } // Add our custom category rewrite rules add_filter('category_rewrite_rules', 'nc_no_category_base_rewrite_rules'); function nc_no_category_base_rewrite_rules($category_rewrite) { //var_dump($category_rewrite); // For Debugging $category_rewrite = array(); $categories = get_categories(array('hide_empty' => false)); foreach ($categories as $category) { $category_nicename = $category -> slug; if ($category -> parent == $category -> cat_ID)// recursive recursion $category -> parent = 0; elseif ($category -> parent != 0) $category_nicename = get_category_parents($category -> parent, false, '/', true) . $category_nicename; $category_rewrite['(' . $category_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]'; $category_rewrite['(' . $category_nicename . ')/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]'; $category_rewrite['(' . $category_nicename . ')/?$'] = 'index.php?category_name=$matches[1]'; } // Redirect support from Old Category Base global $wp_rewrite; $old_category_base = get_option('category_base') ? get_option('category_base') : 'category'; $old_category_base = trim($old_category_base, '/'); $category_rewrite[$old_category_base . '/(.*)$'] = 'index.php?category_redirect=$matches[1]'; return $category_rewrite; } // Add 'category_redirect' query variable add_filter('query_vars', 'nc_no_category_base_query_vars'); function nc_no_category_base_query_vars($public_query_vars) { $public_query_vars[] = 'category_redirect'; return $public_query_vars; } add_filter('request', 'nc_no_category_base_request'); function nc_no_category_base_request($query_vars) { if (isset($query_vars['category_redirect'])) { $catlink = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['category_redirect'], 'category'); status_header(301); header("Location: $catlink"); exit(); } return $query_vars; } endif; } if (!function_exists('nc_custom_head_code')): add_action('wp_head', 'nc_custom_head_code'); function nc_custom_head_code() { $nc_option = get_option('nc_option'); $site = $nc_option['site']; echo $site['custom_head_code']; } endif; if (!function_exists('nc_custom_footer_code')): add_action('wp_footer', 'nc_custom_footer_code'); function nc_custom_footer_code() { $nc_option = get_option('nc_option'); $site = $nc_option['site']; echo $site['custom_footer_code']; } endif; if( $usability['nc_highlight'] == 1 ){ function usability_highlight(){ if( is_single() || is_singular() ){ wp_register_script( 'ncHighlightJs', NC_OPTIMIZEUP_URL . 'assets/highlight/highlight.pack.js', array(), NC_OPTIMIZEUP_VERSION, true ); wp_register_style( 'ncHighlightCss', NC_OPTIMIZEUP_URL . 'assets/highlight/styles/a11y-dark.css', array(), NC_OPTIMIZEUP_VERSION, 'all' ); wp_enqueue_style('ncHighlightCss'); wp_enqueue_script('ncHighlightJs'); } } add_action( 'wp_enqueue_scripts', 'usability_highlight' ); } if( $usability['nc_highlight'] == 1 && is_admin() ){ function nicetheme_highlight_register_mce_button( $buttons ) { array_push( $buttons, 'nicetheme_highlight_button' ); return $buttons; } add_filter( 'mce_buttons', 'nicetheme_highlight_register_mce_button' ); function nicetheme_highlight_tinymce_plugin( $plugin_array ) { $plugin_array['nicetheme_highlight_button'] = NC_OPTIMIZEUP_URL .'assets/highlight/admin.js'; return $plugin_array; } add_filter( 'mce_external_plugins', 'nicetheme_highlight_tinymce_plugin' ); } if( $usability['nc_lightgallery'] == 1 && !is_admin() ){ function usability_lightgallery(){ if( is_single() || is_singular() ){ wp_register_style( 'ncLightgalleryCss', NC_OPTIMIZEUP_URL . 'assets/lightGallery/css/lightgallery.min.css', array(), NC_OPTIMIZEUP_VERSION, 'all' ); wp_register_script( 'ncPicturefill', NC_OPTIMIZEUP_URL . 'assets/lightGallery/lib/picturefill.min.js', array(), NC_OPTIMIZEUP_VERSION, true ); wp_register_script( 'ncLightgallery', NC_OPTIMIZEUP_URL . 'assets/lightGallery/js/lightgallery-all.min.js', array('jquery'), NC_OPTIMIZEUP_VERSION, true ); wp_register_script( 'ncMousewheel', NC_OPTIMIZEUP_URL . 'assets/lightGallery/lib/jquery.mousewheel.min.js', array('jquery'), NC_OPTIMIZEUP_VERSION, true ); wp_enqueue_style('ncLightgalleryCss'); wp_enqueue_script('ncPicturefill'); wp_enqueue_script('ncLightgallery'); wp_enqueue_script('ncMousewheel'); } } add_action( 'wp_enqueue_scripts', 'usability_lightgallery' ); function lightgallery_box( $content ){ return '