Skip to content

Instantly share code, notes, and snippets.

View kaskad88's full-sized avatar

Dmytro Bartoshchak kaskad88

  • Ukraine
View GitHub Profile
@kaskad88
kaskad88 / Create alt date post meta ( timestamp )
Last active August 30, 2019 10:34
Create alt date post meta ( timestamp )
add_action( 'save_post_event', '__your_prefix__save_event_start_date_timestamp', 10, 3 );
function __your_prefix__save_event_start_date_timestamp( $post_id, $post, $update ) {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
$event_start_date = $_POST[ 'event_start_date' ];
add_filter( 'wp_dropdown_cats', 'remove_spacing_wp_dropdown_cats', 10, 2 );
function remove_spacing_wp_dropdown_cats( $output, $args ) {
if ( $args['name'] === 'jet_ajax_search_categories' ) {
$output = str_replace( ' ', '', $output );
}
return $output;
}
@kaskad88
kaskad88 / HDquiz & JetPopup compatibility
Last active November 4, 2019 14:54
HDquiz & JetPopup compatibility
add_action( 'elementor/widget/before_render_content', function( $widget ) {
if ( 'shortcode' !== $widget->get_name() ) {
return;
}
if ( false === strpos( $widget->get_settings_for_display( 'shortcode' ), '[HDquiz quiz' ) ) {
return;
}
/**
* Adding custom icon to icon control in Elementor
*/
function jet_add_custom_icons_tab( $tabs = array() ) {
// Append new icons
$new_icons = array(
'account',
'airplane',
'wordpress',
add_filter( 'jet-engine/listing/grid/posts-query-args', function ( $args ) {
if ( in_array( 'tribe_events', $args['post_type'] ) ) {
$args['suppress_filters'] = true;
}
return $args;
} );
function cf_search_join( $join ) {
if ( is_admin() || ! is_search() ) {
return $join;
}
global $wpdb;
$join .= " LEFT JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id ";
add_action( 'init', function () {
global $wp_scripts;
$script = $wp_scripts->query( 'imagesloaded', 'registered' );
if ( ! $script ) {
return;
}
if ( ! in_array( 'jquery', $script->deps ) ) {
add_filter( 'the_posts', '__search_by_sku' );
function __search_by_sku( $posts ) {
if ( is_admin() || ! is_search() ) {
return $posts;
}
$ignoreIds = array( 0 );
foreach ( $posts as $post ) {
add_filter( 'jet-engine/listings/filters-list', function( $list ) {
$list['posts_list_by_ids'] = array(
'cb' => '__custom_posts_list_by_ids',
'args' => false,
);
return $list;
} );
@kaskad88
kaskad88 / javascript.translit.js
Created April 3, 2020 14:57 — forked from croisillon/javascript.translit.js
JavaScript translater russian to translit
function rus_to_latin ( str ) {
var ru = {
'а': 'a', 'б': 'b', 'в': 'v', 'г': 'g', 'д': 'd',
'е': 'e', 'ё': 'e', 'ж': 'j', 'з': 'z', 'и': 'i',
'к': 'k', 'л': 'l', 'м': 'm', 'н': 'n', 'о': 'o',
'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u',
'ф': 'f', 'х': 'h', 'ц': 'c', 'ч': 'ch', 'ш': 'sh',
'щ': 'shch', 'ы': 'y', 'э': 'e', 'ю': 'u', 'я': 'ya'
}, n_str = [];