Skip to content

Instantly share code, notes, and snippets.

View yayMark's full-sized avatar
💾
Gettin ma tech awn

Mark Hewitt yayMark

💾
Gettin ma tech awn
  • Perth, Western Australia
View GitHub Profile
@yayMark
yayMark / gist:11d394e83ef209f35015006c7166d96d
Created March 5, 2019 01:31
WordPress: logout via URL
http://example.com/wp-login.php?action=logout
@yayMark
yayMark / passwords.sh
Created February 19, 2019 04:16
Bash script to generate a list of random passwords
for i in `seq 10`; do openssl rand -base64 16 | colrm 17; done
@yayMark
yayMark / sync.sh
Created February 6, 2019 06:32
Use rsync to sync files from server to local
rsync -avP user@server:/home/servername/website/web/wp-content/uploads/ /Users/yaymark/projects/website/web/wp-content/uploads
@yayMark
yayMark / wp_change_user_password.sql
Created December 13, 2018 03:30
WordPress: change the password for an existing user
UPDATE `wp_users` SET `user_pass`= MD5('tzFuO7YR1ElE85lu3Xmt') WHERE `user_login`='iamtheadminbowbeforeme';
@yayMark
yayMark / swap_regular_and_sale_prices.php
Created October 18, 2018 02:54
WooCommerce: swap sale and regular pricing display
<?php
add_filter( 'woocommerce_get_price_html', 'my_price_html', 100, 2 );
function my_price_html( $price, $product ){
// swap the regular and sale prices
$pos_start = strpos($price, '<del>');
if ($pos_start !== false) {
$end = '</del>';
$end_length = strlen($end);
$pos_end_start = strpos($price, $end);
$pos_end = $pos_end_start + $end_length;
@yayMark
yayMark / other_pages_using_template.php
Created October 11, 2018 07:32
WordPress: find out which pages are using the same template as this one
<?php
$template = get_page_template_slug();
$args = array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => $template
)
)
// Callback function to remove default bio field from user profile page
// https://gist.github.com/dkomando/6214787a8d36d9f13c9b
if(!function_exists('remove_bio_box')){
function remove_bio_box($buffer){
$buffer = preg_replace('/<tr class=\"user-description-wrap\"[\s\S]*?<\/tr>/','',$buffer,1);
return $buffer;
}
function user_profile_subject_start(){ ob_start('remove_bio_box'); }
function user_profile_subject_end(){ ob_end_flush(); }
@yayMark
yayMark / functions.php
Created September 17, 2018 22:16
WordPress: remove the editor from the top of a post type in wp-admin
<?php
function post_type_no_editor() {
$post_type = 'insert_post_type_here';
remove_post_type_support($post_type, 'editor');
}
add_action('init', 'post_type_no_editor', 100);
@yayMark
yayMark / jQuery.outline.js
Created September 6, 2018 07:19
Put a border on a jQuery element or two
(function ($) {
$.fn.outline = function(options) {
var settings = $.extend({
borderWidth: "1px",
borderStyle: "solid",
borderColor: "red"
}, options);
return this.css({
borderWidth: settings.borderWidth,
@yayMark
yayMark / add_bootstrap_control_class.php
Created September 5, 2018 05:48
Apply Bootstrap 4 custom checkboxes and radio buttons to Gravity Fields generated forms
<?php
// Apply Bootstrap 4 custom checkboxes and radio buttons to Gravity Fields generated forms
// Derived from https://jayhoffmann.com/using-gravity-forms-bootstrap-styles/
add_filter( 'gform_field_container', 'add_bootstrap_control_class', 10, 6 );
function add_bootstrap_control_class( $field_container, $field, $form, $css_class, $style, $field_content ) {
$id = $field->id;
$field_id = is_admin() || empty( $form ) ? "field_{$id}" : 'field_' . $form['id'] . "_$id";