Skip to content

Instantly share code, notes, and snippets.

View elvismdev's full-sized avatar
🇨🇺

Elvis Morales elvismdev

🇨🇺
View GitHub Profile
@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 );
@jeremejazz
jeremejazz / require_all.php
Last active January 9, 2024 22:19
PHP require all files in folder
<?php
$files = glob( __DIR__ . '/folder/*.php');
foreach ($files as $file) {
require($file);
}
@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/
*
*/
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 );
development:
adapter: mysql2
encoding: utf8
database: my_database
username: root
roles:
- admin
- developer
- guest
password:
@anestan
anestan / functions.php
Last active March 10, 2018 00:02
icelock - Use Polylang Plugins for customizer homepage
// check Polylang exist
if ( function_exists('pll_register_string') ) {
$icelock_title_portfolio_section = get_theme_mod('icelock_title_portfolio_section', '');
pll_register_string('Portfolio Section Title', $icelock_title_portfolio_section);
$icelock_title_team_section = get_theme_mod('icelock_title_team_section', '');
pll_register_string('Team Section Title', $icelock_title_team_section);
$icelock_title_recent_post_section = get_theme_mod('icelock_title_recent_post_section', '');
pll_register_string('Recent Post Section Title', $icelock_title_recent_post_section);
$icelock_title_testimonials_section = get_theme_mod('icelock_title_testimonials_section', '');
pll_register_string('Testimonial Section Title', $icelock_title_testimonials_section);
{
"name": "shelob9/router-experiment",
"require": {
"silex/silex": "~1.3",
"twig/twig": "^2.0@dev"
},
"minimum-stability": "dev",
"autoload": {
"psr-4": {
"shelob9\\router\\": "src"
@wpmark
wpmark / using-media-handle-sideload.php
Created July 10, 2015 10:32
Using Media Handle Sideload
<?php
/* set the url of the file to sideload - probably be from $_POST or something */
$url = 'http://domain.com/image.jpg';
/**
* donwload the url into wordpress
* saved temporarly for now
*/
$tmp = download_url( $url );
@mgussekloo
mgussekloo / gist:8ec5fa53c1505d032991
Last active January 26, 2018 00:09
Timberdate-filter for Twig, to use in combination with Wordpress & Timber
Add to something like functions.php
// https://www.skyverge.com/blog/down-the-rabbit-hole-wordpress-and-timezones/
function wp_get_timezone_string() {
// if site timezone string exists, return it
if ( $timezone = get_option( 'timezone_string' ) )
return $timezone;
// get UTC offset, if it isn't set then return UTC
@ThomasLeCoz
ThomasLeCoz / ld_woosubs_course_access.php
Created February 15, 2015 13:22
Functions to give or remove access to LearnDash courses
// Remove Access to the course linked to the subscription key
function remove_course_access( $user_id, $subscription_key ) {
// Get the course ID related to the subscription
$subscription = WC_Subscriptions_Manager::get_subscription( $subscription_key );
$courses_id = get_post_meta($subscription['product_id'], '_related_course', true);
// Update access to the courses
if ($courses_id && is_array($courses_id)) {
foreach ($courses_id as $course_id) {