Skip to content

Instantly share code, notes, and snippets.

View pingram3541's full-sized avatar

pingram3541 pingram3541

View GitHub Profile
@pingram3541
pingram3541 / wp-minimal-adminbar.css
Last active August 19, 2021 18:47
Plugin: Minimal WP Adminbar - Hides wp-admin bar leaving only 32px icon upper left-corner - slides down on hover / toggle w F1 key
body.admin-bar {
position: relative;
top: -32px;
}
div#wpadminbar {
transition: top 300ms ease-in-out;
top: -32px;
}
div#wpadminbar:hover,
body.f1 div#wpadminbar /* see f1-toggle.js */ {
@pingram3541
pingram3541 / back2top.html
Created August 17, 2021 22:01
Sticky Back to Top JavaScript using Element ID
<!--
Title: Scroll Top
Type: elementor_snippet
Author: Website Admin
Last edited: 2021-04-02 18:07:14
Note: This was added by Elementor, just copy script code below.
Instructions: Add to any site or via Elementor Custom Code feature (Body -> End),
then use "up" as the id of the trigger element in your design
--- The comment is visible only for administrators ---
-->
@pingram3541
pingram3541 / form-mask.php
Created August 12, 2021 19:52
Ability to mask Elementor Pro Form fields w/ custom pattern
<?php
/***
* Add to custom plugins or functions.php (i.e. use include)
* Allows for custom patterns like: https://www.html5pattern.com/
* See Git issue: https://github.com/elementor/elementor/issues/8587
*/
namespace ElementorPro\Modules\Forms\Classes;
use Elementor\Repeater;
@pingram3541
pingram3541 / functions.php
Created June 22, 2021 18:09
Elementor - Add URL control to Star-Rating widget
/**
* add url control to star rating widget
**/
add_action( 'elementor/element/star-rating/section_rating/before_section_end', function( $element, $args ) {
$element->add_control(
'rating_url',
[
'type' => \Elementor\Controls_Manager::URL,
'label' => __( 'Link', 'elementor' ),
'placeholder' => __( 'https://your-link.com', 'elementor' ),
@pingram3541
pingram3541 / functions.php
Last active April 27, 2021 19:23
Mediavine custom Create Recipe Jump-To button using $post_id
//Shortcode to output custom Jump-To Recipe button by Create
function custom_mvcreate_jumpbutton_func(){
$post_id = get_the_ID();
if( ! function_exists( 'mv_get_post_creations' ) )
return;
$recipes = mv_get_post_creations( $post_id );
if( empty( $recipes ) )
return;
@pingram3541
pingram3541 / functions.php
Created October 29, 2020 03:05
Dynamic Widget checks for ACF field value or uses Shortcode fallback
/**
* add custom widget to switch city page map preferences
*
* Simply performs an audit on City Pages to check if
* the preference is to output custom code or use the
* automatic map search by city name
*
*************************************/
class Custom_City_Map_Widget extends WP_Widget {
@pingram3541
pingram3541 / functions.php
Created August 3, 2020 21:51
Strips html "name" attribute from Elementor Form's rendered html - All Forms
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
if ( 'form' === $widget->get_name() ) {
$content = preg_replace('/(<[^>]+) name=".*?"/i', '$1', $content);
}
return $content;
}, 10, 2 );
@pingram3541
pingram3541 / function.php
Created July 12, 2020 20:12
Add disclaimer notice after all Elementor HTML widgets that use id 'html_notice'
<?php
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
if ( 'html' === $widget->get_name() ) {
$settings = $widget->get_settings(); //contains all widget settings - read-only!
//checks if special id exists
if ( ! empty( $settings['_element_id'] ) && $settings['_element_id'] === 'html_notice' ) {
$content .= '<div class="disclaimer_notice"><span>Copy and use of the above code is at your own risk.</span></div>';
}
}
@pingram3541
pingram3541 / functions.php
Created June 29, 2020 00:23
Shortcode to produce WooCoomerce Product Attributes
//Shortcode to output product attribute
function product_list_attribute_func( $atts ){
global $product;
$atts = shortcode_atts( array(
'name' => '',
), $atts );
if( is_string( $atts['name'] ) ){
@pingram3541
pingram3541 / functions.php
Last active August 1, 2021 00:14
Elementor HTML Widget - Add toggle to render script in wp_footer
/**
* 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
*