Skip to content

Instantly share code, notes, and snippets.

@runezero
runezero / manage_edit-product_columns.php
Created May 25, 2022 13:44
[Admin products sort by date] Adds the modified date to the Admin product column and gives the option to sort products by date modified #woocommerce
add_filter( 'manage_edit-product_columns', 'admin_products_sort_modified', 9999 );
function admin_products_sort_modified( $columns ){
$columns['laatst_bijgewerkt'] = 'Laatst bijgewerkt';
return $columns;
}
add_action( 'manage_product_posts_custom_column', 'admin_products_sort_modified_content', 10, 2 );
function admin_products_sort_modified_content( $column, $product_id ){
if ( $column == 'laatst_bijgewerkt' ) {
//echo strtotime(get_the_modified_date("Y-m-d H:i:s", $product_id));
@runezero
runezero / wp_head.php
Last active May 25, 2022 19:26
[Set mobile browser bar color] Set the mobile url bar color on mobile devices #wordpress
<?php
add_action( 'wp_head', 'address_mobile_address_bar' );
function address_mobile_address_bar() {
$color = '#ffffff';
echo '<meta name=”theme-color” content=”' . $color . '”>';
echo '<meta name=”msapplication-navbutton-color” content=”' . $color . '”>';
echo '<meta name=”apple-mobile-web-app-capable” content=”yes”>';
echo '<meta name=”apple-mobile-web-app-status-bar-style” content=”black-translucent”>';
}
@runezero
runezero / avf_alb_supported_post_types.php
Created May 25, 2022 13:52
[Enable post_type for ALB] Enables custom post types for the Advanced Layout Builder #enfold
/**
* Advanced Layout Builder Custom Post Types
*/
add_filter('avf_alb_supported_post_types', function ($array) {
$array[] = 'projecten';
return $array;
}, 10, 1);
function avf_metabox_layout_post_types_mod( array $supported_post_types )
{
@runezero
runezero / avia_layout_filter.php
Last active May 25, 2022 13:57
[Portfolio page full width] Set the portfolio single page width to full screen #enfold
add_filter('avia_layout_filter', 'enfold_portfolio_item_full_width', 10, 2);
function enfold_portfolio_item_full_width($layout, $post_id){
if(is_singular('portfolio'))
{
$layout['current'] = $layout["fullsize"];
$layout['current']['main'] = "fullsize";
}
return $layout;
}
@runezero
runezero / avia_social_share_title.php
Created May 25, 2022 13:56
[Change social share text] Change the translation for the social share title #enfold
add_filter('avia_social_share_title', 'enfold_modify_share_title');
function enfold_modify_share_title(){
if (get_locale() == "en_US"){
return "Share this article";
}
if (get_locale() == "nl_NL"){
return "Deel dit artikel";
}
@runezero
runezero / embed_oembed_html.php
Created May 25, 2022 13:58
[Youtube NoCookie url] Change the youtube embeds to a nocookie url #wordpress
/**
* Modify YouTube oEmbeds to use youtube-nocookie.com
*
* @param $cached_html
* @param $url
*
* @return string
*/
function wpdev_filter_youtube_embed( $cached_html, $url = null ) {
@runezero
runezero / gettext.php
Created May 25, 2022 14:00
[Add custom translations] Add custom translations to domains or text #wordpress
add_filter('gettext', 'wpdev_change_text', 20, 3);
function wpdev_change_text( $translated_text, $untranslated_text, $domain ) {
if ($untranslated_text == 'Please enter your username or email address. You will receive a link to create a new password via email.'){
$translated_text = 'Vul onderstaand uw email in. U krijgt van ons een mail met een link om uw wachtwoord opnieuw in te stellen.';
}
if ($untranslated_text =='Check your email for the confirmation link.'){
$translated_text = 'Check uw email voor de bevestigingslink.';
}
if ($untranslated_text =='Enter your new password below.'){
@runezero
runezero / wp_head.php
Created May 25, 2022 14:04
[Add GTAG] Add Google Tag Manager to the website trough the script in the head and noscript in the body #enfold #wordpress
add_action('wp_head', 'wpdev_hook_gtag');
function wpdev_hook_gtag() {
?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-1234567');</script>
<!-- End Google Tag Manager -->
@runezero
runezero / init.php
Last active June 13, 2022 13:48
[Get user IP] Get the IP-address from the user and check if it exists in the site owner list #wordpress #enfold
//function to retrieve user IP address
function wpdev_get_user_ip(){
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
//ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
//ip pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
@runezero
runezero / upload_mimes.php
Created May 25, 2022 14:14
[Allow file type upload] Allow new file type uploads in the media library, multisites excluded #wordpress
add_filter( 'upload_mimes', 'allow_upload_new_mimes' );
function allow_upload_new_mimes( $mimes = array() ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}