Skip to content

Instantly share code, notes, and snippets.

@parsafatehi
parsafatehi / wp-config.php
Created April 23, 2023 12:17 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
We can't make this file beautiful and searchable because it's too large.
1,google.com
2,youtube.com
3,facebook.com
4,baidu.com
5,wikipedia.org
6,qq.com
7,amazon.com
8,yahoo.com
9,taobao.com
10,tmall.com
@parsafatehi
parsafatehi / regex-a-tag
Created August 9, 2022 11:07
regex for finding a tag with specific string
<\s*a[^>]*>(YOUR_STRING)<\s*\/\s*a>
@parsafatehi
parsafatehi / woocommerce_attributes_query.sql
Created January 17, 2022 12:02 — forked from zarei-dev/woocommerce_attributes_query.sql
woocommerce attributes sql query
SELECT
t.term_id AS 'Attribute Value ID',
TRIM('pa_' FROM tt.taxonomy) AS 'Attribute Name',
t.name AS 'Attribute Value',
COUNT(t.name) as 'num'
FROM
wp_posts AS p
INNER JOIN wp_term_relationships AS tr
ON
p.ID = tr.object_id
@parsafatehi
parsafatehi / redirect.nginx
Created November 7, 2021 07:35
Redirect to a different domain - NGINX
# Redirect to a different domain
server {
server_name .domain1.com;
return 301 https://domain2.com$request_uri;
}
@parsafatehi
parsafatehi / backup.sh
Last active October 23, 2021 21:50 — forked from bradt/backup.sh
Simple WordPress Backups v2
#!/bin/bash
# Change WP_PATH with your WordPress installation path
cd /WP_PATH
NOW=$(date +%Y%m%d%H%M%S)
SQL_FILE=${NOW}_database.sql
# Backup database
wp db export ../backups/$SQL_FILE --add-drop-table
@parsafatehi
parsafatehi / wp-local-remote-image.txt
Last active August 16, 2021 17:11
Load WordPress remote images if they don't exist on the local Nginx.
location ~ ^/wp-content/uploads/(.*) {
if (!-f $request_filename) {
rewrite ^/wp-content/uploads/(.*)$ http://REMOTE_DOMAIN.com/wp-content/uploads/$1 redirect;
}
}
@parsafatehi
parsafatehi / zoho-webmail-redirect.nginx
Last active November 7, 2021 07:37
Redirect subdomain to a URL with Nginx (e.g. Zoho webmail custom mail URL)
server {
listen 80;
server_name webmail.DOMAIN.com;
rewrite ^(.*) https://mail.zoho.com/zm/#mail/views/unread$1 permanent;
}
server {
listen 443 ssl;
server_name webmail.DOMAIN.com;
rewrite ^(.*) https://mail.zoho.com/zm/#mail/views/unread$1 permanent;
@parsafatehi
parsafatehi / css_resources.md
Created October 22, 2013 20:56 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides