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 / .sql
Created May 22, 2020 09:40
Update ALL postmeta specifications
UPDATE wp_postmeta SET meta_value = 'yes' WHERE meta_key like '_specifications_display_attributes'
@pavlo-bondarchuk
pavlo-bondarchuk / finctions.php
Created May 21, 2020 16:59
WooCommerce Enable Reviews - Bulk Edit
/**
*
* Plugin Name: WooCommerce Enable Reviews - Bulk Edit
* Description: Allow enable reviews by bulk edit into WooCommerce
* Version: 1.0.0
* Author: Mário Valney
* Author URI: http://mariovalney.com
* Text Domain: woo-enable-reviews-bulk-edit
*
*/
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created May 21, 2020 15:28
PHP Snippet: Move Related Products to a Tab – WooCommerce
/**
* @snippet Checkbox to display Custom Product Badge Part 1 - WooCommerce
* @how-to Get CustomizeWoo.com FREE
* @source https://businessbloomer.com/?p=17419
* @author Rodolfo Melogli
* @compatible Woo 3.5.3
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
// First, let's remove related products from their original position
@pavlo-bondarchuk
pavlo-bondarchuk / .js
Created April 25, 2020 18:58
at-spectr
jQuery(document).ready(function($){
var el = $('.realfactory-header-wrap');
var top = $(el).offset().top + $(document).scrollTop();
var el_height = $(el).height();
$(document).scroll(function(){
var scrollTop = $(document).scrollTop();
var $logo = $( '<div class="logo"></div>');
console.log(scrollTop);
if ( scrollTop > el_height && !el.is('.highlighted') ){
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created March 27, 2020 10:50
woocommerce checkout - login user if email exists
add_action( 'woocommerce_before_checkout_process', 'wc_before_checkout_process', 999 ); // hook, function name, priority
function wc_before_checkout_process(){ // function name
foreach ( WC()->cart->get_cart() as $cart_item ) { // loop wc cart
$item_id = $cart_item['data']->get_id(); // item id
$is_ticket = get_post_meta( $item_id, '_tutor_product', true ); // get post meta field '_tutor_product'
if( $is_ticket ){ // if ticket
if( isset( $_POST['primarycontactemail'] ) ){ // if field exists
if ( !empty( $_POST['primarycontactemail'] ) ){ // if field not empty
if ( ! is_user_logged_in() ) { // if user not logged in
nocache_headers(); // clear headers
@pavlo-bondarchuk
pavlo-bondarchuk / manage_columns_wp_admin.php
Created February 28, 2020 10:58 — forked from vishalkakadiya/manage_columns_wp_admin.php
Manage custom columns with sortable in WordPress Admin side
<?php
/*
* =================================================================================================
* Below both hooks works for custom post types.
* e.g. Suppose we have custom post-type name : Books
* @ref https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
* =================================================================================================
*/
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created February 22, 2020 22:53
after new user registration login new user automatically by link in welcome email and redirect to admin dashboard
/*
This code snippet can be added to your functions.php file (without the <?php)
to add a query string to the login link emailed to the user upon registration
which when clicked will validate the user, log them in, and direct them to
the home page.
*/
/**
* This first function is hooked to the 'user_register' action which fires
* during the new user registration process. The process here gets some of
@pavlo-bondarchuk
pavlo-bondarchuk / finctions.php
Created February 5, 2020 14:25
HOW TO USE ADVANCED CUSTOM FIELDS TO CREATE USER GROUPS
// https://www.quickcleancode.com/how-to-use-advanced-custom-fields-to-create-user-groups/
add_action('publish_post', 'notifyauthor');
function notifyauthor() {
$loop = new WP_Query(array('post_type' => 'groups', 'posts_per_page' => -1, 'order' => 'ASC'));
while ($loop->have_posts()) : $loop->the_post();
if(have_rows('members')):
while (have_rows('members')) : the_row();
@pavlo-bondarchuk
pavlo-bondarchuk / hide-course-complete-btn.php
Created February 5, 2020 12:43
Hide Course complete button until complete all lessons in Tutor LMS
/**
* Hide Course complete button until complete all lessons in Tutor LMS
*
*/
add_filter('tutor_course/single/complete_form', 'tutor_lms_hide_course_complete_btn');
function tutor_lms_hide_course_complete_btn($html){
$completed_lesson = tutils()->get_completed_lesson_count_by_course();
$lesson_count = tutils()->get_lesson_count_by_course();
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created February 1, 2020 16:50
Removing default Dashboard Widgets
function wporg_remove_all_dashboard_metaboxes() {
// Remove Welcome panel
remove_action( 'welcome_panel', 'wp_welcome_panel' );
// Remove the rest of the dashboard widgets
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'health_check_status', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal');
}