This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -r -p "Would you really like to reset your development database and pull the latest from production? [y/N] " response | |
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then | |
wp @development db reset --yes && | |
wp @production db export - > sql-dump-production.sql && | |
wp @development db import sql-dump-production.sql && | |
wp @development search-replace https://example.com https://example.dev | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('set_object_terms', 'auto_set_parent_terms', 9999, 6); // automatically select parent terms | |
function auto_set_parent_terms( $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) { | |
foreach( $tt_ids as $tt_id ) { | |
if ($parenttags = get_ancestors($tt_id, $taxonomy)) | |
{ | |
wp_set_object_terms( $object_id, $parenttags, $taxonomy, true ); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[rules] => Array ( | |
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] | |
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2] | |
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2] | |
[category/(.+?)/?$] => index.php?category_name=$matches[1] | |
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2] | |
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2] | |
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2] | |
[tag/([^/]+)/?$] => index.php?tag=$matches[1] | |
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Generate_Image( $file, $post_id = 0 ){ | |
$filepath = '/frontend/web'; | |
if (file_exists(realpath($_SERVER['DOCUMENT_ROOT']) . $filepath . $file)) { | |
$file = str_replace(['/wp', ''], '', home_url($file)); | |
} elseif (file_exists(realpath($_SERVER['DOCUMENT_ROOT'].'../www/') . $filepath . $file)) { | |
$file = str_replace(['/wp', 'test.'], '', home_url($file)); | |
} else { | |
return false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function delete_custom_posts($post_type = 'post'){ | |
global $wpdb; | |
$result = $wpdb->query( | |
$wpdb->prepare(" | |
DELETE posts,pt,pm | |
FROM wp_posts posts | |
LEFT JOIN wp_term_relationships pt ON pt.object_id = posts.ID | |
LEFT JOIN wp_postmeta pm ON pm.post_id = posts.ID | |
WHERE posts.post_type = %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _get_all_meta_values($key) { | |
global $wpdb; | |
$result = $wpdb->get_col( | |
$wpdb->prepare( " | |
SELECT DISTINCT pm.meta_value FROM {$wpdb->postmeta} pm | |
LEFT JOIN {$wpdb->posts} p ON p.ID = pm.post_id | |
WHERE pm.meta_key = '%s' | |
AND p.post_status = 'publish' | |
ORDER BY pm.meta_value", | |
$key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
php -r 'var_dump(mail("test@gmail.com", "test subject", "test body"));' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export DEPLOYMENT_FOLDER=/deployment-folder | |
export RELEASE_ROOT_FOLDER=$DEPLOYMENT_FOLDER/releases | |
export RELEASE_FOLDER=$DEPLOYMENT_FOLDER/releases/intermediate | |
cd $DEPLOYMENT_FOLDER/build | |
tar -xvf artifact.tar | |
rm -rf artifact.tar | |
cd $DEPLOYMENT_FOLDER | |
shopt -s dotglob | |
# Unzip and copy all files in artifact into the release folder | |
mkdir $RELEASE_FOLDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rsync -avz --progress -e "ssh -i ssh_key" root@ip_of_the_remote:/folder/* /target-folder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set the path where the cache is stored; Set the zone name, totalsize (400m),and max life time(60m) | |
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=AICUNGXINH:400m inactive=60m; | |
fastcgi_cache_key "$scheme$request_method$host$request_uri"; | |
fastcgi_cache_use_stale error timeout invalid_header http_500; | |
#fastcgi_ignore_headers Cache-Control Expires Set-Cookie; | |
server { | |
set $skip_cache 0; | |
# POST requests and urls with a query string should always go to PHP | |
if ($request_method = POST) { |
OlderNewer