Type: php
Adsense Code
MemberPress: Add a description to Order Bumps on the registration page
function mepr_order_bumps_desc() { ?>Continue reading
PHP [Vendor Posts]: Preserve Vendor Post Author
// This code ensures that the post author of vendor records remains unchanged when an admin updates or publishes the post, // maintaining the association between vendor records and the original post author (love list vendor). // Necessary to prevent…Continue reading
MA GDPR YouTube
/* Plugin Name: MA GDPR YouTube Description: GDPR compliant YouTube video embedding Author: Matthias Altmann Project: Code Snippet: GDPR Compliant YouTube Embed Version: 1.2.0 Plugin URI: https://www.altmann.de/blog/code-snippet-gdpr-compliant-youtube-videos/ Description: en: https://www.altmann.de/blog/code-snippet-gdpr-compliant-youtube-videos/ de: https://www.altmann.de/blog/code-snippet-dsgvo-konforme-youtube-videos/ Copyright: © 2021-2022, Matthias Altmann Version History: Date…Continue reading
Enable Menu Management for Non-Administrators
function modify_appearance_menu() { if (!current_user_can(‘administrator’)) { // Remove access to themes and customize for all users except administrators remove_submenu_page(‘themes.php’, ‘themes.php’); remove_submenu_page(‘themes.php’, ‘customize.php’); // Block access to /wp-admin/themes.php and /wp-admin/customize.php global $pagenow; $restricted_pages = array(‘themes.php’, ‘customize.php’); if (in_array($pagenow, $restricted_pages)) { wp_redirect(admin_url());…Continue reading
only_authorised_rest_access
add_filter( ‘rest_authentication_errors’, ‘only_authorised_rest_access’); function only_authorised_rest_access( $result ) { if( ! is_user_logged_in() ) { return new WP_Error( ‘rest_unauthorised’, __( ‘Only authenticated users can access the REST API.’, ‘rest_unauthorised’ ), array( ‘status’ => rest_authorization_required_code() ) ); } return $result; }Continue reading
Allow SVG Files Upload (copy)
/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading
Allow SVG Files Upload (copy)
/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading
WhatsApp Button to WooCommerce Single Product Pages
/** * Enqueue script and styles for child theme */ function woodmart_child_enqueue_styles() { wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array( ‘woodmart-style’ ), woodmart_get_theme_info( ‘Version’ ) ); } add_action( ‘wp_enqueue_scripts’, ‘woodmart_child_enqueue_styles’, 10010 ); define(‘ALLOW_UNFILTERED_UPLOADS’, true); function add_whatsapp_buttonlux() { ?> // Please enter…Continue reading