Skip to content

Instantly share code, notes, and snippets.

View yaroslav-borodii's full-sized avatar
😁
Working from home

Yaroslav Borodii yaroslav-borodii

😁
Working from home
View GitHub Profile
@yaroslav-borodii
yaroslav-borodii / wp-permissions-script
Last active June 14, 2024 10:46 — forked from macbleser/wp-permissions-script
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=$1 # <-- wordpress owner
WP_GROUP=$1 # <-- wordpress group
WP_ROOT=$2 # <-- wordpress root directory
@yaroslav-borodii
yaroslav-borodii / wp-permissions-script
Created June 14, 2024 10:40 — forked from macbleser/wp-permissions-script
WordPress Permissions Configuration Script
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro
#
WP_OWNER=changeme # <-- wordpress owner
WP_GROUP=changeme # <-- wordpress group
WP_ROOT=/home/changeme # <-- wordpress root directory
@yaroslav-borodii
yaroslav-borodii / wp-local-setup-proxy.sh
Last active March 6, 2024 02:39
The script automates the configuration of a WordPress (WP) site to proxy missing media files from a production server, by modifying Nginx settings.
#!/bin/bash
# wp-local-setup-proxy.sh
# Automates the configuration of a WordPress (WP) site to proxy missing media files from a production server.
# -----------------------------------------------------------------------------------------
# To use this script from anywhere on your system, follow these steps:
# For macOS and Linux:
#
# Using one line:
@yaroslav-borodii
yaroslav-borodii / nf-get-sub-by-seq.php
Last active May 23, 2023 19:34
Retrieves a Ninja Forms submission by its form ID and sequence number.
<?php
/**
* Retrieves a Ninja Forms submission by its form ID and sequence number.
*
* @param int|string $form_id The ID of the form.
* @param int|string $seq The sequence number of the submission.
*
* @return NF_Database_Models_Submission Returns an NF_Database_Models_Submission from Ninja Forms
*/
if ( function_exists( 'Ninja_Forms' ) && ! function_exists( 'nf_get_sub_by_seq' ) ) {
@yaroslav-borodii
yaroslav-borodii / smooth-vertical-page-scroll.js
Created March 14, 2023 12:16
Smooth vertical scrolling on mouse wheel in vanilla javascript
/**
* Smooth Vertical Scrolling on mouse wheel in vanilla JavaScript
*/
function init(){
new SmoothScroll(document, 30, 18)
}
function SmoothScroll(target, speed, smooth) {
if (target === document)
target = (document.scrollingElement
@yaroslav-borodii
yaroslav-borodii / acf_save_custom_select_options.php
Last active December 7, 2022 20:22
Save custom select options
<?php
/**
* Save custom select options
*
**/
function acf_save_custom_select_options( $value, $post_id, $field ) {
if ( ! $field['allow_custom'] || ! $field['{theme_name}_save_custom'] ) {
return $value;
}
@yaroslav-borodii
yaroslav-borodii / add-rel-nofollow-checkbox.php
Last active October 16, 2022 20:22 — forked from danielbachhuber/add-rel-nofollow-checkbox.php
Add a link style to the WordPress link editor
<?php
/**
* Add a link style to the WordPress link editor
*
*/
add_action(
'after_wp_tiny_mce',
function() {
?>
@yaroslav-borodii
yaroslav-borodii / gist:4fd10e4e2bf749654df42c5d28e82367
Created September 19, 2022 10:27
WP: Replace initial format select with custom
/*
* TinyMCE Custom Styles
* https://codex.wordpress.org/TinyMCE_Custom_Styles
*/
// Callback function to insert 'styleselect' into the $buttons array
function my_mce_buttons( $buttons ) {
unset( $buttons[0] );
array_unshift( $buttons, 'styleselect' );
return $buttons;