Skip to content

Instantly share code, notes, and snippets.

View jayseventwo's full-sized avatar

jayseventwo jayseventwo

View GitHub Profile
@jayseventwo
jayseventwo / Woocommerce replace product listing button to link to product
Created November 8, 2017 03:51
Woocommerce replace product listing button to link to product
@jayseventwo
jayseventwo / Rename woocommerce tabs
Created November 7, 2017 00:35
Rename woocommerce tabs
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
return $tabs;
}
@jayseventwo
jayseventwo / Remove heading from description tab woocommerce
Created November 7, 2017 00:34
Remove heading from description tab woocommerce
// remove redundant "description" heading from description tab
add_filter( 'woocommerce_product_description_heading', 'remove_product_description_heading' );
function remove_product_description_heading() {
return '';
}
@jayseventwo
jayseventwo / add to head
Created September 25, 2014 01:34
Add custom code to head tag through function
add_action('wp_head', 'wpse_43672_wp_head');
function wpse_43672_wp_head(){
//Close PHP tags
?>
ADD YOUR PLAIN HTML CODE HERE
<?php //Open PHP tags
}
@jayseventwo
jayseventwo / cat-order
Created September 23, 2014 23:11
Stope categories going out of order in WP pages/posts admin
/* ----------------------------------- stop categories going out of order in WP page/poasts admin ---------------*/
function taxonomy_checklist_checked_ontop_filter ($args)
{
$args['checked_ontop'] = false;
return $args;
}
@jayseventwo
jayseventwo / 404 to 301
Created September 23, 2014 22:41
404 error to 301 redirect
/* Redirect 404 to correct page */
add_filter( '404_template', 't5_redirect_to_category' );
function t5_redirect_to_category( $template )
{
if ( ! is_404() )
return $template;
global $wp_rewrite, $wp_query;
@jayseventwo
jayseventwo / gist:8b17ca7ffc8f2e725f18
Created September 4, 2014 21:35
Add popup prompt when pressing publish button in WP
/* = Add a "molly guard" to the publish button */
add_action( 'admin_print_footer_scripts', 'sr_publish_molly_guard' );
function sr_publish_molly_guard() {
echo <<<EOT
<script>
jQuery(document).ready(function($){
$('#publishing-action input[name="publish"]').click(function() {
if(confirm('Are you sure you want to publish this?')) {
return true;
@jayseventwo
jayseventwo / cat-class-to-body
Created June 4, 2014 00:55
Add category class to body in WordPress
// add category class to body
function body_class_add_categories( $classes ) {
// Only proceed if we're on a single post page
if ( !is_single() )
return $classes;
// Get the categories that are assigned to this post
$post_categories = get_the_category();
@jayseventwo
jayseventwo / wp-white-screen-of-death
Last active August 29, 2015 13:59
WP white screen of death
// add to wp-config.php to view errors if your WP install only shows a white page
error_reporting(E_ALL); ini_set('display_errors', 1);
define( 'WP_DEBUG', true);
@jayseventwo
jayseventwo / hide_admin_functions
Created January 9, 2014 22:03
Hide various aspects of your WordPress admin page - add to functions.php
// ------------------------------hide admin menus in sidebar
function remove_menu_items() {
global $menu;
$restricted = array(__('Dashboard'), __('Pages') , __('Posts'), __('Comments'), __('Media'), __('Plugins'), __('Appearance'), __('Settings'), __('Tools'), __('Users'));
end ($menu);
while (prev($menu)){
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted)){
unset($menu[key($menu)]);}