/** ************************************************************************
  * Recommended. This is a custom column method and is responsible for what
  * is rendered in any column with a name/slug of 'title'. Every time the class
  * needs to render a column, it first looks for a method named 
  * column_{$column_title} - if it exists, that method is run. If it doesn't
  * exist, column_default() is called instead.
  * 
  * This example also illustrates how to implement rollover actions. Actions
  * should be an associative array formatted as 'slug'=>'link html' - and you
  * will need to generate the URLs yourself. You could even ensure the links
  * 
  * 
  * @see WP_List_Table::::single_row_columns()
  * @param array $item A singular item (one full row's worth of data)
  * @return string Text to be placed inside the column <td> (movie title only)
  **************************************************************************/
 function column_post_title($item)
 {
     //Build row actions
     $actions = array('edit' => sprintf('<a href="post.php?post=%s&action=edit">Edit Post</a>', $item['ID'], 'edit', $item['ID']), 'update' => '<a href="' . add_query_arg('esml_sync_now', $item['ID']) . '">Update Stats</a>', 'info' => sprintf('Updated %s', EasySocialMetricsLite::timeago($item['esml_socialcount_LAST_UPDATED'])));
     //Return the title contents
     return sprintf('%1$s <span style="color:silver">(id:%2$s)</span>%3$s', $item['post_title'], $item['ID'], $this->row_actions($actions));
 }
Beispiel #2
0
function essb_register_settings_metabox()
{
    global $post;
    $essb_off = "false";
    if (isset($_GET['action'])) {
        $custom = get_post_custom($post->ID);
        // print_r($custom);
        $essb_off = isset($custom["essb_off"]) ? $custom["essb_off"][0] : "false";
    }
    wp_nonce_field('essb_metabox_handler', 'essb_nonce');
    ?>

<div class="essb-meta">

	<table border="0" cellpadding="5" cellspacing="0" width="100%">
		<col width="60%" />
		<col width="40%" />
		<tr class="even">
			<td class="bold">Turn off for current post:</td>
			<td><select class="input-element stretched" id="essb_off"
				name="essb_off">
					<option value="true"
						<?php 
    echo $essb_off == "true" ? " selected=\"selected\"" : "";
    ?>
>Yes</option>
					<option value="false"
						<?php 
    echo $essb_off == "false" ? " selected=\"selected\"" : "";
    ?>
>No</option>
			</select></td>
		</tr>
		<tr>
			<td colspan="2"><a href="#" id="essb-goto-advanced" class="button">Advanced
					Options</a></td>
		</tr>

	</table>
	<?php 
    if (ESSB_ESML_ACTIVE == 'true') {
        echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" style="font-size: 11px;">';
        echo '<col width="60%"/>';
        echo '<col width="40%"/>';
        $parse_list = array("facebook" => "Facebook", "twitter" => "Twitter", "googleplus" => "Google+", "pinterest" => "Pinterest", "linkedin" => "LinkedIn", "stumbleupon" => "StumbleUpon");
        $item = array();
        $item['esml_socialcount_total'] = get_post_meta($post->ID, "esml_socialcount_TOTAL", true) ? get_post_meta($post->ID, "esml_socialcount_TOTAL", true) : 0;
        $item['esml_socialcount_LAST_UPDATED'] = get_post_meta($post->ID, "esml_socialcount_LAST_UPDATED", true);
        foreach ($parse_list as $singleValueCode => $singleValue) {
            $item['esml_socialcount_' . $singleValueCode] = get_post_meta($post->ID, "esml_socialcount_{$singleValueCode}", true);
        }
        $total = $item['esml_socialcount_total'];
        echo '<tr style="background-color: #f4f4f4; padding: 4px;">';
        echo '<td colspan="2" style="padding: 10px 5px;"><strong>Easy Social Metrics Lite Report</strong></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="2"><strong>Data last updated ' . EasySocialMetricsLite::timeago($item['esml_socialcount_LAST_UPDATED']) . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td><strong>Total Social Shares:</strong></td>';
        echo '<td align="right"><strong>' . number_format($total) . '</strong></td>';
        echo '</tr>';
        $cnt = 1;
        foreach ($parse_list as $singleValueCode => $singleValue) {
            $single_value = $item['esml_socialcount_' . $singleValueCode];
            $cnt = $cnt + 1;
            $style = "";
            if ($cnt % 2 == 0) {
                $style = " style=\"background-color: #f4f4f4;\"";
            }
            if ($total != 0) {
                $display_percent = number_format($single_value * 100 / $total, 2);
                $percent = number_format($single_value * 100 / $total);
            } else {
                $display_percent = "0.00";
                $percent = "0";
            }
            if (intval($percent) == 0 && intval($single_value) != 0) {
                $percent = 1;
            }
            echo '<tr ' . $style . '>';
            echo '<td>' . $singleValue . ' <span style="background-color: #2980b9; padding: 2px 5px; color: #fff; font-size: 10px; border-radius: 3px;">' . $display_percent . ' %</span></td>';
            echo '<td align="right"><strong>' . number_format(intval($single_value)) . '</strong></td>';
            echo '</tr>';
            echo '<tr ' . $style . '>';
            echo '<td colspan="2"><div style="background-color: #2980b9; display: block; height: 11px; width:' . $percent . '%;">&nbsp;</div></td>';
            echo '</tr>';
        }
        if (ESSB_SELF_ENABLED) {
            essb_self_hosted_counter_values();
        }
        echo '</table>';
    }
    ?>
</div>


<?php 
}
 public function output_main_result()
 {
     echo '<table id="esml-result" class="display hover row-border stripe" cellspacing="0" width="100%">';
     echo '<thead>';
     echo '<tr>';
     echo '<th>Title</th>';
     echo '<th>Total</th>';
     echo '<th>Facebook</th>';
     echo '<th>Twitter</th>';
     echo '<th>Google+</th>';
     echo '<th>LinkedIn</th>';
     echo '<th>Pinterest</th>';
     echo '<th>StumbleUpon</th>';
     echo '<th>Post Comments</th>';
     echo '<th>Facebook Comments</th>';
     echo '</tr>';
     echo '</thead>';
     echo '<tbody>';
     foreach ($this->data_report as $item) {
         $total_value = number_format(intval($item['esml_socialcount_total']));
         $item_actions = sprintf('<a href="post.php?post=%s&action=edit">Edit Post</a>', $item['ID'], 'edit', $item['ID']) . '&nbsp;<a href="' . esc_url(add_query_arg('esml_sync_now', $item['ID'])) . '">Update Stats</a>&nbsp;' . sprintf('Updated %s', EasySocialMetricsLite::timeago($item['esml_socialcount_LAST_UPDATED']));
         echo '<tr>';
         echo '<td>';
         printf('%1$s <br/><span class="esml-navigation-item">(id:%2$s) %3$s</span>', $item['post_title'], $item['ID'], $item_actions);
         echo '</td>';
         echo '<td align="right">' . $total_value . '</td>';
         foreach ($this->services as $key => $text) {
             if ($key == "diggs") {
                 continue;
             }
             echo '<td align="right">' . number_format(intval($item['esml_socialcount_' . $key])) . '</td>';
         }
         echo '</tr>';
     }
     echo '</tbody>';
     echo '</table>';
 }