Skip to content

Instantly share code, notes, and snippets.

View shivapoudel's full-sized avatar
🎯
Focusing on React and User Interfaces.

Shiva Poudel shivapoudel

🎯
Focusing on React and User Interfaces.
View GitHub Profile
@shivapoudel
shivapoudel / functions.php
Last active August 27, 2023 14:01
WooCommerce - Automatically delete attached images after product deletion
<?php
/**
* Delete attached images after product deletion.
*
* @since 1.0.0
*
* @see wp_delete_post()
*
* @param int $post_id Post ID.
*/
@shivapoudel
shivapoudel / fix-wordpress-permissions.sh
Last active April 9, 2023 19:32 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=nobody # <-- wordpress owner
WP_GROUP=nogroup # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@shivapoudel
shivapoudel / functions.php
Created February 24, 2023 05:42
Redirect homepage depending on country code.
<?php // Do not include this if already open!
/**
* Return the country code.
*
* @since 1.0.0
*/
function get_user_country_code() {
return 'GB'; // This is main United Kingdom front page.
}
@shivapoudel
shivapoudel / woocommerce-hidden-products-from-cart.php
Last active January 13, 2023 04:12
Exclude hidden products from cart area.
<?php
/**
* Filter hidden product from cart.
*
* @since 1.0.0
*
* @param bool $visibility Visibility.
* @param array $cart_item Cart item.
* @param string $cart_item_key Cart item key.
*/
@shivapoudel
shivapoudel / action-schedular.php
Last active January 29, 2022 08:49
Action Schedular queue in loop
<?php
function args_update() {
$loop = 0;
$args = array(
'name',
'surname'
);
foreach ( $args as $arg ) {
WC()->queue()->schedule_single(
@shivapoudel
shivapoudel / Learn.php
Last active April 9, 2021 11:52
Learning some PHP use cases!
<?php
class Logger {
public function log( $message ) {
return "LOG : {$message}" . PHP_EOL;
}
}
interface MailSentAction {
public function sent( $message );
@shivapoudel
shivapoudel / functions.php
Last active July 21, 2020 07:30
Everest Forms - Support reCAPTCHA v2 Language code. (Updated for 1.7.0)
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_filter( 'everest_forms_frontend_recaptcha_url', 'evf_recaptcha_lang_code', 10, 2 );
/**
* Language code support for reCAPTCHA v2.
*
@shivapoudel
shivapoudel / 1-git.md
Last active February 19, 2023 19:47
WSL setup for Ubuntu environment.

Installing Git on WSL

Git appears to come as standard as part of the WSL install. You can test this by running:

$ git --version

If for some reason Git is not installed then you can simply pull it down:

@shivapoudel
shivapoudel / local-restore.md
Last active December 12, 2023 20:57
How can I restore a site from a Local site folder?

In case you are just needing to restore a Local site from an existing Local site folder, here’s how:

Note: There must be SQL files present in app/sql in order for this to work. Otherwise, the database won’t be able to be restored.

  1. Rename htdocs with htdocs-backup.
  2. Create new sites for each using existing domains and paths. Now go to Open Site SSH and browse the directory.
D:
cd ..
@shivapoudel
shivapoudel / functions.php
Created November 22, 2019 11:38
Everest Forms display form entries with a custom shortcode.
<?php
/**
* Custom shortcode to display form entries.
*
* Usage [everest_forms_entries_table id="FORMID"]
*
* @param array $atts Shortcode attributes.
*/
function evf_entries_table( $atts ) {
$atts = shortcode_atts(