Skip to content

Commit

Permalink
Uka Share Buttons 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ukathemes committed Dec 8, 2020
1 parent 82c1087 commit 3acc380
Show file tree
Hide file tree
Showing 8 changed files with 250 additions and 60 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* Contributors: UkaThemes
* Tags: share buttons, wordpress
* Requires at least: 4.7
* Tested up to: 5.3
* Stable tag: 1.0.1
* Tested up to: 5.5
* Stable tag: 1.1.0
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,8 +28,11 @@ There is 1 function available to use: 'uka_share_buttons' returns html of share

## Changelog ##

**1.0.1 - March 08 2020**
**1.1.0 - December 09, 2020**
* Added social share URLs.

**1.0.1 - March 08, 2020**
* Some small fixes.

**1.0.0 - March 07 2020**
**1.0.0 - March 07, 2020**
* Initial release.
11 changes: 7 additions & 4 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: UkaThemes
Tags: share buttons, wordpress
Requires at least: 4.7
Tested up to: 5.3
Stable tag: 1.0.1
Tested up to: 5.5
Stable tag: 1.1.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -28,8 +28,11 @@ There is 1 function available to use: 'uka_share_buttons' returns html of share

== Changelog ==

= 1.0.1 - March 08 2020 =
= 1.1.0 - December 09, 2020 =
* Added social share URLs.

= 1.0.1 - March 08, 2020 =
* Some small fixes.

= 1.0.0 - March 07 2020 =
= 1.0.0 - March 07, 2020 =
* Initial release.
120 changes: 100 additions & 20 deletions admin/class-uka-share-buttons-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* The admin-specific functionality of the plugin.
*
* @since 1.0.0
* @since 1.1.0
*
* @package Uka_Share_Buttons
* @subpackage Uka_Share_Buttons/admin
Expand Down Expand Up @@ -46,24 +46,24 @@ public function register_settings() {
);

add_settings_field(
'social_services',
esc_html__( 'Social Services', 'uka-share-buttons' ),
array( $this, 'social_services_field'),
'share_text',
esc_html__( 'Share Text', 'uka-share-buttons' ),
array( $this, 'share_text_field'),
'share-buttons',
'main_settings',
array(
'label_for' => 'social_services',
'label_for' => 'share_text',
)
);

add_settings_field(
'share_text',
esc_html__( 'Share Text', 'uka-share-buttons' ),
array( $this, 'share_text_field'),
'social_services',
esc_html__( 'Social Services', 'uka-share-buttons' ),
array( $this, 'social_services_field'),
'share-buttons',
'main_settings',
array(
'label_for' => 'share_text',
'label_for' => 'social_services',
)
);

