Skip to content

Instantly share code, notes, and snippets.

View ellegaarddk's full-sized avatar

ellegaarddk ellegaarddk

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / remove_product_tabs.php
Created November 2, 2018 11:15
Remove one or all of the WooCommerce tabs
<?php
/**
* Remove woocomerce product data tabs
* @origin https://wp-pro.dk/guides/tilpas-woocommerce-faneblades-titel-og-overskrift
*/
add_filter( 'woocommerce_product_tabs', 'eid_remove_product_tabs', 98 );
function eid_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
@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 / functions.php
Last active March 11, 2019 08:08
Autoptimize: adjust the level of the autowarning on cache size to 1GB
<?php
// #Adjusting Autoptimize warning limit to 1GB
add_filter('autoptimize_filter_cachecheck_maxsize','adjust_cachesize');
function adjust_cachesize() {
return 1024*512*1024;
}
@ellegaarddk
ellegaarddk / stikcy-anchor-points.css
Last active July 27, 2022 07:41
Keeping anchor point below sticky header
/** better solution
* description on https://wp-pro.dk/?p=3656
**/
:target { scroll-margin-top:75px}
/** old solution - don't use this! **/
body:not(.elementor-editor-active) /* for not messsing up elementor editor */
*[id]:before {
content: "";
display:block;
@ellegaarddk
ellegaarddk / MENU-text-hamburger.css
Last active October 10, 2023 14:18
Add the text "MENU" to a hamburger/mobile menu created with Elementor in WordPress
/* places the text "MENU" til the left of the default hamburger menu */
.elementor-menu-toggle:before{
position: relative;
padding-right: 10px;
content: "MENU";
font-weight: 700;
color: rgba(0,0,0,.5)
}