apt update && apt install jpegoptim optipng -y
cd /path/to/your/image/folder
<?php | |
/** | |
* Filter the content of the new user registration email | |
* @param $message The email content | |
* @param $user The user object | |
* @param $blogname The name of the site | |
* @param $url The url for the user profile | |
*/ | |
function prefix_new_registration_email_content( $message, $user, $blogname, $url ) { | |
$_message = $meessage . '<br>'; |
<?php | |
function auto_complete_order( $order_id, $old_status, $new_status ) { | |
$order = wc_get_order( $order_id ); | |
/* | |
* You can get the `your_payment_gateway` identifyer by visiting the WC payments setting page | |
* and selecting the gateway you would like to use. The payment gateway identifyer is the "section=" part of the browser URL | |
*/ | |
if ( $new_status === 'processing' && $order->get_payment_method() === 'your_payment_gateway' ) { | |
$order->update_status( 'completed' ); |
<?php | |
/** | |
* Get the average pixel colour from the given file using Image Magick | |
* | |
* @param string $filename | |
* @param bool $as_hex Set to true, the function will return the 6 character HEX value of the colour. | |
* If false, an array will be returned with r, g, b components. | |
*/ | |
function get_average_colour($filename, $as_hex_string = true) { |
<?php | |
use PhpCsFixer\Config; | |
use PhpCsFixer\Finder; | |
$rules = [ | |
'array_indentation' => true, | |
'array_syntax' => ['syntax' => 'short'], | |
'binary_operator_spaces' => [ | |
'default' => 'single_space', |
<script type="text/javascript"> | |
function idleTimer() { | |
var t; | |
//window.onload = resetTimer; | |
window.onmousemove = resetTimer; // catches mouse movements | |
window.onmousedown = resetTimer; // catches mouse movements | |
window.onclick = resetTimer; // catches mouse clicks | |
window.onscroll = resetTimer; // catches scrolling | |
window.onkeypress = resetTimer; //catches keyboard actions |
<?php | |
/** | |
* Generate a sequence of numbers for use in a pagination system, the clever way. | |
* @author Bramus Van Damme <bramus@bram.us> | |
* | |
* The algorithm always returns the same amount of items in the sequence, | |
* indepdendent of the position of the current page. | |
* | |
* Example rows generated: |
<?php | |
function themename_custom_logo_setup( $args ) { | |
$args['height'] = 116; | |
$args['width'] = 250; | |
return $args; | |
} | |
add_filter( 'storefront_custom_logo_args', 'themename_custom_logo_setup' ); |
jQuery(document).ready(function() { | |
jQuery("#the-empty-div").click(function(){ | |
jQuery.ajax({ | |
type: 'POST', | |
url: my_ajax_data.ajax_url, | |
data: { | |
action: 'my_ajax_action_callback', | |
security: my_ajax_data.security_nonce, | |
first_name: 'John', // Get this however | |
last_name: 'Smith', // Get this however |
<?php | |
add_filters( 'wp_list_pages_excludes', function( $exclude_array ) { | |
$exclude_array = array( '121' ); | |
return $exclude_array; | |
} | |
); |