Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Plugin Name: PluginName
* Plugin URI: http://websiteurl
* Description: Description
* Version: 1.0
* Author: Brian DiChiara
* Author URI: http://www.briandichiara.com
*/
<?php
if(class_exists('Plugin')) return;
class Plugin {
var $debug = false;
var $admin_page = 'plugin';
var $settings = array();
var $errors = array();
@solepixel
solepixel / CPT-Letter-Anchors.php
Last active January 21, 2022 03:07
Generate Letter Anchors for your Custom Post Types in WordPress
<?php
$alphabet = range('A','Z');
$letters = array();
while( $the_query->have_posts() ) : $the_query->the_post();
$lname = get_post_meta(get_the_ID(), $prefix.'lname', true);
$first = strtoupper(substr(trim($lname), 0, 1));
if($first && !in_array($first, $letters)){
$letters[] = $first;
}
endwhile;
<?php
$start_section = array();
$my_section = array();
$end_section = array();
$started = false;
foreach ($arr as $item) {
if (strpos($item, '?param=my_val') !== false) {
$my_section[] = $item;
$started = true;
@solepixel
solepixel / CTXPS_Security.php
Last active December 16, 2015 08:39
PHP warnings fix
<?php
// ...
/* Line 91 */
public static function filter_loops($content){
global $current_user;
//Get plugin options
$dbOpts = get_option('contexture_ps_options');
@solepixel
solepixel / get-page-shortcode.php
Last active December 16, 2015 10:29
WordPress shortcode to get a page's content
<?php
add_shortcode('get-page', 'mytheme_get_page');
function mytheme_get_page($atts=array(), $content=NULL){
extract(shortcode_atts(array(
'page' => NULL
), $atts));
if(!$page){
return '';
}
@solepixel
solepixel / delete-them-all.php
Last active December 17, 2015 23:19
Delete Them All Plugin for WordPress
<?php
/**
* Plugin Name: Delete Them All!
* Plugin URI: http://infomedia.com
* Description: Delete ALL posts and associated data, leaving your database nice and clean!
* Version: 1.0
* Author: Brian DiChiara
* Author URI: http://www.briandichiara.com
*/
@solepixel
solepixel / index.html
Created June 3, 2013 20:53
Temporary index.html file for site launching.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="Brian DiChiara" />
<title>Launching...</title>
<style type="text/css">
* { margin:0; padding:0; }
body, html, .container { background:#2f2f2f; }
p { margin:100px auto; text-align:center; font-size:0; width:373px; height:29px; background:url(http://assets.infomedia.net/launching.gif) no-repeat 50% 50%; }
@solepixel
solepixel / stacked-date.php
Last active December 19, 2015 00:49
Stacked Date
$prefix = hybrid_get_prefix();
add_filter( "{$prefix}_byline", 'wwon_byline');
function wwon_byline($byline){
if(!is_single()){
$byline = '<div class="post-date">
<span class="post-date-month">'.get_the_date('M').'</span>
<span class="post-date-day">'.get_the_date('d').'</span>
</div>
@solepixel
solepixel / image-widget.php
Created August 25, 2013 14:48
Suggested change for Tri.be Image Widget plugin, image-widget/image-widget.php, See line 32 and 84 for changes.
<?php
class Tribe_Image_Widget extends WP_Widget {
// ...
private function get_image_html( $instance, $include_link = true ) {
// Backwards compatible image display.
if ( $instance['attachment_id'] == 0 && $instance['image'] > 0 ) {