Skip to content

Instantly share code, notes, and snippets.

@Ercogx
Ercogx / WordPressStage
Created July 9, 2025 17:07
Cloudpanel Vhost Templates
#{"rootDirectory":"","phpVersion":"8.3"}
server {
listen 80;
listen [::]:80;
listen 443 ssl http2;
listen [::]:443 ssl http2;
{{ssl_certificate_key}}
{{ssl_certificate}}
{{server_name}}
{{root}}
@Ercogx
Ercogx / country-code-to-currency-code-mapping.csv
Created June 19, 2024 12:00 — forked from HarishChaudhari/country-code-to-currency-code-mapping.csv
Country, Country Code, Currency code mapping in CSV format Taken from https://gist.github.com/304261 Contains 249 countries.
Country CountryCode Currency Code
New Zealand NZ New Zealand Dollars NZD
Cook Islands CK New Zealand Dollars NZD
Niue NU New Zealand Dollars NZD
Pitcairn PN New Zealand Dollars NZD
Tokelau TK New Zealand Dollars NZD
Australian AU Australian Dollars AUD
Christmas Island CX Australian Dollars AUD
Cocos (Keeling) Islands CC Australian Dollars AUD
Heard and Mc Donald Islands HM Australian Dollars AUD
@Ercogx
Ercogx / .gitignore
Created February 20, 2024 10:38
WP gitignore
# Author @Zubonick
# Default log files, DB, archives, etc.
*.log
*.sql
*.zip
*.sqlite
*.7z
*.dmg
*.gz
@Ercogx
Ercogx / nginx.conf
Created August 15, 2023 16:58
rewrite webp nginx
location ~* \.(jpe?g|png|gif|tif?f|bmp)$ {
add_header Cache-Control max-age=31536000;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
log_not_found off;
expires max;
if ($http_accept ~* "webp") {
set $webp "accept";
}
@Ercogx
Ercogx / export_user.php
Created January 21, 2023 12:19
Export User Wp CLI
<?php
class ExportUser {
public function __invoke() {
$allUserByRole = count_users()['avail_roles']['subscriber'];
$usersCSV = fopen( 'users_export.csv', 'w' );
for ( $i = 0; $i <= $allUserByRole; $i += 1000 ) {
$user_query = new WP_User_Query( [
'role' => 'Subscriber',
@Ercogx
Ercogx / functions.php
Last active April 5, 2022 15:53
WC coupon code in checkout form
<?php
// Add a custom coupon field before checkout payment section
add_action( 'woocommerce_checkout_order_review', 'woocommerce_checkout_coupon_form_custom' );
function woocommerce_checkout_coupon_form_custom() {
?>
<div class="add_gift_card_form coupon-fictitious-form">
<h4>Have a coupon?</h4>
<div id="wc_gc_cart_redeem_form">
<input placeholder="Coupon code" type="text" name="coupon_code" id="wc_gc_cart_code" autocomplete="off">
@Ercogx
Ercogx / _0__ssl_certbot_letsencrypt.md
Created August 1, 2021 17:06 — forked from maxivak/_0__ssl_certbot_letsencrypt.md
Let's encrypt SSL certificates using certbot in docker

Directories on host machine:

  • /data/certbot/letsencrypt

  • /data/certbot/www

  • Nginx server in docker container

docker run -d --name nginx \
@Ercogx
Ercogx / WP upload image by url.php
Created June 6, 2021 13:59
Uploading images from the url path to the product when we only have a sku. The first picture will be made the main, others will be added to the gallery.We also turn off all wp image_sizes, so as not to create duplicates
add_action('wp_print_scripts', function (){
foreach ( get_intermediate_image_sizes() as $size ) {
if ( !in_array( $size, array( 'thumbnail') ) ) {
remove_image_size( $size );
}
}
if(isset($_GET['import_image']) && $_GET['import_image'] === 'yes'){
require_once ABSPATH . 'wp-admin/includes/media.php';
require_once ABSPATH . 'wp-admin/includes/file.php';
function save_image($img,$path){
if (file_exists($path)){
return;
}
$curl = curl_init($img);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_BINARYTRANSFER,1);
$content = curl_exec($curl);
curl_close($curl);
@Ercogx
Ercogx / functions.php
Created November 11, 2020 20:48 — forked from maxkostinevich/functions.php
WP-Admin: Add fields to Gallery Settings
<?php
add_action('print_media_templates', function(){
// define your backbone template;
// the "tmpl-" prefix is required,
// and your input field should have a data-setting attribute
// matching the shortcode name
?>
<script type="text/html" id="tmpl-my-custom-gallery-setting">
<label class="setting">