Skip to content

Instantly share code, notes, and snippets.

@tangrufus
tangrufus / class-cloudflare-api-helper.php
Created July 17, 2014 18:33
Make CloudFlare Client API calls via wp_remote_post. A fork from CloudFlare-API by VEXXHOST, Inc.
<?php
/**
* Make CloudFlare Client API calls via wp_remote_post
* A fork from CloudFlare-API by VEXXHOST, Inc.
*
* @package CloudFlare_API_Helper
* @link https://github.com/vexxhost/CloudFlare-API
* @link https://www.cloudflare.com/docs/client-api.html
*/
@tangrufus
tangrufus / sunny-demo.php
Created July 20, 2014 01:08
WordPress Plugin Boilerplate. PHPDoc Tags & Plugin File Header http://tangrufus.com/wordpress-plugin-boilerplate-tutorial-getting-started/
// sunny-demo/sunny-demo.php
<?php
/**
* Sunny Demo
*
* A demo to show how to write a plugin interacting with CloudFlare
* Client API base on WordPress Plugin Boilerplate.
*
* @package Sunny_Demo
<?php
// inside private function register_settings()
// below add_settings_section()
// Next, we will introduce the fields for CloudFlare Account info.
add_settings_field(
// ID used to identify the field throughout the theme
'sunny_demo_cloudflare_email',
// The label to the left of the option interface element
@tangrufus
tangrufus / settings-api-tabs-demo.php
Created July 26, 2014 07:58
Adding Tabs with Settings API
<?php
/*
* Plugin Name: Settings API Tabs Demo
* Plugin URI: http://theme.fm/?p=
* Description: This is a demo showing off usage of tabs with the WordPress Settings API
* Version: 1.0
* Author: kovshenin
* Author URI: http://theme.fm
* License: GPL2
*/
<?php
// sunny-demo/admin/class-sunny-demo-admin.php
class Sunny_Demo_Admin {
// Some code is skipped!!!!!!!
/**
* Initialize the plugin by loading admin scripts & styles and adding a
* settings page and menu.
<div id="sunny_demo_url_purger" class="wrap">
<form id="sunny_demo_url_purger_form" method="POST">
<?php wp_nonce_field( 'sunny_demo_url_purger', 'sunny_demo_url_purger_nonce'); ?>
<?php do_settings_sections( 'sunny_demo_url_purger_section' ); ?>
<?php submit_button( __('Purge', $plugin_slug ), 'primary', 'sunny_demo_url_purger_button' ); ?>
</form>
<br class="clear">
<div id="sunny_demo_url_purger_result" style="display: none">
<h3 id="sunny_demo_url_purger_result_heading">URL Purger Result</h3>
<img id="sunny_demo_url_purger_form_spinner" style="display: none" src="<?php echo admin_url(); ?>images/spinner-2x.gif">
# Install dependencies
#
# * checkinstall: package the .deb
# * libpcre3, libpcre3-dev: required for HTTP rewrite module
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \
mkdir -p ~/sources/ && \
# Compile against OpenSSL to enable NPN
$ adduser deployer
$ gpasswd -a deployer sudo
$ gpasswd -a deployer www-data
$ sudo usermod -g www-data deployer
$ curl --data "author=YourName&amp;email=you@your-domain.com&amp;url=http://www.your-domain.com&amp;comment=Testing-Zero-Spam&amp;comment_post_ID=123456789" http://your-domain.com/wp-comments-post.php
<?php
// Skipping lots of array elements above.....
$settings['your_tab_slug']['user_email'] = array(
'name' => __( 'Your Email', $this->plugin_name ),
'type' => 'email'
);
$settings['your_tab_slug']['user_plan'] = array(
'name' => __( 'Select a plan', $this->plugin_name ),