Plugin Directory

Changeset 1043827


Ignore:
Timestamp:
12/13/2014 02:20:34 AM (11 years ago)
Author:
andreyk
Message:

Version 1.6

Location:
wp-ya-share/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-ya-share/trunk/readme.txt

    r851335 r1043827  
    22
    33Plugin page: http://andrey.eto-ya.com/wordpress/my-plugins/wp-ya-share
    4 Tags: social, share, bookmarks, twitter, facebook, livejournal, vkontakte, widget, post, smo, smm, social media, yandex
     4Tags: social, share, bookmarks, twitter, facebook, livejournal, vkontakte, widget, post, smo, smm, social media, yandex, pinterest
    55Requires at least: 2.8.6
    6 Tested up to: 3.8.1
    7 Stable tag: 1.5
     6Tested up to: 4.0.1
     7Stable tag: 1.6
    88Contributors: andreyk
    99
     
    5151== Changelog ==
    5252
     53= 1.6 =
     54* API domain changed from unreliable yandex.st to yastatic.net.
     55* Added: sharing to Pinterest.
     56* Removed: sharing to Ya.ru.
     57
    5358= 1.5 =
    5459* New setting: button style (theme).
  • wp-ya-share/trunk/wp-ya-share.php

    r851335 r1043827  
    22/*
    33Plugin Name: WP Ya.Share
    4 Version: 1.5
     4Version: 1.6
    55Description: Adds the Yandex 'Share in social networks' block into posts or widget to simplify saving URLs of your blog pages into social networks.
    66Requires at least: 2.8.6
    7 Tested up to: 3.8.1
     7Tested up to: 4.0.1
    88Plugin URI: http://andrey.eto-ya.com/wordpress/my-plugins/wp-ya-share
    99Author: Andrey K.
    1010Author URI: http://andrey.eto-ya.com/
    11 Stable tag: 1.5
     11Stable tag: 1.6
    1212License: GPL2
    1313*/
     
    4646    }
    4747
    48     $ya_share_default= array(
     48    $ya_share_default = array(
    4949        'where' => 'content',
    50         'list' =>  array('vkontakte', 'lj', 'facebook', 'twitter', 'odnoklassniki', 'gplus', 'yaru'),
     50        'list' =>  array('vkontakte', 'lj', 'facebook', 'twitter', 'odnoklassniki', 'gplus',),
    5151        'popup_list' => array('blogger', 'digg', 'evernote', 'delicious', 'diary', 'friendfeed',
    52         'juick', 'liveinternet', 'linkedin', 'moikrug', 'moimir', 'myspace', 'tutby', 'yazakladki', 'surfingbird',),
     52        'juick', 'liveinternet', 'linkedin', 'pinterest', 'moikrug', 'moimir', 'myspace', 'tutby', 'yazakladki', 'surfingbird'),
    5353        'type' => 'button',
    5454        'align' => 'left',
     
    6161    );
    6262
    63     $ya_share_allowed= array(
     63    $ya_share_allowed = array(
    6464        'where' => array('content', 'multiple', 'widget', 'selectively'),
    6565        'type'  => array('button', 'icon', 'link', 'none'),
     
    7171    );
    7272
    73     $all_services= array('none', 'blogger', 'digg', 'evernote', 'delicious', 'diary', 'facebook', 'friendfeed', 'gplus',
    74             'juick', 'liveinternet', 'linkedin', 'lj',  'moikrug', 'moimir', 'myspace', 'odnoklassniki', 'twitter', 'tutby',
    75             'vkontakte', 'yaru', 'yazakladki', 'surfingbird',);
     73    $all_services = array('none', 'blogger', 'digg', 'evernote', 'delicious', 'diary', 'facebook', 'friendfeed', 'gplus',
     74            'juick', 'liveinternet', 'linkedin', 'lj', 'pinterest', 'moikrug', 'moimir', 'myspace', 'odnoklassniki', 'twitter', 'tutby',
     75            'vkontakte', 'yazakladki', 'surfingbird',);
    7676
    7777    foreach( array_keys($ya_share_allowed) as $key ) {
     
    8080        }
    8181        else {
    82             $new_ya_share[$key]= $arr[$key];
    83         }
    84     }
    85 
    86     foreach( array("list","popup_list" ) as $key ) {
     82            $new_ya_share[$key] = $arr[$key];
     83        }
     84    }
     85
     86    foreach( array('list', 'popup_list') as $key ) {
    8787        if ( empty($arr[$key]) ) {
    88             $new_ya_share[$key]= $ya_share_default[$key];
     88            $new_ya_share[$key] = $ya_share_default[$key];
    8989        }
    9090        else {
    91             $new_ya_share[$key]= array_intersect((array)$arr[$key], $all_services);
     91            $new_ya_share[$key] = array_intersect((array)$arr[$key], $all_services);
    9292        }
    9393        if ( in_array('none', $new_ya_share[$key]) ) {
     
    9696    }
    9797
    98     $new_ya_share['txt']= empty($arr['txt'])? '' : htmlspecialchars(trim($arr['txt'], ENT_QUOTES));
     98    $new_ya_share['txt'] = empty($arr['txt'])? '' : htmlspecialchars(trim($arr['txt'], ENT_QUOTES));
    9999    $new_ya_share['popup_txt'] =  empty($arr['popup_txt'])? '' : htmlspecialchars(trim($arr['popup_txt'], ENT_QUOTES));
    100100
     
    104104function ya_share_out() {
    105105    static $div;
     106    global $post;
    106107    if ( !isset($div) ) {
    107108        $div = 0;
    108109    }
    109110    $ya_share= ya_share_sanitize(get_option('ya_share'));
    110 
    111     $link= (in_array($ya_share['where'], array('multiple', 'selectively'))?('link: "'
    112         . get_permalink(). '", title: "' . get_the_title() . '",') : '');
    113     $ya_share_div= '<!--WP Ya.share--><div class="wp_ya_share" style="text-align:' . $ya_share['align']. ';">
     111    $link = '';
     112    if ( in_array($ya_share['where'], array('multiple', 'selectively')) ) {
     113        $link .= 'link: "' . get_permalink() . '", title: "' . get_the_title() . '",';
     114    }
     115    if ( in_array('pinterest', $ya_share['list']) || in_array('pinterest', $ya_share['popup_list']) ) {
     116        if (current_theme_supports('post-thumbnails') && ($id = get_post_thumbnail_id()) && ($image = wp_get_attachment_image_src($id, 'full')) ) {}
     117        elseif( $images = get_attached_media('image') ) {
     118            $image = (array)array_pop($images);
     119            $image[0] = $image['guid'];
     120        }
     121        elseif ( preg_match("/http(\S*?)\.(jpg|jpeg|png|gif)/i", $post->post_content, $image) ) {}
     122        else {
     123            $image[0] = '';
     124        }
     125        $link .= 'serviceSpecific: {pinterest: {image: "'. $image[0] .'"}},';
     126    }
     127   
     128    $ya_share_div = '<!--WP Ya.share--><div class="wp_ya_share" style="text-align:' . $ya_share['align']. ';">
    114129    <div id="yashare' . (++$div) . '"></div>
    115130    <script type="text/javascript">
    116131        <!--
    117         Ya.share({
     132        var yashareInstance' . $div. ' = new Ya.share({
    118133            element: "yashare' . $div. '",
    119                 ' . $link. '
    120                 l10n: "' . $ya_share['lang']. '",
    121                 theme: "' . $ya_share['theme']. '",
    122                 elementStyle: {
    123                         type: "' . $ya_share['type']. '", '
    124                         . ( $ya_share['txt'] ?  'text: "' . $ya_share['txt'] . '",' : '')
    125                         . ' quickServices: [\'' . implode("', '", $ya_share['list']) . '\']
    126                 },
    127                 popupStyle: {' . (('Yes'==$ya_share['copy_paste'])?'copyPasteField:true,':'') . '
    128                     blocks: {\'' . $ya_share['popup_txt'] . '\': [\'' . implode("', '", $ya_share['popup_list']). '\']}
    129                 }
    130                                 });
     134            ' . $link . '
     135            l10n: "' . $ya_share['lang'] . '",
     136            theme: "' . $ya_share['theme'] . '",
     137            elementStyle: {
     138                type: "' . $ya_share['type'] . '", '
     139                    . ( $ya_share['txt'] ?  'text: "' . $ya_share['txt'] . '",' : '')
     140                    . ' quickServices: [\'' . implode("', '", $ya_share['list']) . '\']
     141            },
     142            popupStyle: {' . (('Yes'==$ya_share['copy_paste'])?'copyPasteField:true,':'') . '
     143                blocks: {\'' . $ya_share['popup_txt'] . '\': [\'' . implode("', '", $ya_share['popup_list']). '\']}
     144            }
     145
     146        });
    131147        //-->
    132148    </script></div><!--/WP Ya.share-->';
     
    135151
    136152function ya_share_scripts() {
    137     wp_enqueue_script('ya-share', '//yandex.st/share/share.js');
     153    wp_enqueue_script('ya-share', '//yastatic.net/share/share.js');
    138154}
    139155
     
    190206    'blogger' => 'Blogger', 'digg' => 'Digg', 'evernote' => 'Evernote', 'delicious' => 'Delicious', 'diary' => 'Diary',
    191207    'facebook' => 'Facebook', 'friendfeed' => 'FriendFeed', 'gplus' => 'Google+', 'juick' => 'Juick',
    192     'liveinternet' => 'LiveInternet', 'linkedin' => 'LinkedIn', 'lj' => 'LiveJournal',  'moikrug' => 'MoiKrug',
     208    'liveinternet' => 'LiveInternet', 'linkedin' => 'LinkedIn', 'lj' => 'LiveJournal',  'pinterest' => 'Pinterest', 'moikrug' => 'MoiKrug',
    193209    'moimir' => 'MoiMir', 'myspace' => 'MySpace', 'odnoklassniki' => 'Odnoklassniki', 'twitter' => 'Twitter',
    194210    'tutby' => 'Tutby', 'vkontakte' => 'VKontakte', 'yaru' => 'Yaru', 'yazakladki' => 'YandexZakladki',
     
    294310} ?></td>
    295311</tr>
    296 
    297312</table>
    298313
Note: See TracChangeset for help on using the changeset viewer.