Skip to content

Instantly share code, notes, and snippets.

View tcmulder's full-sized avatar

Tomas tcmulder

View GitHub Profile
@tcmulder
tcmulder / wp-shortcode-starter.php
Created October 9, 2023 13:42
WordPress Shortcode Starter
<?php
/**
* Add shortcode
*/
add_shortcode( 'button', 'aqua_btn_shortcode' );
function aqua_btn_shortcode( $attr, $content = "" ) {
extract( shortcode_atts( array(
'label' => 'Button',
'link' => '#',
'new_tab' => '',
@tcmulder
tcmulder / wp-maint-redirect.php
Last active September 25, 2023 22:57
WordPress Maint. Redirect
<?php
define( 'AQUAMIN_ADMIN_LOCKOUT', true );
add_action( 'admin_init', function() {
if( AQUAMIN_ADMIN_LOCKOUT && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) {
header( 'location: http://www.thinkaquamarine.com/maintenance.html' );
// or use this to redirect internally: wp_safe_redirect( home_url( '/maint.html' ) );
exit;
}
} );
@tcmulder
tcmulder / nav-mixin.scss
Last active December 20, 2023 15:44
Creates a dropdown or nested navigation.
/*------------------------------------*\
//Navigation
\*------------------------------------*/
// Use this mixin to add basic nav styling.
// Just add the following code within your styles.
//
//
// @include nav(
// $type: 'dropdown', //nav type: dropdown or nested
@tcmulder
tcmulder / wp-template-part-shortcode.php
Last active December 20, 2023 18:49
Template Part Shortcode
<?php
//Usage: [include template='template' part='part']
function template_part_shortcode($atts) {
extract(shortcode_atts(array(
'template' => 'templates/parts/page',
'part' => null
), $atts));
ob_start();
get_template_part($template, $part);
@tcmulder
tcmulder / crud-cookies.js
Last active December 20, 2023 18:50
CRUD Cookies
var cookies = {
create: function(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
@tcmulder
tcmulder / wp-small-admin-bar.php
Last active December 20, 2023 18:51
Makes the WordPress admin bar small and unobtrusive up in the corner of the screen.
/*
* Mini Admin Bar
* Modified from plugin URI: http://www.netyou.co.il/
* Description: Makes the admin bar a small button on the left and expands on hover.
*/
add_action('get_header', 'my_filter_head');
function my_filter_head() { remove_action('wp_head', '_admin_bar_bump_cb'); }
function my_admin_css() {
@tcmulder
tcmulder / wp-output-current-template.php
Last active December 20, 2023 18:52
Quick output of template in use for WordPress.
<?php global $template; echo $template;?>
<?php
/*
* Use Parent Category
* Description: Causes subcategories to use their parent's template
*/
function new_subcategory_hierarchy() {
$category = get_queried_object();
$parent_id = $category->category_parent;
@tcmulder
tcmulder / expand-click-aria-ie.css
Last active December 20, 2023 18:54
Make the hover area bigger for dropdown menus.
li ul:after {
content: "";
position: absolute;
top: -10px;
bottom: -40px;
left: -40px;
right: -40px;
//IE hack
background-color: #000;
filter:alpha(opacity=0);
@tcmulder
tcmulder / wp-old-content-debugger.php
Last active December 20, 2023 18:55
Simulate the_content() with a WordPress shortcode.
<?php
/**
* Set up faux the_content() simulation
*
* You can use this to simulate the_content() through a shortcode. Simply
* add the shortcode [faux] on any page in wp-admin and publish. Then,
* Then, make all your changes in your favorite text editor in the includes/faux-content.php
* file. Once finished, paste the contents of includes/faux-content.php into the page in wp-admin.
*/
function faux_the_content_() {