Skip to content

Instantly share code, notes, and snippets.

View pavlo-bondarchuk's full-sized avatar
🏠
remote

Pavlo Bondarchuk pavlo-bondarchuk

🏠
remote
View GitHub Profile
@futtta
futtta / autoptimize_defer_inline_jquery.php
Last active November 11, 2022 21:43
POC to defer inline JS that requires jQuery
<?php
add_action('plugins_loaded','ao_defer_inline_init');
function ao_defer_inline_init() {
if ( get_option('autoptimize_js_include_inline') != 'on' ) {
add_filter('autoptimize_html_after_minify','ao_defer_inline_jquery',10,1);
}
}
function ao_defer_inline_jquery( $in ) {
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created June 22, 2019 10:13
popup on event adding_to_cart
//add_action('wp_footer', 'show_template');
add_action(
'wp_footer',
function() {
?>
<script>jQuery( function( $ ) {
// Цепляемся за событие adding_to_cart
$( document.body ).on( 'adding_to_cart', function( event, button ) {
// Выцепляем инициатора события (ссылка/кнопка)
var $btn = $( button[0] );
@ihorvorotnov
ihorvorotnov / functions.php
Last active March 17, 2021 10:01
Painless 3rd party marketing scripts in WordPress
<?php
// Enqueue all js codes combined in a single file.
function enqueue_theme_assets()
{
wp_enqueue_script(
'trackers',
get_stylesheet_directory_uri() . '/js/trackers.js',
null,
null,
@erikyo
erikyo / wordpress_preload_featured_image.php
Last active July 10, 2024 10:24
Wordpress preload featured image (src and srcset)
@petermann
petermann / Disable WP REST API - Contact Form 7 Endpoints
Created April 28, 2023 18:54
Automatically Enable Contact Form 7 Endpoints with Disable WP REST API Plugin
/**
* Automatically Enable Contact Form 7 Endpoints with Disable WP REST API Plugin
* Plugin URI: https://wordpress.org/plugins/disable-wp-rest-api/
*/
function disable_wp_rest_api_enable_contact_form7_endpoints() {
$active_plugins = get_option('active_plugins');
// Check if the "Disable WP REST API" plugin is active
if (in_array('disable-wp-rest-api/disable-wp-rest-api.php', $active_plugins)
// Check if the "Contact Form 7" plugin is active
&& in_array('contact-form-7/wp-contact-form-7.php', $active_plugins)
@evtihii
evtihii / custom-languge-swicther-schortcode.php
Created July 13, 2023 10:37
Translatepress custom language switcher shortcode
<?php
/*
* Custom language switcher shortcode
*/
function trpc_language_switcher($atts)
{
ob_start();
global $TRP_LANGUAGE;
@pavlo-bondarchuk
pavlo-bondarchuk / custom-languge-swicther-schortcode.php
Created July 13, 2023 19:02 — forked from evtihii/custom-languge-swicther-schortcode.php
Translatepress custom language switcher shortcode
<?php
/*
* Custom language switcher shortcode
*/
function trpc_language_switcher($atts)
{
ob_start();
global $TRP_LANGUAGE;