',
$post_type,
isset( $GLOBALS['shariff3uu_basic']['add_after'][ $post_type ] ) ? checked( $GLOBALS['shariff3uu_basic']['add_after'][ $post_type ], 1, 0 ) : '',
// The following should already be localized <- not always, but there is no way to know, so we have to accept the language mix up.
esc_html( $object->labels->singular_name )
);
}
}
/**
* Add before.
*/
function shariff3uu_multiplecheckbox_add_before_render() {
// Add before all posts.
echo '
',
$post_type,
isset( $GLOBALS['shariff3uu_basic']['add_before'][ $post_type ] ) ? checked( $GLOBALS['shariff3uu_basic']['add_before'][ $post_type ], 1, 0 ) : '',
// The following should already be localized <- not always, but there is no way to know, so we have to accept the language mix up.
esc_html( $object->labels->singular_name )
);
}
}
/**
* Disable on password protected posts.
*/
function shariff3uu_checkbox_disable_on_protected_render() {
echo '';
}
/**
* Disable outside loop.
*/
function shariff3uu_checkbox_disable_outside_loop_render() {
echo '';
}
/**
* Custom hooks.
*/
function shariff3uu_text_custom_hooks_render() {
if ( isset( $GLOBALS['shariff3uu_basic']['custom_hooks'] ) ) {
$custom_hooks = $GLOBALS['shariff3uu_basic']['custom_hooks'];
} else {
$custom_hooks = '';
}
echo '';
echo '
' . esc_html__( 'Use the pipe sign | (Alt Gr + < or ⌥ + 7) between two or more hooks.', 'shariff' ) . '
';
}
/**
* Custom hooks shortcode.
*/
function shariff3uu_text_custom_hooks_shortcode_render() {
if ( isset( $GLOBALS['shariff3uu_basic']['custom_hooks_shortcode'] ) ) {
$custom_hooks_shortcode = $GLOBALS['shariff3uu_basic']['custom_hooks_shortcode'];
} else {
$custom_hooks_shortcode = '';
}
echo '';
}
/** Design options */
/**
* Description of the design options.
*/
function shariff3uu_design_section_callback() {
esc_html_e( 'This configures the default design of the Shariff buttons. Most options can be overwritten for single posts or pages with the options within the [shariff] shorttag. ', 'shariff' );
$help_link = get_bloginfo( 'wpurl' ) . '/wp-admin/options-general.php?page=shariff3uu&tab=help';
// Translators: %s will be replaced with the correct URL to the help section.
printf( wp_kses( __( 'For more information please take a look at the Help Section. ', 'shariff' ), array( 'a' => array( 'href' => true ) ) ), esc_url( $help_link ) );
printf(
wp_kses(
// Translators: %s will be replaced with the correct URL to the wordpress.org support forum.
__( 'You should also check out the Support Forum. ', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
),
'https://wordpress.org/support/plugin/shariff/'
);
}
/**
* Language.
*/
function shariff3uu_select_language_render() {
$options = $GLOBALS['shariff3uu_design'];
if ( ! isset( $options['lang'] ) ) {
$options['lang'] = substr( get_locale(), 0, 2 );
}
echo '';
}
/**
* Automatic button language.
*/
function shariff3uu_checkbox_autolang_render() {
echo '';
}
/**
* Theme.
*/
function shariff3uu_radio_theme_render() {
$options = $GLOBALS['shariff3uu_design'];
if ( ! isset( $options['theme'] ) ) {
$options['theme'] = '';
}
$plugins_url = plugins_url();
echo '
';
echo esc_html__( 'Basic HTML as well as style and class attributes are allowed. You can use %total to show the total amount of shares.', 'shariff' );
echo ' ';
echo esc_html__( 'Example:', 'shariff' );
echo ' <h3 class="shariff_headline">';
echo esc_html__( 'Already shared %total times!', 'shariff' );
echo '</h3>
' . wp_kses(
__( 'Warning: This is an experimental feature. Please read the Frequently Asked Questions (FAQ).', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
) . '
';
echo '
' . esc_html__( 'Please check, if you have to add this domain to the array $SHARIFF_FRONTENDS on the external server.', 'shariff' ) . '
';
}
/**
* Direct external api call from JS.
*/
function shariff3uu_checkbox_external_direct_render() {
echo '';
echo '
' . esc_html__( 'Please check, if you have correctly set the Access-Control-Allow-Origin header!', 'shariff' ) . '
';
}
/**
* Local API only reachable in subfolder.
*/
function shariff3uu_checkbox_subapi_render() {
echo '';
}
/**
* Help section.
*/
function shariff3uu_help_section_callback() {
echo '
';
printf(
wp_kses(
// Translators: %1$s and %2$s will be replaced with the correct URLs to the authors websites.
__( 'The WordPress plugin "Shariff Wrapper" has been developed by Jan-Peter Lambeck and 3UU in order to help protect the privacy of your visitors. ', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
),
'https://www.jplambeck.de',
'https://datenverwurstungszentrale.com'
);
echo ' ';
printf(
wp_kses(
// Translators: %s will be replaced with the correct URL to the German computer magazine.
__( 'It is based on the original Shariff buttons developed by the German computer magazine c\'t that are compliant to the General Data Protection Regulation (GDPR) (Regulation (EU) 2016/679).', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
),
'https://ct.de/-2467514'
);
echo ' ';
printf(
wp_kses(
// Translators: %1$s and %2$s will be replaced with the correct URLs to FAQ and the forum on wordpress.org.
__( 'If you need any help with the plugin, take a look at the Frequently Asked Questions (FAQ) and the Support Forum on wordpress.org. ', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
),
'https://wordpress.org/plugins/shariff/#faq',
'https://wordpress.org/support/plugin/shariff'
);
echo '
';
echo '
';
// Translators: %s will be replaced with the correct URL to the authors twitter account.
printf(
wp_kses(
// Translators: %s will be replaced with the correct URL to the authors twitter account.
__( 'You can also follow @jplambeck on Twitter.', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
),
'https://twitter.com/jplambeck'
);
echo '
';
echo '
';
// Translators: %s will be replaced with the correct URL to the wordpress.org review page.
printf(
wp_kses(
// Translators: %s will be replaced with the correct URL to the wordpress.org review page.
__( 'If you enjoy our plugin, please consider writing a review about it on wordpress.org.', 'shariff' ),
array(
'a' => array(
'href' => true,
'target' => true,
),
)
),
'https://wordpress.org/support/view/plugin-reviews/shariff'
);
echo '
';
echo '
';
echo wp_kses( __( 'This is a list of all available options for the [shariff] shortcode:', 'shariff' ), array( 'code' => array() ) );
echo '
' . esc_html__( 'Determines which buttons to show and in which order.', 'shariff' ) . '
';
echo '
';
// Backend.
echo '
';
echo '
backend
';
echo '
on off
';
echo '
off
';
echo '
[shariff backend="on"]
';
echo '
' . esc_html__( 'Enables share counts on the buttons.', 'shariff' ) . '
';
echo '
';
// Theme.
echo '
';
echo '
theme
';
echo '
default color grey white round wcag
';
echo '
default
';
echo '
[shariff theme="round"]
';
echo '
' . esc_html__( 'Determines the main design of the buttons.', 'shariff' ) . '
';
echo '
';
// Buttonsize.
echo '
';
echo '
buttonsize
';
echo '
small medium large
';
echo '
medium
';
echo '
[shariff buttonsize="small"]
';
echo '
' . esc_html__( 'Determines the button size regardless of theme choice.', 'shariff' ) . '
';
echo '
';
// Buttonstretch.
echo '
';
echo '
buttonstretch
';
echo '
0 1
';
echo '
0
';
echo '
[shariff buttonstretch="1"]
';
echo '
' . esc_html__( 'Stretch buttons horizontally to full width.', 'shariff' ) . '
';
echo '
';
// Borderradius.
echo '
';
echo '
borderradius
';
echo '
1-50
';
echo '
50
';
echo '
[shariff borderradius="1"]
';
echo '
' . esc_html__( 'Sets the border radius for the round theme. 1 essentially equals a square.', 'shariff' ) . '
';
echo '
';
// Maincolor.
echo '
';
echo '
maincolor
';
echo '';
echo '';
echo '
[shariff maincolor="#000"]
';
echo '
' . esc_html__( 'Sets a custom main color for all buttons (hexadecimal).', 'shariff' ) . '
';
echo '
';
// Secondarycolor.
echo '
';
echo '
secondarycolor
';
echo '';
echo '';
echo '
[shariff secondarycolor="#afafaf"]
';
echo '
' . esc_html__( 'Sets a custom secondary color for all buttons (hexadecimal). The secondary color is, depending on theme, used for hover effects.', 'shariff' ) . '
';
echo '
';
// Orientation.
echo '
';
echo '
orientation
';
echo '
horizontal vertical
';
echo '
horizontal
';
echo '
[shariff orientation="vertical"]
';
echo '
' . esc_html__( 'Changes the orientation of the buttons.', 'shariff' ) . '
';
echo '
';
// Alignment.
echo '
';
echo '
align
';
echo '
flex-start center flex-end
';
echo '
flex-start
';
echo '
[shariff align="center"]
';
echo '
' . esc_html__( 'Changes the horizontal alignment of the buttons. flex-start means left, center is obvious and flex-end means right.', 'shariff' ) . '
';
echo '
';
// Language.
echo '
';
echo '
language
';
echo '
bg, cs, da, de, en, es, fi, fr, hr, hu, it, ja, ko, nl, no, pl, pt, ro, ru, sk, sl, sr, sv, tr, zh
' . esc_html__( 'Adds a headline above the Shariff buttons. Basic HTML as well as style and class attributes can be used. To remove a headline set on the plugins options page use headline="".', 'shariff' ) . '
';
echo '
';
// Style.
echo '
';
echo '
style
';
echo '';
echo '';
echo '
[shariff style="margin:20px;"]
';
echo '
' . esc_html__( 'Adds custom style attributes to the container around Shariff.', 'shariff' ) . '
';
echo '
';
// CSS class.
echo '
';
echo '
cssclass
';
echo '';
echo '';
echo '
[shariff class="classname"]
';
echo '
' . esc_html__( 'Adds a custom class to the container around Shariff.', 'shariff' ) . '
';
echo '
';
// Twitter_via.
echo '
';
echo '
twitter_via
';
echo '';
echo '';
echo '
[shariff twitter_via="your_twittername"]
';
echo '
' . esc_html__( 'Sets the Twitter via tag.', 'shariff' ) . '
' . esc_html__( 'Changes the title to share. Only for special use cases.', 'shariff' ) . '
';
echo '
';
// Timestamp.
echo '
';
echo '
timestamp
';
echo '';
echo '
' . esc_html__( 'The timestamp of the last modification of the current post or page.', 'shariff' ) . '
';
echo '
[shariff timestamp="1473240010"]
';
echo '
' . esc_html__( 'Provides the time the current post or page was last modified as a timestamp. Used for determining the dynamic cache lifespan. Only for special use cases.', 'shariff' ) . '
' . esc_html__( 'Changes the RSS feed url to another feed.', 'shariff' ) . '
';
echo '
';
echo '
';
}
/**
* Status section.
*/
function shariff3uu_status_section_callback() {
// Get options.
$shariff3uu = $GLOBALS['shariff3uu'];
// Begin status table.
echo '
';
// Begin statistic row.
echo '
';
echo '
' . esc_html__( 'Statistic:', 'shariff' ) . '
';
// Check if statistic is enabled.
if ( ! isset( $shariff3uu['backend'] ) ) {
// Statistic disabled message.
echo '
';
echo '
' . esc_html__( 'Disabled', 'shariff' ) . '
';
echo '
';
// End statistic row, if statistic is disabled.
echo '
';
} else {
// Encode shareurl.
$post_url = rawurlencode( esc_url( get_bloginfo( 'url' ) ) );
$post_url_raw = esc_url( get_bloginfo( 'url' ) );
// We only need the backend part.
$backend = 1;
// But we also want error messages.
$record_errors = 1;
// Avoid debug messages.
$service_errors = array();
// Loop through all desired services.
foreach ( $GLOBALS['shariff3uu_services_backend'] as $service ) {
// Include service parameters.
if ( ! isset( $shariff3uu['disable'][ $service ] ) || ( isset( $shariff3uu['disable'][ $service ] ) && 0 === $shariff3uu['disable'][ $service ] ) ) {
include plugin_dir_path( __FILE__ ) . '../services/shariff-' . $service . '.php';
}
}
// General statistic status.
echo '
' . esc_html__( 'Facebook shut down the possibility to request share counts without an APP ID and Secret. Therefore, you need to create a Facebook APP ID and Secret and enter it in the settings on the Statistic tab. Google will provide you with many tutorials. Simple search for “facebook app id secret” and you will find one in your language.', 'shariff' ) . '
' . esc_html__( 'The GD Library is not installed on this server. This is only needed for the QR codes, if your are using the bitcoin button.', 'shariff' ) . '
';
echo '
';
echo '
';
}
echo '
';
// End status table.
echo '';
}
/**
* Ranking section.
*/
function shariff3uu_ranking_section_callback() {
// Post and service array.
$posts = array();
$services = array();
// Amount of posts - set to 100 if not set.
if ( isset( $GLOBALS['shariff3uu']['ranking'] ) && absint( $GLOBALS['shariff3uu']['ranking'] ) > '0' ) {
$numberposts = absint( $GLOBALS['shariff3uu']['ranking'] );
} else {
$numberposts = '100';
}
// Set arguments for wp_get_recent_posts().
$args = array(
'numberposts' => $numberposts,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
);
// Catch last 100 posts or whatever number is set for it.
$recent_posts = wp_get_recent_posts( $args );
if ( $recent_posts ) {
foreach ( $recent_posts as $recent ) {
// Get URL.
$url = get_permalink( $recent['ID'] );
$post_url = rawurlencode( $url );
// Set transient name.
$post_hash = 'shariff' . hash( 'md5', $post_url );
// Get share counts from cache.
if ( get_transient( $post_hash ) !== false ) {
$share_counts = get_transient( $post_hash );
$services = array_merge( $services, $share_counts );
if ( isset( $share_counts['total'] ) ) {
$total = $share_counts['total'];
} else {
$total = '0';
}
} else {
$share_counts = array();
$total = '';
}
// Add to array.
$posts[ $post_hash ] = array(
'url' => $url,
'title' => $recent['post_title'],
'post_date' => $recent['post_date'],
'share_counts' => $share_counts,
'total_share_counts' => $total,
);
}
}
// Clean up services.
unset( $services['total'] );
unset( $services['timestamp'] );
unset( $services['url'] );
ksort( $services );
// Sort array: first descending using total share counts then descending using post date.
$tmp = array();
$tmp2 = array();
foreach ( $posts as &$ma ) {
$tmp[] = &$ma['total_share_counts'];
}
foreach ( $posts as &$ma2 ) {
$tmp2[] = &$ma2['post_date'];
}
array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
// Intro text.
echo '
';
echo esc_html__( 'The following tables shows the ranking of your last 100 posts, pages and, if applicable, products in descending order by total share counts. To prevent slow loading times only cached data is being used. Therefore, you may see blank entries for posts that have not been visited by anyone since the last update or activation of Shariff Wrapper. You can simply visit the respective post yourself in order to have the share counts fetched.', 'shariff' );
echo '
';
// Warning if statistic has been disabled.
if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
echo '
';
echo '';
echo esc_html__( 'Warning:', 'shariff' );
echo ' ';
echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
echo '
';
// Clear arrays.
$posts = array();
$services = array();
// Set arguments for wp_get_recent_posts().
$args = array(
'numberposts' => $numberposts,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
'post_type' => 'page',
);
// Catch last 100 pages or whatever number is set for it.
$recent_posts = wp_get_recent_posts( $args );
if ( $recent_posts ) {
foreach ( $recent_posts as $recent ) {
// Get URL.
$url = get_permalink( $recent['ID'] );
$post_url = rawurlencode( $url );
// Set transient name.
$post_hash = 'shariff' . hash( 'md5', $post_url );
// Get share counts from cache.
if ( get_transient( $post_hash ) !== false ) {
$share_counts = get_transient( $post_hash );
$services = array_merge( $services, $share_counts );
if ( isset( $share_counts['total'] ) ) {
$total = $share_counts['total'];
} else {
$total = '0';
}
} else {
$share_counts = array();
$total = '';
}
// Add to array.
$posts[ $post_hash ] = array(
'url' => $url,
'title' => $recent['post_title'],
'post_date' => $recent['post_date'],
'share_counts' => $share_counts,
'total_share_counts' => $total,
);
}
}
// Clean up services.
unset( $services['total'] );
unset( $services['timestamp'] );
unset( $services['url'] );
ksort( $services );
// Sort array: first descending using total share counts then descending using post date.
$tmp = array();
$tmp2 = array();
foreach ( $posts as &$ma ) {
$tmp[] = &$ma['total_share_counts'];
}
foreach ( $posts as &$ma2 ) {
$tmp2[] = &$ma2['post_date'];
}
array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
echo '';
// Warning if statistic has been disabled.
if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
echo '
';
echo '';
echo esc_html__( 'Warning:', 'shariff' );
echo ' ';
echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
echo '
';
// Clear arrays.
$posts = array();
$services = array();
// Set arguments for wp_get_recent_posts().
$args = array(
'numberposts' => $numberposts,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
'post_type' => 'product',
);
// Catch last 100 pages or whatever number is set for it.
$recent_posts = wp_get_recent_posts( $args );
if ( $recent_posts ) {
foreach ( $recent_posts as $recent ) {
// Get URL.
$url = get_permalink( $recent['ID'] );
$post_url = rawurlencode( $url );
// Set transient name.
$post_hash = 'shariff' . hash( 'md5', $post_url );
// Get share counts from cache.
if ( get_transient( $post_hash ) !== false ) {
$share_counts = get_transient( $post_hash );
$services = array_merge( $services, $share_counts );
if ( isset( $share_counts['total'] ) ) {
$total = $share_counts['total'];
} else {
$total = '0';
}
} else {
$share_counts = array();
$total = '';
}
// Add to array.
$posts[ $post_hash ] = array(
'url' => $url,
'title' => $recent['post_title'],
'post_date' => $recent['post_date'],
'share_counts' => $share_counts,
'total_share_counts' => $total,
);
}
}
// Clean up services.
unset( $services['total'] );
unset( $services['timestamp'] );
unset( $services['url'] );
ksort( $services );
// Sort array: first descending using total share counts then descending using post date.
$tmp = array();
$tmp2 = array();
foreach ( $posts as &$ma ) {
$tmp[] = &$ma['total_share_counts'];
}
foreach ( $posts as &$ma2 ) {
$tmp2[] = &$ma2['post_date'];
}
array_multisort( $tmp, SORT_DESC, $tmp2, SORT_DESC, $posts );
echo '';
// Warning if statistic has been disabled.
if ( ! isset( $GLOBALS['shariff3uu']['backend'] ) ) {
echo '
';
echo '';
echo esc_html__( 'Warning:', 'shariff' );
echo ' ';
echo esc_html__( 'The statistic option has been disabled on the statistic tab. Share counts will not get updated!', 'shariff' );
echo '
';
}
if ( ! empty( $services ) ) {
// Begin ranking table.
echo '