Skip to content

Instantly share code, notes, and snippets.

View ellegaarddk's full-sized avatar

ellegaarddk ellegaarddk

View GitHub Profile
@ellegaarddk
ellegaarddk / remove_widgets.php
Created August 23, 2018 06:34
WordpRess: Remove not needed widgets from backend
/*
* Remove unneccesary default widgets from backend
* Comment out what you wish to see
*/
function unregister_default_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
//* Remove unused Woocommerce widgets */
function eid_unregister_woo_widgets() {
// unregister_widget( 'WC_Widget_Recent_Products' );
unregister_widget( 'WC_Widget_Featured_Products' );
// unregister_widget( 'WC_Widget_Product_Categories' );
unregister_widget( 'WC_Widget_Product_Tag_Cloud' );
unregister_widget( 'WC_Widget_Cart' );
// unregister_widget( 'WC_Widget_Layered_Nav' );
// unregister_widget( 'WC_Widget_Layered_Nav_Filters' );
unregister_widget( 'WC_Widget_Price_Filter' );
@ellegaarddk
ellegaarddk / woo_add_SKU_cat_pages
Created October 22, 2018 17:30
Tilføj SKU fra WooCommerce på kategorisider
/* WooCommerce - add SKU on cat pages */
add_action( 'woocommerce_after_shop_loop_item_title', 'shop_sku', 5 );
function shop_sku(){
global $product;
echo '<span itemprop="productID" class="sku">' . __('SKU', 'woocommerce'). ': ' . $product->sku . '</span>';
}
@ellegaarddk
ellegaarddk / wpml_show_default.php
Last active March 6, 2019 16:57
Show default version if translation isn't found
<?php
add_filter('icl_ls_languages', 'wpml_ls_filter');
function wpml_ls_filter($languages) {
global $sitepress;
$default_url = $languages[$sitepress->get_default_language()]['url'];
foreach($languages as $lang_code => $language){
if($languages[$lang_code]['missing']==1){
$languages[$lang_code]['url'] = $default_url;
@ellegaarddk
ellegaarddk / woo_change_tab_headline_desc.php
Last active March 6, 2019 16:56
Change Woocommerce tab title and/or description to something else - or nothing
<?php
/* This will change the heading (H2:Decstiption) within the description tab to product name
* @origin https://wp-pro.dk/guides/tilpas-woocommerce-faneblades-titel-og-overskrift
*/
add_filter( 'woocommerce_product_description_heading', 'eid_change_product_description_tab_heading', 10, 1 );
function eid_change_product_description_tab_heading( $title ) {
global $post;
return $post->post_title; //change to "" to remove text
}
@ellegaarddk
ellegaarddk / functions.php
Created November 2, 2018 12:14
Special functions for this website that shouldn't be put in the child theme
<?php
/*
Plugin Name: Functions for my website
Plugin URI: https://wp-pro.dk/lav-dit-eget-funktionsplugin/
Description: Special functions for this website without their own plugin
Version: 1.5
Author: Ellegaard ID
Author URI: http://www.eid.dk
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@ellegaarddk
ellegaarddk / change_product_description_tab_title.php
Last active November 2, 2018 11:09
This will change the title (Description) of the description tab to something else - here 'Event information'. Use a suitable txt_domain for translations.
<?php
/* This will change the title (Description) of the description tab to something else
* @origin https://wp-pro.dk/guides/tilpas-woocommerce-faneblades-titel-og-overskrift
*/
add_filter( 'woocommerce_product_tabs', 'eid_change_product_description_tab_title', 10, 1 );
function eid_change_product_description_tab_title( $tabs ) {
global $post;
if ( isset( $tabs['description']['title'] ) )
$tabs['description']['title'] = __('Event information', 'txt_domain'); // change for something else, ready for translation
@ellegaarddk
ellegaarddk / woo_change_tab_titel_desc.php
Last active November 2, 2018 10:15
Change Woocommerce description tab title to product name
<?php
// This wil cheange the title (Description) of the description tab to product name
add_filter( 'woocommerce_product_tabs', 'eid_change_product_description_tab_title', 10, 1 );
function eid_change_product_description_tab_title( $tabs ) {
global $post;
if ( isset( $tabs['description']['title'] ) )
$tabs['description']['title'] = $post->post_title;
return $tabs;
}
@ellegaarddk
ellegaarddk / slider_cpt.php
Created October 22, 2018 17:44
creating custom post type for frontpage slider
<?php
/* creating custom post type for frontpage slider
* By ellegaard ID - www.eid.dk
*/
add_action('init', 'create_frontpagepic');
function create_frontpagepic() {
$feature_args = array(
'labels' => array(
'name' => __( 'Forsidebilleder' ),
@ellegaarddk
ellegaarddk / rename_CTP_title.php
Last active October 22, 2018 17:16
Omdøb titelfelt i Custom Post Type
function change_default_title( $title ){
$screen = get_current_screen();
if ( $screen->post_type == 'your_custom_post_type' ) {
return __( Skriv din egen tekst her', 'lang_domain' );
}
}
add_action('init', 'change_default_title');