This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Hold money. | |
* Hold customer's money in loyalty program. Payment will be process on POS during processing of an order. | |
* | |
* Удерживание денег клиентов в программе лояльности. Оплата будет произведена на POS-терминале во время обработки заказа. | |
* | |
* @param string $customerId | |
* @param string $walletId | |
* @param int|string $sum | |
* @param string|null $comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Livewire 3 component - TinyMce editor | |
* | |
* 1. Add component to LiveWire folder in project | |
* 2. Register component, for example add node to AppServiceProvider boot method: Blade::component('editor', Editor::class); | |
* 3. Register route for file uploader : | |
* Route::middleware(['web', 'auth'])->post('/tinymce/upload', function (Request $request) { | |
* $disk = $request->disk ?? 'public'; | |
* $folder = $request->folder ?? 'editor'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function true_logged_in_user_content( $atts, $content = null ) { | |
if(!class_exists('\iiko\bonuses\Bonuses')){ | |
return 'Ошибка вывода баланса. woo2iiko не подключен'; | |
} | |
$bonuses = \iiko\bonuses\Bonuses::getInstance(); | |
if ( is_user_logged_in() && !is_null( $content ) && !is_feed() ) { | |
$balance = $bonuses->get_user_balances(); | |
return 'Ваш бонусный баланс: ' . ($balance ?: '0'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Вывод / Удаление файлов из директории по шаблону | |
*/ | |
// создание | |
foreach ( array_fill(0, 6, '// silence is golden') as $key => $value) { | |
if (!file_exists("АВР № $key.php")) { | |
file_put_contents("АВР № $key.php", $value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spl_autoload_register(function ($className){ | |
if ( strpos( $className, __NAMESPACE__ ) !== 0 ) { | |
return; | |
} | |
$className = str_replace(__NAMESPACE__ . '\\', 'includes\\', $className); | |
$path = realpath(__DIR__) . DIRECTORY_SEPARATOR . strtr($className, '\\', DIRECTORY_SEPARATOR) . '.php'; | |
if (is_readable($path)) { | |
require_once $path; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Пример создания и использования атрибутов PHP 8 | |
*/ | |
// Объявление атрибута | |
#[Attribute] | |
final class MyAttribute | |
{ | |
public $value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_before_thankyou', function ($wc_order_id){ | |
$wc_order = wc_get_order($wc_order_id); | |
if (empty($wc_order) || $wc_order->has_status('failed')) { | |
return; | |
} | |
$wc_order->update_meta_data('deliveryDurationInMinutes', ''); | |
$wc_order->save_meta_data(); | |
}, 5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* WordPress Autoload classes. | |
*/ | |
spl_autoload_register( function ( $full_class_name ) { //phpcs:ignore PEAR.Functions.FunctionCallSignature | |
if ( strpos( $full_class_name, __NAMESPACE__ ) !== 0 ) { // . '\Core' | |
return; // Not in the plugin namespace, don't check. | |
} | |
$full_class_name = strtolower( str_replace( '_', '-', $full_class_name ) ); | |
$class_parts = explode( '\\', $full_class_name ); | |
unset( $class_parts[0] ); // Unset the __NAMESPACE__. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// WP AJAX example | |
class WP_AJAX_Example{ | |
/** | |
* Add WP actions. Must be called only once. | |
* @return void | |
*/ | |
public function add_actions(){ |
NewerOlder