Skip to content

Instantly share code, notes, and snippets.

View bulentsakarya's full-sized avatar
🎯
Focusing

Bülent Sakarya bulentsakarya

🎯
Focusing
View GitHub Profile
@tprinty
tprinty / Adding Logging to Laravel Authentication
Last active July 14, 2024 04:32
Add Logging to Lavavel Authentication
Here is a quick way to add authentication logging to Laravel.
1. Modify app/Providers/EventServiceProvider.php and add lines 16 through 32 of the example file in this GIST.
2. Create a new file app/Listeners/LogActivity.php and copy the contents of the file below into that file.
3. Enjoy logging.
@nginx-gists
nginx-gists / ubuntu_install.sh
Last active August 6, 2024 22:32
Automating Installation of WordPress with NGINX Unit on Ubuntu
#!/usr/bin/env bash
if [ "$EUID" -ne 0 ];then
>&2 echo "This script requires root level access to run"
exit 1
fi
if [ -z "${WORDPRESS_DB_PASSWORD}" ]; then
>&2 echo "WORDPRESS_DB_PASSWORD must be set"
>&2 echo "Here is a random one that you can paste:"
@harslannet
harslannet / woocommerce-tr-fields.php
Last active September 8, 2021 08:58
Woocommerce ödeme sayfasında bireysel müşteriler için T.C. numarası kurumsal müşteriler için vergi numarası alanını ekleme.
<?php
/*
* Çalışma koşulu şu şekilde;
* Ödeme ekranına geldiğinde müşteri varsayılan olarak T.C. alanını görecek ama araştırdığım ve öğrendiğim kadarıyla sadece 5000 TL ve üstü siparişler için T.C. numarası zorunluymuş bu yüzden zorunlu olmayacak.
* Zorunlu olmamasına rağmen eğer müşteri buraya yanlış bir T.C. yazarsa doğrulamadan geçecek ve eğer yazmak istemiyorsa boş bırakması için uyarı mesajı gelecek
* Eğer firma adına fatura isterse Kurumsal Sipariş Checkbox'ını işaretleyerek T.C. alanı gizlenecek ve vergi dairesi ile vergi numarası alanı gözükecek ve bu alanlar zorunlu olacak
* Not: T.C. numarası ve Vergi Numarası doğrulamadan geçiyor.
* Eksikler: T.C. Numarasını boş bırakabildikleri için veri tabanına o sipariş için 11111111111 yazdırmayı başaramadım. ->
* Ama 147. satırdaki kod sipariş ekranında bu bilgiyi gösteriyor, bunu nasıl yaparız bilen varsa yazsın ->
* Aslında 'default' => 11111111111 ile veritabanına bunu yazdırabilirim ama bunu set edince sipariş ekranında bu numaranın gözükmesi hoşuma git
<?php
add_action( 'woocommerce_thankyou', 'redirect_product_based', 1 );
function redirect_product_based ( $order_id ){
$order = wc_get_order( $order_id );
foreach( $order->get_items() as $item ) {
// Add whatever product id you want below here
if ( $item['product_id'] == 643 ) {
// change below to the URL that you want to send your customer to
@emir
emir / tax_validation.php
Last active December 26, 2023 18:40
PHP Vergi Numarası Doğrulama
<?php
/**
* This method logically validates Turkish VAT number
*
* @param string $taxNumber
* @return bool
*/
public function validateTaxNumber(string $taxNumber): bool
{
@ajskelton
ajskelton / WP Customizer - Select
Last active May 14, 2024 04:54
Add a Select field to the WordPress Customizer.
$wp_customize->add_setting( 'themeslug_select_setting_id', array(
'capability' => 'edit_theme_options',
'sanitize_callback' => 'themeslug_sanitize_select',
'default' => 'value1',
) );
$wp_customize->add_control( 'themeslug_select_setting_id', array(
'type' => 'select',
'section' => 'custom_section', // Add a default or your own section
'label' => __( 'Custom Select Option' ),
@danielbachhuber
danielbachhuber / query-params.php
Last active March 13, 2016 20:04
Compare query arguments supported by each WP REST API endpoint
<?php
/**
* Prepare a table comparing query arguments supported by each endpoint
*
* wp eval-file query-params --skip-wordpress
*/
$endpoints = array(
'posts' => '/wp/v2/posts',
'pages' => '/wp/v2/pages',
'media' => '/wp/v2/media',
@claudiosanches
claudiosanches / functions.php
Last active June 4, 2022 07:52
WooCommerce - Add Order Again button to My Orders actions
<?php
/**
* Add order again button in my orders actions.
*
* @param array $actions
* @param WC_Order $order
* @return array
*/
function cs_add_order_again_to_my_orders_actions( $actions, $order ) {
if ( $order->has_status( 'completed' ) ) {
@sjozsef
sjozsef / Pure Bootstrap Contact Form 7 template
Last active March 23, 2023 10:03
bootstrap-contact-form-7.html
<hr />
<div class="row">
<div class="col-md-4">
[text* your-name class:form-control placeholder "Name (required)"]
</div>
<div class="col-md-4">
[email* your-email class:form-control placeholder "Email (required)"]