├── .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 |
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 || 17 | |
|
18 |
|---|
get_scp_widget() function that displays with images.', 'social-count-plus' ); ?>
25 | 26 || 30 | |
|
31 |
|---|---|
| 35 | |
|
36 |
| 12 | | |
|---|---|
| : | 18 |19 | |
| : | 22 |23 | |
| : | 26 |27 | |
| : | 30 |31 | |
| : | 34 |35 | |
| : | 54 |55 | 56 | 57 | 58 | | 59 |
| : | 74 |75 | 76 | 77 | 78 | | 79 |
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 | '%shttps://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 | '%shttps://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( '%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 | --------------------------------------------------------------------------------