options = $options; $this->version = $version; } /** * Creates plugin menu in admin area * * @since 1.0 */ public function create_admin_menu() { $page = add_menu_page( __( 'Sassy Social Share by Heateor', 'sassy-social-share' ), 'Sassy Social Share', 'manage_options', 'heateor-sss-options', array( $this, 'options_page' ), plugins_url( '../images/logo.png', __FILE__ ) ); // options $options_page = add_submenu_page( 'heateor-sss-options', __( "Sassy Social Share", 'sassy-social-share' ), __( "Sassy Social Share", 'sassy-social-share' ), 'manage_options', 'heateor-sss-options', array( $this, 'options_page' ) ); //adding mycred addon in submenu $my_cred = add_submenu_page( 'heateor-sss-options', __( "Social Share myCRED Integration", 'sassy-social-share' ), __( "Social Share myCRED Integration", 'sassy-social-share' ), 'manage_options', 'heateor-sss-mycred-options', array( $this, 'mycred_options_page' ) ); //adding recover sharing counts addon in submenu $rssc = add_submenu_page( 'heateor-sss-options', __( "Recover Social Share Counts", 'sassy-social-share' ), __( "Recover Social Share Counts", 'sassy-social-share' ), 'manage_options', 'heateor-sss-rssc-options', array( $this, 'rssc_option_page' ) ); //adding analytics addon in submenu $ssga = add_submenu_page( 'heateor-sss-options', __( "Social Analytics", 'sassy-social-share' ), __( "Social Analytics", 'sassy-social-share' ), 'manage_options', 'heateor-sss-ssga-options', array( $this, 'ssga_option_page' ) ); $ssb = add_submenu_page( 'heateor-sss-options', __( "Social Share Buttons", 'sassy-social-share' ), __( "Social Share Buttons", 'sassy-social-share' ), 'manage_options', 'heateor-sss-ssb-options', array( $this, 'ssb_option_page' ) ); add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_scripts' ) ); add_action( 'admin_print_scripts-' . $page, array( $this, 'admin_style' ) ); add_action( 'admin_print_scripts-' . $ssga, array( $this, 'admin_scripts' ) ); add_action( 'admin_print_scripts-' . $ssga, array( $this, 'admin_style' ) ); add_action( 'admin_print_scripts-' . $ssga, array( $this, 'fb_sdk_script' ) ); add_action( 'admin_print_styles-' . $ssga, array( $this, 'admin_options_style' ) ); add_action( 'admin_print_scripts-' . $rssc, array( $this, 'admin_scripts' ) ); add_action( 'admin_print_scripts-' . $rssc, array( $this, 'admin_style' ) ); add_action( 'admin_print_scripts-' . $rssc, array( $this, 'fb_sdk_script' ) ); add_action( 'admin_print_styles-' . $rssc, array( $this, 'admin_options_style' ) ); add_action( 'admin_print_scripts-' . $my_cred, array( $this, 'admin_scripts' ) ); add_action( 'admin_print_scripts-' . $my_cred, array( $this, 'admin_style' ) ); add_action( 'admin_print_scripts-' . $ssb, array( $this, 'admin_scripts' ) ); add_action( 'admin_print_scripts-' . $ssb, array( $this, 'admin_style' ) ); add_action( 'admin_print_scripts-' . $ssb, array( $this, 'fb_sdk_script' ) ); add_action( 'admin_print_styles-' . $ssb, array( $this, 'admin_options_style' ) ); add_action( 'admin_print_scripts-' . $my_cred, array( $this, 'fb_sdk_script' ) ); add_action( 'admin_print_styles-' . $my_cred, array( $this, 'admin_options_style' ) ); add_action( 'admin_print_scripts-' . $page, array( $this, 'fb_sdk_script' ) ); add_action( 'admin_print_styles-' . $page, array( $this, 'admin_options_style' ) ); add_action( 'admin_print_scripts-' . $options_page, array( $this, 'admin_scripts' ) ); add_action( 'admin_print_scripts-' . $options_page, array( $this, 'fb_sdk_script' ) ); add_action( 'admin_print_styles-' . $options_page, array( $this, 'admin_style' ) ); add_action( 'admin_print_scripts-' . $options_page, array( $this, 'admin_options_scripts' ) ); add_action( 'admin_print_styles-' . $options_page, array( $this, 'admin_options_style' ) ); } /** * myCRED integration options page * * @since 3.3.51 */ public function mycred_options_page() { /** * The file rendering options page */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/sassy-social-share-my-cred-plugin-options.php'; } /** * Options page for Recover Social Share Counts module * * @since 3.3.51 */ public function rssc_option_page() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/sassy-social-share-rssc-plugin-options.php'; } /** * Options page for Social Analytics module * * @since 3.3.51 */ public function ssga_option_page() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/sassy-social-share-ssga-plugin-options.php'; } /** * Options page for Social share buttons module * * @since 3.3.51 */ public function ssb_option_page() { require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/sassy-social-share-ssb-options.php'; } /** * Register plugin settings and its sanitization callback. * * @since 1.0 */ public function options_init() { register_setting( 'heateor_sss_options', 'heateor_sss', array( $this, 'validate_options' ) ); if ( current_user_can( 'manage_options' ) ) { // show option to disable sharing on particular page/post $post_types = get_post_types( array( 'public' => true ), 'names', 'and' ); $post_types = array_unique( array_merge( $post_types, array( 'post', 'page' ) ) ); foreach ( $post_types as $type ) { add_meta_box( 'heateor_sss_meta', 'Sassy Social Share', array( $this, 'sharing_meta_setup' ), $type ); } // save sharing meta on post/page save add_action( 'save_post', array( $this, 'save_sharing_meta' ) ); } } /** * Update options in all the old blogs. * * @since 1.0 */ public function update_old_blogs( $old_config ) { $option_parts = explode( '_', current_filter() ); $option = $option_parts[2] . '_' . $option_parts[3] . '_' . $option_parts[4]; $new_config = get_option( $option ); if ( isset( $new_config['config_multisite'] ) && $new_config['config_multisite'] == 1 ) { $blogs = get_blog_list( 0, 'all' ); foreach ( $blogs as $blog ) { update_blog_option( $blog['blog_id'], $option, $new_config ); } } } /** * Replicate the options to the new blog created. * * @since 1.0 */ public function replicate_settings( $blog_id ) { add_blog_option( $blog_id, 'heateor_sss', $this->options ); } /** * Show sharing meta options * * @since 1.0 */ public function sharing_meta_setup() { global $post; $postType = $post->post_type; $sharing_meta = get_post_meta( $post->ID, '_heateor_sss_meta', true ); ?>


options['hor_enable'] ) && isset( $this->options['horizontal_counts'] ) && isset( $this->options['horizontal_re_providers'] ) && count( $this->options['horizontal_re_providers'] ) > 0 ) { ?>

options['horizontal_re_providers'], $valid_networks ) as $network ) { ?>

options['vertical_enable'] ) && isset( $this->options['vertical_counts'] ) && isset( $this->options['vertical_re_providers'] ) && count( $this->options['vertical_re_providers'] ) > 0 ) { ?>

options['vertical_re_providers'], $valid_networks ) as $network ) { ?>

'; } /** * Save sharing meta fields. * * @since 1.0 */ public function save_sharing_meta( $post_id ) { // make sure data came from our meta box if ( ! isset( $_POST['heateor_sss_meta_nonce'] ) || ! wp_verify_nonce( $_POST['heateor_sss_meta_nonce'], __FILE__ ) ) { return $post_id; } // check user permissions if ( $_POST['post_type'] == 'page' ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return $post_id; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return $post_id; } } $newData = isset( $_POST['_heateor_sss_meta'] ) && is_array( $_POST['_heateor_sss_meta'] ) ? array_map('sanitize_text_field', $_POST['_heateor_sss_meta'] ) : array( 'sharing' => 0, 'vertical_sharing' => 0 ); update_post_meta( $post_id, '_heateor_sss_meta', $newData ); return $post_id; } /** * Sanitization callback for plugin options. * * IMPROVEMENT: complexity can be reduced (this function is called on each option page validation and "if ( $k == 'providers' ) {" * condition is being checked every time) * @since 1.0 */ public function validate_options( $heateorSssOptions ) { foreach ( $heateorSssOptions as $k => $v ) { if ( is_string( $v ) ) { $heateorSssOptions[$k] = esc_attr( trim( $v ) ); } } return $heateorSssOptions; } /** * Include Javascript at plugin options page in admin area * * @since 1.0 */ public function admin_options_scripts() { wp_enqueue_script( 'heateor_sss_admin_options_script', plugins_url( 'js/sassy-social-share-options.js', __FILE__ ), array( 'jquery', 'jquery-ui-sortable' ), $this->version ); wp_localize_script( 'heateor_sss_admin_options_script', 'heateor_sss_admin_options_script_object', array( 'plugin_page_url' => admin_url() . 'admin.php?page=heateor-sss-options', 'nonce' => wp_create_nonce( 'heateor_sss_admin_options_script' ), ) ); } /** * Include Javascript SDK in admin. * * @since 1.0 */ public function fb_sdk_script() { wp_enqueue_script( 'heateor_sss_fb_sdk_script', plugins_url( 'js/sassy-social-share-fb-sdk.js', __FILE__ ), false, $this->version ); } /** * Include CSS files in admin. * * @since 1.0 */ public function admin_style() { wp_enqueue_style( 'heateor_sss_admin_style', plugins_url( 'css/sassy-social-share-admin.css', __FILE__ ), false, $this->version ); } /** * Include CSS files at plugin options page in admin area * * @since 1.0 */ public function admin_options_style() { wp_enqueue_style( 'heateor_sss_admin_svg', plugins_url( 'css/sassy-social-share-svg.css', __FILE__ ), false, $this->version ); } /** * Update CSS file * * @since 1.0 */ private function update_css( $replace_color_option, $logo_color_option, $css_file ) { if ( $this->options[$replace_color_option] != $this->options[$logo_color_option] ) { $path = plugin_dir_url( __FILE__ ) . 'css/' . $css_file . '.css'; try { $content = file( $path ); if ( $content !== false ) { $handle = fopen( dirname( __FILE__ ) . '/css/' . $css_file . '.css','w' ); if ( $handle !== false ) { foreach ( $content as $value ) { fwrite( $handle, str_replace( str_replace( '#', '%23', $this->options[$replace_color_option] ), str_replace( '#', '%23', $this->options[$logo_color_option] ), $value ) ); } fclose( $handle ); $this->options[$replace_color_option] = $this->options[$logo_color_option]; update_option( 'heateor_sss', $this->options ); return true; } } } catch ( Exception $e ) { } } return false; } /** * Include javascript files in admin. * * @since 1.0 */ public function admin_scripts() { ?> version ); } /** * Export plugin configuration * * @since 3.3.22 */ public function export_config() { if ( current_user_can( 'manage_options' ) ) { if ( check_ajax_referer( 'heateor_sss_admin_options_script', 'nonce' ) === false ) { die; } $config = get_option( 'heateor_sss' ); die( json_encode( array( 'config' => json_encode( $config ) ) ) ); } } /** * Sanitize the value of the passed configuration array * * @since 3.3.41 */ private function sanitize_configuration_array( $config_value ) { if ( is_array( $config_value ) ) { return array_map( array( $this, 'sanitize_configuration_array' ), $config_value ); } else { return sanitize_text_field( $config_value ); } } /** * Import plugin configuration * * @since 3.3.22 */ public function import_config() { if ( current_user_can( 'manage_options' ) ) { if ( check_ajax_referer( 'heateor_sss_admin_options_script', 'nonce' ) === false ) { die; } if ( isset( $_POST['config'] ) && strlen( trim( $_POST['config'] ) ) > 0 ) { $config = json_decode( stripslashes( trim( $_POST['config'] ) ), true ); if ( is_array( $config ) && count( $config ) > 0 ) { $config = array_map( array( $this, 'sanitize_configuration_array' ), $config ); update_option( 'heateor_sss', $config ); die( json_encode( array( 'success' => 1 ) ) ); } } die; } } /** * Renders options page * * @since 1.0 */ public function options_page() { // message on saving options echo $this->settings_saved_notification(); $options = $this->options; /** * The file rendering options page */ require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/sassy-social-share-options-page.php'; } /** * Display notification message when plugin options are saved * * @since 1.0 * @return string Notification after saving options */ private function settings_saved_notification() { if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] == 'true' ) { return '

' . __( 'Settings saved', 'sassy-social-share' ) . '

'; } } /** * Check if plugin is active * * @since 1.0 */ private function is_plugin_active( $plugin_file ) { return in_array( $plugin_file, apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ); } /** * Set BuddyPress active flag to true * * @since 1.0 */ public function is_bp_loaded() { $this->is_bp_active = true; } /** * Clear Bitly shorturl cache * * @since 1.7 */ public function clear_shorturl_cache() { if ( current_user_can( 'manage_options' ) ) { if ( check_ajax_referer( 'heateor_sss_admin_options_script', 'nonce' ) === false ) { die; } global $wpdb; $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_heateor_sss_bitly_url'" ); } die; } /** * Clear share counts cache * * @since 1.7 */ public function clear_share_count_cache() { if ( current_user_can( 'manage_options' ) ) { if ( check_ajax_referer( 'heateor_sss_admin_options_script', 'nonce' ) === false ) { die; } global $wpdb; $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE '_transient_heateor_sss_share_count_%'" ); } die; } /** * Save Twitcount notification flag in DB * * @since 3.2.9 */ public function twitcount_notification_read() { if ( current_user_can( 'manage_options' ) ) { if ( check_ajax_referer( 'heateor_sss_admin_ajax_nonce', 'nonce' ) === false ) { die; } update_option( 'heateor_sss_twitcount_notification_read', '1' ); } die; } /** * Save GDPR notification flag in DB * * @since 3.2.1 */ public function gdpr_notification_read() { if ( current_user_can( 'manage_options' ) ) { if ( check_ajax_referer( 'heateor_sss_admin_ajax_nonce', 'nonce' ) === false ) { die; } update_option( 'heateor_sss_gdpr_notification_read', '1' ); } die; } /** * Show notices in admin area * * @since 2.4 */ public function show_notices() { if ( current_user_can( 'manage_options' ) ) { if( get_transient( 'heateor-sss-admin-notice-on-activation' ) ) { ?>

0 ) { ?>

Social Share - myCRED Integration

0 ) { ?>

Social Sharing Analytics

version ) <= 0 ) { if ( ! get_option( 'heateor_sss_gdpr_notification_read' ) ) { ?>

Sassy Social Share

here', 'sassy-social-share' ), 'http://support.heateor.com/gdpr-and-our-plugins' ); ?>

version ) <= 0 ) { if ( ( isset( $this->options['hor_enable'] ) && isset( $this->options['horizontal_re_providers'] ) && in_array( 'twitter', $this->options['horizontal_re_providers'] ) && ( isset( $this->options['horizontal_counts'] ) || isset( $this->options['horizontal_total_shares'] ) ) ) || ( isset( $this->options['vertical_enable'] ) && isset( $this->options['vertical_re_providers'] ) && in_array( 'twitter', $this->options['vertical_re_providers'] ) && ( isset($this->options['vertical_counts'] ) || isset( $this->options['vertical_total_shares'] ) ) ) ) { if ( ! get_option( 'heateor_sss_twitcount_notification_read' ) ) { ?>

Sassy Social Share

their website and register your website %s with them. No need to copy-paste any code from their website.', 'sassy-social-share' ), 'http://twitcount.com', home_url() ); ?>

' . __( 'Add-Ons', 'sassy-social-share' ) . ''; $support_link = '
' . __( 'Support Documentation', 'sassy-social-share' ) . ''; $settings_link = '' . __( 'Settings', 'sassy-social-share' ) . ''; // place it before other links array_unshift( $links, $settings_link ); $links[] = $addons_link; $links[] = $support_link; } return $links; } /** * Update options based on plugin version * * @since 2.5.8 */ public function update_db_check() { $current_version = get_option( 'heateor_sss_version' ); if ( $current_version != $this->version ) { if ( version_compare( '3.3.77', $current_version ) > 0 ) { $networks_to_remove = array( 'Webnews' ); if ( isset( $this->options['vertical_re_providers'] ) && $this->options['vertical_re_providers'] ) { $this->options['vertical_re_providers'] = array_diff( $this->options['vertical_re_providers'], $networks_to_remove ); } if ( isset( $this->options['horizontal_re_providers'] ) && $this->options['horizontal_re_providers'] ) { $this->options['horizontal_re_providers'] = array_diff( $this->options['horizontal_re_providers'], $networks_to_remove ); } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.3.75', $current_version ) > 0 ) { $networks_to_remove = array( 'Yoolink' ); if ( isset( $this->options['vertical_re_providers'] ) && $this->options['vertical_re_providers'] ) { $this->options['vertical_re_providers'] = array_diff( $this->options['vertical_re_providers'], $networks_to_remove ); } if ( isset( $this->options['horizontal_re_providers'] ) && $this->options['horizontal_re_providers'] ) { $this->options['horizontal_re_providers'] = array_diff( $this->options['horizontal_re_providers'], $networks_to_remove ); } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.3.48', $current_version ) > 0 ) { if ( ! isset( $this->options['google_news_url'] ) ) { $this->options['google_news_url'] = ''; } if ( ! isset( $this->options['vertical_google_news_url'] ) ) { $this->options['vertical_google_news_url'] = ''; } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.3.44', $current_version ) > 0 ) { $networks_to_remove = array( 'Google_Bookmarks' ); if ( isset( $this->options['vertical_re_providers'] ) && $this->options['vertical_re_providers'] ) { $this->options['vertical_re_providers'] = array_diff( $this->options['vertical_re_providers'], $networks_to_remove ); } if ( isset( $this->options['horizontal_re_providers'] ) && $this->options['horizontal_re_providers'] ) { $this->options['horizontal_re_providers'] = array_diff( $this->options['horizontal_re_providers'], $networks_to_remove ); } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.3.43', $current_version ) > 0 ) { $this->options['rutube_username'] = ''; $this->options['vertical_rutube_username'] = ''; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.3.9', $current_version ) > 0 ) { $this->options['bitly_access_token'] = ''; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.3', $current_version ) > 0 ) { $this->options['youtube_username'] = ''; $this->options['vertical_youtube_username'] = ''; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.2.24', $current_version ) > 0 ) { if ( ! $this->options['fb_key'] && ! $this->options['fb_secret'] && $this->options['vertical_fb_key'] && $this->options['vertical_fb_secret'] ) { $this->options['fb_key'] = $this->options['vertical_fb_key']; $this->options['fb_secret'] = $this->options['vertical_fb_secret']; } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.2.20', $current_version ) > 0 ) { $this->options['fb_key'] = ''; $this->options['fb_secret'] = ''; $this->options['vertical_fb_key'] = ''; $this->options['vertical_fb_secret'] = ''; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.2.18', $current_version ) > 0 ) { $networks_to_remove = array( 'google_plus', 'google_plusone', 'google_plus_share' ); if ( $this->options['vertical_re_providers'] ) { $this->options['vertical_re_providers'] = array_diff( $this->options['vertical_re_providers'], $networks_to_remove ); } if ( $this->options['horizontal_re_providers'] ) { $this->options['horizontal_re_providers'] = array_diff( $this->options['horizontal_re_providers'], $networks_to_remove ); } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.2.6', $current_version ) > 0 ) { $networks_to_remove = array( 'yahoo', 'Yahoo_Messenger', 'delicious', 'Polyvore', 'Oknotizie', 'Baidu', 'diHITT', 'Netlog', 'NewsVine', 'NUjij', 'Segnalo', 'Stumpedia', 'YouMob' ); if ( $this->options['vertical_re_providers'] ) { $this->options['vertical_re_providers'] = array_diff( $this->options['vertical_re_providers'], $networks_to_remove ); } if ( $this->options['horizontal_re_providers'] ) { $this->options['horizontal_re_providers'] = array_diff( $this->options['horizontal_re_providers'], $networks_to_remove ); } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.2.5', $current_version ) > 0 ) { $this->options['tweet_count_service'] = 'opensharecount'; update_option( 'heateor_sss', $this->options ); } if ( version_compare( "3.2.4", $current_version ) > 0 ) { if ( isset( $this->options['horizontal_re_providers'] ) ) { foreach( $this->options['horizontal_re_providers'] as $key => $social_network ) { if ( $social_network == 'stumbleupon_badge' ) { unset( $this->options['horizontal_re_providers'][$key] ); } elseif ( $social_network == 'stumbleupon' ) { $this->options['horizontal_re_providers'][$key] = 'mix'; } } } if ( isset( $this->options['vertical_re_providers'] ) ) { foreach ( $this->options['vertical_re_providers'] as $key => $social_network ) { if ( $social_network == 'stumbleupon_badge' ) { unset( $this->options['vertical_re_providers'][$key] ); } elseif ( $social_network == 'stumbleupon' ) { $this->options['vertical_re_providers'][$key] = 'mix'; } } } update_option( 'heateor_sss', $this->options ); } if ( version_compare( '1.7', $current_version ) > 0 ) { $this->options['share_count_cache_refresh_count'] = '10'; $this->options['share_count_cache_refresh_unit'] = 'minutes'; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '2.3', $current_version ) > 0 ) { $this->options['amp_enable'] = '1'; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '2.4', $current_version ) > 0 ) { $this->options['instagram_username'] = ''; $this->options['vertical_instagram_username'] = ''; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '2.5.8', $current_version ) > 0 ) { $this->options['bottom_sharing_position_radio'] = 'responsive'; update_option( 'heateor_sss', $this->options ); } if ( version_compare( '3.0', $current_version ) > 0 ) { $this->options['comment_container_id'] = 'respond'; $this->options['vertical_comment_container_id'] = 'respond'; update_option( 'heateor_sss', $this->options ); } // update plugin version in database update_option( 'heateor_sss_version', $this->version ); } } }