Skip to content

Instantly share code, notes, and snippets.

@Daronspence
Daronspence / mehTotal.js
Last active Aug 5, 2016
Calculate Meh.com Total
View mehTotal.js
// Run this is the JS console of your Browser.
// jQuery must be loaded
// https://meh.com/orders
var total = 0;
$('span.summary').each(function() {
// Get the QTY and Purchase Price
var nums = $(this).text().match(/\d+\.\d+|\d+\b|\d+(?=\w)/g);
// Multiply QTY by Purchase Price
View sorority-edits.css
.woocommerce-main-image img { width: 100%; }
img {
width: 100%;
}
.single-product div.product .images .thumbnails a.zoom:focus { outline: none; }
@Daronspence
Daronspence / .htaccess-new-requests
Created Aug 2, 2016
Redirect and preserve POST requests
View .htaccess-new-requests
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_METHOD} GET
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R=307,L]
View edd-sl-update-snippet.php
<?php
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
@Daronspence
Daronspence / .htaccess-redirect
Created Aug 2, 2016
Same HTTPS .htaccess Redirect
View .htaccess-redirect
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]
View user-info-widget.php
<?php
// Put this inside of the widget template file for ACFW
// You could also just add this stuff to the template file for your sidebar. Same thing essentially :)
// Note, none of this has been tested! You have been warned! :)
$department = get_user_meta('fire_department', wp_get_current_user()->ID );
$federal_id = get_user_meta('federal_id', wp_get_current_user()->ID );
@Daronspence
Daronspence / Custom-Taxonomy-Meta-Box.php
Last active Feb 11, 2016
Add code to custom taxonomy meta boxes
View Custom-Taxonomy-Meta-Box.php
<?php
register_taxonomy( 'acme_custom_taxonomy', array( 'my_cpt', 'post' ), array(
'meta_box_cb' => 'acme_metabox_cb',
) );
function acme_metabox_cb( $post, $box ){
// Render the default hierarchical meta box form
post_categories_meta_box( $post, $box );
@Daronspence
Daronspence / pagination.php
Created Jan 27, 2016
WordPress Pagination Bar (1,2,3,4,...,87,88)
View pagination.php
<?php
function pagination_bar() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
View submit-ssl-working.php
<?php
// https://github.com/daverogers/serverpilot-php
require_once('serverpilot-php/lib/ServerPilot.php');
$clientid = "cid_XXXXXXXXX";
$apikey = "XXXXXXXXXXXXXX";
$appid = "XXXXXXXXXX";
$priv = trim(file_get_contents('/etc/letsencrypt/live/DOMAINNAME/privkey.pem'));
$cert = trim(file_get_contents('/etc/letsencrypt/live/DOMAINNAME/fullchain.pem'));
@Daronspence
Daronspence / showpassword.js
Last active Dec 14, 2015
Show Password for Active Field
View showpassword.js
(
function(){
document.activeElement.setAttribute('type', 'text');
}
)();
// Encoded // javascript:(function()%7Bdocument.activeElement.setAttribute('type'%2C 'text')%7D)()