This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//////////////////////// | |
# COLUMN EXAMPLES | |
//////////////////////// | |
//////////////////////// | |
# Add Column (after) | |
//////////////////////// | |
global $wpdb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script> | |
<h1>Here is my map of a particular Bay Area company</h1> | |
<div id="my-map"></div> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
// Grab the target map | |
var $map = $('#my-map'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
///////////////////////////////////////////////////////////////// | |
# Create a Simple JSON Based Download Counter with WordPress | |
///////////////////////////////////////////////////////////////// | |
// Extending from: | |
// http://www.kavoir.com/2010/05/simplest-php-hit-counter-or-download-counter-count-the-number-of-times-of-access-visits-or-downloads.html | |
function download_count_actions($id = null, $step = 'get', $file = null){ | |
# Note for newbies: Because we know what we're doing, we will prepend the file functions with the at sign (@) to supress known PHP errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/////////////////////////////////////// | |
# WordPress Remote Request (Retreive) | |
/////////////////////////////////////// | |
$url = 'https://external-site.com/api/?json=1'; | |
// $response = file_get_contents($url); // old method | |
$request = wp_remote_get( $token_url, array( 'sslverify' => false, 'timeout' => 120 ) ); | |
$response = wp_remote_retrieve_body( $request ); | |
echo '<pre>'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/////////////////////////////////// | |
# Enqueue Human Comment Script | |
/////////////////////////////////// | |
add_action('wp_enqueue_scripts', 'add_human_comment_script'); // Add Theme Stylesheet | |
function add_human_comment_script(){ | |
wp_register_script('human_comments', admin_url() . 'admin-ajax.php?action=human_comments_script', array('jquery'), '1.0', true); | |
wp_enqueue_script('human_comments'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/////////////////////////////// | |
# COMPLETE METABOX EXAMPLE | |
/////////////////////////////// | |
/////////////////////////////// | |
# I. ADD METABOX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
///////////////////////////// | |
# Register Post Type | |
///////////////////////////// | |
add_action('init', 'register_post_type_review'); | |
function register_post_type_review(){ | |
# NOTE: to enable comments for your custom post type, you must set the option 'default_comment_status' to true: update_option('default_comment_status', true); | |
// or goto: WP ADMIN => SETTINGS => DISCUSSION => check the "Allow people to post comments on new articles" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
////////////////////////// | |
# Set Emails as HTML | |
////////////////////////// | |
if(!function_exists('set_html_content_type')){ | |
function set_html_content_type() { | |
return 'text/html'; | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//////////////////////////// | |
# WP AJAX EXAMPLE | |
//////////////////////////// | |
///////////////////////// | |
# Enqueue Script | |
///////////////////////// |