This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Shortcode to output product attribute | |
function product_list_attribute_func( $atts ){ | |
global $product; | |
$atts = shortcode_atts( array( | |
'name' => '', | |
), $atts ); | |
if( is_string( $atts['name'] ) ){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Modify HTML Widget to load as an inline script in wp_footer | |
* | |
* 1) Add toggle control to html widget for loading as a footer script | |
* with jQuery dependency | |
* | |
* 2) Use 'elementor/frontend/widget/should_render' filter to disable the html widget's | |
* normal output on the front end and add our script to the wp_footer action using the | |
* global variable: $html_custom_script | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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' ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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 ){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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' ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); |