Skip to content

Instantly share code, notes, and snippets.

View webdevs-pro's full-sized avatar

Alex Ishchenko webdevs-pro

View GitHub Profile
@webdevs-pro
webdevs-pro / index.html
Created December 13, 2021 15:50
Elementor custom animated progress bar with waypoint
<div class="pref-progress" data-percent="50">
<div class="pref-bar"><div class="pref-perc">0%</div></div>
</div>
<br>
<div class="pref-progress" data-percent="72">
<div class="pref-bar"><div class="pref-perc">0%</div></div>
</div>
<br>
<div class="pref-progress" data-percent="99">
<div class="pref-bar"><div class="pref-perc">0%</div></div>
function initDHtooltips() {
// tolltips
$( document ).on( 'mouseenter', '[data-dh-tooltip]', function() {
clearTimeout( $( this ).data( 'dh-tooltip-timeout-id' ) );
var prevTooltip = $( this ).find( '.tooltip' );
if ( prevTooltip.length > 0 ) return false;
$( this ).append( '<div class="tooltip"><div class="tooltip-wrapper"><span>' + $( this ).data( 'dh-tooltip' ) + '</span></div><div class="tooltip-trangle"></div></div>' );
@webdevs-pro
webdevs-pro / index.php
Created October 16, 2021 17:32
WP set default page template for new post
<?php
add_action( 'wp_insert_post', 'filter_function_name_11', 10, 3 );
function filter_function_name_11( $post_id, $post, $update ) {
update_post_meta( $post_id, '_wp_page_template', 'elementor_canvas' );
}
@webdevs-pro
webdevs-pro / page-update.php
Created October 3, 2021 18:02
Elementor data widget controls updater
<?php
function update_controls( $elements ) {
$new_elements = array();
foreach ( $elements as $element_index => $element ) {
foreach ( $element as $key => $value ) {
if ( $key == 'elements' && ! empty( $value ) ) {
$new_elements[$element_index][$key] = update_controls( $value );
@webdevs-pro
webdevs-pro / index.js
Created June 24, 2021 07:40
Remove event from element
$.each($._data($('.elementor-control')[0], "events"), function(i, event) {
$.each(event, function(j, h) {
if(h.selector == '[contenteditable=\"true\"]') {
handler = h.handler;
}
});
});
$('.elementor-control').unbind('input', handler); // fix contenteditable update control
@webdevs-pro
webdevs-pro / index.html
Created May 7, 2021 06:18
Swiper carousel with thumbnails (Elementor)
<script>
function defer(method) {
if (window.jQuery) {
method();
} else {
setTimeout(function() { defer(method) }, 50);
}
}
@webdevs-pro
webdevs-pro / index.php
Created April 16, 2021 03:29
Compare multidimensional arrays in PHP
<?php
//results for array1 (when it is in more, it is in array1 and not in array2. same for less)
function compare_multi_Arrays($array1, $array2){
$result = array("more"=>array(),"less"=>array(),"diff"=>array());
foreach($array1 as $k => $v) {
if(is_array($v) && isset($array2[$k]) && is_array($array2[$k])){
$sub_result = compare_multi_Arrays($v, $array2[$k]);
//merge results
foreach(array_keys($sub_result) as $key){
if(!empty($sub_result[$key])){
@webdevs-pro
webdevs-pro / gist:749980e978a410f3e9c01e39dc33bcc4
Created February 12, 2021 05:45 — forked from rugor/gist:1decc15655891825d15a7024a06d898b
PHP: WordPress echo SVG file contents for inline SVG
<?php echo file_get_contents( get_stylesheet_directory_uri() . '/img/awesome.svg' ); ?>
@webdevs-pro
webdevs-pro / index.js
Created February 8, 2021 20:49
Disable Elementor smooth scroll to ID
var change_elementor_options = function() {
if ( typeof elementorFrontend === 'undefined' ) {
return;
}
elementorFrontend.on( 'components:init', function() {
elementorFrontend.utils.anchors.setSettings( 'selectors.targets', '.dummy-selector' );
} );
};
<?php
\Elementor\Plugin::$instance->db->switch_to_post( 895 );
echo \Elementor\Plugin::instance()->frontend->get_builder_content_for_display(1250);
\Elementor\Plugin::$instance->db->restore_current_post();
// $current_id = get_the_ID();
// echo $id;
// \Elementor\Plugin::$instance->db->switch_to_post( 895 );