Skip to content

Instantly share code, notes, and snippets.

View pingram3541's full-sized avatar

pingram3541 pingram3541

View GitHub Profile
@pingram3541
pingram3541 / single-elementor_library.php
Last active February 21, 2018 18:24
Used in theme functions.php - set Elementor Library post type to use built-in Canvas template by default
/* ---------------------------------------------------------------------------
* Force Elementor Library to use Canvas Template
* - this gist file name can also be used in your theme to override the template instead of this
* --------------------------------------------------------------------------- */
function get_elementor_library_post_type_template( $single_template ) {
global $post;
if ($post->post_type == 'elementor_library') {
$single_template = WP_PLUGIN_DIR . '/elementor/includes/page-templates/canvas.php';
}
@pingram3541
pingram3541 / functions.php
Created September 5, 2018 23:29
Add CPT and register support for Elementor on theme activaton
/*
* adding a cpt and registering on theme activation w/ elementor support
*
*/
//most basic add of cpt
function codex_custom_init() {
$args = array(
'public' => true,
'label' => 'Portfolios'
);
@pingram3541
pingram3541 / functions.php
Created September 19, 2018 20:30
Widget - Switch Map based on post's ACF values
/**
* 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 / diamond_redirect.php
Last active December 31, 2018 00:28
Diamond Member redirect with shortcode
<?php
/**
* Plugin Name: Diamond Member Redirect Shortcode
* Plugin URI: http://wordpress.org
* Description: This plugin checks conditions and if diamond member will redirect to specified url, use [diamond_redirect] on any page/post
* Version: 1.0
* Author: Some dude
**/
//check for shortcode in content "before" sent to browser
@pingram3541
pingram3541 / functions.php
Created February 8, 2019 05:39
Shortcode to create button from most recent post by category
/***
* Button - Get Most Recent Post by Category
*
* usage:
* [get_button_recent_post_by_cat $atts]
*
* atts ex:
* align="center" i.e.(left, right)
* bg_color="white" i.e. #000
* border="1px solid black !important"
@pingram3541
pingram3541 / functions.php
Created March 4, 2019 20:20
Add rendering of shortcodes in Elementor Slides widget
/**
* Add rendering of shortcodes in Elementor Slides widget
*
* Simply renders shortcodes in slide content
*
**/
add_action( 'elementor/widget/render_content', function( $content, $widget ) {
if ( 'slides' === $widget->get_name() ) {
$content = do_shortcode( $content );
}
@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 );
@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
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 / 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 = [