-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better naming for multisite compatibility (+ bug fix on THIS_PLUGIN_N…
…ETWORK_ACTIVATED)
- Loading branch information
1 parent
45c40bc
commit c05e8e3
Showing
4 changed files
with
94 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<?php | ||
/* | ||
Plugin Name: Juiz Social Post Sharer Forked | ||
Plugin Name: Juiz Social Post Sharer | ||
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 | ||
|
@@ -32,65 +32,81 @@ | |
*/ | ||
|
||
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' ); | ||
|
||
/** | ||
* MULTISITE COMPATIBILITY | ||
**/ | ||
// define a constant to see if site is network activated | ||
if ( ! function_exists( 'is_plugin_active_for_network' ) ) { | ||
// Makes sure the plugin is defined before trying to use it | ||
require_once( ABSPATH . '/wp-admin/includes/plugin.php' ); | ||
} | ||
if (is_plugin_active_for_network('juiz-social-post-sharer/juiz-social-post-sharer.php')) { // path to plugin folder and main file | ||
define('JUIZ_NETWORK_ACTIVATED', true); | ||
} | ||
else { | ||
define('JUIZ_NETWORK_ACTIVATED', false); | ||
} | ||
// 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; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
// Wordpress function 'get_site_option' and 'get_option' | ||
function juiz_get_option($option_name) { | ||
define( 'JUIZ_SPS_NETWORK_ACTIVATED', $is_nw_activated ); | ||
|
||
if(THIS_PLUGIN_NETWORK_ACTIVATED == true) { | ||
|
||
// 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' ); | ||
} | ||
|
||
// Get network site option | ||
return get_blog_option(get_current_blog_id(), $option_name); | ||
} | ||
else { | ||
/** | ||
* 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 ) { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
$options = get_blog_option( get_current_blog_id(), JUIZ_SPS_SETTING_NAME ); | ||
return $options[ $option_name ]; | ||
} | ||
|
||
// Get blog option | ||
return get_option($option_name); | ||
} | ||
} | ||
// Wordpress function 'update_site_option' and 'update_option' | ||
function juiz_update_plugin_option($option_name, $option_value) { | ||
// 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 ); | ||
} | ||
|
||
if(THIS_PLUGIN_NETWORK_ACTIVATED== true) { | ||
// 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 ]; | ||
} | ||
|
||
// Update network site option | ||
return update_blog_option(get_current_blog_id(), $option_name, $option_value); | ||
} | ||
else { | ||
// When we want all options in a simple website. | ||
else { | ||
return get_option( JUIZ_SPS_SETTING_NAME ); | ||
} | ||
|
||
// Update blog option | ||
return update_option($option_name, $option_value); | ||
} | ||
} | ||
|
||
/** | ||
* MULTISITE COMPATIBILITY | ||
**/ | ||
* 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 ) ) { | ||
This comment has been minimized.
Sorry, something went wrong.
geoffreycrofte
Author
Owner
|
||
die( '$options has to be an array' ); | ||
} | ||
|
||
// multilingue | ||
// 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; | ||
} | ||
|
||
add_action( 'init', 'make_juiz_sps_multilang' ); | ||
function make_juiz_sps_multilang() { | ||
load_plugin_textdomain( 'juiz-social-post-sharer', false, JUIZ_SPS_DIRNAME.'/languages' ); | ||
// 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 ) ) { | ||
|
@@ -108,7 +124,7 @@ function make_juiz_sps_multilang() { | |
|
||
function juiz_sps_style_and_script() { | ||
|
||
$juiz_sps_options = juiz_get_option( JUIZ_SPS_SETTING_NAME ); | ||
$juiz_sps_options = jsps_get_option(); | ||
|
||
if ( is_array( $juiz_sps_options ) ) { | ||
|
||
|
@@ -219,7 +235,7 @@ function get_juiz_sps( $networks = array(), $counters = 0, $is_current_page_url | |
|
||
|
||
// get the plugin options | ||
$juiz_sps_options = juiz_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"' : ''; | ||
|
@@ -420,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 = juiz_get_option( JUIZ_SPS_SETTING_NAME ); | ||
$juiz_sps_options = jsps_get_option(); | ||
|
||
if ( isset( $juiz_sps_options['juiz_sps_display_in_types'] ) ) { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Named
jsps_
to avoid conflict with otherjuiz_
plugins. (yeah I have got several plugins)