|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * @package nyzo-tip |
| 4 | + */ |
| 5 | +/* |
| 6 | +Plugin Name: Nyzo tip button |
| 7 | +Plugin URI: https://angainor.com |
| 8 | +Description: Activate on your WordPress blog and get tips from the Nyzo Chrome extension in seconds. |
| 9 | +Version: 0.0.1 |
| 10 | +Author: AngainorDev |
| 11 | +Author URI: https://angainor.com |
| 12 | +License: Unlicence |
| 13 | +Text Domain: nyzo-tip |
| 14 | +*/ |
| 15 | + |
| 16 | +defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
| 17 | +load_plugin_textdomain('nyzo-tip', false, basename( dirname( __FILE__ ) ) . '/languages' ); |
| 18 | + |
| 19 | +$nyzotip_options = get_option('nyzotip_options'); |
| 20 | + |
| 21 | + |
| 22 | +function nyzotip_install() { |
| 23 | + global $nyzotip_options; |
| 24 | + if (!get_option('nyzo_options')) { |
| 25 | + add_option('nyzo_options', array ( |
| 26 | + 'client_url' => 'https://client.nyzo.co', |
| 27 | + 'receiver_id' => 'id__8fKFZURhpkYzQA6CkP~kivW_ospgrjJXU0tMwS3uByzcqjaVvi-I', |
| 28 | + 'stealth_tip' => true |
| 29 | + )); |
| 30 | + $nyzotip_options = get_option('nyzo_options'); |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +function get_dataset(){ |
| 35 | + global $nyzotip_options; |
| 36 | + return(' data-client-url="'.$nyzotip_options['client_url'].'" data-receiver-id="'.$nyzotip_options['receiver_id'].'" data-tag="Sent with nyzo tip wp extension" '); |
| 37 | +} |
| 38 | + |
| 39 | +function nyzotip_wp_head(){ |
| 40 | + global $nyzotip_options; |
| 41 | + if($nyzotip_options["stealth_tip"]){ |
| 42 | + echo('<span style="display:none" class="nyzo-tip-button" '.get_dataset().'></span>'); |
| 43 | + } |
| 44 | + echo('<style>.nyzo-extension-installed{content:url("/wp-content/plugins/nyzo-tip/nyzo-extension-installed-256.png");};</style>'); |
| 45 | +} |
| 46 | + |
| 47 | +add_action('wp_head', 'nyzotip_wp_head'); |
| 48 | + |
| 49 | +function nyzotip_shortcode($atts) { |
| 50 | + return('<img src="/wp-content/plugins/nyzo-tip/nyzo-extension-not-installed-256.png" class="nyzo-tip-button nyzo-extension-not-installed" '.get_dataset().'" data-tag="Sent with nyzo tip wp extension" style="width:120px">'); |
| 51 | +} |
| 52 | + |
| 53 | +add_shortcode('nyzotip', 'nyzotip_shortcode'); |
| 54 | + |
| 55 | +function nyzotip_options() { |
| 56 | + global $current_user; |
| 57 | + global $nyzotip_options; |
| 58 | + if (!is_admin()) { |
| 59 | + die(); |
| 60 | + } |
| 61 | + if (!empty($_POST['receiver_id'])) { |
| 62 | + //check_admin_referer(); |
| 63 | + $nyzotip_options['receiver_id'] = $_POST['receiver_id']; |
| 64 | + $nyzotip_options['client_url'] = $_POST['client_url']; |
| 65 | + if($_POST['stealth_tip'] == "1"){ |
| 66 | + $nyzotip_options['stealth_tip'] = true; |
| 67 | + } |
| 68 | + else{ |
| 69 | + $nyzotip_options['stealth_tip'] = false; |
| 70 | + } |
| 71 | + |
| 72 | + update_option('nyzotip_options', $nyzotip_options); |
| 73 | + |
| 74 | + echo '<div id="message" class="updated fade"><p>' . __('Changes successfully saved!', 'nyzotip') . '</p></div>' . "\n"; |
| 75 | + } |
| 76 | + |
| 77 | + $nyzotip_options = get_option('nyzotip_options'); |
| 78 | + include ('options.tmpl.php'); |
| 79 | +} |
| 80 | + |
| 81 | +function nyzotip_admin_menu() { |
| 82 | + if (is_admin()) { |
| 83 | + $menu = array ( |
| 84 | + 'Nyzotip', |
| 85 | + 'Nyzotip', |
| 86 | + 8, |
| 87 | + 'nyzotip/nyzo-tip.php' , |
| 88 | + 'nyzotip_options' |
| 89 | + ); |
| 90 | + call_user_func_array('add_menu_page', $menu); |
| 91 | + } |
| 92 | +} |
| 93 | + |
| 94 | +if (is_admin()) { |
| 95 | + register_activation_hook(__FILE__, 'nyzotip_install'); |
| 96 | + add_action('admin_menu', 'nyzotip_admin_menu'); |
| 97 | +} |
0 commit comments