Browse Source

update

Shane
VidYen 2 years ago
parent
commit
fc9f19156d
8 changed files with 130 additions and 51 deletions
  1. +1
    -0
      vidyen-point-system-vyps/README.md
  2. +10
    -9
      vidyen-wc-mmo/includes/functions/ajax/vyps_mmo_bal_ajax.php
  3. +0
    -39
      vidyen-wc-mmo/includes/js/mmo.js
  4. +33
    -0
      vidyen-wc-mmo/includes/js/mmo_bal.js
  5. +42
    -0
      vidyen-wc-mmo/includes/shortcodes/vyps-wc-ajax-bal.php
  6. +1
    -1
      vidyen-wc-mmo/includes/shortcodes/vyps-wc-ww-bal.php
  7. +38
    -0
      vidyen-wc-mmo/uninstall.php
  8. +5
    -2
      vidyen-wc-mmo/vidyen-wc-mmo.php

+ 1
- 0
vidyen-point-system-vyps/README.md View File

@ -110,6 +110,7 @@ Unfortunately, postbacks are generally not intended for WordPress so I had to sh
- Fix: CSS fix for VY256 to be more theme compatible
- Add: Shortcode `roundup=TRUE` which rounds up to nearest point as after 1 point as currently you lose hashes in between after the first point you earned (not a default)
- Add: Earned function to allow to show total earned over all time rather than a sum of current. (Useful for book keeping)
= 2.3.2 =

vidyen-wc-mmo/includes/functions/ajax/vyps_mmo_ajax.php → vidyen-wc-mmo/includes/functions/ajax/vyps_mmo_bal_ajax.php View File

@ -18,17 +18,18 @@ function vyps_mmo_bal_api_action()
//NOTE: I do not think there is a need for nonce as no user input to wordpress
//Post gather from the AJAX post
$point_id = sanitize_text_field($_POST['point_id']);
$mo_array_server_response = array(
'site_hashes' => $site_total_hashes,
'site_hash_per_second' => $site_hash_per_second,
'site_validShares' => $site_valid_shares,
'current_XMRprice' => $current_xmr_price,
$point_id = intval($_POST['point_id']);
$user_id = get_current_user_id();
$point_balance = intval(vyps_point_balance_func($point_id, $user_id)); //Yes we always be santising so whelp
$mmo_bal_array_server_response = array(
'point_balance' => $point_balance,
);
echo json_encode($mo_array_server_response); //Proper method to return json
echo json_encode($mmo_bal_array_server_response); //Proper method to return json
wp_die(); // this is required to terminate immediately and return a proper response
}

+ 0
- 39
vidyen-wc-mmo/includes/js/mmo.js View File

@ -1,39 +0,0 @@
function pull_mo_stats()
{
jQuery(document).ready(function($) {
var data = {
'action': 'vyps_mo_api_action',
'site_wallet': '$mo_site_wallet',
'site_worker': '$mo_site_worker',
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response) {
output_response = JSON.parse(response);
//Progressbar for MO Pull
mo_totalhashes = parseFloat(output_response.site_hashes);
mo_XMRprice = parseFloat(output_response.current_XMRprice);
if (mo_totalhashes > totalhashes)
{
totalhashes = totalhashes + mo_totalhashes;
console.log('MO Hashes were greater.');
}
if ($market_multi > 0)
{
jsMarketMulti = ( mo_XMRprice * $market_multi );
}
else
{
jsMarketMulti = 1; //May not be necessary.
}
valid_shares = Math.floor( (parseFloat(output_response.site_validShares) / $shares_per_point) * jsMarketMulti ); //Multipass goes here. Realized oder of oeprations should be fine.
progresspoints = mo_totalhashes - ( Math.floor( mo_totalhashes / $hash_per_point ) * $hash_per_point );
totalpoints = Math.floor( mo_totalhashes / $hash_per_point );
document.getElementById('pool_text').innerHTML = 'Reward[' + '$reward_icon ' + totalpoints + '] - Reward Progress[' + progresspoints + '/' + $hash_per_point + ']';
//document.getElementById('progress_text').innerHTML = 'Reward[' + '$reward_icon ' + valid_shares + '] - Hashes[' + totalhashes + ']'; //This needs to remain not on the MO pull
//document.getElementById('hash_rate').innerHTML = output_response.site_hash_per_second;
poolProgresswidth = (( mo_totalhashes / $hash_per_point ) - Math.floor( mo_totalhashes / $hash_per_point )) * 100;
elempoolbar.style.width = poolProgresswidth + '%';
});
});
}

+ 33
- 0
vidyen-wc-mmo/includes/js/mmo_bal.js View File

@ -0,0 +1,33 @@
//Sets the method to update to the refresh I'm debatin gto make this universial or by point.
function pull_mmo_stats()
{
jQuery(document).ready(function($)
{
var data =
{
'action': 'vyps_mmo_bal_api_action',
'point_id': point_id,
};
// since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
jQuery.post(ajaxurl, data, function(response)
{
output_response = JSON.parse(response);
//MMO Pull
mmo_point_balance = parseFloat(output_response.point_balance);
if (mmo_point_balance > 0)
{
console.log('Point Balance is: ' + mmo_point_balance);
}
else
{
console.log('Point Balance is: 0');
}
});
});
}
window.setInterval(function()
{
/// call your function here
pull_mmo_stats();
}, 5000);

