Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🇨🇺

Elvis Morales elvismdev

🇨🇺
View GitHub Profile
function _remove_script_version( $src ){
$parts = explode( '?ver', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
@mathetos
mathetos / plugin.php
Last active April 13, 2023 16:48
Dependent Plugin Activation/Deactivation and Alert
<?php
/*
* Dependent Plugin Activation/Deactivation
*
* Sources:
* 1. https://pippinsplugins.com/checking-dependent-plugin-active/
* 2. http://10up.com/blog/2012/wordpress-plug-in-self-deactivation/
*
*/
@jeremejazz
jeremejazz / require_all.php
Last active January 30, 2026 00:36
PHP require all files in folder
<?php
$files = glob( __DIR__ . '/folder/*.php');
foreach ($files as $file) {
require($file);
}
@mgibbs189
mgibbs189 / test.php
Last active October 20, 2018 07:19
FacetWP - index multiple field values for a single autocomplete facet
<?php
// Add to functions.php
function fwp_combine_sources( $params, $class ) {
if ( 'MY_FACET_NAME' == $params['facet_name'] ) {
$value = get_field( 'YOUR_FIELD_1' );
$params['facet_value'] = sanitize_title( $value );
$params['facet_display_value'] = $value;
$class->insert( $params );
// Add Async to JS deferred by Autoptimize plugin
add_filter('autoptimize_filter_js_defer','my_ao_override_defer',10,1);
function my_ao_override_defer($defer) {
return $defer."async ";
}
@carlodaniele
carlodaniele / food-example-plugin.php
Last active August 22, 2021 09:00
An example plugin for WPMU DEV readers
<?php
/**
* @package Food_example_plugin
* @version 1.0
*/
/*
Plugin Name: Food example plugin
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin for WPMU DEV readers
Author: Carlo Daniele
@sebkouba
sebkouba / ParentChild.es6
Created February 17, 2016 06:00
Basic example to pass values between parent and child components in React.
/**
* Basic example to pass values between parent and child components in React
* Seems to be in line with this
* http://stackoverflow.com/questions/24147331/react-the-right-way-to-pass-form-element-state-to-sibling-parent-elements
* Now I have the state in parent and child. Is that good or bad? Why would I need it in child?
* Could probably take that out
* */
class Parent extends React.Component {
constructor(props) {
super(props);
@acobster
acobster / CustomMenu.php
Created February 18, 2016 17:44
Extending TimberMenu
<?php
/**
* Custom Menu class to add special nav behavior on top of
* TimberMenu instances.
*
* Context: https://github.com/jarednova/timber/issues/808
*/
class CustomMenu extends \TimberMenu {
public $MenuItemClass = '\CustomMenuItem';
@maxkostinevich
maxkostinevich / functions.php
Last active February 11, 2023 20:03
WordPress: Export custom data to CSV
<?php
/**
* Export Data to CSV file
* Could be used in WordPress plugin or theme
*/
// A sample link to Download CSV, could be placed somewhere in plugin settings page
?>
<a href="<?php echo admin_url( 'admin.php?page=myplugin-settings-page' ) ?>&action=download_csv&_wpnonce=<?php echo wp_create_nonce( 'download_csv' )?>" class="page-title-action"><?php _e('Export to CSV','my-plugin-slug');?></a>
@mgibbs189
mgibbs189 / test.js
Created April 12, 2016 11:41
FacetWP - wp js hooks
(function($) {
$(function() {
wp.hooks.addFilter('facetwp/set_options/date_range', function(args) {
// do something
args.format = 'yyyy-mm-dd';
return args;
});
});
})(jQuery);