Skip to content

Instantly share code, notes, and snippets.

View robertdevore's full-sized avatar
🛠️
#NeverNotWorking

Robert DeVore robertdevore

🛠️
#NeverNotWorking
View GitHub Profile
@robertdevore
robertdevore / wpd-display-categories.php
Last active April 30, 2017 13:32
WP Dispensary - display categories at the bottom of the Details table
<?php
/**
* WPD - Display categories in the Data Details table
*/
add_action( 'wpd_dataoutput_bottom', 'add_wpd_categories' );
function add_wpd_categories() { ?>
<?php if ( in_array( get_post_type(), array( 'flowers' ) ) ) { ?>
<tr><td><span>Categories:</span></td><td><?php echo get_the_term_list( $post->ID, 'flowers_category', '', ', ' ); ?></td></tr>
<?php } ?>
<?php if ( in_array( get_post_type(), array( 'concentrates' ) ) ) { ?>
@robertdevore
robertdevore / wp-dispensary-inventory-management-remove-actions.php
Last active May 15, 2017 21:37
Remove public "In Stock" message from the Dispensary Inventory Management add-on via WP Dispensary
<?php
/** Removes the Inventory Management add-on's front end display of available inventory */
add_action( 'wpd_dataoutput_bottom', 'remove_wpd_inventory_data', 1 );
function remove_wpd_inventory_data() {
remove_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data_flowers' );
remove_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data_concentrates' );
remove_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data_edibles' );
remove_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data_prerolls' );
remove_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data_topicals' );
remove_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data_growers' );
@robertdevore
robertdevore / wp-dispensary-inventory-management-add-actions.php
Created April 30, 2017 14:35
Add your own "In Stock" message to the Dispensary Inventory Management add-on via WP Dispensary
<?php
/** Adds a new version of the In Stock message for each menu type */
add_action( 'wpd_dataoutput_bottom', 'add_wpd_inventory_data', 10 );
function add_wpd_inventory_data() { ?>
<?php if ( ! get_post_meta( get_the_ID(), '_inventory_flowers', true ) ) { } else { ?>
<tr><td><span>In stock:</span></td><td>YES</td></tr>
<?php } ?>
<?php if ( ! get_post_meta( get_the_ID(), '_inventory_concentrates', true ) ) { } else { ?>
<tr><td><span>In stock:</span></td><td>YES</td></tr>
<?php } ?>
@robertdevore
robertdevore / wpd-shortcode-view-details-button.php
Created May 12, 2017 19:05
Add a "view details" button to the bottom of the WP Dispensary shortcode output
<?php
/**
* WP Dispensary - view details button
*/
add_action( 'wpd_shortcode_inside_bottom', 'acme_viewdetails' );
function acme_viewdetails() { ?>
<p><a href="<?php the_permalink(); ?>" class="acme-button">View Details</a></p>
<?php } // function acme_viewdetails
@robertdevore
robertdevore / wp-dispensary-locations-shortcode-display.php
Created May 15, 2017 23:47
Display your menu item's selected locations to shortcode output
<?php
/**
* Display your selected location(s) within the WP Dispensary shortcodes
* Requires the "Dispensary Locations" add-on from WP Dispensary
*
* @link https://www.wpdispensary.com/downloads/dispensary-locations
*/
add_action( 'wpd_shortcode_inside_top', 'acme_mylocation' );
function acme_mylocation() {
global $post;
@robertdevore
robertdevore / wp-dispensary-locations-shortcode-display.css
Created May 15, 2017 23:51
Quick CSS styles for the dispensary locations output code snippet
span.mylocation {
background: #FFF;
font-size: 13px;
padding: 10px;
position: absolute;
top: 5px;
right: 5px;
}
@robertdevore
robertdevore / oembed-content.php
Created June 21, 2017 14:04
change oembed from the_excerpt to the_content
<?php
add_filter( 'the_excerpt_embed', 'get_excerpt_embed' );
function get_excerpt_embed( $output ) {
return the_content();
return $output;
}
@robertdevore
robertdevore / wp-cpt-flush-rewrite-on-activation.php
Last active June 23, 2017 09:08
Flush rewrite rules on plugin activation to stop your CPT from returning 404 errors
<?php
function activate_acme_cpt() {
cpt_function();
/** CPT taxonomy functions can be added too */
cpt_tax_function();
global $wp_rewrite;
$wp_rewrite->init();
$wp_rewrite->flush_rules();
}
@robertdevore
robertdevore / wp-featured-image-link-wrap.php
Last active June 23, 2017 14:17
Display your featured image wrapped in a link to the post
@robertdevore
robertdevore / storefront-remove-welcome-link.php
Last active January 12, 2018 10:27
Removes the "Storefront" link from under the Appearance tab in your dashboard