Advertisement
Guest User

Shortcode Functionality

a guest
Jun 12th, 2013
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. /* Shortcode */
  2.     function shortcode($args, $instance) {
  3.         $hits = get_option("wphc_data");
  4.         $style = get_option("wphc_style");
  5.         $align = get_option("wphc_align");
  6.        
  7.         if ($align) {
  8.             $alignment_options = "align='".$align."'";
  9.         }
  10.        
  11.         echo "<div class='wordpress-hit-counter'".$alignment_options.">";
  12.         if (get_option("wphc_pad_zeros") && strlen($hits) < 7) {
  13.             for ($i = 0; $i < (7 - strlen($hits)); $i++) {
  14.                 echo "<img src='".WP_PLUGIN_URL."/wordpress-hit-counter/styles/$style/0.gif'>";
  15.             }
  16.         }
  17.         echo preg_replace("/(\d)/", "<img src='".WP_PLUGIN_URL."/wordpress-hit-counter/styles/$style/$1.gif'>", $hits);
  18.         echo "</div>";
  19.     }
  20.     add_shortcode("wHitCounter", "shortcode");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement