Skip to content

Instantly share code, notes, and snippets.

View briankompanee's full-sized avatar
🎯
Focusing

Brian Brown briankompanee

🎯
Focusing
View GitHub Profile
@briankompanee
briankompanee / resize-carousel-banner-to-window.js
Last active August 8, 2016 14:20
Javascript: Make Bootstrap Carousel or Hero Banner height the same as open window.
@briankompanee
briankompanee / bootstrap-dopdowns-linked-hover.js
Created July 18, 2016 23:29
JavaScript: Allow bootstrap menu items to be linked and show on hover.
// Allow bootstrap menu items to be linked and show on hover.
$('#primary-navigation .dropdown-toggle').click(function() {
var location = $(this).attr('href');
window.location.href = location;
return false;
});
//Add Fade Amination on Hover
$('#primary-navigation ul.nav li.dropdown').hover(function() {
$(this).find('.dropdown-menu').stop(true, true).delay(50).fadeIn(200);
}, function() {
@briankompanee
briankompanee / wp-shortcode-loggedin-loggedout.php
Created July 15, 2016 22:57
WordPress: Add a shortcode to use in the content that shows content to non-logged in users. If user is logged in then they will not see the content.
<?php
/**
* Add A Shortcode allowing content for non-logged in users.
* Add to functions.php
* This could used in a situation where you have gated content and the user needs to be logged in to view.
* An example of usage is: [not_logged_in]You must be logged in to view this content[/not_logged_in]
*/
function check_user ($params, $content = null){
//if the user is not logged in. You can remove the ! if you want to change the statement to is logged in.
@briankompanee
briankompanee / wp-search-query-custom-per-page.php
Last active July 15, 2016 18:38
WordPress: Change default search query to return custom number of posts per page.
<?php
/**
* Change the search page to return 25 posts per page in results.
* Add to functions.php
*/
add_filter('post_limits', 'search_postsperpage');
function search_postsperpage($limits) {
if (is_search()) {
global $wp_query;
@briankompanee
briankompanee / wp-solidworks-file-media-library.php
Created July 15, 2016 18:27
WordPress: Add support for SOLIDWORKS (.sldprt) file type to be uploaded in Media Library
<?php
/**
* Add support for SOLIDWORKS (.sldprt) file type to be uploaded in Media Library
* Add to functions.php
*/
function solidworks_mime_types($mime_types){
$mime_types['sldprt'] = 'application/octet-stream'; //Adding svg extension
return $mime_types;
}
@briankompanee
briankompanee / wp-slug-class-to-menu.php
Last active July 15, 2016 18:39
WordPress: Add the page or post slug as a class to a menu item.
<?php
/**
* Add the page or post slug as a class to a menu item.
* Add to functions.php
*/
function add_slug_class_to_menu_item($output){
$ps = get_option('permalink_structure');if(!empty($ps)){
$idstr = preg_match_all('/<li id="menu-item-(\d+)/', $output, $matches);
foreach($matches[1] as $mid){
@briankompanee
briankompanee / custom-wp-login-register-url.php
Last active July 15, 2016 18:40
WordPress: Customize URL for default registration on wp-login page.
<?php
/**
* Customize URL for default registration on wp-login page.
* Add to functions.php
**/
function wp_kompanee_register_url($link){
//Change wp-login registration url
return str_replace(site_url('wp-login.php?action=register', 'login'),site_url('register', 'login'),$link);
}
@briankompanee
briankompanee / customize-wp-login.php
Last active August 2, 2016 06:15
WordPress: Customize the standard wp-login Page. Overrides for stylesheet, logo, and links included.
<?php
/**
* Customize the standard WordPress Login page.
* Add to functions.php
*/
//Link to custom style sheet to override default.
function my_login_stylesheet() {
wp_enqueue_style( 'custom-login', get_template_directory_uri() . '/dist/styles/main.css' );
}
@briankompanee
briankompanee / sage-google-fonts-config.php
Last active January 7, 2024 14:28
WordPress: Add Google Font support to the Sage theme for roots.io
<?php
/**
* Add your Google Fonts here.
* This is specifically for the theme Sage from roots.io and goes in config.php
* Change the font name, weights and styles to what you are using as needed.
*/
define('GOOGLE_FONTS', 'Oswald:400,300,700:latin');
@briankompanee
briankompanee / login-logout.php
Last active July 15, 2016 17:56
WordPress: Add a login/logout link to any existing menu location.
<?php
/**
* Add login/logout link to naviagation menu
* Typically this will go in functions.php.
*/
function add_login_out_item_to_menu( $items, $args ){
//change the theme_location menu name to match the location in your theme.
if( is_admin() || $args->theme_location != 'primary_navigation' )