\n";
}
add_action('admin_head', 'apschema_admin_register_head');
// Show box on posts
add_action( 'the_post', 'apschema_set_box', 0 );
function apschema_set_box() {
$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 = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars']=="yellow_round") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars'] == "green_round") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars'] == "blue_round") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars'] == "yellow_sharp") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
}
else {
echo "";
}
if ($apschema_display == 'on' && (is_single() || is_page()) && $apschema_bottom == 'off') {
include 'inc/boxcontent.php';
} elseif ($apschema_display == 'on' && (is_single() || is_page()) && $apschema_bottom == 'on') {
function apschema_display_box_bottom($content) {
//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 = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars']=="yellow_round") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars'] == "green_round") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars'] == "blue_round") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
} elseif($apschema_options['premadestars'] == "yellow_sharp") {
$full_star_image = '
';
$empty_star_image = '
';
$half_star_image = '
';
}
else {
echo "";
}
ob_start(); # start buffer
include 'inc/boxcontent.php';
# we pass the output to a variable
$blag = ob_get_clean();
$content .= $blag;
return $content;
}
add_Action( 'the_content', 'apschema_display_box_bottom');
}
} //end function apschema_set_box