aioFaviconDefaultSettings();
$this->aioFaviconSettings = wp_parse_args($usersettings, $defaultArray);
if(!is_admin()){
require_once 'includes/header-blog.php';
add_action( 'wp_head', 'aioFaviconRenderBlogHeader' );
} else if (is_admin()){
require_once 'includes/header-admin.php';
add_action( 'admin_head', 'aioFaviconRenderAdminHeader' );
}
// only register scripts and styles for this plugin page since JavaScript overwrites default WordPress behaviour
if (isset($_GET['page']) && $_GET['page'] == 'all-in-one-favicon/all-in-one-favicon.php') {
add_action('admin_print_scripts', array(& $this, 'registerAdminScripts'));
add_action('admin_print_styles', array(& $this, 'registerAdminStyles'));
}
//only add link to meta box
if(isset($this->aioFaviconSettings['removeLinkFromMetaBox']) && !$this->aioFaviconSettings['removeLinkFromMetaBox']){
add_action('wp_meta',array(& $this, 'renderMetaLink'));
}
}
// allInOneFavicon()
/**
* Renders plugin link in Meta widget
*
* @since 1.0
* @access public
* @author Arne Franken
*/
//public function renderMetaLink() {
function renderMetaLink() { ?>
registerAdminNotice($return_message);
$this->registerSettingsPage();
}
// registerAdminMenu()
/**
* Registers Admin Notices
*
* @since 1.0
* @access private
* @author Arne Franken
*/
//private function registerAdminNotice($notice) {
function registerAdminNotice($notice) {
if ($notice != '') {
$message = '';
add_action('admin_notices', create_function('', "echo '$message';"));
}
}
// registerAdminNotice()
/**
* Default array of All In One Favicon settings
*
* @since 3.0
* @access private
* @author Arne Franken
*/
//private function aioFaviconDefaultSettings() {
function aioFaviconDefaultSettings() {
// Create and return array of default settings
return array(
'aioFaviconVersion' => AIOFAVICON_VERSION,
'debugMode' => false,
'removeLinkFromMetaBox' => false
);
}
// aioFaviconDefaultSettings()
/**
* Update jQuery Colorbox settings wrapper
*
* handles checks and redirect
*
* @since 1.0
* @access public
* @author Arne Franken
*/
//public function aioFaviconUpdateSettings() {
function aioFaviconUpdateSettings() {
if (!current_user_can('manage_options'))
wp_die(__('Did not update settings, you do not have the necessary rights.', AIOFAVICON_TEXTDOMAIN));
//cross check the given referer for nonce set in settings form
check_admin_referer('aio-favicon-settings-form');
//get settings from plugins admin page
$this->aioFaviconSettings = $_POST[AIOFAVICON_SETTINGSNAME];
//have to add jQueryColorboxVersion here because it is not included in the HTML form
$this->aioFaviconSettings['aioFaviconVersion'] = AIOFAVICON_VERSION;
$this->updateSettingsInDatabase();
$referrer = str_replace(array('&aioFaviconUpdateSettings', '&aioFaviconDeleteSettings'), '', $_POST['_wp_http_referer']);
wp_redirect($referrer . '&aioFaviconUpdateSettings');
}
// aioFaviconUpdateSettings()
/**
* Update jQuery Colorbox settings
*
* handles updating settings in the WordPress database
*
* @since 1.0
* @access private
* @author Arne Franken
*/
//private function updateSettingsInDatabase() {
function updateSettingsInDatabase() {
update_option(AIOFAVICON_SETTINGSNAME, $this->aioFaviconSettings);
}
//aioFaviconUpdateSettingsInDatabase()
/**
* Delete jQuery Colorbox settings wrapper
*
* handles checks and redirect
*
* @since 1.0
* @access public
* @author Arne Franken
*/
//public function aioFaviconDeleteSettings() {
function aioFaviconDeleteSettings() {
if (current_user_can('manage_options') && isset($_POST['delete_settings-true'])) {
//cross check the given referer for nonce set in delete settings form
check_admin_referer('aio-favicon-delete_settings-form');
$this->deleteSettingsFromDatabase();
} else {
wp_die(sprintf(__('Did not delete %1$s settings. Either you dont have the nececssary rights or you didnt check the checkbox.', AIOFAVICON_TEXTDOMAIN), AIOFAVICON_NAME));
}
//clean up referrer
$referrer = str_replace(array('&aioFaviconUpdateSettings', '&aioFaviconDeleteSettings'), '', $_POST['_wp_http_referer']);
wp_redirect($referrer . '&aioFaviconDeleteSettings');
}
// aioFaviconDeleteSettings()
/**
* Delete jQuery Colorbox settings
*
* handles deletion from WordPress database
*
* @since 1.0
* @access private
* @author Arne Franken
*/
//private function deleteSettingsFromDatabase() {
function deleteSettingsFromDatabase() {
delete_option(AIOFAVICON_SETTINGSNAME);
}
// aioFaviconDeleteSettingsFromDatabase()
/**
* Read HTML from a remote url
*
* @since 2.1
* @access private
* @author Arne Franken
*
* @param string $url
* @return the response
*/
//private function getRemoteContent($url) {
function getRemoteContent($url) {
if ( function_exists('wp_remote_request') ) {
$options = array();
$options['headers'] = array(
'User-Agent' => 'All-in-One Favicon V' . AIOFAVICON_VERSION . '; (' . get_bloginfo('url') .')'
);
$response = wp_remote_request($url, $options);
if ( is_wp_error( $response ) )
return false;
if ( 200 != wp_remote_retrieve_response_code($response) )
return false;
return wp_remote_retrieve_body($response);
}
return false;
}
// getRemoteContent()
/**
* gets current URL to return to after donating
*
* @since 2.1
* @access private
* @author Arne Franken
*/
//private function getReturnLocation(){
function getReturnLocation(){
$currentLocation = "http";
$currentLocation .= ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? "s" : "")."://";
$currentLocation .= $_SERVER['SERVER_NAME'];
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') {
if($_SERVER['SERVER_PORT']!='443') {
$currentLocation .= ":".$_SERVER['SERVER_PORT'];
}
}
else {
if($_SERVER['SERVER_PORT']!='80') {
$currentLocation .= ":".$_SERVER['SERVER_PORT'];
}
}
$currentLocation .= $_SERVER['REQUEST_URI'];
echo $currentLocation;
}
// getReturnLocation()
}
?>