Skip to content

Instantly share code, notes, and snippets.

View PatelUtkarsh's full-sized avatar
🧘

Utkarsh Patel PatelUtkarsh

🧘
View GitHub Profile
@rahul286
rahul286 / hook-debug.php
Last active August 29, 2015 14:16
git-webhook in php
<?php
// array - repo names and local filesystem path and branch
$repos = array(
'bad-plugin' => array (
'branch' => 'master',
'localpath' => '/var/www/example.com/htdocs/wp-content/plugins/bad-plugin'
)
);
rt_write_log("Hello at " . date("D M j G:i:s T Y") );
@faishal
faishal / wpdb-in-query-prepare.php
Last active April 11, 2016 13:07
WPDB In Query Prepare
<?php
global $wpdb;
if ( is_array( $ids ) ) {
$in_str_arr = array_fill( 0, count( $ids ), '%d' );
$in_str = join( ',', $in_str_arr );
$form_id_where = $wpdb->prepare( "ID IN ($in_str)", $ids );
} else {
$form_id_where = $ids> 0 ? $wpdb->prepare( 'ID=%d', $ids ) : '';
}
<?php
/**
* Plugin Name: Customize Changesets Admin UI
* Description: Enable revisions for customize changeset posts and enable admin screens.
* Author: Weston Ruter, XWP
*
* @package Customize_Changesets_Admin_UI
*/
namespace Customize_Changesets_Admin_UI;
@PatelUtkarsh
PatelUtkarsh / index.js
Last active January 14, 2020 06:01
Send pushbullet msg on website hit.
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
@westonruter
westonruter / .gitignore
Last active June 8, 2020 17:02
Now available on the WordPress.org plugin directory: https://wordpress.org/plugins/lazy-loading-oembed-iframes/
.svn
@ericandrewlewis
ericandrewlewis / a.md
Last active October 27, 2020 18:44
The WordPress Customizer

The WordPress Customizer

The WordPress Customizer is an interface for drafting changes to content while previewing the changes before they are saved. This is an alternative to the "save and suprise" model of changing settings without knowing what exactly will happen.

The customizer can be accessed in the admin interface under Appearance > Customize.

A screenshot of the customizer

#19909 is the trac ticket that introduced the Customizer during the 3.4 release cycle.

@mcaskill
mcaskill / wp-leadingslash.php
Created April 17, 2015 15:38
WordPress \ Formatting : Prepends a leading slash and removes leading forward slashes and backslashes if they exist.
<?php
/**
* Prepends a leading slash.
*
* Will remove leading forward and backslashes if it exists already before adding
* a leading forward slash. This prevents double slashing a string or path.
*
* The primary use of this is for paths and thus should be used for paths. It is
* not restricted to paths and offers no specific path support.
@vgeshel
vgeshel / function.js
Last active February 9, 2022 09:19
AWS Lambda function for forwarding SNS notifications to Slack
console.log('Loading function');
const https = require('https');
const url = require('url');
// to get the slack hook url, go into slack admin and create a new "Incoming Webhook" integration
const slack_url = 'https://hooks.slack.com/services/...';
const slack_req_opts = url.parse(slack_url);
slack_req_opts.method = 'POST';
slack_req_opts.headers = {'Content-Type': 'application/json'};
@SeanChristopherConway
SeanChristopherConway / docker-compose.yaml
Last active June 15, 2022 00:30
Docker Pihole with unbound for authoritative, validating, recursive caching DNS
version: "3.7"
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
dns: 127.0.0.1
restart: unless-stopped
links:
- unbound
@danielbachhuber
danielbachhuber / collection-filter.js
Last active April 18, 2023 20:30
Add a custom taxonomy dropdown filter to the WordPress Media Library
(function(){
/**
* Create a new MediaLibraryTaxonomyFilter we later will instantiate
*/
var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({
id: 'media-attachment-taxonomy-filter',
createFilters: function() {
var filters = {};
// Formats the 'terms' we've included via wp_localize_script()