/**
 * 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;
}
 /**
  * Generates content for a single row of the table
  *
  * @access public
  * @param array $item The Audit.
  */
 public function single_row($item)
 {
     // Check if this row is for an extension.
     if (isset($item['extension']) && $item['extension']) {
         echo '<tr class="msa-extension-row">';
         $this->single_row_columns($item);
         echo '</tr>';
     } else {
         $class = '';
         if ('completed' === $item['status']) {
             $class = 'msa-post-status msa-post-status-' . msa_get_score_status($item['score']);
         }
         echo '<tr class="' . esc_attr($class) . '">';
         $this->single_row_columns($item);
         echo '</tr>';
     }
 }
 /**
  * Generates content for a single row of the table
  *
  * @param object $item The current item.
  */
 public function single_row($item)
 {
     echo '<tr class="msa-post-status msa-post-status-' . esc_attr__(msa_get_score_status($item['data']['score']['score'])) . '">';
     $this->single_row_columns($item);
     echo '</tr>';
 }
示例#4
0
        ?>
		<a href="<?php 
        esc_attr_e(get_admin_url() . 'admin.php?page=msa-all-audits');
        ?>
" class="page-title-action"><?php 
        esc_attr_e('All Audits', 'msa');
        ?>
</a>
	</h1>

	<div class="msa-header msa-single-audit">

		<div class="msa-column msa-header-column msa-header-score-wrap">
			<div class="msa-header-score-container">
				<div class="msa-header-post-score msa-post-status-bg msa-post-status-bg-<?php 
        esc_attr_e(msa_get_score_status($audit['score']));
        ?>
">
					<span><?php 
        esc_attr_e(round($audit['score'] * 100) . '%');
        ?>
</span>
				</div>
			</div>
		</div>

		<div class="msa-column msa-header-column msa-detail-container">

			<h3><?php 
        esc_attr_e($audit['name']);
        ?>
示例#5
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');
}
/**
 * Display the conditions within a category
 *
 * @access public
 * @param mixed  $category The condition category.
 * @param object $post     The WP_Post object.
 * @param mixed  $data     The audit data.
 * @param mixed  $score    The post score.
 * @return string $output The HTML output of the specifc condition category.
 */
function msa_display_condition_category_data($category, $post, $data, $score)
{
    $total_weight = msa_get_total_conditions_weight();
    $conditions = msa_get_conditions_from_category($category);
    $condition_categories = msa_get_condition_categories();
    $conditions_weight = msa_get_total_weight_for_conditions($conditions);
    $post_score = $score['data'];
    $overall_score = 0;
    $output = '<table class="wp-list-table widefat striped posts msa-audit-table">
			<thead>
				<th class="msa-condition-score-col">' . __('Score', 'msa') . '</th>
				<th class="msa-condition-weight-col">' . __('Weight', 'msa') . '</th>
				<th class="msa-condition-attribute-col">' . __('Attribute', 'msa') . '</th>
				<th class="msa-condition-goal-col">' . __('Goal', 'msa') . '</th>
				<th class="msa-condition-value-col">' . __('Value', 'msa') . '</th>
			</thead>

			<tbody>';
    foreach ($conditions as $key => $condition) {
        // Goal.
        if (1 === $condition['comparison']) {
            $goal = __('Greater Than ' . $condition['min'], 'msa');
        } else {
            if (2 === $condition['comparison']) {
                $goal = __('Less Than ' . $condition['max'], 'msa');
            } else {
                if (3 === $condition['comparison']) {
                    $goal = __('In Between ' . $condition['min'] . ' - ' . $condition['max'], 'msa');
                }
            }
        }
        $score = apply_filters('msa_condition_category_content_score', round($post_score[$key] * 100) . '%', $data, $post, $key);
        $weight = apply_filters('msa_condition_category_content_weight', round($condition['weight'] / $total_weight * 100) . '%', $data, $post, $key);
        $name = apply_filters('msa_condition_category_content_name', $condition['name'], $data, $post, $key);
        $goal = apply_filters('msa_condition_category_content_goal', $goal, $data, $post, $key, $condition);
        $value = apply_filters('msa_condition_category_content_value', $data[$key], $data, $post, $key);
        $more_info = '';
        if (isset($condition['description'])) {
            $learn_more = '';
            if (isset($condition['learn_more_link'])) {
                $learn_more = '<div class="msa-modal-learn-more-link">
					<a href="' . $condition['learn_more_link'] . '" target="_blank">' . __('Learn More', 'msa') . '</a>
				</div>';
            }
            $more_info = '<span class="msa-condition-more-info" data-condition="' . $key . '">
				<i class="fa fa-info-circle"></i>
				<div class="msa-modal" data-condition="' . $key . '">
					<div class="msa-modal-container">
						<div class="msa-modal-title">
							<h3>' . $condition['name'] . '</h3>
							<a class="msa-modal-close">' . __('Close', 'msa') . '</a>
						</div>
						<div class="msa-modal-content">' . $condition['description'] . '</div>' . $learn_more . '</div>
				</div>
			</span>';
        }
        $output .= '<tr class="msa-post-status msa-post-status-' . msa_get_score_status($post_score[$key]) . '">
			<td class="msa-condition-score">' . $score . '</td>
			<td class="msa-condition-weight">' . $weight . '</td>
			<td class="msa-condition-name">' . $name . '</td>
			<td class="msa-condition-goal">' . $goal . '</td>
			<td class="msa-condition-value">' . $value . $more_info . '</td>
		</tr>';
        $overall_score += $post_score[$key] * $condition['weight'];
    }
    $output .= '</tbody>

		</table>
	</div>';
    $output = '<h3 class="msa-condition-category-heading hndle ui-sortable-handle"><span class="msa-condition-category-score msa-post-status-bg msa-post-status-bg-' . msa_get_score_status($overall_score / $conditions_weight) . '">' . round($overall_score / $conditions_weight * 100, 2) . '%</span> <span>' . $condition_categories[$category]['name'] . '</span><span style="float:right;">' . __('Weight: ', 'msa') . ' ' . round($conditions_weight / $total_weight * 100, 2) . '%</span></h3><div class="inside">' . $output;
    return $output;
}