Skip to content

Instantly share code, notes, and snippets.

View EdenK's full-sized avatar

Eden Kindil EdenK

  • SHIBI
  • ישראל
View GitHub Profile
@EdenK
EdenK / wp-elementor-nav-menu-breakpoint.scss
Created July 16, 2018 14:00
Wordpress: Elementor Pro change nav menu breakpoint css
@media (max-width: 1299px) {
body .elementor-nav-menu--dropdown-tablet .elementor-nav-menu--dropdown {
display: block;
}
body .elementor-nav-menu--dropdown-tablet .elementor-menu-toggle {
display: flex;
}
}
@media (min-width: 1300px) {
@EdenK
EdenK / wp-set-child-page-template.php
Last active August 2, 2023 13:30
Wordpress: Auto set page template for child pages to be the same as parent.
<?php
/**
* Wordpress: Auto set page template for child pages to be the same as parent.
*/
function set_child_page_template( $post_id, $post, $update ) {
// Check for post type page
if( $post->post_type === 'page' ) {
// Check if its a child page
if( $post->post_parent !== 0 ) {
// If its child get the post parent template
@EdenK
EdenK / wp-wpml-elementor-library.php
Last active October 11, 2018 16:30
Wordpress: WPML & Elementor fix for elementor library translations (Header etc..).
<?php
/**
* Wordpress: WPML & Elementor fix for elementor library translations (Header etc..).
*/
function wpml_elementor_library( $theme_template_id ) {
return apply_filters( 'wpml_object_id', $theme_template_id, 'elementor_library', true );
}
add_filter('elementor/theme/get_location_templates/template_id', 'wpml_elementor_library', 10, 1);
/**
@EdenK
EdenK / wp-menu-item-added.js
Last active February 13, 2024 10:09
Wordpress: Javascript Hook / Event for menu item added
jQuery(document).ready(function($) {
/**
* Event trigger document#menu-item-added file nav-menu.js in the function addMenuItemToBottom
* @param {object} event
* @param {object} markup Menu item html object
*/
$(document).on('menu-item-added', function(event, markup) {
// If more than 1 items is added we will need to loop
$.each(markup, function(index, menuItem) {
// Check if its the html object becuase there is another object that we get when we adding more than 1
@EdenK
EdenK / wp-cf7-add-custom-form-tag.php
Created January 22, 2018 21:30
Wordpress: Contact form 7, Add form tag (shortcode) current url example
<?php
/**
* Wordpress: Contact form 7, Add form tag (shortcode) current url example
*/
add_action( 'wpcf7_init', 'wpcf7_add_form_tag_current_url' );
function wpcf7_add_form_tag_current_url() {
// Add shortcode for the form [current_url]
wpcf7_add_form_tag( 'current_url',
'wpcf7_current_url_form_tag_handler',
array(
@EdenK
EdenK / wp-remove-yoast-seo-columns.php
Created December 28, 2017 10:47
Wordpress: Filter admin columns and remove yoast seo columns
<?php
/**
* Wordpress: Filter admin columns and remove yoast seo columns
*/
function yoast_seo_remove_columns( $columns ) {
/* remove the Yoast SEO columns */
unset( $columns['wpseo-score'] );
unset( $columns['wpseo-title'] );
unset( $columns['wpseo-metadesc'] );
unset( $columns['wpseo-focuskw'] );
@EdenK
EdenK / wp-change-static-homepage-cpt.php
Last active December 26, 2017 10:02
Wordpress: Change options-reading.php static page dropdown to custom post type
<?php
/**
* Change options-reading.php static page post type
*/
function add_cpt_to_static_home($output, $r, $pages) {
if($r['name'] === 'page_on_front' && !isset($r['post_type'])) {
$post_type = 'post'; // Set the post type
@EdenK
EdenK / elementor-video-youtube-enablejsapi.php
Last active March 14, 2024 13:37
Filter to add enablejsapi to Elementor youtube video
<?php
/**
* Filter to add enablejsapi to Elementor youtube video
*/
function add_youtube_jsapi($iframe_html, $video_url, $frame_attributes) {
if(strpos($video_url, 'youtube') !== false) {
$src = esc_attr($frame_attributes['src']);
$new_src = esc_attr(add_query_arg(array('enablejsapi' => '1'), $frame_attributes['src']));
$iframe_html = str_replace($src, $new_src, $iframe_html);
}