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
@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;
@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;
@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)
@erikyo
erikyo / wordpress_preload_featured_image.php
Last active July 10, 2024 10:24
Wordpress preload featured image (src and srcset)
@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,
@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] );
@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 ) {
<?php
class MyTheme
{
private function actionAfterSetup($function)
{
add_action('after_setup_theme', function() use ($function) {
$function();
});
}
@bph
bph / psl-theme-test.txt
Last active October 19, 2023 15:21
Blocks for Themes Test
<!-- wp:paragraph -->
<p><a href="https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e">https://gist.github.com/bph/335ddef358bb41efdcd159cbc76f582e</a></p>
<!-- /wp:paragraph -->
<!-- wp:heading {"className":"eplus-oOhLNH"} -->
<h2 class="eplus-oOhLNH">Common Blocks / Formatting / Layout Elements / Widgets and Embeds</h2>
<!-- /wp:heading -->
<!-- wp:list {"className":"eplus-eI3gin"} -->
<ul class="eplus-eI3gin"><li><a href="#images">Images</a> (Single image, cover image, gallery </li><li><a href="#quotes">Pull Quote / Quote</a></li><li><a href="#verse">Verse</a></li><li><a href="#buttons">Buttons</a></li><li><a href="#socialicons" data-type="internal" data-id="#socialicons">Social Icons</a></li><li><a href="#columns">Columns </a> Text (only) columns / Columns experimental</li><li><a href="#cover" data-type="internal" data-id="#cover">Cover</a> with CAT + button</li><li><a href="#paragraphs">Paragraph</a> </li><li><a href="#audio">Audio</a> </li><li><a href="#video">Video</a></li><li><a href="#w
@pavlo-bondarchuk
pavlo-bondarchuk / .php
Last active May 9, 2018 10:32
statements meta is type of page & lang
<?php if(is_archive() && ICL_LANGUAGE_CODE == 'ru'){
echo '<meta name="description" content="Программы курсов по охране труда и обучению рабочим специальностям учебно-консультационного центра по охране труда «ПРОФИТЕХ»">';
}?>
<?php if(is_archive() && ICL_LANGUAGE_CODE == 'uk'){
echo '<meta name="description" content="Програми курсів з охорони праці та навчання робітничим спеціальностям навчально-консультаційного центру з охорони праці «ПРОФІТЕХ»">';
}?>
<?php if($paged > 1 || is_author() || is_tag() || is_date() || is_attachment()){
echo '<meta name="robots" content="noindex,follow" />';
} ?>