_x( 'Reviews', 'post type general name', 'amz-plugin' ),
'singular_name' => _x( 'Review', 'post type singular name', 'amz-plugin' ),
'menu_name' => _x( 'Reviews', 'admin menu', 'amz-plugin' ),
'name_admin_bar' => _x( 'Review', 'add new on admin bar', 'amz-plugin' ),
'add_new' => _x( 'Add New', 'review', 'amz-plugin' ),
'add_new_item' => __( 'Add New Review', 'amz-plugin' ),
'new_item' => __( 'New Review', 'amz-plugin' ),
'edit_item' => __( 'Edit Review', 'amz-plugin' ),
'view_item' => __( 'View Review', 'amz-plugin' ),
'all_items' => __( 'All Reviews', 'amz-plugin' ),
'search_items' => __( 'Search Reviews', 'amz-plugin' ),
'parent_item_colon' => __( 'Parent Reviews:', 'amz-plugin' ),
'not_found' => __( 'No reviews found.', 'amz-plugin' ),
'not_found_in_trash' => __( 'No reviews found in Trash.', 'amz-plugin' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', 'amz-plugin' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'reviews' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 5,
'taxonomies' => array('category', 'post_tag'),
'supports' => array('title', 'editor', 'author', 'comments', 'revisions', 'thumbnail'),
'menu_icon' => 'dashicons-star-filled'
);
if (!post_type_exists('reviews')) {
register_post_type( 'reviews', $args );
add_action('init', 'amz_reviews_add_default_boxes');
function amz_reviews_add_default_boxes() {
register_taxonomy_for_object_type('category', 'reviews');
register_taxonomy_for_object_type('post_tag', 'reviews');
}
}
if (post_type_exists('reviews')) {
register_post_type( 'reviews', $args );
require_once('reviewcustomfields.php');
}
}
/**
* Include CSS file for MyPlugin.
*/
function amz_plugin_scripts() {
wp_register_style( 'amz-styles', plugin_dir_url( __FILE__ ) . 'style.css' );
wp_enqueue_style( 'amz-styles' );
}
add_action( 'wp_enqueue_scripts', 'amz_plugin_scripts' );
// Recent Reviews Sidebar Widget
function amz_widget_reviews_display($args) {
echo $args['before_widget'];
echo $args['before_title'] . 'Recent Reviews' . $args['after_title'];
?>
have_posts()): ?>
have_posts()): $treviews->the_post(); ?>
-
'.esc_html($post->post_title).' - Review
';
$rating=sprintf("%.1f",esc_html(get_post_meta( get_the_ID(), 'amz_rating', true )));
$expertrating=sprintf("%.1f",esc_html(get_post_meta( get_the_ID(), 'amz_rating_expert', true )));
if ($rating) {
$inf.='';
}
$inf.='';
$feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$inf.='
';
$manufacturer=esc_html(get_post_meta( get_the_ID(), 'amz_manufacturer', true ));
if(!empty($manufacturer)){
$inf.='Manufacturer: '.$manufacturer.'
';
}
$brand=esc_html(get_post_meta( get_the_ID(), 'amz_brand', true ));
if(!empty($brand)){
$inf.='';
if(empty($manufacturer)) $inf.="Manufacturer/";
$inf.='Brand: '.$brand.'
';
}
$model=esc_html(get_post_meta( get_the_ID(), 'amz_model', true ));
if(!empty($model)){
$inf.='Model: '.$model.'
';
}
$asin=esc_html(get_post_meta( get_the_ID(), 'amz_asin', true ));
if(!empty($asin)){
$inf.='ASIN: '.$asin.'
';
}
$ean=esc_html(get_post_meta( get_the_ID(), 'amz_ean', true ));
if(!empty($ean)){
$inf.='EAN: '.$ean.'
';
}
$cats=esc_html(get_post_meta( get_the_ID(), 'amz_categories', true ));
if(!empty($cats)){
$inf.='Available in Categories: '.$cats.'
';
}
$inf.='
';
$bullets=get_post_meta( get_the_ID(), 'amz_bullet' );
if(!empty($bullets)){
$inf.=' Features
';
foreach($bullets as $bullet){
$inf.='- '.esc_html($bullet).'
';
}
$inf.='
';
}
$inf.='
';
}
return $inf;
}
//
//[amz-specs] - Specifications
add_shortcode( 'amz-specs', 'amz_specs' );
function amz_specs(){
global $post;
$ptype=get_post_type($post);
if(!in_array($ptype, array('reviews', 'product'))) return;
$spc=''; $specs=get_post_meta( $post->ID, 'amz_specs' );
if(!empty($specs)){
$spc='';
}
return $spc;
}
//
//[amz-bottom-buybox]
add_shortcode( 'amz-bottom-buybox', 'amz_bottom_buybox' );
function amz_bottom_buybox(){
global $post;
$ptype=get_post_type($post);
if(!in_array($ptype, array('reviews', 'product'))) return;
$url=esc_url(get_post_meta( $post->ID, 'amz_url', true ));
$asin=esc_html(get_post_meta( $post->ID, 'amz_asin',true ));
$feat_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$ret='';
return $ret;
}
//
//[amz-expert]
add_shortcode( 'amz-expert', 'amz_expert' );
function amz_expert(){
return '';
}
// Reviews - Questions
// [amz-reviews-questions]
add_shortcode( 'amz-reviews-questions', 'amz_reviews_questions' );
function amz_reviews_questions(){
global $post;
$ptype=get_post_type($post);
if(!in_array($ptype, array('reviews', 'product'))) return;
global $amz_tag, $loc;
$id = $post->ID;
//if($GLOBALS['post']){
$url=esc_url(get_post_meta( $id, 'amz_url', true ));
$asin=esc_html(get_post_meta( $id, 'amz_asin',true ));
$eazyazon=esc_html(get_option("easyazon-settings"));
$loc=$eazyazon['default_search_locale'];
$amz_tag="";
if($loc == "US") $amz_tag=$eazyazon['associates_us'];
if($loc == "UK") $amz_tag=$eazyazon['associates_uk'];
$box1 = ''; $box2 = ''; $clear='';
$opinions=get_post_meta( $id, 'amz_opinions', true );
$out='';
if(!empty($opinions)){$box1='';}
$questions=get_post_meta( $id, 'amz_questions', true );
if(!empty($questions)){$box2='';}
if(!empty($box1) || !empty($box2)){
$out=$clear.$box1.$box2.$clear;
}
return $out;
//}
}
// working on
// [amz-proscons]
add_shortcode( 'amz-proscons', 'amz_proscons' );
function amz_proscons(){
global $post; $id=$post->ID;
$pross = get_post_meta( $id, 'amz_pros', true );
$conss = get_post_meta( $id, 'amz_cons', true );
$pc='';
if (!empty($pross) || !empty($conss)) {
$pc.='';
}
return $pc;
}
// Inserts our content before & after main content
// by executing the shortcode functions & returning
// their content in a string
function amz_content_filter($content) {
global $post;
$ptype=get_post_type($post);
if(!in_array($ptype, array('reviews', 'product'))) return $content;
if(get_option('amz_cont', 'insert')=='insert'){
$clr='';
$inf=do_shortcode('[amz-main-infobox]');
$spc=do_shortcode('[amz-specs]');
$anc=do_shortcode('[amz-expert]');
$qaa=do_shortcode('[amz-reviews-questions]');
$con=do_shortcode('[amz-proscons]');
$buy=do_shortcode('[amz-bottom-buybox]');
$out=$clr.$inf.$spc.$clr.$anc.$content.$clr.$qaa.$con.$buy;
return $out;
}else{
return $content;
}
}
add_filter( 'the_content', 'amz_content_filter' ,9);
?>