Advertisement
Guest User

Untitled

a guest
May 25th, 2018
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 63.62 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Hide My Site
  4. Description: Choose a single password to protect your entire wordpress site. Only visitors who know the password will be able to access your wordpress site. This is a great tool for someone setting up a development version of a wordpress site or anyone else looking to hide their site from the public, search engines, etc...Set your site-wide password by going to <strong>Settings > Hide My Site > Set Your Password</strong>. If you want to disable password protection uncheck the box at <strong>Settings > Hide My Site > Enable Password Protection</strong>.
  5. Version: 2.0.5
  6. Author: Justin Saad
  7. Author URI: http://www.clevelandwebdeveloper.com
  8. License: GPL2
  9. */
  10.  
  11. $plugin_label = "Hide My Site";
  12. $plugin_slug = "hide_my_site";
  13.  
  14. class hide_my_site{
  15.    
  16.     //define variables
  17.     var $plugin_label = "Hide My Site";
  18.     var $plugin_slug = "hide-my-site";
  19.    
  20.     public function __construct(){
  21.        
  22.         global $plugin_label, $plugin_slug;
  23.         $this->plugin_slug = $plugin_slug;
  24.         $this->plugin_label = $plugin_label;
  25.         $this->plugin_dir = plugins_url( '' , __FILE__ );
  26.         global $pagenow;
  27.         include('includes/security.php');
  28.         $this->security = new hidemysite_security();
  29.         if( (!is_admin()) AND ($pagenow!='xmlrpc.php') AND ($pagenow!='wp-login.php') AND (get_option($this->plugin_slug.'_enabled', 1) == 1) AND (get_option($this->plugin_slug.'_password')) ) { //public site and plugin enabled with password set
  30.             add_action('wp', array($this, 'rss_check')); //hooks into plugins_loaded. one of the earliest functions in wordpress
  31.         }
  32.        
  33.         if(is_admin()){
  34.             add_action('admin_menu', array($this, 'add_plugin_page'));
  35.             add_action('admin_init', array($this, 'page_init'));
  36.             //add admin notices
  37.             add_action( 'admin_notices', array($this, 'admin_notices') );
  38.             //add Settings link to plugin page
  39.             add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array($this, 'add_plugin_action_links') );
  40.             add_filter( 'plugin_row_meta', array($this,'plugin_row_links'), 10, 2 );
  41.            
  42.             //image upload script
  43.             add_action('admin_enqueue_scripts', array($this,'motech_imageupload_script'));
  44.            
  45.             //custom image picker css for admin page
  46.             add_action('admin_head', array($this,'motech_imagepicker_admin_css'));
  47.            
  48.             //custom image picker jquery for admin page
  49.             add_action('admin_footer', array($this,'motech_imagepicker_admin_jquery'));
  50.            
  51.             add_action( 'admin_enqueue_scripts', array($this, 'enqueue_color_picker') ); //enqueue color picker
  52.            
  53.             //admin messages
  54.             add_action('admin_notices', array($this,'admin_show_message'));
  55.             add_action('admin_init', array($this,'adminmessage_init'));
  56.         }
  57.        
  58.     }
  59.    
  60.     function enqueue_color_picker( $hook_suffix ) {
  61.         wp_enqueue_style( 'wp-color-picker' );
  62.         wp_enqueue_script( 'motech-script-handle', plugins_url('motech-color-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
  63.     }
  64.    
  65.     function motech_imageupload_script() {
  66.         if (isset($_GET['page']) && $_GET['page'] == $this->plugin_slug.'-setting-admin') {
  67.             wp_enqueue_media();
  68.             wp_register_script('motech_imageupload-js', plugins_url( 'js/motech_imageupload.js' , __FILE__ ), array('jquery'));
  69.             wp_enqueue_script('motech_imageupload-js');
  70.         }
  71.     }
  72.    
  73.     function admin_show_message()
  74.     {
  75.         $user_id = get_current_user_id();
  76.         //there is no default spacer height set, and nag message not ignored...
  77.         //$checkdefault = get_option($this->plugin_slug . '_default_height_mobile','');
  78.         if ( ( ! get_user_meta($user_id, 'hidemy4592_nag_ignore') ) && (current_user_can( 'manage_options' )) ) {
  79.             echo '<div id="message" class="updated fade notice"><p>';
  80.             echo "<b>".__('Create multiple passwords, track login attempts, and set expiration dates and access levels for your passwords with the Hide My Site add-on, Multipass!', 'motech-hidemy')."</b>";
  81.             echo "</p>";
  82.             echo "<p><strong><a href=\"http://www.clevelandwebdeveloper.com/?p=1001&amp;utm_medium=plugin&amp;utm_source=plugin-notice-msg&amp;utm_campaign=Hidemy+Notice+Msg&amp;utm_content=Multipass+Notice\" target=\"_blank\">".__('Create Multiple Passwords &raquo;', 'motech-hidemy')."</a> | <a class=\"dismiss-notice\" style=\"color:red;\" href=\"".get_bloginfo( 'wpurl' ) . "/wp-admin/options-general.php?page=".$this->plugin_slug."-setting-admin&hidemy4592_nag_ignore=0\" target=\"_parent\">".__('I got it. Thanks.', 'motech-hidemy')." [X]</a></strong></p></div>";
  83.         }
  84.     }
  85.    
  86.     function adminmessage_init()
  87.     {
  88.         if ( isset($_GET['hidemy4592_nag_ignore']) && '0' == $_GET['hidemy4592_nag_ignore'] ) {
  89.             $user_id = get_current_user_id();
  90.             add_user_meta($user_id, 'hidemy4592_nag_ignore', 'true', true);
  91.             if (wp_get_referer()) {
  92.                 /* Redirects user to where they were before */
  93.                 wp_safe_redirect(wp_get_referer());
  94.             } else {
  95.                 /* if there is no referrer you redirect to home */
  96.                 wp_safe_redirect(home_url());
  97.             }
  98.         }
  99.     }
  100.    
  101.     public function rss_check() {
  102.         if(!$this->allow_because_rss()) {
  103.             $this->verify_login();
  104.         }
  105.     }
  106.     public function allow_because_rss() {
  107.         if( (get_option($this->plugin_slug.'_public_rss', 0) == 1) and (is_feed()) ) {
  108.             return true;
  109.         } else {
  110.             return false;  
  111.         }
  112.     }
  113.     public function get_cookie_name(){
  114.         $name = $this->plugin_slug . "-access";
  115.         return $name ;
  116.     }
  117.     public function get_cookie2_name(){
  118.         $name = $this->get_cookie_name();
  119.         $cookie2suffix = get_option($this->plugin_slug . '_cookie2suffix','');
  120.         if(!empty($cookie2suffix)) { //cookie2suffix already set. add suffix from db
  121.             $name .= $cookie2suffix;
  122.         } else { //cookie2suffix not already set. generate new suffix, save to db, and add generated suffix
  123.             $generated_suffix = rand(1,99999);
  124.             update_option( $this->plugin_slug . '_cookie2suffix', $generated_suffix );
  125.             $name .= $generated_suffix;
  126.         }
  127.         return $name;
  128.     }
  129.     public function get_cookie_duration(){
  130.         $duration_setting = get_option($this->plugin_slug.'_duration', 1);
  131.         if($duration_setting > 0){
  132.             return time()+(($duration_setting)*(86400));
  133.         } else{
  134.             return 0;  
  135.         }
  136.     }
  137.     public function no_admin_bypass() {
  138.        
  139.         #logic to see if accessing from allowed ip
  140.           $allowip = "";
  141.           $value = get_option($this->plugin_slug.'_allow_ips', '');
  142.           if(!empty($value)){
  143.               $textAr = explode(",", $value);
  144.               $userip = $_SERVER['REMOTE_ADDR'];
  145.                 if (in_array($userip, $textAr)) {
  146.                     $allowip = "yes";
  147.                 }            
  148.           }
  149.         if ( (get_option($this->plugin_slug.'_allow_admin', 0) == 1) AND (current_user_can( 'manage_options' )) ){  //site owner has chosen for admins to bypass login page, and user is an admin
  150.             return false;
  151.         } elseif($allowip=="yes"){ #accessing from allowed ip
  152.             return false;
  153.         }else {
  154.             return true;   
  155.         }
  156.     }
  157.     public function get_robots_html() {
  158.         if (  get_option( 'blog_public',1 ) != 1 ){ //site owner has chosen for search engines not to index the site
  159.             return "<meta name='robots' content='noindex,follow'>";
  160.         } else {
  161.             return;
  162.         }
  163.     }
  164.     public function get_title_html() {
  165.         return;
  166.     }
  167.     public function get_preview_alert(){
  168.         if(isset($_GET['hmspreview']) && ($_GET['hmspreview'] == 'true')) {
  169.             return "
  170.                 <script>
  171.                 var form = document.forms[0];
  172.                 form.addEventListener('submit', function(evt){
  173.                      evt.preventDefault();
  174.                      alert('This is just a preview page. You can not submit the form.');
  175.                 });
  176.                 </script>
  177.             ";
  178.         }  
  179.     }
  180.     public function verify_login(){
  181.         //a password was entered. first let's confirm the user isn't blocked...
  182.         if ((isset($_POST['hwsp_motech']))) {
  183.             $this->security->track_ip();
  184.         }
  185.         do_action( 'hidemy_beforeverify', $this ); #use this hook to add additional logic before verifying password entry
  186.         //set access cookie if password is correct
  187.         if ((isset($_POST['hwsp_motech']) AND ($this->security->needs_to_wait != 1) AND ($_POST['hwsp_motech'] != "")) AND ((!empty($this->verifyother)) or ($_POST['hwsp_motech'] == get_option($this->plugin_slug.'_password'))  )) {
  188.             setcookie($this->get_cookie2_name(), 1, $this->get_cookie_duration(), '/');
  189.             $cookie_just_set = 1;
  190.             $this->cookie_just_set = 1;
  191.             $this->security->remove_ip();
  192.             $this->attempt_status = "accepted";
  193.             do_action( 'hidemy_loginattempted', $this ); #use this hook to take an action upon login acceptance...    
  194.         }
  195.         //if
  196.         //failother is true and default cookie was not just set, or no cookie is set AND cookie was not just set
  197.         //AND there is no admin bypass and this is not hmspreview
  198.             //then show the login page
  199.         if(
  200.             (isset($_GET['hmspreview']) && ($_GET['hmspreview'] == 'true'))
  201.             or
  202.             (
  203.                    (
  204.                      ( (!empty($this->failother)) AND ($this->failother) AND (empty($cookie_just_set)) )
  205.                      or
  206.                      ( (empty($_COOKIE[$this->get_cookie2_name()])) AND (empty($cookie_just_set)) )
  207.                    )  
  208.                    AND
  209.                    ( ($this->no_admin_bypass()) AND (!(isset($_GET['hmspreview']) && ($_GET['hmspreview'] == 'true'))) )  
  210.                    AND
  211.                    (empty($this->open_to_public))
  212.              )
  213.           ) {
  214.                 // This is the login page for the public
  215.                 $current_hint = get_option($this->plugin_slug.'_password_hint');
  216.                 if(!empty($current_hint)) { //there is a password hint, set the hint html
  217.                     $hinthtml = "<div id='the_hint_wrap'><div id='the_hint_title'>Password Hint:</div><div id='the_hint'>".$current_hint."</div></div>";
  218.                 } else { //no password hint
  219.                     $hinthtml = "";
  220.                 }
  221.                
  222.                 if(isset($_POST['hwsp_motech'])){
  223.                     $this->attempt_status = "rejected";
  224.                     do_action( 'hidemy_loginattempted', $this ); #use this hook to take an action upon login rejection...  
  225.                 }
  226.                
  227.                 $current_message_override = get_option($this->plugin_slug.'_custom_messaging_banner_override');
  228.                 $current_message = get_option($this->plugin_slug.'_custom_messaging_banner');
  229.                 if(!empty($current_message_override)) {
  230.                     $messagehtml = "<div id='custom_messaging_banner'>".$current_message_override."</div>";
  231.                 } elseif(!empty($current_message)) { //there is a message, set the html
  232.                     $messagehtml = "<div id='custom_messaging_banner'>".$current_message."</div>";
  233.                 } else { //no message
  234.                     $messagehtml = "";
  235.                 }
  236.                
  237.                 echo "<!DOCTYPE html><html><head><title>".(get_option($this->plugin_slug . '_pagetitle','Password Protected Site'))."</title>".$this->get_robots_html().$this->security->get_alert()."<style>";//Begin HTML and login page CSS which can be customized via plugin setting page. also include security alert if applicable
  238.                 ?>
  239.                 body {margin:0px;}
  240.                 #custom_messaging_banner {background: #eb583c;padding: 7px 10px;color: white;border-bottom: solid 3px white;font-size:16px;position:relative;z-index:1;}
  241.                 <?php
  242.                 //use custom background image if there is one
  243.                 if(get_option($this->plugin_slug.'_custom_background_image_upload')) { ?>
  244.                     body { background: url(<?php echo get_option($this->plugin_slug.'_custom_background_image_upload') ?>) !important;}
  245.                     <?php
  246.                 }
  247.                 //use custom background image position if it's set
  248.                 if(get_option($this->plugin_slug.'_custom_background_image_position', '') != '') { ?>
  249.                     <?php if ( get_option($this->plugin_slug.'_custom_background_image_position') == 'croptofit' ) : ?>
  250.                         body {background-size: cover !important;background-position: center !important;}
  251.                     <?php elseif ( get_option($this->plugin_slug.'_custom_background_image_position') == 'repeat' ) : ?>
  252.                         body {background-repeat:repeat !important;}
  253.                     <?php elseif ( get_option($this->plugin_slug.'_custom_background_image_position') == 'stretch' ) : ?>
  254.                         body {background-size: 100% 100% !important;background-repeat: no-repeat !important;background-position: center !important;}
  255.                     <?php elseif ( get_option($this->plugin_slug.'_custom_background_image_position') == 'propstretch' ) : ?>
  256.                         body {background-size: contain !important;background-repeat: no-repeat !important;background-position: center !important;}
  257.                     <?php endif ?>
  258.                     <?php
  259.                 }
  260.                 //custom background color if applicable
  261.                 if(get_option($this->plugin_slug.'_background_color', '') != '') { ?>
  262.                     body {background-color: <?php echo get_option($this->plugin_slug.'_background_color') ?> !important;}
  263.                     <?php
  264.                 }
  265.                 //use custom css if there is any
  266.                 if(get_option($this->plugin_slug.'_custom_css')) { ?>
  267.                     <?php echo get_option($this->plugin_slug.'_custom_css') ?>
  268.                     <?php
  269.                 }
  270.                 echo "</style></head>"; //End custom CSS set via plugin setting page
  271.                
  272.                
  273.                 //get the login page template
  274.                 $template_slug = get_option($this->plugin_slug . "_current_theme", "hmsclassic");
  275.                 if (  (locate_template( $template_slug.'.php' )) and (get_option($this->plugin_slug . '_ihmsa','') == 'hmsia')  ) { //template override via theme file
  276.                     include( locate_template( $template_slug.'.php' ) );
  277.                 } else { //not overriden, use plugin template
  278.                     include ('templates/'.$template_slug.'.php');
  279.                 }
  280.                 echo $this->get_preview_alert() . "</html>"; //end html
  281.                 exit;
  282.         }
  283.     }
  284.    
  285.     public function add_plugin_page(){
  286.         // This page will be under "Settings"
  287.         add_options_page('Settings Admin', $this->plugin_label, 'manage_options', $this->plugin_slug.'-setting-admin', array($this, 'create_admin_page'));
  288.     }
  289.    
  290.     public function print_section_info(){ //section summary info goes here
  291.         //print 'This is the where you set the password for your site.';
  292.     }
  293.  
  294.     public function get_donate_button(){ ?>
  295.     <style type="text/css">
  296.     .mt_donate_wrap {position:relative;}
  297.     .motechdonate{border: 1px solid #DADADA; background:white; font-family: tahoma,arial,helvetica,sans-serif;font-size: 12px;overflow: hidden;padding: 5px;position: absolute;right: 0;text-align: center;top: 0;width: 160px; box-shadow:0px 0px 8px rgba(153, 153, 153, 0.81);}
  298.     .motechdonate form{display:block;}
  299.     </style>
  300.     <div class="motechdonate">
  301.         <div style="overflow: hidden; width: 161px; text-align: center;">
  302.         <div style="overflow: hidden; width: 161px; text-align: center; float: left;"><form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input name="cmd" value="_s-xclick" type="hidden"><input name="hosted_button_id" value="9TL57UDBAB7LU" type="hidden"><input type="hidden" name="no_shipping" value="1"><input type="hidden" name="item_name" value="The Motech Network Plugin Support - <?php echo $this->plugin_label ?>" /><input alt="PayPal - The safer, easier way to pay online!" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" type="image"> <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="" border="0" height="1" width="1"></form></div>
  303.         If you enjoy or find any of my plugins useful, please donate a few dollars to my company The Motech Network to help with future development and updates. Thanks in advance.<br /><span style="font-size: 11px;display: block;margin-top: 6px;">This is for donations only. If you wish to purchase a premium license, click the <a href="javascript:void(0)" class="hms_get_premium">Get Premium</a> green button, at the top of the page, instead.</span>      </div>
  304.     </div>    
  305.    
  306.     <?php
  307.  
  308.     }
  309.  
  310.     public function create_admin_page(){
  311.         ?>
  312.         <div class="wrap" style="position:relative">
  313.             <?php screen_icon(); ?>
  314.             <h2 class="aplabel"><?php echo $this->plugin_label ?></h2>
  315.             <div id="green_ribbon">
  316.            
  317.                 <div id="green_ribbon_top">
  318.                     <div id="green_ribbon_left">
  319.                     </div>
  320.                     <div id="green_ribbon_base">
  321.                         <span id="hms_get_premium">NEW! Get Premium</span>
  322.                         <span class="hms_get_premium_meta">Hide My Site Premium is now available for as low as $20!</span>
  323.                     </div>
  324.                     <div id="green_ribbon_right">
  325.                     </div>
  326.                 </div>
  327.                
  328.                 <div class="motech_premium_box">
  329.                     <div class="motech_premium_box_wrap">
  330.                         <h2>Get Premium</h2>
  331.                         <div class="updated below-h2" style="margin-bottom: -20px !important;"><p><strong>Purchase will be processed via PayPal.</strong></p></div>
  332.                         <div class="updated below-h2"><p><strong>Every license is valid for the lifetime of the website where it's installed.</strong></p></div>
  333.                        
  334.                         <div class="motech_purchase_buttons">
  335.                        
  336.                             <div class="motech_purchase_button one_use">
  337.                                 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input name="cmd" value="_s-xclick" type="hidden"><input name="hosted_button_id" value="LB32DUSMJNQNY" type="hidden"><input type="hidden" name="page_style" value="hide_my_site_premium">
  338.                                     <button name="submit">
  339.                                         <div class="purchase_graphic">Buy 1 Use</div>
  340.                                         <div class="purchase_bubble">
  341.                                             <div class="purchase_price">$20</div>
  342.                                             <div class="purchase_meta">1 site license</div>
  343.                                         </div>
  344.                                     </button>
  345.                                     <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="" border="0" height="1" width="1">
  346.                                 </form>
  347.                             </div>
  348.                            
  349. <?php /*?>                            <div class="motech_purchase_button three_use">
  350.                                 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input name="cmd" value="_s-xclick" type="hidden"><input name="hosted_button_id" value="XPEKT7LZMF8ZL" type="hidden"><input type="hidden" name="page_style" value="hide_my_site_premium">
  351.                                     <button name="submit">
  352.                                         <div class="purchase_graphic">Buy 3 Uses</div>
  353.                                         <div class="purchase_bubble">
  354.                                             <div class="purchase_price">$50</div>
  355.                                             <div class="purchase_meta">3 site license</div>
  356.                                         </div>
  357.                                     </button>
  358.                                     <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="" border="0" height="1" width="1">
  359.                                 </form>
  360.                             </div><?php */?>
  361.                            
  362.                             <div class="motech_purchase_button unlimited_use">
  363.                                 <form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input name="cmd" value="_s-xclick" type="hidden"><input name="hosted_button_id" value="X5WGHSZDJKTJL" type="hidden"><input type="hidden" name="page_style" value="hide_my_site_premium">
  364.                                     <button name="submit">
  365.                                         <div class="purchase_graphic">Buy <span>Unlimited</span></div>
  366.                                         <div class="purchase_bubble">
  367.                                             <div class="purchase_price">$50</div>
  368.                                             <div class="purchase_meta">Unlimited sites forever!</div>
  369.                                         </div>
  370.                                     </button>
  371.                                     <img src="https://www.paypal.com/en_US/i/scr/pixel.gif" alt="" border="0" height="1" width="1">
  372.                                 </form>
  373.                             </div>
  374.                            
  375.                         </div>
  376.                        
  377.                         <div class="motech_premium_cancel"><span>Cancel</span></div>
  378.                        
  379.                     </div>
  380.                 </div>
  381.             </div>
  382.             <div class="mt_donate_wrap">
  383.                 <?php if (get_option($this->plugin_slug . '_ihmsa','') != 'hmsia') : ?>
  384.                 <?php /*?><?php $this->get_donate_button() ?><?php */?>
  385.                 <?php endif ?>
  386.             </div>
  387.  
  388.     <h2 class="nav-tab-wrapper">
  389.             <a href="#generalhidemy" class="nav-tab nav-tab-active">General</a>
  390.             <?php do_action( 'hidemy_sectiontabhook' ); #use this hook to add additional section tabs ?>
  391.             <a href="#addons" class="nav-tab"><span class="dashicons dashicons-admin-plugins"></span> <?php _e('Add-Ons', 'motech-hidemy')?></a>
  392.             <a href="#licenses" class="nav-tab"><span class="dashicons dashicons-admin-network"></span> <?php _e('Licenses', 'motech-hidemy')?></a>
  393.            <?php /*?> <a href="#licenses" class="nav-tab"><span class="dashicons dashicons-admin-network"></span> <?php _e('Licenses', 'motech-spacer')?></a><?php */?>
  394. <?php /*?>            <a href="#privacy-settings" class="nav-tab">Privacy settings</a>
  395.             <a href="#admin-custom" class="nav-tab">Admin Customizations</a>
  396.             <a href="#smtp" class="nav-tab">Smtp Settings</a><?php */?>
  397.     </h2>
  398.                
  399.             <form method="post" action="options.php" class="<?php echo $this->plugin_slug ?>_form">
  400.                 <?php
  401.                 // This prints out all hidden setting fields
  402.                 settings_fields($this->plugin_slug.'_option_group');
  403.                 ?>
  404.                 <div id="generalhidemy" class="metabox-holder mainsection">
  405.                     <?php do_settings_sections($this->plugin_slug.'-setting-admin'); ?>
  406.                     <div><?php do_settings_sections($this->plugin_slug.'-setting-admin-hidden'); ?></div>
  407.                 </div>
  408.                 <?php do_action( 'hidemy_sectionshook' ); #use this hook to add additional sections ?>
  409.                 <div id="addons" class="metabox-holder mainsection hidden">
  410.  
  411. <div class="msaddon mscol"><img src="<?php echo plugins_url( 'images/pr_banner.png' , __FILE__ ) ?>"><h2><?php _e('Premium', 'motech-hidemy') ?></h2><div class="msaddon-content"><p><?php _e('Customize your login page to give it a polished look and feel.', 'motech-hidemy') ?></p><div class="msaddon-buttons"><a href="http://www.clevelandwebdeveloper.com/wordpress-plugins/hide-site-custom-login-page-examples/?utm_medium=plugin&amp;utm_source=plugin-addons-page&amp;utm_campaign=Hidemysite+Addons+Page&amp;utm_content=Premium+Learn" target="_blank" class="button-secondary msdbutton"><?php _e('Learn More', 'motech-spacer') ?></a></div></div></div>
  412.  
  413. <div class="msaddon mscol"><img src="<?php echo plugins_url( 'images/multipass_banner2.png' , __FILE__ ) ?>"><h2><?php _e('Multipass', 'motech-hidemy') ?></h2><div class="msaddon-content"><p><?php _e('Create multiple passwords, track login attempts, set expiration dates and access levels for your passwords.', 'motech-hidemy') ?></p><div class="msaddon-buttons"><a href="http://www.clevelandwebdeveloper.com/?p=1001&amp;utm_medium=plugin&amp;utm_source=plugin-notice-msg&amp;utm_campaign=Hidemy+Addons+Page&amp;utm_content=Multipass+Learn" target="_blank" class="button-secondary msdbutton"><?php _e('Learn More', 'motech-spacer') ?></a></div></div></div>
  414.                
  415.                 <div style="clear:both;"></div>
  416.                 </div>
  417.                 <div id="licenses" class="metabox-holder mainsection hidden">
  418.                     <?php do_settings_sections($this->plugin_slug.'-setting-admin_licenses'); ?>            
  419.                 </div>                          
  420.                 <?php submit_button(); ?>
  421.             </form>
  422.         </div>
  423.     <?php
  424.     }
  425.    
  426.     public function page_init(){
  427.        
  428.         do_action( 'hidemy_sectionfieldhook', $this ); #use this hook to add additional field sections
  429.        
  430.         add_settings_section(
  431.         $this->plugin_slug.'_setting_section',
  432.         'Configuration',
  433.         array($this, 'print_section_info'),
  434.         $this->plugin_slug.'-setting-admin'
  435.         );
  436.        
  437.         add_settings_section(
  438.         $this->plugin_slug.'_setting_section',
  439.         __('Licenses', 'motech-hidemy'),
  440.         array($this, 'print_section_info_licenses'),
  441.         $this->plugin_slug.'-setting-admin_licenses'
  442.         );
  443.        
  444.         if(has_filter('hidemysite_licenses_settings')) {
  445.             apply_filters('hidemysite_licenses_settings','',$this);
  446.         }      
  447.  
  448.         //add text input field
  449.         $field_slug = "plk";
  450.         $field_label = "Premium License Key";
  451.         $field_id = $this->plugin_slug.'_'.$field_slug;
  452.         register_setting($this->plugin_slug.'_option_group', $field_id);
  453.         if( is_plugin_active( 'expansion-hide-my-site/index.php' ) ) {
  454.             $enterprompt = "<a href='" . get_bloginfo( "wpurl" ) . "/wp-admin/options-general.php?page=hide_my_site_premium_expansion-setting-admin'>Enter your license key</a> to unlock premium features. <a href='javascript:void(0)' class='hms_get_premium'>Get Premium »</a>";
  455.         } else {
  456.             $enterprompt = "Enter your license key to unlock premium features. <a href='javascript:void(0)' class='hms_get_premium'>Get Premium »</a>";
  457.         }
  458.         $enterprompt .= "<br><a href='javascript:void(0)' class='how_to_redeem'>How To Redeem Your License Key</a><div class='redeem_info'><ol><li>Download the <a href='http://www.justinsaad.com/pau/expansion-hide-my-site/expansion-hide-my-site.zip'>Hide My Site Premium Expansion plugin file</a> in zip format</li><li>Upload the zip file via WordPress plugin uploader (in your <strong>WordPress admin > Plugins > Add New > Upload</strong>) and activate it</li><li>Enter your license key in your <strong>WordPress admin > Settings > Hide My Site Premium Expansion > Premium License Key</strong></li></ol></div>";
  459.         if (get_option($this->plugin_slug . '_ihmsa','') == 'hmsia') {
  460.             $desc = "<div class='mvalid'>Valid</div>";
  461.         } else {
  462.             $desc = $enterprompt;
  463.         }
  464.         add_settings_field(
  465.             $field_id,
  466.             $field_label,
  467.             array($this, 'create_a_text_input'), //callback function for text input
  468.             $this->plugin_slug.'-setting-admin',
  469.             $this->plugin_slug.'_setting_section',
  470.             array(                              // The array of arguments to pass to the callback.
  471.                 "id" => $field_id, //sends field id to callback
  472.                 "class" => "hmshiddenfield",
  473.                 "desc" => $desc, //description of the field (optional)
  474.             )
  475.         );
  476.        
  477.         //add checkbox field
  478.         $field_slug = "enabled";
  479.         $field_label = "Enable Password Protection";
  480.         $field_id = $this->plugin_slug.'_'.$field_slug;
  481.         register_setting($this->plugin_slug.'_option_group', $field_id);
  482.         add_settings_field(
  483.             $field_id,
  484.             $field_label,
  485.             array($this, 'create_a_checkbox'), //callback function for checkbox
  486.             $this->plugin_slug.'-setting-admin',
  487.             $this->plugin_slug.'_setting_section',
  488.             array(                              // The array of arguments to pass to the callback.
  489.                 "id" => $field_id, //sends field id to callback
  490.                 "desc" => 'Check this box to enable site-wide password protection.', //description of the field (optional)
  491.                 "default" => '1' //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  492.                
  493.             )          
  494.         );
  495.    
  496.         //add text input field
  497.         $field_slug = "password";
  498.         $field_label = "Set Your Password";
  499.         $field_id = $this->plugin_slug.'_'.$field_slug;
  500.         register_setting($this->plugin_slug.'_option_group', $field_id);
  501.         add_settings_field(
  502.             $field_id,
  503.             $field_label,
  504.             array($this, 'create_a_text_input'), //callback function for text input
  505.             $this->plugin_slug.'-setting-admin',
  506.             $this->plugin_slug.'_setting_section',
  507.             array(                              // The array of arguments to pass to the callback.
  508.                 "id" => $field_id, //sends field id to callback
  509.                 "desc" => 'Choose a password for your site. Only visitors who know this password will be able to access your site.', //description of the field (optional)
  510.             )          
  511.         );
  512.        
  513.         //add text input field
  514.         $field_slug = "password_hint";
  515.         $field_label = "Password Hint (Optional)";
  516.         $field_id = $this->plugin_slug.'_'.$field_slug;
  517.         register_setting($this->plugin_slug.'_option_group', $field_id);
  518.         add_settings_field(
  519.             $field_id,
  520.             $field_label,
  521.             array($this, 'create_a_text_input'), //callback function for text input
  522.             $this->plugin_slug.'-setting-admin',
  523.             $this->plugin_slug.'_setting_section',
  524.             array(                              // The array of arguments to pass to the callback.
  525.                 "id" => $field_id, //sends field id to callback
  526.                 "maxlength" => 53, //set max length (optional)
  527.                 "desc" => 'Set a password hint to remind yourself in the future what the password is. You can also use this as a password clue that only your desired visitors would know (for example, what\'s my dog\'s name?). The hint can be a maximum of 53 characters. Leave empty to not show a password hint.', //description of the field (optional)
  528.             )          
  529.         );
  530.        
  531.         //add text input field
  532.         $field_slug = "duration";
  533.         $field_label = "Duration (in days)";
  534.         $field_id = $this->plugin_slug.'_'.$field_slug;
  535.         register_setting($this->plugin_slug.'_option_group', $field_id);
  536.         add_settings_field(
  537.             $field_id,
  538.             $field_label,
  539.             array($this, 'create_a_text_input'), //callback function for text input
  540.             $this->plugin_slug.'-setting-admin',
  541.             $this->plugin_slug.'_setting_section',
  542.             array(                              // The array of arguments to pass to the callback.
  543.                 "id" => $field_id, //sends field id to callback
  544.                 "desc" => 'For how many days do you want the user to stay logged in? If set to 0, the user will be logged out when the browser closes.', //description of the field (optional)
  545.                 "default" => '1' //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  546.             )          
  547.         );
  548.        
  549.         //add checkbox field
  550.         $field_slug = "bruteforce";
  551.         $field_label = "Brute Force Protection";
  552.         $field_id = $this->plugin_slug.'_'.$field_slug;
  553.         register_setting($this->plugin_slug.'_option_group', $field_id);
  554.         add_settings_field(
  555.             $field_id,
  556.             $field_label,
  557.             array($this, 'create_a_checkbox'), //callback function for checkbox
  558.             $this->plugin_slug.'-setting-admin',
  559.             $this->plugin_slug.'_setting_section',
  560.             array(                              // The array of arguments to pass to the callback.
  561.                 "id" => $field_id, //sends field id to callback
  562.                 "desc" => 'Check this box to temporarily block access to users after repeated failed login attempts. This protects you from hackers trying to guess your password using "Brute Force" methods', //description of the field (optional)
  563.                 "default" => '1' //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  564.                
  565.             )          
  566.         );
  567.        
  568.         //add a textarea input field
  569.         $field_slug = "allow_ips";
  570.         $field_label = "Allow IP Addresses (Optional)";
  571.         $field_id = $this->plugin_slug.'_'.$field_slug;
  572.         register_setting($this->plugin_slug.'_option_group', $field_id);
  573.         add_settings_field(
  574.             $field_id,                     
  575.             $field_label,                          
  576.             array($this, 'create_a_textarea_input'), //callback function for select input
  577.             $this->plugin_slug.'-setting-admin',
  578.             $this->plugin_slug.'_setting_section',
  579.             array(                              // The array of arguments to pass to the callback.
  580.                 "id" => $field_id, //sends field id to callback
  581.                 "desc" => 'Seperate multiple IP addresses with a comma. Do not put a space after the comma. Users from these IPs will always be granted access.', //description of the field (optional)
  582.                 "placeholder" => 'eg: 22.231.113.64,72.231.113.64' //sets the field placeholder which appears when the field is empty (optional)
  583.             )              
  584.         );     
  585.        
  586.         //add a select input field
  587.         $field_slug = "custom_messaging_banner";
  588.         $field_label = "Notification Message";
  589.         $field_id = $this->plugin_slug.'_'.$field_slug;
  590.         $this->back_options = array(
  591.                                 array("label" => "None", "value" => ""),
  592.                                 array("label" => "This site is password protected while under development. Enter your password to access the development site.", "value" => "This site is password protected while under development. Enter your password to access the development site."),
  593.                                 array("label" => "This site is a private site. You must enter the access password to proceed.", "value" => "This site is a private site. You must enter the access password to proceed."),
  594.         );
  595.         register_setting($this->plugin_slug.'_option_group', $field_id);
  596.         add_settings_field(
  597.             $field_id,                     
  598.             $field_label,                          
  599.             array($this, 'create_a_select_input'), //callback function for select input
  600.             $this->plugin_slug.'-setting-admin',
  601.             $this->plugin_slug.'_setting_section',
  602.             array(                              // The array of arguments to pass to the callback.
  603.                 "id" => $field_id, //sends select field id to callback
  604.                 "default" => '', //sets the default field value (optional), when grabbing this field value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  605.                 "desc" => 'Select a notification message to appear at the top of your login page.', //description of the field (optional)
  606.                 "meta" => 'style="max-width:450px;"',
  607.                 "select_options" => $this->back_options //sets select option data
  608.             )              
  609.         );
  610.        
  611.         //add a textarea input field
  612.         $field_slug = "custom_messaging_banner_override";
  613.         $field_label = "Custom Notification Message" . $this->get_premium_warning();
  614.         $field_id = $this->plugin_slug.'_'.$field_slug;
  615.         register_setting($this->plugin_slug.'_option_group', $field_id, array($this, 'po'));
  616.         add_settings_field(
  617.             $field_id,                     
  618.             $field_label,                          
  619.             array($this, 'create_a_textarea_input'), //callback function for select input
  620.             $this->plugin_slug.'-setting-admin',
  621.             $this->plugin_slug.'_setting_section',
  622.             array(                              // The array of arguments to pass to the callback.
  623.                 "id" => $field_id, //sends field id to callback
  624.                 "desc" => 'Enter a custom notification message to appear at the top of your login page. This will override the custom message setting in the previous field.', //description of the field (optional)
  625.                 "placeholder" => 'This website is invitation-only. Shoot me an email at info@mysite.com to request the access password.' //sets the field placeholder which appears when the field is empty (optional)
  626.             )              
  627.         );
  628.        
  629.         //add text input field
  630.         $field_slug = "pagetitle";
  631.         $field_label = "Login Page Title Tag";
  632.         $field_id = $this->plugin_slug.'_'.$field_slug;
  633.         register_setting($this->plugin_slug.'_option_group', $field_id);
  634.         add_settings_field(
  635.             $field_id,
  636.             $field_label,
  637.             array($this, 'create_a_text_input'), //callback function for text input
  638.             $this->plugin_slug.'-setting-admin',
  639.             $this->plugin_slug.'_setting_section',
  640.             array(                              // The array of arguments to pass to the callback.
  641.                 "id" => $field_id, //sends field id to callback
  642.                 "desc" => 'This will be used as the title tag for your login page.', //description of the field (optional)
  643.                 "placeholder" => 'Password Protected Site',
  644.                 "default" => 'Password Protected Site' //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  645.             )          
  646.         );
  647.  
  648.         //add checkbox field
  649.         $field_slug = "allow_admin";
  650.         $field_label = "Allow Admins?";
  651.         $field_id = $this->plugin_slug.'_'.$field_slug;
  652.         register_setting($this->plugin_slug.'_option_group', $field_id);
  653.         add_settings_field(
  654.             $field_id,
  655.             $field_label,
  656.             array($this, 'create_a_checkbox'), //callback function for checkbox
  657.             $this->plugin_slug.'-setting-admin',
  658.             $this->plugin_slug.'_setting_section',
  659.             array(                              // The array of arguments to pass to the callback.
  660.                 "id" => $field_id, //sends field id to callback
  661.                 "desc" => 'Check this box to grant access if the user is logged in as admin', //description of the field (optional)
  662.                 "default" => '0' //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  663.                
  664.             )          
  665.         );
  666.  
  667.         //add checkbox field
  668.         $field_slug = "public_rss";
  669.         $field_label = "Allow RSS?";
  670.         $field_id = $this->plugin_slug.'_'.$field_slug;
  671.         register_setting($this->plugin_slug.'_option_group', $field_id);
  672.         add_settings_field(
  673.             $field_id,
  674.             $field_label,
  675.             array($this, 'create_a_checkbox'), //callback function for checkbox
  676.             $this->plugin_slug.'-setting-admin',
  677.             $this->plugin_slug.'_setting_section',
  678.             array(                              // The array of arguments to pass to the callback.
  679.                 "id" => $field_id, //sends field id to callback
  680.                 "desc" => 'Check this box to make your rss feeds public even while your site is hidden', //description of the field (optional)
  681.                 "default" => '0' //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  682.                
  683.             )          
  684.         );
  685.        
  686.         do_action( 'hidemy_general_hook', $this ); #use this hook to add additional fields to general options section
  687.        
  688.         //add text input field
  689.         $field_slug = "prev";
  690.         $field_label = "Preview Login Page";
  691.         $field_id = $this->plugin_slug.'_'.$field_slug;
  692.         register_setting($this->plugin_slug.'_option_group', $field_id);
  693.         $desc = "<a href='" . get_bloginfo( "wpurl" ) . "?hmspreview=true' target='_blank'>View your login page &raquo;</a><br>See your login page as a logged-out visitor would see it (Remember to save any changes first!)";
  694.         add_settings_field(
  695.             $field_id,
  696.             $field_label,
  697.             array($this, 'create_a_text_input'), //callback function for text input
  698.             $this->plugin_slug.'-setting-admin',
  699.             $this->plugin_slug.'_setting_section',
  700.             array(                              // The array of arguments to pass to the callback.
  701.                 "id" => $field_id, //sends field id to callback
  702.                 "class" => "hmshiddenfield",
  703.                 "desc" => $desc, //description of the field (optional)
  704.             )
  705.         );
  706.        
  707.         add_settings_section(
  708.         $this->plugin_slug.'_setting_section_displayoptions',
  709.         '<br>Display Options',
  710.         array($this, 'get_image_picker'), //get image picker code via callback
  711.         $this->plugin_slug.'-setting-admin'
  712.         );
  713.        
  714.         //add an image select input field
  715.         $field_slug = "current_theme";
  716.         $field_label = "";
  717.         $field_id = $this->plugin_slug.'_'.$field_slug;
  718.         $this->current_theme_options = array(
  719.                                 array("label" => "Cobalt", "value" => "hmscobalt"),
  720.                                 array("label" => "Ice", "value" => "hmsice"),
  721.                                 array("label" => "Lock and Key", "value" => "hmslockandkey"),
  722.                                 array("label" => "Binder", "value" => "hmsbinder"),
  723.                                 array("label" => "Iris", "value" => "hmsiris"),
  724.                                 array("label" => "Discreet", "value" => "hmsdiscreet"),
  725.                                 array("label" => "Classic", "value" => "hmsclassic"),
  726.         );
  727.         register_setting($this->plugin_slug.'_option_group', $field_id, array($this, 'po_theme'));
  728.         add_settings_field(
  729.             $field_id,                     
  730.             $field_label,                          
  731.             array($this, 'create_a_select_input'), //callback function for select input
  732.             $this->plugin_slug.'-setting-admin',
  733.             $this->plugin_slug.'_setting_section',
  734.             array(                              // The array of arguments to pass to the callback.
  735.                 "id" => $field_id, //sends select field id to callback
  736.                 "default" => 'hmsclassic', //sets the default field value (optional), when grabbing this field value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  737.                 "select_options" => $this->current_theme_options //sets select option data
  738.             )              
  739.         );
  740.        
  741.         //add image upload field
  742.         $field_slug = "custom_background_image_upload";
  743.         $field_label = "Custom Background Image (Optional)" . $this->get_premium_warning();
  744.         $field_id = $this->plugin_slug.'_'.$field_slug;
  745.         register_setting($this->plugin_slug.'_option_group', $field_id, array($this, 'po'));
  746.         add_settings_field(
  747.           $field_id,            // ID of the option
  748.           $field_label,                      // Title of the option
  749.           array($this, 'create_image_upload'),  // Callback used to render the input field
  750.           $this->plugin_slug.'-setting-admin',               // Page to associate this option with
  751.           $this->plugin_slug.'_setting_section_displayoptions',       // Section to associate this option with
  752.             array(                              // The array of arguments to pass to the callback.
  753.                 "id" => $field_id, //sends field id to callback
  754.                 "desc" => 'Enter a URL or upload a custom background image to use for your login page. Leave empty to use the default background image.<br><span style="color:red">NEW:</span> See examples of <a href="http://www.clevelandwebdeveloper.com/wordpress-plugins/hide-site-custom-login-page-examples/" target="_blank">what you can do with a customized login page &raquo;</a>', //description of the field (optional)
  755.             )
  756.         );
  757.        
  758.         //add an image select input field
  759.         $field_slug = "custom_background_image_position";
  760.         $field_label = "Background Image Position (Optional)" . $this->get_premium_warning();
  761.         $field_id = $this->plugin_slug.'_'.$field_slug;
  762.         $this->back_options = array(
  763.                                 array("label" => "Select...", "value" => ""),
  764.                                 array("label" => "Repeat", "value" => "repeat"),
  765.                                 array("label" => "Crop to Fit", "value" => "croptofit"),
  766.                                 array("label" => "Stretch", "value" => "stretch"),
  767.                                 array("label" => "Proportional Stretch", "value" => "propstretch"),
  768.         );
  769.         register_setting($this->plugin_slug.'_option_group', $field_id, array($this, 'po'));
  770.         add_settings_field(
  771.             $field_id,                     
  772.             $field_label,                          
  773.             array($this, 'create_a_select_input'), //callback function for select input
  774.             $this->plugin_slug.'-setting-admin',
  775.             $this->plugin_slug.'_setting_section_displayoptions',
  776.             array(                              // The array of arguments to pass to the callback.
  777.                 "id" => $field_id, //sends select field id to callback
  778.                 "default" => '', //sets the default field value (optional), when grabbing this field value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  779.                 "desc" => 'Adjust how your custom background image is positioned and resized. If left empty, default settings will be used', //description of the field (optional)
  780.                 "select_options" => $this->back_options //sets select option data
  781.             )              
  782.         );
  783.        
  784.         //add color picker text input field
  785.         $field_slug = "background_color";
  786.         $field_label = "Background Color (Optional)" . $this->get_premium_warning();
  787.         $field_id = $this->plugin_slug.'_'.$field_slug;
  788.         register_setting($this->plugin_slug.'_option_group', $field_id, array($this, 'po'));
  789.         add_settings_field(
  790.             $field_id,
  791.             $field_label,
  792.             array($this, 'create_a_text_input'), //callback function for text input
  793.             $this->plugin_slug.'-setting-admin',
  794.             $this->plugin_slug.'_setting_section_displayoptions',
  795.             array(                              // The array of arguments to pass to the callback.
  796.                 "id" => $field_id, //sends field id to callback
  797.                 "desc" => 'Choose a background color to appear behind your custom image. If left empty, default background color will be used', //description of the field (optional)
  798.                 "default" => '', //sets the default field value (optional), when grabbing this option value later on remember to use get_option(option_name, default_value) so it will return default value if no value exists yet
  799.                 "class" => "motech-color-field" //designate this as color field. remember to uncomment js enqueue in class construct
  800.             )          
  801.         );
  802.        
  803.         //add textarea input field
  804.         $field_slug = "custom_css";
  805.         $field_label = "Custom CSS (Optional)" . $this->get_premium_warning();
  806.         $field_id = $this->plugin_slug.'_'.$field_slug;
  807.         register_setting($this->plugin_slug.'_option_group', $field_id, array($this, 'po'));
  808.         add_settings_field(
  809.             $field_id,                     
  810.             $field_label,                          
  811.             array($this, 'create_a_textarea_input'), //callback function for textarea input
  812.             $this->plugin_slug.'-setting-admin',
  813.             $this->plugin_slug.'_setting_section_displayoptions',
  814.             array(                              // The array of arguments to pass to the callback.
  815.                 "id" => $field_id, //sends field id to callback
  816.                 "desc" => 'Enter custom css for your login page. This is for advanced users. Just leave this empty if you\'re not sure what this means or if you don\'t have a use for it.', //description of the field (optional)
  817.                 "placeholder" => 'Custom CSS goes here.' //sets the field placeholder which appears when the field is empty (optional)
  818.             )              
  819.         );
  820.    
  821.     //add radio option
  822.     //$option_id = "status";
  823.     //add_settings_field($option_id, 'Status', array($this, 'create_radio_field'), 'wordpresshidesite-setting-admin', 'setting_section_id', array("option_id" => $option_id));
  824.            
  825.     }  //end page_init
  826.    
  827.     function po($input) {
  828.         if (get_option($this->plugin_slug . '_ihmsa','') == 'hmsia') {
  829.             return $input;     
  830.         }
  831.         if (!empty($input)) {
  832.             add_settings_error('plk_error_id8',esc_attr('settings_updated_8'),__('A premium option was not saved. You must first enter your license key to unlock this premium feature.'),'error');    
  833.         }
  834.     }
  835.  
  836.     function po_theme($input) {
  837.         if (get_option($this->plugin_slug . '_ihmsa','') == 'hmsia') {
  838.             return $input; 
  839.         } else {
  840.             if ($input != 'hmsclassic') {
  841.                 add_settings_error('plk_error_id8',esc_attr('settings_updated_8'),__('A premium option was not saved. You must first enter your license key to unlock this premium feature.'),'error');    
  842.             }
  843.             return 'hmsclassic';
  844.         }
  845.     }
  846.    
  847.     function get_premium_warning() {
  848.         if (get_option($this->plugin_slug . '_ihmsa','') == 'hmsia') {
  849.             return ''; 
  850.         } else {
  851.             return '<span class="motech_premium_only"> (Premium Only)</span>';
  852.         }
  853.     }
  854.    
  855.    
  856.     //the image picker code
  857.     public function get_image_picker(){
  858.         ?>
  859.             <strong style="display: block; font-size: 18px;margin-bottom:3px;">Select a theme for your login page<?php echo $this->get_premium_warning() ?></strong>
  860.             <div style="font-style:italic;margin-bottom:15px;">If you want a theme that doesn't block the background image, choose 'Discreet'</div>
  861.             <div class="motech_image_picker" selectid="<?php echo $this->plugin_slug ?>_current_theme"><?php /*?>put id of select field here<?php */?>
  862.             <?php $options = $this->current_theme_options ?>
  863.             <?php foreach ($options as $option) : ?>
  864.                 <div class="motech_image_picker_wrap <?php if ( $option["value"] == get_option($this->plugin_slug . "_current_theme", "hmsclassic") ) echo "current"; ?> />">
  865.                     <img src="<?php echo plugins_url( 'images/'.$option["value"].'_screenshot.jpg' , __FILE__ ) ?>" alt="<?php echo $option["value"] ?>" />
  866.                     <div><?php echo $option["label"] ?></div>
  867.                 </div>
  868.             <?php endforeach ?>
  869.             </div>
  870.         <?php
  871.     }
  872.    
  873.     function motech_imagepicker_admin_css() {
  874.         if (isset($_GET['page']) && $_GET['page'] == $this->plugin_slug.'-setting-admin') { //if we are on our admin page
  875.             ?>
  876.             <style>
  877.                 .hmshidden {display:none;}
  878.                 input.hmshiddenfield {display:none;}
  879.                 #wpbody h3 {font-size:20px;}
  880.                 #hide_my_site_current_theme {display:none;}
  881.                 div.updated.success {background-color: rgb(169, 252, 169);border-color: rgb(85, 151, 85);}
  882.                 .mvalid {background-color: rgb(169, 252, 169);border-color: rgb(85, 151, 85);width: 127px;font-weight: bold;padding-left: 10px;border: solid 1px rgb(85, 151, 85);border-radius: 3px;}
  883.                 .motech_premium_only {color:red;}
  884.                 #green_ribbon_top {position:relative;z-index:2;}
  885.                 #green_ribbon_left {background:url(<?php echo $this->plugin_dir ?>/images/green_ribbon_left.png) no-repeat -11px 0px;width: 80px;height: 60px;float: left;}
  886.                 #green_ribbon_right {background:url(<?php echo $this->plugin_dir ?>/images/green_ribbon_right.png) no-repeat;width: 80px;height: 60px;position: absolute;top: 0px;right: -10px;}
  887.                 #green_ribbon_base {background:url(<?php echo $this->plugin_dir ?>/images/green_ribbon_base.png) repeat-x;height: 60px;margin-left: 49px;margin-right: 70px;}
  888.                 #green_ribbon_base span {display: inline-block;color: white;position: relative;top: 11px;height: 35px; line-height:33px;font-size: 17px;font-weight: bold;font-style: italic;text-shadow: 1px 3px 2px #597c2a;}
  889.                 #hms_get_premium {background: rgb(58, 80, 27);background: rgba(58, 80, 27, 0.73);cursor:pointer;padding: 0px 12px;margin-left: -17px;font-style: normal !important;margin-right: 12px;text-shadow: 1px 3px 2px #364C18 !important;}
  890.                 #hms_get_premium:hover {background:rgb(30, 43, 12);background:rgba(30, 43, 12, 0.73);text-shadow: 1px 3px 2px #21310B !important;}
  891.                 .motech_premium_box {background:url(<?php echo $this->plugin_dir ?>/images/premium_back.png); margin-left: 49px;padding-top: 29px;padding-bottom:36px;margin-right: 70px;position:relative;top:-16px;display:none;}
  892.                 .motech_premium_box_wrap {margin-left:20px; margin-right:20px;}
  893.                 .motech_premium_box h2 {text-align: center;color: #585858;font-size: 36px;text-shadow: 1px 3px 2px #acabab;}
  894.                 .motech_premium_box .updated {margin-bottom: 20px !important;margin-top: 29px !important;}
  895.                 .motech_premium_box button {background: none;border: none; position:relative;cursor: pointer;overflow: visible;}
  896.                 .motech_purchase_button .purchase_graphic {background:url(<?php echo $this->plugin_dir ?>/images/buy_sprite.png) no-repeat;height: 100px;width: 101px;background-position: -17px -24px;color: white;font-size: 22px;padding: 20px 42px;padding-top: 57px;text-shadow: 1px 1px 7px black;position: absolute;top: -80px;left: -80px;line-height:normal;font-family: 'Open Sans', sans-serif;}
  897.                 .redeem_info{margin-top:20px;display:none;}
  898.                 .motech_purchase_button.unlimited_use .purchase_graphic {width: 115px;padding: 21px 36px;padding-top: 57px;}
  899.                 .motech_purchase_button.unlimited_use .purchase_graphic span {font-weight:bold;}
  900.                 .motech_purchase_button .purchase_bubble {background: white;border-radius: 9px;width: 350px;height: 123px;margin-bottom: 5px;-webkit-transition: all .2s ease-out;  -moz-transition: all .2s ease-out;-o-transition: all .2s ease-out;transition: all .2s ease-out;}
  901.                 .motech_purchase_button:hover .purchase_bubble {  background-color: #99dcf8;box-shadow:2px 3px 2px rgba(0, 0, 0, 0.31);}
  902.                 .motech_purchase_button.three_use:hover .purchase_bubble {  background-color: #96f5e4;}
  903.                 .motech_purchase_button.unlimited_use:hover .purchase_bubble {  background-color: #f8c4c6;}
  904.                 .motech_purchase_buttons {padding-top:90px;text-align:center;}
  905.                 .motech_purchase_button {display:inline-block;margin-right: 100px;vertical-align:top;}
  906.                 .motech_purchase_button .purchase_price {font-size: 60px;color: #585858;line-height:normal;}
  907.                 .motech_purchase_button:last-child {margin-right:0px;}
  908.                 .motech_purchase_button.three_use .purchase_graphic {background-position: -208px -24px;}
  909.                 .motech_purchase_button.unlimited_use .purchase_graphic {background-position: -397px -24px;}
  910.                 .motech_premium_cancel {color:#626262;text-align:center;font-size:22px;margin-top:43px;}
  911.                 .motech_premium_cancel span:hover {cursor:pointer;text-decoration:underline;}
  912.                 .<?php echo $this->plugin_slug ?>_form > .form-table {max-width:770px;}
  913.                
  914.  
  915.                 /*css for the image picker*/
  916.                 .motech_image_picker img {border-radius: 14px;box-shadow: 0px 0px 0px 2px rgba(0, 0, 255, 0.3);}
  917.                 .motech_image_picker_wrap:hover img, .motech_image_picker_wrap:focus img {box-shadow: 0px 0px 0px 2px rgba(0, 0, 255, 0.56);}
  918.                 .motech_image_picker_wrap.current img, .motech_image_picker_wrap:active img {box-shadow: 0px 0px 0px 4px rgba(0, 0, 255, 0.9);}
  919.                 .motech_image_picker_wrap {display:inline-block;cursor: pointer;margin-right:20px;margin-bottom: 30px;}
  920.                 .motech_image_picker_wrap div {font-weight:bold;font-size:16px;margin-top:10px;color:rgba(0, 0, 0, 0.47);}
  921.                
  922. /*css for addon page*/             
  923. .mscol {background: #fff;border: 1px solid #ccc;border-radius: 4px;padding: 10px;}
  924. .msaddon {float: left;margin: 0 20px 20px 0;width: 300px;position: relative;}
  925. .msaddon img {margin-bottom: 10px;max-width: 100%;height: auto;}
  926. .wrap .msaddon h2 {font-size: 14px;padding: 8px 12px;margin: 0;line-height: 1.4;display: block;font-weight: 600;}
  927. .msaddon-content p {min-height: 60px;}
  928. .msaddon .msdbutton {float: left;}
  929.                 </style>
  930.                 <?php do_action('hidemy_add_to_admincss',''); ?>
  931.                 <style>
  932.  
  933.                 /* Begin Responsive
  934.                 ====================================================================== */
  935.                 @media only screen and (max-width: 1700px) {
  936.                     .motech_purchase_button .purchase_price {font-size: 42px;padding-top: 18px;}
  937.                     .motech_purchase_button .purchase_bubble {width: 252px;}
  938.                 }
  939.                 @media only screen and (max-width: 1535px) {
  940.                     .motech_purchase_button .purchase_bubble {width: 131px;padding-top: 69px;}
  941.                     .motech_purchase_button .purchase_graphic {left: -23px;}
  942.                     .motech_purchase_button {margin-right:70px;}
  943.                 }
  944.                 @media only screen and (max-width: 1255px) {
  945.                     .motechdonate {height: 55px;}
  946.                 }
  947.                 @media only screen and (max-width: 1025px) {
  948.                     .hms_get_premium_meta {display:none !important;}
  949.                 }
  950.                 @media only screen and (max-width: 980px) {
  951.                     .motech_purchase_button {display:block;margin-bottom: 80px;margin-right:0px;}
  952.                 }
  953.                 @media only screen and (max-width: 445px) {
  954.                     .motech_premium_box h2 {font-size:22px;}
  955.                 }
  956.                 @media only screen and (max-width: 380px) {
  957.                     #green_ribbon_base span {font-size: 12px;}
  958.                     #hms_get_premium {margin-right:0px;}
  959.                 }
  960.                 @media only screen and (max-width: 330px) {
  961.                     .motech_purchase_button {
  962.                         margin-left: -9px;
  963.                     }
  964.             </style>
  965.            
  966.             <!--[if lt IE 9]>
  967.                 <style>
  968.                     .motech_image_picker_wrap.current img, .motech_image_picker_wrap:active img {
  969.                         border: 4px solid rgb(0, 0, 255);
  970.                         margin:-4px;
  971.                     }
  972.                     .motech_purchase_button {
  973.                         display: block;
  974.                         padding-bottom: 70px;
  975.                         margin-right: 0px;
  976.                     }
  977.                     .motech_purchase_button.unlimited_use {
  978.                         padding-bottom: 0px;
  979.                     }
  980.                     .hms_get_premium_meta {display:none !important;}
  981.                 </style>
  982.             <![endif]-->            
  983.             <?php
  984.         }
  985.     }
  986.    
  987.     public function print_section_info_licenses(){ //section summary info goes here
  988.         if(!has_filter('hidemysite_licenses_settings')) {
  989.             _e('To activate licenses for Hide My Site add ons you must first install and activate the chosen add on. License settings will then appear below.', 'motech-hidemy');
  990.         }
  991.     }      
  992.    
  993.     function motech_imagepicker_admin_jquery() {
  994.         if (isset($_GET['page']) && $_GET['page'] == $this->plugin_slug.'-setting-admin') { //if we are on our admin page
  995.             ?>
  996.                 <script>
  997.  
  998.                     jQuery(function($) {
  999.                                    
  1000.         //Tabs on click
  1001.         $('.nav-tab-wrapper').on('click', 'a', function(e){
  1002.             e.preventDefault();
  1003.             tabContent = $(this).attr('href');
  1004.             $('.nav-tab').removeClass('nav-tab-active');
  1005.             //$tabBoxes.addClass('hidden');
  1006.             //$currentTab = $($tabContent).toggleClass('hidden');
  1007.             $(".mainsection").addClass("hidden");
  1008.             $(tabContent+".mainsection").removeClass("hidden");
  1009.             $(this).addClass('nav-tab-active');
  1010.             if(window.location.hash != tabContent){
  1011.                 if(history.pushState) {
  1012.                     history.pushState(null, null, tabContent);
  1013.                 }
  1014.                 else {
  1015.                     location.hash = tabContent;
  1016.                 }              
  1017.                 //window.location.replace(tabContent);
  1018.             }
  1019.             if($(this).attr("href")=="#addons" || $(this).attr("href")=="#suggestionbox"){
  1020.                 $(".savebutton").hide();
  1021.             }else{
  1022.                 $(".savebutton").show();
  1023.             }
  1024.  
  1025.         })
  1026.         var hash = window.location.hash;
  1027.         $('.nav-tab-wrapper a[href="'+hash+'"]').click();      
  1028.  
  1029.                         //jquery for color picker
  1030.                         jQuery('tr.motech-color-field').removeClass('motech-color-field');
  1031.                        
  1032.                         //jquery for image picker
  1033.                         jQuery(".motech_image_picker_wrap").click(function(){
  1034.                             jQuery(this).closest(".motech_image_picker").find(".motech_image_picker_wrap").removeClass("current");
  1035.                             jQuery(this).addClass("current");
  1036.                             selectedvalue = jQuery(this).find("img").attr("alt");
  1037.                             jQuery("#<?php echo $this->plugin_slug ?>_current_theme").val(selectedvalue);
  1038.                         });
  1039.                         jQuery("#<?php echo $this->plugin_slug ?>_current_theme").parent().parent().hide();
  1040.                         <?php if (get_option($this->plugin_slug . '_ihmsa','') == 'hmsia') : ?>
  1041.                             <?php
  1042.                                 $useval = '';
  1043.                                 if(get_option('hide_my_site_premium_expansion_plk','') != '') {
  1044.                                     $useval = get_option('hide_my_site_premium_expansion_plk','');
  1045.                                 } elseif(get_option($this->plugin_slug . '_plk','') != '') {
  1046.                                     $useval = get_option('hide_my_site_premium_expansion_plk','');
  1047.                                 }
  1048.                             ?>
  1049.                             useval = '<?php echo $useval ?>';
  1050.                             jQuery("#hide_my_site_plk").replaceWith("<div>"+useval+"</div>");
  1051.                         <?php else : ?>
  1052.                             jQuery("#hide_my_site_plk").replaceWith("<div></div>");
  1053.                         <?php endif ?>
  1054.                        
  1055.                         jQuery("#hms_get_premium, .motech_premium_cancel span").click(function(){
  1056.                             jQuery(".motech_premium_box").slideToggle(200);
  1057.                         });
  1058.                         jQuery(".how_to_redeem").click(function(){
  1059.                             jQuery(".redeem_info").slideToggle(200);
  1060.                         });
  1061.                         jQuery(".hms_get_premium").click(function(){
  1062.                             jQuery("html, body").animate({ scrollTop: 0 }, 300, function() {
  1063.                                 // Animation complete.
  1064.                                 jQuery(".motech_premium_box").slideDown(200);
  1065.                             });
  1066.                         });
  1067.  
  1068.  
  1069.                     });        
  1070.                 </script>
  1071.             <?php
  1072.         }
  1073.     }
  1074.    
  1075.  
  1076.     /**
  1077.      * This following set of functions handle all input field creation
  1078.      *
  1079.      */
  1080.     function create_image_upload($args) {
  1081.         ?>
  1082.             <?php
  1083.             //set default value if applicable
  1084.             if(isset($args["default"])) {
  1085.                 $default = $args["default"];
  1086.             } else {
  1087.                 $default = false;
  1088.             }
  1089.             ?>
  1090.             <input class="motech_upload_image" type="text" size="36" name="<?php echo $args["id"] ?>" value="<?php echo get_option($args["id"], $default) ?>" />
  1091.             <input class="motech_upload_image_button" class="button" type="button" value="Upload Image" />
  1092.             <br />
  1093.             <?php
  1094.             if(isset($args["desc"])) {
  1095.                 echo "<span class='description'>".$args["desc"]."</span>";
  1096.             } else {
  1097.                 echo "<span class='description'>Enter a URL or upload an image.</span>";   
  1098.             }
  1099.             ?>
  1100.             <?php
  1101.                 $current_image = get_option($args["id"],$default);
  1102.                 if(!empty($current_image)) {
  1103.                     echo "<br><strong>Preview</strong><br><img style='padding-left:20px; max-width: 50%; max-height: 400px;' src='".$current_image."'>";   
  1104.                 }
  1105.             ?>
  1106.         <?php
  1107.     } // end create_image_upload
  1108.  
  1109.     function create_a_checkbox($args) {
  1110.         $html = '<input type="checkbox" id="'  . $args["id"] . '" name="'  . $args["id"] . '" value="1" ' . checked(1, get_option($args["id"], $args["default"]), false) . '/>';
  1111.        
  1112.         // Here, we will take the desc argument of the array and add it to a label next to the checkbox
  1113.         $html .= '<label for="'  . $args["id"] . '"> '  . $args["desc"] . '</label>';
  1114.        
  1115.         echo $html;
  1116.        
  1117.     } // end create_a_checkbox
  1118.    
  1119.     function create_a_text_input($args) {
  1120.         //grab placeholder if there is one
  1121.         if(isset($args["placeholder"])) {
  1122.             $placeholder_html = "placeholder=\"".$args["placeholder"]."\"";
  1123.         }   else {
  1124.             $placeholder_html = "";
  1125.         }
  1126.         //grab maxlength if there is one
  1127.         if(isset($args["maxlength"])) {
  1128.             $max_length_html = "maxlength=\"".$args["maxlength"]."\"";
  1129.         }   else {
  1130.             $max_length_html = "";
  1131.         }
  1132.         if(isset($args["default"])) {
  1133.             $default = $args["default"];
  1134.         } else {
  1135.             $default = false;
  1136.         }
  1137.         if(isset($args["class"])) {
  1138.             $useclass = $args["class"];
  1139.         } else {
  1140.             $useclass = "";
  1141.         }      
  1142.         // Render the output
  1143.         echo '<input type="text" '  . $placeholder_html . $max_length_html . ' id="'  . $args["id"] . '" class="' .$useclass. '" name="'  . $args["id"] . '" value="' . get_option($args["id"], $default) . '" />';
  1144.         if($args["desc"]) {
  1145.             echo "<p class='description'>".$args["desc"]."</p>";
  1146.         }
  1147.        
  1148.  
  1149.     } // end create_a_text_input
  1150.    
  1151.     function create_a_textarea_input($args) {
  1152.         //grab placeholder if there is one
  1153.         if($args["placeholder"]) {
  1154.             $placeholder_html = "placeholder=\"".$args["placeholder"]."\"";
  1155.         }   else {
  1156.             $placeholder_html = "";
  1157.         }
  1158.         //get default value if there is one
  1159.         if(isset($args["default"])) {
  1160.             $default = $args["default"];
  1161.         } else {
  1162.             $default = false;
  1163.         }
  1164.         // Render the output
  1165.         echo '<textarea '  . $placeholder_html . ' id="'  . $args["id"] . '"  name="'  . $args["id"] . '" rows="5" cols="50">' . get_option($args["id"], $default) . '</textarea>';
  1166.         if($args["desc"]) {
  1167.             echo "<p class='description'>".$args["desc"]."</p>";
  1168.         }      
  1169.     }
  1170.    
  1171.     function create_a_radio_input($args) {
  1172.    
  1173.         $radio_options = $args["radio_options"];
  1174.         $html = "";
  1175.         if($args["desc"]) {
  1176.             $html .= $args["desc"] . "<br>";
  1177.         }
  1178.         //get default value if there is one
  1179.         if(isset($args["default"])) {
  1180.             $default = $args["default"];
  1181.         } else {
  1182.             $default = false;
  1183.         }
  1184.         foreach($radio_options as $radio_option) {
  1185.             $html .= '<input type="radio" id="'  . $args["id"] . '_' . $radio_option["value"] . '" name="'  . $args["id"] . '" value="'.$radio_option["value"].'" ' . checked($radio_option["value"], get_option($args['id'], $default), false) . '/>';
  1186.             $html .= '<label for="'  . $args["id"] . '_' . $radio_option["value"] . '"> '.$radio_option["label"].'</label><br>';
  1187.         }
  1188.        
  1189.         echo $html;
  1190.    
  1191.     } // end create_a_radio_input callback
  1192.  
  1193.     function create_a_select_input($args) {
  1194.    
  1195.         $select_options = $args["select_options"];
  1196.         $html = "";
  1197.         //get default value if there is one
  1198.         if(isset($args["default"])) {
  1199.             $default = $args["default"];
  1200.         } else {
  1201.             $default = false;
  1202.         }
  1203.         if(isset($args["meta"])) {
  1204.             $meta = $args["meta"];
  1205.         } else {
  1206.             $meta = "";
  1207.         }
  1208.         $html .= '<select id="'  . $args["id"] . '" name="'  . $args["id"] . '" ' . $meta . '" >';
  1209.             foreach($select_options as $select_option) {
  1210.                 $html .= '<option value="'.$select_option["value"].'" ' . selected( $select_option["value"], get_option($args["id"], $default), false) . '>'.$select_option["label"].'</option>';
  1211.             }
  1212.         $html .= '</select>';
  1213.         if(!empty($args["desc"])) {
  1214.             $html .= "<p class='description'>".$args["desc"]."</p>";
  1215.         }      
  1216.         echo $html;
  1217.    
  1218.     } // end create_a_select_input callback
  1219.    
  1220.  
  1221.     /**
  1222.      * Add admin notices logic
  1223.      */
  1224.    
  1225.     public function admin_notices() {
  1226.         global $current_user;
  1227.         $userid = $current_user->ID;
  1228.         global $pagenow;
  1229.        
  1230.         // This notice will only be shown if no data entered for required input
  1231.         //check input field based on field slug
  1232.         $field_slug = "password";
  1233.         //check if plugin is enabled
  1234.         if((!(get_option($this->plugin_slug.'_'.$field_slug)) AND (get_option($this->plugin_slug.'_enabled', 1, false) == 1) )) {
  1235.             echo '
  1236.                 <div class="updated">
  1237.                     <p><strong>'.$this->plugin_label.' is almost ready.</strong> You must <a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/options-general.php?page='.$this->plugin_slug.'-setting-admin">set your password</a> for it to work.</p>
  1238.                 </div>';
  1239.         }
  1240.        
  1241.    
  1242.     }
  1243.    
  1244.     //add plugin action links logic
  1245.     function add_plugin_action_links( $links ) {
  1246.      
  1247.         return array_merge(
  1248.             array(
  1249.                 'settings' => '<a href="' . get_bloginfo( 'wpurl' ) . '/wp-admin/options-general.php?page='.$this->plugin_slug.'-setting-admin">Settings</a>'
  1250.             ),
  1251.             $links
  1252.         );
  1253.      
  1254.     }
  1255.    
  1256.     public function plugin_row_links($links, $file) {
  1257.         $plugin = plugin_basename(__FILE__);
  1258.         if ($file == $plugin) // only for this plugin
  1259.                 return array_merge( $links,
  1260.             array( '<a target="_blank" href="http://www.linkedin.com/in/ClevelandWebDeveloper/">' . __('Find me on LinkedIn' ) . '</a>' ),
  1261.             array( '<a target="_blank" href="http://twitter.com/ClevelandWebDev">' . __('Follow me on Twitter') . '</a>' )
  1262.         );
  1263.         return $links;
  1264.     }
  1265.    
  1266.    
  1267.        
  1268.  
  1269. } //end plugin class
  1270.  
  1271. //load the plugin
  1272. $custom_plugin = new $plugin_slug();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement