Skip to content

Instantly share code, notes, and snippets.

Yurii Taran yuriitaran

Block or report user

Report or block yuriitaran

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cloudSettings
{"lastUpload":"2020-01-05T20:47:00.036Z","extensionVersion":"v3.4.3"}
View Get formatted date in JS
// Attaching a new function toShortFormat() to any instance of Date() class
Date.prototype.toShortFormat = function() {
const months = ["Jan","Feb","Mar", "Apr","May","Jun", "Jul","Aug","Sep", "Oct","Nov","Dec"];
const day = this.getDate();
const monthIndex = this.getMonth();
const year = this.getFullYear();
return "" + day + "-" + months[monthIndex] + "-" + year;
View gist:aa971217fe97f3efb60b829ae0241bdd
/*
* Add SVG to allowed file uploads
*/
add_filter( 'upload_mimes', function ( $mimes = array() ) {
// allow SVG file upload
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
});
@yuriitaran
yuriitaran / gist:f885b4c5e7b165dea84e599a448a1fbf
Last active Apr 20, 2019
WP: remove Visual Composer scripts from front-end
View gist:f885b4c5e7b165dea84e599a448a1fbf
add_action('wp_print_scripts', function () {
wp_deregister_script('wpb_composer_front_js');
wp_dequeue_script('wpb_composer_front_js');
}, 100);
@yuriitaran
yuriitaran / gist:cf21203245ac19b22918635a48d6b38b
Created Dec 5, 2018
Opencart get all language variables in controller
View gist:cf21203245ac19b22918635a48d6b38b
$data = $this->load->language('module/latest');
@yuriitaran
yuriitaran / responsive-video.css
Created Nov 27, 2018 — forked from jaicab/responsive-video.css
Pure CSS solution for embed videos with an aspect ratio of 16:9
View responsive-video.css
.video-container {
position: relative;
padding-bottom: 56.25%; /*16:9*/
padding-top: 30px;
height: 0;
overflow: hidden;
}
.video-container iframe,
.video-container object,
@yuriitaran
yuriitaran / WP: Remove 100 post limit for RESR API
Created Nov 26, 2018
WP: Remove 100 post limit for RESR API
View WP: Remove 100 post limit for RESR API
add_filter( 'rest_endpoints', function( $endpoints ){
if ( ! isset( $endpoints['/wp/v2/posts'] ) ) {
return $endpoints;
}
unset( $endpoints['/wp/v2/posts'][0]['args']['per_page']['maximum'] );
return $endpoints;
});
//
@yuriitaran
yuriitaran / javascript sorting
Last active Feb 20, 2019
Javascript sorting
View javascript sorting
// sort array of objects by items value ('jobId')
data.sort((a, b) => {
if (a.jobId > b.jobId) {
return -1
} else if (a.jobId < b.jobId) {
return 1
} else {
return 0
}
})
@yuriitaran
yuriitaran / helpers-write-log.php
Created Nov 14, 2018 — forked from kostiantyn-petlia/helpers-write-log.php
Logging function write_log() for debugging process
View helpers-write-log.php
// -----------------------------------------------------------------------------
/**
* Logging to debug.log in DEBUG_LOG_DIR dir (default is the root site dir)
*
* Note: You can define in the wp-config.php:
* 1) define( 'DEBUG_LOG_DIR', dirname( __FILE__ ) . '/' );
* 2) define( 'DEBUG_LOG_INVERTED', false);
*
* Author K
@yuriitaran
yuriitaran / functions.php
Last active Nov 12, 2018
Retrieving data from Wordpress REST API
View functions.php
wp_enqueue_script( 'wp-rest', get_template_directory_uri() . '/js/wp-rest.js', null, null, true );
// Posts custom fields
function prepare_rest($data, $post, $request){
$_data = $data->data;
$_data['custom_fields'] = get_post_meta($post->ID); // retrieving all post meta fields
return $_data;
}
add_filter('rest_prepare_post', 'prepare_rest', 10, 3);
You can’t perform that action at this time.