Skip to content

Instantly share code, notes, and snippets.

View shivapoudel's full-sized avatar
🎯
Focusing

Shiva Poudel shivapoudel

🎯
Focusing
View GitHub Profile
@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 / quotefancy.py
Last active June 19, 2021 13:39
Scraped wallpapers from Quotefancy.com
import shutil
import os
import requests
from bs4 import BeautifulSoup
# URL handlers to scraped.
url_handles = [
'motivational-quotes',
'inspirational-entrepreneurship-quotes',
@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 / 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(
@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 / 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 / functions.php
Last active February 24, 2023 05:29
WordPress - Enable Dashicons in Frontend
<?php // Do not include this if already open!
/**
* Code goes in theme functions.php.
*/
add_action( 'wp_enqueue_scripts', 'load_dashicons_front_end' );
/**
* Enqueue the Dashicons script.
*/
@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 / 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
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.
*/