Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
<?php
/**
* Plugin Name: Fix JSON Support Detection for Action Scheduler
* Description: Fixes the JSON support detection in Action Scheduler for MariaDB on Pantheon
* Version: 1.0.0
* Author: Lindsey Catlett, Pantheon
*/
// Make sure this runs before Action Scheduler initializes
add_action('plugins_loaded', 'fix_json_support_detection', 5);
@dexit
dexit / custom-widget.php
Created July 25, 2025 10:32 — forked from beinoriusju/custom-widget.php
Custom Elementor Widget using React
<?php
//widgets/custom-widget.php
class Custom_Widget extends \Elementor\Widget_Base {
public function get_name() {
return 'custom_widget';
}
public function get_title() {
return __('Custom Widget', 'my-plugin');
}
@dexit
dexit / bloat.php
Created July 25, 2025 10:32 — forked from anthony9981/bloat.php
Clear WordInstallation
<?php
/* Cleaner WP header
*===============================================================*/
function clean_header() {
// Remove the REST API lines from the HTML Header
remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );
remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );
@dexit
dexit / elementor_show_hide.php
Created July 25, 2025 10:21 — forked from mehrshaddarzi/elementor_show_hide.php
elementor Add condition show/hide field
<?php
/**
* Register custom Elementor display conditions.
*
* @param \Elementor\Core\Kits\Documents\Tabs\Conditions_Manager $conditions_manager
* @return void
*/
function register_custom_elementor_conditions( $conditions_manager ) {
@dexit
dexit / single-elementor_library.php
Created July 25, 2025 10:21 — forked from pingram3541/single-elementor_library.php
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';
}
@dexit
dexit / functions.php
Created July 25, 2025 10:20 — forked from pingram3541/functions.php
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 ){
@dexit
dexit / function.php
Created July 25, 2025 10:20 — forked from pingram3541/function.php
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>';
}
}
@dexit
dexit / script.js
Created July 25, 2025 10:20 — forked from pingram3541/script.js
Toggle Elementor Popup + Add Body Class
var nav = false;
const menu_close = () => {
//elementorProFrontend.modules.popup.closePopup( { id: 191 } );
elementorFrontend.documentsManager.documents[191].getModal().hide();
nav = false;
//console.log('menu closed!');
}
const menu_open = () => {
//elementorProFrontend.modules.popup.showPopup( { id: 191 } );
@dexit
dexit / webpcheck.js
Created July 25, 2025 10:20 — forked from pingram3541/webpcheck.js
Detect Webp browser support
// check_webp_feature:
// 'feature' can be one of 'lossy', 'lossless', 'alpha' or 'animation'.
// 'callback(feature, isSupported)' will be passed back the detection result (in an asynchronous way!)
// see: https://stackoverflow.com/a/54631141/4845112
function check_webp_feature(feature, callback) {
var kTestImages = {
lossy: "UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",
lossless: "UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==",
alpha: "UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==",
animation: "UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA"
<?php
/**
* prevent Elementor sections and containers from rendering on frontend if they are set to hide in all 3 responsive settings
*/
function do_not_render_hidden_sections( $should_render, $section ) {
// skip check if we are and editing
if ( is_admin() ) { return $should_render; }