Commit 8d590436 authored by Varun Sridharan's avatar Varun Sridharan

Fixes #38 Fixes #35

* Moved Template File Check From admin functions to plugin install class
* New Menu Added {Support Request} And Added Its JS & CSS
* Included Sys Info plugin
* Re-modified Admin Notice
* Auto Flush Permalink
* wc_page_endpoint_title issue fixed
parent c7a11ad1
...@@ -18,52 +18,13 @@ if ( ! defined( 'WPINC' ) ) { die; } ...@@ -18,52 +18,13 @@ if ( ! defined( 'WPINC' ) ) { die; }
class WooCommerce_Quick_Donation_Admin_Function { class WooCommerce_Quick_Donation_Admin_Function {
public function __construct(){ public function __construct(){
$this->check_template_files();
add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2); add_action( 'post_row_actions', array($this,'protect_donation_product'),99,2);
add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) ); add_action( 'parse_query', array( $this, 'hide_donation_order_woocommerce_order' ) );
add_filter( 'wc_order_types',array($this,'add_wc_order_types'),99,2); add_filter( 'wc_order_types',array($this,'add_wc_order_types'),99,2);
} }
public function check_template_files(){
$template_files = WC_Admin_Status::scan_template_files( WC_QD_TEMPLATE );
$outdated = false;
if(is_array($template_files)){
foreach($template_files as $file){
$theme_file = false;
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/' . $file;
} elseif ( file_exists( get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file ) ) {
$theme_file = get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file;
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
$theme_file = get_template_directory() . '/' . $file;
} elseif( file_exists( get_template_directory() . WC_QD_THEME_TEMPLATE . $file ) ) {
$theme_file = get_template_directory() . WC_QD_THEME_TEMPLATE . $file;
}
if ( $theme_file !== false ) {
$core_version = WC_Admin_Status::get_file_version(WC_QD_TEMPLATE.$file);
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
$outdated = true;
break;
}
}
}
if ( $outdated ) {
$theme = wp_get_theme();
$message = sprintf( __( '<strong>Your theme (%s) contains outdated copies of some WooCommerce Quick Donation template files.</strong> These files may need updating to ensure they are compatible with the current version of WooCommerce Quick Donation. You can see which files are affected from the %ssystem status page%s. If in doubt, check with the author of the theme.', 'woocommerce' ), esc_html( $theme['Name'] ), '<a href="' . esc_url( admin_url( 'admin.php?page=wc-status' ) ) . '">', '</a>' );
wc_qd_notice($message,'error');
}
}
}
public function hide_donation_order_woocommerce_order($query) { public function hide_donation_order_woocommerce_order($query) {
global $pagenow,$post_type; global $pagenow,$post_type;
......
...@@ -58,6 +58,13 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -58,6 +58,13 @@ class WooCommerce_Quick_Donation_Admin {
'administrator', 'administrator',
'wc_qd_donors', 'wc_qd_donors',
array($this,'donors_listing_page')); array($this,'donors_listing_page'));
$this->donors_list = add_submenu_page('edit.php?post_type=wcqd_project',
__('Support Request',WC_QD_TXT),
__('Support Request',WC_QD_TXT),
'administrator',
'wc_qd_support',
array($this,'support_request'));
} }
...@@ -75,6 +82,7 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -75,6 +82,7 @@ class WooCommerce_Quick_Donation_Admin {
$arr[] = $submenu[$name][15]; $arr[] = $submenu[$name][15];
$arr[] = $submenu[$name][16]; $arr[] = $submenu[$name][16];
$arr[] = $submenu[$name][17]; $arr[] = $submenu[$name][17];
$arr[] = $submenu[$name][20];
$submenu[$name] = $arr; $submenu[$name] = $arr;
return $menu_ord; return $menu_ord;
} }
...@@ -124,6 +132,12 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -124,6 +132,12 @@ class WooCommerce_Quick_Donation_Admin {
donor_render_list_page($args); donor_render_list_page($args);
} }
public function support_request(){
require(WC_QD_ADMIN.'/sysinfo/sysinfo.php');
$sysinfo = new WooCommerce_Quick_Donation_SysInfo;
$sysinfo->setup();
$sysinfo->render_info();
}
public function donation_orders_page(){ public function donation_orders_page(){
global $wpdb; global $wpdb;
...@@ -164,10 +178,12 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -164,10 +178,12 @@ class WooCommerce_Quick_Donation_Admin {
wp_enqueue_style(WC_QD_SLUG.'_quick_hacks',WC_QD_CSS.'admin-hack-style.css' , array(), WC_QD()->version, 'all' ); wp_enqueue_style(WC_QD_SLUG.'_quick_hacks',WC_QD_CSS.'admin-hack-style.css' , array(), WC_QD()->version, 'all' );
if('wcqd_project_page_WC_QD_settings' == $this->current_screen()){ if('wcqd_project_page_WC_QD_settings' == $this->current_screen()){
wp_enqueue_style(WC_QD_SLUG.'_core_style',WC_QD_CSS.'admin-settings-style.css' , array(), WC_QD()->version, 'all' ); wp_enqueue_style(WC_QD_SLUG.'_settings_style',WC_QD_CSS.'admin-settings-style.css' , array(), WC_QD()->version, 'all' );
} }
if('wcqd_project_page_wc_qd_support' == $this->current_screen()){
wp_enqueue_style(WC_QD_SLUG.'_sysinfo_style',WC_QD_CSS.'sysinfo.css' , array(), WC_QD()->version, 'all' );
}
if(in_array($this->current_screen() , $this->get_screen_ids())) { if(in_array($this->current_screen() , $this->get_screen_ids())) {
wp_enqueue_style(WC_QD_SLUG.'_core_style',WC_QD_CSS.'admin-style.css' , array(), WC_QD()->version, 'all' ); wp_enqueue_style(WC_QD_SLUG.'_core_style',WC_QD_CSS.'admin-style.css' , array(), WC_QD()->version, 'all' );
...@@ -182,6 +198,13 @@ class WooCommerce_Quick_Donation_Admin { ...@@ -182,6 +198,13 @@ class WooCommerce_Quick_Donation_Admin {
if(in_array($this->current_screen() , $this->get_screen_ids())) { if(in_array($this->current_screen() , $this->get_screen_ids())) {
wp_enqueue_script(WC_QD_SLUG.'_core_script', WC_QD_JS.'admin-script.js', array('jquery'), WC_QD()->version, false ); wp_enqueue_script(WC_QD_SLUG.'_core_script', WC_QD_JS.'admin-script.js', array('jquery'), WC_QD()->version, false );
} }
if('wcqd_project_page_wc_qd_support' == $this->current_screen()){
wp_register_script(WC_QD_SLUG.'_sysinfo_script', WC_QD_JS.'sysinfo.js', array( 'jquery' ), WC_QD()->version,false );
wp_localize_script(WC_QD_SLUG.'_sysinfo_script', 'systemInfoAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );
wp_enqueue_script(WC_QD_SLUG.'_sysinfo_script');
}
} }
public function set_wc_screen_ids($screens){ public function set_wc_screen_ids($screens){
......
<?php
/**
* Modified to remove var
* Chris Christoff on 12/26/2012
* Changes: Changes vars to publics
*
* Modified by
* Chris Christoff on 12/23/2012
* Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
*
* Modified to add formatted User Agent string by
* Chris Christoff on 12/23/2012
* Changes: Split user string and add formatting so we can print a nicely
* formatted user agent string
*
* File: Browser.php
* Author: Chris Schuld (http://chrisschuld.com/)
* Last Modified: August 20th, 2010
* @version 1.9
* @package PegasusPHP
*
* Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details at:
* http://www.gnu.org/copyleft/gpl.html
*
*
* Typical Usage:
*
* $browser = new Browser();
* if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
* echo 'You have FireFox version 2 or greater';
* }
*
* User Agents Sampled from: http://www.useragentstring.com/
*
* This implementation is based on the original work from Gary White
* http://apptools.com/phptools/browser/
*
* UPDATES:
*
* 2010-08-20 (v1.9):
* + Added MSN Explorer Browser (legacy)
* + Added Bing/MSN Robot (Thanks Rob MacDonald)
* + Added the Android Platform (PLATFORM_ANDROID)
* + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
*
* 2010-04-27 (v1.8):
* + Added iPad Support
*
* 2010-03-07 (v1.7):
* + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
* + Almost allof Gary's original code has been replaced
* + Large PHPUNIT testing environment created to validate new releases and additions
* + Added FreeBSD Platform
* + Added OpenBSD Platform
* + Added NetBSD Platform
* + Added SunOS Platform
* + Added OpenSolaris Platform
* + Added support of the Iceweazel Browser
* + Added isChromeFrame() call to check if chromeframe is in use
* + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
* + Added the __toString() method (Thanks Deano)
*
* 2009-11-15:
* + Updated the checkes for Firefox
* + Added the NOKIA platform
* + Added Checks for the NOKIA brower(s)
*
* 2009-11-08:
* + PHP 5.3 Support
* + Added support for BlackBerry OS and BlackBerry browser
* + Added support for the Opera Mini browser
* + Added additional documenation
* + Added support for isRobot() and isMobile()
* + Added support for Opera version 10
* + Added support for deprecated Netscape Navigator version 9
* + Added support for IceCat
* + Added support for Shiretoko
*
* 2010-04-27 (v1.8):
* + Added iPad Support
*
* 2009-08-18:
* + Updated to support PHP 5.3 - removed all deprecated function calls
* + Updated to remove all double quotes (") -- converted to single quotes (')
*
* 2009-04-27:
* + Updated the IE check to remove a typo and bug (thanks John)
*
* 2009-04-22:
* + Added detection for GoogleBot
* + Added detection for the W3C Validator.
* + Added detection for Yahoo! Slurp
*
* 2009-03-14:
* + Added detection for iPods.
* + Added Platform detection for iPhones
* + Added Platform detection for iPods
*
* 2009-02-16: (Rick Hale)
* + Added version detection for Android phones.
*
* 2008-12-09:
* + Removed unused constant
*
* 2008-11-07:
* + Added Google's Chrome to the detection list
* + Added isBrowser(string) to the list of functions special thanks to
* Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
*
*
* Gary White noted: "Since browser detection is so unreliable, I am
* no longer maintaining this script. You are free to use and or
* modify/update it as you want, however the author assumes no
* responsibility for the accuracy of the detected values."
*
* Anyone experienced with Gary's script might be interested in these notes:
*
* Added class constants
* Added detection and version detection for Google's Chrome
* Updated the version detection for Amaya
* Updated the version detection for Firefox
* Updated the version detection for Lynx
* Updated the version detection for WebTV
* Updated the version detection for NetPositive
* Updated the version detection for IE
* Updated the version detection for OmniWeb
* Updated the version detection for iCab
* Updated the version detection for Safari
* Updated Safari to remove mobile devices (iPhone)
* Added detection for iPhone
* Added detection for robots
* Added detection for mobile devices
* Added detection for BlackBerry
* Removed Netscape checks (matches heavily with firefox & mozilla)
*
*/
class Browser {
public $_agent = '';
public $_browser_name = '';
public $_version = '';
public $_platform = '';
public $_os = '';
public $_is_aol = false;
public $_is_mobile = false;
public $_is_robot = false;
public $_aol_version = '';
public $BROWSER_UNKNOWN = 'unknown';
public $VERSION_UNKNOWN = 'unknown';
public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
public $BROWSER_IPOD = 'iPod'; // Http://apple.com
public $BROWSER_IPAD = 'iPad'; // Http://apple.com
public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
// Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
public $PLATFORM_UNKNOWN = 'unknown';
public $PLATFORM_WINDOWS = 'Windows';
public $PLATFORM_WINDOWS_CE = 'Windows CE';
public $PLATFORM_APPLE = 'Apple';
public $PLATFORM_LINUX = 'Linux';
public $PLATFORM_OS2 = 'OS/2';
public $PLATFORM_BEOS = 'BeOS';
public $PLATFORM_IPHONE = 'iPhone';
public $PLATFORM_IPOD = 'iPod';
public $PLATFORM_IPAD = 'iPad';
public $PLATFORM_BLACKBERRY = 'BlackBerry';
public $PLATFORM_NOKIA = 'Nokia';
public $PLATFORM_FREEBSD = 'FreeBSD';
public $PLATFORM_OPENBSD = 'OpenBSD';
public $PLATFORM_NETBSD = 'NetBSD';
public $PLATFORM_SUNOS = 'SunOS';
public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
public $PLATFORM_ANDROID = 'Android';
public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
function Browser($useragent="") {
$this->reset();
if( $useragent != "" ) {
$this->setUserAgent($useragent);
}
else {
$this->determine();
}
}
/**
* Reset all properties
*/
function reset() {
$this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
$this->_browser_name = $this->BROWSER_UNKNOWN;
$this->_version = $this->VERSION_UNKNOWN;
$this->_platform = $this->PLATFORM_UNKNOWN;
$this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
$this->_is_aol = false;
$this->_is_mobile = false;
$this->_is_robot = false;
$this->_aol_version = $this->VERSION_UNKNOWN;
}
/**
* Check to see if the specific browser is valid
* @param string $browserName
* @return True if the browser is the specified browser
*/
function isBrowser($browserName) { return( 0 == strcasecmp($this->_browser_name, trim($browserName))); }
/**
* The name of the browser. All return types are from the class contants
* @return string Name of the browser
*/
function getBrowser() { return $this->_browser_name; }
/**
* Set the name of the browser
* @param $browser The name of the Browser
*/
function setBrowser($browser) { return $this->_browser_name = $browser; }
/**
* The name of the platform. All return types are from the class contants
* @return string Name of the browser
*/
function getPlatform() { return $this->_platform; }
/**
* Set the name of the platform
* @param $platform The name of the Platform
*/
function setPlatform($platform) { return $this->_platform = $platform; }
/**
* The version of the browser.
* @return string Version of the browser (will only contain alpha-numeric characters and a period)
*/
function getVersion() { return $this->_version; }
/**
* Set the version of the browser
* @param $version The version of the Browser
*/
function setVersion($version) { $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/','',$version); }
/**
* The version of AOL.
* @return string Version of AOL (will only contain alpha-numeric characters and a period)
*/
function getAolVersion() { return $this->_aol_version; }
/**
* Set the version of AOL
* @param $version The version of AOL
*/
function setAolVersion($version) { $this->_aol_version = preg_replace('/[^0-9,.,a-z,A-Z]/','',$version); }
/**
* Is the browser from AOL?
* @return boolean True if the browser is from AOL otherwise false
*/
function isAol() { return $this->_is_aol; }
/**
* Is the browser from a mobile device?
* @return boolean True if the browser is from a mobile device otherwise false
*/
function isMobile() { return $this->_is_mobile; }
/**
* Is the browser from a robot (ex Slurp,GoogleBot)?
* @return boolean True if the browser is from a robot otherwise false
*/
function isRobot() { return $this->_is_robot; }
/**
* Set the browser to be from AOL
* @param $isAol
*/
function setAol($isAol) { $this->_is_aol = $isAol; }
/**
* Set the Browser to be mobile
* @param boolean $value is the browser a mobile brower or not
*/
function setMobile($value=true) { $this->_is_mobile = $value; }
/**
* Set the Browser to be a robot
* @param boolean $value is the browser a robot or not
*/
function setRobot($value=true) { $this->_is_robot = $value; }
/**
* Get the user agent value in use to determine the browser
* @return string The user agent from the HTTP header
*/
function getUserAgent() { return $this->_agent; }
/**
* Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
* @param $agent_string The value for the User Agent
*/
function setUserAgent($agent_string) {
$this->reset();
$this->_agent = $agent_string;
$this->determine();
}
/**
* Used to determine if the browser is actually "chromeframe"
* @since 1.7
* @return boolean True if the browser is using chromeframe
*/
function isChromeFrame() {
return( strpos($this->_agent,"chromeframe") !== false );
}
/**
* Returns a formatted string with a summary of the details of the browser.
* @return string formatted string with a summary of the browser
*/
function __toString() {
$text1 = $this->getUserAgent(); //grabs the UA (user agent) string
$UAline1 = substr($text1, 0, 32); //the first line we print should only be the first 32 characters of the UA string
$text2 = $this->getUserAgent();//now we grab it again and save it to a string
$towrapUA = str_replace($UAline1, '', $text2);//the rest of the printoff (other than first line) is equivolent
// To the whole string minus the part we printed off. IE
// User Agent: thefirst32charactersfromUAline1
// the rest of it is now stored in
// $text2 to be printed off
// But we need to add spaces before each line that is split other than line 1
$space = '';
for($i = 0; $i < 25; $i++) {
$space .= ' ';
}
// Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
$wordwrapped = chunk_split($towrapUA, 32, "\n $space");
return "Platform: {$this->getPlatform()} \n".
"Browser Name: {$this->getBrowser()} \n" .
"Browser Version: {$this->getVersion()} \n" .
"User Agent String: $UAline1 \n\t\t\t " .
"$wordwrapped";
}
/**
* Protected routine to calculate and determine what the browser is in use (including platform)
*/
function determine() {
$this->checkPlatform();
$this->checkBrowsers();
$this->checkForAol();
}
/**
* Protected routine to determine the browser type
* @return boolean True if the browser was detected otherwise false
*/
function checkBrowsers() {
return (
// Well-known, well-used
// Special Notes:
// (1) Opera must be checked before FireFox due to the odd
// user agents used in some older versions of Opera
// (2) WebTV is strapped onto Internet Explorer so we must
// check for WebTV before IE
// (3) (deprecated) Galeon is based on Firefox and needs to be
// tested before Firefox is tested
// (4) OmniWeb is based on Safari so OmniWeb check must occur
// before Safari
// (5) Netscape 9+ is based on Firefox so Netscape checks
// before FireFox are necessary
$this->checkBrowserWebTv() ||
$this->checkBrowserInternetExplorer() ||
$this->checkBrowserOpera() ||
$this->checkBrowserGaleon() ||
$this->checkBrowserNetscapeNavigator9Plus() ||
$this->checkBrowserFirefox() ||
$this->checkBrowserChrome() ||
$this->checkBrowserOmniWeb() ||
// Common mobile
$this->checkBrowserAndroid() ||
$this->checkBrowseriPad() ||
$this->checkBrowseriPod() ||
$this->checkBrowseriPhone() ||
$this->checkBrowserBlackBerry() ||
$this->checkBrowserNokia() ||
// Common bots
$this->checkBrowserGoogleBot() ||
$this->checkBrowserMSNBot() ||
$this->checkBrowserSlurp() ||
// WebKit base check (post mobile and others)
$this->checkBrowserSafari() ||
// Everyone else
$this->checkBrowserNetPositive() ||
$this->checkBrowserFirebird() ||
$this->checkBrowserKonqueror() ||
$this->checkBrowserIcab() ||
$this->checkBrowserPhoenix() ||
$this->checkBrowserAmaya() ||
$this->checkBrowserLynx() ||
$this->checkBrowserShiretoko() ||
$this->checkBrowserIceCat() ||
$this->checkBrowserW3CValidator() ||
$this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
);
}
/**
* Determine if the user is using a BlackBerry (last updated 1.7)
* @return boolean True if the browser is the BlackBerry browser otherwise false
*/
function checkBrowserBlackBerry() {
if( stripos($this->_agent,'blackberry') !== false ) {
$aresult = explode("/",stristr($this->_agent,"BlackBerry"));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->_browser_name = $this->BROWSER_BLACKBERRY;
$this->setMobile(true);
return true;
}
return false;
}
/**
* Determine if the user is using an AOL User Agent (last updated 1.7)
* @return boolean True if the browser is from AOL otherwise false
*/
function checkForAol() {
$this->setAol(false);
$this->setAolVersion($this->VERSION_UNKNOWN);
if( stripos($this->_agent,'aol') !== false ) {
$aversion = explode(' ',stristr($this->_agent, 'AOL'));
$this->setAol(true);
$this->setAolVersion(preg_replace('/[^0-9\.a-z]/i', '', $aversion[1]));
return true;
}
return false;
}
/**
* Determine if the browser is the GoogleBot or not (last updated 1.7)
* @return boolean True if the browser is the GoogletBot otherwise false
*/
function checkBrowserGoogleBot() {
if( stripos($this->_agent,'googlebot') !== false ) {
$aresult = explode('/',stristr($this->_agent,'googlebot'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion(str_replace(';','',$aversion[0]));
$this->_browser_name = $this->BROWSER_GOOGLEBOT;
$this->setRobot(true);
return true;
}
return false;
}
/**
* Determine if the browser is the MSNBot or not (last updated 1.9)
* @return boolean True if the browser is the MSNBot otherwise false
*/
function checkBrowserMSNBot() {
if( stripos($this->_agent,"msnbot") !== false ) {
$aresult = explode("/",stristr($this->_agent,"msnbot"));
$aversion = explode(" ",$aresult[1]);
$this->setVersion(str_replace(";","",$aversion[0]));
$this->_browser_name = $this->BROWSER_MSNBOT;
$this->setRobot(true);
return true;
}
return false;
}
/**
* Determine if the browser is the W3C Validator or not (last updated 1.7)
* @return boolean True if the browser is the W3C Validator otherwise false
*/
function checkBrowserW3CValidator() {
if( stripos($this->_agent,'W3C-checklink') !== false ) {
$aresult = explode('/',stristr($this->_agent,'W3C-checklink'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->_browser_name = $this->BROWSER_W3CVALIDATOR;
return true;
}
else if( stripos($this->_agent,'W3C_Validator') !== false ) {
// Some of the Validator versions do not delineate w/ a slash - add it back in
$ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->_agent);
$aresult = explode('/',stristr($ua,'W3C_Validator'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->_browser_name = $this->BROWSER_W3CVALIDATOR;
return true;
}
return false;
}
/**
* Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
* @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
*/
function checkBrowserSlurp() {
if( stripos($this->_agent,'slurp') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Slurp'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->_browser_name = $this->BROWSER_SLURP;
$this->setRobot(true);
$this->setMobile(false);
return true;
}
return false;
}
/**
* Determine if the browser is Internet Explorer or not (last updated 1.7)
* @return boolean True if the browser is Internet Explorer otherwise false
*/
function checkBrowserInternetExplorer() {
// Test for v1 - v1.5 IE
if( stripos($this->_agent,'microsoft internet explorer') !== false ) {
$this->setBrowser($this->BROWSER_IE);
$this->setVersion('1.0');
$aresult = stristr($this->_agent, '/');
if( preg_match('/308|425|426|474|0b1/i', $aresult) ) {
$this->setVersion('1.5');
}
return true;
}
// Test for versions > 1.5
else if( stripos($this->_agent,'msie') !== false && stripos($this->_agent,'opera') === false ) {
// See if the browser is the odd MSN Explorer
if( stripos($this->_agent,'msnb') !== false ) {
$aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'MSN'));
$this->setBrowser( $this->BROWSER_MSN );
$this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
return true;
}
$aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'msie'));
$this->setBrowser( $this->BROWSER_IE );
$this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
return true;
}
// Test for Pocket IE
else if( stripos($this->_agent,'mspie') !== false || stripos($this->_agent,'pocket') !== false ) {
$aresult = explode(' ',stristr($this->_agent,'mspie'));
$this->setPlatform( $this->PLATFORM_WINDOWS_CE );
$this->setBrowser( $this->BROWSER_POCKET_IE );
$this->setMobile(true);
if( stripos($this->_agent,'mspie') !== false ) {
$this->setVersion($aresult[1]);
}
else {
$aversion = explode('/',$this->_agent);
$this->setVersion($aversion[1]);
}
return true;
}
return false;
}
/**
* Determine if the browser is Opera or not (last updated 1.7)
* @return boolean True if the browser is Opera otherwise false
*/
function checkBrowserOpera() {
if( stripos($this->_agent,'opera mini') !== false ) {
$resultant = stristr($this->_agent, 'opera mini');
if( preg_match('/\//',$resultant) ) {
$aresult = explode('/',$resultant);
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$aversion = explode(' ',stristr($resultant,'opera mini'));
$this->setVersion($aversion[1]);
}
$this->_browser_name = $this->BROWSER_OPERA_MINI;
$this->setMobile(true);
return true;
}
else if( stripos($this->_agent,'opera') !== false ) {
$resultant = stristr($this->_agent, 'opera');
if( preg_match('/Version\/(10.*)$/',$resultant,$matches) ) {
$this->setVersion($matches[1]);
}
else if( preg_match('/\//',$resultant) ) {
$aresult = explode('/',str_replace("("," ",$resultant));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$aversion = explode(' ',stristr($resultant,'opera'));
$this->setVersion(isset($aversion[1])?$aversion[1]:"");
}
$this->_browser_name = $this->BROWSER_OPERA;
return true;
}
return false;
}
/**
* Determine if the browser is Chrome or not (last updated 1.7)
* @return boolean True if the browser is Chrome otherwise false
*/
function checkBrowserChrome() {
if( stripos($this->_agent,'Chrome') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Chrome'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser($this->BROWSER_CHROME);
return true;
}
return false;
}
/**
* Determine if the browser is WebTv or not (last updated 1.7)
* @return boolean True if the browser is WebTv otherwise false
*/
function checkBrowserWebTv() {
if( stripos($this->_agent,'webtv') !== false ) {
$aresult = explode('/',stristr($this->_agent,'webtv'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser($this->BROWSER_WEBTV);
return true;
}
return false;
}
/**
* Determine if the browser is NetPositive or not (last updated 1.7)
* @return boolean True if the browser is NetPositive otherwise false
*/
function checkBrowserNetPositive() {
if( stripos($this->_agent,'NetPositive') !== false ) {
$aresult = explode('/',stristr($this->_agent,'NetPositive'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion(str_replace(array('(',')',';'),'',$aversion[0]));
$this->setBrowser($this->BROWSER_NETPOSITIVE);
return true;
}
return false;
}
/**
* Determine if the browser is Galeon or not (last updated 1.7)
* @return boolean True if the browser is Galeon otherwise false
*/
function checkBrowserGaleon() {
if( stripos($this->_agent,'galeon') !== false ) {
$aresult = explode(' ',stristr($this->_agent,'galeon'));
$aversion = explode('/',$aresult[0]);
$this->setVersion($aversion[1]);
$this->setBrowser($this->BROWSER_GALEON);
return true;
}
return false;
}
/**
* Determine if the browser is Konqueror or not (last updated 1.7)
* @return boolean True if the browser is Konqueror otherwise false
*/
function checkBrowserKonqueror() {
if( stripos($this->_agent,'Konqueror') !== false ) {
$aresult = explode(' ',stristr($this->_agent,'Konqueror'));
$aversion = explode('/',$aresult[0]);
$this->setVersion($aversion[1]);
$this->setBrowser($this->BROWSER_KONQUEROR);
return true;
}
return false;
}
/**
* Determine if the browser is iCab or not (last updated 1.7)
* @return boolean True if the browser is iCab otherwise false
*/
function checkBrowserIcab() {
if( stripos($this->_agent,'icab') !== false ) {
$aversion = explode(' ',stristr(str_replace('/',' ',$this->_agent),'icab'));
$this->setVersion($aversion[1]);
$this->setBrowser($this->BROWSER_ICAB);
return true;
}
return false;
}
/**
* Determine if the browser is OmniWeb or not (last updated 1.7)
* @return boolean True if the browser is OmniWeb otherwise false
*/
function checkBrowserOmniWeb() {
if( stripos($this->_agent,'omniweb') !== false ) {
$aresult = explode('/',stristr($this->_agent,'omniweb'));
$aversion = explode(' ',isset($aresult[1])?$aresult[1]:"");
$this->setVersion($aversion[0]);
$this->setBrowser($this->BROWSER_OMNIWEB);
return true;
}
return false;
}
/**
* Determine if the browser is Phoenix or not (last updated 1.7)
* @return boolean True if the browser is Phoenix otherwise false
*/
function checkBrowserPhoenix() {
if( stripos($this->_agent,'Phoenix') !== false ) {
$aversion = explode('/',stristr($this->_agent,'Phoenix'));
$this->setVersion($aversion[1]);
$this->setBrowser($this->BROWSER_PHOENIX);
return true;
}
return false;
}
/**
* Determine if the browser is Firebird or not (last updated 1.7)
* @return boolean True if the browser is Firebird otherwise false
*/
function checkBrowserFirebird() {
if( stripos($this->_agent,'Firebird') !== false ) {
$aversion = explode('/',stristr($this->_agent,'Firebird'));
$this->setVersion($aversion[1]);
$this->setBrowser($this->BROWSER_FIREBIRD);
return true;
}
return false;
}
/**
* Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
* NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
* @return boolean True if the browser is Netscape Navigator 9+ otherwise false
*/
function checkBrowserNetscapeNavigator9Plus() {
if( stripos($this->_agent,'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i',$this->_agent,$matches) ) {
$this->setVersion($matches[1]);
$this->setBrowser($this->BROWSER_NETSCAPE_NAVIGATOR);
return true;
}
else if( stripos($this->_agent,'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i',$this->_agent,$matches) ) {
$this->setVersion($matches[1]);
$this->setBrowser($this->BROWSER_NETSCAPE_NAVIGATOR);
return true;
}
return false;
}
/**
* Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
* @return boolean True if the browser is Shiretoko otherwise false
*/
function checkBrowserShiretoko() {
if( stripos($this->_agent,'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i',$this->_agent,$matches) ) {
$this->setVersion($matches[1]);
$this->setBrowser($this->BROWSER_SHIRETOKO);
return true;
}
return false;
}
/**
* Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
* @return boolean True if the browser is Ice Cat otherwise false
*/
function checkBrowserIceCat() {
if( stripos($this->_agent,'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i',$this->_agent,$matches) ) {
$this->setVersion($matches[1]);
$this->setBrowser($this->BROWSER_ICECAT);
return true;
}
return false;
}
/**
* Determine if the browser is Nokia or not (last updated 1.7)
* @return boolean True if the browser is Nokia otherwise false
*/
function checkBrowserNokia() {
if( preg_match("/Nokia([^\/]+)\/([^ SP]+)/i",$this->_agent,$matches) ) {
$this->setVersion($matches[2]);
if( stripos($this->_agent,'Series60') !== false || strpos($this->_agent,'S60') !== false ) {
$this->setBrowser($this->BROWSER_NOKIA_S60);
}
else {
$this->setBrowser( $this->BROWSER_NOKIA );
}
$this->setMobile(true);
return true;
}
return false;
}
/**
* Determine if the browser is Firefox or not (last updated 1.7)
* @return boolean True if the browser is Firefox otherwise false
*/
function checkBrowserFirefox() {
if( stripos($this->_agent,'safari') === false ) {
if( preg_match("/Firefox[\/ \(]([^ ;\)]+)/i",$this->_agent,$matches) ) {
$this->setVersion($matches[1]);
$this->setBrowser($this->BROWSER_FIREFOX);
return true;
}
else if( preg_match("/Firefox$/i",$this->_agent,$matches) ) {
$this->setVersion("");
$this->setBrowser($this->BROWSER_FIREFOX);
return true;
}
}
return false;
}
/**
* Determine if the browser is Firefox or not (last updated 1.7)
* @return boolean True if the browser is Firefox otherwise false
*/
function checkBrowserIceweasel() {
if( stripos($this->_agent,'Iceweasel') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Iceweasel'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser($this->BROWSER_ICEWEASEL);
return true;
}
return false;
}
/**
* Determine if the browser is Mozilla or not (last updated 1.7)
* @return boolean True if the browser is Mozilla otherwise false
*/
function checkBrowserMozilla() {
if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent) && stripos($this->_agent,'netscape') === false) {
$aversion = explode(' ',stristr($this->_agent,'rv:'));
preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent,$aversion);
$this->setVersion(str_replace('rv:','',$aversion[0]));
$this->setBrowser($this->BROWSER_MOZILLA);
return true;
}
else if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i',$this->_agent) && stripos($this->_agent,'netscape') === false ) {
$aversion = explode('',stristr($this->_agent,'rv:'));
$this->setVersion(str_replace('rv:','',$aversion[0]));
$this->setBrowser($this->BROWSER_MOZILLA);
return true;
}
else if( stripos($this->_agent,'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i',$this->_agent,$matches) && stripos($this->_agent,'netscape') === false ) {
$this->setVersion($matches[1]);
$this->setBrowser($this->BROWSER_MOZILLA);
return true;
}
return false;
}
/**
* Determine if the browser is Lynx or not (last updated 1.7)
* @return boolean True if the browser is Lynx otherwise false
*/
function checkBrowserLynx() {
if( stripos($this->_agent,'lynx') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Lynx'));
$aversion = explode(' ',(isset($aresult[1])?$aresult[1]:""));
$this->setVersion($aversion[0]);
$this->setBrowser($this->BROWSER_LYNX);
return true;
}
return false;
}
/**
* Determine if the browser is Amaya or not (last updated 1.7)
* @return boolean True if the browser is Amaya otherwise false
*/
function checkBrowserAmaya() {
if( stripos($this->_agent,'amaya') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Amaya'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser($this->BROWSER_AMAYA);
return true;
}
return false;
}
/**
* Determine if the browser is Safari or not (last updated 1.7)
* @return boolean True if the browser is Safari otherwise false
*/
function checkBrowserSafari() {
if( stripos($this->_agent,'Safari') !== false && stripos($this->_agent,'iPhone') === false && stripos($this->_agent,'iPod') === false ) {
$aresult = explode('/',stristr($this->_agent,'Version'));
if( isset($aresult[1]) ) {
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$this->setVersion($this->VERSION_UNKNOWN);
}
$this->setBrowser($this->BROWSER_SAFARI);
return true;
}
return false;
}
/**
* Determine if the browser is iPhone or not (last updated 1.7)
* @return boolean True if the browser is iPhone otherwise false
*/
function checkBrowseriPhone() {
if( stripos($this->_agent,'iPhone') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Version'));
if( isset($aresult[1]) ) {
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$this->setVersion($this->VERSION_UNKNOWN);
}
$this->setMobile(true);
$this->setBrowser($this->BROWSER_IPHONE);
return true;
}
return false;
}
/**
* Determine if the browser is iPod or not (last updated 1.7)
* @return boolean True if the browser is iPod otherwise false
*/
function checkBrowseriPad() {
if( stripos($this->_agent,'iPad') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Version'));
if( isset($aresult[1]) ) {
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$this->setVersion($this->VERSION_UNKNOWN);
}
$this->setMobile(true);
$this->setBrowser($this->BROWSER_IPAD);
return true;
}
return false;
}
/**
* Determine if the browser is iPod or not (last updated 1.7)
* @return boolean True if the browser is iPod otherwise false
*/
function checkBrowseriPod() {
if( stripos($this->_agent,'iPod') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Version'));
if( isset($aresult[1]) ) {
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$this->setVersion($this->VERSION_UNKNOWN);
}
$this->setMobile(true);
$this->setBrowser($this->BROWSER_IPOD);
return true;
}
return false;
}
/**
* Determine if the browser is Android or not (last updated 1.7)
* @return boolean True if the browser is Android otherwise false
*/
function checkBrowserAndroid() {
if( stripos($this->_agent,'Android') !== false ) {
$aresult = explode(' ',stristr($this->_agent,'Android'));
if( isset($aresult[1]) ) {
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
}
else {
$this->setVersion($this->VERSION_UNKNOWN);
}
$this->setMobile(true);
$this->setBrowser($this->BROWSER_ANDROID);
return true;
}
return false;
}
/**
* Determine the user's platform (last updated 1.7)
*/
function checkPlatform() {
if( stripos($this->_agent, 'windows') !== false ) {
$this->_platform = $this->PLATFORM_WINDOWS;
}
else if( stripos($this->_agent, 'iPad') !== false ) {
$this->_platform = $this->PLATFORM_IPAD;
}
else if( stripos($this->_agent, 'iPod') !== false ) {
$this->_platform = $this->PLATFORM_IPOD;
}
else if( stripos($this->_agent, 'iPhone') !== false ) {
$this->_platform = $this->PLATFORM_IPHONE;
}
elseif( stripos($this->_agent, 'mac') !== false ) {
$this->_platform = $this->PLATFORM_APPLE;
}
elseif( stripos($this->_agent, 'android') !== false ) {
$this->_platform = $this->PLATFORM_ANDROID;
}
elseif( stripos($this->_agent, 'linux') !== false ) {
$this->_platform = $this->PLATFORM_LINUX;
}
else if( stripos($this->_agent, 'Nokia') !== false ) {
$this->_platform = $this->PLATFORM_NOKIA;
}
else if( stripos($this->_agent, 'BlackBerry') !== false ) {
$this->_platform = $this->PLATFORM_BLACKBERRY;
}
elseif( stripos($this->_agent,'FreeBSD') !== false ) {
$this->_platform = $this->PLATFORM_FREEBSD;
}
elseif( stripos($this->_agent,'OpenBSD') !== false ) {
$this->_platform = $this->PLATFORM_OPENBSD;
}
elseif( stripos($this->_agent,'NetBSD') !== false ) {
$this->_platform = $this->PLATFORM_NETBSD;
}
elseif( stripos($this->_agent, 'OpenSolaris') !== false ) {
$this->_platform = $this->PLATFORM_OPENSOLARIS;
}
elseif( stripos($this->_agent, 'SunOS') !== false ) {
$this->_platform = $this->PLATFORM_SUNOS;
}
elseif( stripos($this->_agent, 'OS\/2') !== false ) {
$this->_platform = $this->PLATFORM_OS2;
}
elseif( stripos($this->_agent, 'BeOS') !== false ) {
$this->_platform = $this->PLATFORM_BEOS;
}
elseif( stripos($this->_agent, 'win') !== false ) {
$this->_platform = $this->PLATFORM_WINDOWS;
}
}
}
?>
<?php
/**
* Handles Remote Viewing of System Status
*
* @package SSI
* @subpackage Classes/Viewer
* @author John Regan
* @since 1.0
*/
class Simple_System_Status_Viewer {
/**
* Renders Remote Viewing portion of Plugin Settings Page
*
* @since 1.0
*
* @return void
*/
static function remote_viewing_section() {
$value = get_option( 'simple_system_status_remote_url' );
$url = home_url() . '/?simple_system_status=' . $value;
?>
<p><?php _e( 'Users with this URL can view a plain-text version of your System Status.<br />This link can be handy in support forums, as access to this information can be removed after you receive the help you need.<br />Generating a new URL will safely void access to all who have the existing URL.', WC_QD_TXT ) ?></p>
<p><input type="text" readonly="readonly" class="sss-url sss-url-text" onclick="this.focus();this.select()" value="<?php echo esc_url( $url ) ?>" title="<?php _e( 'To copy the System Status, click below then press Ctrl + C (PC) or Cmd + C (Mac).', WC_QD_TXT ); ?>" />&nbsp;&nbsp;<a href="<?php echo esc_url( $url ) ?>" target="_blank" class="sss-tiny sss-url-text-link"><?php _e( 'test url', WC_QD_TXT ) ?></a></p>
<p class="submit">
<input type="submit" onClick="return false;" class="button-secondary" name="generate-new-url" value="<?php _e( 'Generate New URL', WC_QD_TXT ) ?>" />
</p>
<?php
}
/**
* Renders Remote View using $_GET value
*
* @since 1.0
* @action template_redirect
*
* @return void
*/
static function remote_view() {
if ( ! isset( $_GET['simple_system_status'] ) || empty( $_GET['simple_system_status'] ) ) {
return;
}
$query_value = $_GET['simple_system_status'];
$value = get_option( 'simple_system_status_remote_url' );
echo '<pre>';
if ( $query_value == $value ) {
echo esc_html( Simple_System_Status::display() );
exit();
} else {
exit( 'Invalid System Status URL.' );
}
echo '</pre>';
}
}
\ No newline at end of file
<?php
//Simple_System_Status
class WooCommerce_Quick_Donation_SysInfo{
/**
* Load hooks
*
* @since 0.9
* @action plugins_loaded
*
* @return void
*/
static function setup() {
define( 'WC_QD_SSS_DIR', plugin_dir_path( __FILE__ ) );
define( 'WC_QD_SSS_INC_DIR', WC_QD_SSS_DIR . 'includes/' );
define( 'WC_QD_SSS_VIEWS_DIR', WC_QD_SSS_DIR . 'views/' );
require_once WC_QD_SSS_INC_DIR . 'viewer.php';
require_once WC_QD_SSS_INC_DIR . 'browser.php';
//register_activation_hook( __FILE__, array( __CLASS__, 'generate_url' ) );
//register_uninstall_hook( __FILE__, array( __CLASS__, 'uninstall' ) );
//add_action( 'wp_ajax_regenerate_url', array( __CLASS__, 'generate_url' ) );
//add_action( 'wp_ajax_download_simple_system_status', array( __CLASS__, 'download_info' ) );
//add_action( 'template_redirect', array( 'WooCommerce_Quick_Donation_SysInfo', 'remote_view' ) );
}
/**
* Render plugin page title, information and info textarea
*
* @since 1.0
*
* @return void
*/
static function render_info() {
include( WC_QD_SSS_VIEWS_DIR . 'simple-system-status.php' );
}
/**
* Generate Text file download
*
* @since 1.0
*
* @return void
*/
static function download_info() {
if ( ! isset( $_POST['simple-system-status-textarea'] ) || empty( $_POST['simple-system-status-textarea'] ) ) {
return;
}
header( 'Content-type: text/plain' );
//Text file name marked with Unix timestamp
header( 'Content-Disposition: attachment; filename=simple_system_status_' . time() . '.txt' );
echo $_POST['simple-system-status-textarea'];
die();
}
/**
* Gather data, then generate System Status
*
* Based on System Status submenu page in Easy Digital Downloads
* by Pippin Williamson
*
* @since 1.0
*
* @return void
*/
static function display() {
$browser = new Browser();
if ( get_bloginfo( 'version' ) < '3.4' ) {
$theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
$theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
} else {
$theme_data = wp_get_theme();
$theme = $theme_data->Name . ' ' . $theme_data->Version;
}
// Try to identify the hosting provider
$host = false;
if ( defined( 'WPE_APIKEY' ) ) {
$host = 'WP Engine';
} elseif ( defined( 'PAGELYBIN' ) ) {
$host = 'Pagely';
}
$request['cmd'] = '_notify-validate';
$params = array(
'sslverify' => false,
'timeout' => 60,
'body' => $request,
);
$response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
$WP_REMOTE_POST = 'wp_remote_post() works' . "\n";
} else {
$WP_REMOTE_POST = 'wp_remote_post() does not work' . "\n";
}
return self::display_output( $browser, $theme, $host, $WP_REMOTE_POST );
}
/**
* Render System Status
*
* Based on System Status submenu page in Easy Digital Downloads
* by Pippin Williamson
*
* @since 1.0
*
* @param string Browser information
* @param string Theme Data
* @param string Theme name
* @param string Host
* @param string WP Remote Host
* @return string Output of System Status display
*/
//Render Info Display
static function display_output( $browser, $theme, $host, $WP_REMOTE_POST ) {
global $wpdb;
ob_start();
include( WC_QD_SSS_VIEWS_DIR . 'output.php' );
return ob_get_clean();
}
/**
* Size Conversions
*
* @author Chris Christoff
* @since 1.0
*
* @param unknown $v
* @return int|string
*/
static function let_to_num( $v ) {
$l = substr( $v, -1 );
$ret = substr( $v, 0, -1 );
switch ( strtoupper( $l ) ) {
case 'P': // fall-through
case 'T': // fall-through
case 'G': // fall-through
case 'M': // fall-through
case 'K': // fall-through
$ret *= 1024;
break;
default:
break;
}
return $ret;
}
/**
* Generate Random URL for the remote view.
* Saves result to options. If it's an ajax request
* the new query value is sent back to the js script.
*
* @since 1.0
* @action wp_ajax_regenerate_url
*
* @return void
*/
static function generate_url() {
$alphabet = 'abcdefghijklmnopqrstuwxyz-ABCDEFGHIJKLMNOPQRSTUWXYZ0123456789';
$value = array();
$alphaLength = strlen( $alphabet ) - 1;
for ( $i = 0; $i < 16; $i++ ) {
$n = rand( 0, $alphaLength );
$value[] = $alphabet[$n];
}
$value = implode( $value );
update_option( 'simple_system_status_remote_url', $value );
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
$output = home_url() . '/?simple_system_status=' . $value;
wp_send_json( $output );
}
}
/**
* Delete URL option on uninstall.
*
* @since 1.0
*
* @return void
*/
static function uninstall() {
delete_option( 'simple_system_status_remote_url' );
}
}
\ No newline at end of file
<?php
/**
*
* This file runs when the plugin in uninstalled (deleted).
* This will not run when the plugin is deactivated.
* Ideally you will add all your clean-up scripts here
* that will clean-up unused meta, options, etc. in the database.
*
*/
// If plugin is not being uninstalled, exit (do nothing)
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Do something here if plugin is being uninstalled.
\ No newline at end of file
<?php
/**
* Get User IP
*
* Returns the IP address of the current visitor
*
* @since 1.0.8.2
* @return string $ip User's IP address
*/
function sss_get_ip() {
$ip = '127.0.0.1';
if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
//check ip from share internet
$ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
//to check ip is pass from proxy
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} elseif( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
$ip = $_SERVER['REMOTE_ADDR'];
}
return apply_filters( 'edd_get_ip', $ip );
}
/**
* Get user host
*
* Returns the webhost this site is using if possible
*
* @since 2.0
* @return mixed string $host if detected, false otherwise
*/
function sss_get_host() {
$host = false;
if( defined( 'WPE_APIKEY' ) ) {
$host = 'WP Engine';
} elseif( defined( 'PAGELYBIN' ) ) {
$host = 'Pagely';
} elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
$host = 'ICDSoft';
} elseif( DB_HOST == 'mysqlv5' ) {
$host = 'NetworkSolutions';
} elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
$host = 'iPage';
} elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
$host = 'IPower';
} elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
$host = 'MediaTemple Grid';
} elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
$host = 'pair Networks';
} elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
$host = 'Rackspace Cloud';
} elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
$host = 'SysFix.eu Power Hosting';
} elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
$host = 'Flywheel';
} else {
// Adding a general fallback for data gathering
$host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
}
return $host;
} ?>
### Begin WooCommerce Quick Donation Status ###
-- WordPress Environment
Home URL: <?php echo home_url() . "\n"; ?>
Site URL: <?php echo site_url() . "\n"; ?>
WP Version: <?php echo get_bloginfo( 'version' ) . "\n"; ?>
WP_DEBUG: <?php echo defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' . "\n" : 'Disabled' . "\n" : 'Not set' . "\n" ?>
WP Language: <?php echo ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n"; ?>
Multisite: <?php echo is_multisite() ? 'Yes' . "\n" : 'No' . "\n" ?>
WP Memory Limit: <?php echo ( self::let_to_num( WP_MEMORY_LIMIT )/( 1024 ) )."MB"; ?><?php echo "\n"; ?>
WP Memory Limit Status: <?php if (( WP_MEMORY_LIMIT )/( 1024 ) > 63) { echo 'OK'. "\n"; } else {echo 'Not OK - Recommended Memory Limit is 64MB'."\n";} ?>
WP Table Prefix: <?php echo $wpdb->prefix. "\n"; ?>
WP Table Prefix Length: <?php echo strlen( $wpdb->prefix ). "\n"; ?>
WP Table Prefix Status: <?php if ( strlen( $wpdb->prefix ) > 16 ) { echo 'ERROR: Too Long'; } else { echo 'Acceptable'; } echo "\n"; ?>
WP Timezone: <?php echo get_option('timezone_string') . ', GMT: ' . get_option('gmt_offset') . "\n"; ?>
WP Remote Post: <?php echo $WP_REMOTE_POST; ?>
Permalink Structure: <?php echo get_option( 'permalink_structure' ) . "\n"; ?>
Registered Post Stati: <?php echo implode( ', ', get_post_stati() ) . "\n"; ?>
Show On Front: <?php echo get_option( 'show_on_front' ) . "\n" ?>
<?php if( get_option( 'show_on_front' ) == 'page' ) {
$front_page_id = get_option( 'page_on_front' );
$blog_page_id = get_option( 'page_for_posts' ); ?>
Page On Front: <?php ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n"; ?>
Page For Posts: <?php ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n"; ?>
<?php } ?>
## Theme Information ##
<?php $active_theme = wp_get_theme(); ?>
Theme Name: <?php echo $active_theme->Name . "\n"; ?>
Theme Version: <?php echo $active_theme->Version . "\n"; ?>
Theme Author: <?php echo $active_theme->get('Author') . "\n"; ?>
Theme Author URI: <?php echo $active_theme->get('AuthorURI') . "\n"; ?>
Is Child Theme: <?php echo is_child_theme() ? 'Yes' . "\n" : 'No' . "\n"; if( is_child_theme() ) { $parent_theme = wp_get_theme( $active_theme->Template ); ?>
Parent Theme: <?php echo $parent_theme->Name ?>
Parent Theme Version: <?php echo $parent_theme->Version . "\n"; ?>
Parent Theme URI: <?php echo $parent_theme->get('ThemeURI') . "\n"; ?>
Parent Theme Author URI: <?php echo $parent_theme->{'Author URI'} . "\n"; ?>
<?php } ?>
## Plugins Information ##
<?php
$muplugins = wp_get_mu_plugins();
if( count( $muplugins > 0 ) ) {
echo "\n" . '-- Must-Use Plugins' . "\n\n";
foreach( $muplugins as $plugin => $plugin_data ) {
echo $plugin['Name'] . ': {V : ' . $plugin['Version'] . ' || A : ' .$plugin['Author'] .' } ' .$plugin['PluginURI'] ."\n";
}
}
// WordPress active plugins
echo "\n" . '-- WordPress Active Plugins' . "\n\n";
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
$active_plugins = get_option( 'active_plugins', array() );
foreach( $plugins as $plugin_path => $plugin ) {
if( !in_array( $plugin_path, $active_plugins ) )
continue;
echo $plugin['Name'] . ' : {V : ' . $plugin['Version'] . ' || A : ' .$plugin['Author'] .' } ' .$plugin['PluginURI'] ."\n";
}
// WordPress inactive plugins
echo "\n" . '-- WordPress Inactive Plugins' . "\n\n";
foreach( $plugins as $plugin_path => $plugin ) {
if( in_array( $plugin_path, $active_plugins ) )
continue;
echo $plugin['Name'] . ' : {V : ' . $plugin['Version'] . ' || A : ' .$plugin['Author'] .' } ' .$plugin['PluginURI'] ."\n";
}
if( is_multisite() ) {
// WordPress Multisite active plugins
echo "\n" . '-- Network Active Plugins' . "\n\n";
$plugins = wp_get_active_network_plugins();
$active_plugins = get_site_option( 'active_sitewide_plugins', array() );
foreach( $plugins as $plugin_path ) {
$plugin_base = plugin_basename( $plugin_path );
if( !array_key_exists( $plugin_base, $active_plugins ) )
continue;
$plugin = get_plugin_data( $plugin_path );
echo $plugin['Name'] . ': ' . $plugin['Version'] . ' ' .$plugin['Author'] .' ' .$plugin['PluginURI'] ."\n";
}
}
?>
## Server Environment ##
Server Info: <?php echo $_SERVER['SERVER_SOFTWARE'] . "\n"; ?>
Host: <?php echo sss_get_host() . "\n"; ?>
Default Timezone: <?php echo date_default_timezone_get() . "\n"; ?>
<?php
if ( $wpdb->use_mysqli ) {
$mysql_ver = @mysqli_get_server_info( $wpdb->dbh );
} else {
$mysql_ver = @mysql_get_server_info();
}
?>
MySQL Version: <?php echo $mysql_ver . "\n"; ?>
-- PHP Configuration
PHP Version: <?php echo PHP_VERSION . "\n"; ?>
PHP Post Max Size: <?php echo ini_get( 'post_max_size' ) . "\n"; ?>
PHP Time Limit: <?php echo ini_get( 'max_execution_time' ) . "\n"; ?>
PHP Max Input Vars: <?php echo ini_get( 'max_input_vars' ) . "\n"; ?>
PHP Safe Mode: <?php echo ini_get( 'safe_mode' ) ? "Yes" : "No\n"; ?>
PHP Memory Limit: <?php echo ini_get( 'memory_limit' ) . "\n"; ?>
PHP Upload Max Size: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
PHP Upload Max Filesize: <?php echo ini_get( 'upload_max_filesize' ) . "\n"; ?>
PHP Arg Separator: <?php echo ini_get( 'arg_separator.output' ) . "\n"; ?>
PHP Allow URL File Open: <?php echo ini_get( 'allow_url_fopen' ) ? "Yes". "\n" : "No" . "\n"; ?>
-- PHP Extentions
DISPLAY ERRORS: <?php echo ( ini_get( 'display_errors' ) ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A'; ?><?php echo "\n"; ?>
FSOCKOPEN: <?php echo ( function_exists( 'fsockopen' ) ) ? 'Your server supports fsockopen.' : 'Your server does not support fsockopen.'; ?><?php echo "\n"; ?>
cURL: <?php echo ( function_exists( 'curl_init' ) ) ? 'Your server supports cURL.' : 'Your server does not support cURL.'; ?><?php echo "\n"; ?>
SOAP Client: <?php echo ( class_exists( 'SoapClient' ) ) ? 'Your server has the SOAP Client enabled.' : 'Your server does not have the SOAP Client enabled.'; ?><?php echo "\n"; ?>
SUHOSIN: <?php echo ( extension_loaded( 'suhosin' ) ) ? 'Your server has SUHOSIN installed.' : 'Your server does not have SUHOSIN installed.'; ?><?php echo "\n"; ?>
-- Session Configuration
Session: <?php echo isset( $_SESSION ) ? 'Enabled' : 'Disabled'; ?><?php echo "\n"; ?>
Session Name: <?php echo esc_html( ini_get( 'session.name' ) ); ?><?php echo "\n"; ?>
Cookie Path: <?php echo esc_html( ini_get( 'session.cookie_path' ) ); ?><?php echo "\n"; ?>
Save Path: <?php echo esc_html( ini_get( 'session.save_path' ) ); ?><?php echo "\n"; ?>
Use Cookies: <?php echo ini_get( 'session.use_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
Use Only Cookies: <?php echo ini_get( 'session.use_only_cookies' ) ? 'On' : 'Off'; ?><?php echo "\n"; ?>
-- Client Details:
<?php if ( isset( $_GET['simple_system_status'] ) ) {
echo '// Browser of Current Viewer //';
echo "\r\n\r\n";
} ?>
<?php echo $browser ; ?>
<?php if ( isset( $_GET['simple_system_status'] ) ) {
echo "\r\n";
echo '// End Browser of Current Viewer //';
echo "\r\n\r\n";
} ?>
Client IP Address: <?php echo sss_get_ip() . "\n"; ?>
## WC Qucik Donation Settings Information ##
Simple Donation Product Exist : <?php echo WC_QD()->donation_product_exist_public(); ?>
<?php
$settings = WC_QD()->settings()->get_settings();
foreach($settings as $id => $setting){
$value = $setting;
if(is_array($setting)){$value = json_encode($setting);}
echo $id .' : '.$value."\n";
}
?>
### End WooCommerce Quick Donation Status ###
\ No newline at end of file
<div class="wrap">
<h2 class="sss-title"><?php _e( 'WC Quick Donation System Status', 'simple-system-status' ); ?></h2>
<div id="templateside">
</div>
<div id="template">
<?php // Form used to download .txt file ?>
<form action="<?php echo esc_url( self_admin_url( 'admin-ajax.php' ) ); ?>" method="post" enctype="multipart/form-data" >
<input type="hidden" name="action" value="download_simple_system_status" />
<div>
<textarea readonly="readonly" onclick="this.focus();this.select()" id="sss-textarea" name="simple-system-status-textarea" title="<?php _e( 'To copy the System Status, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'simple-system-status' ); ?>">
<?php //Non standard indentation needed for plain-text display ?>
<?php echo esc_html( self::display() ) ?>
</textarea>
</div>
<p class="submit">
<input type="submit" class="button-secondary" value="<?php _e( 'Download Sytem Info as Text File', 'simple-system-status' ) ?>" />
</p>
</form>
</div>
</div>
...@@ -1076,6 +1076,31 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -1076,6 +1076,31 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table {
/**
* Generate the table navigation above or below the table
*
* @since 3.1.0
* @access protected
* @param string $which
*/
protected function display_tablenav( $which ) {
if ( 'top' == $which )
wp_nonce_field( 'bulk-' . $this->_args['plural'] );
?>
<div class="tablenav <?php echo esc_attr( $which ); ?>">
<div class="alignleft actions bulkactions">
<?php $this->bulk_actions( $which ); ?>
</div>
<?php
$this->extra_tablenav( $which );
$this->pagination( $which );
?>
<br class="clear" />
</div>
<?php
}
} }
......
...@@ -151,6 +151,7 @@ class WooCommerce_Quick_Donation_Settings { ...@@ -151,6 +151,7 @@ class WooCommerce_Quick_Donation_Settings {
} }
$this->settings_values = $values; $this->settings_values = $values;
return $values;
} }
} }
......
<?php <?php
/* /*
Name: Admin Notice Helper * Copyright (C) 2014 Panagiotis Vagenas <pan.vagenas@gmail.com>
URI: https://github.com/iandunn/admin-notice-helper
Version: 0.2
Author: Ian Dunn
Author URI: http://iandunn.name
License: GPLv2
*/
/*
* Copyright 2014 Ian Dunn (email : ian@iandunn.name)
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License, version 2, as * it under the terms of the GNU General Public License as published by
* published by the Free Software Foundation. * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
...@@ -22,119 +14,507 @@ License: GPLv2 ...@@ -22,119 +14,507 @@ License: GPLv2
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program. If not, see <http://www.gnu.org/licenses/>.
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
if ( ! defined( 'ABSPATH' ) ) { /**
die( 'Access denied.' ); * @author Panagiotis Vagenas <pan.vagenas@gmail.com>
} * @url https://bitbucket.org/vagenas/wp-admin-notices/wiki/Home
* @
*/
if (!class_exists('WP_Admin_Notices')) {
/**
* Singleton class of WP_Admin_Notices
* Please see https://bitbucket.org/vagenas/wp-admin-notices/wiki/Home
*
* @author Panagiotis Vagenas <pan.vagenas@gmail.com>
*/
class WP_Admin_Notices {
/**
* Instance of this class.
*
* @since 1.0.0
* @var WP_Admin_Notices
*/
protected static $instance = null;
if ( ! class_exists( 'WC_QD_Admin_Notice_Helper' ) ) { /**
* Name of the array that will be stored in DB
* @var string
* @since 1.0.0
*/
protected $noticesArrayName = 'WCQDWPAdminNotices';
/**
* Name of the GET / POST that will be to remove the msg
* @var string
* @since 1.0.0
*/
protected $REQUESTID = 'WCQDRMSG';
class WC_QD_Admin_Notice_Helper { /**
// Declare variables and constants * Notices array as loaded from DB
protected static $instance; * @var array
protected $notices, $notices_were_updated; * @since 1.0.0
*/
protected $notices = array();
/** /**
* Constructor * Costructor (private since this is a singleton)
*/ */
protected function __construct() { private function __construct() {
$this->init(); $this->loadNotices();
//add_action( 'init', array( $this, 'init' )); // needs to run before other plugin's init callbacks so that they can enqueue messages in their init callbacks $this->auto_remove_Notice();
add_action( 'admin_notices', array( $this, 'print_notices' ) ); add_action('admin_notices', array($this, 'displayNotices'));
add_action( 'shutdown', array( $this, 'shutdown' ) );
} }
/** /**
* Provides access to a single instances of the class using the singleton pattern * Returns an instance of this class.
* *
* @mvc Controller * @since 1.0.0
* @author Ian Dunn <ian@iandunn.name> * @return WP_Admin_Notices
* @return object
*/ */
public static function get_singleton() { public static function getInstance() {
if ( ! isset( self::$instance ) ) { if (null == self::$instance) {
self::$instance = new WC_QD_Admin_Notice_Helper(); self::$instance = new self();
} }
return self::$instance; return self::$instance;
} }
/** /**
* Initializes variables * Loads notices from DB
*/
private function loadNotices() {
$notices = get_option($this->noticesArrayName);
if (is_array($notices)) {
$this->notices = $notices;
}
}
/**
* Action hook to display notices.
* Just echoes notices that should be displayed.
*/
public function displayNotices() {
foreach ($this->notices as $key => $notice) {
if ($this->isTimeToDisplay($notice)) {
echo $notice->getContentFormated($notice->getWrapper());
$notice->incrementDisplayedTimes();
}
if($notice->getTimes() > 0){
if ($notice->isTimeToDie()) {
unset($this->notices[$key]);
}
}
}
$this->storeNotices();
}
/**
* Removes Notice By Getting ID From GET / POST METHOD
*/
public function auto_remove_Notice(){
if(isset($_REQUEST[$this->REQUESTID])){
$nonce = $_REQUEST['_wpnonce'];
if (wp_verify_nonce( $nonce, 'WCQDREMOVEMSG' ) ) {
$this->deleteNotice($_REQUEST[$this->REQUESTID]);
if (wp_get_referer()){ wp_safe_redirect( wp_get_referer() ); }
}
}
}
/**
* Stores notices in DB
*/ */
public function init() { private function storeNotices() {
$default_notices = array( 'update' => array(), 'error' => array() ); update_option($this->noticesArrayName, $this->notices);
$this->notices = array_merge( $default_notices, get_option( 'anh_notices', array() ) ); }
$this->notices_were_updated = false;
/**
* Deletes a notice
* @param int $notId The notice unique id
*/
public function deleteNotice($notId) {
foreach ($this->notices as $key => $notice) {
if ($notice->getId() === $notId) {
unset($this->notices[$key]);
break;
}
}
$this->storeNotices();
} }
/** /**
* Queues up a message to be displayed to the user * Adds a notice to be displayed
* @param erpAdminMessage $notice
*/
public function addNotice(WP_Notice $notice) {
$this->notices[] = $notice;
$this->storeNotices();
}
/**
* Checks if is time to display a notice
* @param WP_Notice $notice
* @return bool
*/
private function isTimeToDisplay(WP_Notice $notice) {
$screens = $notice->getScreen();
if (!empty($screens)) {
$curScreen = get_current_screen();
if (!is_array($screens) || !in_array($curScreen->id, $screens)) {
return false;
}
}
$usersArray = $notice->getUsers();
if (!empty($usersArray)) {
$curUser = get_current_user_id();
if (!is_array($usersArray) || !in_array($curUser, $usersArray) || $usersArray[$curUser] >= $notice->getTimes()) {
return false;
}
} else if ($notice->getTimes() == 0) {
return true;
} else if ($notice->getTimes() <= $notice->getDisplayedTimes()) {
return false;
}
return true;
}
}
}
if (!class_exists('WP_Notice')) {
/**
* Abstract class of a notice
* *
* @param string $message The text to show the user * @author Panagiotis Vagenas <pan.vagenas@gmail.com>
* @param string $type 'update' for a success or notification message, or 'error' for an error message */
abstract class WP_Notice {
/**
* Notice message to be displayed
* @var string
*/ */
public function enqueue( $message, $type = 'update' ) { protected $content;
if(!empty($this->notices)){ /**
if(isset( $this->notices[ $type ])){ * Notice type
if ( in_array( $message, array_values( $this->notices[ $type ] ) ) ) { * @var string
return; */
protected $type;
/**
* In which screens the notice to be displayed
* @var array
*/
protected $screen;
/**
* Unique identifier for notice
* @var int
*/
protected $id;
/**
* Number of times to be displayed
* @var int
*/
protected $times = 1;
/**
* User ids this notice should be displayed
* @var array
*/
protected $users = array();
/**
* Number of times this message is displayed
* @var int
*/
protected $displayedTimes = 0;
/**
* Keeps track of how many times and to
* which users this notice is displayed
* @var array
*/
protected $displayedToUsers = array();
/**
* With Or WithOut Wraper
* @var array
*/
protected $WithWraper = true;
/**
*
* @param type $content Coantent to be displayed
* @param type $times How many times this notice will be displayed
* @param array $screen The admin screens this notice will be displayed into (empty for all screens)
* @param array $users Array of users this notice concernes (empty for all users)
*/
public function __construct($content, $times = 1, Array $screen = array(), Array $users = array(), $WithWraper = true) {
$this->content = $content;
$this->screen = $screen;
$this->id = uniqid();
$this->times = $times;
$this->users = $users;
$this->WithWraper = $WithWraper;
}
/**
* Get the content of the notice
* @param bool $wrapInParTag If the content should be wrapped in a paragraph tag
* @return string Formated content
*/
public function getContentFormated($wrapInParTag = true) {
$before = '<div class="' . $this->type . '">';
$before .= $wrapInParTag ? '<p>' : '';
$after = $wrapInParTag ? '</p>' : '';
$after .= '</div>';
return $before . $this->getContent() . $after;
}
/**
* Increment displayed times of the notice
* @return \WP_Notice
*/
public function incrementDisplayedTimes() {
$this->displayedTimes++;
if (array_key_exists(get_current_user_id(), $this->displayedToUsers)) {
$this->displayedToUsers[get_current_user_id()] ++;
} else {
$this->displayedToUsers[get_current_user_id()] = 1;
}
return $this;
}
/**
* Checks if the notice should me destroyed
* @return boolean True iff notice is deprecated
*/
public function isTimeToDie() {
if (empty($this->users)) {
return $this->displayedTimes >= $this->times;
} else {
$i = 0;
foreach ($this->users as $key => $value) {
if (isset($this->displayedToUsers[$value]) && $this->displayedToUsers[$value] >= $this->times) {
$i++;
} }
} }
if ($i >= count($this->users)) {
return true;
}
}
return false;
}
/**
* Get the $WithWraper Value
*/
public function getWrapper(){
return $this->WithWraper;
} }
$this->notices[ $type ][] = (string) apply_filters( 'anh_enqueue_message', $message ); /**
$this->notices_were_updated = true; * Set the $WithWraper Value
* @param boolean $screen
*/
public function setWrapper($wrapper = true){
$this->WithWraper = $wrapper;
return $this;
}
/**
* Get the current screen slug
* @return string Current screen slug
*/
public function getScreen() {
return $this->screen;
}
/**
* Set the screens the notice will be displayed
* @param array $screen
* @return \WP_Notice
*/
public function setScreen(Array $screen) {
$this->screen = $screen;
return $this;
}
/**
* Get the notice string unformated
* @return string
*/
public function getContent() {
return $this->content;
}
/**
*
* @param string $content
* @return \WP_Notice
*/
public function setContent($content) {
$this->content = $content;
return $this;
}
/**
*
* @return string
*/
public function getId() {
return $this->id;
} }
/** /**
* Displays updates and errors *
* @return int
*/ */
public function print_notices() { public function getTimes() {
//$this->notices_were_updated = true; return $this->times;
foreach ( array( 'update', 'error' ) as $type ) { }
if ( count( $this->notices[ $type ] ) ) { /**
$class = 'update' == $type ? 'updated' : 'error'; *
* @return array
*/
public function getUsers() {
return $this->users;
}
?> /**
*
* @param int $times
* @return \WP_Notice
*/
public function setTimes($times) {
$this->times = $times;
return $this;
}
<div class="anh_message <?php esc_attr_e( $class ); ?>"> /**
<?php foreach ( $this->notices[ $type ] as $notice ) : ?> *
<p><?php echo wp_kses( $notice, wp_kses_allowed_html( 'post' ) ); ?></p> * @param array $users
<?php endforeach; ?> * @return \WP_Notice
</div> */
public function setUsers(Array $users) {
$this->users = $users;
return $this;
}
<?php /**
*
* @return int
*/
public function getDisplayedTimes() {
return $this->displayedTimes;
}
/**
*
* @return array
*/
public function getDisplayedToUsers() {
return $this->displayedToUsers;
}
$this->notices[ $type ] = array(); /**
$this->notices_were_updated = true; *
* @param int $displayedTimes
* @return \WP_Notice
*/
public function setDisplayedTimes($displayedTimes) {
$this->displayedTimes = $displayedTimes;
return $this;
} }
/**
*
* @param array $displayedToUsers
* @return \WP_Notice
*/
public function setDisplayedToUsers(Array $displayedToUsers) {
$this->displayedToUsers = $displayedToUsers;
return $this;
} }
} }
/** /**
* Writes notices to the database * Type of notices
*/ */
public function shutdown() { class WP_Error_Notice extends WP_Notice {
if ( $this->notices_were_updated ) {
update_option( 'anh_notices', $this->notices ); protected $type = 'error wcQD';
} }
class WP_Updated_Notice extends WP_Notice {
protected $type = 'updated';
} }
} // end Admin_Notice_Helper
WC_QD_Admin_Notice_Helper::get_singleton(); // Create the instance immediately to make sure hook callbacks are registered in time class WP_UpdateNag_Notice extends WP_Notice {
protected $type = 'update-nag';
if ( ! function_exists( 'wc_qd_notice' ) ) {
function wc_qd_notice( $message, $type = 'update' ) {
WC_QD_Admin_Notice_Helper::get_singleton()->enqueue( $message, $type );
} }
}
/**
* Hook action to admin init
*/
if(!has_action('init', array('WP_Admin_Notices', 'getInstance'))){
add_action('init', array('WP_Admin_Notices', 'getInstance'));
}
//WP_Admin_Notices::getInstance();
if ( ! function_exists( 'wc_qd_notice' ) ) {
function wc_qd_notice( $message, $type = 'update',$args = array()) {
$notice = '';
$defaults = array('times' => 11,'screen' => array(),'users' => array(), 'wraper' => true);
$args = wp_parse_args( $args, $defaults );
extract($args);
if($type == 'error'){$notice = new WP_Error_Notice($message,$times, $screen, $users);}
if($type == 'update'){$notice = new WP_Updated_Notice($message,$times, $screen, $users);}
if($type == 'upgrade'){$notice = new WP_UpdateNag_Notice($message,$times, $screen, $users);}
$msgID = $notice->getId();
$message = str_replace('$msgID$',$msgID,$message);
$notice->setContent($message);
$notice->setWrapper($wraper);
///var_dump($notice->getId());
WP_Admin_Notices::getInstance()->addNotice($notice);
} }
} }
if ( ! function_exists( 'wc_qd_remove_link' ) ) {
function wc_qd_remove_link($attributes = '',$msgID = '$msgID$', $text = 'Remove Notice') {
if(!empty($msgID)){
$url = admin_url().'?WCQDRMSG='.$msgID ;
$url = wp_nonce_url($url, 'WCQDREMOVEMSG');
$url = urldecode($url);
$tag = '<a '.$attributes.' href="'.$url.'">'.__($text,'woocommerce-quick-donation').'</a>';
return $tag;
}
}
}
?> ?>
\ No newline at end of file
...@@ -8,12 +8,22 @@ class WC_QD_INSTALL{ ...@@ -8,12 +8,22 @@ class WC_QD_INSTALL{
public static function init(){ public static function init(){
$donation_exist = self::check_donation_exists(); $donation_exist = self::check_donation_exists();
self::check_db_version(); self::check_db_version();
self::post_register();
self::wc_qd_table_install(); self::wc_qd_table_install();
if($donation_exist){ return true; } self::check_template_files();
if(! $donation_exist){
$post_id = self::create_donation(); $post_id = self::create_donation();
update_option(WC_QD_DB.'product_id',$post_id); update_option(WC_QD_DB.'product_id',$post_id);
} }
}
public static function post_register(){
WC_QD_Post_Types::register_donation_posttype();
WC_QD_Post_Types::register_donation_category();
WC_QD_Post_Types::register_donation_tags();
flush_rewrite_rules();
}
/** /**
* Checks Upgrade Status * Checks Upgrade Status
...@@ -86,6 +96,58 @@ class WC_QD_INSTALL{ ...@@ -86,6 +96,58 @@ class WC_QD_INSTALL{
update_post_meta($post_id, '_sku', 'checkout-donation'); update_post_meta($post_id, '_sku', 'checkout-donation');
return $post_id; return $post_id;
} }
public static function get_template_list(){
$core_tempalte_list = WC_Admin_Status::scan_template_files( WC_QD_TEMPLATE );
return $core_tempalte_list;
}
public static function check_template_files(){
$template_files = self::get_template_list();
$outdated = false;
if(is_array($template_files)){
foreach($template_files as $file){
$theme_file = false;
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
$theme_file = get_stylesheet_directory() . '/' . $file;
} elseif ( file_exists( get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file ) ) {
$theme_file = get_stylesheet_directory() . WC_QD_THEME_TEMPLATE . $file;
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
$theme_file = get_template_directory() . '/' . $file;
} elseif( file_exists( get_template_directory() . WC_QD_THEME_TEMPLATE . $file ) ) {
$theme_file = get_template_directory() . WC_QD_THEME_TEMPLATE . $file;
}
if ( $theme_file !== false ) {
$core_version = WC_Admin_Status::get_file_version(WC_QD_TEMPLATE.$file);
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
if ( $core_version && $theme_version && version_compare( $theme_version, $core_version, '<' ) ) {
$outdated = true;
break;
}
}
}
if ( $outdated ) {
$theme = wp_get_theme();
$message = sprintf(
__( '<p> <strong>Your theme (%s) contains outdated copies of some WooCommerce Quick Donation template files.</strong> These files may need updating to ensure they are compatible with the current version of WooCommerce Quick Donation. You can see which files are affected from the %ssystem status page%s. If in doubt, check with the author of the theme. </p> <p class="submit">%sLear More About Templates%s %s</p>',
'woocommerce' ),
esc_html( $theme['Name'] ),
'<a href="' . admin_url( 'admin.php?page=wc-status' ) . '">','</a>',
'<a target="_blank" href="" class="button-primary" href="">','</a>',
wc_qd_remove_link('class="button" ')
);
wc_qd_notice($message,'error',array('times' => 0,'wraper' => false));
}
}
}
} }
?> ?>
\ No newline at end of file
...@@ -17,6 +17,9 @@ class WC_QD_Post_Types { ...@@ -17,6 +17,9 @@ class WC_QD_Post_Types {
* Registers Donation Post Type * Registers Donation Post Type
*/ */
public static function register_donation_posttype(){ public static function register_donation_posttype(){
if ( post_type_exists(WC_QD_PT) ) {
return;
}
$args = array( $args = array(
'label' => __( 'Quick Donation Project', WC_QD_TXT ), 'label' => __( 'Quick Donation Project', WC_QD_TXT ),
'description' => __( 'WooCommerce Donation Projects', WC_QD_TXT ), 'description' => __( 'WooCommerce Donation Projects', WC_QD_TXT ),
...@@ -82,7 +85,9 @@ class WC_QD_Post_Types { ...@@ -82,7 +85,9 @@ class WC_QD_Post_Types {
* Registers Post Type Category * Registers Post Type Category
*/ */
public static function register_donation_category(){ public static function register_donation_category(){
if ( taxonomy_exists( WC_QD_CAT ) ) {
return;
}
$labels = array( $labels = array(
'name' => _x( 'Project Categories', 'Taxonomy General Name', WC_QD_TXT ), 'name' => _x( 'Project Categories', 'Taxonomy General Name', WC_QD_TXT ),
'singular_name' => _x( 'Project Category', 'Taxonomy Singular Name', WC_QD_TXT ), 'singular_name' => _x( 'Project Category', 'Taxonomy Singular Name', WC_QD_TXT ),
...@@ -129,7 +134,9 @@ class WC_QD_Post_Types { ...@@ -129,7 +134,9 @@ class WC_QD_Post_Types {
* Registers Donation Tags * Registers Donation Tags
*/ */
public static function register_donation_tags() { public static function register_donation_tags() {
if ( taxonomy_exists( 'wcqd_tags' ) ) {
return;
}
$labels = array( $labels = array(
'name' => _x( 'Project Tags', 'Taxonomy General Name', WC_QD_TXT ), 'name' => _x( 'Project Tags', 'Taxonomy General Name', WC_QD_TXT ),
'singular_name' => _x( 'Project Tag', 'Taxonomy Singular Name', WC_QD_TXT ), 'singular_name' => _x( 'Project Tag', 'Taxonomy Singular Name', WC_QD_TXT ),
......
...@@ -68,7 +68,7 @@ class WooCommerce_Quick_Donation_Functions { ...@@ -68,7 +68,7 @@ class WooCommerce_Quick_Donation_Functions {
} }
public function wc_page_endpoint_title($title, $id){ public function wc_page_endpoint_title($title = '', $id = ''){
if(is_page($id)){ if(is_page($id)){
global $wp_query; global $wp_query;
......
/*
* Styles for Simple System Status Plugin
*/
h2.sss-title {
font-family: 'Open Sans', Arial,sans-serif;
font-weight: 300;
font-size: 3em;
margin: 5px 0 20px 0;
}
.instructions {
font-family: 'Open Sans', Arial,sans-serif;
margin-top: 0;
}
p.submit {
margin-top: 0px;
padding-top: 0px !important;
max-width: 100%;
padding-top: 10px;
text-align: left;
}
textarea#sss-textarea {
height: 500px;
font-family: Menlo,Monaco,monospace;
background: 0 0;
white-space: pre;
overflow: auto;
display: block;
padding: 10px 30px;
}
input[type="text"].sss-url {
font-family: Menlo,Monaco,monospace;
width: 600px;
color: #444;
padding: 10px;
}
.sss-tiny {
font-size: .8em;
}
\ No newline at end of file
(function($) {
$( document ).ready( function() {
/**
* Generate new Remote View URL
* and display it on the admin page
*/
$( 'input[name="generate-new-url"]' ).on( 'click', function( event ) {
event.preventDefault();
$.ajax({
type : 'post',
dataType : 'json',
url : systemInfoAjax.ajaxurl,
data : { action : 'regenerate_url' },
success : function( response ) {
$( '.sss-url-text' ).val( response );
$( '.sss-url-text-link' ).attr( 'href', response );
},
error : function( j, t, e ) {
console.log( "Simple System Status Error: " + j.responseText );
}
});
});
});
})(jQuery);
...@@ -60,8 +60,8 @@ class WooCommerce_Quick_Donation { ...@@ -60,8 +60,8 @@ class WooCommerce_Quick_Donation {
* Triggers When INIT Action Called * Triggers When INIT Action Called
*/ */
public function init(){ public function init(){
$this->init_class();
$this->check_donation_product_exist(); $this->check_donation_product_exist();
$this->init_class();
add_action('plugins_loaded', array( $this, 'after_plugins_loaded' )); add_action('plugins_loaded', array( $this, 'after_plugins_loaded' ));
add_filter('load_textdomain_mofile', array( $this, 'load_plugin_mo_files' ), 10, 2); add_filter('load_textdomain_mofile', array( $this, 'load_plugin_mo_files' ), 10, 2);
} }
...@@ -69,14 +69,22 @@ class WooCommerce_Quick_Donation { ...@@ -69,14 +69,22 @@ class WooCommerce_Quick_Donation {
/** /**
* Checks If Donation Product Exist In WooCommerce Products * Checks If Donation Product Exist In WooCommerce Products
*/ */
private function check_donation_product_exist(){ private function check_donation_product_exist($notice = true){
$install = new WC_QD_INSTALL; $install = new WC_QD_INSTALL;
if(! $install->check_donation_exists()){ if(! $install->check_donation_exists()){
self::$is_donation_product_exist = false; self::$is_donation_product_exist = false;
wc_qd_notice('WooCommerce Donation Product Not Exist','error'); if($notice){ wc_qd_notice('WooCommerce Donation Product Not Exist','error',true);}
} }
} }
/**
* Checks If Donation Product Exist In WooCommerce Products
*/
public function donation_product_exist_public(){
$this->check_donation_product_exist();
return self::$is_donation_product_exist;
}
/** /**
* Checks If Donation Product Exists In Cart * Checks If Donation Product Exists In Cart
*/ */
...@@ -99,7 +107,7 @@ class WooCommerce_Quick_Donation { ...@@ -99,7 +107,7 @@ class WooCommerce_Quick_Donation {
private function load_required_files(){ private function load_required_files(){
$this->load_files(WC_QD_INC.'wc-quick-donation-*.php'); $this->load_files(WC_QD_INC.'wc-quick-donation-*.php');
$this->load_files(WC_QD_ADMIN.'wps/*.php'); $this->load_files(WC_QD_ADMIN.'wps/*.php');
$this->load_files(WC_QD_INC.'class-admin-notice.php'); //$this->load_files(WC_QD_INC.'class-admin-notice.php');
$this->load_files(WC_QD_INC.'class-post-*.php'); $this->load_files(WC_QD_INC.'class-post-*.php');
$this->load_files(WC_QD_INC.'class-quick-donation-db.php'); $this->load_files(WC_QD_INC.'class-quick-donation-db.php');
$this->load_files(WC_QD_INC.'class-install.php'); $this->load_files(WC_QD_INC.'class-install.php');
...@@ -283,10 +291,12 @@ if(WC_QD_Dependencies()){ ...@@ -283,10 +291,12 @@ if(WC_QD_Dependencies()){
function WC_QD(){ function WC_QD(){
return WooCommerce_Quick_Donation::get_instance(); return WooCommerce_Quick_Donation::get_instance();
} }
$GLOBALS['woocommerce_quick_donation'] = WC_QD(); $GLOBALS['woocommerce_quick_donation'] = WC_QD();
} else { } else {
wc_qd_notice(__('WooCommerce Is Required. To Use This Plugin :)','woocommerce-quick-donation'),'error'); wc_qd_notice(__('WooCommerce Is Required. To Use This Plugin :)','woocommerce-quick-donation'),
'error',
array('times' => 1));
} }
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment