Skip to content

Instantly share code, notes, and snippets.

View techskilled's full-sized avatar

Tech Skilled techskilled

View GitHub Profile
/** 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;
@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";
}
}
@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;
}
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 / 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);
@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();