Example #1
0
function my_show_extra_profile_fields($user)
{
    $asz_options = get_option('_user-stats--options');
    /*
    $asz_options['author_article_front']
    $asz_options['author_date_front']
    $asz_options['author_views_front']
    $asz_options['over_dollararticles_front']
    $asz_options['over_articleearnings_front']
    $asz_options['author_dollarthousand_front']
    */
    if (is_user_logged_in()) {
        $current_user = wp_get_current_user();
        $profile_posts = asz_ind_get_posts($current_user->ID, $startdate = '', $enddate = '');
    } else {
        return false;
    }
    if (!is_admin()) {
        wp_enqueue_style("user-stats-front");
        wp_enqueue_script("user-stats-tablesorter");
        wp_enqueue_script("user-stats-tablesorter-widget");
        wp_enqueue_script("user-stats-frontjs");
    } else {
        wp_enqueue_script("user-stats-admin");
        wp_enqueue_script("user-stats-tablesorter");
        wp_enqueue_script("user-stats-tablesorter-widget");
        wp_enqueue_style("user-stats-admin");
    }
    ?>

        <div>
            <?php 
    if (!is_admin()) {
    } else {
        ?>
            <h3><?php 
        echo __('User Stats');
        ?>
</h3>
            <?php 
    }
    ?>
            <span id="asz_goto_totals"><a href="#asz_bottom_total">Go to totals</a></span>
            <table class="asz_profile_table asz_table widefat tablesorter tablesorter-blue">
            <thead>
                <tr class="tablesorter-headerRow">
                	<?php 
    if (isset($asz_options['author_article_front']) && $asz_options['author_article_front'] != 'author_article_front') {
        ?>
                    <th class="tablesorter-header"><?php 
        if ($asz_options['over_article_front_name'] == '') {
            echo __('Article', $namespace);
        } else {
            echo $asz_options['over_article_front_name'];
        }
        ?>
</th>
                	<?php 
    }
    ?>

                	<?php 
    if (isset($asz_options['author_date_front']) && $asz_options['author_date_front'] != 'author_date_front') {
        ?>
                    <th class="tablesorter-header"><?php 
        if ($asz_options['over_pubdate_front_name'] == '') {
            echo __('Date Published', $namespace);
        } else {
            echo $asz_options['over_pubdate_front_name'];
        }
        ?>
</th>
                	<?php 
    }
    ?>

                	<?php 
    if (isset($asz_options['author_views_front']) && $asz_options['author_views_front'] != 'author_views_front') {
        ?>
                    <th class="tablesorter-header"><?php 
        if ($asz_options['over_dol_article_front_name'] == '') {
            echo __('Views', $namespace);
        } else {
            echo $asz_options['over_dol_article_front_name'];
        }
        ?>
</th>
                	<?php 
    }
    ?>

                	<?php 
    if (isset($asz_options['over_dollararticles_front']) && $asz_options['over_dollararticles_front'] != 'over_dollararticles_front') {
        ?>
                    <th class="tablesorter-header"><?php 
        if ($asz_options['over_views_front_name'] == '') {
            echo __('Article Earnings', $namespace);
        } else {
            echo $asz_options['over_views_front_name'];
        }
        ?>
</th>
                	<?php 
    }
    ?>

                	<?php 
    if (isset($asz_options['over_articleearnings_front']) && $asz_options['over_articleearnings_front'] != 'over_articleearnings_front') {
        ?>
                    <th class="tablesorter-header"><?php 
        if ($asz_options['over_article_earnings_front_name'] == '') {
            echo __('$/views', $namespace);
        } else {
            echo $asz_options['over_article_earnings_front_name'];
        }
        ?>
</th>
                	<?php 
    }
    ?>

                	<?php 
    if (isset($asz_options['author_dollarthousand_front']) && $asz_options['author_dollarthousand_front'] != 'author_dollarthousand_front') {
        ?>
                    <th class="tablesorter-header"><?php 
        if ($asz_options['over_dol_thou_front_name'] == '') {
            echo __('$/1000 views', $namespace);
        } else {
            echo $asz_options['over_dol_thou_front_name'];
        }
        ?>
</th>
                    <?php 
    }
    ?>
                </tr>
            </thead>
        <?php 
    if (empty($profile_posts)) {
        echo "<tr><td colspan=5>No posts found.</td></tr>";
    }
    $total_views = 0;
    $total_dollar_per_art = 0;
    $total_dollar_per_art_views = 0;
    $total_dollar_per_tho = 0;
    foreach ($profile_posts as $the_posts) {
        $da_author = $the_posts->post_author;
        (int) ($da_author_article_cost = $asz_options['asz_dollar_per_article-' . $da_author]);
        (int) ($da_author_thousand_cost = $asz_options['asz_dollar_per_thousand-' . $da_author]);
        $da_date = $the_posts->post_date;
        $da_date_format = get_option('date_format');
        $da_date = date($da_date_format, strtotime($da_date));
        $da_cat = get_the_category($the_posts->ID);
        $cat_string = '';
        foreach ($da_cat as $dacat) {
            $cat_string .= " " . $dacat->name;
        }
        $asz_post_meta = get_post_meta($the_posts->ID, '_statz_count', true);
        if ($asz_post_meta == '') {
            $asz_post_meta = 0;
        }
        //$asz_dollar_per_views = $da_author_article_cost / $asz_post_meta;
        if ($asz_post_meta == 0 || $da_author_article_cost == 0) {
            $asz_dollar_per_views = 0;
        } else {
            $asz_dollar_per_views = $da_author_article_cost / $asz_post_meta;
        }
        //$asz_dollar_per_views = round($asz_dollar_per_views, 2, PHP_ROUND_HALF_UP);
        $asz_dollar_per_views = asz_round($asz_dollar_per_views);
        $asz_dollar_per_thousand_views = $da_author_thousand_cost / 1000;
        $asz_dollar_per_thousand_views = $asz_dollar_per_thousand_views * $asz_post_meta;
        //$asz_dollar_per_thousand_views = round($asz_dollar_per_thousand_views, 2, PHP_ROUND_HALF_UP);
        $asz_dollar_per_thousand_views = asz_round($asz_dollar_per_thousand_views);
        $total_views = $total_views + $asz_post_meta;
        $total_dollar_per_art_views = $total_dollar_per_art_views + $asz_dollar_per_views;
        $total_dollar_per_art = $total_dollar_per_art + $da_author_article_cost;
        $total_dollar_per_tho = $total_dollar_per_tho + $asz_dollar_per_thousand_views;
        ?>


        <tr>

        <td><?php 
        if (isset($asz_options['author_article']) != 'author_article') {
            echo "<a href='" . $the_posts->guid . "' target='_blank'>" . $the_posts->post_title . "</a>";
        }
        ?>
</td>

        <td><?php 
        if (isset($asz_options['author_date']) != 'author_date') {
            echo $da_date;
        }
        ?>
</td>

    	<?php 
        if (isset($asz_options['author_views_front']) != 'author_views_front') {
            ?>
        <td><?php 
            if (isset($asz_options['author_views']) != 'author_views') {
                echo $asz_post_meta;
            }
            ?>
</td>
    	<?php 
        }
        ?>

    	<?php 
        if (isset($asz_options['over_dollararticles_front']) != 'over_dollararticles_front') {
            ?>
        <td><?php 
            if (isset($da_author_article_cost)) {
                echo $da_author_article_cost;
            }
            ?>
</td>
    	<?php 
        }
        ?>

    	<?php 
        if (isset($asz_options['over_articleearnings_front']) != 'over_articleearnings_front') {
            ?>
        <td><?php 
            if (isset($asz_options['author_dollarviews']) != 'author_dollarviews') {
                echo $asz_dollar_per_views;
            }
            ?>
</td>
    	<?php 
        }
        ?>

    	<?php 
        if (isset($asz_options['author_dollarthousand_front']) != 'author_dollarthousand_front') {
            ?>
        <td><?php 
            if (isset($asz_options['author_dollarthousand']) != 'author_dollarthousand') {
                echo $asz_dollar_per_thousand_views;
            }
            ?>
</td>
        <?php 
        }
        ?>

        </tr>
        <?php 
    }
    ?>

    <tfoot>
        <tr id="asz_bottom_total" class="asz_totals">
        	<td colspan="2"><?php 
    echo __('Totals');
    ?>
</td>
        <?php 
    if (isset($asz_options['author_views_front']) != 'author_views_front') {
        ?>
        <td><?php 
        echo $total_views;
        ?>
</td>
    	<?php 
    }
    ?>

    	<?php 
    if (isset($asz_options['over_dollararticles_front']) != 'over_dollararticles_front') {
        ?>
        <td><?php 
        echo $total_dollar_per_art;
        ?>
</td>
    	<?php 
    }
    ?>

    	<?php 
    if (isset($asz_options['over_articleearnings_front']) != 'over_articleearnings_front') {
        ?>
        <td><?php 
        echo $total_dollar_per_art_views;
        ?>
</td>
    	<?php 
    }
    ?>

    	<?php 
    if (isset($asz_options['author_dollarthousand_front']) != 'author_dollarthousand_front') {
        ?>
        <td><?php 
        echo $total_dollar_per_tho;
        ?>
</td>
        <?php 
    }
    ?>

        </tr>
    </tfoot>

        </table>
    </div>

<?php 
}
Example #2
0
function asz_ind_show_posts()
{
    $ajax_author_name = $_POST['authorname'];
    $startdate = $_POST['startdate'];
    $enddate = $_POST['enddate'];
    global $wpdb;
    $asz_the_users = asz_get_users();
    foreach ($asz_the_users as $users) {
        //var_dump($users);
        //var_dump($_POST);
        if ($users['user_nicename'] == $ajax_author_name) {
            $asz_the_posts = asz_ind_get_posts($users['ID'], $startdate, $enddate);
            foreach ($asz_the_posts as $the_posts) {
                $da_author = $the_posts->post_author;
                $asz_options = get_option('_user-stats--options');
                (int) ($da_author_article_cost = $asz_options['asz_dollar_per_article-' . $da_author]);
                (int) ($da_author_thousand_cost = $asz_options['asz_dollar_per_thousand-' . $da_author]);
                $da_date = $the_posts->post_date;
                $da_date_format = get_option('date_format');
                $da_date = date($da_date_format, strtotime($da_date));
                $da_cat = get_the_category($the_posts->ID);
                $cat_string = '';
                foreach ($da_cat as $dacat) {
                    $cat_string .= " " . $dacat->name;
                }
                $asz_post_meta = get_post_meta($the_posts->ID, '_statz_count', true);
                if ($asz_post_meta == '') {
                    $asz_post_meta = 0;
                }
                //$asz_dollar_per_views = $da_author_article_cost / $asz_post_meta;
                if ($asz_post_meta == 0 || $da_author_article_cost == 0) {
                    $asz_dollar_per_views = 0;
                } else {
                    $asz_dollar_per_views = $da_author_article_cost / $asz_post_meta;
                }
                //$asz_dollar_per_views = round($asz_dollar_per_views, 2, PHP_ROUND_HALF_UP);
                $asz_dollar_per_views = asz_round($asz_dollar_per_views);
                $asz_dollar_per_thousand_views = $da_author_thousand_cost / 1000;
                $asz_dollar_per_thousand_views = $asz_dollar_per_thousand_views * $asz_post_meta;
                //$asz_dollar_per_thousand_views = round($asz_dollar_per_thousand_views, 2, PHP_ROUND_HALF_UP);
                $asz_dollar_per_thousand_views = asz_round($asz_dollar_per_thousand_views);
                //var_dump($users);
                echo "<tr class='asz_ind_posts asz_ind_posts_" . $users['user_nicename'] . "' >";
                if ($asz_options['author_author'] != 'author_author') {
                    echo "<td>" . $users['user_nicename'] . "</td>";
                }
                if ($asz_options['author_article'] != 'author_article') {
                    echo "<td class='asz_article_column'><a href='" . $the_posts->guid . "' target='_blank'>" . $the_posts->post_title . "</a><span class='asz_edit'><a href='" . get_edit_post_link($the_posts->ID) . "' target='_blank'>edit</a></span></td>";
                }
                if ($asz_options['author_date'] != 'author_date') {
                    echo "<td>" . $da_date . "</td>";
                }
                if ($asz_options['author_cat'] != 'author_cat') {
                    echo "<td>" . $cat_string . "</td>";
                }
                if ($asz_options['author_views'] != 'author_views') {
                    echo "<td id='viewcount_" . $the_posts->ID . "'>" . $asz_post_meta . "<span><img title='Reset View Count' class='asz_reset' id='" . $the_posts->ID . "' src='" . USERSTATS_URLPATH . "/images/delete.png" . "' /></span></td>";
                }
                if ($asz_options['author_dollarviews'] != 'author_dollarviews') {
                    echo "<td>" . $asz_dollar_per_views . "</td>";
                }
                if ($asz_options['author_dollarthousand'] != 'author_dollarthousand') {
                    echo "<td>" . $asz_dollar_per_thousand_views . "</td>";
                }
                echo "</tr>";
            }
        }
        //end if
    }
    die;
}
Example #3
0
 function asz_overview()
 {
     $asz_options = get_option('_user-stats--options');
     $asz_users = asz_get_users();
     foreach ($asz_users as $asz_overview) {
         //Remove the user if selected.
         $asz_noauthor = "over_noauthor_" . $asz_overview['user_nicename'];
         $get_check_cos_its_late = isset($asz_options[$asz_noauthor]);
         if (isset($noauthorcheck) != $get_check_cos_its_late) {
             continue;
         }
         //var_dump($asz_overview);
         (int) ($tempdollarperarticle = $asz_options['asz_dollar_per_article-' . $asz_overview['ID']]);
         (int) ($tempdollarperthousand = $asz_options['asz_dollar_per_thousand-' . $asz_overview['ID']]);
         $overview_post_count = count_user_posts($asz_overview['ID']);
         $overview_total_count = asz_get_total_counts($asz_overview['ID']);
         if ($overview_post_count == 0) {
             $overview_avg_views = 0;
         } else {
             $overview_avg_views = $overview_total_count / $overview_post_count;
         }
         //$overview_avg_views = round($overview_avg_views, 2, PHP_ROUND_HALF_UP);
         $overview_avg_views = asz_round($overview_avg_views);
         $overview_dollar_per_article = $tempdollarperarticle;
         if ($overview_dollar_per_article == '') {
             $overview_dollar_per_article = 0;
         } else {
             $overview_dollar_per_article = $overview_dollar_per_article;
         }
         $overview_total_dollar_per_article = $overview_post_count * $tempdollarperarticle;
         if ($overview_total_count == 0) {
             $overview_avg_dollar_per_view = 0;
         } else {
             $overview_avg_dollar_per_view = $overview_total_dollar_per_article / $overview_total_count;
         }
         //$overview_avg_dollar_per_view = round($overview_avg_dollar_per_view, 2, PHP_ROUND_HALF_UP);
         $overview_avg_dollar_per_view = asz_round($overview_avg_dollar_per_view);
         $overview_dollar_per_thousand = $tempdollarperthousand;
         if ($overview_dollar_per_thousand == '') {
             $overview_dollar_per_thousand = 0;
         } else {
             $overview_dollar_per_thousand = $overview_dollar_per_thousand;
         }
         $overview_total_dollar_per_thousand = $overview_total_count * $overview_dollar_per_thousand;
         if ($overview_total_count == 0) {
             $overview_avg_dollar_per_thousand = 0;
         } else {
             $overview_avg_dollar_per_thousand = $overview_total_dollar_per_thousand / $overview_total_count;
         }
         //$overview_avg_dollar_per_thousand = round($overview_total_dollar_per_thousand, 2, PHP_ROUND_HALF_UP)/1000;
         $overview_avg_dollar_per_thousand = asz_round($overview_total_dollar_per_thousand);
         echo "<tr>";
         echo "<td><input type='checkbox' class='asz_overview_totals' /></td>";
         echo "<td class='asz_author_name' id='" . $asz_overview['user_nicename'] . "'>" . $asz_overview['user_nicename'] . "</td>";
         if (isset($asz_options['over_role']) != 'over_role') {
             echo "<td>" . asz_user_role($asz_overview['ID']) . "</td>";
         }
         if (isset($asz_options['over_noarticles']) != 'over_noarticles') {
             echo "<td>" . $overview_post_count . "</td>";
         }
         if (isset($asz_options['over_tviews']) != 'over_tviews') {
             echo "<td>" . $overview_total_count . "</td>";
         }
         if (isset($asz_options['over_aviews']) != 'over_aviews') {
             echo "<td>" . $overview_avg_views . "</td>";
         }
         if (isset($asz_options['over_dollararticles']) != 'over_dollararticles') {
             echo "<td>" . $overview_dollar_per_article . "</td>";
         }
         if (isset($asz_options['over_totaldollararticles']) != 'over_totaldollararticles') {
             echo "<td>" . $overview_total_dollar_per_article . "</td>";
         }
         if (isset($asz_options['over_avgdollarview']) != 'over_avgdollarview') {
             echo "<td>" . $overview_avg_dollar_per_view . "</td>";
         }
         if (isset($asz_options['over_dollarthousandview']) != 'over_dollarthousandview') {
             echo "<td>" . $overview_dollar_per_thousand . "</td>";
         }
         if (isset($asz_options['over_avgdollarthousandview']) != 'over_avgdollarthousandview') {
             echo "<td>" . $overview_avg_dollar_per_thousand . "</td>";
         }
         echo "</tr>";
     }
     // This will be the running total
     echo "<tfoot><tr id='asz_running_total'>";
     echo "<td></td>";
     echo "<td class='asz_author_name' id=''>TOTAL</td>";
     if (isset($asz_options['over_role']) != 'over_role') {
         echo '<td id="asz_running_role"></td>';
     }
     if (isset($asz_options['over_noarticles']) != 'over_noarticles') {
         echo '<td id="asz_running_noarticles"></td>';
     }
     if (isset($asz_options['over_tviews']) != 'over_tviews') {
         echo '<td id="asz_running_totalview"></td>';
     }
     if (isset($asz_options['over_aviews']) != 'over_aviews') {
         echo '<td id="asz_running_avgview"></td>';
     }
     if (isset($asz_options['over_dollararticles']) != 'over_dollararticles') {
         echo '<td id="asz_running_dollarart"></td>';
     }
     if (isset($asz_options['over_totaldollararticles']) != 'over_totaldollararticles') {
         echo '<td id="asz_running_totalart"></td>';
     }
     if (isset($asz_options['over_avgdollarview']) != 'over_avgdollarview') {
         echo '<td id="asz_running_avgdollarview"></td>';
     }
     if (isset($asz_options['over_dollarthousandview']) != 'over_dollarthousandview') {
         echo '<td id="asz_running_dollarthou"></td>';
     }
     if (isset($asz_options['over_avgdollarthousandview']) != 'over_avgdollarthousandview') {
         echo '<td id="asz_running_avgdollarthou"></td>';
     }
     echo "</tr></tfoot>";
 }