Skip to content

Instantly share code, notes, and snippets.

<?php
//content type
header('Content-Type: image/png');
$font = 'znikomit-webfont.ttf';
$font_size = $_GET['s'];
$width = $_GET['w'];
$margin = 5;
$text = $_GET['t'];
<?php
// Print two names on the picture, which accepted by query string parameters.
$n1 = $_GET['n1'];
$n2 = $_GET['n2'];
Header ("Content-type: image/jpeg");
$image = imageCreateFromPNG("someimage.png");
$color = ImageColorAllocate($image, 255, 255, 255);
<?php
Header ("Content-type: image/jpeg");
function ImageTTFCenter($image, $text, $font, $size, $angle = 45) {
$xi = imagesx($image);
$yi = imagesy($image);
$box = imagettfbbox($size, $angle, $font, $text);
<?php
$url = 'https://secure.globalproblems-globalsolutions.org/site/CRDonationAPI?luminateExtend=1.4.3&method=getDonationFormInfo&form_id=9020&api_key=unfkey&response_format=json&suppress_response_codes=true&v=1.0';
$options = array(
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_ENCODING => "", // handle all encodings
CURLOPT_USERAGENT => "spider", // who am i
public function getConvioAuth() {
$url = esc_attr( get_option('convio_api_url') ) . 'SRConsAPI';
$atts = array(
'method' => 'getSingleSignOnToken',
'api_key' => esc_attr( get_option('convio_api_key') ),
'login_name' => esc_attr( get_option('convio_api_auth_user') ),
'login_password' => esc_attr( get_option('convio_api_auth_pw') ),
'cons_id' => esc_attr( $_GET['cons_id'] ),
'v' => '1.0',
'response_format' => 'json'
public function fetchUrl_POST($url, $fields){
//open connection
$ch = curl_init();
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string, '&');
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
<header id="header">
<div>
<div>
<a href="/" id="logo">
<img src="logo.svg">
</a>
<h1>Page Title</h1>
</div>
<div>
<a href="#header-dropdown">MENU</a>
<header id="header">
<div>
<div>
<a href="/" id="logo">
<img src="logo.svg">
</a>
<h1>Page Title</h1>
</div>
<div>
<a id="show-dropdown" href="#header-dropdown">MENU</a>
<?php
add_action( 'pre_get_posts', 'custom_get_posts' );
function custom_get_posts( $query ) {
if( (is_category() || is_archive()) && $query->is_main_query() ) {
if ( $query->query_vars['post_type'] == 'staff' || $query->query_vars['post_type'] == 'stories' ) {
$query->query_vars['orderby'] = 'menu_order';
################################
# START __posttype__
################################
function register__posttype__() {
$cpt_single = '__single__';
$cpt_plural = '__plural__';
$cpt_icon = '__icon__';
$rewrite = array('slug' => '__slug__', 'with_front' => true);
$exclude_from_search = __exclude__;