Skip to content

Instantly share code, notes, and snippets.

/.idea
/.vscode
/.vs
/node_modules
/vendor
@Muetze42
Muetze42 / Plesk: Additional deployment actions
Last active March 3, 2022 20:27
Plesk: Additional deployment actions
/opt/plesk/php/8.1/bin/php artisan config:clear
/opt/plesk/php/8.1/bin/php /usr/lib/plesk-9.0/composer.phar install --optimize-autoloader --no-dev
/opt/plesk/php/8.1/bin/php artisan migrate --force
/opt/plesk/php/8.1/bin/php artisan view:clear
/opt/plesk/php/8.1/bin/php artisan optimize
@Muetze42
Muetze42 / add-windows-context-menu-item.bat
Last active November 10, 2021 09:51
Tested with Windows 11, but should work with older Windows Versions too (Example with Umlauts for Mp3tag)
goto comment
/*
|--------------------------------------------------------------------------
| Instruction
|--------------------------------------------------------------------------
|
| * With Notepadd++
| * [For specialchars and Umlauts] `Encoding` => `Convert to ANSI`
| * [For specialchars and Umlauts] `Language` => `M` => `MS-Dos Style`
@Muetze42
Muetze42 / NovaNoDuplicateRelations.php
Last active November 10, 2021 09:51
Nova: Prevent duplicate relation attachment
<?php
namespace App\Traits\Nova;
use Illuminate\Database\Eloquent\Builder;
use Laravel\Nova\Http\Controllers\AttachableController;
use Laravel\Nova\Http\Requests\NovaRequest;
trait NoDuplicateRelations
{
@Muetze42
Muetze42 / wp-override-templates-via-plugin.php
Last active March 21, 2022 12:51
WordPress: Override Templates Via Plugin
<?php
define('VENDOR_PLUGIN_TEMPLATE_PATH', plugin_dir_path( __FILE__ ).'/templates/');
function override_template( $template, $template_name, $template_path ) {
$originTemplate = $template_path.$template_name;
$pluginTemplate = VENDOR_PLUGIN_TEMPLATE_PATH.$originTemplate;
if(file_exists($pluginTemplate)) {
$template = $pluginTemplate;
@Muetze42
Muetze42 / wp-contact-form-7-skip-sending-mail.php
Last active March 21, 2022 12:51
WordPress: Contact Form 7 Skip sending Mail
<?php
add_filter('wpcf7_skip_mail', function ($skip_mail, $contact_form) {
$skip = [
'1',
'2',
'3',
];
return in_array($contact_form->id(), $skip);
@Muetze42
Muetze42 / nova-indexquery-default-order.php
Last active November 10, 2021 09:52
Laravel Nova: indexQuery Default order
<?php
/**
* The column by which to sort as default
*
* @var string
*/
public static string $defaultSort = '';
/**
@Muetze42
Muetze42 / nova-check-if-filter-is-active.php
Last active November 10, 2021 09:52
Laravel Nova: Check if filter is active
<?php // Functions
if (!function_exists('decodeNovaFilter')) {
/**
* Decode the filter string from base64 encoding.
*
* @param string $filtersRequestString
* @return array
*/
function decodeNovaFilter(string $filtersRequestString): array
{
@Muetze42
Muetze42 / hide-shipping-rates-when-free-shipping-is-available.php
Last active March 21, 2022 12:51
WordPress: Hide other shipping methods when “Free Shipping” is available
<?php
// Source: https://woocommerce.com/document/hide-other-shipping-methods-when-free-shipping-is-available/
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
@Muetze42
Muetze42 / functions.php
Last active March 29, 2022 20:52
WordPress WooCommerce: Add Revisions For Products
<?php
add_filter( 'woocommerce_register_post_type_product', 'wc_add_revision_support' );
function wc_add_revision_support( $args ) {
$args['supports'][] = 'revisions';
return $args;
}