예제 #1
0
/**
 * The Last Audit Panel Content
 *
 * @access public
 * @return string $output The HTML ouput of the last audit panel.
 */
function msa_dashboard_panel_last_audit_content()
{
    // Get the latest Audit.
    $audit_model = new MSA_Audits_Model();
    $audit = $audit_model->get_latest();
    if (isset($audit)) {
        $output = '<div class="msa-left-column">
			<div class="msa-left-column-content">
				<div class="msa-circle msa-circle-border msa-post-status-border-' . msa_get_score_status($audit['score']) . '">
				     <div class="msa-circle-inner">
				         <div class="msa-score-text msa-post-status-text-' . msa_get_score_status($audit['score']) . '">' . round(100 * $audit['score']) . '%</div>
				     </div>
				</div>
			</div>
		</div>';
        $output .= '<div class="msa-right-column">
			<div class="msa-right-column-content">
				<table class="wp-list-table widefat striped">
					<tbody>';
        $user = get_userdata($audit['user']);
        $output .= '<tr><td>' . __('Name', 'msa') . '</td> <td><a href="' . msa_get_single_audit_link($audit['id']) . '">' . $audit['name'] . '</a></td></tr>';
        $output .= '<tr><td>' . __('Created On', 'msa') . '</td> <td>' . date('M d Y, h:i:s', strtotime($audit['date'])) . '</td></tr>';
        $output .= '<tr><td>' . __('Number of Posts', 'msa') . '</td> <td>' . $audit['num_posts'] . '</td></tr>';
        $output .= '<tr><td>' . __('Created By', 'msa') . '</td> <td>' . $user->display_name . '</td></tr>';
        $output .= '</tbody>
				</table>
			</div>
		</div>';
    } else {
        $output = '<p>' . __('You do not have any audits yet.', 'msa') . ' <a href="' . get_admin_url() . 'admin.php?page=msa-all-audits">' . __('Create one now!', 'msa') . '</a></p>';
    }
    return $output;
}
예제 #2
0
/**
 * Prints the box content.
 *
 * @access public
 * @param object $post A WP_Post obejct.
 * @return void
 */
function msa_meta_box_callback($post)
{
    // Get the latest audit.
    $audit_model = new MSA_Audits_Model();
    $audit = $audit_model->get_latest();
    // Check to see if we have an audit.
    if (isset($audit)) {
        $post_id = -1;
        if (isset($_GET['post'])) {
            // Input var okay.
            $post_id = sanitize_text_field(wp_unslash($_GET['post']));
            // Input var okay.
        }
        $audit = $audit_model->get_data_from_id($audit['id']);
        $audit_posts_model = new MSA_Audit_Posts_Model();
        $audit_post = $audit_posts_model->get_data_from_id($audit['id'], $post_id);
        if ($audit_post) {
            $post = (object) $audit_post['post'];
            $data = $audit_post['data']['values'];
            $score = $audit_post['data']['score'];
            $condition_categories = msa_get_condition_categories();
            $user = get_userdata($audit['user']);
            do_action('msa_before_post_meta_box', $audit['id'], $post_id);
            ?>
<div class="msa-post-meta-container msa-post-meta-audit-meta-attributes">
				<p class="msa-post-meta-attribute"><?php 
            esc_attr_e('Score: ', 'msa');
            ?>
</p>
				<p class="msa-post-meta-attribute"><?php 
            esc_attr_e('From Audit: ', 'msa');
            ?>
</p>
				<p class="msa-post-meta-attribute"><?php 
            esc_attr_e('Created On: ', 'msa');
            ?>
</p>
				<p class="msa-post-meta-attribute"><?php 
            esc_attr_e('Created By: ', 'msa');
            ?>
</p>
			</div>

			<div class="msa-post-meta-container msa-post-meta-audit-meta-values">
				<p class="msa-post-meta-value msa-post-status-bg msa-post-status-bg-<?php 
            esc_attr_e(msa_get_score_status($score['score']));
            ?>
"><?php 
            esc_attr_e(round($score['score'] * 100, 2));
            ?>
%</p>
				<p class="msa-post-meta-value"><a href="<?php 
            esc_attr_e(msa_get_single_audit_link($audit['id']));
            ?>
" target="_blank"><?php 
            esc_attr_e($audit['name']);
            ?>
</a></p>
				<p class="msa-post-meta-value"><?php 
            esc_attr_e(date('M j, Y', strtotime($audit['date'])));
            ?>
</p>
				<p class="msa-post-meta-value"><?php 
            esc_attr_e($user->display_name);
            ?>
</p>
			</div><?php 
            foreach ($condition_categories as $key => $condition_category) {
                ?>
<div class="postbox" id="<?php 
                esc_attr_e($key);
                ?>
" style="pointer-events: none;">
					<?php 
                echo apply_filters('msa_condition_category_content', $key, $post, $data, $score);
                // WPCS: XSS ok.
                ?>
				</div><?php 
            }
            do_action('msa_after_post_meta_box', $audit['id'], $post_id);
        }
    }
    wp_enqueue_style('msa-all-audits-css', MY_SITE_AUDIT_PLUGIN_URL . '/css/all-audits.css');
    wp_enqueue_style('msa-post-meta-css', MY_SITE_AUDIT_PLUGIN_URL . '/css/post-meta.css');
    wp_enqueue_style('msa-common-css', MY_SITE_AUDIT_PLUGIN_URL . '/css/common.css');
}