Skip to content

Instantly share code, notes, and snippets.

View ChrisFlannagan's full-sized avatar

Chris Flannagan ChrisFlannagan

View GitHub Profile
<?php
/**
* hook into WP's admin_init action hook
*/
public function admin_init() {
// Here we create our settings fields to be contained in the setting group 'wpfh-group'
register_setting( self::PLUGIN_ABBR . '-group', self::PLUGIN_ABBR . '-group' );
add_settings_section ( self::PLUGIN_SLUG . '_main_section' , 'Primary Settings', array( $this, 'settings_callback'), self::PLUGIN_SLUG . '-options' );
<?php
public function __construct() {
// register actions
add_action( 'init', array( &$this, 'init' ) );
}
//Sanitizers
public function cplh_hexcolor_sanitize( $new_value, $old_value ) {
$new_value = sanitize_hex_color( $new_value );
return $new_value;
<?php
if( ! current_user_can( 'manage_options' ) ) {
exit();
}
$settings_color = "#fff";
if( isset( $_POST['settings_color'] ) && wp_verify_nonce( $_POST['_wpnonce'] ) ) {
update_option( "myplugin_settings_color", $_POST['settings_color'] );
if( isset( $_POST['feature_on'] ) ) {
<div u="slides" style="cursor: move; position: absolute; overflow: hidden; left: 0px; top: 0px; width: 1090px; height: 550px;">
<?php
$slides_trans = get_transient( "slides_rest_api");
$allslides = array();
if( !$slides_trans || $_REQUEST['reset_trans'] == 'please' ) {
// Best to use wp_remote_get here but for brevity in example we use file_get_contents
$callret = file_get_contents( site_url() . '/wp-json/posts?filter[category_name]=home-slides&filter[posts_per_page]=-1' );
$allslides = json_decode( $callret, true );
set_transient( "slides_rest_api", $callret, 60*60*12 );
} else {
<?php
/**
* Add the SSN field to the checkout if Four Easy Payments is available
*/
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
if( has_deposit() ) {
echo '<div id="my_custom_checkout_field"><h2>' . __('Payment Plan Requirements') . '</h2>';
woocommerce_form_field('ssn_easypay', array(
exports.takephoto = function(args) {
cameraModule.takePicture().then(function(picture) {
var savepath = fsModule.knownFolders.documents().path;
var filename = 'img_' + new Date().getTime() + '.' + enumsModule.ImageFormat.jpeg;
var filepath = fsModule.path.join(savepath, filename);
console.log("Save: + " + picture);
if(picture.saveToFile(filepath, format)) {
var session = bghttp.session("image-upload");
console.logi("Saving");
var request = {
<?php
/**
* Clear cache on add to cart so the cart counter in header is updated
*/
add_action( 'woocommerce_add_to_cart', 'my_custom_clear_cache', 10, 1 );
function my_custom_clear_cache( ) {
comet_cache::clear();
}
var viewModule = require("ui/core/view");
var imageModule = require("ui/image");
var absoluteLayoutModule = require("ui/layouts/absolute-layout");
var page;
var id;
var timer = require("timer");
var face;
var deviceimg;
var angle = 0;
var viewModule = require("ui/core/view");
var imageModule = require("ui/image");
var absoluteLayoutModule = require("ui/layouts/absolute-layout");
var page;
var id;
var timer = require("timer");
var timestart = 1000*60*3;
var timerlabel;
var face;
<?php
/**
* User submits url which converts to WebSitesCPT
*/
if ( ! class_exists( 'Website_Submit' ) ) {
class Website_Submit {
const POST_TYPE = 'user-websites';
public $return_message = '';