Skip to content

Instantly share code, notes, and snippets.

View ValeriiVasyliev's full-sized avatar
🏄
Focusing

Valerii Vasyliev ValeriiVasyliev

🏄
Focusing
View GitHub Profile
<?php
/**
* WordPress WP_User_Query Comprehensive Reference
* Compiled by wpsmith - wpsmith.net
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_User_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.4.1/wp-includes/user.php
*/
$args = array(
@ValeriiVasyliev
ValeriiVasyliev / Resync git repo with new .gitignore file.md
Created February 22, 2022 02:42
Resync git repo with new .gitignore file
# rm all files
git rm -r --cached .
# add all files as per new .gitignore
git add .
# now, commit for new .gitignore to apply
git commit -m ".gitignore is now working"
@ValeriiVasyliev
ValeriiVasyliev / wp-cli-fully-updating-in-one-command.md
Last active January 23, 2024 08:42
WP-CLI: Fully updating a website with one command
wp core update && wp plugin update --all && wp theme update --all && wp core language update
@ValeriiVasyliev
ValeriiVasyliev / woocommerce-delete-all-orders-by-mysql.md
Created February 7, 2022 15:21
Woocommerce : delete all orders by mysql
DELETE FROM wp_woocommerce_order_itemmeta;
DELETE FROM wp_woocommerce_order_items;
DELETE FROM wp_comments WHERE comment_type = 'order_note';
DELETE FROM wp_postmeta WHERE post_id IN ( SELECT ID FROM wp_posts WHERE post_type = 'shop_order' );
DELETE FROM wp_posts WHERE post_type = 'shop_order';
# This script removes all multidevs for a given environment.
# Pass the site as the first argument.
# E.g. ./terminus-multidev-delete-all.sh my-pantheon-site
SITE=$1
MULTIDEVS=$(terminus multidev:list $SITE --field=Name)
for ENV in $MULTIDEVS
do
@ValeriiVasyliev
ValeriiVasyliev / wordpress-bulk-delete-all-images.md
Created February 1, 2022 09:26
WordPress : bulk deleter all images
DELETE FROM `wp_posts` WHERE `post_type` = "attachment";

DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attached_file";

DELETE FROM `wp_postmeta` WHERE `meta_key` = "_wp_attachment_metadata";

DELETE FROM `wp_postmeta` WHERE `meta_key` = "_thumbnail_id";

UPDATE `wp_postmeta` SET `meta_value` = NULL WHERE `meta_key` = "_product_image_gallery";
@ValeriiVasyliev
ValeriiVasyliev / wordpress-change-domain-after-transfer.md
Created February 1, 2022 09:15
WordPress : change a domain after transfer
UPDATE wp_options SET option_value = replace(option_value, 'oldurl.com', 'newurl.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET guid = replace(guid, 'oldurl.com','newurl.com');

UPDATE wp_posts SET post_content = replace(post_content, 'oldurl.com', 'newurl.com'); 

UPDATE wp_postmeta SET meta_value = replace(meta_value,'oldurl.com','newurl.com');
@ValeriiVasyliev
ValeriiVasyliev / wp-query-ref.php
Created December 10, 2021 20:28 — forked from luetkemj/wp-query-ref.php
WP: Query $args
// This gist is now maintained on github at https://github.com/luetkemj/wp-query-ref
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
<?php
/**
* Read ACF fields from JSON
*/
function PREFIX_acf_register_json_fields() {
if (function_exists("acf_add_local_field_group")) {
$acf_json_data = locate_template("path/to/advanced-custom-fields.json");
$custom_fields = $acf_json_data ? json_decode(file_get_contents($acf_json_data), true) : array();
foreach ($custom_fields as $custom_field) {
@ValeriiVasyliev
ValeriiVasyliev / wordpress-admin-remove-unnecessary fields.md
Created November 2, 2021 10:23
WordPress Admin : remove unnecessary fields
class AdminUsers
{

    private $plugin;

    public function __construct(Plugin $plugin)
    {