\n"; } add_action('admin_head', 'apschema_admin_register_head'); // Show box on posts add_action( 'the_content', 'apschema_set_box' ); function apschema_set_box($content) { $values = get_post_custom( $post->ID ); $apschema_keyword = isset( $values['my_meta_box_keyword'] ) ? esc_attr( $values['my_meta_box_keyword'][0] ) : ''; $apschema_afflink = isset( $values['my_meta_box_afflink'] ) ? esc_attr( $values['my_meta_box_afflink'][0] ) : ''; $apschema_producturl = isset( $values['my_meta_box_producturl'] ) ? esc_attr( $values['my_meta_box_producturl'][0] ) : ''; $apschema_productdesc = isset( $values['my_meta_box_productdesc'] ) ? esc_attr( $values['my_meta_box_productdesc'][0] ) : ''; $apschema_display = isset( $values['my_meta_box_display'] ) ? esc_attr( $values['my_meta_box_display'][0] ) : ''; $apschema_rating = isset( $values['my_meta_box_rating'] ) ? esc_attr( $values['my_meta_box_rating'][0] ) : ''; $apschema_bottom = isset( $values['my_meta_box_bottom'] ) ? esc_attr( $values['my_meta_box_bottom'][0] ) : ''; $apschema_options = get_option('apschema_settings'); $apschema_custom_date = isset( $values['my_meta_box_custom_date'] ) ? esc_attr( $values['my_meta_box_custom_date'][0] ) : ''; $apschema_todays_date = isset( $values['my_meta_box_todays_date'] ) ? esc_attr( $values['my_meta_box_todays_date'][0] ) : ''; $origpostdate = get_the_date($d, $the_post->post_parent); $origposttime = get_the_time($d, $the_post->post_parent); $dateline = $origpostdate.' '.$origposttime; $reviewdate = $origpostdate; if($apschema_todays_date == 'on') { $reviewdate = date('j F Y'); } if(!empty($apschema_custom_date) && $apschema_todays_date == 'off') { $reviewdate = $apschema_custom_date; } if($apschema_rating<=0.5) {$testcount = 0.5;} if($apschema_rating>0.5 && $apschema_rating<=1) {$testcount = 1;} if($apschema_rating>1 && $apschema_rating<=1.5) {$testcount = 1.5;} if($apschema_rating>1.5 && $apschema_rating<=2) {$testcount = 2;} if($apschema_rating>2 && $apschema_rating<=2.5) {$testcount = 2.5;} if($apschema_rating>2.5 && $apschema_rating<=3) {$testcount = 3;} if($apschema_rating>3 && $apschema_rating<=3.5) {$testcount = 3.5;} if($apschema_rating>3.5 && $apschema_rating<=4) {$testcount = 4;} if($apschema_rating>4 && $apschema_rating<=4.5) {$testcount = 4.5;} if($apschema_rating>4.5 && $apchema_rating<=5) {$testcount = 5;} if(!empty($apschema_options['starsimg'])) { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars']=="yellow_round") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars'] == "green_round") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars'] == "blue_round") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars'] == "yellow_sharp") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } else { echo ""; } if ($apschema_display == 'on' && (is_single() || is_page()) && $apschema_bottom == 'off') { ob_start(); # start buffer include 'inc/boxcontent.php'; # we pass the output to a variable $boxattop = ob_get_clean(); $boxattop .= $content; return $boxattop; } elseif ($apschema_display == 'on' && (is_single() || is_page()) && $apschema_bottom == 'on') { //Annoying that I have to duplicate this, but cannot get ob_start and globals to work with it $values = get_post_custom( $post->ID ); $apschema_keyword = isset( $values['my_meta_box_keyword'] ) ? esc_attr( $values['my_meta_box_keyword'][0] ) : ''; $apschema_afflink = isset( $values['my_meta_box_afflink'] ) ? esc_attr( $values['my_meta_box_afflink'][0] ) : ''; $apschema_producturl = isset( $values['my_meta_box_producturl'] ) ? esc_attr( $values['my_meta_box_producturl'][0] ) : ''; $apschema_productdesc = isset( $values['my_meta_box_productdesc'] ) ? esc_attr( $values['my_meta_box_productdesc'][0] ) : ''; $apschema_display = isset( $values['my_meta_box_display'] ) ? esc_attr( $values['my_meta_box_display'][0] ) : ''; $apschema_rating = isset( $values['my_meta_box_rating'] ) ? esc_attr( $values['my_meta_box_rating'][0] ) : ''; $apschema_bottom = isset( $values['my_meta_box_bottom'] ) ? esc_attr( $values['my_meta_box_bottom'][0] ) : ''; $apschema_options = get_option('apschema_settings'); $origpostdate = get_the_date($d, $the_post->post_parent); $origposttime = get_the_time($d, $the_post->post_parent); $dateline = $origpostdate.' '.$origposttime; $reviewdate = $origpostdate; if($apschema_todays_date == 'on') { $reviewdate = date('j F Y'); } if(!empty($apschema_custom_date) && $apschema_todays_date == 'off') { $reviewdate = $apschema_custom_date; } if($apschema_rating<=0.5) {$testcount = 0.5;} if($apschema_rating>0.5 && $apschema_rating<=1) {$testcount = 1;} if($apschema_rating>1 && $apschema_rating<=1.5) {$testcount = 1.5;} if($apschema_rating>1.5 && $apschema_rating<=2) {$testcount = 2;} if($apschema_rating>2 && $apschema_rating<=2.5) {$testcount = 2.5;} if($apschema_rating>2.5 && $apschema_rating<=3) {$testcount = 3;} if($apschema_rating>3 && $apschema_rating<=3.5) {$testcount = 3.5;} if($apschema_rating>3.5 && $apschema_rating<=4) {$testcount = 4;} if($apschema_rating>4 && $apschema_rating<=4.5) {$testcount = 4.5;} if($apschema_rating==5) {$testcount = 5;} if(!empty($apschema_options['starsimg'])) { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars']=="yellow_round") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars'] == "green_round") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars'] == "blue_round") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } elseif($apschema_options['premadestars'] == "yellow_sharp") { $full_star_image = ''.$apschema_keyword.'Rating'; $empty_star_image = ''.$apschema_keyword.'Rating'; $half_star_image = ''.$apschema_keyword.'Rating'; } else { echo ""; } ob_start(); # start buffer include 'inc/boxcontent.php'; # we pass the output to a variable $boxatbottom = ob_get_clean(); $content .= $boxatbottom; return $content; } elseif ( $apschema_display !== 'on' OR is_category() OR is_tag) { return $content; } } //end function apschema_set_box