+ 42
- 0
vidyen-wc-mmo/includes/shortcodes/vyps-wc-ajax-bal.php View File

@ -0,0 +1,42 @@
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
//I'm going to do this all in a slew of both the balance if ww or not
//NOTE: I've decided to this this with just one point and the WooWallet output for simplicity. If people want more they can ask.
function vyps_mmo_ajax_bal_func($atts)
{
//Check if user is logged in and stop the code.
//NOTE:I moved this here. I realized, its more likely that 10,000 users are bashing site mem while the admin is almost always logged in.
if ( !is_user_logged_in() )
{
return; //You get nothing. Use the LG code.
}
//Only need to get the output id to show
$atts = shortcode_atts(
array(
'pointid' => '0',
), $atts, 'vyps-pe' );
$point_id = $atts['pointid'];
$div_id = $point_id.'mmobaldiv';
$user_id = get_current_user_id();
//Get the url for the solver
$mmo_ajax_js_url = plugins_url( 'js/mmo_bal.js', dirname(__FILE__) );
$vyps_bal_html_output = '<div id="'.$div_id.'">'.vyps_point_icon_func($point_id).' '.vyps_point_balance_func($point_id, $user_id).'</div>';
$www_bal_html_output = '<div id="'.$div_id.'">'.vyps_point_icon_func($point_id).' '.vyps_point_balance_func($point_id, $user_id).'</div>';
$js_html_output = '<script src="'.$mmo_ajax_js_url.'"></script><script>var point_id = '.$point_id.';</script>'; //this sets the poitn id for the mmo_bal.js
return $ww_bal_html_output;
}
/* Telling WP to use function for shortcode */
add_shortcode( 'vyps-mmo-bal', 'vyps_wc_ajax_bal_func');
/* Ok after much deliberation, I decided I want the WW plugin to go into the pt since it has become the exchange */
/* If you don't have WW, it won't kill anything if you don't call it */

+ 1
- 1
vidyen-wc-mmo/includes/shortcodes/vyps-wc-ww-bal.php View File

@ -30,7 +30,7 @@ function vyps_wc_ww_bal_func($atts)
/* Telling WP to use function for shortcode */
add_shortcode( 'vyps-mmo-bal', 'vyps_wc_ww_bal_func');
add_shortcode( 'vyps-mmo-wc-bal', 'vyps_wc_ww_bal_func');
/* Ok after much deliberation, I decided I want the WW plugin to go into the pt since it has become the exchange */
/* If you don't have WW, it won't kill anything if you don't call it */

+ 38
- 0
vidyen-wc-mmo/uninstall.php View File

@ -0,0 +1,38 @@
<?php
/*
* Removing Plugin data using uninstall.php
* the below function clears the database table on uninstall
* only loads this file when uninstalling a plugin.
*/
//NOTE: The VidYen MMO plugin SQL table is so small its worth removing through uninstall
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/*
* exit uninstall if not called by WP
*/
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit();
}
//I commented everything out, but will install a proper uninstall page in 3.0
/*
* Making WPDB as global
* to access database information.
*/
global $wpdb;
/*
* @var $table_name
* name of table to be dropped
* prefixed with $wpdb->prefix from the database
*/
$table_name_mmo = $wpdb->prefix . 'vidyen_wc_mmo';
// drop the table from the database. NOTE: I called each without a loop as this should be very simple and specific. -Felty
$wpdb->query( "DROP TABLE IF EXISTS $table_name_mmo" );

+ 5
- 2
vidyen-wc-mmo/vidyen-wc-mmo.php View File

@ -3,7 +3,7 @@
Plugin Name: VYPS WooCommerce MMO Plugin
Plugin URI: https://wordpress.org/plugins/vidyen-point-system-vyps/
Description: Adds RPG like currencies to WooCommerce for VYPS
Version: 0.0.9
Version: 0.0.10
Author: VidYen, LLC
Author URI: https://vidyen.com/
License: GPLv2
@ -207,4 +207,7 @@ include( plugin_dir_path( __FILE__ ) . 'includes/shortcodes/vyps-wc-mmo-point-ex
include( plugin_dir_path( __FILE__ ) . 'includes/shortcodes/vyps-wc-ww-bal.php'); //Point Exchange
/*** Menu Includes ***/
include( plugin_dir_path( __FILE__ ) . 'includes/menus/adgate-menu.php'); //Order 450 (residual from the extraction for core VYPS)
//NOTE: Note really needed //include( plugin_dir_path( __FILE__ ) . 'includes/menus/adgate-menu.php'); //Order 450 (residual from the extraction for core VYPS)
/*** AJAX ***/
include( plugin_dir_path( __FILE__ ) . 'includes/functions/ajax/vyps_mmo_bal_ajax.php');

Loading…
Cancel
Save