Skip to content

Instantly share code, notes, and snippets.

View nickalexej's full-sized avatar

Nick Alexej nickalexej

View GitHub Profile
@nickalexej
nickalexej / product expiration woocommerce code snippet.php
Created February 24, 2023 16:37
Dieser Code enthält eine Funktion check_product_expiry(), die alle Produkte mit einem Ablaufdatum durchläuft und alle Produkte auf "Entwurf" setzt, deren Ablaufdatum erreicht ist. Die Überprüfung des Ablaufdatums wird einmal täglich mithilfe des wp_schedule_event()-Hooks geplant. Außerdem enthält der Code eine Funktion product_expiry_date_field(…
// Ablaufdatum- und Ablaufzeit-Felder zum Produkt hinzufügen
add_action('woocommerce_product_options_general_product_data', 'add_product_expiration_date_field');
function add_product_expiration_date_field() {
woocommerce_wp_text_input(array(
'id' => '_expiration_date',
'label' => __('Ablaufdatum', 'woocommerce'),
'type' => 'date',
'desc_tip' => true,
'description' => __('Geben Sie das Ablaufdatum für das Produkt ein.', 'woocommerce')
));
@nickalexej
nickalexej / Disabel Wordpress Rest API
Created February 21, 2023 16:03
deaktiviert die restapi für nicht authentifizierte user
<?
add_filter( 'rest_authentication_errors', 'disable_rest_api' );
function disable_rest_api( $access ) {
return new WP_Error( 'rest_disabled', __( 'The WordPress REST API has been disabled on this site.' ), array( 'status' => rest_authorization_required_code() ) );
}
@nickalexej
nickalexej / close an elementor hamburger menu on click.
Created November 26, 2022 08:31
Hamburger Menu click on close
// Gist for CodeSnippet Plugins
<?php
echo "<script id='elementor-menu-close'>
document.addEventListener('DOMContentLoaded', function () {
document.body.addEventListener('click', function (event) {
if (!event.target.closest('.elementor-nav-menu--toggle') && document.querySelector('.elementor-menu-toggle.elementor-active')) {
document.querySelector('.elementor-menu-toggle.elementor-active').click();
}
});
});
@nickalexej
nickalexej / Shopify delivery note with German Text
Created September 28, 2022 09:33
Translate delivery note template from English to German
<div class="wrapper">
<div class="header">
<div class="shop-title">
<p class="to-uppercase">
{{ shop.name }}
</p>
</div>
<div class="order-title">
<p class="text-align-right">
Bestellung: {{ order.name }}
@nickalexej
nickalexej / function.php
Created January 31, 2021 18:44 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
exit;
}