Skip to content

Instantly share code, notes, and snippets.

View ambercouch's full-sized avatar

Richard Arnold ambercouch

View GitHub Profile
@ambercouch
ambercouch / Wordpress image alignment placeholder
Last active February 4, 2016 10:00
Sass image alignment placeholder for wordpress themes
%post__img{
img, .wp-caption{
display: block;
max-width:100%;
height: auto;
overflow: hidden;
&.alignleft{
float: left;
margin: 0.5em 1.5em 0.5em 0.5em ;
@ambercouch
ambercouch / WP-define-site
Last active February 2, 2020 04:48
Define your site url in wp-config.php
/**
* When developing locally define these constants in your wp-config.php instead to your database.
* This saves time when moving your database.
*/
if (!defined('WP_SITEURL')) {
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME']);
}
if (!defined('WP_HOME')) {
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']);
@ambercouch
ambercouch / admin.php
Last active August 29, 2015 14:01
profile controller
<?php
function profiles($action = FALSE, $id = FALSE) {
$data = $this->data;
//set the file upload path is the method as the admin controler might upload files for different things
$this->original_path = realpath(APPPATH . '../uploads/profiles');
$this->thumbs_path = realpath(APPPATH . '../uploads/profiles/thumbs');
$view_content = __FUNCTION__;
@ambercouch
ambercouch / folder structure
Last active August 29, 2015 14:01
Wordpress as a sub-module
##Put our core files and folders in the cms folder
##Put our content files and folders in the content folder
|--my_wp_folder
| |--index.php
| |--wp-config.php
| |--wp-wapper-config.php
| |--cms
| | |--wp-admin
| | |--wp-includes
@ambercouch
ambercouch / Menu-button.markdown
Last active August 29, 2015 14:02
A Pen by Richie Arnold.
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@ambercouch
ambercouch / track-tel-mailto.js
Last active October 8, 2018 16:29
Track tel: and mailto: click with Google Analytics and jQuery
jQuery(document).ready(function(){
//set up the vars
var eCat = 'contact',
eAct = '',
eLabel = window.location.pathname;
//target href attributes that begin tel:
jQuery(document).on('click','[href^="tel:"]', function(e) {
@ambercouch
ambercouch / class.jetpack,php
Created January 18, 2016 07:48
Contact form 7 breaks when using JP Custom CSS. This is the fix.
<?php
class Jetpack {
/**
* Get $content_width, but with a <s>twist</s> filter.
*/
public static function get_content_width() {
$content_width = isset( $GLOBALS['content_width'] ) ? $GLOBALS['content_width'] : false;
return apply_filters( 'jetpack_content_width', $content_width );
}
@ambercouch
ambercouch / functions.php
Created February 4, 2016 12:14
Get only the first category of a post when using get_the_category_list() in your template.
<?php
//filters WordPress the_category_list to return onlt the first category.
function first_cat($cats)
{
return [$cats[0]];
}
add_filter('the_category_list', 'first_cat');
@ambercouch
ambercouch / Import-sql.txt
Last active January 28, 2021 20:05
MySQL commands
mysql -u username -p database_name < file.sql