Skip to content

Instantly share code, notes, and snippets.

View pingram3541's full-sized avatar

pingram3541 pingram3541

View GitHub Profile
@pingram3541
pingram3541 / functions.php
Last active April 29, 2022 21:00
Add Elementor Widget Control to Remove Schema from Star Rating Widget
/**
* add toggle control to star rating widget for schema
**/
add_action( 'elementor/element/star-rating/section_rating/before_section_end', function( $element, $args ) {
$element->add_control(
'use_schema',
[
'type' => \Elementor\Controls_Manager::SWITCHER,
'label' => __( 'Use Schema', 'elementor' ),
'label_on' => __( 'Enable', 'elementor' ),
@pingram3541
pingram3541 / functions.php
Last active September 14, 2023 12:23
How to hide Elementor Section or Widget for use with custom conditional
//How to hide any widget with an id of 'test':
add_filter( 'elementor/frontend/widget/should_render', function( $bool, $element ){
$settings = $element->get_settings();
if( 'test' === $settings['_element_id'] && 'heading' === $type ){
return false;
} else { return true }
}, 10, 3);
//How to hide any specific type of widget':
add_filter( 'elementor/frontend/widget/should_render', function( $bool, $element ){
@pingram3541
pingram3541 / functions.php
Created January 10, 2020 19:01
Elementor Posts widget change query to more post types instead of just one
/** Showing multiple post types in Posts Widget
* 1) Add "my_custom_filter" or your unique id to your Posts element
* 2) Add the following code to your functions.php making sure to use the same
* unique id that you added to the Posts widget
* 3) Modify the post-types below in the code as needed to match
* the post types you'd desire to use
**/
add_action( 'elementor/query/my_custom_filter', function( $query ) {
// Here we set the query to fetch posts with
// post type of 'custom-post-type1' and 'custom-post-type2'
@pingram3541
pingram3541 / functions.php
Last active January 5, 2020 18:13
Shotcode to create custom url from ACF fields and post id
/**
* Returns a custom url based on the post id, title and a unique ACF field value then loops through
* the resulting string of id's returned by "this" post's ACF field, querying and returning yet another ACF
* field from each looped post id.
**/
add_shortcode( 'url_from_acf', 'my_url_from_acf' );
function my_url_from_acf(){
$post_id = get_the_ID();
if ( get_post_type( $post_id ) === 'my_cpt' ) {
@pingram3541
pingram3541 / functions.php
Created January 4, 2020 19:08
Elementor Widget Render Action on Specific Post Type Only
add_action( 'elementor/widget/render_content', function( $content, $widget ){
if ( 'button' === $widget->get_name() && 'my_cpt' == get_post_type() ) {
$settings = $widget->get_settings();
//make sure it is the right button element
if ( ! empty( $settings['_element_id'] ) && $settings['_element_id'] === 'my_button' ) {
$settings['link']['url'] = 'https://my-custom-url.com/';
/**
* How do I update $content with
@pingram3541
pingram3541 / functions.php
Created December 11, 2019 19:18
capture $_POST on specific page w/ Elementor widget of matching ID
if ( ! function_exists('write_log')) {
function write_log ( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
@pingram3541
pingram3541 / functions.php
Last active August 27, 2019 17:21
MailerLite Integration w/ Resubscribe support - Elementor Pro Forms
add_action( 'elementor_pro/forms/new_record', function( $record ) {
// Make sure this is the correct form
$form_name = $record->get_form_settings( 'form_name' );
if ( 'YOUR_ACTUAL_FORM_NAME_HERE' !== $form_name ) {
return;
}
$submmited_fields = $record->get( 'fields' );
// Ref: https://developers.mailerlite.com/v2/reference#create-a-subscriber
$fields = [
@pingram3541
pingram3541 / functions.php
Last active July 29, 2019 16:57
Wordpress Inline Script with Fallback
<?php
/**
* see - https://digwp.com/2019/07/better-inline-script/
* by - Jeff Starr
*/
// enqueue scripts
function shapeSpace_enqueue_scripts() {
wp_enqueue_script('shapeSpace_script', get_template_directory_uri() .'/js/script.js', array(), '1.0', true);
@pingram3541
pingram3541 / gradient.css
Created April 11, 2019 00:04
Background Gradient Animation
#gradient {
background: linear-gradient(-45deg,#ee7752,#e73c7e,#23a6d5,#23d5ab);
background-size: 400% 400%;
-webkit-animation: Gradient 15s ease infinite;
-moz-animation: Gradient 15s ease infinite;
animation: Gradient 15s ease infinite;
}
@-webkit-keyframes Gradient {
0% {
background-position: 0 50%
@pingram3541
pingram3541 / functions.php
Created March 6, 2019 19:59
Override parent theme script file w/ modified child theme version
/**
* Override the parent theme misc.js script.
*
* fix for Elementor popup forms due to
* issue w/ Bold Themes Medicare theme
*/
function boldtheme_deregister_script() {
if( is_page( array( 'mypage', 'myotherpage' ) ) ){
wp_deregister_script( 'boldthemes_misc_js' );
wp_register_script( 'boldthemes_misc_js', get_stylesheet_directory_uri() . '/scripts/misc.js', array( 'jquery' ), null, false );