public static function pvc_get_stats($post_id) { global $wpdb; $output_html = ''; // get all the post view info to display $results = A3_PVC::pvc_fetch_post_counts($post_id); // get the stats and if ($results) { $output_html .= number_format($results->total) . ' ' . __('total views', 'pvc') . ', ' . number_format($results->today) . ' ' . __('views today', 'pvc'); } else { $total = A3_PVC::pvc_fetch_post_total($post_id); if ($total > 0) { $output_html .= number_format($total) . ' ' . __('total views', 'pvc') . ', ' . __('no views today', 'pvc'); } else { $output_html .= __('No views yet', 'pvc'); } } $output_html = apply_filters('pvc_filter_get_stats', $output_html, $post_id); return $output_html; }
/** * Render Meta Box content. * * @param WP_Post $post The post object. */ public function render_meta_box_content($post) { global $wp_version; global $wp_pvc_admin_interface; wp_enqueue_script('jquery'); // Add an nonce field so we can check for it later. wp_nonce_field('a3_pvc_activation_custom_box', 'a3_pvc_activation_custom_box_nonce'); $is_activated = A3_PVC::pvc_admin_is_activated($post->ID); $view_status = A3_PVC::pvc_fetch_post_counts($post->ID); $total_views = 0; $today_views = 0; if ($view_status) { $total_views = $view_status->total; $today_views = $view_status->today; } // Display the form, using the current value. ?> <div class="" style="visibility: visible; height: auto;"> <div class=""> <div class="forminp forminp-onoff_checkbox"> <input id="a3_pvc_activated" name="a3_pvc_activated" class="a3_pvc_activated" type="checkbox" value="true" checked_label="<?php _e('ON', 'page-views-count'); ?> " unchecked_label="<?php _e('OFF', 'page-views-count'); ?> " <?php checked($is_activated); ?> /> <label for="a3_pvc_activated"><?php _e('Activate on this item', 'page-views-count'); ?> </label> </div> <div style="clear:both;"></div> <div class="a3_pvc_activated_container"> <p> <label for="a3_pvc_total_views" style="display: inline-block; width: 100px;"><?php _e('All Time Views', 'page-views-count'); ?> </label> <input type="text" name="a3_pvc_total_views" id="a3_pvc_total_views" value="<?php echo $total_views; ?> " style="width: 100px;" /> </p> <p> <label for="a3_pvc_today_views" style="display: inline-block; width: 100px;"><?php _e('Today Views', 'page-views-count'); ?> </label> <input type="text" name="a3_pvc_today_views" id="a3_pvc_today_views" value="<?php echo $today_views; ?> " style="width: 100px;" /> </p> </div> </div> </div> <script type="text/javascript"> (function($) { $(document).ready(function() { if ( $("input.a3_pvc_activated:checked").val() != 'true') { $('.a3_pvc_activated_container').slideUp(); } $("input.a3_pvc_activated").on( 'change', function() { if ( $(this).is(":checked") ) { $('.a3_pvc_activated_container').slideDown(); } else { $('.a3_pvc_activated_container').slideUp(); } }); }); })(jQuery); </script> <div style="clear:both;"></div> <?php }