Skip to content

Instantly share code, notes, and snippets.

View czerspalace's full-sized avatar

czerspalace

  • Los Angeles, CA
View GitHub Profile
@RevConcept
RevConcept / attachment-cpt.php
Last active August 28, 2015 06:51
Adds thumbnail of attachment to admin columns and image preview to CPT admin post page. CPT in example is 'guest-photos'. Using this in addition to "Frontend Uploader" plugin (https://wordpress.org/plugins/frontend-uploader/)
/* ===========================================
Show Guest Photo Attachment in CPT Admin Columns
=============================================*/
// GET ATTACHED IMAGE
function revcon_get_attachment_image($post_ID) {
$images = get_attached_media('image', $post_ID);
if ($images) {
@tuespetre
tuespetre / Set-AppPoolEnvVariable.ps1
Last active August 9, 2018 14:32
A PowerShell cmdlet for setting environment variables for AppPoolIdentity users
function global:Set-AppPoolEnvVariable {
param (
[string]$appPool = $(Read-Host "Application Pool"),
[string]$varName = $(Read-Host "Variable name"),
[string]$varValue = $(Read-Host "Variable value")
)
$sec = "System.Security.Principal";
$acct = New-Object "$sec.NTAccount" -ArgumentList "IIS AppPool\$appPool";
$sid = $acct.Translate([System.Type]::GetType("$sec.SecurityIdentifier")).Value;
@mgmartel
mgmartel / duplicate-p2p.php
Created December 7, 2013 16:27
Duplicate WP-Posts-to-Posts (https://github.com/scribu/wp-posts-to-posts/) connections when duplicating a post using Duplicate Post (http://wordpress.org/plugins/duplicate-post/) or the WooCommerce product duplicator.
<?php
add_action( 'dp_duplicate_page', 'dp_duplicate_p2p', 10, 2 );
add_action( 'dp_duplicate_post', 'dp_duplicate_p2p', 10, 2 );
// For Duplicate Product support in WooCommerce:
//add_action( 'woocommerce_duplicate_product', 'dp_duplicate_p2p', 10, 2 );
function dp_duplicate_p2p( $new_post_id, $old_post ) {
global $wpdb;
@jasdeepkhalsa
jasdeepkhalsa / longPolling.js
Last active April 17, 2024 10:59
Simple Long Polling Example with JavaScript and jQuery by Tian Davis (@tiandavis) from Techoctave.com (http://techoctave.com/c7/posts/60-simple-long-polling-example-with-javascript-and-jquery)
// Long Polling (Recommened Technique - Creates An Open Connection To Server ∴ Fast)
(function poll(){
$.ajax({ url: "server", success: function(data){
//Update your dashboard gauge
salesGauge.setValue(data.value);
}, dataType: "json", complete: poll, timeout: 30000 });
})();