Skip to content

Commit

Permalink
Version 1.4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdevore committed Apr 20, 2016
1 parent c3c6a3d commit d57ef8a
Show file tree
Hide file tree
Showing 17 changed files with 565 additions and 21 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Changelog

### 1.4
* PHP Code Sniffer WordPress standards updates throughout plugin files
* PHP CodeSniffer WordPress Standards updates throughout various plugin files
* Created the Topicals menu type, with widget, shortcode and WP-API output options
* Updated the output style of the shortcode item information
* Added the WP Dispensary icon to each CPT in the admin dashboard for easier recognition when you're in the admin dashboard
* Added `active_plugins` check for "Subtitles" plugin in `admin/wp-dispensary-rest-api.php` API output
* Added sanitization to $_POST in `admin/post-types/wp-dispensary-metaboxes.php` pre-roll flower selection drop down

### 1.3.1
* Fixed CBD being called BCD #typingtoofast
Expand Down
12 changes: 9 additions & 3 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: deviodigital
Donate link: http://www.wpdispensary.com
Tags: menu, dispensary, medical, marijuana, mmj, cannabis
Requires at least: 3.0.1
Tested up to: 4.4.2
Tested up to: 4.5
Stable tag: 1.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -72,7 +72,9 @@ You can call your menu anywhere shortcodes are accepted in your theme. The short

`[wpd-prerolls posts="6"]`

*please note that more options to customize output are being worked into the shortcode for future versions*
`[wpd-topicals posts="6"]`

*please note that more options to customize shortcode output are being worked into the shortcode for future versions*

### Extend WP Dispensary

Expand All @@ -98,7 +100,11 @@ You can view our current add-on's on the [offical WP Dispensary website](http://
== Changelog ==

= 1.4 =
* PHP Code Sniffer WordPress standards updates throughout plugin files
* PHP CodeSniffer WordPress Standards updates throughout various plugin files
* Created the Topicals menu type, with widget, shortcode and WP-API output options
* Updated the output style of the shortcode item information
* Added the WP Dispensary icon to each CPT in the admin dashboard for easier recognition when you're in the admin dashboard
* Added `active_plugins` check for "Subtitles" plugin in `admin/wp-dispensary-rest-api.php` API output

= 1.3.1 =
* Fixed CBD being called BCD #typingtoofast
Expand Down
6 changes: 4 additions & 2 deletions admin/css/wp-dispensary-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@
#dashboard_right_now .concentrates-count a:before,
#dashboard_right_now .concentrates-count span:before,
#dashboard_right_now .prerolls-count a:before,
#dashboard_right_now .prerolls-count span:before {
#dashboard_right_now .prerolls-count span:before,
#dashboard_right_now .topicals-count a:before,
#dashboard_right_now .topicals-count span:before {
content: "\f345";
}


/* Leafly Reviews admin
/* Widget styles
-------------------------------------------------------------- */

