Skip to content

Instantly share code, notes, and snippets.

View bkaminski's full-sized avatar
🍺
IPA Time

Ben Kaminski bkaminski

🍺
IPA Time
View GitHub Profile
@bkaminski
bkaminski / toggle-fontawesome-on-click-jquery.js
Created February 4, 2017 00:06
Toggle FontAwesome icons on-click, toggles back to original state on second click
//TOGGLE FONT AWESOME ON CLICK
$('.example-class').click(function(){
var collapsed=$(this).find('i').hasClass('font-awesome-icon-1');
$('.example-class').find('i').removeClass('font-awesome-icon-2');
$('.example-class').find('i').addClass('font-awesome-icon-1');
if(collapsed)
$(this).find('i').toggleClass('font-awesome-icon-1 font-awesome-icon-2')
});
@bkaminski
bkaminski / wp-turn-off-emoji.php
Created February 4, 2017 00:09
Add to WordPress functions.php, removes bloaty code related to Emoji's from WordPress Theme
//PLACE THIS CODE WITHIN YOUR FUNCTIONS.PHP FILE
// REMOVE WP EMOJI
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@bkaminski
bkaminski / bs4-image-fluid-class-auto-wp.php
Created February 4, 2017 00:17
Automatically add the Bootstrap 4 "img-fluid" class to any uploaded image through the WordPress dashboard. Add to "functions.php"
<?php
//Wordpress Fluid Images Bootstrap 4.0.0-alpha.4
function bootstrap_fluid_images( $html ){
$classes = 'img-fluid'; // Bootstrap 4.0.0-alpha.4
// check if there are already classes assigned to the anchor
if ( preg_match('/<img.*? class="/', $html) ) {
$html = preg_replace('/(<img.*? class=".*?)(".*?\/>)/', '$1 ' . $classes . ' $2', $html);
} else {
$html = preg_replace('/(<img.*?)(\/>)/', '$1 class="' . $classes . '" $2', $html);
@bkaminski
bkaminski / bootstrap-a4v6-vertical-carousel.css
Last active March 20, 2017 18:42
Bootstrap 4 Alpha 6 Vertical Carousel
//The correct way to call an include file from within a custom template
<?php include get_template_directory() . '/inc/example_inc.php'; ?>
@bkaminski
bkaminski / random-data-interval.php
Last active March 25, 2017 22:12
Using php 'rand' and or WordPress to create random "data-interval" string to be inserted in Bootstrap 4 Carousel values across a WordPress loop.
<div id="post-<?php the_ID(); ?>" class="carousel slide" data-ride="carousel" data-interval="<?php echo rand(4500, 6000); ?>">
<div class="carousel-inner" role="listbox">
<div class="carousel-item active">
<img class="d-block img-fluid" src="..." alt="First slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="..." alt="Second slide">
</div>
<div class="carousel-item">
<img class="d-block img-fluid" src="..." alt="Third slide">
@bkaminski
bkaminski / bootstrap3-carousel.html
Created August 6, 2017 16:42
Basic Bootstrap 3 Modal
@bkaminski
bkaminski / sample-customizer-section01.php
Last active September 29, 2017 02:56
Bootstrap Carousel WP Theme Customizer Create Section
// ADD IMAGE, TEXT, and URL (Heading, Subtext, Link) TO FIRST IMAGE IN SEQUENCE -- WP THEME CUSTOMIZER
function theme_slug_home_img_slide_1( $wp_customize ) {
$wp_customize->add_section(
'home_slide_img_one',
array(
'title' => 'Home Image Slide 1',
'description' => 'This section updates all information pertaining to the first image in the slideshow on the home page',
'priority' => 1,
));
@bkaminski
bkaminski / sample-customizer-section02.php
Last active September 29, 2017 02:57
Bootstrap Carousel WordPress Theme Customizer (Upload Image)
$wp_customize->add_setting( 'theme_slug_slide_img_upload_one' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize,'theme_slug_slide_img_upload_one', array(
'label' => __( 'Upload image for first slide in sequence:', 'theme_slug' ),
'section' => 'home_slide_img_one',
'settings' => 'theme_slug_slide_img_upload_one',
'description' => 'Upload your first slider image here.'
)));
@bkaminski
bkaminski / sample-customizer-section03.php
Last active September 29, 2017 02:57
H1 Text inside Bootstrap 3 Carousel WP Theme Customizer Func
$wp_customize->add_setting( 'theme_slug_slide_title_1', array(
'default' => 'No Title Text Has Been Entered',
'sanitize_callback' => 'sanitize_headline_one_text',
));
function sanitize_headline_one_text( $input ) {
return wp_kses_post( force_balance_tags( $input ) );
}
$wp_customize->add_control( 'theme_slug_slide_title_1', array(
'type' => 'text',
'label' => __( 'Heading Text Here:', 'theme_slug' ),