Skip to content

Instantly share code, notes, and snippets.

View Yorlinq's full-sized avatar
🏠
Working from home

Dennis Dallau Yorlinq

🏠
Working from home
View GitHub Profile
@Yorlinq
Yorlinq / Add 'EAN code' field to simple products and product variations - WooCommerce
Created August 10, 2022 10:02
Add 'EAN code' field to simple products and product variations - WooCommerce
/*
* Add our Custom Fields to simple products
*/
function yl_woo_add_custom_fields() {
global $woocommerce, $product, $post;
$product = wc_get_product( get_the_id() );
if ($product->is_type( 'simple' )) {
@Yorlinq
Yorlinq / Add YOOtheme's Uikiit styling - Advanced Custom Fields
Created July 27, 2022 16:57
Add YOOtheme's Uikiit styling - Advanced Custom Fields
function yl_deregister_acf_styles() {
// Deregister ACF Form style
wp_deregister_style('acf-global');
wp_deregister_style('acf-input');
// Avoid dependency conflict
wp_register_style('acf-global', false);
wp_register_style('acf-input', false);
}
@Yorlinq
Yorlinq / Rename 'Analytics' menu item in admin menu - WooCommerce
Last active July 27, 2022 08:45
Rename 'Analytics' menu item in admin menu - WooCommerce
// Rename 'Analytics' menu item in admin menu
function yl_rename_analytics_menu_item( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Analytische gegevens' :
$translated_text = __( 'Statistics', 'yorlinq' );
break;
}
return $translated_text;
}
@Yorlinq
Yorlinq / Display featured post thumbnail in RSS feed - WordPress
Created July 24, 2022 07:09
Display featured post thumbnail in RSS feed - WordPress
// Display featured post thumbnail in RSS feed
function yl_featured_image_in_rss_feed($content) {
global $post;
if (has_post_thumbnail($post->ID)) {
$content = '<div style="margin-top: 15px; margin-bottom: 15px;">' . get_the_post_thumbnail( $post->ID, 'medium' ) . '</div>' . $content;
}
return $content;
}
add_filter('the_excerpt_rss', 'yl_featured_image_in_rss_feed');
@Yorlinq
Yorlinq / Use shortcodes in HTML widgets - WordsPress
Created July 24, 2022 07:07
Use shortcodes in HTML widgets - WordsPress
// Use shortcodes in HTML widgets
add_filter('widget_text', 'shortcode_unautop');
add_filter('widget_text', 'do_shortcode');
@Yorlinq
Yorlinq / Redirect search to post with only 1 search result - WordPress
Created July 24, 2022 07:02
Redirect search to post with only 1 search result - WordPress
// Redirect search to post with only 1 search result
add_action('template_redirect', 'yl_auto_redirect_one_search_match');
function yl_auto_redirect_one_search_match() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
}
}
}
@Yorlinq
Yorlinq / Use shortcodes in system emails - WordPress
Last active July 24, 2022 07:05
Use shortcodes in system emails - WordPress
// Use shortcodes in system emails
function yl_activate_shortcodes_in_wp_mail($args) {
$args['message'] = do_shortcode($args['message']);
return $args;
}
add_filter('wp_mail', 'yl_activate_shortcodes_in_wp_mail', 20, 1);
@Yorlinq
Yorlinq / Remove 'Version information' from source code - WordPress
Last active July 24, 2022 06:50
Remove 'Version information' from source code - WordPress
// Remove 'Version information' from source code
remove_action( 'wp_head', 'wp_generator' );
@Yorlinq
Yorlinq / Remove 'Advanced Custom Fields' menu item from admin menu for non Super admins - Advanced Custom Fields
Created July 24, 2022 06:27
Remove 'Advanced Custom Fields' menu item from admin menu for non Super admins - Advanced Custom Fields
// Remove 'Advanced Custom Fields' menu item from admin menu for non Super admins
function yl_remove_admin_menu_custom_fields_for_non_super_admins() {
$user = wp_get_current_user();
if ($user && !is_super_admin()) {
remove_menu_page('edit.php?post_type=acf-field-group');
remove_menu_page('tools.php');
remove_menu_page('options-general.php');
}
}
@Yorlinq
Yorlinq / Add custom admin footer in backend - WordPress
Created July 24, 2022 06:22
Add custom admin footer in backend - WordPress