Skip to content

Instantly share code, notes, and snippets.

@digitalinkwell
digitalinkwell / enable-core-auto-updates.php
Created July 29, 2015 18:34
enable-core-auto-updates
# Enable all core updates, including minor and major:
define( 'WP_AUTO_UPDATE_CORE', true );
@digitalinkwell
digitalinkwell / dashboard-instruction-widget.php
Created August 11, 2015 17:40
dashboard-instruction-widget
add_action( 'wp_dashboard_setup', 'register_my_dashboard_widget' );
function register_my_dashboard_widget() {
wp_add_dashboard_widget(
'my_dashboard_widget',
'My Dashboard Widget',
@digitalinkwell
digitalinkwell / postviews.php
Created February 24, 2016 19:51
Post views
<?php
// function to display number of posts.
function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return "0 View";
}
@digitalinkwell
digitalinkwell / getjetpackpostviews.php
Created February 24, 2016 22:27
Get Jetpack post views
<?php
// extract JetPack pageviews
// courtesy of Topher: http://wpgr.org/2013/03/02/rendering-jetpack-stats/
function get_page_views($post_id) {
if (function_exists('stats_get_csv')) {
$args = array('days'=>-1, 'limit'=>-1, 'post_id'=>$post_id);
$result = stats_get_csv('postviews', $args);
@digitalinkwell
digitalinkwell / postviewentrymeta.php
Created February 24, 2016 22:35
Post View Entry Meta
<div class="entry-meta">
<?php twentythirteen_entry_meta(); ?>
<?php
// adding page views after Meta Information
$post_id = get_the_ID();
$pageviews = get_page_views($post_id);
echo "$pageviews Views.";
// end of views
?>
function doctype_opengraph($output) {
return $output . '
xmlns:og="http://opengraphprotocol.org/schema/"
xmlns:fb="http://www.facebook.com/2008/fbml"';
}
function fb_opengraph() {
global $post;
if(is_single()) {
if(has_post_thumbnail($post->ID)) {
<meta property="og:title" content="<?php echo the_title(); ?>"/>
<meta property="og:description" content="<?php echo $excerpt; ?>"/>
<meta property="og:type" content="article"/>
<meta property="og:url" content="<?php echo the_permalink(); ?>"/>
<meta property="og:site_name" content="<?php echo get_bloginfo(); ?>"/>
<?php
/*
Plugin Name: Sample Plugin
Plugin URI: http://samplepluginsite.com
Description: Sample plugin that's ready for translation
Author: John Doe
Version: 1.0
Author URI: http://johndoe.com
Text Domain: sample-plugin
Domain Path: /languages/
<?php
function load_plugin_textdomain() {
load_plugin_textdomain( 'sample-plugin', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'load_plugin_textdomain' );