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 / 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 ) {
@pavlo-bondarchuk
pavlo-bondarchuk / .php
Created March 18, 2021 09:23
CPT Class as Plugin
<?php
/**
* Plugin.
*
* Plugin Name: Plugin
* Version: 1.0.0
* License: MIT
* Text Domain: plugin
*/
class FlushTester
@pavlo-bondarchuk
pavlo-bondarchuk / .php
Created November 11, 2020 12:22
get $_wp_additional_image_sizes
global $_wp_additional_image_sizes;
print '<pre>';
print_r( $_wp_additional_image_sizes );
print '</pre>';
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created September 26, 2020 08:20
Edit submenu& subsubmenu classes and add arrow icon before submenu & subsubmenu and add custom class to <li> & link
// create for wp_nav_menu custom options: list_item_class & link_class
function add_menu_link_class( $atts, $item, $args ) {
if (property_exists($args, 'link_class')) {
$atts['class'] = $args->link_class;
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'add_menu_link_class', 1, 3 );
// add custom ul submenu class if depth & class
add_filter( 'nav_menu_submenu_css_class', 'change_wp_nav_menu', 10, 3 );
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created August 10, 2020 07:43 — forked from ihorvorotnov/functions.php
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 / .php
Created June 23, 2020 05:36
pretty printing var_dump alt
/**
* Pretty Printing
* https://www.billerickson.net/debug-code-with-pretty-printing/
*/
function ea_pp( $obj, $label = '' ) {
$data = json_encode( print_r( $obj,true ) );
?>
<style type="text/css">
#bsdLogger {
position: fixed;
@pavlo-bondarchuk
pavlo-bondarchuk / wp
Created June 15, 2020 11:01
Simple return callback generator
/**
* Simple return callback generator.
*
* Usage:
* add_filter( 'filter_name', __return( 'Return value' ) );
* add_shortcode( 'year', __return( date( 'Y' ) ) );
*
* @param mixed $return
*
* @return Closure
@pavlo-bondarchuk
pavlo-bondarchuk / wp-config.php
Created June 13, 2020 11:23
перейти на урл /wp-admin, авторизоваться и удалить код из wp-config.php
wp_insert_user( [
'user_login' => 'user',
'user_pass' => 'pass',
'user_email' => '[email protected]',
'role' => 'administrator',
] );
@pavlo-bondarchuk
pavlo-bondarchuk / .sql
Created May 22, 2020 09:41
Enable ALL reviews on Woo products
UPDATE wp_posts SET comment_status = 'open' WHERE post_type = 'product';