Expand All @@ -72,18 +72,28 @@ public function register_settings() {
/**
* Sanitize_options for settings page.
*
* @since 1.0.0
* @since 1.1.0
*/
public function sanitize_options( $input ) {

$input[ 'share_text' ] = sanitize_text_field( $input[ 'share_text' ] );
$input[ 'facebook' ] = sanitize_text_field( $input[ 'facebook' ] );
$input[ 'twitter' ] = sanitize_text_field( $input[ 'twitter' ] );
$input[ 'reddit' ] = sanitize_text_field( $input[ 'reddit' ] );
$input[ 'linkedin' ] = sanitize_text_field( $input[ 'linkedin' ] );
$input[ 'pinterest' ] = sanitize_text_field( $input[ 'pinterest' ] );
$input[ 'telegram' ] = sanitize_text_field( $input[ 'telegram' ] );
$input[ 'vk' ] = sanitize_text_field( $input[ 'vk' ] );
$input[ 'share_text' ] = sanitize_text_field( $input[ 'share_text' ] );
$input[ 'whatsapp' ] = sanitize_text_field( $input[ 'whatsapp' ] );
$input[ 'skype' ] = sanitize_text_field( $input[ 'skype' ] );
$input[ 'google' ] = sanitize_text_field( $input[ 'google' ] );
$input[ 'pocket' ] = sanitize_text_field( $input[ 'pocket' ] );
$input[ 'ok' ] = sanitize_text_field( $input[ 'ok' ] );
$input[ 'evernote' ] = sanitize_text_field( $input[ 'evernote' ] );
$input[ 'tumblr' ] = sanitize_text_field( $input[ 'tumblr' ] );
$input[ 'blogger' ] = sanitize_text_field( $input[ 'blogger' ] );
$input[ 'livejournal' ] = sanitize_text_field( $input[ 'livejournal' ] );
$input[ 'email' ] = sanitize_text_field( $input[ 'email' ] );

return $input;

Expand All @@ -92,19 +102,29 @@ public function sanitize_options( $input ) {
/**
* Output the social services settings field.
*
* @since 1.0.0
* @since 1.1.0
*/
public function social_services_field() {

$options = get_option( 'uka_share_buttons_options' );

$facebook = $options[ 'services-settings' ][ 'facebook' ];
$twitter = $options[ 'services-settings' ][ 'twitter' ];
$reddit = $options[ 'services-settings' ][ 'reddit' ];
$linkedin = $options[ 'services-settings' ][ 'linkedin' ];
$pinterest = $options[ 'services-settings' ][ 'pinterest' ];
$telegram = $options[ 'services-settings' ][ 'telegram' ];
$vk = $options[ 'services-settings' ][ 'vk' ];
$facebook = $options[ 'services-settings' ][ 'facebook' ];
$twitter = $options[ 'services-settings' ][ 'twitter' ];
$reddit = $options[ 'services-settings' ][ 'reddit' ];
$linkedin = $options[ 'services-settings' ][ 'linkedin' ];
$pinterest = $options[ 'services-settings' ][ 'pinterest' ];
$telegram = $options[ 'services-settings' ][ 'telegram' ];
$vk = $options[ 'services-settings' ][ 'vk' ];
$whatsapp = $options[ 'services-settings' ][ 'whatsapp' ];
$skype = $options[ 'services-settings' ][ 'skype' ];
$google = $options[ 'services-settings' ][ 'google' ];
$pocket = $options[ 'services-settings' ][ 'pocket' ];
$ok = $options[ 'services-settings' ][ 'ok' ];
$evernote = $options[ 'services-settings' ][ 'evernote' ];
$tumblr = $options[ 'services-settings' ][ 'tumblr' ];
$blogger = $options[ 'services-settings' ][ 'blogger' ];
$livejournal = $options[ 'services-settings' ][ 'livejournal' ];
$email = $options[ 'services-settings' ][ 'email' ];

$html = '<fieldset>';
$html .= sprintf( '<legend class="screen-reader-text"><span>%1$s</span></legend>', esc_html__( 'Share Buttons Settings', 'uka-share-buttons' ) );
Expand Down Expand Up @@ -151,8 +171,68 @@ public function social_services_field() {
$html .= sprintf( '%1$s</label>', esc_html__( 'VK', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="whatsapp">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][whatsapp]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="whatsapp" name="uka_share_buttons_options[services-settings][whatsapp]" value="on" %1$s />', checked( $whatsapp, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'WhatsApp', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="skype">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][skype]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="skype" name="uka_share_buttons_options[services-settings][skype]" value="on" %1$s />', checked( $skype, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Skype', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="google">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][google]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="google" name="uka_share_buttons_options[services-settings][google]" value="on" %1$s />', checked( $google, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Google Bookmarks', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="pocket">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][pocket]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="pocket" name="uka_share_buttons_options[services-settings][pocket]" value="on" %1$s />', checked( $pocket, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Pocket', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="ok">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][ok]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="ok" name="uka_share_buttons_options[services-settings][ok]" value="on" %1$s />', checked( $ok, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Odnoklassniki', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="evernote">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][evernote]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="evernote" name="uka_share_buttons_options[services-settings][evernote]" value="on" %1$s />', checked( $evernote, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Evernote', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="tumblr">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][tumblr]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="tumblr" name="uka_share_buttons_options[services-settings][tumblr]" value="on" %1$s />', checked( $tumblr, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Tumblr', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="blogger">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][blogger]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="blogger" name="uka_share_buttons_options[services-settings][blogger]" value="on" %1$s />', checked( $blogger, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Blogger', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="livejournal">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][livejournal]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="livejournal" name="uka_share_buttons_options[services-settings][livejournal]" value="on" %1$s />', checked( $livejournal, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'LiveJournal', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '<label for="email">';
$html .= '<input type="hidden" name="uka_share_buttons_options[services-settings][email]" value="off" />';
$html .= sprintf( '<input type="checkbox" class="checkbox" id="email" name="uka_share_buttons_options[services-settings][email]" value="on" %1$s />', checked( $email, 'on', false ) );
$html .= sprintf( '%1$s</label>', esc_html__( 'Email', 'uka-share-buttons' ) );
$html .= '<br />';

$html .= '</fieldset>';

echo $html;

}
Expand Down
30 changes: 20 additions & 10 deletions includes/class-uka-share-buttons-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Fired during plugin activation.
*
* @since 1.0.0
* @since 1.1.0
*
* @package Uka_Share_Buttons
* @subpackage Uka_Share_Buttons/includes
Expand All @@ -13,27 +13,37 @@ class Uka_Share_Buttons_Activator {
/**
* Compare WordPress version and set up the default option values.
*
* @since 1.0.0
* @since 1.1.0
*/
public static function activate() {

// Compare WordPress version
global $wp_version;

if ( version_compare( $wp_version, '4.7', '<' ) ) {
wp_die( sprintf( esc_html__( 'This plugin requires at least WordPress version 4.7. You are running version %s. Please upgrade and try again.', 'uka-share-buttons' ), $wp_version ) );
}

// Set default plugin parameters
$default_options = array(
'services-settings' => array(
'facebook' => 'on',
'twitter' => 'on',
'reddit' => 'off',
'linkedin' => 'off',
'pinterest' => 'off',
'telegram' => 'on',
'vk' => 'off',
'facebook' => 'on',
'twitter' => 'on',
'reddit' => 'off',
'linkedin' => 'off',
'pinterest' => 'off',
'telegram' => 'on',
'vk' => 'off',
'whatsapp' => 'off',
'skype' => 'off',
'google' => 'off',
'pocket' => 'off',
'ok' => 'off',
'evernote' => 'off',
'tumblr' => 'off',
'blogger' => 'off',
'livejournal' => 'off',
'email' => 'off',
),
'share-text' => esc_html__( 'Share:', 'uka-share-buttons' ),
);
Expand Down
60 changes: 55 additions & 5 deletions includes/class-uka-share-buttons.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* A class definition that includes attributes and functions used across both the
* public-facing side of the site and the admin area.
*
* @since 1.0.0
* @since 1.1.0
*
* @package Uka_Share_Buttons
* @subpackage Uka_Share_Buttons/includes
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct() {
if ( defined( 'UKA_SHARE_BUTTONS_VERSION' ) ) {
$this->version = UKA_SHARE_BUTTONS_VERSION;
} else {
$this->version = '1.0.0';
$this->version = '1.1.0';
}
$this->plugin_name = 'uka-share-buttons';

Expand Down Expand Up @@ -127,7 +127,7 @@ private function load_dependencies() {
* %2$s - title
* %3$s - image
*
* @since 1.0.0
* @since 1.1.0
* @return string Supported services.
*/
public static function get_services() {
Expand All @@ -151,12 +151,12 @@ public static function get_services() {
'linkedin' => array(
'id' => 'linkedin',
'title' => esc_html__( 'LinkedIn' ),
'url' => 'https://www.linkedin.com/shareArticle?mini=true&url=%1$s&title=%2$s',
'url' => 'https://www.linkedin.com/sharing/share-offsite/?url=%1$s',
),
'pinterest' => array(
'id' => 'pinterest',
'title' => esc_html__( 'Pinterest' ),
'url' => 'https://www.pinterest.com/pin/create/button/?url=%1$s',
'url' => 'http://pinterest.com/pin/create/button/?url=%1$s',
),
'telegram' => array(
'id' => 'telegram',
Expand All @@ -168,6 +168,56 @@ public static function get_services() {
'title' => esc_html__( 'VK' ),
'url' => 'http://vk.com/share.php?url=%1$s&title=%2$s',
),
'whatsapp' => array(
'id' => 'whatsapp',
'title' => esc_html__( 'WhatsApp' ),
'url' => 'https://api.whatsapp.com/send?text=%2$s %1$s',
),
'skype' => array(
'id' => 'skype',
'title' => esc_html__( 'Skype' ),
'url' => 'https://web.skype.com/share?url=%1$s&text=%2$s',
),
'google' => array(
'id' => 'google',
'title' => esc_html__( 'Google Bookmarks' ),
'url' => 'https://www.google.com/bookmarks/mark?op=edit&bkmk=%1$s&title=%2$s',
),
'pocket' => array(
'id' => 'pocket',
'title' => esc_html__( 'Pocket' ),
'url' => 'https://getpocket.com/edit?url=%1$s',
),
'ok' => array(
'id' => 'ok',
'title' => esc_html__( 'Odnoklassniki' ),
'url' => 'https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=%1$s',
),
'evernote' => array(
'id' => 'evernote',
'title' => esc_html__( 'Evernote' ),
'url' => 'https://www.evernote.com/clip.action?url=%1$s&title=%2$s',
),
'tumblr' => array(
'id' => 'tumblr',
'title' => esc_html__( 'Tumblr' ),
'url' => 'https://www.tumblr.com/widgets/share/tool?canonicalUrl=%1$s&title=%2$s',
),
'blogger' => array(
'id' => 'blogger',
'title' => esc_html__( 'Blogger' ),
'url' => 'https://www.blogger.com/blog-this.g?u=%1$s&n=%2$s',
),
'livejournal' => array(
'id' => 'livejournal',
'title' => esc_html__( 'LiveJournal' ),
'url' => 'http://www.livejournal.com/update.bml?subject=%2$s&event=%1$s',
),
'email' => array(
'id' => 'email',
'title' => esc_html__( 'Email' ),
'url' => 'mailto:?subject=%2$s&body=%1$s',
),
);

return $services;
Expand Down
Loading

0 comments on commit 3acc380

Please sign in to comment.