Skip to content

Instantly share code, notes, and snippets.

View codescribblr's full-sized avatar

Jonathan Wadsworth codescribblr

View GitHub Profile
@codescribblr
codescribblr / 0_reuse_code.js
Created February 6, 2014 19:47
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@codescribblr
codescribblr / Snipplr-65700.txt
Created February 13, 2014 21:41
Add custom styles to visual editor Wordpress
// Add custom CTA styles to TinyMCE editor
if ( ! function_exists('tdav_css') ) {
function tdav_css($wp) {
$wp .= ',' . get_bloginfo('stylesheet_directory') . '/css/tinymce.css';
return $wp;
}
}
add_filter( 'mce_css', 'tdav_css' );
@codescribblr
codescribblr / Snipplr-58530.txt
Created February 13, 2014 21:41
Connect to LDAP anonymously or with a uid/pass combo
<?php
// basic sequence with LDAP is connect, bind, search, interpret search
// result, close connection
// using ldap bind
$ldaprdn = 'userid'; // ldap rdn or dn
$ldappass = 'password'; // associated password
echo "<h3>LDAP query test</h3>";
echo "Connecting ...";
@codescribblr
codescribblr / Snipplr-70009.txt
Created February 13, 2014 21:41
Custom columns for wordpress custom post type
add_filter( 'manage_edit-events_columns', 'my_edit_events_columns' ) ;
function my_edit_events_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => __( 'Event' ),
'event-date' => __( 'Event Date' ),
'category' => __( 'Category' ),
'date' => __( 'Date' )
@codescribblr
codescribblr / Snipplr-67783.txt
Created February 13, 2014 21:41
Custom login page changes for Wordpress
function custom_login_logo() {
echo '<style type="text/css">
.login h1 a { background-image: url("http://craveacademy.com/wp-content/uploads/wordpress-logo.png") !important; }
</style>';
}
add_action('login_head', 'custom_login_logo');
function custom_login_url(){
return 'http://www.craveacademy.com/';
}
@codescribblr
codescribblr / Snipplr-71257.txt
Created February 13, 2014 21:41
Custom Page Templates in a WordPress Plugin
add_filter( 'page_template', 'wpa3396_page_template' );
function wpa3396_page_template( $page_template )
{
if ( is_page( 'my-custom-page-slug' ) ) {
$page_template = dirname( __FILE__ ) . '/custom-page-template.php';
}
return $page_template;
}
@codescribblr
codescribblr / Snipplr-67717.txt
Created February 13, 2014 21:41
custom post type custom update message
//add a custom message to the post message function
add_filter('post_updated_messages', 'listing_updated_messages');
function listing_updated_messages( $messages ) {
$messages['listing'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Listing updated. <a href="%s">View Listing</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
@codescribblr
codescribblr / Snipplr-67757.txt
Created February 13, 2014 21:41
Custom post type, taxonomy, and messages
// The register_post_type() function is not to be used before the 'init'.
add_action( 'init', 'my_custom_init' );
/* Here's how to create your customized labels */
function my_custom_init() {
$labels = array(
'name' => _x( 'Portfolio Galleries', 'post type general name' ), // Tip: _x('') is used for localization
'singular_name' => _x( 'Portfolio Gallery', 'post type singular name' ),
'add_new' => _x( 'Add New', 'Portfolio Gallery' ),
'add_new_item' => __( 'Add New Portfolio Gallery' ),
@codescribblr
codescribblr / Snipplr-70529.txt
Created February 13, 2014 21:41
Email Smime
<?php //view comments for instructions ?>
@codescribblr
codescribblr / Snipplr-72192.txt
Created February 13, 2014 21:41
Facebook Comments for Wordpress
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=Your App ID Here";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<meta property="fb:app_id" content="Your App ID Here"/>