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 / functions.php
Last active January 30, 2020 13:35
class MetaBox
class trueMetaBox {
function __construct($options) {
$this->options = $options;
$this->prefix = $this->options['id'] .'_';
add_action( 'add_meta_boxes', array( &$this, 'create' ) );
add_action( 'save_post', array( &$this, 'save' ), 1, 2 );
}
function create() {
foreach ($this->options['post'] as $post_type) {
if (current_user_can( $this->options['cap'])) {
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created January 18, 2020 14:36
Modify a Custom Post Type after it’s been registered
function grd_client_filter_products_cpt( $args, $post_type ) {
// If not courses CPT, bail.
if ( 'courses' !== $post_type ) {
return $args;
}
// Add additional courses CPT options.
$args = array(
'has_archive' => false,
);
// Merge args together.
@pavlo-bondarchuk
pavlo-bondarchuk / .js
Created January 7, 2020 12:54
How to Submit an HTML Form to Google Sheets…without Google Forms
var $form = $('form#telegram'),
url = 'https://script.google.com/macros/s/------/exec'
$('.telegram').submit(function (e) {
e.preventDefault();
$.ajax({
url: url,
method: "GET",
dataType: "json",
data: $(this).serialize()
@pavlo-bondarchuk
pavlo-bondarchuk / inside.css
Created December 28, 2019 03:18
custom css inside hero menu plugin admin area
#hmenu_load_2 .hmenu_navigation_holder > ul{position:relative;}
#hmenu_load_2 .hmenu_mega_sub{width: max-content;}
.hmenu_text_item a{color:#666!important;}
.hmenu_text_item a:hover{color:#cc6600!important;}
.hmenu_col_6 {width: max-content;}
.hmenu_col_3 {width: max-content;}
#hmenu_load_2 .hmenu_navigation_holder > ul li a .hmenu_nav_uni_9 span{display:none!important;}
#hmenu_load_2 .hmenu_navigation_holder > ul li a .hmenu_nav_uni_10 span {
display: none;
}
@pavlo-bondarchuk
pavlo-bondarchuk / header.php
Created December 28, 2019 03:15
integration hero menu plugin in enfold child theme - replace start with line 74
<!--//https://heroplugins.com/product/hero-menu/documentation/?section=knowledge_base&article=Enfold//-->
<?php
if(!$blank) //blank templates dont display header nor footer
{
if(!class_exists( 'hmenu_frontend')){
//fetch the template file that holds the main menu, located in includes/helper-menu-main.php
get_template_part( 'includes/helper', 'main-menu' );
} else {
// wp_nav_menu( array( 'theme_location' => 'avia' ) );
echo do_shortcode( "[hmenu id=2]" );
@pavlo-bondarchuk
pavlo-bondarchuk / custom.js
Created December 28, 2019 03:04
search in hero menu implementation - ambir project
jQuery(document).ready(function( $ ){
//$('.searchicon a').attr('data-avia-search-tooltip', '<form action="https://www.ambir.com/" id="searchform" method="get" class=""><div><input type="submit" value="" id="searchsubmit" class="button avia-font-entypo-fontello" /><input type="text" id="s" name="s" value="" placeholder="Search" /></div></form>');
$('.searchicon').append('<div class="avia-search-tooltip avia-tt" style="top: 95px; left: -138.5px; display: none; opacity: 1;"><div class="inner_tooltip"><form action="https://www.ambir.com/" id="searchform" method="get" class=""><div><input type="submit" value="" id="searchsubmit" class="button avia-font-entypo-fontello" style="background: #cc6600;color: #fff;"><input type="text" id="s" name="s" value="" placeholder="Search"></div></form></div><span class="avia-arrow-wrap"><span class="avia-arrow"></span></span></div>');
$('.searchicon a').click(function(e){
e.preventDefault();
console.log('click');
$('.avia-search-tooltip').toggle();
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Last active December 13, 2019 18:00
Create Custom Primary Contact Information Fields if Cart contains Virtual Products @ WooCommerce Checkout
add_action( 'woocommerce_after_checkout_billing_form', 'primary_contact_fields' );
function primary_contact_fields( $checkout ){
if( is_virtual() ) {
echo '</div>';
echo '<div class="woocommerce-primary_contact-fields" style="float:left;">';
echo '<h3>Primary Contact Information</h3>';
echo '<div class="woocommerce-primary_contact-fields__field-wrapper">';
woocommerce_form_field( 'primarycontactname', array(
'type' => 'text', // text, textarea, select, radio, checkbox, password, about custom validation a little later
'required' => true, // actually this parameter just adds "*" to the field
@pavlo-bondarchuk
pavlo-bondarchuk / google_shop_feed.php
Last active November 14, 2019 10:42
quick generate google_shop_feed.xml on wordpress
<?php
require_once( dirname( __FILE__ ) . '/wp-load.php' );
$args = array(
'post_type' => 'product',
'posts_per_page' => 9999999
);
@pavlo-bondarchuk
pavlo-bondarchuk / srcset.php
Created September 25, 2019 11:34 — forked from verticalgrain/srcset.php
Wordpress srcset snippet for ACF image field
<?php
// Use an ACF image field
// Set the 'return value' option to "array" (this is the default)
// This example uses three image sizes, called medium, medium_large, thumbnail
$imageobject = get_field('image');
if( !empty($imageobject) ):
echo '<img alt="' . $imageobject['title'] . '" src="' . $imageobject['sizes']['medium'] . '" srcset="' . $imageobject['sizes']['medium_large'] .' '. $imageobject['sizes']['medium_large-width'] .'w, '. $imageobject['sizes']['medium'] .' '. $imageobject['sizes']['medium-width'] .'w, '. $imageobject['sizes']['thumbnail'] .' '. $imageobject['sizes']['thumbnail-width'] .'w">';
endif;
?>
@pavlo-bondarchuk
pavlo-bondarchuk / dividing_the_menu_in_half.php
Created August 6, 2019 14:39 — forked from campusboy87/dividing_the_menu_in_half.php
Деление WordPress меню пополам
<?php
add_filter( 'wp_nav_menu_objects', function ( $menu_items, $args ) {
if ( $args->theme_location !== 'menu-1' ) {
return $menu_items;
}
static $average_cnt = null;
static $items = [];
if ( $average_cnt === null ) {