Skip to content

Instantly share code, notes, and snippets.

@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 / 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');
<?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 / 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
if(class_exists('Plugin')) return;
class Plugin {
var $debug = false;
var $admin_page = 'plugin';
var $settings = array();
var $errors = array();
<?php
/**
* Plugin Name: PluginName
* Plugin URI: http://websiteurl
* Description: Description
* Version: 1.0
* Author: Brian DiChiara
* Author URI: http://www.briandichiara.com
*/