Commit 368edfd5c17f5eab8c2f7147e64f12ca3c160c0e
1 parent
a73531d6
Incluindo os arquivos do plugin.
Showing
7 changed files
with
217 additions
and
0 deletions
funifier/funifier-options.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +include('styles.css'); | ||
| 4 | + | ||
| 5 | +$submitted = sanitize_text_field($_POST['submitted']); | ||
| 6 | +if (isset($submitted) && !empty($submitted)) { | ||
| 7 | + | ||
| 8 | + $apikey = sanitize_text_field($_POST['funifier-api-key']); | ||
| 9 | + $checkWidgetSite = sanitize_text_field($_POST['funifier-check-widget-site']); | ||
| 10 | + $checkWidgetAdmin = sanitize_text_field($_POST['funifier-check-widget-admin']); | ||
| 11 | + $loginImplicit = sanitize_text_field($_POST['funifier-login-implicit']); | ||
| 12 | + | ||
| 13 | + update_option('funifier-api-key', $apikey); | ||
| 14 | + update_option('funifier-check-widget-site', $checkWidgetSite); | ||
| 15 | + update_option('funifier-check-widget-admin', $checkWidgetAdmin); | ||
| 16 | + update_option('funifier-login-implicit', $loginImplicit); | ||
| 17 | +} | ||
| 18 | +?> | ||
| 19 | + | ||
| 20 | +<div class="wrap"> | ||
| 21 | + <form method="post" action="<?php echo get_option('siteurl').'/wp-admin/admin.php?page=funifier'; ?>" id="form-funifier"> | ||
| 22 | + <div class="funifier-div"> | ||
| 23 | + <div class="title-funifier"><img src="<?php echo esc_url(plugin_dir_url( __FILE__ ).'logo-funifier.png'); ?>" /></div> | ||
| 24 | + <table class="form-table"> | ||
| 25 | + <tr class="funifier-tr"> | ||
| 26 | + <td class="funifier-th"><?php echo esc_html('API Key:'); ?></td> | ||
| 27 | + <td><input type="text" size="25" name="funifier-api-key" value="<?php echo (stripslashes(get_option('funifier-api-key'))); ?>" class="funifier-input"></td> | ||
| 28 | + </tr> | ||
| 29 | + <tr class="funifier-tr"> | ||
| 30 | + <td class="funifier-th"><?php echo esc_html('Show Widget Site:'); ?></td> | ||
| 31 | + <td><input type="checkbox" name="funifier-check-widget-site" value="1" class="funifier-input" <?php echo (stripslashes(get_option('funifier-check-widget-site'))) ? 'checked="checked"' : ''; ?>></td> | ||
| 32 | + </tr> | ||
| 33 | + <tr class="funifier-tr"> | ||
| 34 | + <td class="funifier-th"><?php echo esc_html('Show Widget Admin:'); ?></td> | ||
| 35 | + <td><input type="checkbox" name="funifier-check-widget-admin" value="1" class="funifier-input" <?php echo (stripslashes(get_option('funifier-check-widget-admin'))) ? 'checked="checked"' : ''; ?>></td> | ||
| 36 | + </tr> | ||
| 37 | + <tr class="funifier-tr"> | ||
| 38 | + <td class="funifier-th"><?php echo esc_html('Login implicit with actual user wordpress:'); ?></td> | ||
| 39 | + <td><input type="checkbox" name="funifier-login-implicit" value="1" class="funifier-input" <?php echo (stripslashes(get_option('funifier-login-implicit'))) ? 'checked="checked"' : ''; ?>></td> | ||
| 40 | + </tr> | ||
| 41 | + </table> | ||
| 42 | + </div> | ||
| 43 | + <input type="hidden" name="submitted" id="submitted" value="1"> | ||
| 44 | + <p class="submit"> | ||
| 45 | + <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" /> | ||
| 46 | + </p> | ||
| 47 | + </form> | ||
| 48 | +</div> | ||
| 49 | + |
funifier/funifier.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/* | ||
| 3 | +Plugin Name: Funifier | ||
| 4 | +Plugin URI: http://www.funifier.com | ||
| 5 | +Description: O plugin do Funifier foi criado para integração com o sistema de gamificação da empresa. | ||
| 6 | +Author: Jefferson Alessandro | ||
| 7 | +Author URI: https://plus.google.com/+jeffalessandro/about | ||
| 8 | +Contributors: Caio Lucena | ||
| 9 | +Tags: admin, javascript, gamification, funifier | ||
| 10 | +Version: 1.0 | ||
| 11 | +*/ | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Add admin menu | ||
| 15 | + */ | ||
| 16 | +function funifier_add_menu() { | ||
| 17 | + add_menu_page('Funifier Settings', 'Funifier', 'manage_options', 'funifier', 'funifier_options', plugin_dir_url( __FILE__ ).'funifier.png'); | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * Sanitize options | ||
| 22 | + */ | ||
| 23 | +function funifier_options_validate($input) { | ||
| 24 | + return $input; | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Include options page | ||
| 29 | + */ | ||
| 30 | +function funifier_options() { | ||
| 31 | + include 'funifier-options.php'; | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +/** | ||
| 35 | + * Add widget start - Admin Control | ||
| 36 | + */ | ||
| 37 | +function admin_funifier_js(){ | ||
| 38 | + $funifierApiKey = stripslashes(get_option('funifier-api-key')); | ||
| 39 | + $funifierLoginImplicit = stripslashes(get_option('funifier-login-implicit')); | ||
| 40 | + | ||
| 41 | + if($funifierLoginImplicit){ | ||
| 42 | + global $current_user; | ||
| 43 | + $current_user = wp_get_current_user(); | ||
| 44 | + $user_info = get_userdata($current_user->ID); | ||
| 45 | + //$first_name = $user_info->first_name; | ||
| 46 | + $user_email = $user_info->user_email; | ||
| 47 | + $funifierHtmlLoginImplicit = " | ||
| 48 | + Funifier.auth.authenticate({ | ||
| 49 | + auth_mode: 'IMPLICIT', | ||
| 50 | + player: '$user_email' | ||
| 51 | + }, function (err, data) { }); | ||
| 52 | + "; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + wp_enqueue_script( 'my_custom_script', '//client2.funifier.com/2.0.0/funifier.js' ); | ||
| 56 | + echo '<script type="text/javascript">'; | ||
| 57 | + echo 'window.funifierAsyncInit = function(){ Funifier.init({ apiKey : "'.$funifierApiKey.'" },function(err){ | ||
| 58 | + Funifier._$("body").append(\'<div data-funifier-gui="start" data-id="pluginStart"></div>\'); | ||
| 59 | + Funifier.widget._init(); | ||
| 60 | + '.$funifierHtmlLoginImplicit.' }); };'; | ||
| 61 | + echo "</script>"; | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +$funifierCheckWidgetAdmin = stripslashes(get_option('funifier-check-widget-admin')); | ||
| 65 | +if($funifierCheckWidgetAdmin){ | ||
| 66 | + add_action( 'admin_enqueue_scripts', 'admin_funifier_js' ); | ||
| 67 | +} | ||
| 68 | + | ||
| 69 | +/** | ||
| 70 | + * Add widget start - Website | ||
| 71 | + */ | ||
| 72 | +function site_funifier_js(){ | ||
| 73 | + $funifierApiKey = stripslashes(get_option('funifier-api-key')); | ||
| 74 | + | ||
| 75 | + wp_enqueue_script( 'my_custom_script', '//client2.funifier.com/2.0.0/funifier.js' ); | ||
| 76 | + echo '<script type="text/javascript">'; | ||
| 77 | + echo 'window.funifierAsyncInit = function(){ Funifier.init({ apiKey : "'.$funifierApiKey.'" },function(err){ | ||
| 78 | + if(err==null){ | ||
| 79 | + Funifier._$("body").append(\'<div data-funifier-gui="start" data-id="pluginStart"></div>\'); | ||
| 80 | + Funifier.widget._init(); | ||
| 81 | + } | ||
| 82 | + }); };'; | ||
| 83 | + echo "</script>"; | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +$funifierCheckWidgetSite = stripslashes(get_option('funifier-check-widget-site')); | ||
| 87 | +if($funifierCheckWidgetSite){ | ||
| 88 | + add_action( 'wp_enqueue_scripts', 'site_funifier_js' ); | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +/** | ||
| 92 | + * Add Funifier Menu | ||
| 93 | + */ | ||
| 94 | +add_action('admin_menu', 'funifier_add_menu'); | ||
| 95 | + | ||
| 96 | +?> |
funifier/funifier.png
0 → 100644
641 Bytes
funifier/logo-funifier.png
0 → 100644
6.98 KB
funifier/readme.txt
0 → 100644
| 1 | +=== Funifier === | ||
| 2 | +Plugin Name: Funifier | ||
| 3 | +Plugin URI: http://www.funifier.com | ||
| 4 | +Description: O plugin do Funifier foi criado para integração com o sistema de gamificação da empresa. | ||
| 5 | +Author: Jefferson Alessandro | ||
| 6 | +Author URI: https://plus.google.com/+jeffalessandro/about | ||
| 7 | +Contributors: Caio Lucena | ||
| 8 | +Tags: admin, javascript, gamification, funifier | ||
| 9 | +Version: 1.0 | ||
| 10 | + | ||
| 11 | +O plugin do Funifier foi criado para integração com o sistema de gamificação da empresa. | ||
| 12 | + | ||
| 13 | +== Description == | ||
| 14 | + | ||
| 15 | +Para conhecer mais sobre como gamificar seu site, acesse o site www.funifier.com! | ||
| 16 | + | ||
| 17 | +== Installation == | ||
| 18 | + | ||
| 19 | +1. Faça o upload do arquivo funifer.zip no menu Plugins -> Adicionar Novo; | ||
| 20 | +2. Ative o plugin após a instalação; | ||
| 21 | +3. Edite o contúdo do HTML em Configurações -> Funifier | ||
| 22 | + | ||
| 23 | +== Frequently Asked Questions == | ||
| 24 | + | ||
| 25 | +== Changelog == | ||
| 26 | + | ||
| 27 | += 1.0 = | ||
| 28 | +Release inicial |
funifier/styles.css
0 → 100644
| 1 | +<style type="text/css"> | ||
| 2 | + .funifier-div{ | ||
| 3 | + padding-top: 10px; | ||
| 4 | + padding-right: 10px; | ||
| 5 | + padding-left: 10px; | ||
| 6 | + background-color: #D5D5D5; | ||
| 7 | + } | ||
| 8 | + .title-funifier { | ||
| 9 | + background-color: #252527; | ||
| 10 | + font-size: 20px; | ||
| 11 | + padding: 10px 25px; | ||
| 12 | + } | ||
| 13 | + .form-table { | ||
| 14 | + margin-top: 0px; | ||
| 15 | + border-collapse: separate !important; | ||
| 16 | + border-spacing: 0px 10px !important; | ||
| 17 | + } | ||
| 18 | + .funifier-tr { | ||
| 19 | + background-color: #DFDFDF !important; | ||
| 20 | + } | ||
| 21 | + .funifier-th { | ||
| 22 | + font-size: 16px !important; | ||
| 23 | + font-weight: 100; | ||
| 24 | + width: 170px; | ||
| 25 | + height: 40px; | ||
| 26 | + text-align: right; | ||
| 27 | + } | ||
| 28 | + .funifier-input { | ||
| 29 | + padding: 8px !important; | ||
| 30 | + border: 1px solid #999 !important; | ||
| 31 | + color: #555 !important; | ||
| 32 | + } | ||
| 33 | +</style> |
funifier/uninstall.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +//if uninstall not called from WordPress exit | ||
| 4 | +if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) | ||
| 5 | + exit(); | ||
| 6 | + | ||
| 7 | +// Deleta as opções | ||
| 8 | +delete_option( 'funifier-api-key' ); | ||
| 9 | +delete_option( 'funifier-check-widget-site' ); | ||
| 10 | +delete_option( 'funifier-check-widget-admin' ); | ||
| 11 | +delete_option( 'funifier-login-implicit' ); |