Skip to content

Instantly share code, notes, and snippets.

View marcwiest's full-sized avatar
🌳
Branching out

Marc Wiest marcwiest

🌳
Branching out
View GitHub Profile
@marcwiest
marcwiest / check-env.php
Created April 13, 2020 14:47
Check your current environment
<?php
if (in_array($_SERVER['REMOTE_ADDR'], ['::1', '127.0.0.1'])) {
// localhost
} else if ('staging.example.com' == $_SERVER['HTTP_HOST']) {
// staging
}
@marcwiest
marcwiest / extend-is-ssl-check.php
Last active April 13, 2020 06:11
Extended WP `is_ssl()` function
<?php
if (! function_exists('is_ssl')) :
/**
* Check if SSL is enabled.
*/
function is_ssl()
{
if (is_ssl()) {
return true;
@marcwiest
marcwiest / get-yoast-primary-category.php
Created April 13, 2020 05:27
Get WP Yoast Primary Category
<?php
/**
* Get yoast primary (or 1st found) category.
*/
function get_yoast_primary_category($post_id=0)
{
// If no category is set, return fasle.
if ( ! $category = get_the_category( $post_id ?: get_the_ID() ) ) {
return false;
@marcwiest
marcwiest / jquery-literal-module-pattern.js
Last active March 2, 2019 17:02
jQuery Literal Module Pattern
(function( $ ) {
'use strict';
var $doc = $(document);
var module = {
init : function() {
this.createElements();
this.cacheProps();
@marcwiest
marcwiest / README.md
Created August 28, 2018 18:55 — forked from jonathantneal/README.md
SASS @font-face mixin

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);
@marcwiest
marcwiest / dabblet.css
Created September 7, 2017 15:25 — forked from juptrking/dabblet.css
Masking with equilateral triangles in CSS
/**
* Masking with equilateral triangles in CSS
*/
body{
background: #fff;
min-height: 100%;
}
/*
<?php
wp_nav_menu( array(
'theme_location' => 'mobile',
'walker' => new Walker_Nav_Menu_Dropdown(),
'items_wrap' => '<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value">%3$s</select></form></div>',
) );
class Walker_Nav_Menu_Dropdown extends Walker_Nav_Menu {
function start_lvl(&$output, $depth){
<?php
/* Register custom post types on the 'init' hook. */
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 0.1.0
* @access public
@marcwiest
marcwiest / better-wp-post-content.php
Last active April 13, 2020 05:37
Better WordPress Post–Page / Content–Excerpt Function
<?php
function better_wp_post_content( $word_limit=false, $force_excerpt=false, $do_shortcode=false ) {
$post = get_post();
$excerpt_metabox = $post->post_excerpt;
// If word limit was used, return the excerpt.
if ( is_int( $word_limit ) ) :
$excerpt = $force_excerpt ? $excerpt_metabox : get_the_excerpt();
@marcwiest
marcwiest / print-visibility.css
Created April 2, 2013 00:20
print visibility classes
.print-only { display: none !important; }
@media print {
.hide-on-print { display: none !important; }
.print-only { display: block !important; }
}