Skip to content

Instantly share code, notes, and snippets.

View yratof's full-sized avatar
🍊
Eating an orange

Andrew yratof

🍊
Eating an orange
View GitHub Profile
@yratof
yratof / 768.scss
Last active December 19, 2015 11:29
Multi-Level Navigation for Wordpress
nav.js {
li ul {
display: block;
}
.menu_button{
display: none;
}
.top-nav{
display: inline-block;
@yratof
yratof / functions.php
Created July 18, 2013 11:31
Function to add CURRENT_PAGE class to current page menu items
<?php
add_filter( 'nav_menu_css_class', 'add_parent_url_menu_class', 10, 2 );
function add_parent_url_menu_class( $classes = array(), $item = false ) {
// Get current URL
$current_url = current_url();
// Get homepage URL
$homepage_url = trailingslashit( get_bloginfo( 'url' ) );
@yratof
yratof / functions.php
Created July 24, 2013 14:11
Wordpress WooCommerce 360 Images as the featured image
// This will make a new function called "get_the_slug()" which will get the page
// slug, for example, of the page is ...com/blog/news/story-name-here, then this
// will echo 'story-name-here'. I'm using this in WooCommerce for the product
// 360 images, because I need to rename each set of images so they become
// unique, I needed a way of getting separating them. The only drawback here, is
// that you need to know the slug before you make the images, AND if you rename
// that page, the images will break. SO. It's something that is experimental,
// but if monitored right, shouldn't be a problem! &
function get_the_slug( $id=null ){
@yratof
yratof / base.scss
Last active June 6, 2019 07:15
Contact Form 7 - Removing the unwanted stuff, Making it look pretty, then reading the needed stuff
/*********************
Contact Form 7 Styles -
If you want to leave these colours as they are, then do so,
otherwise, wap grey and green for your brand colours in your MIXINS file
*********************/
$dark: rgb(50,50,50);
$green: rgb(0,200,100);
div.wpcf7 {
margin: 0;
@yratof
yratof / functions.php
Created August 9, 2013 09:19
Remove "update available" message from wordpress dashboard
// Remove UPDATE AVAILABLE messages from Wordpress
// Not all clients want to be notifified that their
// site is out of date straight away. This way, they
// are less likely to explore the link themselves
// and either A) Update the site perfectly fine
// or b) mess the whole site up beyond replair (database)
add_action('admin_menu','wphidenag');
function wphidenag() {
remove_action( 'admin_notices', 'update_nag', 3 );
@yratof
yratof / scripts.js
Last active November 9, 2016 13:12
Sticky header after X scroll
jQuery( function($) {
// This element will stick...
var $sticky = $( '#stick_me' );
// ...When you pass this point
var $trigger = $( '#turn_on_sticky' );
// If the element exists...
if ( $sticky.length > 0 ) {
// Get the top
@yratof
yratof / fixed.js
Created August 14, 2013 12:30
$ is not defined?
jQuery(document).ready(function ($) {
$.fn.scrollBottom = function() {
return $(document).height() - this.scrollTop() - this.height();
};
jQuery(window).scroll(function ($) {
var offset = $('#main').offset(); //<--- Top of the element where the scroll should start
var docViewTop = $(window).scrollTop();//<--- Top of the window
var docViewBottom = docViewTop + $(window).height(); //<--- Bottom of the window
var elemTop = $('#footer').offset().top; // <-- This is the top of the element that we are testing if it has come into view
@yratof
yratof / scripts.js
Last active December 21, 2015 06:59
Smooth scrolling & snapping headers
//This makes all links that start with # scrolling links
$('a[href^="#"]').on('click',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top - 100
}, 900, 'swing', function () {
window.location.hash = target - 100;
});
@yratof
yratof / functions.php
Last active December 21, 2015 12:28
Wordpress 3.6 Searchform.php isn't seen anymore. Add this to your functions.
// Wordpress 3.6 seems to have messed up the searchform
// Credit: http://salferrarello.com/searchform-php-wordpress-3-6-broken/
function search_form_no_filters() {
// look for local searchform template
$search_form_template = locate_template( 'searchform.php' );
if ( '' !== $search_form_template ) {
// searchform.php exists, remove all filters
remove_all_filters('get_search_form');
}
}
@yratof
yratof / content-product.php
Last active December 21, 2015 14:09
Get content from product page, put it on normal page.
<script>
jQuery(document).ready(function($) {
$('.shit-<?php the_ID(); ?>').click(function(){
$.get("<?php echo get_permalink( $post->ID ); ?>", function(data){
$('.iframeArea').empty();
$('#product-<?php the_ID(); ?>', data).appendTo('.iframeArea');
});
});
});
</script>