Skip to content

Instantly share code, notes, and snippets.

@teachmeter
teachmeter / gitflow-breakdown.md
Last active November 19, 2020 10:44 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
  git commit --allow-empty -m "Initial commit"
  git checkout -b develop master

Connect to the remote repository

@teachmeter
teachmeter / composer-wp-cli.md
Created July 9, 2020 11:52 — forked from neverything/comopser-wp-cli.md
Install composer and wp-cli on cyon.ch hostings with SSH access.

Cyon.ch/Hostpoint - Install composer & wp-cli

SSH into your server and stay in the home directory of the user. Check if you have a bin directory in your user directory already, in case you do, omit the mkdir bin.

Use bin folder in $HOME for user scriptsr

For the commands to be loaded from the bin directory run echo "export PATH=$HOME/bin:$PATH" >> ~/.bashrc. For the new config to be used run source ~/.bashrc or close and reopen your SSH session.

Composer

@teachmeter
teachmeter / wp-author-import-auto-select.js
Created February 19, 2020 11:47 — forked from webercoder/wp-author-import-auto-select.js
Auto-select authors for posts during WordPress import. They must already be assigned to the project. Enable jQuery in a plugin or functions.php, and paste this in the browser console.
(function($){
$('#authors li').each(function(key, value) {
var name = $(this).children('strong').first().html();
var re = /\s\([^\)]+\)/gi;
name = name.replace(re, '');
$(this).find('select').first().children('option').each(function(){
if ($(this).html() == name) {
console.log('Comparing ' + $(this).html() + ' to ' + name + ".\n");
$(this).attr('selected', 'selected');
@teachmeter
teachmeter / hide-admin-bar.php
Created November 6, 2015 11:25
Disables the #wpadmin bar for users without "edit_posts" permissions.
<?php
/**
* Disables the #wpadmin bar for users without "edit_posts" permissions.
*/
function prefix_hide_admin_bar() {
if ( ! current_user_can( 'edit_posts' ) ) {
add_filter( 'show_admin_bar', '__return_false' );
}
}
add_action( 'after_setup_theme', 'prefix_hide_admin_bar' );
@teachmeter
teachmeter / redirect-admin.php
Created November 6, 2015 11:25
Redirects subscribers back to the home page if they attempt to access the dashboard.
<?php
/**
* Redirects subscribers back to the home page if they attempt to access the dashboard.
*/
function prefix_redirect_admin() {
if ( ! current_user_can( 'edit_posts' ) && ! defined( 'DOING_AJAX' ) ) {
wp_safe_redirect( home_url() );
exit;
}
}
@teachmeter
teachmeter / authenticate-by-email.php
Created November 6, 2015 11:24
Allows visitors to log in using e-mail address
<?php
/**
* Allows visitors to log in using e-mail address
*
* @param string username passed by reference
*/
function prefix_authenticate_by_email( &$username ) {
$user = get_user_by( 'email', $username );
if ( false !== $user ) {
$username = $user->user_login;
@teachmeter
teachmeter / WP: Install WP
Created October 21, 2015 09:14
Install WP latest in current directory
wget http://wordpress.org/latest.tar.gz && tar xvzf latest.tar.gz && mv ./wordpress/* ./ && rm -rf ./wordpress && cp ./wp-config-sample.php ./wp-config.php
alias lsa='ls -la'
alias ..="cd .."
# GIT RELATED SHORTCUTS
alias lg='git log --graph --full-history --all --color --pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"'
alias gl="git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gs="git status"
alias gm="git commit -m"
alias gb="git branch"
<?php
function getExtension($url = '') {
if ( empty($url) ) {
return false;
}
$domain = content_url() . '/uploads/';
$url = str_replace($domain, '', $url);
$reversed = strrev($url);
$dotPosition = strpos($reversed, '.' );
$extension = strrev(substr($reversed,0,$dotPosition));
@teachmeter
teachmeter / gist:8845660
Created February 6, 2014 14:54
Ipad Fixed element with scrolling bug
var hack = document.createElement("div");
hack.style.height = "101%";
document.body.appendChild(hack);
setTimeout(function(){
document.body.removeChild(hack);
hack = null;
}, 0);