Skip to content

Instantly share code, notes, and snippets.

View yoren's full-sized avatar

Yoren Chang yoren

View GitHub Profile
<?php
function get_page_by_template( $template ){
$page = get_posts(array(
'post_type' => 'page',
'meta_query' => array(
array(
'key' => '_wp_page_template',
'value' => $template,
'compare' => '=',
),
@lgedeon
lgedeon / wp_remote_post files
Created December 20, 2013 16:22
wip maybe
$response = wp_remote_post(
"https://api.freewheel.tv/services/upload/bvi.xml",
array(
'method' => 'POST',
'timeout' => 30,
'redirection' => 5,
'httpversion' => '1.0',
'headers' => array(
'X-FreeWheelToken' => 'MYAPIKEY',
'Expect' => ????
@pixline
pixline / .scrutinizer.yml
Created September 28, 2013 17:22
sample scrutinizer.yml config file for WordPress plugin
filter:
paths:
- 'lib/*'
- '/*'
excluded_paths:
- 'tests/*'
- 'examples/*'
tools:
php_mess_detector:
filter:
@willmot
willmot / gist:1277790
Created October 11, 2011 10:33
WordPress attachment category plugin
<?php
/*
Plugin Name: Attachment Categories
Description: Allows attachments to be categorised
Version: 1.0
Author: Human Made Limited
Author URI: http://hmn.md
*/
{
// Goes inside Preference.sublime-settings -- User
//
// First "theme" line defines which Boxy theme you've selected
// Rest of the lines are configuration of Boxy theme itself.
//
// Boxy theme full settings: https://github.com/ihodev/sublime-boxy/wiki/Settings#accent
"theme": "Boxy Tomorrow.sublime-theme",
"theme_accent_purple": true,
"theme_bar": true,
<?php
/*
Plugin Name: EDD Webhooks
Description: Captures new sale notifications from 3rd party service and adds to Easy Digital Downloads
Version: 1.0
Author: Brian Hogg
Author URI: https://brianhogg.com
Text Domain: edd-webhooks
License: GPL2
*/
@rynaldos-zz
rynaldos-zz / wc-custom-purchased-column.php
Last active June 15, 2020 06:26
[WooCommerce 3.0+] Re-instate the "Purchased items" column on orders page
add_filter('manage_edit-shop_order_columns', 'wc_custom_purchased_column');
function wc_custom_purchased_column($columns)
{
$new_array = array();
foreach ($columns as $key => $title) {
if ($key == 'billing_address') {
$new_array['order_items'] = __('Purchased', 'woocommerce');
}
@mannieschumpert
mannieschumpert / gist:8886289
Last active August 2, 2020 13:15
Code Examples from Andrew Nacin's "Current User Can Watch This Talk"
<?php
// If you can edit pages, you can edit widgets
add_filter( 'user_has_cap',
function( $caps ) {
if ( ! empty( $caps['edit_pages'] ) )
$caps['edit_theme_options'] = true;
return $caps;
} );
<?php
/**
* Gets Gravity Forms via form title.
*
* @access public
* @param string $title (default: null) - Form title to search for
* @param bool $return_form (default: false) - Return form object or form ID
* @return array - Array of form IDs or form objects (based on $return_form value)
*/