Esempio n. 1
0
            require_once jr_ps_path() . 'includes/net-settings.php';
        }
    } else {
        //	Regular (non-Network) Admin pages
        //	Settings page for Plugin
        require_once jr_ps_path() . 'includes/admin-settings.php';
    }
    //	All changes to all Admin-Installed Plugins pages
    require_once jr_ps_path() . 'includes/installed-plugins.php';
} else {
    /*	Public WordPress content, i.e. - not Admin pages
    		Do nothing if Private Site setting not set by Administrator
    	*/
    if ($settings['private_site']) {
        //	Private Site code
        require_once jr_ps_path() . 'includes/public.php';
    }
}
/**
 * Check for missing Settings and set them to defaults
 * 
 * Ensures that the Named Setting exists, and populates it with defaults for any missing values.
 * Safe to use on every execution of a plugin because it only does an expensive Database Write
 * when it finds missing Settings.
 *
 * @param	string	$name		Name of Settings as looked up with get_option()
 * @param	array	$defaults	Each default Settings value in [key] => value format
 * @param	array	$deletes	Each old Settings value to delete as [0] => key format
 * @return  bool/Null			Return value from update_option(), or NULL if update_option() not called
 */
function jr_ps_init_settings($name, $defaults, $deletes = array())
<?php

/*
	Initiated when in the Admin panels.
	Used to create the Settings page for the plugin.
*/
//	Exit if .php file accessed directly
if (!defined('ABSPATH')) {
    exit;
}
DEFINE('JR_PS_BELOW_FIELDS', '<br /> &nbsp; ');
require_once jr_ps_path() . 'includes/functions-admin.php';
add_action('admin_menu', 'jr_ps_admin_hook');
//	Runs just before admin_init (below)
/**
 * Add Admin Menu item for plugin
 * 
 * Plugin needs its own Page in the Settings section of the Admin menu.
 *
 */
function jr_ps_admin_hook()
{
    //  Add Settings Page for this Plugin
    global $jr_ps_plugin_data;
    $settings = get_option('jr_ps_settings');
    if ($settings['user_submenu']) {
        add_users_page($jr_ps_plugin_data['Name'], 'Private Site', 'add_users', 'jr_ps_settings', 'jr_ps_users_settings_page');
    }
    add_options_page($jr_ps_plugin_data['Name'], 'Private Site', 'manage_options', 'jr_ps_settings', 'jr_ps_settings_page');
}
function jr_ps_users_settings_page()