/**
  * getOpts function.
  * 
  * @access public
  * @return array
  */
 function getOpts()
 {
     $opts = array();
     $config_vars = $this->getClassVars();
     if (null != $config_vars && is_array($config_vars)) {
         $metrics = wpsd_get_metrics_types();
         $this->total_opts_count = count($metrics) - count($this->exclude_opts);
         foreach ($metrics as $k => $v) {
             if (isset($config_vars['wpsd_option_' . $k])) {
                 $opts[$k] = $config_vars['wpsd_option_' . $k];
                 if ($opts[$k]) {
                     if (!in_array($k, $this->exclude_opts)) {
                         $this->active_opts_count++;
                     }
                 }
             }
         }
     }
     return $opts;
 }
    function widget($args, $instance)
    {
        extract($args);
        $title = apply_filters('widget_title', $instance['title']);
        $desc = $instance['desc'];
        ?>
        <?php 
        echo $before_widget;
        ?>
        <!-- wp-stats-dashboard social profiles widget by http://daveligthart.com -->
        <div id="wpsd-profiles-widget">
      
        <?php 
        if ($title) {
            echo $before_title . $title . $after_title;
        }
        ?>
            
            <?php 
        if ('' != trim($desc)) {
            ?>
             
          	<p><?php 
            echo $desc;
            ?>
</p>
          	<?php 
        }
        ?>
								
			<ul id="wpsd-profiles-list" class="wpsd-profiles-list">
			<?php 
        $enabled_images = false;
        $enabled_attribute = false;
        $wpsd_metrics = wpsd_get_metrics_types();
        $widget_opts = get_option('widget_wpsdsocialprofileswidget');
        if (null != $widget_opts) {
            foreach ($widget_opts as $opt) {
                if (is_array($opt)) {
                    foreach ($opt as $key => $value) {
                        if ('on' == $value) {
                            if ('enable_attribute' == $key) {
                                $enabled_attribute = true;
                            } else {
                                if ('enable_images' == $key) {
                                    $enabled_images = true;
                                }
                            }
                        }
                    }
                }
            }
            foreach ($widget_opts as $opt) {
                if (null != $opt && count($opt) > 0) {
                    if (is_array($opt)) {
                        foreach ($opt as $key => $value) {
                            if ($value == 'on') {
                                $v = $wpsd_metrics[$key];
                                $username = get_option("wpsd_{$key}_un");
                                if ('' == $username) {
                                    $username = get_option("wpsd_{$key}_uri");
                                }
                                if ('facebook' == $key) {
                                    $username = get_option('wpsd_facebook_link');
                                }
                                if ('klout' == $key) {
                                    $username = get_option('wpsd_twitter_un');
                                }
                                if ('' != trim($username)) {
                                    $tag = $v[1];
                                    $url = str_replace('{username}', $username, $v[2]);
                                    $link_title = __('Visit my', 'wpsd') . "{$v[0]}" . __('profile', 'wpsd');
                                    $img_src = WPSD_PLUGIN_URL . '/resources/images/icons/' . $tag . '.png';
                                    $link = "<a href=\"{$url}\" target=\"_blank\" rel=\"me\" title=\"{$link_title}\">{$v[0]}</a>";
                                    if ($enabled_images) {
                                        $img = "<a href=\"{$url}\" target=\"_blank\" rel=\"me\" title=\"{$link_title}\"><img class=\"wpsd-profiles-icon\" src=\"{$img_src}\" alt=\"\" width=\"34\" height=\"34\"/></a>";
                                    }
                                    echo "<li class=\"wpsd-profiles-list-item\">{$img} {$link}</li>";
                                }
                            }
                        }
                    }
                }
            }
        }
        if ($enabled_attribute) {
            $link = "<a href=\"http://www.daveligthart.com/wp-stats-dashboard-10/\" target=\"_blank\" rel=\"external\" title=\"Powered by WP-Stats-Dashboard. Created by Dave Ligthart Freelance WordPress Developer.\">WPSD</a>";
            $img_src = WPSD_PLUGIN_URL . '/resources/images/icons/pow.png';
            if ($enabled_images) {
                $img = "<a href=\"http://www.daveligthart.com/wp-stats-dashboard-10/\" target=\"_blank\" rel=\"external\" title=\"\"><img class=\"wpsd-profiles-icon\" src=\"{$img_src}\" alt=\"\" width=\"34\" height=\"34\"/></a>";
            }
            echo "<li class=\"wpsd-profiles-list-item\">{$img} {$link}</li>";
        }
        ?>
			</ul>			
						
		</div>
		<!-- wp-stats-dashboard social profiles widget by http://daveligthart.com -->			
        <?php 
        echo $after_widget;
        ?>
   
<?php 
    }
