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
<?php
class MyTheme
{
private function actionAfterSetup($function)
{
add_action('after_setup_theme', function() use ($function) {
$function();
});
}
@pavlo-bondarchuk
pavlo-bondarchuk / psl-theme-test.txt
Created April 12, 2022 15:37 — forked from bph/psl-theme-test.txt
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 / wp_ext_pll_functions.php
Created March 16, 2022 17:43 — forked from icetee/wp_ext_pll_functions.php
Polylang function_exists (active the plugin) - WordPress - Paste the code into functions.php
/*
* Polylang Language API functions tester - WordPress
* Github: https://gist.github.com/icetee/fbbfef5534fead58611e
*
*/
function ex_pll_the_languages($arg = '') {
if ( function_exists('pll_the_languages') ) {
return pll_the_languages($arg);
}
/**
* Allow to remove method for an hook when, it's a class method used and class don't have variable, but you know the class name :)
* source: https://github.com/herewithme/wp-filters-extras
* More: http://wordpress.stackexchange.com/questions/57079/how-to-remove-a-filter-that-is-an-anonymous-object
*/
function remove_filters_for_anonymous_class( $hook_name = '', $class_name ='', $method_name = '', $priority = 0 ) {
global $wp_filter;
// Take only filters on right hook name and priority
if ( !isset($wp_filter[$hook_name][$priority]) || !is_array($wp_filter[$hook_name][$priority]) )
@pavlo-bondarchuk
pavlo-bondarchuk / .js
Created September 10, 2021 12:41
count text
document.addEventListener('DOMContentLoaded', function(event) {
var $ = jQuery;
if (!$('body').hasClass('wp-admin')) {
$(window).on('loads scroll', function() {
var element = $('.counter');
var top_of_element = element.offset().top;
var bottom_of_element = element.offset().top + element.outerHeight();
var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight();
var top_of_screen = $(window).scrollTop();
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created August 12, 2021 15:00
add a products per-page select dropdown to archive - above shop productloop
// add a products per-page select dropdown to archive - above shop productloop
add_action( 'woocommerce_before_shop_loop', 'pro_selectbox', 30 );
function pro_selectbox() {
$per_page = filter_input(INPUT_GET, 'perpage', FILTER_SANITIZE_NUMBER_INT);
$orderby_options = array(
'16' => '16',
'32' => '32',
'64' => '64',
'96' => '96'
);
@pavlo-bondarchuk
pavlo-bondarchuk / php
Created August 3, 2021 07:11
randomizer_product_category_tag_attribute
add_shortcode( 'randomizer_product_category_tag_attribute', 'randomizer_product_category_tag_attribute_func' );
function randomizer_product_category_tag_attribute_func( ){
$attribute = get_field('attributy', 'attributes');
$taxonomy = array();
$id = array();
if(!empty($attribute)){
foreach ($attribute as $term) {
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Last active May 15, 2021 19:47
set only these mce-button on specific acf wysiwyg field
add_action(
'acf/input/admin_footer',
static function () {
?>
<script type="text/javascript">
(function ($) {
acf
.add_filter(
'wysiwyg_tinymce_settings',
@pavlo-bondarchuk
pavlo-bondarchuk / gist:88d9ce83de048fa72e47da4451b4339f
Created May 15, 2021 19:44 — forked from mattheu/gist:508d3246eea566e6fa33
Tidy Up WordPress TinyMCE 4 editor buttons
<?php
// Modify Tiny_MCE init
add_filter('tiny_mce_before_init', 'tmy_modify_tinyMCE4', 10, 2 );
/**
* Filter TinyMCE4 Init args.
*/
function tmy_modify_tinyMCE4( $mceInit, $editor_id ) {
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created May 7, 2021 16:41
Use ACF Pro for Simple, Local Avatars
<?php
/**
* Use ACF image field as avatar
* @author Mike Hemberger - Thank you, Mike :)
* @link http://thestizmedia.com/acf-pro-simple-local-avatars/
* @uses ACF Pro image field (tested return value set as Array )
*/
add_filter('get_avatar', 'tsm_acf_profile_avatar', 10, 5);
function tsm_acf_profile_avatar( $avatar, $id_or_email, $size, $default, $alt ) {