Skip to content

Instantly share code, notes, and snippets.

View ValeriiVasyliev's full-sized avatar
🏄
Focusing

Valerii Vasyliev ValeriiVasyliev

🏄
Focusing
View GitHub Profile
@ValeriiVasyliev
ValeriiVasyliev / aux-functions.php
Created August 8, 2019 08:25 — forked from eduwass/duplicate-post.php
Programmatically duplicating a WordPress post
<?php
/**
* Duplicates a post & its meta and it returns the new duplicated Post ID
* @param [int] $post_id The Post you want to clone
* @return [int] The duplicated Post ID
*/
function duplicate($post_id) {
$title = get_the_title($post_id);
$oldpost = get_post($post_id);
@ValeriiVasyliev
ValeriiVasyliev / .htaccess
Created May 5, 2020 09:44 — forked from siffring/.htaccess
htaccess to password protect a specific server
# ----------------------------------------------------------------------
# Password protect staging server
# Use one .htaccess file across multiple environments
# (e.g. local, dev, staging, production)
# but only password protect a specific environment.
# ----------------------------------------------------------------------
SetEnvIf Host staging.domain.com passreq
AuthType Basic
AuthName "Password Required"
@ValeriiVasyliev
ValeriiVasyliev / acf5_get_acf_field_groups_by_cpt.php
Created May 13, 2020 19:54 — forked from sunriseweb/acf5_get_acf_field_groups_by_cpt.php
Get ACF (Advanced Custom Field) field groups with their fields for a given custom post type. i.e. where the ACF location rule is "post_type == cpt".
/**
* Returns an array of field groups with fields for the passed CPT, where field group ACF location rule of "post_type == CPT" exists.
* - each field group points at an array of its fields, in turn pointed at an array of that field's detailed information:
* - array of info for each field [ ID, key, label, name, type, menu_order, instructions, required, id, class, conditional_logic[array()], etc. ]
*
* @since 1.0.0
*/
function get_acf_field_groups_by_cpt($cpt) {
// need to create cache or transient for this data?
<?php if (($wp_query->current_post +1) == ($wp_query->post_count)) {
echo 'This is the last post';
} ?>
<?php if (($wp_query->current_post +1) != ($wp_query->post_count)) {
echo 'This is the not the last post';
} ?>
@ValeriiVasyliev
ValeriiVasyliev / wordpress_terms_clauses_sorting.txt
Created October 17, 2020 19:16 — forked from ontiuk/wordpress_terms_clauses_sorting.txt
WordPress: Taxonomy Meta Sorting With Terms_Clauses Filter
add_filter( 'terms_clauses', 'filter_terms_clauses', 10, 3 );
/** 
* Filter WP_Term_Query meta query 
* @param   object  $query  WP_Term_Query 
* @return  object 
*/
function filter_terms_clauses( $pieces, $taxonomies, $args ) {
global $pagenow, $wpdb;    
@ValeriiVasyliev
ValeriiVasyliev / git-auto-deploy.md
Created November 29, 2020 12:54 — forked from yosukehasumi/git-auto-deploy.md
Setting Up Git-Auto-Deploy on Digital Ocean

Install software-properties-common

sudo apt-get install software-properties-common

Add Repo

sudo add-apt-repository ppa:olipo186/git-auto-deploy
@ValeriiVasyliev
ValeriiVasyliev / functions.php
Created December 15, 2020 20:26 — forked from jaredatch/functions.php
WordPress Search Autocomplete using admin-ajax.php
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@ValeriiVasyliev
ValeriiVasyliev / functions.php
Created December 23, 2020 16:11 — forked from mrwweb/functions.php
Example Child Theme Files
<?php
/*
Important!
Make sure to replace {my_} with your theme's unique prefix.
All future functions you write should use that same prefix.
Example: mrwnten_parent_theme_enqueue_styles()
*/
add_action( 'wp_enqueue_scripts', '{my_}parent_theme_enqueue_styles' );
@ValeriiVasyliev
ValeriiVasyliev / README.md
Created January 13, 2021 21:43 — forked from developius/README.md
Setup SSH keys for use with GitHub/GitLab/BitBucket etc
@ValeriiVasyliev
ValeriiVasyliev / .gitignore
Created January 13, 2021 21:43 — forked from redoPop/.gitignore
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your