div.widget[id*=_wpdispensary_] .widget-top,
Expand Down
Binary file added admin/post-types/images/menu-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions admin/post-types/wp-dispensary-concentrates.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function wpdispensary_concentrates() {
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-arrow-right-alt2',
'menu_position' => 10,
'menu_icon' => plugin_dir_url( __FILE__ ) . ( 'images/menu-icon.png' ),
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
Expand Down
4 changes: 2 additions & 2 deletions admin/post-types/wp-dispensary-edibles.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function wpdispensary_edibles() {
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-arrow-right-alt2',
'menu_position' => 10,
'menu_icon' => plugin_dir_url( __FILE__ ) . ( 'images/menu-icon.png' ),
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
Expand Down
4 changes: 2 additions & 2 deletions admin/post-types/wp-dispensary-flowers.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function wpdispensary_flowers() {
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-arrow-right-alt2',
'menu_position' => 10,
'menu_icon' => plugin_dir_url( __FILE__ ) . ( 'images/menu-icon.png' ),
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
Expand Down
105 changes: 104 additions & 1 deletion admin/post-types/wp-dispensary-metaboxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ function select_box( $post ) {
}
function save_post( $post_id, $post ) {
if ( $post->post_type == $this->FOR_POST_TYPE && isset( $_POST[ $this->field_name ] ) ) {
update_post_meta( $post_id, $this->meta_key, $_POST[ $this->field_name ] );
$prerollflower = sanitize_text_field( $_POST['selected_flowers'] );
update_post_meta( $post_id, $this->meta_key, $prerollflower );
}
}
}
Expand Down Expand Up @@ -468,3 +469,105 @@ function wpdispensary_save_thcmg_meta( $post_id, $post ) {
}

add_action( 'save_post', 'wpdispensary_save_thcmg_meta', 1, 2 ); /** save the custom fields */



/**
* Topicals THC & CBD content metabox
*
* Adds a THC & CBD content metabox to the topicals custom post type
*
* @since 1.4.0
*/

function add_thccbdtopical_metaboxes() {

$screens = array( 'topicals' );

foreach ( $screens as $screen ) {
add_meta_box(
'wpdispensary_thccbdtopical',
__( 'Product Information', 'wp-dispensary' ),
'wpdispensary_thccbdtopical',
$screen,
'side',
'default'
);
}

}

add_action( 'add_meta_boxes', 'add_thccbdtopical_metaboxes' );

function wpdispensary_thccbdtopical() {
global $post;

/** Noncename needed to verify where the data originated */
echo '<input type="hidden" name="thccbdtopical_noncename" id="thccbdtopical_noncename" value="' .
wp_create_nonce( plugin_basename( __FILE__ ) ) . '" />';

/** Get the thc mg data if its already been entered */
$pricetopicals = get_post_meta( $post->ID, '_pricetopical', true );
$thctopicals = get_post_meta( $post->ID, '_thctopical', true );
$cbdtopicals = get_post_meta( $post->ID, '_cbdtopical', true );
$sizetopicals = get_post_meta( $post->ID, '_sizetopical', true );

/** Echo out the fields */
echo '<p>Price per unit:</p>';
echo '<input type="text" name="_pricetopical" value="' . $pricetopicals . '" class="widefat" />';
echo '<p>Size (oz):</p>';
echo '<input type="text" name="_sizetopical" value="' . $sizetopicals . '" class="widefat" />';
echo '<p>THC mg:</p>';
echo '<input type="number" name="_thctopical" value="' . $thctopicals . '" class="widefat" />';
echo '<p>CBD mg:</p>';
echo '<input type="number" name="_cbdtopical" value="' . $cbdtopicals . '" class="widefat" />';

}

/** Save the Metabox Data */

function wpdispensary_save_thccbdtopical_meta( $post_id, $post ) {

/**
* Verify this came from the our screen and with proper authorization,
* because save_post can be triggered at other times
*/
if ( ! wp_verify_nonce( $_POST['thccbdtopical_noncename'], plugin_basename( __FILE__ ) ) ) {
return $post->ID;
}

/** Is the user allowed to edit the post or page? */
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return $post->ID;
}

/**
* OK, we're authenticated: we need to find and save the data
* We'll put it into an array to make it easier to loop though.
*/

$thcmgtopical_meta['_pricetopical'] = $_POST['_pricetopical'];
$thcmgtopical_meta['_thctopical'] = $_POST['_thctopical'];
$thcmgtopical_meta['_cbdtopical'] = $_POST['_cbdtopical'];
$thcmgtopical_meta['_sizetopical'] = $_POST['_sizetopical'];

/** Add values of $thcmg_meta as custom fields */

foreach ( $thcmgtopical_meta as $key => $value ) { /** Cycle through the $thcmg_meta array! */
if ( $post->post_type == 'revision' ) { /** Don't store custom data twice */
return;
}
$value = implode( ',', (array) $value ); /** If $value is an array, make it a CSV (unlikely) */
if ( get_post_meta( $post->ID, $key, false ) ) { /** If the custom field already has a value */
update_post_meta( $post->ID, $key, $value );
} else { /** If the custom field doesn't have a value */
add_post_meta( $post->ID, $key, $value );
}
if ( ! $value ) { /** Delete if blank */
delete_post_meta( $post->ID, $key );
}
}

}

add_action( 'save_post', 'wpdispensary_save_thccbdtopical_meta', 1, 2 ); /** save the custom fields */
4 changes: 2 additions & 2 deletions admin/post-types/wp-dispensary-prerolls.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ function wpdispensary_prerolls() {
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-arrow-right-alt2',
'menu_position' => 10,
'menu_icon' => plugin_dir_url( __FILE__ ) . ( 'images/menu-icon.png' ),
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
Expand Down
43 changes: 43 additions & 0 deletions admin/post-types/wp-dispensary-taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,47 @@ function wpdispensary_concentratecategory() {

}

/**
* Topical Category Taxonomy
*
* Adds the Topical Category taxonomy to all custom post types
*
* @since 1.4.0
*/

add_action( 'init', 'wpdispensary_topicalcategory', 0 );

function wpdispensary_topicalcategory() {

$labels = array(
'name' => _x( 'Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Categories' ),
'all_items' => __( 'All Categories' ),
'parent_item' => __( 'Parent Category' ),
'parent_item_colon' => __( 'Parent Category:' ),
'edit_item' => __( 'Edit Category' ),
'update_item' => __( 'Update Category' ),
'add_new_item' => __( 'Add New Category' ),
'new_item_name' => __( 'New Category Name' ),
'not_found' => 'No categories found',
'menu_name' => __( 'Categories' ),
);

register_taxonomy('topicals_category','topicals', array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'show_in_nav_menus' => false,
'query_var' => true,
'rewrite' => array(
'slug' => 'topicals/category',
'with_front' => false
),
));

}

?>
71 changes: 71 additions & 0 deletions admin/post-types/wp-dispensary-topicals.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* Topicals post type
*
* This file is used to create the 'Topicals' custom post type.
*
* @link http://www.wpdispensary.com
* @since 1.4.0
*
* @package WP_Dispensary
* @subpackage WP_Dispensary/admin/post-types
*/

/**
* Topical post type
*
* Add custom type for Topicals
*
* @since 1.4.0
*/
function wpdispensary_topicals() {

$labels = array(
'name' => _x( 'Topicals', 'Post Type General Name', 'wp-dispensary' ),
'singular_name' => _x( 'Topical', 'Post Type Singular Name', 'wp-dispensary' ),
'menu_name' => __( 'Topicals', 'wp-dispensary' ),
'name_admin_bar' => __( 'Topicals', 'wp-dispensary' ),
'parent_item_colon' => __( 'Parent Topical:', 'wp-dispensary' ),
'all_items' => __( 'All Topicals', 'wp-dispensary' ),
'add_new_item' => __( 'Add New Topical', 'wp-dispensary' ),
'add_new' => __( 'Add New', 'wp-dispensary' ),
'new_item' => __( 'New Topical', 'wp-dispensary' ),
'edit_item' => __( 'Edit Topical', 'wp-dispensary' ),
'update_item' => __( 'Update Topical', 'wp-dispensary' ),
'view_item' => __( 'View Topical', 'wp-dispensary' ),
'search_items' => __( 'Search Topical', 'wp-dispensary' ),
'not_found' => __( 'Not found', 'wp-dispensary' ),
'not_found_in_trash' => __( 'Not found in Trash', 'wp-dispensary' ),
);
$rewrite = array(
'slug' => 'topicals',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => __( 'Topicals', 'wp-dispensary' ),
'description' => __( 'Topical products that our dispensary offers', 'wp-dispensary' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions' ),
'taxonomies' => array(),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_rest' => true,
'menu_position' => 10,
'menu_icon' => plugin_dir_url( __FILE__ ) . ( 'images/menu-icon.png' ),
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'post',
);
register_post_type( 'topicals', $args );

}
add_action( 'init', 'wpdispensary_topicals', 0 );
Loading

0 comments on commit d57ef8a

Please sign in to comment.