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
...@@ -17,53 +17,14 @@ if ( ! defined( 'WPINC' ) ) { die; } ...@@ -17,53 +17,14 @@ 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){
......
This diff is collapsed.
<?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
This diff is collapsed.
<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>
...@@ -1075,7 +1075,32 @@ class WC_Quick_Donation_Listing_Table extends WP_List_Table { ...@@ -1075,7 +1075,32 @@ 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;
} }
} }
......
This diff is collapsed.
...@@ -8,11 +8,21 @@ class WC_QD_INSTALL{ ...@@ -8,11 +8,21 @@ 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();
$post_id = self::create_donation(); if(! $donation_exist){
update_option(WC_QD_DB.'product_id',$post_id); $post_id = self::create_donation();
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();
} }
/** /**
...@@ -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;
......
...@@ -185,7 +185,7 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -185,7 +185,7 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
} }
public function redirect_cart($key = ''){ public function redirect_cart($key = ''){
if(empty($key)){$key = WC_QD_DB.'redirect_user';} if(empty($key)){$key = WC_QD_DB.'redirect_user';}
if($this->is_donation_exists){ if($this->is_donation_exists){
$redirect = WC_QD()->settings()->get_option($key); $redirect = WC_QD()->settings()->get_option($key);
$url = ''; $url = '';
...@@ -245,4 +245,4 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation { ...@@ -245,4 +245,4 @@ class WooCommerce_Quick_Donation_Process extends WooCommerce_Quick_Donation {
} }
?> ?>
\ No newline at end of file
/*
* 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