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 / 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 / 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 ) {
@pavlo-bondarchuk
pavlo-bondarchuk / README.php.detect_os.md
Created March 20, 2019 10:35
PHP: Detect user's operating system

Usage

It's that simple:

$os = getOS($_SERVER['HTTP_USER_AGENT']);

echo $os;
@pavlo-bondarchuk
pavlo-bondarchuk / blockClicks.js
Created December 28, 2018 14:18 — forked from lucas-pelton/blockClicks.js
Prevent multiple clicks and submissions in Contact Form 7
//http://epsiloncool.ru/programmirovanie/preventing-multiple-submits-in-contact-form-7
jQuery(document).on('click', '.wpcf7-submit', function(e){
if( jQuery('.ajax-loader').hasClass('is-active') ) {
e.preventDefault();
return false;
}
});
@pavlo-bondarchuk
pavlo-bondarchuk / Convert strings to slugs
Created December 22, 2018 20:46 — forked from vrushank-snippets/Convert strings to slugs
PHP : Convert strings to slugs
function slug($str){
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return $str;
}
@pavlo-bondarchuk
pavlo-bondarchuk / WP - get custom post
Created December 20, 2018 23:02 — forked from gianlucacandiotti/WP - get custom post
Get all posts for a custom post type and query them.
<?php
$type = 'custom_post_type';
$args = array(
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts'=> true
);
$my_query = null;
$my_query = new WP_Query($args);
<?php if ( get_field( 'field_name' ) ): ?>
This is displayed when the field_name is TRUE or has a value.
<?php else: // field_name returned false ?>
This is displayed when the field is FALSE, NULL or the field does not exist.
<?php endif; // end of if field_name logic ?>
@pavlo-bondarchuk
pavlo-bondarchuk / functions.php
Created May 7, 2018 14:27 — forked from braginteractive/extras.php
WordPress Filter to change the Custom Logo class
/**
* Changes the class on the custom logo in the header.php
*/
function helpwp_custom_logo_output( $html ) {
$html = str_replace('custom-logo-link', 'navbar-brand', $html );
return $html;
}
add_filter('get_custom_logo', 'helpwp_custom_logo_output', 10);