__( 'Choose image', 'shariff' ), ); wp_localize_script( 'shariff_mediaupload', 'shariff_media', $translation_array ); wp_enqueue_script( 'shariff_mediaupload' ); } } add_action( 'admin_enqueue_scripts', 'shariff3uu_admin_style' ); /** * Adds the admin menu. */ function shariff3uu_add_admin_menu() { add_options_page( 'Shariff', 'Shariff', 'manage_options', 'shariff3uu', 'shariff3uu_options_page' ); } /** * Creates the plugin options page. */ function shariff3uu_options_init() { /** First tab - basic */ // Registers first tab (basic) settings and calls sanitize function. register_setting( 'shariff3uu_basic', 'shariff3uu_basic', 'shariff3uu_basic_sanitize' ); // First tab - basic options. add_settings_section( 'shariff3uu_basic_section', __( 'Basic options', 'shariff' ), 'shariff3uu_basic_section_callback', 'shariff3uu_basic' ); // Services. add_settings_field( 'shariff3uu_text_services', '
' . __( 'Enable the following services in the provided order:', 'shariff' ) . '
', 'shariff3uu_text_services_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); // Add after. add_settings_field( 'shariff3uu_multiplecheckbox_add_after', __( 'Add the Shariff buttons after all:', 'shariff' ), 'shariff3uu_multiplecheckbox_add_after_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); // Add before. add_settings_field( 'shariff3uu_checkbox_add_before', __( 'Add the Shariff buttons before all:', 'shariff' ), 'shariff3uu_multiplecheckbox_add_before_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); // Disable on protected posts. add_settings_field( 'shariff3uu_checkbox_disable_on_protected', __( 'Disable the Shariff buttons on password protected posts.', 'shariff' ), 'shariff3uu_checkbox_disable_on_protected_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); // Disable outside of loop. add_settings_field( 'shariff3uu_checkbox_disable_outside_loop', __( 'Disable the Shariff buttons outside of the main loop.', 'shariff' ), 'shariff3uu_checkbox_disable_outside_loop_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); // Add to custom WordPress hooks. add_settings_field( 'shariff3uu_text_custom_hooks', __( 'Add Shariff to the following custom WordPress hooks:', 'shariff' ), 'shariff3uu_text_custom_hooks_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); // Shortcode to use for custom hook. add_settings_field( 'shariff3uu_text_custom_hooks_shortcode', __( 'Use the following shortcode for the custom hooks:', 'shariff' ), 'shariff3uu_text_custom_hooks_shortcode_render', 'shariff3uu_basic', 'shariff3uu_basic_section' ); /** Second tab - design */ // Registers second tab (design) settings and calls sanitize function. register_setting( 'shariff3uu_design', 'shariff3uu_design', 'shariff3uu_design_sanitize' ); // Second tab - design options. add_settings_section( 'shariff3uu_design_section', __( 'Design options', 'shariff' ), 'shariff3uu_design_section_callback', 'shariff3uu_design' ); // Button language. add_settings_field( 'shariff3uu_select_language', '
' . esc_html__( 'Default button language:', 'shariff' ) . '
', 'shariff3uu_select_language_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Automatic button language for multilingual sites. add_settings_field( 'shariff3uu_checkbox_autolang', __( 'Automatically set button language based on locale (e.g. set by WPML).', 'shariff' ), 'shariff3uu_checkbox_autolang_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Theme. add_settings_field( 'shariff3uu_radio_theme', __( 'Shariff button design:', 'shariff' ), 'shariff3uu_radio_theme_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Button size. add_settings_field( 'shariff3uu_checkbox_buttonsize', __( 'Button size:', 'shariff' ), 'shariff3uu_checkbox_buttonsize_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Button stretch. add_settings_field( 'shariff3uu_checkbox_buttonsstretch', __( 'Stretch buttons horizontally to full width.', 'shariff' ), 'shariff3uu_checkbox_buttonstretch_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Border radius. add_settings_field( 'shariff3uu_number_borderradius', __( 'Border radius for the round theme (1-50):', 'shariff' ), 'shariff3uu_number_borderradius_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Custom main color. add_settings_field( 'shariff3uu_text_maincolor', __( 'Custom main color for all buttons (hexadecimal):', 'shariff' ), 'shariff3uu_text_maincolor_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Custom secondary color. add_settings_field( 'shariff3uu_text_secondarycolor', __( 'Custom secondary color for all buttons (hexadecimal):', 'shariff' ), 'shariff3uu_text_secondarycolor_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Vertical. add_settings_field( 'shariff3uu_checkbox_vertical', __( 'Shariff button orientation vertical.', 'shariff' ), 'shariff3uu_checkbox_vertical_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Alignment option. add_settings_field( 'shariff3uu_radio_align', __( 'Alignment of the Shariff buttons:', 'shariff' ), 'shariff3uu_radio_align_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Alignment option for the widget. add_settings_field( 'shariff3uu_radio_align_widget', __( 'Alignment of the Shariff buttons in the widget:', 'shariff' ), 'shariff3uu_radio_align_widget_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Headline. add_settings_field( 'shariff3uu_text_headline', __( 'Headline above all Shariff buttons:', 'shariff' ), 'shariff3uu_text_headline_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Alternative headline if share counts are zero. add_settings_field( 'shariff3uu_text_headline_zero', __( 'Alternative headline, if share counts are zero:', 'shariff' ), 'shariff3uu_text_headline_zero_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Custom css. add_settings_field( 'shariff3uu_text_style', __( 'Custom CSS attributes for the container around Shariff:', 'shariff' ), 'shariff3uu_text_style_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Custom css class. add_settings_field( 'shariff3uu_text_cssclass', __( 'Custom CSS class for the container around Shariff:', 'shariff' ), 'shariff3uu_text_cssclass_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Hide until css loaded. add_settings_field( 'shariff3uu_checkbox_hideuntilcss', __( 'Hide buttons until page is fully loaded.', 'shariff' ), 'shariff3uu_checkbox_hideuntilcss_render', 'shariff3uu_design', 'shariff3uu_design_section' ); // Open in popup. add_settings_field( 'shariff3uu_checkbox_popup', __( 'Open links in a popup (requires JavaScript).', 'shariff' ), 'shariff3uu_checkbox_popup_render', 'shariff3uu_design', 'shariff3uu_design_section' ); /** Third tab - advanced */ // Registers third tab (advanced) settings and calls sanitize function. register_setting( 'shariff3uu_advanced', 'shariff3uu_advanced', 'shariff3uu_advanced_sanitize' ); // Third tab - advanced options. add_settings_section( 'shariff3uu_advanced_section', __( 'Advanced options', 'shariff' ), 'shariff3uu_advanced_section_callback', 'shariff3uu_advanced' ); // Info url. add_settings_field( 'shariff3uu_text_info_url', '
' . __( 'Custom link for the info button:', 'shariff' ) . '
', 'shariff3uu_text_info_url_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Info text. add_settings_field( 'shariff3uu_text_info_text', __( 'Custom text for the info button:', 'shariff' ), 'shariff3uu_text_info_text_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Twitter via. add_settings_field( 'shariff3uu_text_twittervia', __( 'Twitter username for the via tag:', 'shariff' ), 'shariff3uu_text_twittervia_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Patreon username. add_settings_field( 'shariff3uu_text_patreonid', __( 'Patreon username:', 'shariff' ), 'shariff3uu_text_patreonid_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Paypal button id. add_settings_field( 'shariff3uu_text_paypalbuttonid', __( 'PayPal hosted button ID:', 'shariff' ), 'shariff3uu_text_paypalbuttonid_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Paypalme id. add_settings_field( 'shariff3uu_text_paypalmeid', __( 'PayPal.Me ID:', 'shariff' ), 'shariff3uu_text_paypalmeid_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Bitcoin address. add_settings_field( 'shariff3uu_text_bitcoinaddress', __( 'Bitcoin address:', 'shariff' ), 'shariff3uu_text_bitcoinaddress_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // RSS feed. add_settings_field( 'shariff3uu_text_rssfeed', __( 'RSS feed:', 'shariff' ), 'shariff3uu_text_rssfeed_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Default image for pinterest. add_settings_field( 'shariff3uu_text_default_pinterest', __( 'Default image for Pinterest:', 'shariff' ), 'shariff3uu_text_default_pinterest_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Hide WhatsApp. add_settings_field( 'shariff3uu_checkbox_hide_whatsapp', __( 'Hide WhatsApp on desktop devices.', 'shariff' ), 'shariff3uu_checkbox_hide_whatsapp_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Shortcode priority. add_settings_field( 'shariff3uu_number_shortcodeprio', __( 'Shortcode priority:', 'shariff' ), 'shariff3uu_number_shortcodeprio_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); // Disable metabox. add_settings_field( 'shariff3uu_checkbox_disable_metabox', __( 'Disable the metabox.', 'shariff' ), 'shariff3uu_checkbox_disable_metabox_render', 'shariff3uu_advanced', 'shariff3uu_advanced_section' ); /** Fifth tab - statistic */ // Registers fifth tab (statistic) settings and calls sanitize function. register_setting( 'shariff3uu_statistic', 'shariff3uu_statistic', 'shariff3uu_statistic_sanitize' ); // Fifth tab (statistic). add_settings_section( 'shariff3uu_statistic_section', __( 'Statistic', 'shariff' ), 'shariff3uu_statistic_section_callback', 'shariff3uu_statistic' ); // Statistic. add_settings_field( 'shariff3uu_checkbox_backend', '
' . __( 'Enable statistic.', 'shariff' ) . '
', 'shariff3uu_checkbox_backend_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Share counts. add_settings_field( 'shariff3uu_checkbox_sharecounts', __( 'Show share counts on buttons.', 'shariff' ), 'shariff3uu_checkbox_sharecounts_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Hide when zero. add_settings_field( 'shariff3uu_checkbox_hidezero', __( 'Hide share counts when they are zero.', 'shariff' ), 'shariff3uu_checkbox_hidezero_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Facebook App ID. add_settings_field( 'shariff3uu_text_fb_id', __( 'Facebook App ID:', 'shariff' ), 'shariff3uu_text_fb_id_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Facebook App Secret. add_settings_field( 'shariff3uu_text_fb_secret', __( 'Facebook App Secret:', 'shariff' ), 'shariff3uu_text_fb_secret_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Automatic cache. add_settings_field( 'shariff3uu_checkbox_automaticcache', __( 'Fill cache automatically.', 'shariff' ), 'shariff3uu_checkbox_automaticcache_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Ranking. add_settings_field( 'shariff3uu_number_ranking', __( 'Number of posts on ranking tab:', 'shariff' ), 'shariff3uu_number_ranking_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // TTL. add_settings_field( 'shariff3uu_number_ttl', __( 'Cache TTL in seconds (60 - 7200):', 'shariff' ), 'shariff3uu_number_ttl_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Disable dynamic cache lifespan. add_settings_field( 'shariff3uu_checkbox_disable_dynamic_cache', __( 'Disable the dynamic cache lifespan (not recommended).', 'shariff' ), 'shariff3uu_checkbox_disable_dynamic_cache_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Disable services. add_settings_field( 'shariff3uu_multiplecheckbox_disable_services', __( 'Disable the following services (share counts only):', 'shariff' ), 'shariff3uu_multiplecheckbox_disable_services_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // External hosts. add_settings_field( 'shariff3uu_text_external_host', __( 'External API for share counts:', 'shariff' ), 'shariff3uu_text_external_host_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // Request external api directly from js. add_settings_field( 'shariff3uu_checkbox_external_direct', __( 'Request external API directly.', 'shariff' ), 'shariff3uu_checkbox_external_direct_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); // WP in sub folder and api only reachable there? add_settings_field( 'shariff3uu_checkbox_subapi', __( 'Local API not reachable in root.', 'shariff' ), 'shariff3uu_checkbox_subapi_render', 'shariff3uu_statistic', 'shariff3uu_statistic_section' ); /** Sixth tab - help */ // Register sixth tab (help). add_settings_section( 'shariff3uu_help_section', __( 'Shariff Help', 'shariff' ), 'shariff3uu_help_section_callback', 'shariff3uu_help' ); /** Seventh tab - status */ // Register seventh tab (status). add_settings_section( 'shariff3uu_status_section', __( 'Status', 'shariff' ), 'shariff3uu_status_section_callback', 'shariff3uu_status' ); /** Eight tab - ranking */ // Register eight tab (ranking). add_settings_section( 'shariff3uu_ranking_section', __( 'Ranking', 'shariff' ), 'shariff3uu_ranking_section_callback', 'shariff3uu_ranking' ); } /** * Sanitizes input from the basic settings page. * * @param array $input Input from settings page to sanitize. * * @return array Sanitized array with settings. */ function shariff3uu_basic_sanitize( $input ) { // Create array. $valid = array(); if ( isset( $input['version'] ) ) { $valid['version'] = sanitize_text_field( $input['version'] ); } if ( isset( $input['services'] ) ) { $valid['services'] = trim( preg_replace( '/[^A-Za-z|]/', '', sanitize_text_field( $input['services'] ) ), '|' ); } if ( isset( $input['add_after'] ) ) { $valid['add_after'] = sani_arrays( $input['add_after'] ); } if ( isset( $input['add_before'] ) ) { $valid['add_before'] = sani_arrays( $input['add_before'] ); } if ( isset( $input['disable_on_protected'] ) ) { $valid['disable_on_protected'] = absint( $input['disable_on_protected'] ); } if ( isset( $input['disable_outside_loop'] ) ) { $valid['disable_outside_loop'] = absint( $input['disable_outside_loop'] ); } if ( isset( $input['custom_hooks'] ) ) { $valid['custom_hooks'] = sanitize_text_field( $input['custom_hooks'] ); } if ( isset( $input['custom_hooks_shortcode'] ) ) { $valid['custom_hooks_shortcode'] = sanitize_text_field( $input['custom_hooks_shortcode'] ); } // Remove empty elements. $valid = array_filter( $valid ); return $valid; } /** * Sanitizes input from the design settings page. * * @param array $input Input from settings page to sanitize. * * @return array Sanitized array with settings. */ function shariff3uu_design_sanitize( $input ) { // Create array. $valid = array(); if ( isset( $input['lang'] ) ) { $valid['lang'] = sanitize_text_field( $input['lang'] ); } if ( isset( $input['autolang'] ) ) { $valid['autolang'] = absint( $input['autolang'] ); } if ( isset( $input['theme'] ) ) { $valid['theme'] = sanitize_text_field( $input['theme'] ); } if ( isset( $input['buttonsize'] ) ) { $valid['buttonsize'] = sanitize_text_field( $input['buttonsize'] ); } if ( isset( $input['buttonstretch'] ) ) { $valid['buttonstretch'] = absint( $input['buttonstretch'] ); } if ( isset( $input['borderradius'] ) ) { $valid['borderradius'] = absint( $input['borderradius'] ); } if ( isset( $input['maincolor'] ) ) { $valid['maincolor'] = sanitize_text_field( $input['maincolor'] ); } if ( isset( $input['secondarycolor'] ) ) { $valid['secondarycolor'] = sanitize_text_field( $input['secondarycolor'] ); } if ( isset( $input['vertical'] ) ) { $valid['vertical'] = absint( $input['vertical'] ); } if ( isset( $input['align'] ) ) { $valid['align'] = sanitize_text_field( $input['align'] ); } if ( isset( $input['align_widget'] ) ) { $valid['align_widget'] = sanitize_text_field( $input['align_widget'] ); } if ( isset( $input['style'] ) ) { $valid['style'] = sanitize_text_field( $input['style'] ); } if ( isset( $input['cssclass'] ) ) { $valid['cssclass'] = sanitize_text_field( $input['cssclass'] ); } if ( isset( $input['headline'] ) ) { $valid['headline'] = wp_kses( $input['headline'], $GLOBALS['allowed_tags'] ); } if ( isset( $input['headline_zero'] ) ) { $valid['headline_zero'] = wp_kses( $input['headline_zero'], $GLOBALS['allowed_tags'] ); } if ( isset( $input['hideuntilcss'] ) ) { $valid['hideuntilcss'] = absint( $input['hideuntilcss'] ); } if ( isset( $input['popup'] ) ) { $valid['popup'] = absint( $input['popup'] ); } // Remove empty elements. $valid = array_filter( $valid ); return $valid; } /** * Sanitize input from the advanced settings page. * * @param array $input Input from settings page to sanitize. * * @return array Sanitized array with settings. */ function shariff3uu_advanced_sanitize( $input ) { // Creates array. $valid = array(); if ( isset( $input['info_url'] ) ) { $valid['info_url'] = esc_url_raw( $input['info_url'] ); } if ( isset( $input['info_text'] ) ) { $valid['info_text'] = sanitize_text_field( $input['info_text'] ); } if ( isset( $input['twitter_via'] ) ) { $valid['twitter_via'] = str_replace( '@', '', sanitize_text_field( $input['twitter_via'] ) ); } if ( isset( $input['flattruser'] ) ) { $valid['flattruser'] = sanitize_text_field( $input['flattruser'] ); } if ( isset( $input['patreonid'] ) ) { $valid['patreonid'] = sanitize_text_field( $input['patreonid'] ); } if ( isset( $input['paypalbuttonid'] ) ) { $valid['paypalbuttonid'] = sanitize_text_field( $input['paypalbuttonid'] ); } if ( isset( $input['paypalmeid'] ) ) { $valid['paypalmeid'] = sanitize_text_field( $input['paypalmeid'] ); } if ( isset( $input['bitcoinaddress'] ) ) { $valid['bitcoinaddress'] = sanitize_text_field( $input['bitcoinaddress'] ); } if ( isset( $input['rssfeed'] ) ) { $valid['rssfeed'] = sanitize_text_field( $input['rssfeed'] ); } if ( isset( $input['default_pinterest'] ) ) { $valid['default_pinterest'] = sanitize_text_field( $input['default_pinterest'] ); } if ( isset( $input['hide_whatsapp'] ) ) { $valid['hide_whatsapp'] = absint( $input['hide_whatsapp'] ); } if ( isset( $input['shortcodeprio'] ) ) { $valid['shortcodeprio'] = absint( $input['shortcodeprio'] ); } if ( isset( $input['disable_metabox'] ) ) { $valid['disable_metabox'] = absint( $input['disable_metabox'] ); } // Remove empty elements. $valid = array_filter( $valid ); return $valid; } /** * Sanitizes input from the statistic settings page. * * @param array $input Input from settings page to sanitize. * * @return array Sanitized array with settings. */ function shariff3uu_statistic_sanitize( $input ) { // Creates array. $valid = array(); if ( isset( $input['backend'] ) ) { $valid['backend'] = absint( $input['backend'] ); } if ( isset( $input['sharecounts'] ) ) { $valid['sharecounts'] = absint( $input['sharecounts'] ); } if ( isset( $input['hidezero'] ) ) { $valid['hidezero'] = absint( $input['hidezero'] ); } if ( isset( $input['ranking'] ) ) { $valid['ranking'] = absint( $input['ranking'] ); } if ( isset( $input['automaticcache'] ) ) { $valid['automaticcache'] = absint( $input['automaticcache'] ); } if ( isset( $input['fb_id'] ) ) { $valid['fb_id'] = sanitize_text_field( $input['fb_id'] ); } if ( isset( $input['fb_secret'] ) ) { $valid['fb_secret'] = sanitize_text_field( $input['fb_secret'] ); } if ( isset( $input['ttl'] ) ) { $valid['ttl'] = absint( $input['ttl'] ); } if ( isset( $input['disable_dynamic_cache'] ) ) { $valid['disable_dynamic_cache'] = absint( $input['disable_dynamic_cache'] ); } if ( isset( $input['disable'] ) ) { $valid['disable'] = sani_arrays( $input['disable'] ); } if ( isset( $input['external_host'] ) ) { $valid['external_host'] = str_replace( ' ', '', rtrim( esc_url_raw( $input['external_host'], '/' ) ) ); } if ( isset( $input['external_direct'] ) ) { $valid['external_direct'] = absint( $input['external_direct'] ); } if ( isset( $input['subapi'] ) ) { $valid['subapi'] = absint( $input['subapi'] ); } // Protect users from themselves. if ( isset( $valid['ttl'] ) && $valid['ttl'] < '60' ) { $valid['ttl'] = ''; } elseif ( isset( $valid['ttl'] ) && $valid['ttl'] > '7200' ) { $valid['ttl'] = '7200'; } // Remove empty elements. $valid = array_filter( $valid ); return $valid; } /** * Helper function to sanitize arrays. * * @param array $data Input array. * * @return array Sanitized array. */ function sani_arrays( $data = array() ) { if ( ! is_array( $data ) || ! count( $data ) ) { return array(); } foreach ( $data as $k => $v ) { if ( ! is_array( $v ) && ! is_object( $v ) ) { $data[ $k ] = absint( trim( $v ) ); } if ( is_array( $v ) ) { $data[ $k ] = sani_arrays( $v ); } } return $data; } /** Render admin options: use isset() to prevent errors while debug mode is on. */ /** Basic options */ /** * Description of basic options. */ function shariff3uu_basic_section_callback() { esc_html_e( 'Select the desired services in the order you want them to be displayed and where the Shariff buttons should be included automatically.', 'shariff' ); } /** * Services. */ function shariff3uu_text_services_render() { if ( isset( $GLOBALS['shariff3uu_basic']['services'] ) ) { $services = $GLOBALS['shariff3uu_basic']['services']; } else { $services = ''; } echo ''; echo '

addthis|bitcoin|buffer|diaspora|facebook|flattr|flipboard|info|linkedin|mailto|mewe|mix

'; echo '

odnoklassniki|patreon|paypal|paypalme|pinterest|pocket|printer|qzone|reddit|rss|sms

'; echo '

telegram|tencentweibo|threema|tumblr|twitter|vk|wallabag|weibo|whatsapp|xing

'; echo '

' . esc_html__( 'Use the pipe sign | (Alt Gr + < or ⌥ + 7) between two or more services.', 'shariff' ) . '

'; } /** * Add after. */ function shariff3uu_multiplecheckbox_add_after_render() { // Add after all posts. echo '

' . esc_html__( 'Posts', 'shariff' ) . '

'; // Add after all posts (blog page). echo '

' . esc_html__( 'Posts (blog page)', 'shariff' ) . '

'; // Add after all pages. echo '

' . esc_html__( 'Pages', 'shariff' ) . '

'; // Add after all excerpts. echo '

' . esc_html__( 'Excerpts', 'shariff' ) . '

'; // Add after custom post types - choose after which to add. $post_types = get_post_types( array( '_builtin' => false ) ); if ( isset( $post_types ) && is_array( $post_types ) && ! empty( $post_types ) ) { echo '

Custom Post Types:

'; }; foreach ( $post_types as $post_type ) { $object = get_post_type_object( $post_type ); printf( '

%s

', $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 '

' . esc_html__( 'Posts', 'shariff' ) . '

'; // Add before all posts (blog page). echo '

' . esc_html__( 'Posts (blog page)', 'shariff' ) . '

'; // Add before all pages. echo '

' . esc_html__( 'Pages', 'shariff' ) . '

'; // Add before all excerpts. echo '

' . esc_html__( 'Excerpts', 'shariff' ) . '

'; // Add before custom post types - choose before which to add. $post_types = get_post_types( array( '_builtin' => false ) ); if ( isset( $post_types ) && is_array( $post_types ) && ! empty( $post_types ) ) { echo '

Custom Post Types:

'; }; foreach ( $post_types as $post_type ) { $object = get_post_type_object( $post_type ); printf( '

%s

', $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 '
default
color
grey
white
round
wcag
Shariff Designs
'; } /** * Button size. */ function shariff3uu_checkbox_buttonsize_render() { $options = $GLOBALS['shariff3uu_design']; if ( ! isset( $options['buttonsize'] ) ) { $options['buttonsize'] = 'medium'; } echo '

' . esc_html__( 'small', 'shariff' ) . '

'; echo '

' . esc_html__( 'medium', 'shariff' ) . '

'; echo '

' . esc_html__( 'large', 'shariff' ) . '

'; } /** * Button stretch. */ function shariff3uu_checkbox_buttonstretch_render() { echo ''; } /** * Border radius. */ function shariff3uu_number_borderradius_render() { $plugins_url = plugins_url(); if ( isset( $GLOBALS['shariff3uu_design']['borderradius'] ) ) { $borderradius = $GLOBALS['shariff3uu_design']['borderradius']; } else { $borderradius = ''; } echo ''; echo ''; } /** * Custom main color. */ function shariff3uu_text_maincolor_render() { if ( isset( $GLOBALS['shariff3uu_design']['maincolor'] ) ) { $maincolor = $GLOBALS['shariff3uu_design']['maincolor']; } else { $maincolor = ''; } echo ''; } /** * Custom secondary color. */ function shariff3uu_text_secondarycolor_render() { if ( isset( $GLOBALS['shariff3uu_design']['secondarycolor'] ) ) { $secondarycolor = $GLOBALS['shariff3uu_design']['secondarycolor']; } else { $secondarycolor = ''; } echo ''; } /** * Vertical. */ function shariff3uu_checkbox_vertical_render() { $plugins_url = plugins_url(); echo ''; } /** * Alignment. */ function shariff3uu_radio_align_render() { $options = $GLOBALS['shariff3uu_design']; if ( ! isset( $options['align'] ) ) { $options['align'] = 'flex-start'; } echo '

' . esc_html__( 'left', 'shariff' ) . '

'; echo '

' . esc_html__( 'center', 'shariff' ) . '

'; echo '

' . esc_html__( 'right', 'shariff' ) . '

'; } /** * Alignment widget. */ function shariff3uu_radio_align_widget_render() { $options = $GLOBALS['shariff3uu_design']; if ( ! isset( $options['align_widget'] ) ) { $options['align_widget'] = 'flex-start'; } echo '

' . esc_html__( 'left', 'shariff' ) . '

'; echo '

' . esc_html__( 'center', 'shariff' ) . '

'; echo '

' . esc_html__( 'right', 'shariff' ) . '

'; } /** * Headline. */ function shariff3uu_text_headline_render() { if ( isset( $GLOBALS['shariff3uu_design']['headline'] ) ) { $headline = $GLOBALS['shariff3uu_design']['headline']; } else { $headline = ''; } echo ''; 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>

'; } /** * Alternative headline. */ function shariff3uu_text_headline_zero_render() { if ( isset( $GLOBALS['shariff3uu_design']['headline_zero'] ) ) { $headline_zero = $GLOBALS['shariff3uu_design']['headline_zero']; } else { $headline_zero = ''; } echo ''; echo '

'; echo esc_html__( 'Same rules as for the default headline. Leave empty to keep the same headline in all cases.', 'shariff' ); echo '

'; } /** * Custom CSS. */ function shariff3uu_text_style_render() { if ( isset( $GLOBALS['shariff3uu_design']['style'] ) ) { $style = $GLOBALS['shariff3uu_design']['style']; } else { $style = ''; } echo ''; } /** * Custom CSS class. */ function shariff3uu_text_cssclass_render() { if ( isset( $GLOBALS['shariff3uu_design']['cssclass'] ) ) { $cssclass = $GLOBALS['shariff3uu_design']['cssclass']; } else { $cssclass = ''; } echo ''; } /** * Hide buttons until page is fully loaded. */ function shariff3uu_checkbox_hideuntilcss_render() { echo ''; } /** * Open links in a popup. */ function shariff3uu_checkbox_popup_render() { echo ''; } /** Advanced options */ /** * Description of the advanced options. */ function shariff3uu_advanced_section_callback() { esc_html_e( 'This configures the advanced options of Shariff regarding specific services. ', '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/' ); } /** * Info URL. */ function shariff3uu_text_info_url_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['info_url'] ) ) { $info_url = $GLOBALS['shariff3uu_advanced']['info_url']; } else { $info_url = ''; } echo ''; } /** * Info Text. */ function shariff3uu_text_info_text_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['info_text'] ) ) { $info_text = $GLOBALS['shariff3uu_advanced']['info_text']; } else { $info_text = ''; } echo ''; } /** * Twitter via attribute. */ function shariff3uu_text_twittervia_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['twitter_via'] ) ) { $twitter_via = $GLOBALS['shariff3uu_advanced']['twitter_via']; } else { $twitter_via = ''; } echo ''; } /** * Patreon username. */ function shariff3uu_text_patreonid_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['patreonid'] ) ) { $patreonid = $GLOBALS['shariff3uu_advanced']['patreonid']; } else { $patreonid = ''; } echo ''; } /** * PayPal Button ID. */ function shariff3uu_text_paypalbuttonid_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['paypalbuttonid'] ) ) { $paypalbuttonid = $GLOBALS['shariff3uu_advanced']['paypalbuttonid']; } else { $paypalbuttonid = ''; } echo ''; } /** * PayPal.Me ID. */ function shariff3uu_text_paypalmeid_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['paypalmeid'] ) ) { $paypalmeid = $GLOBALS['shariff3uu_advanced']['paypalmeid']; } else { $paypalmeid = ''; } echo ''; } /** * Bitcoin address. */ function shariff3uu_text_bitcoinaddress_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['bitcoinaddress'] ) ) { $bitcoinaddress = $GLOBALS['shariff3uu_advanced']['bitcoinaddress']; } else { $bitcoinaddress = ''; } echo ''; } /** * RSS feed. */ function shariff3uu_text_rssfeed_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['rssfeed'] ) ) { $rssfeed = $GLOBALS['shariff3uu_advanced']['rssfeed']; } else { $rssfeed = ''; } $rssdefault = get_bloginfo( 'rss_url' ); echo ''; } /** * Pinterest Default Image. */ function shariff3uu_text_default_pinterest_render() { $options = $GLOBALS['shariff3uu_advanced']; if ( ! isset( $options['default_pinterest'] ) ) { $options['default_pinterest'] = ''; } echo '
'; } /** * Hide WhatsApp on Desktop. */ function shariff3uu_checkbox_hide_whatsapp_render() { echo ''; } /** * Shortcode Priority. */ function shariff3uu_number_shortcodeprio_render() { if ( isset( $GLOBALS['shariff3uu_advanced']['shortcodeprio'] ) ) { $prio = $GLOBALS['shariff3uu_advanced']['shortcodeprio']; } else { $prio = ''; } echo ''; echo '

' . esc_html__( 'Warning: DO NOT change this unless you know what you are doing or have been told so by the plugin author!', 'shariff' ) . '

'; } /** * Disable metabox. */ function shariff3uu_checkbox_disable_metabox_render() { echo ''; } /** Statistic section */ /** * Description statistic options. */ function shariff3uu_statistic_section_callback() { echo esc_html__( 'This determines how share counts are handled by Shariff.', 'shariff' ); echo '
'; echo esc_html__( 'Notice: Twitter does not offer official share counts anymore. As an alternative share counts for Twitter can be requested via twitcount.com. You will need to register with them for it to work. Otherwise the count will always be zero.', 'shariff' ); if ( isset( $GLOBALS['shariff3uu_statistic']['external_direct'] ) ) { echo '
'; echo esc_html__( 'Warning: ', 'shariff' ); echo ''; echo esc_html__( 'You entered an external API and chose to call it directly! Therefore, all options and features (e.g. the ranking tab) regarding the statistic have no effect. You need to configure them on the external server. Remember: This feature is still experimental!', 'shariff' ); } // Hook to add or remove cron job. do_action( 'shariff3uu_save_statistic_options' ); } /** * Enable Statistic. */ function shariff3uu_checkbox_backend_render() { // Check WP version. if ( version_compare( get_bloginfo( 'version' ), '4.4.0' ) < 1 ) { echo esc_html__( 'WordPress-Version 4.4 or better is required to enable the statistic / share count functionality.', 'shariff' ); } else { echo ''; } } /** * Share Counts On Buttons. */ function shariff3uu_checkbox_sharecounts_render() { echo ''; if ( ! isset( $GLOBALS['shariff3uu_statistic']['backend'] ) && isset( $GLOBALS['shariff3uu_statistic']['sharecounts'] ) ) { echo ' '; echo esc_html__( 'Warning: The statistic functionality must be enabled in order for the share counts to be shown.', 'shariff' ); } } /** * Hide when zero. */ function shariff3uu_checkbox_hidezero_render() { echo ''; } /** * Ranking. */ function shariff3uu_number_ranking_render() { if ( isset( $GLOBALS['shariff3uu_statistic']['ranking'] ) ) { $numberposts = $GLOBALS['shariff3uu_statistic']['ranking']; } else { $numberposts = ''; } echo ''; } /** * Automatic cache. */ function shariff3uu_checkbox_automaticcache_render() { echo ''; } /** * Facebook App ID. */ function shariff3uu_text_fb_id_render() { if ( isset( $GLOBALS['shariff3uu_statistic']['fb_id'] ) ) { $fb_id = $GLOBALS['shariff3uu_statistic']['fb_id']; } else { $fb_id = ''; } echo ''; } /** * Facebook App Secret. */ function shariff3uu_text_fb_secret_render() { if ( isset( $GLOBALS['shariff3uu_statistic']['fb_secret'] ) ) { $fb_secret = $GLOBALS['shariff3uu_statistic']['fb_secret']; } else { $fb_secret = ''; } echo ''; } /** * TTL. */ function shariff3uu_number_ttl_render() { if ( isset( $GLOBALS['shariff3uu_statistic']['ttl'] ) ) { $ttl = $GLOBALS['shariff3uu_statistic']['ttl']; } else { $ttl = ''; } echo ''; } /** * Disable dynamic cache lifespan. */ function shariff3uu_checkbox_disable_dynamic_cache_render() { echo ''; } /** * Disable services. */ function shariff3uu_multiplecheckbox_disable_services_render() { // Loop through all services with a backend. foreach ( $GLOBALS['shariff3uu_services_backend'] as $service ) { // Capitalize service name. $service_name = ucfirst( $service ); // Add option. echo '

' . esc_html( $service_name ) . '

'; } } /** * External host. */ function shariff3uu_text_external_host_render() { if ( isset( $GLOBALS['shariff3uu_statistic']['external_host'] ) ) { $external_host = $GLOBALS['shariff3uu_statistic']['external_host']; } else { $external_host = ''; } echo ''; echo '

' . 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 '

'; // Shortcode table. echo '
'; // Head. echo '
'; echo '
' . esc_html__( 'Name', 'shariff' ) . '
'; echo '
' . esc_html__( 'Options', 'shariff' ) . '
'; echo '
' . esc_html__( 'Default', 'shariff' ) . '
'; echo '
' . esc_html__( 'Example', 'shariff' ) . '
'; echo '
' . esc_html__( 'Description', 'shariff' ) . '
'; echo '
'; // Services. echo '
'; echo '
services
'; echo '
addthis
bitcoin
buffer
diaspora
facebook
flattr
flipboard
info
linkedin
mailto
mewe
mix
odnoklassniki
patreon
paypal
paypalme
pinterest
pocket
printer
qzone
reddit
rss
sms
telegram
tencentweibo
threema
tumblr
twitter
vk
wallabag
weibo
whatsapp
xing
'; echo '
twitter|facebook|linkedin|info
'; echo '
[shariff services="facebook|twitter|mailto"]
'; 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
'; echo '
' . esc_html__( 'Automatically selected by browser.', 'shariff' ) . '
'; echo '
[shariff lang="de"]
'; echo '
' . esc_html__( 'Changes the language of the share buttons.', 'shariff' ) . '
'; echo '
'; // Headline. echo '
'; echo '
headline
'; echo '
'; echo '
'; echo '
[shariff headline="<hr style=\'margin:20px 0\'><p>' . esc_html__( 'Please share this post', 'shariff' ) . '</p>"]
'; echo '
' . 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' ) . '
'; echo '
'; // Patreonid. echo '
'; echo '
patreonid
'; echo '
'; echo '
'; echo '
[shariff patreonid="your_username"]
'; echo '
' . esc_html__( 'Sets the Patreon username.', 'shariff' ) . '
'; echo '
'; // Paypalbuttonid. echo '
'; echo '
paypalbuttonid
'; echo '
'; echo '
'; echo '
[shariff paypalbuttonid="hosted_button_id"]
'; echo '
' . esc_html__( 'Sets the PayPal hosted button ID.', 'shariff' ) . '
'; echo '
'; // Paypalmeid. echo '
'; echo '
paypalmeid
'; echo '
'; echo '
'; echo '
[shariff paypalmeid="name"]
'; echo '
' . esc_html__( 'Sets the PayPal.Me ID. Default amount can be added with a / e.g. name/25.', 'shariff' ) . '
'; echo '
'; // Bitcoinaddress. echo '
'; echo '
bitcoinaddress
'; echo '
'; echo '
'; echo '
[shariff bitcoinaddress="bitcoin_address"]
'; echo '
' . esc_html__( 'Sets the bitcoin address.', 'shariff' ) . '
'; echo '
'; // Media. echo '
'; echo '
media
'; echo '
'; echo '
' . esc_html__( 'The post featured image or the first image of the post.', 'shariff' ) . '
'; echo '
[shariff media="http://www.mydomain.com/image.jpg"]
'; echo '
' . esc_html__( 'Determines the default image to share for Pinterest, if no other usable image is found.', 'shariff' ) . '
'; echo '
'; // Info_URL. echo '
'; echo '
info_url
'; echo '
'; echo '
http://ct.de/-2467514
'; echo '
[shariff info_url="http://www.mydomain.com/shariff-buttons"]
'; echo '
' . esc_html__( 'Sets a custom link for the info button.', 'shariff' ) . '
'; echo '
'; // Info_Text. echo '
'; echo '
info_text
'; echo '
'; echo '
' . esc_html__( 'More information about these buttons.', 'shariff' ) . '
'; echo '
[shariff info_text="' . esc_html__( 'My custom text.', 'shariff' ) . '"]
'; echo '
' . esc_html__( 'Sets a custom text for the info button.', 'shariff' ) . '
'; echo '
'; // URL. echo '
'; echo '
url
'; echo '
'; echo '
' . esc_html__( 'The url of the current post or page.', 'shariff' ) . '
'; echo '
[shariff url="http://www.mydomain.com/somepost"]
'; echo '
' . esc_html__( 'Changes the url to share. Only for special use cases.', 'shariff' ) . '
'; echo '
'; // Title. echo '
'; echo '
title
'; echo '
'; echo '
' . esc_html__( 'The title of the current post or page.', 'shariff' ) . '
'; echo '
[shariff title="' . esc_html__( 'My Post Title', 'shariff' ) . '"]
'; echo '
' . 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' ) . '
'; echo '
'; // RSS feed. echo '
'; echo '
rssfeed
'; echo '
'; echo '
http://www.mydomain.com/feed/rss/
'; echo '
[shariff rssfeed="http://www.mydomain.com/feed/rss2/"]
'; echo '
' . 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 '
'; echo '
'; if ( empty( $service_errors ) ) { echo '
' . esc_html__( 'OK', 'shariff' ) . '
'; echo '
' . esc_html__( 'No error messages.', 'shariff' ) . '
'; } elseif ( array_filter( $service_errors ) ) { echo '
' . esc_html__( 'Error', 'shariff' ) . '
'; echo '
' . esc_html__( 'One or more services reported an error.', 'shariff' ) . '
'; } else { echo '
' . esc_html__( 'Timeout', 'shariff' ) . '
'; echo '
' . esc_html__( 'One or more services didn\'t respond in less than five seconds.', 'shariff' ) . '
'; } echo '
'; echo '
'; echo '
'; // End statistic row. echo '
'; // Output all services. foreach ( $GLOBALS['shariff3uu_services_backend'] as $service ) { // Begin service row. echo '
'; echo '
' . esc_html( ucfirst( $service ) ) . ':
'; echo '
'; echo '
'; if ( isset( $shariff3uu['disable'][ $service ] ) && 1 === $shariff3uu['disable'][ $service ] ) { echo '
' . esc_html__( 'Disabled', 'shariff' ) . '
'; } elseif ( 'facebook' === $service && ( ! isset( $shariff3uu['fb_id'] ) || ! isset( $shariff3uu['fb_secret'] ) ) ) { 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' ) . '
'; } elseif ( ! array_key_exists( $service, $service_errors ) ) { echo '
' . esc_html__( 'OK', 'shariff' ) . '
'; echo '
' . esc_html__( 'Share Count:', 'shariff' ) . ' ' . absint( $share_counts[ $service ] ) . '
'; } elseif ( empty( $service_errors[ $service ] ) ) { echo '
' . esc_html__( 'Timeout', 'shariff' ) . '
'; echo '
'; echo esc_html__( 'Service didn\'t respond in less than five seconds.', 'shariff' ); echo '
'; } else { echo '
' . esc_html__( 'Error', 'shariff' ) . '
'; echo '
'; echo esc_html( $service_errors[ $service ] ); echo '
'; } echo '
'; echo '
'; echo '
'; echo '
'; } }// End if. // GD needed for QR codes of the Bitcoin links. echo '
'; echo '
' . esc_html__( 'GD Library:', 'shariff' ) . '
'; // Working message. if ( function_exists( 'gd_info' ) ) { $gd_info = gd_info(); echo '
'; echo '
'; echo '
' . esc_html__( 'OK', 'shariff' ) . '
'; echo '
Version: ' . esc_html( $gd_info['GD Version'] ) . '
'; echo '
'; echo '
'; } else { echo '
'; echo '
'; echo '
' . esc_html__( 'Error', 'shariff' ) . '
'; echo '
' . 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 '

'; } // Begin ranking table. echo '
'; // Head. echo '
'; echo '
' . esc_html__( 'Rank', 'shariff' ) . '
'; echo '
' . esc_html__( 'Post', 'shariff' ) . '
'; echo '
' . esc_html__( 'Date', 'shariff' ) . '
'; echo '
' . esc_html__( 'Time', 'shariff' ) . '
'; foreach ( $services as $service => $nothing ) { echo '
' . esc_html( ucfirst( $service ) ) . '
'; } echo '
' . esc_html__( 'Total', 'shariff' ) . '
'; echo '
'; // Posts. $rank = '0'; foreach ( $posts as $post => $value ) { $rank ++; echo '
'; echo '
' . absint( $rank ) . '
'; echo '
' . esc_html( wp_strip_all_tags( $value['title'] ) ) . '
'; echo '
' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '
'; echo '
' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '
'; // Share counts. foreach ( $services as $service => $nothing ) { echo '
'; if ( isset( $value['share_counts'][ $service ] ) ) { echo absint( $value['share_counts'][ $service ] ); } echo '
'; } echo '
'; if ( isset( $value['share_counts']['total'] ) ) { echo absint( $value['share_counts']['total'] ); } echo '
'; echo '
'; } 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 '

'; } // Begin ranking table. echo '
'; // Head. echo '
'; echo '
' . esc_html__( 'Rank', 'shariff' ) . '
'; echo '
' . esc_html__( 'Page', 'shariff' ) . '
'; echo '
' . esc_html__( 'Date', 'shariff' ) . '
'; echo '
' . esc_html__( 'Time', 'shariff' ) . '
'; foreach ( $services as $service => $nothing ) { echo '
' . esc_html( ucfirst( $service ) ) . '
'; } echo '
' . esc_html__( 'Total', 'shariff' ) . '
'; echo '
'; // Pages. $rank = '0'; foreach ( $posts as $post => $value ) { $rank ++; echo '
'; echo '
' . absint( $rank ) . '
'; echo '
' . esc_html( $value['title'] ) . '
'; echo '
' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '
'; echo '
' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '
'; // Share counts. foreach ( $services as $service => $nothing ) { echo '
'; if ( isset( $value['share_counts'][ $service ] ) ) { echo absint( $value['share_counts'][ $service ] ); } echo '
'; } echo '
'; if ( isset( $value['share_counts']['total'] ) ) { echo absint( $value['share_counts']['total'] ); } echo '
'; echo '
'; } 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 '
'; // Head. echo '
'; echo '
' . esc_html__( 'Rank', 'shariff' ) . '
'; echo '
' . esc_html__( 'Product', 'shariff' ) . '
'; echo '
' . esc_html__( 'Date', 'shariff' ) . '
'; echo '
' . esc_html__( 'Time', 'shariff' ) . '
'; foreach ( $services as $service => $nothing ) { echo '
' . esc_html( ucfirst( $service ) ) . '
'; } echo '
' . esc_html__( 'Total', 'shariff' ) . '
'; echo '
'; // Pages. $rank = '0'; foreach ( $posts as $post => $value ) { $rank ++; echo '
'; echo '
' . absint( $rank ) . '
'; echo '
' . esc_html( $value['title'] ) . '
'; echo '
' . esc_html( mysql2date( 'd.m.Y', $value['post_date'] ) ) . '
'; echo '
' . esc_html( mysql2date( 'H:i', $value['post_date'] ) ) . '
'; // Share counts. foreach ( $services as $service => $nothing ) { echo '
'; if ( isset( $value['share_counts'][ $service ] ) ) { echo absint( $value['share_counts'][ $service ] ); } echo '
'; } echo '
'; if ( isset( $value['share_counts']['total'] ) ) { echo absint( $value['share_counts']['total'] ); } echo '
'; echo '
'; } echo '
'; } } /** * Renders the plugin option page. */ function shariff3uu_options_page() { // The
with the class "wrap" makes sure that admin messages are displayed below the title and not above. echo '
'; // Title. echo '

Shariff ' . esc_html( $GLOBALS['shariff3uu_basic']['version'] ) . '

'; // Start the form. echo '
'; // Hidden version entry, so it will get saved upon updating the options. echo ''; // Determine active tab. // phpcs:ignore if ( isset( $_GET['tab'] ) ) { // phpcs:ignore $active_tab = $_GET['tab']; } else { $active_tab = 'shariff3uu_basic'; } // Tabs. echo ''; // Content of tabs. if ( 'shariff3uu_basic' === $active_tab ) { settings_fields( 'shariff3uu_basic' ); do_settings_sections( 'shariff3uu_basic' ); submit_button(); } elseif ( 'shariff3uu_design' === $active_tab ) { settings_fields( 'shariff3uu_design' ); do_settings_sections( 'shariff3uu_design' ); submit_button(); } elseif ( 'shariff3uu_advanced' === $active_tab ) { settings_fields( 'shariff3uu_advanced' ); do_settings_sections( 'shariff3uu_advanced' ); submit_button(); } elseif ( 'shariff3uu_statistic' === $active_tab ) { settings_fields( 'shariff3uu_statistic' ); do_settings_sections( 'shariff3uu_statistic' ); submit_button(); } elseif ( 'shariff3uu_help' === $active_tab ) { settings_fields( 'shariff3uu_help' ); do_settings_sections( 'shariff3uu_help' ); } elseif ( 'shariff3uu_status' === $active_tab ) { settings_fields( 'shariff3uu_status' ); do_settings_sections( 'shariff3uu_status' ); } elseif ( 'shariff3uu_ranking' === $active_tab ) { settings_fields( 'shariff3uu_ranking' ); do_settings_sections( 'shariff3uu_ranking' ); } // End of form. echo '
'; }