예제 #3
0
        	 
        <div class="stuffbox wpsd">
          <h3> <?php 
    echo _e('Enable / Disable Social Metrics', 'wpsd');
    ?>
</h3>
          <div class="inside"><br/>
            <form name="wpsd_config_metrics_form" method="post" action="<?php 
    echo $_SERVER['REQUEST_URI'];
    ?>
" method="post" accept-charset="utf-8">
            <?php 
    echo $form2->htmlFormId();
    ?>
            <?php 
    $wpsd_metrics = wpsd_get_metrics_types();
    ?>
            <?php 
    if (null != $wpsd_metrics && is_array($wpsd_metrics)) {
        ksort($wpsd_metrics);
        ?>
            <?php 
        foreach ($wpsd_metrics as $k => $v) {
            if (is_array($v)) {
                $title = $v[0];
            }
            ?>
            <?php 
            wpsd_create_cb($k, $title, $form2);
            ?>
            <?php 
예제 #4
0
 /**
  * wp_ajax_wpsd_find_profile function.
  * 
  * @access public
  * @return void
  */
 function wp_ajax_wpsd_find_profile()
 {
     $username = wpsd_sanitize($_POST['name']);
     if ('' != $username) {
         $types = wpsd_get_metrics_types();
         if (null != $types && is_array($types)) {
             foreach ($types as $k => $opts) {
                 $url = $opts[2];
                 if ('' != trim($url)) {
                     $url = str_replace('{username}', $username, $url);
                     $code = $this->getResponseCode($this->getDataRemote($url));
                     $this->render_admin('admin_profile_type', array('username' => $username, 'code' => $code, 'type' => $k, 'url' => $url, 'icon' => $opts[1], 'name' => $opts[0]));
                 }
             }
         }
     }
 }
예제 #5
0
    function form($instance)
    {
        // outputs the options form on admin
        $title = esc_attr($instance['title']);
        $desc = esc_attr($instance['desc']);
        ?>
            <p><label for="<?php 
        echo $this->get_field_id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
 <input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo $title;
        ?>
" /></label></p>
       		
       		<p><label for="<?php 
        echo $this->get_field_id('desc');
        ?>
"><?php 
        _e('Description:');
        ?>
 <textarea class="widefat" id="<?php 
        echo $this->get_field_id('desc');
        ?>
" name="<?php 
        echo $this->get_field_name('desc');
        ?>
" type="text"><?php 
        echo $desc;
        ?>
</textarea></label></p>
       		
       		<fieldset>
       		
       		<p><strong><?php 
        _e('Enable / Disable Metrics', 'wpsd');
        ?>
</strong><br/>
			<?php 
        $wpsd_metrics = wpsd_get_metrics_types();
        ?>
			<?php 
        if (null != $wpsd_metrics && is_array($wpsd_metrics)) {
            ?>
			
			<?php 
            foreach ($wpsd_metrics as $k => $v) {
                if (is_array($v)) {
                    $title = $v[0];
                }
                ?>
			<?php 
                $this->create_cb($k, $title, $instance);
                ?>
			<?php 
            }
            ?>
			<?php 
        }
        ?>
			</p>
       		</fieldset>
        <?php 
    }
 /**
  * getTotalCount function.
  * 
  * @access public
  * @return integer total
  */
 function getTotalCount()
 {
     $metrics = wpsd_get_metrics_types();
     $config_vars = $this->getClassVars();
     $count = 0;
     if (null != $metrics) {
         foreach ($metrics as $k => $v) {
             if (array_key_exists('wpsd_' . $k . '_un', $config_vars) || array_key_exists('wpsd_' . $k . '_uri', $config_vars)) {
                 $count++;
             }
         }
     }
     return $count;
 }