├── .gitignore ├── .PSDs ├── sprite-flat.psd ├── sprite-circle.psd └── sprite-default.psd ├── assets ├── images │ ├── sprite-flat.png │ ├── sprite-circle.png │ └── sprite-default.png ├── js │ ├── admin.min.js │ └── admin.js ├── css │ ├── admin.css │ └── counter.css └── sass │ ├── admin.scss │ └── counter.scss ├── uninstall.php ├── .editorconfig ├── .jshintrc ├── package.json ├── includes ├── social-count-plus-functions.php ├── admin │ ├── views │ │ ├── html-help-us.php │ │ ├── html-settings-functions-shortcodes-page.php │ │ ├── html-settings-page.php │ │ └── html-settings-system-status-page.php │ └── class-social-count-plus-admin.php ├── class-social-count-plus-shortcodes.php ├── counters │ ├── class-social-count-plus-comments-counter.php │ ├── class-social-count-plus-users-counter.php │ ├── class-social-count-plus-posts-counter.php │ ├── class-social-count-plus-github-counter.php │ ├── class-social-count-plus-vimeo-counter.php │ ├── class-social-count-plus-steam-counter.php │ ├── class-social-count-plus-googleplus-counter.php │ ├── class-social-count-plus-soundcloud-counter.php │ ├── class-social-count-plus-twitch-counter.php │ ├── class-social-count-plus-linkedin-counter.php │ ├── class-social-count-plus-youtube-counter.php │ ├── class-social-count-plus-instagram-counter.php │ ├── class-social-count-plus-pinterest-counter.php │ ├── class-social-count-plus-facebook-counter.php │ ├── class-social-count-plus-twitter-counter.php │ └── class-social-count-plus-tumblr-counter.php ├── class-social-count-plus-view.php ├── class-social-count-plus-widget.php ├── class-social-count-plus-generator.php ├── abstracts │ └── abstract-social-count-plus-counter.php └── social-count-plus-deprecated-functions.php ├── social-count-plus.php ├── Gruntfile.js ├── readme.txt ├── README.md └── languages └── social-count-plus.pot /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | .sass-cache/ 3 | -------------------------------------------------------------------------------- /.PSDs/sprite-flat.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiosanches/social-count-plus/HEAD/.PSDs/sprite-flat.psd -------------------------------------------------------------------------------- /.PSDs/sprite-circle.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiosanches/social-count-plus/HEAD/.PSDs/sprite-circle.psd -------------------------------------------------------------------------------- /.PSDs/sprite-default.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiosanches/social-count-plus/HEAD/.PSDs/sprite-default.psd -------------------------------------------------------------------------------- /assets/images/sprite-flat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiosanches/social-count-plus/HEAD/assets/images/sprite-flat.png -------------------------------------------------------------------------------- /assets/images/sprite-circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiosanches/social-count-plus/HEAD/assets/images/sprite-circle.png -------------------------------------------------------------------------------- /assets/images/sprite-default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/claudiosanches/social-count-plus/HEAD/assets/images/sprite-default.png -------------------------------------------------------------------------------- /uninstall.php: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 |

9 |

