Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@oliwa
oliwa / snippet.php
Created November 19, 2015 10:03
Environment Conditional
<!-- Environment -->
<?php if ($_SERVER['SERVER_ADDR']=="192.168.100.10"){ ?>
<!-- local, do something... -->
<?php } else { ?>
<!-- online, do something else... -->
<?php } ?>
@oliwa
oliwa / snippet.php
Created November 19, 2015 10:04
Conditionals
<?php if(is_page('xy')) { ?>
// do something on the xy page
<?php } ?>
<?php if(!is_page('xy')) { ?>
// do something on every but the yx page
<?php } ?>
<?php if(is_page('xy') || is_page('xyz') ) { ?>
// do something on the xy and xyz page
@oliwa
oliwa / multisite.php
Created November 19, 2015 10:04
WP Multisite Blog Conditional
<?php global $blog_id; ?>
<?php if( $blog_id == '1' /* Blog 1 */) { ?>
<p>Blog 1</p>
<?php } else if( $blog_id == '2' /* Blog 2 */) { ?>
<p>Blog 2</p>
<?php } else if( $blog_id == '3' /* Blog 3 */) { ?>
<p>Blog 3</p>
<?php } ?>
@oliwa
oliwa / default.css
Last active December 5, 2018 07:10
Default CSS with SVG support
img {
max-width: 100%;
height: auto;
}
img [src$=".svg"] {
max-width: auto;
width: 100%;
height: auto;
}
@oliwa
oliwa / index.html
Last active December 5, 2018 07:09
HTML5 Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Flexbox</h1>
<p>Test</p>
@oliwa
oliwa / wp-body-class.php
Last active December 5, 2018 07:09
add blog ID to body class
<?php
// add blog_ID class to the body tag, see http://zurb.com/forrst/posts/Wordpress_multisite_blog_class-dAb
add_action( 'body_class', 'wpmu_body_class' );
function wpmu_body_class( $class ) {
global $current_blog;
$class[] = 'site-lang-' . $current_blog-> blog_id;
return $class;
}
@oliwa
oliwa / functions.php
Last active December 5, 2018 07:09
add a class to next/prev post and posts links
<?php
// Add class to links generated by next_posts_link and previous_posts_link,
// see https://css-tricks.com/snippets/wordpress/add-class-to-links-generated-by-next_posts_link-and-previous_posts_link/
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes() {
return 'class="button"';
}
@oliwa
oliwa / submenu-wp_nav_menu.php
Last active December 5, 2018 07:09
Submenus from wp_nav_menu
<?php wp_nav_menu( array(
'container' => '',
'menu' => 'primary-nav',
'submenu' => 11,
)); ?>
@oliwa
oliwa / google-map.php
Created June 3, 2016 07:53
Google Map
<div id="map" style="height: 420px; width: 100%;"></div>
<script>
function initMap() {
var mapDiv = document.getElementById('map');
var myLatLng = {lat: 52.251458, lng: -0.118886};
var map = new google.maps.Map(mapDiv, {
center: myLatLng,
zoom: 15
});
@oliwa
oliwa / functions.php
Created June 17, 2016 15:52
Output blog ID in body tag
<?php
// Add site-id class to body functions.php
add_filter('body_class', 'multisite_body_classes');
function multisite_body_classes($classes) {
$id = get_current_blog_id();
$classes[] = 'site-id-'.$id;
return $classes;
}