Пример #1
0
function evc_widget_subscribe($element_id = null, $args = array(), $owner_id = null, $class = "")
{
    global $post;
    $options = get_option('evc_lock');
    if (!isset($element_id)) {
        $element_id = 'vk-widget-subscribe' . $owner_id;
    }
    $o['mode'] = $options['subscribe_widget_mode'];
    // 0 - Кнопка, 1 - Лёгкая кнопка, 2 - Ссылка.
    $o['soft'] = $options['subscribe_widget_soft'];
    // 0 - Отображать автора и кнопку, 1 - Отображать только кнопку.
    $o = wp_parse_args($args, $o);
    $o = evc_vk_widget_data_encode($o);
    $out = '
<script type="text/javascript">
  
  VKWidgetsSubscribe.push ({
    element_id: "' . $element_id . '",
    options: ' . $o . ', 
    owner_id: ' . $owner_id . '
  });  
  
</script>';
    $out .= '<div class = "vk_widget_subscribe ' . $class . '" id = "' . $element_id . '"></div>';
    return $out;
}
Пример #2
0
function evc_vk_widget_comments($element_id = null, $args = array(), $page_id = null)
{
    global $post;
    $options = get_option('evc_comments');
    if (!isset($element_id)) {
        $element_id = 'vk-widget-' . $post->ID;
    }
    $o['width'] = $options['comment_widget_width'];
    $o['height'] = $options['comment_widget_height'];
    $o['limit'] = $options['comment_widget_limit'];
    if (!isset($options['comment_widget_attach']) || empty($options['comment_widget_attach']) || isset($options['comment_widget_attach']['none'])) {
        $o['attach'] = 'false';
    } else {
        foreach ($options['comment_widget_attach'] as $attach) {
            $o['attach'][] = $attach;
        }
        $o['attach'] = implode(',', $o['attach']);
    }
    $o['norealtime'] = $options['comment_widget_norealtime'];
    $o['autoPublish'] = $options['comment_widget_autopublish'];
    $o = wp_parse_args($args, $o);
    $o = evc_vk_widget_data_encode($o);
    $out = '
<script type="text/javascript">
  VKWidgetsComments.push ({
    element_id: "' . $element_id . '",
    options: ' . $o;
    if (isset($page_id)) {
        $out .= ',page_id: ' . $page_id;
    } elseif (isset($options['comment_widget_page_id']) && $options['comment_widget_page_id']) {
        $out .= ',page_id: ' . $post->ID;
    }
    $out .= '
  });    
</script>';
    $out .= '<div class = "vk_widget_comments" id = "' . $element_id . '"></div>	
  ';
    return $out;
}
Пример #3
0
function evc_poll_vk_widget($poll_id, $args = array(), $element_id = null)
{
    global $post;
    $options = get_option('evc_poll');
    if (!isset($element_id)) {
        $element_id = 'evc-poll-' . $poll_id;
    }
    $o = array();
    $o = wp_parse_args($args, $o);
    $o = evc_vk_widget_data_encode($o);
    $out = '
<script type="text/javascript">
  VKWidgetsPolls.push ({
    element_id: "' . $element_id . '",
    options: ' . $o . ',
    poll_id: "' . $poll_id . '"';
    $out .= '
  });    
</script>';
    $out .= '<div class = "vk_widget_polls" id = "' . $element_id . '"></div>  
  ';
    return $out;
}
Пример #4
0
function evc_vk_widget_group($data, $echo = 1)
{
    if ($data['options']['width'] === 0) {
        $data['options']['width'] = 'auto';
    }
    if (isset($data['group_id']) && !empty($data['group_id']) && is_numeric($data['group_id'])) {
        $out = '
      <script type="text/javascript">
        VKWidgetsGroup.push ({
          element_id: "vk-widget-' . $data['element_id'] . '",
          options: ' . evc_vk_widget_data_encode($data['options']) . ',
          group_id: ' . -1 * $data['group_id'] . '
        });         
      </script>

      <div class = "vk_widget_group" id = "vk-widget-' . $data['element_id'] . '"></div>  
    ';
    } else {
        $out = '';
    }
    if ($echo) {
        echo $out;
    } else {
        return $out;
    }
}