Skip to content

Instantly share code, notes, and snippets.

View techskilled's full-sized avatar

Tech Skilled techskilled

View GitHub Profile
@techskilled
techskilled / gist:394d3b5b1175ff2a3cb8
Last active August 29, 2015 14:19
Create a WordPress Database Error Page
<?php
// INFORM GOOGLE SITES TEMP DOWN
$protocol = $_SERVER["SERVER_PROTOCOL"];
if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol ) $protocol = 'HTTP/1.0';
header( "$protocol 503 Service Unavailable", true, 503 );
header( 'Content-Type: text/html; charset=utf-8' );
header( 'Retry-After: 600' );
$temp = mysql_error();
$url = curPageURL();
@techskilled
techskilled / Deleteusers.sql
Created August 22, 2016 16:12
WooCommerce SQL to delete users who have no orders or posts
DELETE from wp_users where wp_users.ID not in (
SELECT meta_value FROM wp_postmeta WHERE meta_key = '_customer_user'
) AND wp_users.ID not in (
select distinct(post_author) from wp_posts
);
delete from wp_usermeta where wp_usermeta.user_id not in (select ID from wp_users);
add_filter( 'woocommerce_product_categories_widget_args', 'woo_product_cat_widget_args' );
function woo_product_cat_widget_args( $cat_args ) {
$cat_args['exclude'] = array('16');
return $cat_args;
}
@techskilled
techskilled / functions.php
Created August 24, 2016 10:00
WooCommerce change out of stock text to sold
add_filter('woocommerce_get_availability', 'availability_filter_func');
function availability_filter_func($availability)
{
$availability['availability'] = str_ireplace('Out of stock', 'Sold', $availability['availability']);
return $availability;
}
@techskilled
techskilled / functions.php
Created August 24, 2016 10:22
WooCommerce Replace text : Shop page title
add_filter( 'woocommerce_page_title', 'woo_shop_page_title');
function woo_shop_page_title( $page_title ) {
if( 'Shop' == $page_title) {
return "Place your new shop page title here";
}
}
/** DISBALE WP-ADMIN FROM NON ADMIN : SOBER MEDIA 13/08/2016 **/
add_action('admin_init', 'no_mo_dashboard');
function no_mo_dashboard() {
$isAjax = (defined('DOING_AJAX') && true === DOING_AJAX) ? true : false;
//if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
if(!$isAjax) {
if(!current_user_can('administrator')) {
wp_redirect('http://www.example.com/'); exit;
/**
* Remove Cart Stage
* @see: http://stackoverflow.com/questions/15592633/woocommerce-add-to-cart-button-redirect-to-checkout
*/
add_filter( 'add_to_cart_redirect', 'redirect_to_checkout' );
function redirect_to_checkout() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
@techskilled
techskilled / functions.php
Last active March 19, 2019 11:30
WooCommerce Text Replace: Change / Rename product tab text
/**
* @snippet WooCommerce Text Replace: Change / Rename product tab text
* @code https://techskilled.co.uk/knowledgebases/woocommerce-single-product-change-rename-product-tab-text
* @author https://techskilled.co.uk
*/
function techskilled_renameproduct_tab($tabs) {
$tabs['description']['title'] = 'Extra Information';
#Redirect a Single Page
Redirect 301 /oldpage.html http://www.yoursite.com/newpage.html
Redirect 301 /oldpage2.html http://www.yoursite.com/folder/
#Redirect Entire Website
Redirect 301 / http://yournewsite.com/
Redirect 301 / http://yournewsite.com/
/**
* @snippet WooCommerce Single Page - Move Tabs below the add to cart button
* @code https://techskilled.co.uk/snippets/single-page-move-tabs-below-the-add-to-cart-button
* @author https://techskilled.co.uk
*/
function techskilled_move_tabs(){
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 70 );
}