10 |
11 | -------------------------------------------------------------------------------- /includes/class-social-count-plus-shortcodes.php: -------------------------------------------------------------------------------- 1 | 'twitter' 30 | ), 31 | $atts 32 | ) 33 | ); 34 | 35 | $counter = $count[ $code ]; 36 | 37 | return apply_filters( 'social_count_plus_number_format', $counter ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /assets/js/admin.min.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function(a){function b(b){var c=b.attr("id"),d=c.replace("_active",""),e=a('.form-table [id^="'+d+'"]').not('[id^="'+c+'"]').parent("td").parent("tr");b.is(":checked")?e.show():e.hide()}a(".social-count-plus-color-field").wpColorPicker(),a('.form-table input[id$="_active"]').each(function(){b(a(this))}),a('.form-table input[id$="_active"]').on("click",function(){b(a(this))}),a(".form-table .social-count-plus-icons-order").sortable({items:"div.social-icon",cursor:"move",scrollSensitivity:40,forcePlaceholderSize:!0,forceHelperSize:!1,helper:"clone",opacity:.65,placeholder:"social-icon-placeholder",start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style")},update:function(){var b=a(".social-count-plus-icons-order .social-icon").map(function(){return a(this).data("icon")}).get().join();a("input",a(this)).val(b)}})}); -------------------------------------------------------------------------------- /assets/css/admin.css: -------------------------------------------------------------------------------- 1 | table#social-count-plus-system-status{margin-top:1.1em}table#social-count-plus-system-status tr:nth-child(2n) th,table#social-count-plus-system-status tr:nth-child(2n) td{background:#fcfcfc}table#social-count-plus-system-status th{font-weight:bold}table#social-count-plus-system-status td:first-child{width:20%}table#social-count-plus-system-status td{font-size:1.1em;padding:6px 9px}table#social-count-plus-system-status td mark{background:transparent none}table#social-count-plus-system-status td mark.yes{color:#7AD03A}table#social-count-plus-system-status td mark.no{color:#999}table#social-count-plus-system-status td mark.error{color:#a00}table#social-count-plus-system-status td ul{margin:0}.social-count-plus-icons-order{*zoom:1;background:#fff;border:1px solid #ddd;padding:10px 5px 0 5px}.social-count-plus-icons-order:before,.social-count-plus-icons-order:after{content:" ";display:table}.social-count-plus-icons-order:after{clear:both}.social-count-plus-icons-order .social-icon,.social-count-plus-icons-order .social-icon-placeholder{border:3px solid #ddd;cursor:move;float:left;font-weight:bold;margin:0 5px 10px;padding:4px}.social-count-plus-icons-order .social-icon-placeholder{background:#f4f4f4;border-style:dashed}.social-count-plus{margin-bottom:20px}.social-count-plus .vertical li:not(:first-child){margin-left:26px}.social-count-plus-model-input{display:block !important;float:left !important;margin:10px 10px 0 0 !important} 2 | -------------------------------------------------------------------------------- /assets/sass/admin.scss: -------------------------------------------------------------------------------- 1 | /* Status page */ 2 | table#social-count-plus-system-status { 3 | margin-top: 1.1em; 4 | 5 | tr { 6 | &:nth-child(2n) { 7 | th, td { 8 | background: #fcfcfc; 9 | } 10 | } 11 | } 12 | th { 13 | font-weight: bold; 14 | } 15 | td:first-child { 16 | width: 20%; 17 | } 18 | td { 19 | font-size: 1.1em; 20 | padding: 6px 9px; 21 | 22 | mark { 23 | background: transparent none; 24 | } 25 | mark.yes { 26 | color: #7AD03A; 27 | } 28 | mark.no { 29 | color: #999; 30 | } 31 | mark.error { 32 | color: #a00; 33 | } 34 | ul { 35 | margin: 0; 36 | } 37 | } 38 | } 39 | 40 | .social-count-plus-icons-order { 41 | *zoom: 1; 42 | background: #fff; 43 | border: 1px solid #ddd; 44 | padding: 10px 5px 0 5px; 45 | 46 | &:before, 47 | &:after { 48 | content: " "; 49 | display: table; 50 | } 51 | 52 | &:after { 53 | clear: both; 54 | } 55 | 56 | .social-icon, 57 | .social-icon-placeholder { 58 | border: 3px solid #ddd; 59 | cursor: move; 60 | float: left; 61 | font-weight: bold; 62 | margin: 0 5px 10px; 63 | padding: 4px; 64 | } 65 | 66 | .social-icon-placeholder { 67 | background: #f4f4f4; 68 | border-style: dashed; 69 | } 70 | } 71 | 72 | .social-count-plus { 73 | margin-bottom: 20px; 74 | 75 | .vertical li:not(:first-child) { 76 | margin-left: 26px; 77 | } 78 | } 79 | 80 | .social-count-plus-model-input { 81 | display: block !important; 82 | float: left !important; 83 | margin: 10px 10px 0 0 !important; 84 | } 85 | -------------------------------------------------------------------------------- /assets/js/admin.js: -------------------------------------------------------------------------------- 1 | jQuery( document ).ready( function ( $ ) { 2 | // Init the color picker. 3 | $( '.social-count-plus-color-field' ).wpColorPicker(); 4 | 5 | function socialCountPlusShowHide( input ) { 6 | var current = input.attr( 'id' ), 7 | id = current.replace( '_active', '' ), 8 | elements = $( '.form-table [id^="' + id + '"]' ) 9 | .not( '[id^="' + current + '"]' ) 10 | .parent( 'td' ) 11 | .parent( 'tr' ); 12 | 13 | if ( input.is( ':checked' ) ) { 14 | elements.show(); 15 | } else { 16 | elements.hide(); 17 | } 18 | } 19 | 20 | $( '.form-table input[id$="_active"]' ).each( function () { 21 | socialCountPlusShowHide( $( this ) ); 22 | }); 23 | 24 | $( '.form-table input[id$="_active"]' ).on( 'click', function () { 25 | socialCountPlusShowHide( $( this ) ); 26 | }); 27 | 28 | $( '.form-table .social-count-plus-icons-order' ).sortable({ 29 | items: 'div.social-icon', 30 | cursor: 'move', 31 | scrollSensitivity: 40, 32 | forcePlaceholderSize: true, 33 | forceHelperSize: false, 34 | helper: 'clone', 35 | opacity: 0.65, 36 | placeholder: 'social-icon-placeholder', 37 | start: function ( event, ui ) { 38 | ui.item.css('background-color', '#f6f6f6'); 39 | }, stop: function ( event, ui ) { 40 | ui.item.removeAttr( 'style' ); 41 | }, update: function () { 42 | var icons = $( '.social-count-plus-icons-order .social-icon' ).map( function () { 43 | return $( this ).data( 'icon' ); 44 | }).get().join(); 45 | 46 | $( 'input', $( this ) ).val( icons ); 47 | } 48 | }); 49 | }); 50 | -------------------------------------------------------------------------------- /includes/admin/views/html-settings-functions-shortcodes-page.php: -------------------------------------------------------------------------------- 1 | 6 | 7 |

8 | 9 |

10 | 11 |

12 | 13 | 14 | get_i18n_counters() as $slug => $name ) : ?> 15 | 16 | 17 | 18 | 19 | 20 |

[scp code=""]

21 | 22 |

23 | 24 |

get_scp_widget() function that displays with images.', 'social-count-plus' ); ?>

25 | 26 | 27 | get_i18n_counters() as $slug => $name ) : ?> 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |

<?php echo get_scp_counter( '' ); ?>

<?php echo get_scp_widget(); ?>

38 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-comments-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $data = wp_count_comments(); 52 | 53 | if ( is_wp_error( $data ) ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $count = intval( $data->approved ); 57 | 58 | $this->total = $count; 59 | } 60 | } 61 | 62 | return $this->total; 63 | } 64 | 65 | /** 66 | * Get conter view. 67 | * 68 | * @param array $settings Plugin settings. 69 | * @param int $total Counter total. 70 | * @param string $text_color Text color. 71 | * 72 | * @return string 73 | */ 74 | public function get_view( $settings, $total, $text_color ) { 75 | $url = ! empty( $settings['comments_url'] ) ? $settings['comments_url'] : get_home_url(); 76 | 77 | unset( $settings['target_blank'] ); 78 | 79 | return $this->get_view_li( $url, $total, __( 'comments', 'social-count-plus' ), $text_color, $settings ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /includes/class-social-count-plus-view.php: -------------------------------------------------------------------------------- 1 | '; 54 | $html .= ''; 74 | $html .= ''; 75 | 76 | return $html; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-users-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $users = count_users(); 52 | 53 | if ( 'all' == $settings['users_user_role'] ) { 54 | $this->total = intval( $users['total_users'] ); 55 | } else if ( ! empty( $users['avail_roles'][ $settings['users_user_role'] ] ) ) { 56 | $this->total = intval( $users['avail_roles'][ $settings['users_user_role'] ] ); 57 | } else { 58 | $this->total = 0; 59 | } 60 | } 61 | 62 | return $this->total; 63 | } 64 | 65 | /** 66 | * Get conter view. 67 | * 68 | * @param array $settings Plugin settings. 69 | * @param int $total Counter total. 70 | * @param string $text_color Text color. 71 | * 72 | * @return string 73 | */ 74 | public function get_view( $settings, $total, $text_color ) { 75 | $url = ! empty( $settings['users_url'] ) ? $settings['users_url'] : get_home_url(); 76 | $label = ! empty( $settings['users_label'] ) ? $settings['users_label'] : __( 'users', 'social-count-plus' ); 77 | 78 | unset( $settings['target_blank'] ); 79 | 80 | return $this->get_view_li( $url, $total, $label, $text_color, $settings ); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /includes/admin/views/html-settings-page.php: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 | 11 | 12 | 13 | 14 |
15 | '; 31 | foreach ( $options as $section => $data ) { 32 | echo '
  • ' . esc_html( $data['title'] ) . ''; 33 | echo $last !== $section ? ' | ' : ''; 34 | echo '
  • '; 35 | } 36 | echo '
    '; 37 | 38 | settings_fields( 'socialcountplus_settings' ); 39 | do_settings_sections( 'socialcountplus_settings' ); 40 | submit_button(); 41 | } 42 | ?> 43 |
    44 |
    45 | -------------------------------------------------------------------------------- /includes/class-social-count-plus-widget.php: -------------------------------------------------------------------------------- 1 | __( 'Display the counter', 'social-count-plus' ) ) 20 | ); 21 | } 22 | 23 | /** 24 | * Front-end display of widget. 25 | * 26 | * @see WP_Widget::widget() 27 | * 28 | * @param array $args Widget arguments. 29 | * @param array $instance Saved values from database. 30 | */ 31 | public function widget( $args, $instance ) { 32 | $title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' ); 33 | 34 | echo $args['before_widget']; 35 | 36 | if ( ! empty( $title ) ) { 37 | echo $args['before_title'] . $title . $args['after_title']; 38 | } 39 | 40 | echo Social_Count_Plus_View::get_view(); 41 | 42 | echo $args['after_widget']; 43 | } 44 | 45 | /** 46 | * Back-end widget form. 47 | * 48 | * @see WP_Widget::form() 49 | * 50 | * @param array $instance Previously saved values from database. 51 | */ 52 | public function form( $instance ) { 53 | if ( isset( $instance['title'] ) ) { 54 | $title = $instance['title']; 55 | } else { 56 | $title = ''; 57 | } 58 | 59 | echo sprintf( '

    ', $this->get_field_id( 'title' ), __( 'Title', 'social-count-plus' ), $this->get_field_name( 'title' ), esc_attr( $title ) ); 60 | } 61 | 62 | /** 63 | * Sanitize widget form values as they are saved. 64 | * 65 | * @see WP_Widget::update() 66 | * 67 | * @param array $new_instance Values just sent to be saved. 68 | * @param array $old_instance Previously saved values from database. 69 | * 70 | * @return array Updated safe values to be saved. 71 | */ 72 | public function update( $new_instance, $old_instance ) { 73 | $instance = array(); 74 | $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : ''; 75 | 76 | return $instance; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-posts-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $post_type = ( isset( $settings['posts_post_type'] ) && ! empty( $settings['posts_post_type'] ) ) ? $settings['posts_post_type'] : 'posts'; 52 | $data = wp_count_posts( $post_type ); 53 | 54 | if ( is_wp_error( $data ) ) { 55 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 56 | } else { 57 | $count = intval( $data->publish ); 58 | 59 | $this->total = $count; 60 | } 61 | } 62 | 63 | return $this->total; 64 | } 65 | 66 | /** 67 | * Get conter view. 68 | * 69 | * @param array $settings Plugin settings. 70 | * @param int $total Counter total. 71 | * @param string $text_color Text color. 72 | * 73 | * @return string 74 | */ 75 | public function get_view( $settings, $total, $text_color ) { 76 | $post_type = ( isset( $settings['posts_post_type'] ) && ! empty( $settings['posts_post_type'] ) ) ? $settings['posts_post_type'] : 'post'; 77 | $post_object = get_post_type_object( $post_type ); 78 | $url = ! empty( $settings['posts_url'] ) ? $settings['posts_url'] : get_home_url(); 79 | 80 | unset( $settings['target_blank'] ); 81 | 82 | return $this->get_view_li( $url, $total, strtolower( $post_object->label ), $text_color, $settings ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-github-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( $this->api_url . sanitize_text_field( $settings['github_username'] ), array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) || 200 != $this->connection['response']['code'] ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $_data = json_decode( $this->connection['body'], true ); 57 | 58 | if ( isset( $_data['followers'] ) ) { 59 | $count = intval( $_data['followers'] ); 60 | 61 | $this->total = $count; 62 | } else { 63 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 64 | } 65 | } 66 | } 67 | 68 | return $this->total; 69 | } 70 | 71 | /** 72 | * Get conter view. 73 | * 74 | * @param array $settings Plugin settings. 75 | * @param int $total Counter total. 76 | * @param string $text_color Text color. 77 | * 78 | * @return string 79 | */ 80 | public function get_view( $settings, $total, $text_color ) { 81 | $github_username = ! empty( $settings['github_username'] ) ? $settings['github_username'] : ''; 82 | 83 | return $this->get_view_li( 'https://github.com/' . $github_username, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-vimeo-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( sprintf( $this->api_url, sanitize_text_field( $settings['vimeo_username'] ) ), array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) || 200 != $this->connection['response']['code'] ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $_data = json_decode( $this->connection['body'], true ); 57 | 58 | if ( isset( $_data['total_contacts'] ) ) { 59 | $count = intval( $_data['total_contacts'] ); 60 | 61 | $this->total = $count; 62 | } else { 63 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 64 | } 65 | } 66 | } 67 | 68 | return $this->total; 69 | } 70 | 71 | /** 72 | * Get conter view. 73 | * 74 | * @param array $settings Plugin settings. 75 | * @param int $total Counter total. 76 | * @param string $text_color Text color. 77 | * 78 | * @return string 79 | */ 80 | public function get_view( $settings, $total, $text_color ) { 81 | $vimeo_username = ! empty( $settings['vimeo_username'] ) ? $settings['vimeo_username'] : ''; 82 | 83 | return $this->get_view_li( 'https://vimeo.com/' . $vimeo_username, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-steam-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( $this->api_url . $settings['steam_group_name'] . '/memberslistxml/?xml=1', array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) || '400' <= $this->connection['response']['code'] ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | try { 57 | $xml = @new SimpleXmlElement( $this->connection['body'], LIBXML_NOCDATA ); 58 | $count = intval( $xml->groupDetails->memberCount ); 59 | 60 | $this->total = $count; 61 | } catch ( Exception $e ) { 62 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 63 | } 64 | } 65 | } 66 | 67 | return $this->total; 68 | } 69 | 70 | /** 71 | * Get conter view. 72 | * 73 | * @param array $settings Plugin settings. 74 | * @param int $total Counter total. 75 | * @param string $text_color Text color. 76 | * 77 | * @return string 78 | */ 79 | public function get_view( $settings, $total, $text_color ) { 80 | $steam_group_name = ! empty( $settings['steam_group_name'] ) ? $settings['steam_group_name'] : ''; 81 | 82 | return $this->get_view_li( 'https://steamcommunity.com/groups/' . $steam_group_name, $total, __( 'members', 'social-count-plus' ), $text_color, $settings ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /includes/class-social-count-plus-generator.php: -------------------------------------------------------------------------------- 1 | id ] = $_counter->get_total( $settings, $cache ); 69 | } 70 | 71 | // Update plugin extra cache. 72 | update_option( self::$cache, $total ); 73 | 74 | // Update counter transient. 75 | set_transient( self::$transient, $total, apply_filters( 'social_count_plus_transient_time', 60*60*24 ) ); // 24 hours. 76 | 77 | return $total; 78 | } 79 | 80 | /** 81 | * Delete the counters. 82 | */ 83 | public static function delete_count() { 84 | delete_transient( self::$transient ); 85 | } 86 | 87 | /** 88 | * Reset the counters. 89 | */ 90 | public static function reset_count() { 91 | self::delete_count(); 92 | self::get_count(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-googleplus-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( $this->api_url . $settings['googleplus_id'] . '?key=' . $settings['googleplus_api_key'], array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) || '400' <= $this->connection['response']['code'] ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $_data = json_decode( $this->connection['body'], true ); 57 | 58 | if ( isset( $_data['circledByCount'] ) ) { 59 | $count = intval( $_data['circledByCount'] ); 60 | 61 | $this->total = $count; 62 | } else { 63 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 64 | } 65 | } 66 | } 67 | 68 | return $this->total; 69 | } 70 | 71 | /** 72 | * Get conter view. 73 | * 74 | * @param array $settings Plugin settings. 75 | * @param int $total Counter total. 76 | * @param string $text_color Text color. 77 | * 78 | * @return string 79 | */ 80 | public function get_view( $settings, $total, $text_color ) { 81 | $googleplus_id = ! empty( $settings['googleplus_id'] ) ? $settings['googleplus_id'] : ''; 82 | 83 | return $this->get_view_li( 'https://plus.google.com/' . $googleplus_id, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-soundcloud-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( $this->api_url . $settings['soundcloud_username'] . '.json?client_id=' . $settings['soundcloud_client_id'], array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) || '400' <= $this->connection['response']['code'] ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $response = json_decode( $this->connection['body'], true ); 57 | 58 | if ( isset( $response['followers_count'] ) ) { 59 | $count = intval( $response['followers_count'] ); 60 | 61 | $this->total = $count; 62 | } else { 63 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 64 | } 65 | } 66 | } 67 | 68 | return $this->total; 69 | } 70 | 71 | /** 72 | * Get conter view. 73 | * 74 | * @param array $settings Plugin settings. 75 | * @param int $total Counter total. 76 | * @param string $text_color Text color. 77 | * 78 | * @return string 79 | */ 80 | public function get_view( $settings, $total, $text_color ) { 81 | $soundcloud_username = ! empty( $settings['soundcloud_username'] ) ? $settings['soundcloud_username'] : ''; 82 | 83 | return $this->get_view_li( 'https://soundcloud.com/' . $soundcloud_username, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-twitch-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $params = array( 52 | 'timeout' => 60, 53 | ); 54 | 55 | $this->connection = wp_remote_get( esc_url_raw( $this->api_url . $settings['twitch_username'] . '?client_id=' . $settings['twitch_client_ID'] ), $params ); 56 | 57 | if ( is_wp_error( $this->connection ) || ( isset( $this->connection['response']['code'] ) && 200 != $this->connection['response']['code'] ) ) { 58 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 59 | } else { 60 | $_data = json_decode( $this->connection['body'], true ); 61 | 62 | if ( isset( $_data['followers'] ) ) { 63 | $count = intval( $_data['followers'] ); 64 | 65 | $this->total = $count; 66 | } else { 67 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 68 | } 69 | } 70 | } 71 | 72 | return $this->total; 73 | } 74 | 75 | /** 76 | * Get conter view. 77 | * 78 | * @param array $settings Plugin settings. 79 | * @param int $total Counter total. 80 | * @param string $text_color Text color. 81 | * 82 | * @return string 83 | */ 84 | public function get_view( $settings, $total, $text_color ) { 85 | $twitch_username = ! empty( $settings['twitch_username'] ) ? $settings['twitch_username'] : ''; 86 | 87 | return $this->get_view_li( 'http://www.twitch.tv/' . $twitch_username . '/profile', $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-linkedin-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $params = array( 52 | 'timeout' => 60, 53 | 'headers' => array( 54 | 'Authorization' => 'Bearer ' . sanitize_text_field( $settings['linkedin_access_token'] ) 55 | ) 56 | ); 57 | 58 | $this->connection = wp_remote_get( sprintf( $this->api_url, sanitize_text_field( $settings['linkedin_company_id'] ) ), $params ); 59 | 60 | if ( is_wp_error( $this->connection ) || 200 != $this->connection['response']['code'] ) { 61 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 62 | } else { 63 | $count = intval( $this->connection['body'] ); 64 | 65 | if ( 0 < $count ) { 66 | $this->total = $count; 67 | } else { 68 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 69 | } 70 | } 71 | } 72 | 73 | return $this->total; 74 | } 75 | 76 | /** 77 | * Get conter view. 78 | * 79 | * @param array $settings Plugin settings. 80 | * @param int $total Counter total. 81 | * @param string $text_color Text color. 82 | * 83 | * @return string 84 | */ 85 | public function get_view( $settings, $total, $text_color ) { 86 | $linkedin_company_id = ! empty( $settings['linkedin_company_id'] ) ? $settings['linkedin_company_id'] : ''; 87 | 88 | return $this->get_view_li( 'https://www.linkedin.com/company/' . $linkedin_company_id, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-youtube-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $url = sprintf( 52 | '%s?part=statistics&id=%s&key=%s', 53 | $this->api_url, 54 | sanitize_text_field( $settings['youtube_user'] ), 55 | sanitize_text_field( $settings['youtube_api_key'] ) 56 | ); 57 | 58 | $this->connection = wp_remote_get( $url, array( 'timeout' => 60 ) ); 59 | 60 | if ( is_wp_error( $this->connection ) || 400 <= $this->connection['response']['code'] ) { 61 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 62 | } else { 63 | $_data = json_decode( $this->connection['body'], true ); 64 | 65 | if ( isset( $_data['items'][0]['statistics']['subscriberCount'] ) ) { 66 | $count = intval( $_data['items'][0]['statistics']['subscriberCount'] ); 67 | 68 | $this->total = $count; 69 | } else { 70 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 71 | } 72 | } 73 | } 74 | 75 | return $this->total; 76 | } 77 | 78 | /** 79 | * Get conter view. 80 | * 81 | * @param array $settings Plugin settings. 82 | * @param int $total Counter total. 83 | * @param string $text_color Text color. 84 | * 85 | * @return string 86 | */ 87 | public function get_view( $settings, $total, $text_color ) { 88 | $youtube_url = ! empty( $settings['youtube_url'] ) ? $settings['youtube_url'] : ''; 89 | 90 | return $this->get_view_li( $youtube_url, $total, __( 'subscribers', 'social-count-plus' ), $text_color, $settings ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-instagram-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( $this->api_url . $settings['instagram_user_id'] . '/?access_token=' . $settings['instagram_access_token'], array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) || '400' <= $this->connection['response']['code'] ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $response = json_decode( $this->connection['body'], true ); 57 | 58 | if ( 59 | isset( $response['meta']['code'] ) 60 | && 200 == $response['meta']['code'] 61 | && isset( $response['data']['counts']['followed_by'] ) 62 | ) { 63 | $count = intval( $response['data']['counts']['followed_by'] ); 64 | 65 | $this->total = $count; 66 | } else { 67 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 68 | } 69 | } 70 | } 71 | 72 | return $this->total; 73 | } 74 | 75 | /** 76 | * Get conter view. 77 | * 78 | * @param array $settings Plugin settings. 79 | * @param int $total Counter total. 80 | * @param string $text_color Text color. 81 | * 82 | * @return string 83 | */ 84 | public function get_view( $settings, $total, $text_color ) { 85 | $instagram_username = ! empty( $settings['instagram_username'] ) ? $settings['instagram_username'] : ''; 86 | 87 | return $this->get_view_li( 'https://instagram.com/' . $instagram_username, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-pinterest-counter.php: -------------------------------------------------------------------------------- 1 | is_available( $settings ) ) { 51 | $this->connection = wp_remote_get( $this->api_url . sanitize_text_field( $settings['pinterest_username'] ), array( 'timeout' => 60 ) ); 52 | 53 | if ( is_wp_error( $this->connection ) ) { 54 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 55 | } else { 56 | $count = 0; 57 | 58 | if ( 200 == $this->connection['response']['code'] ) { 59 | $tags = array(); 60 | $regex = '/property\=\"pinterestapp:followers\" name\=\"pinterestapp:followers\" content\=\"(.*?)" data-app/'; 61 | preg_match( $regex, $this->connection['body'], $tags ); 62 | 63 | $count = isset( $tags[1] ) ? intval( $tags[1] ) : 0; 64 | } 65 | 66 | if ( 0 < $count ) { 67 | $this->total = $count; 68 | } else { 69 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 70 | } 71 | 72 | // Just to make the system report more clear... 73 | $this->connection['body'] = '{"followers":' . $count . '}'; 74 | } 75 | } 76 | 77 | return $this->total; 78 | } 79 | 80 | /** 81 | * Get conter view. 82 | * 83 | * @param array $settings Plugin settings. 84 | * @param int $total Counter total. 85 | * @param string $text_color Text color. 86 | * 87 | * @return string 88 | */ 89 | public function get_view( $settings, $total, $text_color ) { 90 | $pinterest_username = ! empty( $settings['pinterest_username'] ) ? $settings['pinterest_username'] : ''; 91 | 92 | return $this->get_view_li( 'https://www.pinterest.com/' . $pinterest_username, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /assets/sass/counter.scss: -------------------------------------------------------------------------------- 1 | @import "compass/css3"; 2 | @import "compass/utilities/general/clearfix"; 3 | 4 | /* General styles */ 5 | .social-count-plus { 6 | @include pie-clearfix(); 7 | 8 | .clear { 9 | clear: both; 10 | } 11 | 12 | ul { 13 | border: none !important; 14 | list-style: none !important; 15 | margin: 0; 16 | padding: 0; 17 | } 18 | 19 | li { 20 | background: none !important; 21 | border: none !important; 22 | clear: none !important; 23 | float: left; 24 | list-style: none !important; 25 | margin: 0; 26 | padding: 0 0 20px; 27 | text-align: center; 28 | width: 60px; 29 | } 30 | 31 | .vertical li { 32 | @include pie-clearfix(); 33 | display: block; 34 | float: none; 35 | padding-bottom: 10px; 36 | text-align: left; 37 | width: 100%; 38 | } 39 | 40 | span { 41 | display: block; 42 | margin: 0; 43 | padding: 0; 44 | } 45 | 46 | /* Icons */ 47 | a { 48 | @include transition(all 0.4s ease); 49 | display: block; 50 | margin: 0 auto; 51 | opacity: 1; 52 | padding: 0 !important; 53 | } 54 | 55 | a:hover { 56 | opacity: 0.7; 57 | } 58 | 59 | .default a { 60 | background-color: transparent !important; 61 | background-image: url('../images/sprite-default.png') !important; 62 | background-repeat: no-repeat !important; 63 | height: 32px !important; 64 | width: 32px !important; 65 | } 66 | 67 | .circle a { 68 | background-image: url('../images/sprite-circle.png') !important; 69 | height: 37px !important; 70 | width: 36px !important; 71 | } 72 | 73 | .flat a { 74 | background-image: url('../images/sprite-flat.png') !important; 75 | height: 32px !important; 76 | width: 32px !important; 77 | } 78 | 79 | .vertical a { 80 | float: left; 81 | } 82 | 83 | .vertical .items { 84 | float: left; 85 | margin-left: 10px; 86 | text-align: left; 87 | } 88 | 89 | /* Counters */ 90 | .count { 91 | display: block; 92 | font-size: 14px; 93 | font-weight: bold; 94 | line-height: 16px; 95 | margin: 5px 0 0; 96 | padding: 0; 97 | } 98 | 99 | .vertical .count { 100 | margin-top: 3px; 101 | } 102 | 103 | /* Labels */ 104 | .label { 105 | font-size: 9px; 106 | font-weight: normal; 107 | line-height: 16px; 108 | text-transform: capitalize; 109 | } 110 | 111 | /* Sprites */ 112 | $icons: twitter facebook youtube googleplus posts comments instagram steam soundcloud twitch linkedin pinterest vimeo users tumblr github; 113 | $i: 0; 114 | @each $icon in $icons { 115 | .default .count-#{$icon} a { 116 | background-position: (-32px*$i) 0 !important; 117 | } 118 | 119 | .circle .count-#{$icon} a { 120 | background-position: (-36px*$i) 0 !important; 121 | } 122 | 123 | .flat .count-#{$icon} a { 124 | background-position: (-32px*$i) 0 !important; 125 | } 126 | 127 | $i: $i+1; 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /includes/abstracts/abstract-social-count-plus-counter.php: -------------------------------------------------------------------------------- 1 | total; 58 | } 59 | 60 | /** 61 | * Get the li element. 62 | * 63 | * @param string $url Item url. 64 | * @param int $count Item count. 65 | * @param string $label Item label. 66 | * @param array $settings Item settings. 67 | * 68 | * @return string HTML li element. 69 | */ 70 | protected function get_view_li( $url, $count, $label, $color, $settings ) { 71 | $target_blank = isset( $settings['target_blank'] ) ? ' target="_blank"' : ''; 72 | $styles = ! empty( $color ) ? ' style="color: ' . $color . ' !important;"' : ''; 73 | 74 | $html = sprintf( '
  • ', $this->id ); 75 | $html .= sprintf( '', esc_url( $url ), $target_blank ); 76 | $html .= ''; 77 | $html .= sprintf( '%s', $styles, apply_filters( 'social_count_plus_number_format', $count ) ); 78 | $html .= sprintf( '%s', $styles, apply_filters( 'social_count_plus_label', $label, $this->id ) ); 79 | $html .= ''; 80 | $html .= '
  • '; 81 | 82 | return apply_filters( 'social_count_plus_get_view_li', $html, $url, $count, $label, $color, $settings, $this->id ); 83 | } 84 | 85 | /** 86 | * Get conter view. 87 | * 88 | * @param array $settings Plugin settings. 89 | * @param int $total Counter total. 90 | * @param string $text_color Text color. 91 | * 92 | * @return string 93 | */ 94 | public function get_view( $settings, $total, $text_color ) { 95 | return ''; 96 | } 97 | 98 | /** 99 | * Debug. 100 | * 101 | * @return array 102 | */ 103 | public function debug() { 104 | return $this->connection; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /includes/admin/views/html-settings-system-status-page.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 53 | 54 | 59 | 60 | 61 | 60 ) ); 65 | 66 | if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) { 67 | $remote_status = 'yes'; 68 | $remote_note = __( 'wp_remote_get() was successful.', 'social-count-plus' ); 69 | } elseif ( is_wp_error( $response ) ) { 70 | $remote_note = __( 'wp_remote_get() failed. This plugin won\'t work with your server. Contact your hosting provider. Error:', 'social-count-plus' ) . ' ' . $response->get_error_message(); 71 | } 72 | ?> 73 | 74 | 79 | 80 | 81 |
    :
    :
    :
    :
    :
    : 55 | 56 | 57 | 58 |
    : 75 | 76 | 77 | 78 |
    82 | 83 |

    84 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-facebook-counter.php: -------------------------------------------------------------------------------- 1 | api_url, 52 | sanitize_text_field( $settings['facebook_app_id'] ), 53 | sanitize_text_field( $settings['facebook_app_secret'] ) 54 | ); 55 | $access_token = wp_remote_get( $url, array( 'timeout' => 60 ) ); 56 | 57 | if ( is_wp_error( $access_token ) || ( isset( $access_token['response']['code'] ) && 200 != $access_token['response']['code'] ) ) { 58 | return ''; 59 | } else { 60 | $access_token = json_decode( $access_token['body'], true ); 61 | return sanitize_text_field( $access_token['access_token'] ); 62 | } 63 | } 64 | 65 | /** 66 | * Get the total. 67 | * 68 | * @param array $settings Plugin settings. 69 | * @param array $cache Counter cache. 70 | * 71 | * @return int 72 | */ 73 | public function get_total( $settings, $cache ) { 74 | if ( $this->is_available( $settings ) ) { 75 | $access_token = $this->get_access_token( $settings ); 76 | $url = sprintf( 77 | '%s%s?fields=fan_count&access_token=%s', 78 | $this->api_url . '/v2.7/', 79 | sanitize_text_field( $settings['facebook_id'] ), 80 | $access_token 81 | ); 82 | 83 | $this->connection = wp_remote_get( $url, array( 'timeout' => 60 ) ); 84 | 85 | if ( is_wp_error( $this->connection ) || ( isset( $this->connection['response']['code'] ) && 200 != $this->connection['response']['code'] ) ) { 86 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 87 | } else { 88 | $_data = json_decode( $this->connection['body'], true ); 89 | 90 | if ( isset( $_data['fan_count'] ) ) { 91 | $count = intval( $_data['fan_count'] ); 92 | 93 | $this->total = $count; 94 | } else { 95 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 96 | } 97 | } 98 | } 99 | 100 | return $this->total; 101 | } 102 | 103 | /** 104 | * Get conter view. 105 | * 106 | * @param array $settings Plugin settings. 107 | * @param int $total Counter total. 108 | * @param string $text_color Text color. 109 | * 110 | * @return string 111 | */ 112 | public function get_view( $settings, $total, $text_color ) { 113 | $facebook_id = ! empty( $settings['facebook_id'] ) ? $settings['facebook_id'] : ''; 114 | 115 | return $this->get_view_li( 'https://www.facebook.com/' . $facebook_id, $total, __( 'likes', 'social-count-plus' ), $text_color, $settings ); 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /includes/social-count-plus-deprecated-functions.php: -------------------------------------------------------------------------------- 1 | includes(); 52 | $this->include_counters(); 53 | 54 | if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { 55 | $this->admin_includes(); 56 | } 57 | 58 | // Widget. 59 | add_action( 'widgets_init', array( $this, 'register_widget' ) ); 60 | 61 | // Shortcode. 62 | add_shortcode( 'scp', array( 'Social_Count_Plus_Shortcodes', 'counter' ) ); 63 | 64 | // Scripts. 65 | add_action( 'wp_enqueue_scripts', array( $this, 'styles_and_scripts' ) ); 66 | } 67 | 68 | /** 69 | * Return an instance of this class. 70 | * 71 | * @return object A single instance of this class. 72 | */ 73 | public static function get_instance() { 74 | if ( null == self::$instance ) { 75 | self::$instance = new self; 76 | } 77 | 78 | return self::$instance; 79 | } 80 | 81 | /** 82 | * Load the plugin text domain for translation. 83 | */ 84 | public function load_plugin_textdomain() { 85 | load_plugin_textdomain( 'social-count-plus', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 86 | } 87 | 88 | /** 89 | * Include admin actions. 90 | */ 91 | protected function admin_includes() { 92 | include dirname( __FILE__ ) . '/includes/admin/class-social-count-plus-admin.php'; 93 | } 94 | 95 | /** 96 | * Include plugin functions. 97 | */ 98 | protected function includes() { 99 | include_once dirname( __FILE__ ) . '/includes/class-social-count-plus-generator.php'; 100 | include_once dirname( __FILE__ ) . '/includes/abstracts/abstract-social-count-plus-counter.php'; 101 | include_once dirname( __FILE__ ) . '/includes/class-social-count-plus-view.php'; 102 | include_once dirname( __FILE__ ) . '/includes/class-social-count-plus-widget.php'; 103 | include_once dirname( __FILE__ ) . '/includes/class-social-count-plus-shortcodes.php'; 104 | include_once dirname( __FILE__ ) . '/includes/social-count-plus-functions.php'; 105 | include_once dirname( __FILE__ ) . '/includes/social-count-plus-deprecated-functions.php'; 106 | } 107 | 108 | /** 109 | * Include counters. 110 | */ 111 | protected function include_counters() { 112 | foreach ( glob( realpath( dirname( __FILE__ ) ) . '/includes/counters/*.php' ) as $filename ) { 113 | include_once $filename; 114 | } 115 | } 116 | 117 | /** 118 | * Register widget. 119 | */ 120 | public function register_widget() { 121 | register_widget( 'SocialCountPlus' ); 122 | } 123 | 124 | /** 125 | * Register public styles and scripts. 126 | */ 127 | public function styles_and_scripts() { 128 | wp_register_style( 'social-count-plus', plugins_url( 'assets/css/counter.css', __FILE__ ), array(), Social_Count_Plus::VERSION, 'all' ); 129 | } 130 | } 131 | 132 | /** 133 | * Init the plugin. 134 | */ 135 | add_action( 'plugins_loaded', array( 'Social_Count_Plus', 'get_instance' ) ); 136 | 137 | endif; 138 | -------------------------------------------------------------------------------- /assets/css/counter.css: -------------------------------------------------------------------------------- 1 | .social-count-plus{*zoom:1}.social-count-plus:after{content:"";display:table;clear:both}.social-count-plus .clear{clear:both}.social-count-plus ul{border:none !important;list-style:none !important;margin:0;padding:0}.social-count-plus li{background:none !important;border:none !important;clear:none !important;float:left;list-style:none !important;margin:0;padding:0 0 20px;text-align:center;width:60px}.social-count-plus .vertical li{*zoom:1;display:block;float:none;padding-bottom:10px;text-align:left;width:100%}.social-count-plus .vertical li:after{content:"";display:table;clear:both}.social-count-plus span{display:block;margin:0;padding:0}.social-count-plus a{-moz-transition:all .4s ease;-o-transition:all .4s ease;-webkit-transition:all .4s ease;transition:all .4s ease;display:block;margin:0 auto;opacity:1;padding:0 !important}.social-count-plus a:hover{opacity:0.7}.social-count-plus .default a{background-color:transparent !important;background-image:url("../images/sprite-default.png") !important;background-repeat:no-repeat !important;height:32px !important;width:32px !important}.social-count-plus .circle a{background-image:url("../images/sprite-circle.png") !important;height:37px !important;width:36px !important}.social-count-plus .flat a{background-image:url("../images/sprite-flat.png") !important;height:32px !important;width:32px !important}.social-count-plus .vertical a{float:left}.social-count-plus .vertical .items{float:left;margin-left:10px;text-align:left}.social-count-plus .count{display:block;font-size:14px;font-weight:bold;line-height:16px;margin:5px 0 0;padding:0}.social-count-plus .vertical .count{margin-top:3px}.social-count-plus .label{font-size:9px;font-weight:normal;line-height:16px;text-transform:capitalize}.social-count-plus .default .count-twitter a{background-position:0px 0 !important}.social-count-plus .circle .count-twitter a{background-position:0px 0 !important}.social-count-plus .flat .count-twitter a{background-position:0px 0 !important}.social-count-plus .default .count-facebook a{background-position:-32px 0 !important}.social-count-plus .circle .count-facebook a{background-position:-36px 0 !important}.social-count-plus .flat .count-facebook a{background-position:-32px 0 !important}.social-count-plus .default .count-youtube a{background-position:-64px 0 !important}.social-count-plus .circle .count-youtube a{background-position:-72px 0 !important}.social-count-plus .flat .count-youtube a{background-position:-64px 0 !important}.social-count-plus .default .count-googleplus a{background-position:-96px 0 !important}.social-count-plus .circle .count-googleplus a{background-position:-108px 0 !important}.social-count-plus .flat .count-googleplus a{background-position:-96px 0 !important}.social-count-plus .default .count-posts a{background-position:-128px 0 !important}.social-count-plus .circle .count-posts a{background-position:-144px 0 !important}.social-count-plus .flat .count-posts a{background-position:-128px 0 !important}.social-count-plus .default .count-comments a{background-position:-160px 0 !important}.social-count-plus .circle .count-comments a{background-position:-180px 0 !important}.social-count-plus .flat .count-comments a{background-position:-160px 0 !important}.social-count-plus .default .count-instagram a{background-position:-192px 0 !important}.social-count-plus .circle .count-instagram a{background-position:-216px 0 !important}.social-count-plus .flat .count-instagram a{background-position:-192px 0 !important}.social-count-plus .default .count-steam a{background-position:-224px 0 !important}.social-count-plus .circle .count-steam a{background-position:-252px 0 !important}.social-count-plus .flat .count-steam a{background-position:-224px 0 !important}.social-count-plus .default .count-soundcloud a{background-position:-256px 0 !important}.social-count-plus .circle .count-soundcloud a{background-position:-288px 0 !important}.social-count-plus .flat .count-soundcloud a{background-position:-256px 0 !important}.social-count-plus .default .count-twitch a{background-position:-288px 0 !important}.social-count-plus .circle .count-twitch a{background-position:-324px 0 !important}.social-count-plus .flat .count-twitch a{background-position:-288px 0 !important}.social-count-plus .default .count-linkedin a{background-position:-320px 0 !important}.social-count-plus .circle .count-linkedin a{background-position:-360px 0 !important}.social-count-plus .flat .count-linkedin a{background-position:-320px 0 !important}.social-count-plus .default .count-pinterest a{background-position:-352px 0 !important}.social-count-plus .circle .count-pinterest a{background-position:-396px 0 !important}.social-count-plus .flat .count-pinterest a{background-position:-352px 0 !important}.social-count-plus .default .count-vimeo a{background-position:-384px 0 !important}.social-count-plus .circle .count-vimeo a{background-position:-432px 0 !important}.social-count-plus .flat .count-vimeo a{background-position:-384px 0 !important}.social-count-plus .default .count-users a{background-position:-416px 0 !important}.social-count-plus .circle .count-users a{background-position:-468px 0 !important}.social-count-plus .flat .count-users a{background-position:-416px 0 !important}.social-count-plus .default .count-tumblr a{background-position:-448px 0 !important}.social-count-plus .circle .count-tumblr a{background-position:-504px 0 !important}.social-count-plus .flat .count-tumblr a{background-position:-448px 0 !important}.social-count-plus .default .count-github a{background-position:-480px 0 !important}.social-count-plus .circle .count-github a{background-position:-540px 0 !important}.social-count-plus .flat .count-github a{background-position:-480px 0 !important} 2 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* jshint node:true */ 2 | var expandHomeDir = require( 'expand-home-dir' ); 3 | 4 | module.exports = function( grunt ) { 5 | 6 | grunt.initConfig({ 7 | 8 | // gets the package vars 9 | pkg: grunt.file.readJSON( 'package.json' ), 10 | 11 | // plugin directories 12 | dirs: { 13 | js: 'assets/js', 14 | css: 'assets/css', 15 | sass: 'assets/sass', 16 | images: 'assets/images', 17 | fonts: 'assets/fonts' 18 | }, 19 | 20 | // svn settings 21 | svn_settings: { 22 | path: expandHomeDir( '~/Projects/wordpress-plugins-svn/' ) + '<%= pkg.name %>', 23 | tag: '<%= svn_settings.path %>/tags/<%= pkg.version %>', 24 | trunk: '<%= svn_settings.path %>/trunk', 25 | exclude: [ 26 | '.tx/', 27 | '.editorconfig', 28 | '.git/', 29 | '.gitignore', 30 | '.jshintrc', 31 | '.sass-cache/', 32 | 'PSDs/', 33 | 'node_modules/', 34 | 'assets/sass/', 35 | 'Gruntfile.js', 36 | 'README.md', 37 | 'package.json', 38 | '*.zip' 39 | ] 40 | }, 41 | 42 | // javascript linting with jshint 43 | jshint: { 44 | options: { 45 | jshintrc: '.jshintrc' 46 | }, 47 | all: [ 48 | 'Gruntfile.js', 49 | '<%= dirs.js %>/admin.js' 50 | ] 51 | }, 52 | 53 | // uglify to concat and minify 54 | uglify: { 55 | dist: { 56 | files: [{ 57 | expand: true, 58 | cwd: '<%= dirs.js %>/', 59 | src: [ 60 | '*.js', 61 | '!*.min.js' 62 | ], 63 | dest: '<%= dirs.js %>/', 64 | ext: '.min.js' 65 | }] 66 | } 67 | }, 68 | 69 | // compass and scss 70 | compass: { 71 | options: { 72 | httpPath: '', 73 | environment: 'production', 74 | relativeAssets: true, 75 | noLineComments: true, 76 | outputStyle: 'compressed' 77 | }, 78 | dist: { 79 | options: { 80 | sassDir: '<%= dirs.sass %>', 81 | cssDir: '<%= dirs.css %>', 82 | imagesDir: '<%= dirs.images %>', 83 | javascriptsDir: '<%= dirs.js %>', 84 | fontsDir: '<%= dirs.fonts %>' 85 | } 86 | } 87 | }, 88 | 89 | // watch for changes and trigger compass, jshint and uglify 90 | watch: { 91 | compass: { 92 | files: [ 93 | '<%= compass.dist.options.sassDir %>/**' 94 | ], 95 | tasks: ['compass'] 96 | }, 97 | js: { 98 | files: [ 99 | '<%= jshint.all %>' 100 | ], 101 | tasks: ['jshint', 'uglify'] 102 | } 103 | }, 104 | 105 | // image optimization 106 | imagemin: { 107 | dist: { 108 | options: { 109 | optimizationLevel: 7, 110 | progressive: true 111 | }, 112 | files: [ 113 | { 114 | expand: true, 115 | cwd: '<%= dirs.images %>/', 116 | src: '*.png', 117 | dest: '<%= dirs.images %>/' 118 | } 119 | ] 120 | } 121 | }, 122 | 123 | makepot: { 124 | dist: { 125 | options: { 126 | type: 'wp-plugin', 127 | potHeaders: { 128 | 'report-msgid-bugs-to': 'https://wordpress.org/plugins/woocommerce-domination/', 129 | 'language-team': 'LANGUAGE ' 130 | } 131 | } 132 | } 133 | }, 134 | 135 | checktextdomain: { 136 | options:{ 137 | text_domain: '<%= pkg.name %>', 138 | keywords: [ 139 | '__:1,2d', 140 | '_e:1,2d', 141 | '_x:1,2c,3d', 142 | 'esc_html__:1,2d', 143 | 'esc_html_e:1,2d', 144 | 'esc_html_x:1,2c,3d', 145 | 'esc_attr__:1,2d', 146 | 'esc_attr_e:1,2d', 147 | 'esc_attr_x:1,2c,3d', 148 | '_ex:1,2c,3d', 149 | '_n:1,2,4d', 150 | '_nx:1,2,4c,5d', 151 | '_n_noop:1,2,3d', 152 | '_nx_noop:1,2,3c,4d' 153 | ] 154 | }, 155 | files: { 156 | src: [ 157 | '**/*.php', // Include all files 158 | '!node_modules/**' // Exclude node_modules/ 159 | ], 160 | expand: true 161 | } 162 | }, 163 | 164 | // rsync commands used to take the files to svn repository 165 | rsync: { 166 | options: { 167 | args: ['--verbose'], 168 | exclude: '<%= svn_settings.exclude %>', 169 | syncDest: true, 170 | recursive: true 171 | }, 172 | tag: { 173 | options: { 174 | src: './', 175 | dest: '<%= svn_settings.tag %>' 176 | } 177 | }, 178 | trunk: { 179 | options: { 180 | src: './', 181 | dest: '<%= svn_settings.trunk %>' 182 | } 183 | } 184 | }, 185 | 186 | // shell command to commit the new version of the plugin 187 | shell: { 188 | // Remove delete files. 189 | svn_remove: { 190 | command: 'svn st | grep \'^!\' | awk \'{print $2}\' | xargs svn --force delete', 191 | options: { 192 | stdout: true, 193 | stderr: true, 194 | execOptions: { 195 | cwd: '<%= svn_settings.path %>' 196 | } 197 | } 198 | }, 199 | // Add new files. 200 | svn_add: { 201 | command: 'svn add --force * --auto-props --parents --depth infinity -q', 202 | options: { 203 | stdout: true, 204 | stderr: true, 205 | execOptions: { 206 | cwd: '<%= svn_settings.path %>' 207 | } 208 | } 209 | }, 210 | // Commit the changes. 211 | svn_commit: { 212 | command: 'svn commit -m "updated the plugin version to <%= pkg.version %>"', 213 | options: { 214 | stdout: true, 215 | stderr: true, 216 | execOptions: { 217 | cwd: '<%= svn_settings.path %>' 218 | } 219 | } 220 | } 221 | } 222 | }); 223 | 224 | // Load tasks 225 | grunt.loadNpmTasks( 'grunt-contrib-watch' ); 226 | grunt.loadNpmTasks( 'grunt-contrib-jshint' ); 227 | grunt.loadNpmTasks( 'grunt-contrib-uglify' ); 228 | grunt.loadNpmTasks( 'grunt-contrib-compass' ); 229 | grunt.loadNpmTasks( 'grunt-contrib-imagemin' ); 230 | grunt.loadNpmTasks( 'grunt-checktextdomain' ); 231 | grunt.loadNpmTasks( 'grunt-wp-i18n' ); 232 | grunt.loadNpmTasks( 'grunt-rsync' ); 233 | grunt.loadNpmTasks( 'grunt-shell' ); 234 | 235 | // default task 236 | grunt.registerTask( 'default', [ 237 | 'jshint', 238 | 'compass', 239 | 'uglify' 240 | ] ); 241 | 242 | // deploy task 243 | grunt.registerTask( 'deploy', [ 244 | 'default', 245 | 'rsync:tag', 246 | 'rsync:trunk', 247 | 'shell:svn_remove', 248 | 'shell:svn_add', 249 | 'shell:svn_commit' 250 | ] ); 251 | }; 252 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-twitter-counter.php: -------------------------------------------------------------------------------- 1 | signature( $query, $consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret ); 44 | 45 | return $this->header( $signature ); 46 | } 47 | 48 | /** 49 | * Build the Signature base string. 50 | * 51 | * @param string $url Request URL. 52 | * @param string $query Request query. 53 | * @param string $method Request method. 54 | * @param string $params OAuth params. 55 | * 56 | * @return string OAuth Signature base. 57 | */ 58 | private function signature_base_string( $url, $query, $method, $params ) { 59 | $return = array(); 60 | ksort( $params ); 61 | 62 | foreach( $params as $key => $value ) { 63 | $return[] = $key . '=' . $value; 64 | } 65 | 66 | return $method . '&' . rawurlencode( $url ) . '&' . rawurlencode( implode( '&', $return ) ) . '%26' . rawurlencode( $query ); 67 | } 68 | 69 | /** 70 | * Build the OAuth Signature. 71 | * 72 | * @param string $query Request query. 73 | * @param string $consumer_key Twitter customer key. 74 | * @param string $consumer_secret Twitter customer secret. 75 | * @param string $oauth_access_token OAuth access token. 76 | * @param string $oauth_access_token_secret OAuth access token secret. 77 | * 78 | * @return array OAuth signature params. 79 | */ 80 | private function signature( $query, $consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret ) { 81 | $oauth = array( 82 | 'oauth_consumer_key' => $consumer_key, 83 | 'oauth_nonce' => hash_hmac( 'sha1', time(), '1', false ), 84 | 'oauth_signature_method' => 'HMAC-SHA1', 85 | 'oauth_token' => $oauth_access_token, 86 | 'oauth_timestamp' => time(), 87 | 'oauth_version' => '1.0' 88 | ); 89 | 90 | $base_info = $this->signature_base_string( $this->api_url, $query, 'GET', $oauth ); 91 | $composite_key = rawurlencode( $consumer_secret ) . '&' . rawurlencode( $oauth_access_token_secret ); 92 | $oauth_signature = base64_encode( hash_hmac( 'sha1', $base_info, $composite_key, true ) ); 93 | $oauth['oauth_signature'] = $oauth_signature; 94 | 95 | return $oauth; 96 | } 97 | 98 | /** 99 | * Build the header. 100 | * 101 | * @param array $signature OAuth signature. 102 | * 103 | * @return string OAuth Authorization. 104 | */ 105 | public function header( $signature ) { 106 | $return = 'OAuth '; 107 | $values = array(); 108 | 109 | foreach( $signature as $key => $value ) { 110 | $values[] = $key . '="' . rawurlencode( $value ) . '"'; 111 | } 112 | 113 | $return .= implode( ', ', $values ); 114 | 115 | return $return; 116 | } 117 | 118 | /** 119 | * Test the counter is available. 120 | * 121 | * @param array $settings Plugin settings. 122 | * 123 | * @return bool 124 | */ 125 | public function is_available( $settings ) { 126 | return ( isset( $settings['twitter_active'] ) && ! empty( $settings['twitter_user'] ) && ! empty( $settings['twitter_consumer_key'] ) && ! empty( $settings['twitter_consumer_secret'] ) && ! empty( $settings['twitter_access_token'] ) && ! empty( $settings['twitter_access_token_secret'] ) ); 127 | } 128 | 129 | /** 130 | * Get the total. 131 | * 132 | * @param array $settings Plugin settings. 133 | * @param array $cache Counter cache. 134 | * 135 | * @return int 136 | */ 137 | public function get_total( $settings, $cache ) { 138 | if ( $this->is_available( $settings ) ) { 139 | $user = $settings['twitter_user']; 140 | 141 | $params = array( 142 | 'method' => 'GET', 143 | 'timeout' => 60, 144 | 'headers' => array( 145 | 'Content-Type' => 'application/x-www-form-urlencoded', 146 | 'Authorization' => $this->authorization( 147 | $user, 148 | $settings['twitter_consumer_key'], 149 | $settings['twitter_consumer_secret'], 150 | $settings['twitter_access_token'], 151 | $settings['twitter_access_token_secret'] 152 | ) 153 | ) 154 | ); 155 | 156 | $this->connection = wp_remote_get( $this->api_url . '?screen_name=' . $user, $params ); 157 | 158 | if ( is_wp_error( $this->connection ) ) { 159 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 160 | } else { 161 | $_data = json_decode( $this->connection['body'], true ); 162 | 163 | if ( isset( $_data['followers_count'] ) ) { 164 | $count = intval( $_data['followers_count'] ); 165 | 166 | $this->total = $count; 167 | } else { 168 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 169 | } 170 | } 171 | } 172 | 173 | return $this->total; 174 | } 175 | 176 | /** 177 | * Get conter view. 178 | * 179 | * @param array $settings Plugin settings. 180 | * @param int $total Counter total. 181 | * @param string $text_color Text color. 182 | * 183 | * @return string 184 | */ 185 | public function get_view( $settings, $total, $text_color ) { 186 | $twitter_user = ! empty( $settings['twitter_user'] ) ? $settings['twitter_user'] : ''; 187 | 188 | return $this->get_view_li( 'https://twitter.com/' . $twitter_user, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 189 | } 190 | } 191 | -------------------------------------------------------------------------------- /includes/counters/class-social-count-plus-tumblr-counter.php: -------------------------------------------------------------------------------- 1 | signature( $hostname, $consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret ); 43 | 44 | return $this->header( $signature ); 45 | } 46 | 47 | /** 48 | * Build the Signature base string. 49 | * 50 | * @param string $url Request URL. 51 | * @param string $query Request query. 52 | * @param string $method Request method. 53 | * @param string $params OAuth params. 54 | * 55 | * @return string OAuth Signature base. 56 | */ 57 | private function signature_base_string( $url, $method, $params ) { 58 | $return = array(); 59 | ksort( $params ); 60 | 61 | foreach( $params as $key => $value ) { 62 | $return[] = $key . '=' . $value; 63 | } 64 | 65 | return $method . '&' . rawurlencode( $url ) . '&' . rawurlencode( implode( '&', $return ) ); 66 | } 67 | 68 | /** 69 | * Build the OAuth Signature. 70 | * 71 | * @param string $hostname hostname. 72 | * @param string $consumer_key Twitter customer key. 73 | * @param string $consumer_secret Twitter customer secret. 74 | * @param string $oauth_access_token OAuth access token. 75 | * @param string $oauth_access_token_secret OAuth access token secret. 76 | * 77 | * @return array OAuth signature params. 78 | */ 79 | private function signature( $hostname, $consumer_key, $consumer_secret, $oauth_access_token, $oauth_access_token_secret ) { 80 | $oauth = array( 81 | 'oauth_consumer_key' => $consumer_key, 82 | 'oauth_nonce' => hash_hmac( 'sha1', time(), '1', false ), 83 | 'oauth_signature_method' => 'HMAC-SHA1', 84 | 'oauth_token' => $oauth_access_token, 85 | 'oauth_timestamp' => time(), 86 | 'oauth_version' => '1.0' 87 | ); 88 | 89 | $base_info = $this->signature_base_string( sprintf( $this->api_url, $hostname ), 'GET', $oauth ); 90 | $composite_key = rawurlencode( $consumer_secret ) . '&' . rawurlencode( $oauth_access_token_secret ); 91 | $oauth_signature = base64_encode( hash_hmac( 'sha1', $base_info, $composite_key, true ) ); 92 | $oauth['oauth_signature'] = $oauth_signature; 93 | 94 | return $oauth; 95 | } 96 | 97 | /** 98 | * Build the header. 99 | * 100 | * @param array $signature OAuth signature. 101 | * 102 | * @return string OAuth Authorization. 103 | */ 104 | public function header( $signature ) { 105 | $return = 'OAuth '; 106 | $values = array(); 107 | 108 | foreach( $signature as $key => $value ) { 109 | $values[] = $key . '="' . rawurlencode( $value ) . '"'; 110 | } 111 | 112 | $return .= implode( ', ', $values ); 113 | 114 | return $return; 115 | } 116 | 117 | /** 118 | * Test the counter is available. 119 | * 120 | * @param array $settings Plugin settings. 121 | * 122 | * @return bool 123 | */ 124 | public function is_available( $settings ) { 125 | return isset( $settings['tumblr_active'] ) && ! empty( $settings['tumblr_hostname'] ) && ! empty( $settings['tumblr_consumer_key'] ) && ! empty( $settings['tumblr_consumer_secret'] ) && ! empty( $settings['tumblr_token'] ) && ! empty( $settings['tumblr_token_secret'] ); 126 | } 127 | 128 | /** 129 | * Get the total. 130 | * 131 | * @param array $settings Plugin settings. 132 | * @param array $cache Counter cache. 133 | * 134 | * @return int 135 | */ 136 | public function get_total( $settings, $cache ) { 137 | if ( $this->is_available( $settings ) ) { 138 | $hostname = str_replace( array( 'http:', 'https:', '/' ), '', sanitize_text_field( $settings['tumblr_hostname'] ) ); 139 | 140 | $params = array( 141 | 'method' => 'GET', 142 | 'timeout' => 60, 143 | 'headers' => array( 144 | 'Content-Type' => 'application/x-www-form-urlencoded', 145 | 'Authorization' => $this->authorization( 146 | $hostname, 147 | $settings['tumblr_consumer_key'], 148 | $settings['tumblr_consumer_secret'], 149 | $settings['tumblr_token'], 150 | $settings['tumblr_token_secret'] 151 | ) 152 | ) 153 | ); 154 | 155 | $this->connection = wp_remote_get( sprintf( $this->api_url, $hostname ), $params ); 156 | 157 | if ( is_wp_error( $this->connection ) || ( isset( $this->connection['response']['code'] ) && 200 != $this->connection['response']['code'] ) ) { 158 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 159 | } else { 160 | $_data = json_decode( $this->connection['body'], true ); 161 | 162 | if ( isset( $_data['response']['total_users'] ) ) { 163 | $count = intval( $_data['response']['total_users'] ); 164 | 165 | $this->total = $count; 166 | } else { 167 | $this->total = ( isset( $cache[ $this->id ] ) ) ? $cache[ $this->id ] : 0; 168 | } 169 | } 170 | } 171 | 172 | return $this->total; 173 | } 174 | 175 | /** 176 | * Get conter view. 177 | * 178 | * @param array $settings Plugin settings. 179 | * @param int $total Counter total. 180 | * @param string $text_color Text color. 181 | * 182 | * @return string 183 | */ 184 | public function get_view( $settings, $total, $text_color ) { 185 | $tumblr_hostname = ! empty( $settings['tumblr_hostname'] ) ? $settings['tumblr_hostname'] : ''; 186 | 187 | return $this->get_view_li( $tumblr_hostname, $total, __( 'followers', 'social-count-plus' ), $text_color, $settings ); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Social Count Plus === 2 | Contributors: claudiosanches, felipesantana, deblynprado 3 | Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y8HP99ZJ5Z59L 4 | Tags: counter, widget, shortcode, facebook, github, googleplus, instagram, linkedin, pinterest, soundcloud, steam, tumblr, twitch, twitter, vimeo, youtube 5 | Requires at least: 4.0 6 | Tested up to: 4.9 7 | Stable tag: 3.4.1 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | Displays your number of followers from Facebook, Google+, Instagram, Twitch, Twitter and several other social media websites. 12 | 13 | == Description == 14 | 15 | The Social Count Plus performs counting for: 16 | 17 | - Comments total 18 | - Facebook page fans 19 | - GitHub followers 20 | - Google+ page/profile followers 21 | - Instagram followers 22 | - LinkedIn company followers 23 | - Pinterest followers 24 | - Posts total 25 | - SoundCloud followers 26 | - Steam Community group members 27 | - Tumblr followers 28 | - Twitch channel followers 29 | - Twitter followers 30 | - Users total 31 | - Vimeo followers 32 | 33 | You can display your numbers using a Widget (with links and icons) or Shortcodes (to be used in posts and pages) or PHP functions in your theme. 34 | 35 | The results of the counters are cached and new values ​​are checked only once a day. This cache can be wiped when published a new post. 36 | 37 | The cache avoids not only that your blog be seeking new results every time a page is loaded, but also prevents collapse of services from Twitter and Facebook, if one of these services does not respond, the counter displays the last count it was successful. 38 | 39 | #### Contribute #### 40 | 41 | You can contribute to the source code in our [GitHub](https://github.com/claudiosanches/social-count-plus) page. 42 | 43 | #### Credits #### 44 | 45 | * Flat icons set, Instagram, SoundCloud and Steam icons by [Felipe Santana](http://wordpress.org/support/profile/felipesantana) 46 | * Steam counter by [Tadas Krivickas](http://wordpress.org/support/profile/tkrivickas) 47 | * `wp_remote_get()` connection test with [httpbin](https://httpbin.org/) 48 | 49 | == Installation == 50 | 51 | * Upload plugin files to your plugins folder, or install using WordPress built-in Add New Plugin installer; 52 | * Activate the plugin; 53 | * Navigate to Settings -> Social Count Plus and fill the plugin options. 54 | 55 | Some counters depend on third-party APIs to work, follow the next steps to generate API keys for each of them: 56 | 57 | = Instagram = 58 | 59 | Get your User ID and Access Token in: https://socialcountplus-instagram.herokuapp.com/ 60 | 61 | = LinkedIn = 62 | 63 | Get your Company ID and Access Token in: https://socialcountplus-linkedin.herokuapp.com/ 64 | 65 | = Facebook = 66 | 67 | You must create a Facebook app to use the Facebook Graph API. 68 | 69 | Log in https://developers.facebook.com/ and go to "My Apps > Add a New App". 70 | 71 | Then follow the steps in this video: 72 | 73 | https://www.youtube.com/watch?v=m1QArbW2z4A 74 | 75 | = Google+ and YouTube = 76 | 77 | It's required a Google API Key for Google+ and YouTube. 78 | 79 | Access https://console.developers.google.com/project to create you Google API key following this steps: 80 | 81 | https://www.youtube.com/watch?v=KufdCMLMuFs 82 | 83 | = Twitter = 84 | 85 | You need access https://dev.twitter.com/apps, then create a Twitter App and copy the Consumer key, Consumer secret, Access token and Access token secret: 86 | 87 | https://www.youtube.com/watch?v=26dpo-g_jQc 88 | 89 | == Frequently Asked Questions == 90 | 91 | = What is the plugin license? = 92 | 93 | * This plugin is released under a GPL license. 94 | 95 | = Google+ is not working? = 96 | 97 | You probably have not been able to generate API keys as it should. 98 | 99 | You can test the API key with the following link: 100 | 101 | https://www.googleapis.com/plus/v1/people/+ClaudioSanches?key=API_KEY_HERE 102 | 103 | The answer must contain the following line: 104 | 105 | "circledByCount": XXX, 106 | 107 | = How to changing the amount of times the counter is updated daily? = 108 | 109 | You can change using the filter `social_count_plus_transient_time`. 110 | Example: 111 | 112 | 113 | function social_count_plus_custom_transient_time( $time ) { 114 | return 43200; // 12 hours in seconds. 115 | } 116 | 117 | add_filter( 'social_count_plus_transient_time', 'social_count_plus_custom_transient_time' ); 118 | 119 | 120 | = How can I round numbers? = 121 | 122 | It's possible to round numbers using the `social_count_plus_number_format` filter. 123 | 124 | Example of rounding 1500 to 1.5K or 1000000 to 1M: 125 | 126 | 127 | function my_custom_scp_number_format( $total ) { 128 | if ( $total > 1000000 ) { 129 | return round( $total / 1000000, 1 ) . 'M'; 130 | } else if ( $total > 1000 ) { 131 | return round( $total / 1000, 1 ) . 'K'; 132 | } 133 | 134 | return $total; 135 | } 136 | 137 | add_filter( 'social_count_plus_number_format', 'my_custom_scp_number_format' ); 138 | 139 | 140 | = Can I use my own icons? = 141 | 142 | Yes, you can! 143 | 144 | Select one of the options without icons in "WordPress admin > Social Count Plus > Design" and create your own CSS in your theme or anywhere you prefer. 145 | 146 | The CSS classes you will need to use: 147 | 148 | .social-count-plus .custom .count-comments a {} 149 | .social-count-plus .custom .count-facebook a {} 150 | .social-count-plus .custom .count-github a {} 151 | .social-count-plus .custom .count-googleplus a {} 152 | .social-count-plus .custom .count-instagram a {} 153 | .social-count-plus .custom .count-linkedin a {} 154 | .social-count-plus .custom .count-pinterest a {} 155 | .social-count-plus .custom .count-posts a {} 156 | .social-count-plus .custom .count-soundcloud a {} 157 | .social-count-plus .custom .count-steam a {} 158 | .social-count-plus .custom .count-tumblr a {} 159 | .social-count-plus .custom .count-twitch a {} 160 | .social-count-plus .custom .count-twitter a {} 161 | .social-count-plus .custom .count-users a {} 162 | .social-count-plus .custom .count-vimeo a {} 163 | 164 | 165 | = Having troubles? = 166 | 167 | If you have any problems with the numbers, go to the plugin settings and then to the "System Status" tab and click the "Get System Report" button. 168 | 169 | Copy the report file content and paste it in [gist.github.com](https://gist.github.com) or [pastebin.com](http://pastebin.com), save and get a link, finally create a topic in our [support forum](https://wordpress.org/support/plugin/social-count-plus). 170 | 171 | == Screenshots == 172 | 173 | 1. Settings page. 174 | 2. Design page. 175 | 3. Shortcodes and Functions API page. 176 | 4. System Status page. 177 | 5. Widget. 178 | 179 | == Changelog == 180 | 181 | = 3.4.1 - 2017/11/01 = 182 | 183 | - Removed `rel="nofollow"` option and applied automatically to all links. 184 | 185 | = 3.4.0 - 2017/10/25 = 186 | 187 | - Updated Twitch integration requiring "Twitch Client ID". 188 | - Fixed PHP notices when Pinterest profile does not exist. 189 | - Introduced the `social_count_plus_get_view_li` filter. 190 | 191 | = 3.3.6 - 2017/04/25 = 192 | 193 | * Fixed Facebook integration according with new Facebook API requirements (Thanks to [tc33](https://github.com/claudiosanches/social-count-plus/pull/38)). 194 | 195 | = 3.3.5 - 2016/08/20 = 196 | 197 | * Update and fixed the Facebook integration. 198 | 199 | = 3.3.4 - 2016/06/18 = 200 | 201 | * Improved the widget styles, not forcing styles anymore (just select the color as empty). Thanks to Sinisa Nikolic. 202 | * Added `social_count_plus_label` filter. 203 | 204 | = 3.3.3 - 2016/04/26 = 205 | 206 | * Updated the Facebook API to support APPs v2.5 or later. 207 | 208 | = 3.3.2 - 2015/09/28 = 209 | 210 | * Restored the `social_count_plus_number_format` filter. 211 | 212 | = 3.3.1 - 2015/09/28 = 213 | 214 | * Added submenu in settings page. 215 | 216 | = 3.3.0 - 2015/09/05 = 217 | 218 | * Added option to show all user roles in users integration. 219 | * Fixed errors in PHP 5.2. 220 | 221 | == Upgrade Notice == 222 | 223 | = 3.4.1 = 224 | 225 | - Removed `rel="nofollow"` option and applied automatically to all links. 226 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Social Count Plus # 2 | **Contributors:** claudiosanches, felipesantana, deblynprado 3 | **Donate link:** https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y8HP99ZJ5Z59L 4 | **Tags:** counter, widget, shortcode, facebook, github, googleplus, instagram, linkedin, pinterest, soundcloud, steam, tumblr, twitch, twitter, vimeo, youtube 5 | **Requires at least:** 4.0 6 | **Tested up to:** 4.9 7 | **Stable tag:** 3.4.1 8 | **License:** GPLv2 or later 9 | **License URI:** http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | Displays your number of followers from Facebook, Google+, Instagram, Twitch, Twitter and several other social media websites. 12 | 13 | ## Description ## 14 | 15 | The Social Count Plus performs counting for: 16 | 17 | - Comments total 18 | - Facebook page fans 19 | - GitHub followers 20 | - Google+ page/profile followers 21 | - Instagram followers 22 | - LinkedIn company followers 23 | - Pinterest followers 24 | - Posts total 25 | - SoundCloud followers 26 | - Steam Community group members 27 | - Tumblr followers 28 | - Twitch channel followers 29 | - Twitter followers 30 | - Users total 31 | - Vimeo followers 32 | 33 | You can display your numbers using a Widget (with links and icons) or Shortcodes (to be used in posts and pages) or PHP functions in your theme. 34 | 35 | The results of the counters are cached and new values ​​are checked only once a day. This cache can be wiped when published a new post. 36 | 37 | The cache avoids not only that your blog be seeking new results every time a page is loaded, but also prevents collapse of services from Twitter and Facebook, if one of these services does not respond, the counter displays the last count it was successful. 38 | 39 | #### Contribute #### 40 | 41 | You can contribute to the source code in our [GitHub](https://github.com/claudiosanches/social-count-plus) page. 42 | 43 | #### Credits #### 44 | 45 | * Flat icons set, Instagram, SoundCloud and Steam icons by [Felipe Santana](http://wordpress.org/support/profile/felipesantana) 46 | * Steam counter by [Tadas Krivickas](http://wordpress.org/support/profile/tkrivickas) 47 | * `wp_remote_get()` connection test with [httpbin](https://httpbin.org/) 48 | 49 | ## Installation ## 50 | 51 | * Upload plugin files to your plugins folder, or install using WordPress built-in Add New Plugin installer; 52 | * Activate the plugin; 53 | * Navigate to Settings -> Social Count Plus and fill the plugin options. 54 | 55 | Some counters depend on third-party APIs to work, follow the next steps to generate API keys for each of them: 56 | 57 | ### Instagram ### 58 | 59 | Get your User ID and Access Token in: https://socialcountplus-instagram.herokuapp.com/ 60 | 61 | ### LinkedIn ### 62 | 63 | Get your Company ID and Access Token in: https://socialcountplus-linkedin.herokuapp.com/ 64 | 65 | ### Facebook ### 66 | 67 | You must create a Facebook app to use the Facebook Graph API. 68 | 69 | Log in https://developers.facebook.com/ and go to "My Apps > Add a New App". 70 | 71 | Then follow the steps in this video: 72 | 73 | https://www.youtube.com/watch?v=m1QArbW2z4A 74 | 75 | ### Google+ and YouTube ### 76 | 77 | It's required a Google API Key for Google+ and YouTube. 78 | 79 | Access https://console.developers.google.com/project to create you Google API key following this steps: 80 | 81 | https://www.youtube.com/watch?v=KufdCMLMuFs 82 | 83 | ### Twitter ### 84 | 85 | You need access https://dev.twitter.com/apps, then create a Twitter App and copy the Consumer key, Consumer secret, Access token and Access token secret: 86 | 87 | https://www.youtube.com/watch?v=26dpo-g_jQc 88 | 89 | ## Frequently Asked Questions ## 90 | 91 | ### What is the plugin license? ### 92 | 93 | * This plugin is released under a GPL license. 94 | 95 | ### Google+ is not working? ### 96 | 97 | You probably have not been able to generate API keys as it should. 98 | 99 | You can test the API key with the following link: 100 | 101 | https://www.googleapis.com/plus/v1/people/+ClaudioSanches?key=API_KEY_HERE 102 | 103 | The answer must contain the following line: 104 | 105 | "circledByCount": XXX, 106 | 107 | ### How to changing the amount of times the counter is updated daily? ### 108 | 109 | You can change using the filter `social_count_plus_transient_time`. 110 | Example: 111 | 112 | 113 | function social_count_plus_custom_transient_time( $time ) { 114 | return 43200; // 12 hours in seconds. 115 | } 116 | 117 | add_filter( 'social_count_plus_transient_time', 'social_count_plus_custom_transient_time' ); 118 | 119 | 120 | ### How can I round numbers? ### 121 | 122 | It's possible to round numbers using the `social_count_plus_number_format` filter. 123 | 124 | Example of rounding 1500 to 1.5K or 1000000 to 1M: 125 | 126 | 127 | function my_custom_scp_number_format( $total ) { 128 | if ( $total > 1000000 ) { 129 | return round( $total / 1000000, 1 ) . 'M'; 130 | } else if ( $total > 1000 ) { 131 | return round( $total / 1000, 1 ) . 'K'; 132 | } 133 | 134 | return $total; 135 | } 136 | 137 | add_filter( 'social_count_plus_number_format', 'my_custom_scp_number_format' ); 138 | 139 | 140 | ### Can I use my own icons? ### 141 | 142 | Yes, you can! 143 | 144 | Select one of the options without icons in "WordPress admin > Social Count Plus > Design" and create your own CSS in your theme or anywhere you prefer. 145 | 146 | The CSS classes you will need to use: 147 | 148 | .social-count-plus .custom .count-comments a {} 149 | .social-count-plus .custom .count-facebook a {} 150 | .social-count-plus .custom .count-github a {} 151 | .social-count-plus .custom .count-googleplus a {} 152 | .social-count-plus .custom .count-instagram a {} 153 | .social-count-plus .custom .count-linkedin a {} 154 | .social-count-plus .custom .count-pinterest a {} 155 | .social-count-plus .custom .count-posts a {} 156 | .social-count-plus .custom .count-soundcloud a {} 157 | .social-count-plus .custom .count-steam a {} 158 | .social-count-plus .custom .count-tumblr a {} 159 | .social-count-plus .custom .count-twitch a {} 160 | .social-count-plus .custom .count-twitter a {} 161 | .social-count-plus .custom .count-users a {} 162 | .social-count-plus .custom .count-vimeo a {} 163 | 164 | 165 | ### Having troubles? ### 166 | 167 | If you have any problems with the numbers, go to the plugin settings and then to the "System Status" tab and click the "Get System Report" button. 168 | 169 | Copy the report file content and paste it in [gist.github.com](https://gist.github.com) or [pastebin.com](http://pastebin.com), save and get a link, finally create a topic in our [support forum](https://wordpress.org/support/plugin/social-count-plus). 170 | 171 | ## Screenshots ## 172 | 173 | ### 1. Settings page. ### 174 | ![1. Settings page.](http://ps.w.org/social-count-plus/assets/screenshot-1.png) 175 | 176 | ### 2. Design page. ### 177 | ![2. Design page.](http://ps.w.org/social-count-plus/assets/screenshot-2.png) 178 | 179 | ### 3. Shortcodes and Functions API page. ### 180 | ![3. Shortcodes and Functions API page.](http://ps.w.org/social-count-plus/assets/screenshot-3.png) 181 | 182 | ### 4. System Status page. ### 183 | ![4. System Status page.](http://ps.w.org/social-count-plus/assets/screenshot-4.png) 184 | 185 | ### 5. Widget. ### 186 | ![5. Widget.](http://ps.w.org/social-count-plus/assets/screenshot-5.png) 187 | 188 | 189 | ## Changelog ## 190 | 191 | ### 3.4.1 - 2017/11/01 ### 192 | 193 | - Removed `rel="nofollow"` option and applied automatically to all links. 194 | 195 | ### 3.4.0 - 2017/10/25 ### 196 | 197 | - Updated Twitch integration requiring "Twitch Client ID". 198 | - Fixed PHP notices when Pinterest profile does not exist. 199 | - Introduced the `social_count_plus_get_view_li` filter. 200 | 201 | ### 3.3.6 - 2017/04/25 ### 202 | 203 | * Fixed Facebook integration according with new Facebook API requirements (Thanks to [tc33](https://github.com/claudiosanches/social-count-plus/pull/38)). 204 | 205 | ### 3.3.5 - 2016/08/20 ### 206 | 207 | * Update and fixed the Facebook integration. 208 | 209 | ### 3.3.4 - 2016/06/18 ### 210 | 211 | * Improved the widget styles, not forcing styles anymore (just select the color as empty). Thanks to Sinisa Nikolic. 212 | * Added `social_count_plus_label` filter. 213 | 214 | ### 3.3.3 - 2016/04/26 ### 215 | 216 | * Updated the Facebook API to support APPs v2.5 or later. 217 | 218 | ### 3.3.2 - 2015/09/28 ### 219 | 220 | * Restored the `social_count_plus_number_format` filter. 221 | 222 | ### 3.3.1 - 2015/09/28 ### 223 | 224 | * Added submenu in settings page. 225 | 226 | ### 3.3.0 - 2015/09/05 ### 227 | 228 | * Added option to show all user roles in users integration. 229 | * Fixed errors in PHP 5.2. 230 | 231 | ## Upgrade Notice ## 232 | 233 | ### 3.4.1 ### 234 | 235 | - Removed `rel="nofollow"` option and applied automatically to all links. 236 | -------------------------------------------------------------------------------- /languages/social-count-plus.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 Claudio Sanches 2 | # This file is distributed under the GPLv2 or later. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Social Count Plus 3.4.1\n" 6 | "Report-Msgid-Bugs-To: https://wordpress.org/plugins/woocommerce-domination/\n" 7 | "POT-Creation-Date: 2017-11-01 18:46:03+00:00\n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=utf-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "PO-Revision-Date: 2017-MO-DA HO:MI+ZONE\n" 12 | "Last-Translator: FULL NAME \n" 13 | "Language-Team: LANGUAGE \n" 14 | "X-Generator: grunt-wp-i18n 0.5.4\n" 15 | 16 | #: includes/admin/class-social-count-plus-admin.php:65 17 | msgid "Create an App on Twitter in %s and get this data." 18 | msgstr "" 19 | 20 | #: includes/admin/class-social-count-plus-admin.php:67 21 | msgid "Create an App on Facebook in %s and get this data." 22 | msgstr "" 23 | 24 | #: includes/admin/class-social-count-plus-admin.php:69 25 | msgid "Get the this data in %s." 26 | msgstr "" 27 | 28 | #: includes/admin/class-social-count-plus-admin.php:71 29 | msgid "" 30 | "Register an App on Tumblr in %s, when the app is ready click in \"Explore " 31 | "API\" and allow your app access your Tumblr account and get this data." 32 | msgstr "" 33 | 34 | #: includes/admin/class-social-count-plus-admin.php:76 35 | #: includes/admin/class-social-count-plus-admin.php:1065 36 | msgid "Comments" 37 | msgstr "" 38 | 39 | #: includes/admin/class-social-count-plus-admin.php:79 40 | msgid "Display Comments Counter" 41 | msgstr "" 42 | 43 | #: includes/admin/class-social-count-plus-admin.php:84 44 | #: includes/admin/class-social-count-plus-admin.php:230 45 | #: includes/admin/class-social-count-plus-admin.php:375 46 | msgid "URL" 47 | msgstr "" 48 | 49 | #: includes/admin/class-social-count-plus-admin.php:91 50 | #: includes/admin/class-social-count-plus-admin.php:1066 51 | msgid "Facebook" 52 | msgstr "" 53 | 54 | #: includes/admin/class-social-count-plus-admin.php:94 55 | msgid "Display Facebook Counter" 56 | msgstr "" 57 | 58 | #: includes/admin/class-social-count-plus-admin.php:98 59 | msgid "Facebook Page ID" 60 | msgstr "" 61 | 62 | #: includes/admin/class-social-count-plus-admin.php:102 63 | msgid "ID Facebook page. Must be the numeric ID or your page slug." 64 | msgstr "" 65 | 66 | #: includes/admin/class-social-count-plus-admin.php:103 67 | msgid "" 68 | "You can find this data clicking to edit your page on Facebook. The URL will " 69 | "be similar to this:" 70 | msgstr "" 71 | 72 | #: includes/admin/class-social-count-plus-admin.php:104 73 | msgid "or" 74 | msgstr "" 75 | 76 | #: includes/admin/class-social-count-plus-admin.php:108 77 | msgid "Facebook App ID" 78 | msgstr "" 79 | 80 | #: includes/admin/class-social-count-plus-admin.php:113 81 | msgid "Facebook App Secret" 82 | msgstr "" 83 | 84 | #: includes/admin/class-social-count-plus-admin.php:120 85 | #: includes/admin/class-social-count-plus-admin.php:1067 86 | msgid "GitHub" 87 | msgstr "" 88 | 89 | #: includes/admin/class-social-count-plus-admin.php:123 90 | msgid "Display GitHub Counter" 91 | msgstr "" 92 | 93 | #: includes/admin/class-social-count-plus-admin.php:127 94 | msgid "GitHub Username" 95 | msgstr "" 96 | 97 | #: includes/admin/class-social-count-plus-admin.php:129 98 | msgid "Insert your GitHub username. Example: %s." 99 | msgstr "" 100 | 101 | #: includes/admin/class-social-count-plus-admin.php:134 102 | #: includes/admin/class-social-count-plus-admin.php:1068 103 | msgid "Google+" 104 | msgstr "" 105 | 106 | #: includes/admin/class-social-count-plus-admin.php:137 107 | msgid "Display Google+ Counter" 108 | msgstr "" 109 | 110 | #: includes/admin/class-social-count-plus-admin.php:141 111 | msgid "Google+ ID" 112 | msgstr "" 113 | 114 | #: includes/admin/class-social-count-plus-admin.php:145 115 | msgid "Google+ page or profile ID." 116 | msgstr "" 117 | 118 | #: includes/admin/class-social-count-plus-admin.php:146 119 | msgid "Example:" 120 | msgstr "" 121 | 122 | #: includes/admin/class-social-count-plus-admin.php:150 123 | #: includes/admin/class-social-count-plus-admin.php:413 124 | msgid "Google API Key" 125 | msgstr "" 126 | 127 | #: includes/admin/class-social-count-plus-admin.php:153 128 | msgid "" 129 | "Get your API key creating a project/app in %s, then inside your project go " 130 | "to \"APIs & auth > APIs\" and turn on the \"Google+ API\", finally go to " 131 | "\"APIs & auth > APIs > Credentials > Public API access\" and click in the " 132 | "\"CREATE A NEW KEY\" button, select the \"Browser key\" option and click in " 133 | "the \"CREATE\" button, now just copy your API key and paste here." 134 | msgstr "" 135 | 136 | #: includes/admin/class-social-count-plus-admin.php:160 137 | #: includes/admin/class-social-count-plus-admin.php:1069 138 | msgid "Instagram" 139 | msgstr "" 140 | 141 | #: includes/admin/class-social-count-plus-admin.php:163 142 | msgid "Display Instagram Counter" 143 | msgstr "" 144 | 145 | #: includes/admin/class-social-count-plus-admin.php:167 146 | msgid "Instagram Username" 147 | msgstr "" 148 | 149 | #: includes/admin/class-social-count-plus-admin.php:169 150 | msgid "Insert your Instagram Username." 151 | msgstr "" 152 | 153 | #: includes/admin/class-social-count-plus-admin.php:172 154 | msgid "Instagram User ID" 155 | msgstr "" 156 | 157 | #: includes/admin/class-social-count-plus-admin.php:174 158 | msgid "Insert your Instagram User ID." 159 | msgstr "" 160 | 161 | #: includes/admin/class-social-count-plus-admin.php:177 162 | msgid "Instagram Access Token" 163 | msgstr "" 164 | 165 | #: includes/admin/class-social-count-plus-admin.php:179 166 | msgid "Insert your Instagram Access Token." 167 | msgstr "" 168 | 169 | #: includes/admin/class-social-count-plus-admin.php:184 170 | #: includes/admin/class-social-count-plus-admin.php:1070 171 | msgid "LinkedIn" 172 | msgstr "" 173 | 174 | #: includes/admin/class-social-count-plus-admin.php:187 175 | msgid "Display LinkedIn counter" 176 | msgstr "" 177 | 178 | #: includes/admin/class-social-count-plus-admin.php:191 179 | msgid "LinkedIn Company ID" 180 | msgstr "" 181 | 182 | #: includes/admin/class-social-count-plus-admin.php:193 183 | msgid "Insert your LinkedIn Company ID. Get your Company ID in %s." 184 | msgstr "" 185 | 186 | #: includes/admin/class-social-count-plus-admin.php:196 187 | msgid "LinkedIn Access Token" 188 | msgstr "" 189 | 190 | #: includes/admin/class-social-count-plus-admin.php:198 191 | msgid "Get your Access Token in %s." 192 | msgstr "" 193 | 194 | #: includes/admin/class-social-count-plus-admin.php:203 195 | #: includes/admin/class-social-count-plus-admin.php:1071 196 | msgid "Pinterest" 197 | msgstr "" 198 | 199 | #: includes/admin/class-social-count-plus-admin.php:206 200 | msgid "Display Pinterest Counter" 201 | msgstr "" 202 | 203 | #: includes/admin/class-social-count-plus-admin.php:210 204 | msgid "Pinterest Username" 205 | msgstr "" 206 | 207 | #: includes/admin/class-social-count-plus-admin.php:212 208 | msgid "Insert your Pinterest username. Example: %s." 209 | msgstr "" 210 | 211 | #: includes/admin/class-social-count-plus-admin.php:217 212 | #: includes/admin/class-social-count-plus-admin.php:1072 213 | msgid "Posts" 214 | msgstr "" 215 | 216 | #: includes/admin/class-social-count-plus-admin.php:220 217 | msgid "Display Posts Counter" 218 | msgstr "" 219 | 220 | #: includes/admin/class-social-count-plus-admin.php:225 221 | msgid "Post Type" 222 | msgstr "" 223 | 224 | #: includes/admin/class-social-count-plus-admin.php:237 225 | #: includes/admin/class-social-count-plus-admin.php:1073 226 | msgid "SoundCloud" 227 | msgstr "" 228 | 229 | #: includes/admin/class-social-count-plus-admin.php:240 230 | msgid "Display SoundCloud Counter" 231 | msgstr "" 232 | 233 | #: includes/admin/class-social-count-plus-admin.php:244 234 | msgid "SoundCloud Username" 235 | msgstr "" 236 | 237 | #: includes/admin/class-social-count-plus-admin.php:246 238 | msgid "Insert your SoundCloud Username." 239 | msgstr "" 240 | 241 | #: includes/admin/class-social-count-plus-admin.php:249 242 | msgid "SoundCloud Client ID" 243 | msgstr "" 244 | 245 | #: includes/admin/class-social-count-plus-admin.php:251 246 | msgid "Insert your SoundCloud App Client ID. Generate this data in %s." 247 | msgstr "" 248 | 249 | #: includes/admin/class-social-count-plus-admin.php:256 250 | #: includes/admin/class-social-count-plus-admin.php:1074 251 | msgid "Steam" 252 | msgstr "" 253 | 254 | #: includes/admin/class-social-count-plus-admin.php:259 255 | msgid "Display Steam Counter" 256 | msgstr "" 257 | 258 | #: includes/admin/class-social-count-plus-admin.php:263 259 | msgid "Steam Group Name" 260 | msgstr "" 261 | 262 | #: includes/admin/class-social-count-plus-admin.php:265 263 | msgid "Insert your Steam Community group name. Example: %s." 264 | msgstr "" 265 | 266 | #: includes/admin/class-social-count-plus-admin.php:270 267 | #: includes/admin/class-social-count-plus-admin.php:1075 268 | msgid "Tumblr" 269 | msgstr "" 270 | 271 | #: includes/admin/class-social-count-plus-admin.php:273 272 | msgid "Display Tumblr counter" 273 | msgstr "" 274 | 275 | #: includes/admin/class-social-count-plus-admin.php:277 276 | msgid "Tumblr Hostname" 277 | msgstr "" 278 | 279 | #: includes/admin/class-social-count-plus-admin.php:279 280 | msgid "Insert your Tumblr Hostname. Example: %s." 281 | msgstr "" 282 | 283 | #: includes/admin/class-social-count-plus-admin.php:282 284 | msgid "Tumblr Consumer Key" 285 | msgstr "" 286 | 287 | #: includes/admin/class-social-count-plus-admin.php:287 288 | msgid "Tumblr Consumer Secret" 289 | msgstr "" 290 | 291 | #: includes/admin/class-social-count-plus-admin.php:292 292 | msgid "Tumblr Token" 293 | msgstr "" 294 | 295 | #: includes/admin/class-social-count-plus-admin.php:297 296 | msgid "Tumblr Token Secret" 297 | msgstr "" 298 | 299 | #: includes/admin/class-social-count-plus-admin.php:304 300 | #: includes/admin/class-social-count-plus-admin.php:1076 301 | msgid "Twitch" 302 | msgstr "" 303 | 304 | #: includes/admin/class-social-count-plus-admin.php:307 305 | msgid "Display Twitch Counter" 306 | msgstr "" 307 | 308 | #: includes/admin/class-social-count-plus-admin.php:311 309 | msgid "Twitch Username" 310 | msgstr "" 311 | 312 | #: includes/admin/class-social-count-plus-admin.php:313 313 | msgid "Insert your Twitch username." 314 | msgstr "" 315 | 316 | #: includes/admin/class-social-count-plus-admin.php:316 317 | msgid "Twitch Client ID" 318 | msgstr "" 319 | 320 | #: includes/admin/class-social-count-plus-admin.php:318 321 | msgid "Insert your Twitch Client ID." 322 | msgstr "" 323 | 324 | #: includes/admin/class-social-count-plus-admin.php:323 325 | #: includes/admin/class-social-count-plus-admin.php:1077 326 | msgid "Twitter" 327 | msgstr "" 328 | 329 | #: includes/admin/class-social-count-plus-admin.php:326 330 | msgid "Display Twitter Counter" 331 | msgstr "" 332 | 333 | #: includes/admin/class-social-count-plus-admin.php:330 334 | msgid "Twitter Username" 335 | msgstr "" 336 | 337 | #: includes/admin/class-social-count-plus-admin.php:332 338 | msgid "Insert the Twitter username. Example: %s." 339 | msgstr "" 340 | 341 | #: includes/admin/class-social-count-plus-admin.php:335 342 | msgid "Twitter Consumer key" 343 | msgstr "" 344 | 345 | #: includes/admin/class-social-count-plus-admin.php:340 346 | msgid "Twitter Consumer secret" 347 | msgstr "" 348 | 349 | #: includes/admin/class-social-count-plus-admin.php:345 350 | msgid "Twitter Access token" 351 | msgstr "" 352 | 353 | #: includes/admin/class-social-count-plus-admin.php:350 354 | msgid "Twitter Access token secret" 355 | msgstr "" 356 | 357 | #: includes/admin/class-social-count-plus-admin.php:357 358 | #: includes/admin/class-social-count-plus-admin.php:1078 359 | msgid "Users" 360 | msgstr "" 361 | 362 | #: includes/admin/class-social-count-plus-admin.php:360 363 | msgid "Display Users Counter" 364 | msgstr "" 365 | 366 | #: includes/admin/class-social-count-plus-admin.php:365 367 | msgid "User Role" 368 | msgstr "" 369 | 370 | #: includes/admin/class-social-count-plus-admin.php:370 371 | msgid "Label" 372 | msgstr "" 373 | 374 | #: includes/admin/class-social-count-plus-admin.php:371 375 | #: includes/counters/class-social-count-plus-users-counter.php:76 376 | msgid "users" 377 | msgstr "" 378 | 379 | #: includes/admin/class-social-count-plus-admin.php:382 380 | #: includes/admin/class-social-count-plus-admin.php:1079 381 | msgid "Vimeo" 382 | msgstr "" 383 | 384 | #: includes/admin/class-social-count-plus-admin.php:385 385 | msgid "Display Vimeo Counter" 386 | msgstr "" 387 | 388 | #: includes/admin/class-social-count-plus-admin.php:389 389 | msgid "Vimeo Username" 390 | msgstr "" 391 | 392 | #: includes/admin/class-social-count-plus-admin.php:391 393 | msgid "Insert your Vimeo username. Example: %s." 394 | msgstr "" 395 | 396 | #: includes/admin/class-social-count-plus-admin.php:396 397 | #: includes/admin/class-social-count-plus-admin.php:1080 398 | msgid "YouTube" 399 | msgstr "" 400 | 401 | #: includes/admin/class-social-count-plus-admin.php:399 402 | msgid "Display YouTube Counter" 403 | msgstr "" 404 | 405 | #: includes/admin/class-social-count-plus-admin.php:403 406 | msgid "YouTube Channel ID" 407 | msgstr "" 408 | 409 | #: includes/admin/class-social-count-plus-admin.php:405 410 | msgid "Insert the YouTube Channel ID. Example: %s." 411 | msgstr "" 412 | 413 | #: includes/admin/class-social-count-plus-admin.php:408 414 | msgid "YouTube Channel URL" 415 | msgstr "" 416 | 417 | #: includes/admin/class-social-count-plus-admin.php:410 418 | msgid "Insert the YouTube channel URL. Example: %s." 419 | msgstr "" 420 | 421 | #: includes/admin/class-social-count-plus-admin.php:416 422 | msgid "" 423 | "Get your API key creating a project/app in %s, then inside your project go " 424 | "to \"APIs & auth > APIs\" and turn on the \"YouTube API\", finally go to " 425 | "\"APIs & auth > APIs > Credentials > Public API access\" and click in the " 426 | "\"CREATE A NEW KEY\" button, select the \"Browser key\" option and click in " 427 | "the \"CREATE\" button, now just copy your API key and paste here." 428 | msgstr "" 429 | 430 | #: includes/admin/class-social-count-plus-admin.php:423 431 | #: includes/admin/class-social-count-plus-admin.php:903 432 | #: includes/admin/views/html-settings-page.php:9 433 | msgid "Settings" 434 | msgstr "" 435 | 436 | #: includes/admin/class-social-count-plus-admin.php:426 437 | msgid "Open URLs in new tab/window" 438 | msgstr "" 439 | 440 | #: includes/admin/class-social-count-plus-admin.php:428 441 | msgid "This option add %s in all counters URLs." 442 | msgstr "" 443 | 444 | #: includes/admin/class-social-count-plus-admin.php:435 445 | #: includes/admin/views/html-settings-page.php:9 446 | msgid "Design" 447 | msgstr "" 448 | 449 | #: includes/admin/class-social-count-plus-admin.php:438 450 | msgid "Layout Models" 451 | msgstr "" 452 | 453 | #: includes/admin/class-social-count-plus-admin.php:444 454 | msgid "Text Color" 455 | msgstr "" 456 | 457 | #: includes/admin/class-social-count-plus-admin.php:449 458 | msgid "Order" 459 | msgstr "" 460 | 461 | #: includes/admin/class-social-count-plus-admin.php:451 462 | msgid "This option controls the order of the icons in the widget." 463 | msgstr "" 464 | 465 | #. Plugin Name of the plugin/theme 466 | msgid "Social Count Plus" 467 | msgstr "" 468 | 469 | #: includes/admin/class-social-count-plus-admin.php:702 470 | msgid "Activate/Deactivate" 471 | msgstr "" 472 | 473 | #: includes/admin/class-social-count-plus-admin.php:756 474 | msgid "All Roles" 475 | msgstr "" 476 | 477 | #: includes/admin/class-social-count-plus-admin.php:956 478 | msgid "General Info" 479 | msgstr "" 480 | 481 | #: includes/admin/class-social-count-plus-admin.php:957 482 | #: includes/admin/views/html-settings-system-status-page.php:17 483 | msgid "Social Count Plus Version" 484 | msgstr "" 485 | 486 | #: includes/admin/class-social-count-plus-admin.php:958 487 | #: includes/admin/views/html-settings-system-status-page.php:21 488 | msgid "WordPress Version" 489 | msgstr "" 490 | 491 | #: includes/admin/class-social-count-plus-admin.php:959 492 | #: includes/admin/views/html-settings-system-status-page.php:25 493 | msgid "WP Multisite Enabled" 494 | msgstr "" 495 | 496 | #: includes/admin/class-social-count-plus-admin.php:959 497 | #: includes/admin/class-social-count-plus-admin.php:962 498 | #: includes/admin/class-social-count-plus-admin.php:963 499 | #: includes/admin/views/html-settings-system-status-page.php:26 500 | msgid "Yes" 501 | msgstr "" 502 | 503 | #: includes/admin/class-social-count-plus-admin.php:959 504 | #: includes/admin/class-social-count-plus-admin.php:962 505 | #: includes/admin/class-social-count-plus-admin.php:963 506 | #: includes/admin/views/html-settings-system-status-page.php:26 507 | msgid "No" 508 | msgstr "" 509 | 510 | #: includes/admin/class-social-count-plus-admin.php:960 511 | #: includes/admin/views/html-settings-system-status-page.php:29 512 | msgid "Web Server Info" 513 | msgstr "" 514 | 515 | #: includes/admin/class-social-count-plus-admin.php:961 516 | #: includes/admin/views/html-settings-system-status-page.php:33 517 | msgid "PHP Version" 518 | msgstr "" 519 | 520 | #: includes/admin/class-social-count-plus-admin.php:964 521 | msgid "Social Connections" 522 | msgstr "" 523 | 524 | #: includes/admin/class-social-count-plus-admin.php:974 525 | msgid "You do not have any counter that needs to connect remotely currently active" 526 | msgstr "" 527 | 528 | #: includes/admin/views/html-help-us.php:8 529 | msgid "" 530 | "Help us keep the %s plugin free making a donation or rate %s on " 531 | "WordPress.org. Thank you in advance!" 532 | msgstr "" 533 | 534 | #: includes/admin/views/html-help-us.php:9 535 | msgid "Make a donation" 536 | msgstr "" 537 | 538 | #: includes/admin/views/html-help-us.php:9 539 | msgid "Make a review" 540 | msgstr "" 541 | 542 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:7 543 | msgid "" 544 | "Use this library to generate your own model layout or display specific data " 545 | "counters." 546 | msgstr "" 547 | 548 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:9 549 | msgid "Shortcodes" 550 | msgstr "" 551 | 552 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:11 553 | msgid "Note: the shortcodes displays only the count in plain text." 554 | msgstr "" 555 | 556 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:16 557 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:29 558 | msgid "%s counter" 559 | msgstr "" 560 | 561 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:22 562 | msgid "Functions" 563 | msgstr "" 564 | 565 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:24 566 | msgid "" 567 | "Note: the functions displays only the count in plain text, except the " 568 | "get_scp_widget() function that displays with images." 569 | msgstr "" 570 | 571 | #: includes/admin/views/html-settings-functions-shortcodes-page.php:34 572 | msgid "Full widget" 573 | msgstr "" 574 | 575 | #: includes/admin/views/html-settings-page.php:9 576 | msgid "Shortcodes and Functions" 577 | msgstr "" 578 | 579 | #: includes/admin/views/html-settings-page.php:9 580 | msgid "System Status" 581 | msgstr "" 582 | 583 | #: includes/admin/views/html-settings-system-status-page.php:11 584 | msgid "Environment" 585 | msgstr "" 586 | 587 | #: includes/admin/views/html-settings-system-status-page.php:39 588 | msgid "" 589 | "Your server does not have fsockopen or cURL enabled. The scripts which " 590 | "communicate with the social APIs will not work. Contact your hosting " 591 | "provider." 592 | msgstr "" 593 | 594 | #: includes/admin/views/html-settings-system-status-page.php:43 595 | msgid "Your server has fsockopen and cURL enabled." 596 | msgstr "" 597 | 598 | #: includes/admin/views/html-settings-system-status-page.php:45 599 | msgid "Your server has fsockopen enabled, cURL is disabled." 600 | msgstr "" 601 | 602 | #: includes/admin/views/html-settings-system-status-page.php:47 603 | msgid "Your server has cURL enabled, fsockopen is disabled." 604 | msgstr "" 605 | 606 | #: includes/admin/views/html-settings-system-status-page.php:53 607 | msgid "fsockopen/cURL" 608 | msgstr "" 609 | 610 | #: includes/admin/views/html-settings-system-status-page.php:63 611 | msgid "wp_remote_get() failed. This may not work with your server." 612 | msgstr "" 613 | 614 | #: includes/admin/views/html-settings-system-status-page.php:68 615 | msgid "wp_remote_get() was successful." 616 | msgstr "" 617 | 618 | #: includes/admin/views/html-settings-system-status-page.php:70 619 | msgid "" 620 | "wp_remote_get() failed. This plugin won't work with your server. Contact " 621 | "your hosting provider. Error:" 622 | msgstr "" 623 | 624 | #: includes/admin/views/html-settings-system-status-page.php:73 625 | msgid "WP Remote Get" 626 | msgstr "" 627 | 628 | #: includes/admin/views/html-settings-system-status-page.php:83 629 | msgid "Get System Report" 630 | msgstr "" 631 | 632 | #: includes/class-social-count-plus-widget.php:19 633 | msgid "Display the counter" 634 | msgstr "" 635 | 636 | #: includes/class-social-count-plus-widget.php:59 637 | msgid "Title" 638 | msgstr "" 639 | 640 | #: includes/counters/class-social-count-plus-comments-counter.php:79 641 | msgid "comments" 642 | msgstr "" 643 | 644 | #: includes/counters/class-social-count-plus-facebook-counter.php:115 645 | msgid "likes" 646 | msgstr "" 647 | 648 | #: includes/counters/class-social-count-plus-github-counter.php:83 649 | #: includes/counters/class-social-count-plus-googleplus-counter.php:83 650 | #: includes/counters/class-social-count-plus-instagram-counter.php:87 651 | #: includes/counters/class-social-count-plus-linkedin-counter.php:88 652 | #: includes/counters/class-social-count-plus-pinterest-counter.php:92 653 | #: includes/counters/class-social-count-plus-soundcloud-counter.php:83 654 | #: includes/counters/class-social-count-plus-tumblr-counter.php:187 655 | #: includes/counters/class-social-count-plus-twitch-counter.php:87 656 | #: includes/counters/class-social-count-plus-twitter-counter.php:188 657 | #: includes/counters/class-social-count-plus-vimeo-counter.php:83 658 | msgid "followers" 659 | msgstr "" 660 | 661 | #: includes/counters/class-social-count-plus-steam-counter.php:82 662 | msgid "members" 663 | msgstr "" 664 | 665 | #: includes/counters/class-social-count-plus-youtube-counter.php:90 666 | msgid "subscribers" 667 | msgstr "" 668 | 669 | #. Plugin URI of the plugin/theme 670 | msgid "https://github.com/claudiosanches/social-count-plus" 671 | msgstr "" 672 | 673 | #. Description of the plugin/theme 674 | msgid "" 675 | "Displays your numbers in Facebook, GitHub, Google+, Instagram, LinkedIn, " 676 | "Pinterest, SoundCloud, Steam Community, Tumblr, Twitch, Twitter, Vimeo, " 677 | "Youtube, posts, comments and users." 678 | msgstr "" 679 | 680 | #. Author of the plugin/theme 681 | msgid "Claudio Sanches" 682 | msgstr "" 683 | 684 | #. Author URI of the plugin/theme 685 | msgid "https://claudiosanches.com/" 686 | msgstr "" -------------------------------------------------------------------------------- /includes/admin/class-social-count-plus-admin.php: -------------------------------------------------------------------------------- 1 | maybe_install(); 57 | } 58 | 59 | /** 60 | * Get the plugin options. 61 | * 62 | * @return array 63 | */ 64 | protected static function get_plugin_options() { 65 | $twitter_oauth_description = sprintf( __( 'Create an App on Twitter in %s and get this data.', 'social-count-plus' ), 'https://dev.twitter.com/apps' ); 66 | 67 | $facebook_app_description = sprintf( __( 'Create an App on Facebook in %s and get this data.', 'social-count-plus' ), 'https://developers.facebook.com/' ); 68 | 69 | $instagram_access_token = sprintf( __( 'Get the this data in %s.', 'social-count-plus' ), 'https://socialcountplus-instagram.herokuapp.com/' ); 70 | 71 | $tumblr_oauth_description = sprintf( __( 'Register an App on Tumblr in %s, when the app is ready click in "Explore API" and allow your app access your Tumblr account and get this data.', 'social-count-plus' ), 'https://www.tumblr.com/oauth/apps' ); 72 | 73 | $settings = array( 74 | 'socialcountplus_settings' => array( 75 | 'comments' => array( 76 | 'title' => __( 'Comments', 'social-count-plus' ), 77 | 'fields' => array( 78 | 'comments_active' => array( 79 | 'title' => __( 'Display Comments Counter', 'social-count-plus' ), 80 | 'default' => true, 81 | 'type' => 'checkbox' 82 | ), 83 | 'comments_url' => array( 84 | 'title' => __( 'URL', 'social-count-plus' ), 85 | 'default' => get_home_url(), 86 | 'type' => 'text' 87 | ) 88 | ) 89 | ), 90 | 'facebook' => array( 91 | 'title' => __( 'Facebook', 'social-count-plus' ), 92 | 'fields' => array( 93 | 'facebook_active' => array( 94 | 'title' => __( 'Display Facebook Counter', 'social-count-plus' ), 95 | 'type' => 'checkbox' 96 | ), 97 | 'facebook_id' => array( 98 | 'title' => __( 'Facebook Page ID', 'social-count-plus' ), 99 | 'type' => 'text', 100 | 'description' => sprintf( 101 | '%s
    %s
    https://www.facebook.com/pages/edit/?id=162354720442454 %s https://www.facebook.com/WordPress.', 102 | __( 'ID Facebook page. Must be the numeric ID or your page slug.', 'social-count-plus' ), 103 | __( 'You can find this data clicking to edit your page on Facebook. The URL will be similar to this:', 'social-count-plus' ), 104 | __( 'or', 'social-count-plus' ) 105 | ) 106 | ), 107 | 'facebook_app_id' => array( 108 | 'title' => __( 'Facebook App ID', 'social-count-plus' ), 109 | 'type' => 'text', 110 | 'description' => $facebook_app_description 111 | ), 112 | 'facebook_app_secret' => array( 113 | 'title' => __( 'Facebook App Secret', 'social-count-plus' ), 114 | 'type' => 'text', 115 | 'description' => $facebook_app_description 116 | ) 117 | ) 118 | ), 119 | 'github' => array( 120 | 'title' => __( 'GitHub', 'social-count-plus' ), 121 | 'fields' => array( 122 | 'github_active' => array( 123 | 'title' => __( 'Display GitHub Counter', 'social-count-plus' ), 124 | 'type' => 'checkbox' 125 | ), 126 | 'github_username' => array( 127 | 'title' => __( 'GitHub Username', 'social-count-plus' ), 128 | 'type' => 'text', 129 | 'description' => sprintf( __( 'Insert your GitHub username. Example: %s.', 'social-count-plus' ), 'claudiosanches' ) 130 | ), 131 | ) 132 | ), 133 | 'googleplus' => array( 134 | 'title' => __( 'Google+', 'social-count-plus' ), 135 | 'fields' => array( 136 | 'googleplus_active' => array( 137 | 'title' => __( 'Display Google+ Counter', 'social-count-plus' ), 138 | 'type' => 'checkbox' 139 | ), 140 | 'googleplus_id' => array( 141 | 'title' => __( 'Google+ ID', 'social-count-plus' ), 142 | 'type' => 'text', 143 | 'description' => sprintf( 144 | '%s
    %s https://plus.google.com/106146333300678794719 or https://plus.google.com/+ClaudioSanches', 145 | __( 'Google+ page or profile ID.', 'social-count-plus' ), 146 | __( 'Example:', 'social-count-plus' ) 147 | ) 148 | ), 149 | 'googleplus_api_key' => array( 150 | 'title' => __( 'Google API Key', 'social-count-plus' ), 151 | 'type' => 'text', 152 | 'description' => sprintf( 153 | __( 'Get your API key creating a project/app in %s, then inside your project go to "APIs & auth > APIs" and turn on the "Google+ API", finally go to "APIs & auth > APIs > Credentials > Public API access" and click in the "CREATE A NEW KEY" button, select the "Browser key" option and click in the "CREATE" button, now just copy your API key and paste here.', 'social-count-plus' ), 154 | 'https://console.developers.google.com/project' 155 | ) 156 | ) 157 | ) 158 | ), 159 | 'instagram' => array( 160 | 'title' => __( 'Instagram', 'social-count-plus' ), 161 | 'fields' => array( 162 | 'instagram_active' => array( 163 | 'title' => __( 'Display Instagram Counter', 'social-count-plus' ), 164 | 'type' => 'checkbox' 165 | ), 166 | 'instagram_username' => array( 167 | 'title' => __( 'Instagram Username', 'social-count-plus' ), 168 | 'type' => 'text', 169 | 'description' => __( 'Insert your Instagram Username.', 'social-count-plus' ) 170 | ), 171 | 'instagram_user_id' => array( 172 | 'title' => __( 'Instagram User ID', 'social-count-plus' ), 173 | 'type' => 'text', 174 | 'description' => __( 'Insert your Instagram User ID.', 'social-count-plus' ) . ' ' . $instagram_access_token 175 | ), 176 | 'instagram_access_token' => array( 177 | 'title' => __( 'Instagram Access Token', 'social-count-plus' ), 178 | 'type' => 'text', 179 | 'description' => __( 'Insert your Instagram Access Token.', 'social-count-plus' ) . ' ' . $instagram_access_token 180 | ) 181 | ) 182 | ), 183 | 'linkedin' => array( 184 | 'title' => __( 'LinkedIn', 'social-count-plus' ), 185 | 'fields' => array( 186 | 'linkedin_active' => array( 187 | 'title' => __( 'Display LinkedIn counter', 'social-count-plus' ), 188 | 'type' => 'checkbox' 189 | ), 190 | 'linkedin_company_id' => array( 191 | 'title' => __( 'LinkedIn Company ID', 'social-count-plus' ), 192 | 'type' => 'text', 193 | 'description' => sprintf( __( 'Insert your LinkedIn Company ID. Get your Company ID in %s.', 'social-count-plus' ), 'https://socialcountplus-linkedin.herokuapp.com/' ) 194 | ), 195 | 'linkedin_access_token' => array( 196 | 'title' => __( 'LinkedIn Access Token', 'social-count-plus' ), 197 | 'type' => 'text', 198 | 'description' => sprintf( __( 'Get your Access Token in %s.', 'social-count-plus' ), 'https://socialcountplus-linkedin.herokuapp.com/' ) 199 | ) 200 | ) 201 | ), 202 | 'pinterest' => array( 203 | 'title' => __( 'Pinterest', 'social-count-plus' ), 204 | 'fields' => array( 205 | 'pinterest_active' => array( 206 | 'title' => __( 'Display Pinterest Counter', 'social-count-plus' ), 207 | 'type' => 'checkbox' 208 | ), 209 | 'pinterest_username' => array( 210 | 'title' => __( 'Pinterest Username', 'social-count-plus' ), 211 | 'type' => 'text', 212 | 'description' => sprintf( __( 'Insert your Pinterest username. Example: %s.', 'social-count-plus' ), 'claudiosmweb' ) 213 | ) 214 | ) 215 | ), 216 | 'posts' => array( 217 | 'title' => __( 'Posts', 'social-count-plus' ), 218 | 'fields' => array( 219 | 'posts_active' => array( 220 | 'title' => __( 'Display Posts Counter', 'social-count-plus' ), 221 | 'default' => true, 222 | 'type' => 'checkbox' 223 | ), 224 | 'posts_post_type' => array( 225 | 'title' => __( 'Post Type', 'social-count-plus' ), 226 | 'default' => 'post', 227 | 'type' => 'post_type' 228 | ), 229 | 'posts_url' => array( 230 | 'title' => __( 'URL', 'social-count-plus' ), 231 | 'default' => get_home_url(), 232 | 'type' => 'text' 233 | ) 234 | ) 235 | ), 236 | 'soundcloud' => array( 237 | 'title' => __( 'SoundCloud', 'social-count-plus' ), 238 | 'fields' => array( 239 | 'soundcloud_active' => array( 240 | 'title' => __( 'Display SoundCloud Counter', 'social-count-plus' ), 241 | 'type' => 'checkbox' 242 | ), 243 | 'soundcloud_username' => array( 244 | 'title' => __( 'SoundCloud Username', 'social-count-plus' ), 245 | 'type' => 'text', 246 | 'description' => __( 'Insert your SoundCloud Username.', 'social-count-plus' ) 247 | ), 248 | 'soundcloud_client_id' => array( 249 | 'title' => __( 'SoundCloud Client ID', 'social-count-plus' ), 250 | 'type' => 'text', 251 | 'description' => sprintf( __( 'Insert your SoundCloud App Client ID. Generate this data in %s.', 'social-count-plus' ), 'http://soundcloud.com/you/apps/new' ) 252 | ) 253 | ) 254 | ), 255 | 'steam' => array( 256 | 'title' => __( 'Steam', 'social-count-plus' ), 257 | 'fields' => array( 258 | 'steam_active' => array( 259 | 'title' => __( 'Display Steam Counter', 'social-count-plus' ), 260 | 'type' => 'checkbox' 261 | ), 262 | 'steam_group_name' => array( 263 | 'title' => __( 'Steam Group Name', 'social-count-plus' ), 264 | 'type' => 'text', 265 | 'description' => sprintf( __( 'Insert your Steam Community group name. Example: %s.', 'social-count-plus' ), 'DOTALT' ) 266 | ) 267 | ) 268 | ), 269 | 'tumblr' => array( 270 | 'title' => __( 'Tumblr', 'social-count-plus' ), 271 | 'fields' => array( 272 | 'tumblr_active' => array( 273 | 'title' => __( 'Display Tumblr counter', 'social-count-plus' ), 274 | 'type' => 'checkbox' 275 | ), 276 | 'tumblr_hostname' => array( 277 | 'title' => __( 'Tumblr Hostname', 'social-count-plus' ), 278 | 'type' => 'text', 279 | 'description' => sprintf( __( 'Insert your Tumblr Hostname. Example: %s.', 'social-count-plus' ), 'http://claudiosmweb.tumblr.com/' ) 280 | ), 281 | 'tumblr_consumer_key' => array( 282 | 'title' => __( 'Tumblr Consumer Key', 'social-count-plus' ), 283 | 'type' => 'text', 284 | 'description' => $tumblr_oauth_description 285 | ), 286 | 'tumblr_consumer_secret' => array( 287 | 'title' => __( 'Tumblr Consumer Secret', 'social-count-plus' ), 288 | 'type' => 'text', 289 | 'description' => $tumblr_oauth_description 290 | ), 291 | 'tumblr_token' => array( 292 | 'title' => __( 'Tumblr Token', 'social-count-plus' ), 293 | 'type' => 'text', 294 | 'description' => $tumblr_oauth_description 295 | ), 296 | 'tumblr_token_secret' => array( 297 | 'title' => __( 'Tumblr Token Secret', 'social-count-plus' ), 298 | 'type' => 'text', 299 | 'description' => $tumblr_oauth_description 300 | ) 301 | ) 302 | ), 303 | 'twitch' => array( 304 | 'title' => __( 'Twitch', 'social-count-plus' ), 305 | 'fields' => array( 306 | 'twitch_active' => array( 307 | 'title' => __( 'Display Twitch Counter', 'social-count-plus' ), 308 | 'type' => 'checkbox' 309 | ), 310 | 'twitch_username' => array( 311 | 'title' => __( 'Twitch Username', 'social-count-plus' ), 312 | 'type' => 'text', 313 | 'description' => __( 'Insert your Twitch username.', 'social-count-plus' ) 314 | ), 315 | 'twitch_client_ID' => array( 316 | 'title' => __( 'Twitch Client ID', 'social-count-plus' ), 317 | 'type' => 'text', 318 | 'description' => __( 'Insert your Twitch Client ID.', 'social-count-plus' ), 319 | ), 320 | ), 321 | ), 322 | 'twitter' => array( 323 | 'title' => __( 'Twitter', 'social-count-plus' ), 324 | 'fields' => array( 325 | 'twitter_active' => array( 326 | 'title' => __( 'Display Twitter Counter', 'social-count-plus' ), 327 | 'type' => 'checkbox' 328 | ), 329 | 'twitter_user' => array( 330 | 'title' => __( 'Twitter Username', 'social-count-plus' ), 331 | 'type' => 'text', 332 | 'description' => sprintf( __( 'Insert the Twitter username. Example: %s.', 'social-count-plus' ), 'claudiosanchesm' ) 333 | ), 334 | 'twitter_consumer_key' => array( 335 | 'title' => __( 'Twitter Consumer key', 'social-count-plus' ), 336 | 'type' => 'text', 337 | 'description' => $twitter_oauth_description 338 | ), 339 | 'twitter_consumer_secret' => array( 340 | 'title' => __( 'Twitter Consumer secret', 'social-count-plus' ), 341 | 'type' => 'text', 342 | 'description' => $twitter_oauth_description 343 | ), 344 | 'twitter_access_token' => array( 345 | 'title' => __( 'Twitter Access token', 'social-count-plus' ), 346 | 'type' => 'text', 347 | 'description' => $twitter_oauth_description 348 | ), 349 | 'twitter_access_token_secret' => array( 350 | 'title' => __( 'Twitter Access token secret', 'social-count-plus' ), 351 | 'type' => 'text', 352 | 'description' => $twitter_oauth_description 353 | ) 354 | ) 355 | ), 356 | 'users' => array( 357 | 'title' => __( 'Users', 'social-count-plus' ), 358 | 'fields' => array( 359 | 'users_active' => array( 360 | 'title' => __( 'Display Users Counter', 'social-count-plus' ), 361 | 'default' => true, 362 | 'type' => 'checkbox' 363 | ), 364 | 'users_user_role' => array( 365 | 'title' => __( 'User Role', 'social-count-plus' ), 366 | 'default' => 'subscriber', 367 | 'type' => 'user_role' 368 | ), 369 | 'users_label' => array( 370 | 'title' => __( 'Label', 'social-count-plus' ), 371 | 'default' => __( 'users', 'social-count-plus' ), 372 | 'type' => 'text' 373 | ), 374 | 'users_url' => array( 375 | 'title' => __( 'URL', 'social-count-plus' ), 376 | 'default' => get_home_url(), 377 | 'type' => 'text' 378 | ) 379 | ) 380 | ), 381 | 'vimeo' => array( 382 | 'title' => __( 'Vimeo', 'social-count-plus' ), 383 | 'fields' => array( 384 | 'vimeo_active' => array( 385 | 'title' => __( 'Display Vimeo Counter', 'social-count-plus' ), 386 | 'type' => 'checkbox' 387 | ), 388 | 'vimeo_username' => array( 389 | 'title' => __( 'Vimeo Username', 'social-count-plus' ), 390 | 'type' => 'text', 391 | 'description' => sprintf( __( 'Insert your Vimeo username. Example: %s.', 'social-count-plus' ), 'claudiosmweb' ) 392 | ) 393 | ) 394 | ), 395 | 'youtube' => array( 396 | 'title' => __( 'YouTube', 'social-count-plus' ), 397 | 'fields' => array( 398 | 'youtube_active' => array( 399 | 'title' => __( 'Display YouTube Counter', 'social-count-plus' ), 400 | 'type' => 'checkbox' 401 | ), 402 | 'youtube_user' => array( 403 | 'title' => __( 'YouTube Channel ID', 'social-count-plus' ), 404 | 'type' => 'text', 405 | 'description' => sprintf( __( 'Insert the YouTube Channel ID. Example: %s.', 'social-count-plus' ), 'UCWGz8KbT5IE7PxhSN1jjimw' ) 406 | ), 407 | 'youtube_url' => array( 408 | 'title' => __( 'YouTube Channel URL', 'social-count-plus' ), 409 | 'type' => 'text', 410 | 'description' => sprintf( __( 'Insert the YouTube channel URL. Example: %s.', 'social-count-plus' ), 'https://www.youtube.com/user/theclaudiosmweb' ) 411 | ), 412 | 'youtube_api_key' => array( 413 | 'title' => __( 'Google API Key', 'social-count-plus' ), 414 | 'type' => 'text', 415 | 'description' => sprintf( 416 | __( 'Get your API key creating a project/app in %s, then inside your project go to "APIs & auth > APIs" and turn on the "YouTube API", finally go to "APIs & auth > APIs > Credentials > Public API access" and click in the "CREATE A NEW KEY" button, select the "Browser key" option and click in the "CREATE" button, now just copy your API key and paste here.', 'social-count-plus' ), 417 | 'https://console.developers.google.com/project' 418 | ) 419 | ) 420 | ) 421 | ), 422 | 'settings' => array( 423 | 'title' => __( 'Settings', 'social-count-plus' ), 424 | 'fields' => array( 425 | 'target_blank' => array( 426 | 'title' => __( 'Open URLs in new tab/window', 'social-count-plus' ), 427 | 'type' => 'checkbox', 428 | 'description' => sprintf( __( 'This option add %s in all counters URLs.', 'social-count-plus' ), 'target="_blank"' ) 429 | ), 430 | ) 431 | ) 432 | ), 433 | 'socialcountplus_design' => array( 434 | 'design' => array( 435 | 'title' => __( 'Design', 'social-count-plus' ), 436 | 'fields' => array( 437 | 'models' => array( 438 | 'title' => __( 'Layout Models', 'social-count-plus' ), 439 | 'default' => '0', 440 | 'type' => 'models', 441 | 'options' => array( 0 ,1, 2, 3, 4, 5, 6, 7 ) 442 | ), 443 | 'text_color' => array( 444 | 'title' => __( 'Text Color', 'social-count-plus' ), 445 | 'default' => '#333333', 446 | 'type' => 'color' 447 | ), 448 | 'icons' => array( 449 | 'title' => __( 'Order', 'social-count-plus' ), 450 | 'type' => 'icons_order', 451 | 'description' => __( 'This option controls the order of the icons in the widget.', 'social-count-plus' ) 452 | ) 453 | ) 454 | ) 455 | ) 456 | ); 457 | 458 | return $settings; 459 | } 460 | 461 | /** 462 | * Add plugin settings menu. 463 | */ 464 | public function settings_menu() { 465 | $this->settings_screen = add_options_page( 466 | __( 'Social Count Plus', 'social-count-plus' ), 467 | __( 'Social Count Plus', 'social-count-plus' ), 468 | 'manage_options', 469 | 'social-count-plus', 470 | array( $this, 'settings_page' ) 471 | ); 472 | } 473 | 474 | /** 475 | * Plugin settings page. 476 | * 477 | * @return string 478 | */ 479 | public function settings_page() { 480 | $screen = get_current_screen(); 481 | 482 | if ( ! $this->settings_screen || $screen->id !== $this->settings_screen ) { 483 | return; 484 | } 485 | 486 | // Load the plugin options. 487 | $this->plugin_settings = get_option( 'socialcountplus_settings' ); 488 | $this->plugin_design = get_option( 'socialcountplus_design' ); 489 | 490 | // Create tabs current class. 491 | $current_tab = ''; 492 | if ( isset( $_GET['tab'] ) ) { 493 | $current_tab = $_GET['tab']; 494 | } else { 495 | $current_tab = 'settings'; 496 | } 497 | 498 | // Reset transients when save settings page. 499 | if ( isset( $_GET['settings-updated'] ) && ! ( isset( $_GET['tab'] ) && 'design' == $_GET['tab'] ) ) { 500 | if ( true == $_GET['settings-updated'] ) { 501 | // Set transients. 502 | Social_Count_Plus_Generator::reset_count(); 503 | 504 | // Set the icons order. 505 | $icons = self::get_current_icons(); 506 | $design = get_option( 'socialcountplus_design', array() ); 507 | $design['icons'] = implode( ',', $icons ); 508 | update_option( 'socialcountplus_design', $design ); 509 | } 510 | } 511 | 512 | include 'views/html-settings-page.php'; 513 | } 514 | 515 | /** 516 | * Plugin settings form fields. 517 | */ 518 | public function plugin_settings() { 519 | 520 | // Process the settings. 521 | foreach ( self::get_plugin_options() as $settings_id => $sections ) { 522 | 523 | // Create the sections. 524 | foreach ( $sections as $section_id => $section ) { 525 | add_settings_section( 526 | $section_id, 527 | $section['title'], 528 | array( $this, 'title_element_callback' ), 529 | $settings_id 530 | ); 531 | 532 | // Create the fields. 533 | foreach ( $section['fields'] as $field_id => $field ) { 534 | switch ( $field['type'] ) { 535 | case 'text': 536 | add_settings_field( 537 | $field_id, 538 | $field['title'], 539 | array( $this, 'text_element_callback' ), 540 | $settings_id, 541 | $section_id, 542 | array( 543 | 'tab' => $settings_id, 544 | 'id' => $field_id, 545 | 'class' => 'regular-text', 546 | 'description' => isset( $field['description'] ) ? $field['description'] : '' 547 | ) 548 | ); 549 | break; 550 | case 'checkbox': 551 | add_settings_field( 552 | $field_id, 553 | $field['title'], 554 | array( $this, 'checkbox_element_callback' ), 555 | $settings_id, 556 | $section_id, 557 | array( 558 | 'tab' => $settings_id, 559 | 'id' => $field_id, 560 | 'description' => isset( $field['description'] ) ? $field['description'] : '' 561 | ) 562 | ); 563 | break; 564 | case 'post_type': 565 | add_settings_field( 566 | $field_id, 567 | $field['title'], 568 | array( $this, 'post_type_element_callback' ), 569 | $settings_id, 570 | $section_id, 571 | array( 572 | 'tab' => $settings_id, 573 | 'id' => $field_id, 574 | 'description' => isset( $field['description'] ) ? $field['description'] : '' 575 | ) 576 | ); 577 | break; 578 | case 'user_role': 579 | add_settings_field( 580 | $field_id, 581 | $field['title'], 582 | array( $this, 'user_role_element_callback' ), 583 | $settings_id, 584 | $section_id, 585 | array( 586 | 'tab' => $settings_id, 587 | 'id' => $field_id, 588 | 'description' => isset( $field['description'] ) ? $field['description'] : '' 589 | ) 590 | ); 591 | break; 592 | case 'models': 593 | add_settings_field( 594 | $field_id, 595 | $field['title'], 596 | array( $this, 'models_element_callback' ), 597 | $settings_id, 598 | $section_id, 599 | array( 600 | 'tab' => $settings_id, 601 | 'id' => $field_id, 602 | 'description' => isset( $field['description'] ) ? $field['description'] : '', 603 | 'options' => $field['options'] 604 | ) 605 | ); 606 | break; 607 | case 'icons_order': 608 | add_settings_field( 609 | $field_id, 610 | $field['title'], 611 | array( $this, 'icons_order_element_callback' ), 612 | $settings_id, 613 | $section_id, 614 | array( 615 | 'tab' => $settings_id, 616 | 'id' => $field_id, 617 | 'description' => isset( $field['description'] ) ? $field['description'] : '' 618 | ) 619 | ); 620 | break; 621 | case 'color': 622 | add_settings_field( 623 | $field_id, 624 | $field['title'], 625 | array( $this, 'color_element_callback' ), 626 | $settings_id, 627 | $section_id, 628 | array( 629 | 'tab' => $settings_id, 630 | 'id' => $field_id, 631 | 'description' => isset( $field['description'] ) ? $field['description'] : '' 632 | ) 633 | ); 634 | break; 635 | 636 | default: 637 | break; 638 | } 639 | } 640 | } 641 | 642 | // Register the setting. 643 | register_setting( $settings_id, $settings_id, array( $this, 'validate_options' ) ); 644 | } 645 | } 646 | 647 | /** 648 | * Get option value. 649 | * 650 | * @param string $id Option ID. 651 | * @param mixed $default Default value. 652 | * 653 | * @return string 654 | */ 655 | protected function get_option_value( $id, $default = '' ) { 656 | $options = array_merge( $this->plugin_settings, $this->plugin_design ); 657 | 658 | return ( isset( $options[ $id ] ) ) ? $options[ $id ] : $default; 659 | } 660 | 661 | /** 662 | * Title element callback. 663 | * 664 | * @param array $args Field arguments. 665 | */ 666 | public function title_element_callback( $args ) { 667 | echo ! empty( $args['id'] ) ? '
    ' : ''; 668 | } 669 | 670 | /** 671 | * Text element callback. 672 | * 673 | * @param array $args Field arguments. 674 | */ 675 | public function text_element_callback( $args ) { 676 | $tab = $args['tab']; 677 | $id = $args['id']; 678 | $class = isset( $args['class'] ) ? $args['class'] : 'small-text'; 679 | $default = isset( $args['default'] ) ? $args['default'] : ''; 680 | $current = $this->get_option_value( $id, $default ); 681 | $html = sprintf( '', $id, $tab, $current, $class ); 682 | 683 | // Displays option description. 684 | if ( isset( $args['description'] ) ) { 685 | $html .= sprintf( '

    %s

    ', $args['description'] ); 686 | } 687 | 688 | echo $html; 689 | } 690 | 691 | /** 692 | * Checkbox field callback. 693 | * 694 | * @param array $args Field arguments. 695 | */ 696 | public function checkbox_element_callback( $args ) { 697 | $tab = $args['tab']; 698 | $id = $args['id']; 699 | $default = isset( $args['default'] ) ? $args['default'] : ''; 700 | $current = $this->get_option_value( $id, $default ); 701 | $html = sprintf( '', $id, $tab, checked( 1, $current, false ) ); 702 | $html .= sprintf( '
    ', $id, __( 'Activate/Deactivate', 'social-count-plus' ) ); 703 | 704 | // Displays option description. 705 | if ( isset( $args['description'] ) ) { 706 | $html .= sprintf( '

    %s

    ', $args['description'] ); 707 | } 708 | 709 | echo $html; 710 | } 711 | 712 | /** 713 | * Post Type element callback. 714 | * 715 | * @param array $args Field arguments. 716 | */ 717 | public function post_type_element_callback( $args ) { 718 | $tab = $args['tab']; 719 | $id = $args['id']; 720 | $default = isset( $args['default'] ) ? $args['default'] : 'post'; 721 | $current = $this->get_option_value( $id, $default ); 722 | $html = ''; 723 | 724 | $html = sprintf( ''; 729 | 730 | // Displays option description. 731 | if ( isset( $args['description'] ) ) { 732 | $html .= sprintf( '

    %s

    ', $args['description'] ); 733 | } 734 | 735 | echo $html; 736 | } 737 | 738 | /** 739 | * User Role element callback. 740 | * 741 | * @param array $args Field arguments. 742 | */ 743 | public function user_role_element_callback( $args ) { 744 | global $wp_roles; 745 | 746 | $tab = $args['tab']; 747 | $id = $args['id']; 748 | $default = isset( $args['default'] ) ? $args['default'] : 'subscriber'; 749 | $current = $this->get_option_value( $id, $default ); 750 | $html = ''; 751 | 752 | $html = sprintf( ''; 758 | 759 | // Displays option description. 760 | if ( isset( $args['description'] ) ) { 761 | $html .= sprintf( '

    %s

    ', $args['description'] ); 762 | } 763 | 764 | echo $html; 765 | } 766 | 767 | /** 768 | * Models element callback. 769 | * 770 | * @param array $args Field arguments. 771 | */ 772 | public function models_element_callback( $args ) { 773 | $tab = $args['tab']; 774 | $id = $args['id']; 775 | $default = isset( $args['default'] ) ? $args['default'] : 0; 776 | $current = $this->get_option_value( $id, $default ); 777 | $html = ''; 778 | 779 | foreach ( $args['options'] as $option ) { 780 | $html .= sprintf( '', $tab, $id, $option, checked( $current, $option, false ) ); 781 | 782 | $style = Social_Count_Plus_View::get_view_model( $option ); 783 | 784 | $html .= ''; 798 | } 799 | 800 | // Displays option description. 801 | if ( isset( $args['description'] ) ) { 802 | $html .= sprintf( '

    %s

    ', $args['description'] ); 803 | } 804 | 805 | echo $html; 806 | } 807 | 808 | /** 809 | * Icons order element callback. 810 | * 811 | * @param array $args Field arguments. 812 | */ 813 | public function icons_order_element_callback( $args ) { 814 | $tab = $args['tab']; 815 | $id = $args['id']; 816 | $current = $this->get_option_value( $id ); 817 | $html = ''; 818 | 819 | $html .= ''; 825 | 826 | // Displays option description. 827 | if ( isset( $args['description'] ) ) { 828 | $html .= sprintf( '

    %s

    ', $args['description'] ); 829 | } 830 | 831 | echo $html; 832 | } 833 | 834 | /** 835 | * Color element callback. 836 | * 837 | * @param array $args Field arguments. 838 | */ 839 | public function color_element_callback( $args ) { 840 | $tab = $args['tab']; 841 | $id = $args['id']; 842 | $default = isset( $args['default'] ) ? $args['default'] : '#333333'; 843 | $current = $this->get_option_value( $id, $default ); 844 | $html = sprintf( '', $id, $tab, $current ); 845 | 846 | // Displays option description. 847 | if ( isset( $args['description'] ) ) { 848 | $html .= sprintf( '

    %s

    ', $args['description'] ); 849 | } 850 | 851 | echo $html; 852 | } 853 | 854 | /** 855 | * Valid options. 856 | * 857 | * @param array $input options to valid. 858 | * 859 | * @return array validated options. 860 | */ 861 | public function validate_options( $input ) { 862 | $output = array(); 863 | 864 | foreach ( $input as $key => $value ) { 865 | if ( isset( $input[ $key ] ) ) { 866 | $output[ $key ] = sanitize_text_field( $input[ $key ] ); 867 | } 868 | } 869 | 870 | return $output; 871 | } 872 | 873 | /** 874 | * Register admin styles and scripts. 875 | */ 876 | public function styles_and_scripts() { 877 | $screen = get_current_screen(); 878 | 879 | if ( $this->settings_screen && $screen->id === $this->settings_screen ) { 880 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 881 | 882 | wp_enqueue_style( 'social-count-plus', plugins_url( 'assets/css/counter.css', plugin_dir_path( dirname( __FILE__ ) ) ), array(), Social_Count_Plus::VERSION, 'all' ); 883 | wp_enqueue_script( 'wp-color-picker' ); 884 | wp_enqueue_style( 'wp-color-picker' ); 885 | wp_enqueue_script( 'jquery-ui-sortable' ); 886 | wp_enqueue_style( 'social-count-plus-admin', plugins_url( 'assets/css/admin.css', plugin_dir_path( dirname( __FILE__ ) ) ), array(), Social_Count_Plus::VERSION, 'all' ); 887 | wp_enqueue_script( 'social-count-plus-admin', plugins_url( 'assets/js/admin' . $suffix . '.js', plugin_dir_path( dirname( __FILE__ ) ) ), array( 'jquery', 'wp-color-picker' ), Social_Count_Plus::VERSION, true ); 888 | } 889 | } 890 | 891 | /** 892 | * Adds custom settings url in plugins page. 893 | * 894 | * @param array $links Default links. 895 | * 896 | * @return array Default links and settings link. 897 | */ 898 | public function action_links( $links ) { 899 | $settings = array( 900 | 'settings' => sprintf( 901 | '%s', 902 | admin_url( 'options-general.php?page=social-count-plus' ), 903 | __( 'Settings', 'social-count-plus' ) 904 | ) 905 | ); 906 | 907 | return array_merge( $settings, $links ); 908 | } 909 | 910 | /** 911 | * Generate a system report file. 912 | * 913 | * @return string 914 | */ 915 | public function report_file() { 916 | if ( ! current_user_can( 'manage_options' ) ) { 917 | return; 918 | } 919 | 920 | if ( ! isset( $_GET['page'] ) || ! isset( $_GET['tab'] ) || ! isset( $_GET['debug_file'] ) ) { 921 | return; 922 | } 923 | 924 | @ob_clean(); 925 | 926 | $debug = array(); 927 | $settings = get_option( 'socialcountplus_settings' ); 928 | $cache = get_option( Social_Count_Plus_Generator::$cache ); 929 | $content = ''; 930 | $counters = apply_filters( 'social_count_plus_counters_test', array( 931 | 'Social_Count_Plus_Facebook_Counter', 932 | 'Social_Count_Plus_GitHub_Counter', 933 | 'Social_Count_Plus_GooglePlus_Counter', 934 | 'Social_Count_Plus_Instagram_Counter', 935 | 'Social_Count_Plus_LinkedIn_Counter', 936 | 'Social_Count_Plus_Pinterest_Counter', 937 | 'Social_Count_Plus_SoundCloud_Counter', 938 | 'Social_Count_Plus_Steam_Counter', 939 | 'Social_Count_Plus_Tumblr_Counter', 940 | 'Social_Count_Plus_Twitch_Counter', 941 | 'Social_Count_Plus_Twitter_Counter', 942 | 'Social_Count_Plus_Vimeo_Counter', 943 | 'Social_Count_Plus_YouTube_Counter', 944 | ) ); 945 | 946 | foreach ( $counters as $counter ) { 947 | $_counter = new $counter(); 948 | 949 | if ( $_counter->is_available( $settings ) ) { 950 | $_counter->get_total( $settings, $cache ); 951 | $debug[ $_counter->id ] = $_counter->debug(); 952 | } 953 | } 954 | 955 | // Set the content. 956 | $content .= '# ' . __( 'General Info', 'social-count-plus' ) . ' #' . PHP_EOL . PHP_EOL; 957 | $content .= __( 'Social Count Plus Version', 'social-count-plus' ) . ': ' . Social_Count_Plus::VERSION . PHP_EOL; 958 | $content .= __( 'WordPress Version', 'social-count-plus' ) . ': ' . esc_attr( get_bloginfo( 'version' ) ) . PHP_EOL; 959 | $content .= __( 'WP Multisite Enabled', 'social-count-plus' ) . ': ' . ( ( is_multisite() ) ? __( 'Yes', 'social-count-plus' ) : __( 'No', 'social-count-plus' ) ) . PHP_EOL; 960 | $content .= __( 'Web Server Info', 'social-count-plus' ) . ': ' . esc_html( $_SERVER['SERVER_SOFTWARE'] ) . PHP_EOL; 961 | $content .= __( 'PHP Version', 'social-count-plus' ) . ': ' . ( function_exists( 'phpversion' ) ? esc_html( phpversion() ) : '' ) . PHP_EOL; 962 | $content .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? __( 'Yes', 'social-count-plus' ) : __( 'No', 'social-count-plus' ) ) . PHP_EOL; 963 | $content .= 'cURL: ' . ( function_exists( 'curl_init' ) ? __( 'Yes', 'social-count-plus' ) : __( 'No', 'social-count-plus' ) ) . PHP_EOL . PHP_EOL; 964 | $content .= '# ' . __( 'Social Connections', 'social-count-plus' ) . ' #'; 965 | $content .= PHP_EOL . PHP_EOL; 966 | 967 | if ( ! empty( $debug ) ) { 968 | foreach ( $debug as $key => $value ) { 969 | $content .= '### ' . strtoupper( esc_attr( $key ) ) . ' ###' . PHP_EOL; 970 | $content .= print_r( $value, true ); 971 | $content .= PHP_EOL . PHP_EOL; 972 | } 973 | } else { 974 | $content .= __( 'You do not have any counter that needs to connect remotely currently active', 'social-count-plus' ); 975 | } 976 | 977 | header( 'Cache-Control: public' ); 978 | header( 'Content-Description: File Transfer' ); 979 | header( 'Content-Disposition: attachment; filename=social-count-plus-debug-' . date( 'y-m-d-H-i' ) . '.txt' ); 980 | header( 'Content-Type: text/plain' ); 981 | header( 'Content-Transfer-Encoding: binary' ); 982 | 983 | echo $content; 984 | exit; 985 | } 986 | 987 | /** 988 | * Maybe install. 989 | */ 990 | public static function maybe_install() { 991 | $version = get_option( 'socialcountplus_version', '0' ); 992 | 993 | if ( version_compare( $version, Social_Count_Plus::VERSION, '<' ) ) { 994 | 995 | // Install options and updated old versions for 3.0.0. 996 | if ( version_compare( $version, '3.0.0', '<' ) ) { 997 | foreach ( self::get_plugin_options() as $settings_id => $sections ) { 998 | $saved = get_option( $settings_id, array() ); 999 | 1000 | foreach ( $sections as $section_id => $section ) { 1001 | foreach ( $section['fields'] as $field_id => $field ) { 1002 | $default = isset( $field['default'] ) ? $field['default'] : ''; 1003 | 1004 | if ( isset( $saved[ $field_id ] ) || '' === $default ) { 1005 | continue; 1006 | } 1007 | 1008 | $saved[ $field_id ] = $default; 1009 | } 1010 | } 1011 | 1012 | update_option( $settings_id, $saved ); 1013 | } 1014 | 1015 | // Set the icons order. 1016 | $icons = self::get_current_icons(); 1017 | $design = get_option( 'socialcountplus_design', array() ); 1018 | $design['icons'] = implode( ',', $icons ); 1019 | update_option( 'socialcountplus_design', $design ); 1020 | } 1021 | 1022 | // Save plugin version. 1023 | update_option( 'socialcountplus_version', Social_Count_Plus::VERSION ); 1024 | 1025 | // Reset the counters. 1026 | Social_Count_Plus_Generator::reset_count(); 1027 | } 1028 | } 1029 | 1030 | /** 1031 | * Get current icons. 1032 | * 1033 | * @return array 1034 | */ 1035 | protected static function get_current_icons() { 1036 | $settings = get_option( 'socialcountplus_settings', array() ); 1037 | $design = get_option( 'socialcountplus_design', array() ); 1038 | $current = isset( $design['icons'] ) ? explode( ',', $design['icons'] ) : array(); 1039 | $icons = array(); 1040 | 1041 | if ( function_exists( 'preg_filter' ) ) { 1042 | $saved = array_values( preg_filter('/^(.*)_active/', '$1', array_keys( $settings ) ) ); 1043 | } else { 1044 | $saved = array_values( array_diff( preg_replace( '/^(.*)_active/', '$1', array_keys( $settings ) ), array_keys( $settings ) ) ); 1045 | } 1046 | 1047 | $icons = array_unique( array_filter( array_merge( $current, $saved ) ) ); 1048 | 1049 | // Exclude extra values. 1050 | $diff = array_diff( $current, $saved ); 1051 | foreach ( $diff as $key => $value ) { 1052 | unset( $icons[ $key ] ); 1053 | } 1054 | 1055 | return $icons; 1056 | } 1057 | 1058 | /** 1059 | * Get i18n counters. 1060 | * 1061 | * @return array 1062 | */ 1063 | public function get_i18n_counters() { 1064 | return apply_filters( 'social_count_plus_icon_name_i18n', array( 1065 | 'comments' => __( 'Comments', 'social-count-plus' ), 1066 | 'facebook' => __( 'Facebook', 'social-count-plus' ), 1067 | 'github' => __( 'GitHub', 'social-count-plus' ), 1068 | 'googleplus' => __( 'Google+', 'social-count-plus' ), 1069 | 'instagram' => __( 'Instagram', 'social-count-plus' ), 1070 | 'linkedin' => __( 'LinkedIn', 'social-count-plus' ), 1071 | 'pinterest' => __( 'Pinterest', 'social-count-plus' ), 1072 | 'posts' => __( 'Posts', 'social-count-plus' ), 1073 | 'soundcloud' => __( 'SoundCloud', 'social-count-plus' ), 1074 | 'steam' => __( 'Steam', 'social-count-plus' ), 1075 | 'tumblr' => __( 'Tumblr', 'social-count-plus' ), 1076 | 'twitch' => __( 'Twitch', 'social-count-plus' ), 1077 | 'twitter' => __( 'Twitter', 'social-count-plus' ), 1078 | 'users' => __( 'Users', 'social-count-plus' ), 1079 | 'vimeo' => __( 'Vimeo', 'social-count-plus' ), 1080 | 'youtube' => __( 'YouTube', 'social-count-plus' ), 1081 | ) ); 1082 | } 1083 | 1084 | /** 1085 | * Get icons names. 1086 | * 1087 | * @param string $slug 1088 | * 1089 | * @return string 1090 | */ 1091 | protected function get_icon_name_i18n( $slug ) { 1092 | $names = $this->get_i18n_counters(); 1093 | 1094 | if ( ! isset( $names[ $slug ] ) ) { 1095 | return $slug; 1096 | } 1097 | 1098 | return $names[ $slug ]; 1099 | } 1100 | } 1101 | 1102 | new Social_Count_Plus_Admin; 1103 | --------------------------------------------------------------------------------