true ) ); $options = get_option( 'addtoany_options' ); $title = apply_filters( 'A2A_SHARE_SAVE_meta_box_title', __( 'AddToAny', 'add-to-any' ) ); foreach( $post_types as $post_type ) { if ( // If automatic placement is enabled // for either floating bar isset( $options['floating_vertical'] ) && 'none' != $options['floating_vertical'] || isset( $options['floating_horizontal'] ) && 'none' != $options['floating_horizontal'] || // for standard buttons in posts 'post' == $post_type && ( ! isset( $options['display_in_posts'] ) || $options['display_in_posts'] != '-1' ) || // for standard buttons in pages 'page' == $post_type && ( ! isset( $options['display_in_pages'] ) || $options['display_in_pages'] != '-1' ) || // for standard buttons in a custom post type ! isset( $options['display_in_cpt_' . $post_type] ) || $options['display_in_cpt_' . $post_type] != '-1' ) { // Add meta box add_meta_box( 'A2A_SHARE_SAVE_meta', $title, 'A2A_SHARE_SAVE_meta_box_content', $post_type, 'advanced', 'high' ); } } } function A2A_SHARE_SAVE_meta_box_content( $post ) { do_action( 'start_A2A_SHARE_SAVE_meta_box_content', $post ); $disabled = get_post_meta( $post->ID, 'sharing_disabled', true ); ?>
'1', // Modernly used for "Use CSS Stylesheet?" 'cache' => '-1', 'display_in_posts_on_front_page' => '1', 'display_in_posts_on_archive_pages' => '1', 'display_in_posts' => '1', 'display_in_pages' => '1', 'display_in_feed' => '1', 'onclick' => '-1', 'button' => 'A2A_SVG_32', 'button_custom' => '', 'additional_js_variables' => '', 'button_text' => 'Share', 'display_in_excerpts' => '1', 'active_services' => Array(), ); $namespace = 'A2A_SHARE_SAVE_'; foreach ( $options as $option_name => $option_value ) { $old_option_name = $namespace . $option_name; $old_option_value = get_option( $old_option_name ); if( $old_option_value === false ) { // Default value $options[ $option_name ] = $option_value; } else { // Old value $options[ $option_name ] = $old_option_value; } delete_option( $old_option_name ); } update_option( 'addtoany_options', $options ); $deprecated_options = array( 'button_opens_new_window', 'hide_embeds', 'show_title', ); foreach ( $deprecated_options as $option_name ) { delete_option( $namespace . $option_name ); } } /** * Adds a WordPress pointer to Settings menu, so user knows where to configure AddToAny */ function A2A_SHARE_SAVE_enqueue_pointer_script_style( $hook_suffix ) { // Requires WP 3.3 if ( get_bloginfo( 'version' ) < '3.3' ) { return; } // Assume pointer shouldn't be shown $enqueue_pointer_script_style = false; // Get array list of dismissed pointers for current user and convert it to array $dismissed_pointers = explode( ',', get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); // Check if our pointer is not among dismissed ones if ( !in_array( 'addtoany_settings_pointer', $dismissed_pointers ) ) { $enqueue_pointer_script_style = true; // Add footer scripts using callback function add_action( 'admin_print_footer_scripts', 'A2A_SHARE_SAVE_pointer_print_scripts' ); } // Enqueue pointer CSS and JS files, if needed if ( $enqueue_pointer_script_style ) { wp_enqueue_style( 'wp-pointer' ); wp_enqueue_script( 'wp-pointer' ); } } if ( ! $A2A_SHARE_SAVE_options ) { // Only show the pointer when no AddToAny options have been set add_action( 'admin_enqueue_scripts', 'A2A_SHARE_SAVE_enqueue_pointer_script_style' ); } function A2A_SHARE_SAVE_pointer_print_scripts() { $pointer_content = '
To customize your AddToAny share buttons, click "AddToAny" in the Settings menu.
'; ?> true, '_builtin' => false ), 'objects' ) ); foreach ( $custom_post_types as $custom_post_type_obj ) { $placement_name = $custom_post_type_obj->name; $new_options['display_in_cpt_' . $placement_name] = ( isset( $_POST['A2A_SHARE_SAVE_display_in_cpt_' . $placement_name] ) && $_POST['A2A_SHARE_SAVE_display_in_cpt_' . $placement_name] == '1' ) ? '1' : '-1'; } // Schedule cache refresh? if ( isset( $_POST['A2A_SHARE_SAVE_cache'] ) && $_POST['A2A_SHARE_SAVE_cache'] == '1' ) { A2A_SHARE_SAVE_schedule_cache(); A2A_SHARE_SAVE_refresh_cache(); } else { A2A_SHARE_SAVE_unschedule_cache(); } // Store desired text if 16 x 16px buttons or text-only is chosen: if ( $new_options['button'] == 'favicon.png|16|16' ) $new_options['button_text'] = $_POST['A2A_SHARE_SAVE_button_favicon_16_16_text']; elseif ( $new_options['button'] == 'share_16_16.png|16|16' ) $new_options['button_text'] = $_POST['A2A_SHARE_SAVE_button_share_16_16_text']; else $new_options['button_text'] = ( trim( $_POST['A2A_SHARE_SAVE_button_text'] ) != '' ) ? $_POST['A2A_SHARE_SAVE_button_text'] : __('Share','add-to-any'); // Store chosen individual services to make active $active_services = array(); if ( ! isset( $_POST['A2A_SHARE_SAVE_active_services'] ) ) $_POST['A2A_SHARE_SAVE_active_services'] = array(); foreach ( $_POST['A2A_SHARE_SAVE_active_services'] as $dummy=>$sitename ) { $service = substr( $sitename, 7 ); $active_services[] = $service; // AddToAny counter enabled? if ( in_array( $service, array( 'facebook', 'pinterest', 'linkedin', 'reddit' ) ) ) { $new_options['special_' . $service . '_options'] = array( 'show_count' => ( ( isset( $_POST['addtoany_' . $service . '_show_count'] ) && $_POST['addtoany_' . $service . '_show_count'] == '1') ? '1' : '-1' ) ); } } $new_options['active_services'] = $active_services; // Store special service options $new_options['special_facebook_like_options'] = array( 'verb' => ( ( isset( $_POST['addtoany_facebook_like_verb'] ) && $_POST['addtoany_facebook_like_verb'] == 'recommend') ? 'recommend' : 'like' ) ); $new_options['special_twitter_tweet_options'] = array( 'show_count' => '-1' // Twitter doesn't provide counts anymore ); $new_options['special_google_plusone_options'] = array( 'show_count' => ( ( isset( $_POST['addtoany_google_plusone_show_count'] ) && $_POST['addtoany_google_plusone_show_count'] == '1' ) ? '1' : '-1' ) ); $new_options['special_google_plus_share_options'] = array( 'show_count' => ( ( isset( $_POST['addtoany_google_plus_share_show_count'] ) && $_POST['addtoany_google_plus_share_show_count'] == '1' ) ? '1' : '-1' ) ); $new_options['special_pinterest_pin_options'] = array( 'show_count' => ( ( isset( $_POST['addtoany_pinterest_pin_show_count'] ) && $_POST['addtoany_pinterest_pin_show_count'] == '1' ) ? '1' : '-1' ) ); } // Get all existing AddToAny options $existing_options = get_option( 'addtoany_options' ); // Merge $new_options into $existing_options to retain AddToAny options from all other screens/tabs if ( $existing_options ) { $new_options = array_merge( $existing_options, $new_options ); } update_option( 'addtoany_options', $new_options ); ?>