Skip to content

Commit

Permalink
Merge pull request #11 from creativejuiz/dev
Browse files Browse the repository at this point in the history
Multisite compatibility
  • Loading branch information
geoffreycrofte authored May 14, 2017
2 parents c0353d8 + c05e8e3 commit 8641cb3
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 33 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Contributors
* Geoffrey Crofte ([WP Media](http://wp-media.me))
* *Contributors*
* Jean-Baptiste Audras ([Whodunit](http://www.whodunit.fr/))
* Marie Comet ([Marie Comet](http://mariecomet.fr/))
* *Translators*
* [Dennis Schmitz](http://compcardinmotion.de)
* [半月 Hangetsu](http://wp.fruit-frappe.net/)
Expand Down
44 changes: 22 additions & 22 deletions admin/jsps-admin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
register_activation_hook( JUIZ_SPS_FILE, 'juiz_sps_activation' );
function juiz_sps_activation() {

$juiz_sps_options = get_option ( JUIZ_SPS_SETTING_NAME );
$juiz_sps_options = jsps_get_option();

if ( ! is_array( $juiz_sps_options ) ) {

Expand Down Expand Up @@ -46,7 +46,7 @@ function juiz_sps_activation() {
)
);

update_option( JUIZ_SPS_SETTING_NAME , $default_array );
jsps_update_option( $default_array );
}
else {
// if was version under 1.2.3
Expand All @@ -56,7 +56,7 @@ function juiz_sps_activation() {
);

$updated_array = array_merge( $juiz_sps_options, $new_options );
update_option( JUIZ_SPS_SETTING_NAME , $updated_array );
jsps_update_option( $updated_array );
}

// if was version under 1.3.0
Expand All @@ -65,15 +65,15 @@ function juiz_sps_activation() {
$juiz_sps_options['juiz_sps_networks']['vk'] = array( 0, __( 'VKontakte', 'juiz-social-post-sharer' ) );
$juiz_sps_options['juiz_sps_colors'] = array( 'bg_color' => '', 'txt_color' => ''); // for next update

update_option( JUIZ_SPS_SETTING_NAME , $juiz_sps_options );
jsps_update_option( $juiz_sps_options );
}

// if was version under 1.3.3.7
if ( ! isset( $juiz_sps_options['juiz_sps_counter_option'] ) ) {

$juiz_sps_options['juiz_sps_counter_option'] = 'both';

update_option( JUIZ_SPS_SETTING_NAME , $juiz_sps_options );
jsps_update_option( $juiz_sps_options );
}

// if was version under 1.4.1
Expand All @@ -84,7 +84,7 @@ function juiz_sps_activation() {
$juiz_sps_options['juiz_sps_networks']['delicious'] = array( 0, __( 'Delicious', 'juiz-social-post-sharer' ) );
$juiz_sps_options['juiz_sps_networks']['reddit'] = array( 0, __( 'Reddit', 'juiz-social-post-sharer' ) );

update_option( JUIZ_SPS_SETTING_NAME , $juiz_sps_options );
jsps_update_option( $juiz_sps_options );
}

// if was version under 1.4.2
Expand All @@ -94,7 +94,7 @@ function juiz_sps_activation() {
$juiz_sps_options['juiz_sps_networks']['bookmark'] = array( 0, __( 'Bookmark', 'juiz-social-post-sharer' ) );
$juiz_sps_options['juiz_sps_networks']['print'] = array( 0, __( 'Print', 'juiz-social-post-sharer' ) );

update_option( JUIZ_SPS_SETTING_NAME , $juiz_sps_options );
jsps_update_option( $juiz_sps_options );
}
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ function juiz_sps_custom_admin_header() {
add_action( 'add_meta_boxes', 'juiz_sps_metaboxes' );
function juiz_sps_metaboxes(){

$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
$pts = get_post_types( array( 'public'=> true, 'show_ui' => true, '_builtin' => true ) );
$cpts = get_post_types( array( 'public'=> true, 'show_ui' => true, '_builtin' => false ) );

Expand Down Expand Up @@ -227,7 +227,7 @@ function juiz_sps_sanitize( $options ) {
if ( is_array( $options['juiz_sps_networks'] ) ) {

$temp_array = array( 'facebook' => 0, 'twitter' => 0, 'google' => 0, 'pinterest' => 0, 'viadeo' => 0, 'linkedin' => 0, 'digg' => 0, 'stumbleupon' => 0, 'weibo' => 0, 'mail' => 0, 'vk' => 0 );
$juiz_sps_opt = get_option ( JUIZ_SPS_SETTING_NAME );
$juiz_sps_opt = jsps_get_option();

// new option (1.2.0)
if ( ! in_array( 'weibo', $juiz_sps_opt['juiz_sps_networks'] ) ) {
Expand Down Expand Up @@ -302,7 +302,7 @@ function juiz_sps_section_text() {
if ( ! function_exists( 'juiz_sps_setting_radio_style_choice' ) ) {
function juiz_sps_setting_radio_style_choice() {

$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
if ( is_array( $options ) ) {
$n1 = $n2 = $n3 = $n4 = $n5 = $n6 = $n7 = $n8 = '';
${'n' . $options['juiz_sps_style']} = ' checked="checked"';
Expand Down Expand Up @@ -348,7 +348,7 @@ function juiz_sps_setting_radio_style_choice() {
if ( ! function_exists( 'juiz_sps_setting_checkbox_network_selection' ) ) {
function juiz_sps_setting_checkbox_network_selection() {
$y = $n = '';
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
if ( is_array( $options ) ) {
foreach ( $options['juiz_sps_networks'] as $k => $v ) {

Expand All @@ -370,7 +370,7 @@ function juiz_sps_setting_checkbox_network_selection() {
// input for twitter username
if ( ! function_exists( 'juiz_sps_setting_input_twitter_user' ) ) {
function juiz_sps_setting_input_twitter_user() {
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
if ( is_array( $options ) ) {
$username = isset( $options['juiz_sps_twitter_user'] ) ? $options['juiz_sps_twitter_user'] : '';
echo '<p class="juiz_sps_options_p">
Expand All @@ -392,7 +392,7 @@ function juiz_sps_section_text_display() {
function juiz_sps_setting_checkbox_content_type() {
$pts = get_post_types( array( 'public'=> true, 'show_ui' => true, '_builtin' => true ) );
$cpts = get_post_types( array( 'public'=> true, 'show_ui' => true, '_builtin' => false ) );
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
$all_lists_icon = '<span class="dashicons-before dashicons-editor-ul"></span>';
$all_lists_selected = '';
if ( is_array( $options['juiz_sps_display_in_types'] ) ) {
Expand Down Expand Up @@ -452,7 +452,7 @@ function juiz_sps_setting_checkbox_content_type() {
if ( ! function_exists( 'juiz_sps_setting_radio_where' ) ) {
function juiz_sps_setting_radio_where() {

$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();

$w_bottom = $w_top = $w_both = $w_nowhere = '';
if ( is_array( $options ) && isset( $options['juiz_sps_display_where'] ) )
Expand Down Expand Up @@ -487,7 +487,7 @@ function juiz_sps_section_text_advanced() {
if ( ! function_exists( 'juiz_sps_setting_radio_hide_social_name' ) ) {
function juiz_sps_setting_radio_hide_social_name() {
$y = $n = '';
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();

if ( is_array( $options ) )
( isset( $options['juiz_sps_hide_social_name'] ) && $options['juiz_sps_hide_social_name'] == 1 ) ? $y = ' checked="checked"' : $n = ' checked="checked"';
Expand All @@ -506,7 +506,7 @@ function juiz_sps_setting_radio_hide_social_name() {
if ( ! function_exists( 'juiz_sps_setting_radio_target_link' ) ) {
function juiz_sps_setting_radio_target_link() {
$y = $n = '';
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();

if ( is_array( $options ) )
( isset( $options['juiz_sps_target_link'] ) && $options['juiz_sps_target_link'] == 1 ) ? $y = ' checked="checked"' : $n = ' checked="checked"';
Expand All @@ -523,7 +523,7 @@ function juiz_sps_setting_radio_target_link() {
if ( ! function_exists( 'juiz_sps_setting_radio_force_snif' ) ) {
function juiz_sps_setting_radio_force_snif() {
$y = $n = '';
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();

if ( is_array( $options ) )
( isset( $options['juiz_sps_force_pinterest_snif'] ) && $options['juiz_sps_force_pinterest_snif'] == 1 ) ? $y = ' checked="checked"' : $n = ' checked="checked"';
Expand All @@ -541,7 +541,7 @@ function juiz_sps_setting_radio_force_snif() {
function juiz_sps_setting_radio_counter() {

$y = $n = '';
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();

if ( is_array( $options ) )
( isset( $options['juiz_sps_counter'] ) && $options['juiz_sps_counter'] == 1 ) ? $y = ' checked="checked"' : $n = ' checked="checked"';
Expand All @@ -558,7 +558,7 @@ function juiz_sps_setting_radio_counter() {
if ( ! function_exists( 'juiz_sps_setting_radio_counter_option' ) ) {
function juiz_sps_setting_radio_counter_option() {

$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
if ( is_array( $options ) ) {
$both = ( isset( $options['juiz_sps_counter_option'] ) && $options['juiz_sps_counter_option'] == 'both' ) ? ' checked="checked"' : '';
$total = ( isset( $options['juiz_sps_counter_option'] ) && $options['juiz_sps_counter_option'] == 'total' ) ? ' checked="checked"' : '';
Expand Down Expand Up @@ -586,7 +586,7 @@ function juiz_sps_setting_radio_counter_option() {
if ( ! function_exists( 'juiz_sps_setting_radio_css_in_html' ) ) {
function juiz_sps_setting_radio_css_in_html() {
$y = $n = '';
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();

if ( is_array( $options ) )
( isset( $options['juiz_sps_write_css_in_html'] ) && $options['juiz_sps_write_css_in_html'] == 1 ) ? $y = ' checked="checked"' : $n = ' checked="checked"';
Expand All @@ -610,15 +610,15 @@ function juiz_sps_section_text_mail() {
}
if ( ! function_exists( 'juiz_sps_setting_input_mail_subject' ) ) {
function juiz_sps_setting_input_mail_subject() {
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
if ( isset( $options['juiz_sps_mail_subject'] ) ) {
echo '<input id="juiz_sps_mail_subject" value="' . esc_attr( $options['juiz_sps_mail_subject'] ) . '" name="' . JUIZ_SPS_SETTING_NAME . '[juiz_sps_mail_subject]" type="text">';
}
}
}
if ( ! function_exists( 'juiz_sps_setting_textarea_mail_body' ) ) {
function juiz_sps_setting_textarea_mail_body() {
$options = get_option( JUIZ_SPS_SETTING_NAME );
$options = jsps_get_option();
if ( isset( $options['juiz_sps_mail_body'] ) ) {
echo '<textarea id="juiz_sps_mail_body" name="' . JUIZ_SPS_SETTING_NAME . '[juiz_sps_mail_body]">' . esc_textarea( $options['juiz_sps_mail_body'] ) . '</textarea>';
}
Expand Down
78 changes: 70 additions & 8 deletions juiz-social-post-sharer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
Plugin URI: http://wordpress.org/extend/plugins/juiz-social-post-sharer/
Description: Add buttons after (or before, or both) your posts to allow visitors share your content (includes no JavaScript mode). You can also use <code>juiz_sps($array)</code> template function or <code>[juiz_sps]</code> shortcode. For more informations see the setting page located in <strong>Settings</strong> submenu.
Author: Geoffrey Crofte
Version: 1.4.6
Version: 1.4.7
Author URI: http://geoffrey.crofte.fr
License: GPLv2 or later
Text Domain: juiz-social-post-sharer
Domain Path: /languages
Copyright 2012-2015 Geoffrey Crofte (email : [email protected])
Copyright 2012-2017 Geoffrey Crofte (email : [email protected])
This program is free software; you can redistribute it and/or
Expand All @@ -32,21 +32,83 @@
*/

define( 'JUIZ_SPS_PLUGIN_NAME', 'Juiz Social Post Sharer' );
define( 'JUIZ_SPS_VERSION', '1.4.6' );
define( 'JUIZ_SPS_VERSION', '1.4.7' );
define( 'JUIZ_SPS_FILE', __FILE__ );
define( 'JUIZ_SPS_DIRNAME', basename( dirname( __FILE__ ) ) );
define( 'JUIZ_SPS_PLUGIN_URL', plugin_dir_url( __FILE__ ));
define( 'JUIZ_SPS_SLUG', 'juiz-social-post-sharer' );
define( 'JUIZ_SPS_SETTING_NAME', 'juiz_SPS_settings' );


// multilingue
// Checking network activation.
$is_nw_activated = function_exists( 'is_plugin_active_for_network' ) && is_plugin_active_for_network( JUIZ_SPS_SLUG . '/' . JUIZ_SPS_SLUG . '.php' ) ? true : false;

define( 'JUIZ_SPS_NETWORK_ACTIVATED', $is_nw_activated );


// Multilingal.
add_action( 'init', 'make_juiz_sps_multilang' );
function make_juiz_sps_multilang() {
load_plugin_textdomain( 'juiz-social-post-sharer', false, JUIZ_SPS_DIRNAME.'/languages' );
}

/**
* Getting options from the right place.
* Multisite compatibility.
*
* @author Marie Comet, Geoffrey Crofte
* @since 1.4.7
*/
function jsps_get_option( $option_name = '' ) {

// When we want a precise option in a network activated website.
if ( ! empty( $option_name ) && true === JUIZ_SPS_NETWORK_ACTIVATED ) {
$options = get_blog_option( get_current_blog_id(), JUIZ_SPS_SETTING_NAME );
return $options[ $option_name ];
}

// When we want all options in a network activated website.
else if ( empty( $option_name ) && true === JUIZ_SPS_NETWORK_ACTIVATED ) {
return get_blog_option( get_current_blog_id(), JUIZ_SPS_SETTING_NAME );
}

// When we want a precise option in a simple website.
else if ( ! empty( $option_name ) && false === JUIZ_SPS_NETWORK_ACTIVATED ) {
$options = get_option( JUIZ_SPS_SETTING_NAME );
return $options[ $option_name ];
}

// When we want all options in a simple website.
else {
return get_option( JUIZ_SPS_SETTING_NAME );
}

}

/**
* Updating options to the right place.
* Multisite compatibility.
*
* @author Marie Comet, Geoffrey Crofte
* @since 1.4.7
*/
function jsps_update_option( $options ) {

if ( ! is_array( $options ) ) {
die( '$options has to be an array' );
}

// When we want to update options in a network activated website.
if ( true === JUIZ_SPS_NETWORK_ACTIVATED ) {
$options = update_blog_option( get_current_blog_id(), JUIZ_SPS_SETTING_NAME, $options );
return $options;
}

// When we want to update options in a simple website.
else {
$options = update_option( JUIZ_SPS_SETTING_NAME, $options );
}
}

if ( is_admin() || ( defined( 'DOING_AJAX' ) && ! DOING_AJAX ) ) {

include('admin/jsps-admin.inc.php');
Expand All @@ -62,7 +124,7 @@ function make_juiz_sps_multilang() {

function juiz_sps_style_and_script() {

$juiz_sps_options = get_option( JUIZ_SPS_SETTING_NAME );
$juiz_sps_options = jsps_get_option();

if ( is_array( $juiz_sps_options ) ) {

Expand Down Expand Up @@ -173,7 +235,7 @@ function get_juiz_sps( $networks = array(), $counters = 0, $is_current_page_url


// get the plugin options
$juiz_sps_options = get_option( JUIZ_SPS_SETTING_NAME );
$juiz_sps_options = jsps_get_option();

// classes and attributes options
$juiz_sps_target_link = ( isset( $juiz_sps_options['juiz_sps_target_link'] ) && $juiz_sps_options['juiz_sps_target_link'] == 1 ) ? ' target="_blank"' : '';
Expand Down Expand Up @@ -374,7 +436,7 @@ function juiz_sps( $networks = array(), $counters = 0, $current_page = 0, $is_sh
if ( ! function_exists( 'juiz_sps_print_links' ) ) {
function juiz_sps_print_links( $content ) {

$juiz_sps_options = get_option( JUIZ_SPS_SETTING_NAME );
$juiz_sps_options = jsps_get_option();

if ( isset( $juiz_sps_options['juiz_sps_display_in_types'] ) ) {

Expand Down
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: CreativeJuiz
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=P39NJPCWVXGDY&lc=FR&item_name=Juiz%20Social%20Post%20Sharer%20%2d%20WP%20Plugin&item_number=%23wp%2djsps&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted
Tags: social, twitter, google, facebook, digg, stumbleupon, linkedin, pinterest, viadeo, weibo, vkontakte, post, share
Requires at least: 3.3
Tested up to: 4.6
Stable tag: 1.4.6
Tested up to: 4.7.4
Stable tag: 1.4.7

Add smart designed buttons after/before your posts to allow visitors sharing your content (includes no JavaScript mode & counters)

Expand Down Expand Up @@ -144,6 +144,9 @@ Find my plugins at <a href="http://profiles.wordpress.org/creativejuiz/">http://

== Changelog ==

= 1.4.7 =
* Compatibility on network (multisite) thanks to Marie Comet ([Marie Comet](http://mariecomet.fr/))

= 1.4.6 =
* Tested up to WordPress 4.6
* Facebook counter is back thanks to Jean-Baptiste (from [Whodunit](http://www.whodunit.fr/))
Expand Down
3 changes: 2 additions & 1 deletion uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
exit();
}

delete_option( 'juiz_SPS_settings' );
delete_option( 'juiz_SPS_settings' );
delete_site_option( 'juiz_SPS_settings' );

0 comments on commit 8641cb3

Please sign in to comment.