Skip to content

Instantly share code, notes, and snippets.

View theodorocaliari's full-sized avatar
💻

Theodoro Caliari theodorocaliari

💻
View GitHub Profile
<?php
/**
* Include the following code in your theme functions.php;
* but first you need to include PHP Console library using one of the methods
* described in PHP Console documentation.
*/
$phpConsole = PhpConsole\Handler::getInstance()->isStarted();
// This check makes sure PHP Console is instantiated only once.
if ( $phpConsole == false ) {
<?php
/*
Here's a couple of metaboxes that I've recently created using this system
*/
$subpostings = redrokk_metabox_class::getInstance('subpostings', array(
'title' => '(optional) Subscription for Postings',
'description' => "As an optional feature, you have a complete api at your disposal which will allow you the ability to offer and manage member posts. In addition to these settings, you may need to create the associated pages for accepting posts from your frontend.",
@theodorocaliari
theodorocaliari / page-template.php
Created December 8, 2014 11:27
Verify if the_content() is empty
<?php
//https://wordpress.org/support/topic/how-can-i-avoid-displaying-empty-the_content
if($post->post_content != ""){
the_content();
}
<?php
// Add Password, Repeat Password and Are You Human fields to WordPress registration form
// http://wp.me/p1Ehkq-gn
add_action( 'register_form', 'ts_show_extra_register_fields' );
function ts_show_extra_register_fields(){
?>
<p>
<label for="password">Password<br/>
<input id="password" class="input" type="password" tabindex="30" size="25" value="" name="password" />
<?php
/**
* Count number of widgets in a sidebar
* Used to add classes to widget areas so widgets can be displayed one, two, three or four per row
*/
function slbd_count_widgets( $sidebar_id ) {
// If loading from front page, consult $_wp_sidebars_widgets rather than options
// to see if wp_convert_widget_settings() has made manipulations in memory.
global $_wp_sidebars_widgets;
<?php
/**
* Get posts and group by taxonomy terms.
* @param string $posts Post type to get.
* @param string $terms Taxonomy to group by.
* @param integer $count How many post to show per taxonomy term.
*/
function list_posts_by_term( $posts, $terms, $count = -1 ) {
$tax_terms = get_terms( $terms, 'orderby=name');
foreach ( $tax_terms as $term ) {
@theodorocaliari
theodorocaliari / 1.WordPress ShortCode.md
Last active August 29, 2015 14:07
WordPress ShortCode
@theodorocaliari
theodorocaliari / roles-and-capabilities.md
Last active August 29, 2015 14:03
Wordpress Roles and Capabilities