Skip to content

Instantly share code, notes, and snippets.

@MrJoshFisher
MrJoshFisher / Addto.phtml
Last active Aug 29, 2015
Magneto Disable Shopping Cart With Attribute
View Addto.phtml
<?php
//Checks if the "Disable Add to Cart" variable is set to 'Yes':
if(($_product->getAttributeText('no_sample_button')) == "Yes"){
//If set to Yes, tell PHP what to output:
} else {
?>
View class_fb_backlink_checker.php
@MrJoshFisher
MrJoshFisher / Show RRP Price & Sale Price In Cart
Created Jul 17, 2017
Shows the RRP Price / Sale Price on the cart page in the table.
View Show RRP Price & Sale Price In Cart
add_filter( 'woocommerce_cart_item_price', 'bbloomer_change_cart_table_price_display', 30, 3 );
function bbloomer_change_cart_table_price_display( $price, $values, $cart_item_key ) {
$slashed_price = $values['data']->get_price_html();
$is_on_sale = $values['data']->is_on_sale();
if ( $is_on_sale ) {
$price = $slashed_price;
}
return $price;
}
@MrJoshFisher
MrJoshFisher / functions.php
Last active Dec 12, 2020
#WordPress Compression PHP - FLHM_HTML_Compression
View functions.php
class FLHM_HTML_Compression{
protected $flhm_compress_css = true;
protected $flhm_compress_js = true;
protected $flhm_info_comment = true;
protected $flhm_remove_comments = true;
protected $html;
public function __construct($html){
if (!empty($html)){
$this->flhm_parseHTML($html);
}
@MrJoshFisher
MrJoshFisher / bash.sh
Created Dec 12, 2020
[Bash Foreach] #bash
View bash.sh
#!/bin/bash
FILES=*.flac
for f in $FILES
do
echo $f
ffmpeg -i "$f" "${f%%.*}.mp3"
done
@MrJoshFisher
MrJoshFisher / index.py
Created Dec 12, 2020
[Beautiful Soup] #bs4
View index.py
#!/usr/bin/python
# Ratings Scraper
# Watches the house price on screetons.
from bs4 import BeautifulSoup
from datetime import datetime
import requests
import re
@MrJoshFisher
MrJoshFisher / index.py
Created Dec 12, 2020
[Selenium] #selenium
View index.py
#!/usr/bin/python
import os
import urllib
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless")
@MrJoshFisher
MrJoshFisher / index.php
Created Dec 12, 2020
[ukvehicledata] UK Vehicle Data PHP Curl Example
View index.php
<?php
$curl = curl_init();
$ApiKey = "<APIKEY>";
$postedcarreg = '<CARREG>';
$carreg = $postedcarreg;
$datatype = "VehicleData";
$url = "https://uk1.ukvehicledata.co.uk/api/datapackage/%s?v=2&api_nullitems=1&key_vrm=%s&auth_apikey=%s";
$url = sprintf($url, $datatype , $carreg, $ApiKey); // Syntax: sprintf($url, "PackageName", "VRM", ApiKey);
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
@MrJoshFisher
MrJoshFisher / functions.php
Created Dec 12, 2020
[WordPress Post Type] #WordPress Post Type
View functions.php
function testimonial_post_type() {
// Labels
$labels = array(
'name' => _x("Testimonials", "post type general name"),
'singular_name' => _x("Testimonial", "post type singular name"),
'menu_name' => 'Testimonials',
'add_new' => _x("Add New", "testimonial item"),
'add_new_item' => __("Add New Testimonial"),
'edit_item' => __("Edit Testimonial"),
@MrJoshFisher
MrJoshFisher / .htacess
Created Dec 12, 2020
[Rewrite URLS to File] #htaccess
View .htacess
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
RewriteRule ^page-1$ page.php?area=1
RewriteRule ^page-2$ page.php?area=1