sexybookmarks - Plugin for Wordpress. Add the buttons "VKontakte" and "Classmates"

Today we will talk about the component for Wordpress - sexybookmarks version 3.0, namely, how to add the VKontakte and Odnoklassniki buttons to this plugin .

Sexybookmarks plugin on WordPress page

For those who are not familiar with this plugin, I’ll explain that this plugin displays “social buttons” for publication Your articles to various services, such as Facebook, Google Bookmarks, Yandex Bookmarks, etc.

What is remarkable about this plugin? Indeed, there are a lot of similar plugins for Wordpress ... In addition to a large number of built-in buttons (87 pieces), a rather convenient settings panel and support for the Russian language, this plugin has an unusual design that can please not only you, but also your visitors.

Download the sexybookmarks pluginversion 3.0, you can link: sexybookmarks . Version 3.0 compatible with Wordpress 3.3.1 , tested on their own experience.

The sexybookmarks preferences pane opens in the Wordpress menu “Options” => “SexyBookmarks”. In the panel, you can mark the buttons you are interested in, add the attribute “rel = 'nofollow'” to the anchors, adjust the placement of the button panel and customize the appearance. What the settings page looks like can be seen in the picture below.

SexyBookmarks Plugin Settings Window.

This concludes the introductory part and proceeds to the main thing - the topic of the article.

As mentioned earlier, the plugin includes 87 built-in buttons, but among them there are none of the most popular Odnoklassniki and VKontakte buttons in our area. Further in the text, I will explain how to add them, but for those who do not need to delve into the process of adding buttons, at the end of the article there is a link to download the plugin with already built-in buttons.

Step 1

Copy the sexy-vkontakte.png and sexy-odnoklassniki.png icons for our future buttons to the sexybookmarks \ images \ icons folder

Step 2

Open the sexybookmarks \ includes \ bookmarks-data.php file and add the following lines to the end of the $ sexy_bookmarks_data array :

'sexy-vkontakte' => array(      
	  'check'=>sprintf(__('Check this box to include %s in your bookmarking menu', 'sexybookmarks'), __('VKontakte', 'sexybookmarks')),	  
	  'share'=>__('Share this on ', 'sexybookmarks').__('VKontakte', 'sexybookmarks'),   
      'baseUrl' => 'http://vk.com/share.php?url=PERMALINK&title=TITLE',
    ),
    'sexy-odnoklassniki' => array(      
	  'check'=>sprintf(__('Check this box to include %s in your bookmarking menu', 'sexybookmarks'), __('Odnoklassniki', 'sexybookmarks')),	  
	  'share'=>__('Share this on ', 'sexybookmarks').__('Odnoklassniki', 'sexybookmarks'),          
      'baseUrl' => 'http://share.yandex.ru/go.xml?service=odnoklassniki&url=PERMALINK',	  
    ),


This code will add 2 buttons to the component settings panel and to the page that your visitor will see.

I’ll explain some points about the code:
'check' - displayed in the tooltip of the button in the settings panel
'share' - displayed in the tooltip of the button on the page with the component
'baseUrl' - this is the url template for the button, where PERMALINK and TITLE are metacharacters.

Step 3

Open the file - sexybookmarks \ includes \ public.php . Find the function " function get_sexy () " function in the switch, add the case:
case 'sexy-vkontakte':
                $socials.=bookmark_list_item($name, array(
                    'permalink'=>urlencode($perms),
                    'title'=>$title,
                ));
                break;	


A small lyrical digression regarding the Odnoklassniki service
As practice has shown, the publishing service in Odnoklassniki is quite capricious, and if the url of your page includes Cyrillic letters, for example: my-site.com/hello-mir , then when you publish the link error " No access to resource "

Error "No access to the resource" when publishing to "Classmates"

Step 4

In principle, the previous three steps are already quite enough to ensure that the component is operational. Well, the most inquisitive can go further.

So, according to the results of the previous three steps, we have already placed the buttons in the admin panel and they are displayed in your notes. But on the settings panel, instead of the Odnoklassniki and VKontakte icons, the icon shown in the figure below is displayed.

Icon displayed for new buttons in sexybookmarks settings panel

In order to fix this situation, open the stylesheet for the admin panel: sexybookmarks \ css \ admin-style.css and add styles:

label.sexy-vkontakte{ background: url('../images/icons/sexy-vkontakte.png') no-repeat; 
background-repeat: no-repeat;
cursor: move;
float: left;
height: 40px;
margin: 12px 2px !important;
text-align: center;
width: 60px;}
label.sexy-odnoklassniki{ background: url('../images/icons/sexy-odnoklassniki.png') no-repeat; 
background-repeat: no-repeat;
cursor: move;
float: left;
height: 40px;
margin: 12px 2px !important;
text-align: center;
width: 60px; }


Step 5

In the tooltip of the button on the page and settings panel, the text is displayed in Latin letters - “Odnoklassniki” and “VKontakte”. If this situation does not suit you, then these buttons can be localized for the Russian language.

To configure localization, you will need the Poedit utility .

Localization files are located in the sexybookmarks \ languages ​​\ folder . These are files with the extensions: “* .po” , “* .mo” and “* .pot” . In the “* .po” file - localization variables are described, then these files are compiled into “* .mo” files.

Editing the * .po file

Run poedit.exe open the Russian language resource file - <directory with the plugin> \ sexybookmarks \ languages ​​\ sexybookmarks-ru_RU.po

Set the path to the directory with the plugin ("Directory" => "Settings ..."), select the "Paths" tab. In the " Database path" field, enter the path to the source folder of the sexybookmarks plugin .

Poedit - setting paths

Make synchronization with the source codes ("Catalog" => "Update from source")

Set translation for "VKontakte" and "Odnoklassniki"

Poedit - translation of constants sexybookmarks

Compilation "* .mo" -file

Now it remains to do the last - compile the “* .po” file into the “* .mo” file. You can do this on the command line.

"C:\Program Files\Poedit\bin\msgfmt.exe" -o C:\ВАША_ПАПКА_С_ПЛАГИНОМ\sexybookmarks\languages\sexybookmarks-ru_RU.mo C:\ ВАША_ПАПКА_С_ПЛАГИНОМ \sexybookmarks\languages\sexybookmarks-ru_RU.po


In response, usually nothing is written, the "* .mo" file is simply updated.

That's all! Thanks to everyone who mastered, I hope that my article was useful to you.

Link to download the sexybookmarks plugin along with the VKontakte and Odnoklassniki buttons:
depositfiles: sexybookmarks

Also popular now: