Skip to content

Instantly share code, notes, and snippets.

Avatar

Theuns Coetzee ipokkel

View GitHub Profile
@LukyVj
LukyVj / outOfViewport.js
Last active Nov 15, 2017
Detect which elements overlap your document width.
View outOfViewport.js
function outOfViewport(colorWrapper, colorTag, colorClass) {
var w = document.body.offsetWidth,
it = document.querySelectorAll('*');
for ( i in it) {
if( it[i].offsetWidth > w ) {
console.log(
`%c [` +
`%c` + it[i].tagName +
`%c.`+ it[i].classList +
`%c]`+
@BurningDog
BurningDog / config.yaml
Last active May 17, 2018 — forked from pkuczynski/parse_yaml.sh
Replace local Wordpress database (running inside Homestead) with production database
View config.yaml
prod:
# ssh authentication details
ssh: user@example.com
# path to wordpress on the server
wordpress: path/to/wordpress
# path to backups folder on the server (must exist)
backups: backups
# production url
url: www.example.com
@tsi
tsi / newsite
Last active May 27, 2018
Bash script to create virtual hosts and prepare your drupal directory.
View newsite
#!/bin/bash
# This script creates virtual hosts and prepares your mysql DB and drupal directory.
# you should put it under /usr/local/bin/
# and run it with sudo newsite
# Set the path to your localhost
www=/var/www
echo "Enter directory name under $www"
read sn
@jonathantneal
jonathantneal / README.md
Last active Jun 28, 2018
Importing CSS from within CSS using PostCSS
View README.md

[PostCSS] is a powerful tool for transforming stylesheets. If it’s unfamiliar to you, PostCSS turns stylesheets into readable objects in JavaScript called ASTs (Abstract Syntax Trees) and then turns those ASTs back into stylesheets, completing the circle.

Nothing changes. What’s the fun in that? The greatness of PostCSS is found in PostCSS plugins.

PostCSS plugins read and modify the AST before it’s turned back into a stylesheet. There are plugins to automatically add [vendor prefixes] to properties and selectors, or interpret Sass-like [variables], [mixins], and [loops], or down-mix [future] and [experimental] features to CSS. PostCSS plugins can even generate entirely new documents based on the CSS, like [styleguides].


Writing a PostCSS plugin is remarkably simple, thanks to its solid API. Still, one of the first challenges aspiring plugin authors face is importing other files. In other words, replacing links in a stylesheet with the contents of those links. This is where something like `@import

@andrewlimaza
andrewlimaza / rh_example_location.php
Last active Mar 26, 2019
Change location where Register Helpers are shown depending if user is logged in or not for Paid Memberships Pro.
View rh_example_location.php
<?php
// Show the custom Register Helper Fields in a different location if the user is logged in.
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
@messica
messica / my_profile_redirect.php
Created Dec 21, 2018
Redirect wp-admin profile to BuddyPress Profile
View my_profile_redirect.php
<?php
/**
* Redirect wp-admin profile to BuddyPress Profile
*/
function my_profile_redirect() {
global $current_user;
if(defined('IS_PROFILE_PAGE') && !current_user_can('manage_options')) {
wp_redirect("/members/$current_user->user_login/profile");
exit;
@kimcoleman
kimcoleman / redirect_profile_page_to_bbpress_user_profile.php
Last active Mar 27, 2019
Redirect the Member's Profile page to the bbPress User Profile when using the Member Directory and Profile Pages Add On for Paid Memberships Pro
View redirect_profile_page_to_bbpress_user_profile.php
<?php
/**
* Use this recipe to redirect the Profile page as defined under Memberships > Page Settings to the member's
* bbPress User Profile when using the Member Directory and Profile Pages Add On in conjunction with bbPress.
*
* You must set a placeholder page under Memberships > Page Settings > Profile in order for this redirect to work.
*/
function redirect_profile_page_to_bbpress_user_profile() {
global $pmpro_pages;
if ( ! empty( $pmpro_pages ) && ! empty( $pmpro_pages['profile'] ) && is_page( $pmpro_pages['profile'] ) ) {
@ideadude
ideadude / init_create_my_administrator_user.php
Created Feb 13, 2018
Create a WordPress administrator user account via PHP/FTP.
View init_create_my_administrator_user.php
<?php
/*
Sometimes you have FTP access to a site, but don't have a WP administrator account.
You can use this code to create one.
1. Add this code into any plugin or theme file that you know will be run.
2. Visit /?createmyadministratoruser=1.
3. Delete the code you added.
*/
function init_create_my_administrator_user() {
@pbrocks
pbrocks / redirect-to-login-if-not-logged-in.php
Created Dec 24, 2018
Redirect to login if not logged in or if not PMPro membership page.
View redirect-to-login-if-not-logged-in.php
<?php
/**
* Redirect to login or homepage if user is logged out or not a member
* Add this code to your active theme's functions.php file.
*/
function my_template_redirect() {
global $current_user;
$okay_pages = array(
pmpro_getOption( 'billing_page_id' ),
@andrewlimaza
andrewlimaza / hide-approval-members-directory.php
Created Apr 4, 2019
Hide Members from Member Directory Page when not approved [Paid Memberships Pro]
View hide-approval-members-directory.php
<?php
/**
* PLEASE NOTE: This will affect only new signups that have happened after this code has been added to your site
* (this won't run through existing pending/denied members and update their directory status).
* This will run on checkout and every time a member is approved, denied or reset in the Approvals Add On.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
// Hide users from Directory when level requires Approval + show them once they are approved.
function hide_user_from_directory_if_level_requires_approval( $level_id, $user_id ) {