Skip to content

Instantly share code, notes, and snippets.

View jmslbam's full-sized avatar
💭
Available for (WordPress) work

Jaime Martínez jmslbam

💭
Available for (WordPress) work
View GitHub Profile
@jmslbam
jmslbam / elasticpress_posttype_weighting.php
Created December 2, 2020 16:40 — forked from CatEntangler/elasticpress_posttype_weighting.php
weighting by post_type using ElasticPress
function SetSearchArgs( $formattedArgs, $args = [] ) {
if( isset( $args[ 'post_type' ] ) && ( count( $args[ 'post_type' ] ) > 1 || gettype( $args[ 'post_type' ] ) === 'string' ) ) {
if( gettype( $args[ 'post_type' ] ) === 'array' ) {
$existing_query = $formattedArgs[ 'query' ];
unset( $formattedArgs[ 'query' ] );
@jmslbam
jmslbam / clarkson_event.php
Last active August 4, 2017 13:29
Clarkson Event Manager - WordPress Object overwrite example
<?php
use Clarkson\EventManager\Event;
// Which class do we need to initiate? new \XYZ?
add_filter('clarkson_event_manager_post_class', function(){
return '\Clarkson_Event';
}, 10, 0);
// Our custom WordPress object
class Clarkson_Event extends Event {
@jmslbam
jmslbam / vip-wp-cli.php
Last active February 10, 2017 11:14
WPCOM_VIP_CLI_Command
<?php
class WPCOM_VIP_CLI_Command extends WP_CLI_Command {
/**
* Clear all of the caches for memory management
*/
protected function stop_the_insanity() {
/**
* @var \WP_Object_Cache $wp_object_cache
@jmslbam
jmslbam / composer.json
Last active May 24, 2017 07:32
Install Clarkson Core via Composer
{
"name": "clarkson/website",
"type": "project",
"license": "MIT",
"description": "Example to add Clarkson Core via Compser",
"repositories": [
{
"type": "git",
"url":"https://github.com/level-level/Clarkson-Core"
}
@jmslbam
jmslbam / mlp_navigation_with_login.php
Last active February 11, 2016 12:45 — forked from thefuxia/mlp_navigation_with_login.php
function mlp_navigation_with_login()
<?php
// copy from here
/**
* Create a navigation like: DE | EN | RU | Log in
*
* @return string
*/
function mlp_navigation_with_login()
@jmslbam
jmslbam / composer.json
Created December 11, 2015 08:17
Clarkson Core via Composer
{
"name": "level-level/wp-clarkson.com",
"type": "project",
"license": "MIT",
"description": "A modern WordPress development",
"repositories": [
{
"type": "composer",
"url": "http://wpackagist.org"
},
@jmslbam
jmslbam / gist:f5a921c399d8fe6dc762
Created May 28, 2015 22:10
FacetWP Selections with reset
<div id="selected-filters" class="selected-filters">
<h4><?php _e('Selected filters','rc'); ?>:</h4>
<?php echo facetwp_display('selections'); ?>
<span class="facetwp-reset" onclick="FWP.reset()"><?php _e('reset all filters','rc'); ?></span>
</div>
@jmslbam
jmslbam / functions.php
Created July 13, 2014 11:56
Change WooCommerce ordernumber prefix
add_filter( 'woocommerce_order_number', 'jm_woocommerce_order_number', 1, 2 );
/**
* Remove # prefix from WooCommerce Order Number
* Could also be done with gettext: https://github.com/woothemes/woocommerce/blob/master/includes/abstracts/abstract-wc-order.php#L537
*
*/
function jm_woocommerce_order_number( $oldnumber, $order ) {
return str_replace('#', '', $order->id);
}
@jmslbam
jmslbam / wp-cli-snippets.sh
Last active July 8, 2017 03:00
WP-CLI snippet solutions collected from WP-CLI issues
#!/bin/bash
# Provide a way to upgrade the network after `wp core update`
# https://github.com/wp-cli/wp-cli/issues/683
for url in $(wp site list --fields=url --format=csv | tail -n +2)
do
wp --url=$url core update-db
done