-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoderbits.php
More file actions
556 lines (495 loc) · 31.3 KB
/
coderbits.php
File metadata and controls
556 lines (495 loc) · 31.3 KB
1
2
3
4
5
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
<?php
/*
Plugin Name: Coderbits Profiler
Plugin URI: https://github.com/stefanbc/Coderbits-Profiler
Description: Display your Coderbits profile data using a widget or a shortcode.
Version: 1.2.6
Author: Stefan Cosma
Author URI: http://coderbits.com/stefanbc
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
// Create cache folder on activation
function coderbits_profiler_activate() {
$old = umask(0);
mkdir(WP_CONTENT_DIR . '/cache', 0777);
umask($old);
}
register_activation_hook(__FILE__, 'coderbits_profiler_activate');
// Create submenu page in the WordPress Settings menu
function coderbits_profiler() {
add_submenu_page('options-general.php', 'Coderbits Profiler', 'Coderbits Profiler', 'edit_posts', 'coderbits_profiler', 'coderbits_profiler_options');
}
add_action('admin_menu','coderbits_profiler');
// Add settings link to plugin on plugins list
function coderbits_add_settings_link($links) {
$settings_link = '<a href="options-general.php?page=coderbits_profiler">Settings</a>';
array_push($links, $settings_link);
return $links;
}
$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_$plugin", 'coderbits_add_settings_link');
// Check if the cache folder is writable
function cache_folder_notice() {
$file = substr(sprintf('%o', fileperms(dirname(__FILE__) . '/cache')), -4);
if ($file != "0777") {
echo '<div class="error">';
echo '<p>The Coderbits Profiler cache folder is not writable! Please chmod(777) the cache folder.</p>';
echo '</div>';
}
}
// General notification function
function notification($message){
echo '<div class="updated">';
echo '<p>' . $message . '</p>';
echo '</div>';
}
// Add styles to the admin header
function coderbits_profiler_admin_styles() {
// Register the styles
wp_register_style('coderbits_profiler_admin_font', 'https://fonts.googleapis.com/css?family=Roboto:300,400');
wp_register_style('coderbits_profiler_admin_style', plugins_url('assets/css/style.css', __FILE__ ));
// Register the script
wp_register_script('coderbits_profiler_admin_script', plugins_url( 'assets/general.js' , __FILE__ ));
// Enqueue styles
wp_enqueue_style('coderbits_profiler_admin_font');
wp_enqueue_style('coderbits_profiler_admin_style');
// Enqueue the script
wp_enqueue_script('coderbits_profiler_admin_script');
}
// Add styles to admin area
add_action('admin_enqueue_scripts', 'coderbits_profiler_admin_styles');
// Plugin options
function coderbits_profiler_options(){
global $wpdb;
// Add the needed options to the wp_options table
add_option('coderbits_profiler_username', $username);
add_option('coderbits_profiler_active_fields', $active_fields);
add_option('coderbits_profiler_inactive_fields', $inactive_fields);
add_option('coderbits_profiler_options', $plugin_options);
// Check if the cache folder is writable
cache_folder_notice();
add_action('admin_notices', 'cache_folder_notice');
// Get the username
$username = $wpdb->escape($_POST['username']);
// Updated the username setting with the current set username
if($username) {
// We call for the JSON file on username change
coderbits_profiler_get_json($username);
// NOtify the user
notification("The profile handler you entered has been aggregated.");
add_action('admin_notices', 'notification');
// Update the username in the database
update_option('coderbits_profiler_username', $username);
}
// Get the submit for the update data function
$update_profile_data = $wpdb->escape($_POST['update_profile_data']);
// Updated the username setting with the current set username
if($update_profile_data) {
// Get the new JSON data
coderbits_profiler_get_json(get_option('coderbits_profiler_username'));
// Notify the user
notification("Your profile data has been updated");
add_action('admin_notices', 'notification');
}
// Styling and scripting
echo '<script type="text/javascript">var AJAX_FILE = "' . plugins_url( 'assets/ajax.php' , __FILE__ ) . '";</script>';
// Start the content part
echo '<div class="main-wrapper">';
echo '<span class="main-title"><img class="logo" src="' . plugins_url( 'assets/logo.png' , __FILE__ ) . '" alt="coderbits"> Profiler</span>';
// The left part
echo '<div class="sides">';
// The profile part
echo '<h2 class="zone-title-profile">Profile <small><i>Update profile options</i></small></h2>';
echo '<div class="row">Current active Coderbits profile: <b>' . get_option('coderbits_profiler_username') . '</b></div>';
echo '<div class="row">';
echo '<form method="post" id="profile_form">';
echo 'Set Coderbits profile: <input type="text" name="username" id="username" placeholder="coderbits username"><input type="submit" name="update_profile_coderbits_profiler" id="update_profile_coderbits_profiler" value="Set Profile" class="button_action">';
echo '</form>';
echo '<form method="post" id="update_profile_form">';
echo '<input type="hidden" name="update_profile_data" id="update_profile_data" value="true"><input type="submit" name="update_profile_data_coderbits_profiler" id="update_profile_data_coderbits_profiler" value="Update Data" class="button_action">';
echo '</form>';
echo '</div>';
// The fields part
echo '<h2 class="zone-title-fields">Fields <small><i>Manage active/inactive fields</i></small></h2>';
echo '<form method="post" id="fields_form">';
echo '<div class="fields_wrapper">';
echo '<div class="smaller-side">';
echo '<h3>Active</h3>';
echo '<div class="active-fields zone" ondrop="dropField(this, event)" ondragenter="return false" ondragover="return false">';
// Get the active fields
$query_active_fields = unserialize(get_option('coderbits_profiler_active_fields'));
if (!empty($query_active_fields)) {
foreach ($query_active_fields as $active_field) {
if (!empty($active_field)) {
if ($active_field == 'gravatar_hash') {
echo '<span class="field" id="' . $active_field . '" draggable="true" ondragstart="dragField(this, event)">Avatar</span>';
} else {
echo '<span class="field" id="' . $active_field . '" draggable="true" ondragstart="dragField(this, event)">' . ucwords(str_replace("_"," ",$active_field)) . '</span>';
}
}
}
}
echo '</div>';
echo '</div>';
echo '<div class="arrows"><></div>';
echo '<div class="smaller-side">';
echo '<h3>Inactive</h3>';
echo '<div class="inactive-fields zone" ondrop="dropField(this, event)" ondragenter="return false" ondragover="return false">';
// Get the inactive fields
$query_inactive_fields = unserialize(get_option('coderbits_profiler_inactive_fields'));
if (!empty($query_inactive_fields)) {
foreach ($query_inactive_fields as $inactive_field) {
if (!empty($inactive_field)) {
if ($inactive_field == 'gravatar_hash') {
echo '<span class="field" id="' . $inactive_field . '" draggable="true" ondragstart="dragField(this, event)">Avatar</span>';
} else {
echo '<span class="field" id="' . $inactive_field . '" draggable="true" ondragstart="dragField(this, event)">' . ucwords(str_replace("_"," ",$inactive_field)) . '</span>';
}
}
}
}
// If there are no fields set, show the default ones
else {
echo '<span id="name" class="field" draggable="true" ondragstart="dragField(this, event)">Name</span>';
echo '<span id="title" class="field" draggable="true" ondragstart="dragField(this, event)">Title</span>';
echo '<span id="location" class="field" draggable="true" ondragstart="dragField(this, event)">Location</span>';
echo '<span id="website_link" class="field" draggable="true" ondragstart="dragField(this, event)">Website Link</span>';
echo '<span id="bio" class="field" draggable="true" ondragstart="dragField(this, event)">Bio</span>';
echo '<span id="views" class="field" draggable="true" ondragstart="dragField(this, event)">Views</span>';
echo '<span id="rank" class="field" draggable="true" ondragstart="dragField(this, event)">Rank</span>';
echo '<span id="gravatar_hash" class="field" draggable="true" ondragstart="dragField(this, event)">Avatar</span>';
echo '<span id="badges_count" class="field" draggable="true" ondragstart="dragField(this, event)">Badges Count</span>';
echo '<span id="follower_count" class="field" draggable="true" ondragstart="dragField(this, event)">Follower Count</span>';
echo '<span id="following_count" class="field" draggable="true" ondragstart="dragField(this, event)">Following Count</span>';
echo '<span id="top_skills" class="field" draggable="true" ondragstart="dragField(this, event)">Top Skills</span>';
echo '<span id="top_languages" class="field" draggable="true" ondragstart="dragField(this, event)">Top Languages</span>';
echo '<span id="top_environments" class="field" draggable="true" ondragstart="dragField(this, event)">Top Environments</span>';
echo '<span id="top_frameworks" class="field" draggable="true" ondragstart="dragField(this, event)">Top Frameworks</span>';
echo '<span id="top_tools" class="field" draggable="true" ondragstart="dragField(this, event)">Top Tools</span>';
echo '<span id="top_interests" class="field" draggable="true" ondragstart="dragField(this, event)">Top Interests</span>';
echo '<span id="top_traits" class="field" draggable="true" ondragstart="dragField(this, event)">Top Traits</span>';
echo '<span id="top_areas" class="field" draggable="true" ondragstart="dragField(this, event)">Top Areas</span>';
echo '<span id="badges" class="field" draggable="true" ondragstart="dragField(this, event)">Badges</span>';
echo '<span id="accounts" class="field" draggable="true" ondragstart="dragField(this, event)">Accounts</span>';
}
echo '</div>';
echo '</div>';
echo '</div>';
echo '<div id="fields_submit_button" class="submit_button"><input type="submit" name="update_fields_coderbits_profiler" id="update_fields_coderbits_profiler" value="Save Fields" class="button_action"></div>';
echo '</form>';
echo '</div>';
// The right part
echo '<div class="sides">';
echo '<h2 class="zone-title-preview">Widget Options <small><i>Change widget options</i></small></h2>';
echo '<form method="post" id="options_form">';
echo '<div class="row">Select a visual theme for the widget ';
$plugin_options = unserialize(get_option('coderbits_profiler_options'));
switch($plugin_options[0]){
case '1':
$selected1 = 'selected';
break;
case '2':
$selected2 = 'selected';
break;
case '3':
$selected3 = 'selected';
break;
case '4':
$selected4 = 'selected';
break;
}
echo '<select name="coderbits_profiler_options_visual_theme" id="coderbits_profiler_options_visual_theme">';
echo '<option value="1" ' . $selected1 . '>None</option>';
echo '<option value="2" ' . $selected2 . '>White</option>';
echo '<option value="3" ' . $selected3 . '>Black</option>';
echo '<option value="4" ' . $selected4 . '>Transparent</option>';
echo '</select><br>';
echo '<span class="alert">Warning! If you choose None, no visual style will be applied to your widget.</span>';
echo '</div>';
echo '<div id="options_submit_button" class="submit_button"><input type="submit" name="update_options_coderbits_profiler" id="update_options_coderbits_profiler" value="Save Options" class="button_action"></div>';
echo '</form>';
echo '<h2 class="zone-title-preview">Preview Widget <small><i>Preview widget based on your settings</i></small></h2>';
coderbits_profiler_output_data();
echo '</div>';
echo '</div>';
}
// Get the JSON file from coderbits
function coderbits_profiler_get_json($username) {
// jSON URL which should be requested
$json_url = 'https://coderbits.com/' . $username . '.json';
// Initializing curl
$ch = curl_init($json_url);
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json')
);
// Setting curl options
curl_setopt_array($ch, $options);
// Getting results
$result = curl_exec($ch); // Getting jSON result string
// Save the result into a local file
$save_file = file_put_contents(dirname(__FILE__) . '/cache/' . md5($username), $result);
// Close request to clear up some resources
curl_close($ch);
}
// Get data from JSON file
function coderbits_profiler_data($type, $subtype = '') {
// The filename path
$file = dirname(__FILE__) . '/cache/' . md5(get_option('coderbits_profiler_username'));
// Check if the file exists
if (file_exists($file)) {
// Read the local file for data
$json_file = file_get_contents($file);
// Parse the JSON result from the file
$output = json_decode($json_file, true);
// Output the requested field
$return = $output[$type];
// Check if the field is array
if (is_array($return)) {
// If the type is badge do other stuff
if ($type == 'badges') {
// Badge limit counter
$badge_limit_counter = 0;
// Get all the items in the array
foreach ($return as $items) {
// Each item has multiple arrays
foreach($items as $key => $badge) {
// Convert key => value arrays into variables
$$key = $badge;
}
// Check if the badge has been earned
if ($earned && !empty($earned_date) && $level == 1) {
// Build the badge
$data .= '<a href="' . $link . '" title="' . $name . ' - ' . $description . '" target="_blank"><img src="' . $image_link . '" width="45px" height="45px" class="badge" alt="badge"></a>';
// Break the loop if we reach 15 entries
if (++$badge_limit_counter == 15) break;
}
}
// Get the badges count
$badges_count = coderbits_profiler_data('one_bit_badges') + coderbits_profiler_data('eight_bit_badges') + coderbits_profiler_data('sixteen_bit_badges') + coderbits_profiler_data('thirty_two_bit_badges') + coderbits_profiler_data('sixty_four_bit_badges');
// Output it
$data .= '<a href="https://coderbits.com/' . get_option('coderbits_profiler_username') . '/badges" target="_blank">view all ' . $badges_count . '</a>';
} elseif ($type == 'accounts') {
// Get all the items in the array
foreach ($return as $items) {
// Each item has multiple arrays
foreach($items as $key => $account) {
// Convert key => value arrays into variables
$$key = $account;
}
// If it's used as a shortcode show coderbits provided image
if($subtype == 'original') {
// Some services have a different name for the image
switch($name) {
case 'Syndication Feed':
$name = 'syndication';
break;
case 'Peer 2 Peer University':
$name = 'p2pu';
break;
case 'Envato Marketplaces':
$name = 'envato';
break;
default:
$name = $name;
break;
}
// Build the service image link
$account_image = 'http://coderbits.com/images/' . str_replace(" ","",strtolower($name)) . '32.png';
$data .= '<a href="' . $link . '" title="' . $name . '" target="_blank"><img src="' . $account_image . '" class="account_shortcode" alt="account"></a>';
} else {
// Build the account link
$account_image = dirname(__FILE__) . '/assets/accounts/' . str_replace(" ","",strtolower($name)) . '-32.png';
if (file_exists($account_image)) {
$account_image = plugins_url('assets/accounts/' . str_replace(" ","",strtolower($name)) . '-32.png', __FILE__ );
} else {
$account_image = plugins_url('assets/accounts/default.png', __FILE__ );
}
$data .= '<a href="' . $link . '" title="' . $name . '" target="_blank"><img src="' . $account_image . '" class="account ' . str_replace(" ","",strtolower($name)) . '" alt="account"></a>';
}
}
} else {
// Get all the items in the array
foreach ($return as $items) {
// Each item has multiple arrays
foreach($items as $key => $item){
// Check if the key from the loop is the chosen type
if ($key == $subtype) {
$data .= $item;
// Add comma after each element except the last one
if (next($items)) $data .= ', ';
}
}
}
}
} else {
// If it's a normal field return it
$data = $return;
}
} else {
// If the file can't be read fill each value with NULL
$data = "NULL";
}
return $data;
}
// Add styles to the header
function coderbits_profiler_widget_styles() {
$plugin_options = unserialize(get_option('coderbits_profiler_options'));
switch($plugin_options[0]){
case '1':
// Register the style
wp_register_style('coderbits_profiler_style', plugins_url('assets/css/style_none.css', __FILE__ ));
break;
case '2':
// Register the style
wp_register_style('coderbits_profiler_style', plugins_url('assets/css/style_white.css', __FILE__ ));
break;
case '3':
// Register the style
wp_register_style('coderbits_profiler_style', plugins_url('assets/css/style_black.css', __FILE__ ));
break;
case '4':
// Register the style
wp_register_style('coderbits_profiler_style', plugins_url('assets/css/style_transparent.css', __FILE__ ));
break;
}
// Enqueue the style
wp_enqueue_style('coderbits_profiler_style');
}
// Add styles to front
add_action('wp_enqueue_scripts', 'coderbits_profiler_widget_styles');
// Add styles to admin area
add_action('admin_enqueue_scripts', 'coderbits_profiler_widget_styles');
// Output function used by preview and widget
function coderbits_profiler_output_data(){
// Get the active fields
$preview_fields = unserialize(get_option('coderbits_profiler_active_fields'));
if (!empty($preview_fields)) {
$plugin_options = unserialize(get_option('coderbits_profiler_options'));
echo '<div class="cp_output_wrapper">';
foreach ($preview_fields as $preview_field) {
if (!empty($preview_field)) {
switch ($preview_field) {
// Output name with link to coderbits profile page
case 'name':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><a href="https://coderbits.com/' . get_option('coderbits_profiler_username') . '" title="' . coderbits_profiler_data($preview_field) . '" target="_blank">' . coderbits_profiler_data($preview_field) . '</a></div>';
break;
// Output for title and bio are the same
case 'title':
case 'bio':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field">' . coderbits_profiler_data($preview_field) . '</div>';
break;
// Output for location has link to Google Maps
case 'location':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><a href="https://maps.google.com/maps?q=' . coderbits_profiler_data($preview_field) . '" title="' . coderbits_profiler_data($preview_field) . '" target="_blank">' . coderbits_profiler_data($preview_field) . '</a></div>';
break;
// Output for website link
case 'website_link':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><a href="' . coderbits_profiler_data($preview_field) . '" title="Website" target="_blank">' . coderbits_profiler_data($preview_field) . '</a></div>';
break;
// Output for views and rank are the same
case 'views':
case 'rank':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field">' .coderbits_profiler_data($preview_field) . ' <span class="field_text">' . strtolower($preview_field) . '</span></div>';
break;
// Output the avatar
case 'gravatar_hash':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><a href="https://coderbits.com/' . get_option('coderbits_profiler_username') . '" title="' . get_option('coderbits_profiler_username') . '" target="_blank"><img src="http://www.gravatar.com/avatar/' . coderbits_profiler_data($preview_field) . '" alt="' . get_option('coderbits_profiler_username') . '"></a></div>';
break;
// Output the badges count
case 'badges_count':
$badges_count = coderbits_profiler_data('one_bit_badges') + coderbits_profiler_data('eight_bit_badges') + coderbits_profiler_data('sixteen_bit_badges') + coderbits_profiler_data('thirty_two_bit_badges') + coderbits_profiler_data('sixty_four_bit_badges');
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field">' . $badges_count . ' <span class="field_text">' . strtolower(substr($preview_field, 0, -6)) . '</span></div>';
break;
// Output follower and following count are the same
case 'follower_count':
case 'following_count':
$text = ($preview_field == "follower_count") ? "followers" : "friends";
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field">' . coderbits_profiler_data($preview_field) . ' <span class="field_text">' . $text . '</span></div>';
break;
// Output top things are the same
case 'top_skills':
case 'top_languages':
case 'top_environments':
case 'top_frameworks':
case 'top_tools':
case 'top_interests':
case 'top_traits':
case 'top_areas':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><span class="field_text">' . ucwords(str_replace("_"," ", $preview_field)) . '</span>' . coderbits_profiler_data($preview_field, 'name') . '</div>';
break;
case 'badges':
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field">' . coderbits_profiler_data($preview_field) . '</div>';
break;
case 'accounts':
if($plugin_options[0] == 1) {
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><span class="field_text">On the web</span>' . coderbits_profiler_data($preview_field, 'original') . '</div>';
} else {
echo '<div id="' . $preview_field . '" class="' . $preview_field . ' cp_output_field"><span class="field_text">On the web</span>' . coderbits_profiler_data($preview_field) . '</div>';
}
break;
}
}
}
echo '</div>';
} else {
echo '<div class="row">No data to display, yet!</div>';
}
}
// We now create the widget and register it with WP
class CoderbitsProfilerWidget extends WP_Widget {
function CoderbitsProfilerWidget() {
// Instantiate the parent object
parent::__construct(false, 'Coderbits Profiler');
}
// Output to frontend widget
function widget($args, $instance) {
coderbits_profiler_output_data();
}
}
// Register the widget
function coderbits_profiler_register_widgets() {
register_widget('CoderbitsProfilerWidget');
}
// Hook the widget to widgets_init action
add_action('widgets_init', 'coderbits_profiler_register_widgets');
// Create the shortcode to use in posts or pages
function coderbits_profiler_output_data_shortcode($params) {
extract(shortcode_atts(array(
'data' => ''
), $params));
switch($data){
case 'gravatar_hash':
$output = '<img src="http://www.gravatar.com/avatar/' . coderbits_profiler_data($data) . '">';
break;
case 'badges_count':
$output = coderbits_profiler_data('one_bit_badges') + coderbits_profiler_data('eight_bit_badges') + coderbits_profiler_data('sixteen_bit_badges') + coderbits_profiler_data('thirty_two_bit_badges') + coderbits_profiler_data('sixty_four_bit_badges');
break;
case 'top_skills':
case 'top_languages':
case 'top_environments':
case 'top_frameworks':
case 'top_tools':
case 'top_interests':
case 'top_traits':
case 'top_areas':
$output = coderbits_profiler_data($data, 'name');
break;
case 'accounts':
$output = coderbits_profiler_data($data, 'original');
break;
default:
$output = coderbits_profiler_data($data);
break;
}
return $output;
}
// Register the shortcode
function coderbits_profiler_register_shortcodes(){
add_shortcode('coderbits-profiler', 'coderbits_profiler_output_data_shortcode');
}
// Hook the shortcode to Wordpress init
add_action('init', 'coderbits_profiler_register_shortcodes');
?>