This commit is contained in:
ruben- 2014-07-02 21:34:07 +02:00
parent 0b3ef41321
commit 26f5482fd1
12 changed files with 288 additions and 97 deletions

View file

@ -69,7 +69,7 @@ class MainWPBackup
}
}
$time = 300; /*300 seconds = 5 minutes*/
$time = 3000; /*300 seconds = 5 minutes*/
$mem = '512M';
@ini_set('memory_limit', $mem);
@ini_set('max_execution_time', $time);
@ -97,7 +97,7 @@ class MainWPBackup
public function zipFile($file, $archive)
{
$time = 300; /*300 seconds = 5 minutes*/
$time = 3000; /*300 seconds = 5 minutes*/
$mem = '512M';
@ini_set('memory_limit', $mem);
@ini_set('max_execution_time', $time);

View file

@ -56,7 +56,8 @@ class MainWPChild
'wordpress_seo' => 'wordpress_seo',
'client_report' => 'client_report',
'createBackupPoll' => 'backupPoll',
'page_speed' => 'page_speed'
'page_speed' => 'page_speed',
'woo_com_status' => 'woo_com_status'
);
private $FTP_ERROR = 'Failed, please add FTP details for automatic upgrades.';
@ -3544,6 +3545,11 @@ class MainWPChild
MainWPChildPagespeed::Instance()->action();
}
function woo_com_status() {
MainWPChildWooCommerceStatus::Instance()->action();
}
}
?>

View file

@ -13,7 +13,7 @@ class MainWPChildPagespeed
}
public function __construct() {
add_action('mainwp_child_deactivation', array($this, 'child_deactivation'));
}
public function action() {
@ -38,6 +38,13 @@ class MainWPChildPagespeed
MainWPHelper::write($information);
}
public function child_deactivation()
{
if ($sched = wp_next_scheduled('mainwp_child_pagespeed_cron_check')) {
wp_unschedule_event($sched, 'mainwp_child_pagespeed_cron_check');
}
}
public function init()
{
if (get_option('mainwp_pagespeed_ext_enabled') !== "Y")
@ -49,6 +56,32 @@ class MainWPChildPagespeed
//add_action('admin_menu', array($this, 'hide_menu'), 999);
add_filter('update_footer', array(&$this, 'update_footer'), 15);
}
$this->init_cron();
}
public function init_cron() {
add_action('mainwp_child_pagespeed_cron_check', array('MainWPChildPagespeed', 'pagespeed_cron_check'));
if (($sched = wp_next_scheduled('mainwp_child_pagespeed_cron_check')) == false)
{
wp_schedule_event(time(), 'daily', 'mainwp_child_pagespeed_cron_check');
}
}
public static function pagespeed_cron_check() {
$count = get_option("mainwp_child_pagespeed_count_checking");
if ($count == 7) {
$recheck = true;
$count = 0;
} else {
$recheck = false;
$count++;
}
update_option("mainwp_child_pagespeed_count_checking", $count);
$worker_args = array(
array(), false, $recheck
);
wp_schedule_single_event( time(), 'googlepagespeedinsightschecknow', $worker_args );
}
public function hide_plugin($plugins) {
@ -150,17 +183,19 @@ class MainWPChildPagespeed
$strategy = $current_values['strategy'];
$sync_data = $this->sync_data($strategy);
$information['data'] = $sync_data['data'];
$information = $this->sync_data($strategy);
return $information;
}
function sync_data($strategy = "") {
if (empty($strategy))
$strategy = "both";
$current_values = get_option('gpagespeedi_options');
if (is_array($current_values) && $current_values['last_run_finished'] == false)
return array('result' => 'RUNNING');
$information = array();
$current_values = get_option('gpagespeedi_options');
$bad_key = ($current_values['bad_api_key'] || empty($current_values['google_developer_key']));
$data = array('bad_api_key' => $bad_key );
@ -183,10 +218,12 @@ class MainWPChildPagespeed
static function cal_pagespeed_data($strategy) {
global $wpdb;
if ( !defined('GPI_DIRECTORY') )
return 0;
if ($strategy !== "desktop" && $strategy !== "mobile")
return 0;
require_once( GPI_DIRECTORY . '/includes/helper.php' );
$options = get_option('gpagespeedi_options');
@ -284,8 +321,7 @@ class MainWPChildPagespeed
ARRAY_A
);
}
return array('last_modified' => isset($data['last_modified']) ? $data['last_modified'] : 0,
return array('last_modified' => is_array($data[0]) && isset($data[0]['last_modified']) ? $data[0]['last_modified'] : 0,
'average_score' => $average_score,
'total_pages' => $total_pages);
}

View file

@ -0,0 +1,145 @@
<?php
class MainWPChildWooCommerceStatus
{
public static $instance = null;
static function Instance() {
if (MainWPChildWooCommerceStatus::$instance == null) {
MainWPChildWooCommerceStatus::$instance = new MainWPChildWooCommerceStatus();
}
return MainWPChildWooCommerceStatus::$instance;
}
public function __construct() {
add_action('mainwp_child_deactivation', array($this, 'child_deactivation'));
}
public function child_deactivation()
{
}
public function action() {
$information = array();
if (!class_exists('WooCommerce')) {
$information['error'] = 'NO_WOOCOMMERCE';
MainWPHelper::write($information);
}
if (isset($_POST['mwp_action'])) {
switch ($_POST['mwp_action']) {
case "sync_data":
$information = $this->sync_data();
break;
}
}
MainWPHelper::write($information);
}
function sync_data() {
global $wpdb;
$file = WP_PLUGIN_DIR . '/woocommerce/includes/admin/reports/class-wc-admin-report.php';
if (file_exists($file))
include_once( $file );
else
return false;
$reports = new WC_Admin_Report();
// Get sales
$sales = $wpdb->get_var( "SELECT SUM( postmeta.meta_value ) FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
WHERE posts.post_type = 'shop_order'
AND posts.post_status = 'publish'
AND tax.taxonomy = 'shop_order_status'
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND postmeta.meta_key = '_order_total'
AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "'
AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "'
" );
// Get top seller
$top_seller = $wpdb->get_row( "SELECT SUM( order_item_meta.meta_value ) as qty, order_item_meta_2.meta_value as product_id
FROM {$wpdb->posts} as posts
LEFT JOIN {$wpdb->term_relationships} AS rel ON posts.ID=rel.object_ID
LEFT JOIN {$wpdb->term_taxonomy} AS tax USING( term_taxonomy_id )
LEFT JOIN {$wpdb->terms} AS term USING( term_id )
LEFT JOIN {$wpdb->prefix}woocommerce_order_items AS order_items ON posts.ID = order_id
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta ON order_items.order_item_id = order_item_meta.order_item_id
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS order_item_meta_2 ON order_items.order_item_id = order_item_meta_2.order_item_id
WHERE posts.post_type = 'shop_order'
AND posts.post_status = 'publish'
AND tax.taxonomy = 'shop_order_status'
AND term.slug IN ( '" . implode( "','", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "' )
AND order_item_meta.meta_key = '_qty'
AND order_item_meta_2.meta_key = '_product_id'
AND posts.post_date >= '" . date( 'Y-m-01', current_time( 'timestamp' ) ) . "'
AND posts.post_date <= '" . date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ) . "'
GROUP BY product_id
ORDER BY qty DESC
LIMIT 1
" );
if (!empty($top_seller))
$top_seller->name = get_the_title( $top_seller->product_id );
// Counts
$on_hold_count = get_term_by( 'slug', 'on-hold', 'shop_order_status' )->count;
$processing_count = get_term_by( 'slug', 'processing', 'shop_order_status' )->count;
// Get products using a query - this is too advanced for get_posts :(
$stock = absint( max( get_option( 'woocommerce_notify_low_stock_amount' ), 1 ) );
$nostock = absint( max( get_option( 'woocommerce_notify_no_stock_amount' ), 0 ) );
$query_from = "FROM {$wpdb->posts} as posts
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
WHERE 1=1
AND posts.post_type IN ('product', 'product_variation')
AND posts.post_status = 'publish'
AND (
postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$stock}' AND CAST(postmeta.meta_value AS SIGNED) > '{$nostock}' AND postmeta.meta_value != ''
)
AND (
( postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' ) OR ( posts.post_type = 'product_variation' )
)
";
$lowinstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
$query_from = "FROM {$wpdb->posts} as posts
INNER JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id
INNER JOIN {$wpdb->postmeta} AS postmeta2 ON posts.ID = postmeta2.post_id
WHERE 1=1
AND posts.post_type IN ('product', 'product_variation')
AND posts.post_status = 'publish'
AND (
postmeta.meta_key = '_stock' AND CAST(postmeta.meta_value AS SIGNED) <= '{$nostock}' AND postmeta.meta_value != ''
)
AND (
( postmeta2.meta_key = '_manage_stock' AND postmeta2.meta_value = 'yes' ) OR ( posts.post_type = 'product_variation' )
)
";
$outofstock_count = absint( $wpdb->get_var( "SELECT COUNT( DISTINCT posts.ID ) {$query_from};" ) );
$data = array('sales' => $sales,
'formated_sales' => wc_price( $sales ),
'top_seller' => $top_seller,
'onhold' => $on_hold_count,
'awaiting' => $processing_count,
'stock' => $stock,
'nostock' => $nostock,
'lowstock' => $lowinstock_count,
'outstock' => $outofstock_count,
);
$information['data'] = $data;
return $information;
}
}

View file

@ -401,7 +401,7 @@ Author URI: http://dd32.id.au/
$uploadSizeInBytes = min(MainWPHelper::return_bytes(ini_get('upload_max_filesize')), MainWPHelper::return_bytes(ini_get('post_max_size')));
$uploadSize = MainWPHelper::human_filesize($uploadSizeInBytes);
?>
<div id="mainwp-child_clone_status" title="Clone process"></div>
<div id="mainwp-child_clone_status" title="Restore process"></div>
<script language="javascript">
jQuery(document).on('change', '#file', function()
{
@ -465,7 +465,7 @@ Author URI: http://dd32.id.au/
};
var translations = [] ;
translations['large_site'] = '<?php _e('This is a large site (%dMB), the clone process will more than likely fail.', 'mainwp-child'); ?>';
translations['large_site'] = '<?php _e('This is a large site (%dMB), the restore process will more than likely fail.', 'mainwp-child'); ?>';
translations['continue_anyway'] = '<?php _e('Continue Anyway?', 'mainwp-child'); ?>';
translations['creating_backup'] = '<?php _e('Creating backup on %s expected size: %dMB (estimated time: %d seconds)', 'mainwp-child'); ?>';
translations['backup_created'] = '<?php _e('Backup created on %s total size to download: %dMB', 'mainwp-child'); ?>';

View file

@ -369,7 +369,7 @@ msgstr "MainWP Kloniranje"
#: class/MainWPClone.class.php:221
#, php-format
#@ mainwp-child
msgid "This is a large site (%dMB), the clone process will more than likely fail."
msgid "This is a large site (%dMB), the restore process will more than likely fail."
msgstr "Ovo je veliki sajt (%dMB), kloniranje verovatno neće uspeti."
#: class/MainWPClone.class.php:222

View file

@ -537,7 +537,7 @@ msgstr "Eine einziges Datenbank-Backup wird nicht funktionieren."
#: class/MainWPClone.class.php:468
#, php-format
#@ mainwp-child
msgid "This is a large site (%dMB), the clone process will more than likely fail."
msgid "This is a large site (%dMB), the restore process will more than likely fail."
msgstr "Dies ist eine große Seite (%dMB), der Klon-Prozess wird mehr als wahrscheinlich scheitern."
#: class/MainWPClone.class.php:469

View file

@ -369,7 +369,7 @@ msgstr "MainWP Kloniranje"
#: class/MainWPClone.class.php:221
#, php-format
#@ mainwp-child
msgid "This is a large site (%dMB), the clone process will more than likely fail."
msgid "This is a large site (%dMB), the restore process will more than likely fail."
msgstr "Ovo je veliki sajt (%dMB), kloniranje verovatno neće uspeti."
#: class/MainWPClone.class.php:222

View file

@ -369,7 +369,7 @@ msgstr "MainWP Kloniranje"
#: class/MainWPClone.class.php:221
#, php-format
#@ mainwp-child
msgid "This is a large site (%dMB), the clone process will more than likely fail."
msgid "This is a large site (%dMB), the restore process will more than likely fail."
msgstr "Ovo je veliki sajt (%dMB), kloniranje verovatno neće uspeti."
#: class/MainWPClone.class.php:222

View file

@ -369,7 +369,7 @@ msgstr "MainWP Kloniranje"
#: class/MainWPClone.class.php:221
#, php-format
#@ mainwp-child
msgid "This is a large site (%dMB), the clone process will more than likely fail."
msgid "This is a large site (%dMB), the restore process will more than likely fail."
msgstr "Ovo je veliki sajt (%dMB), kloniranje verovatno neće uspeti."
#: class/MainWPClone.class.php:222

View file

@ -5,7 +5,7 @@
Description: Child Plugin for MainWP. The plugin is used so the installed blog can be securely managed remotely by your network. Plugin documentation and options can be found here http://docs.mainwp.com
Author: MainWP
Author URI: http://mainwp.com
Version: 0.29.9
Version: 0.29.10
*/
header('X-Frame-Options: ALLOWALL');
//header('X-Frame-Options: GOFORIT');

View file

@ -7,7 +7,7 @@ Author URI: http://mainwp.com
Plugin URI: http://mainwp.com
Requires at least: 3.6
Tested up to: 3.9
Stable tag: 0.29.9
Stable tag: 0.29.10
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -58,6 +58,10 @@ To see full documentation and FAQs please visit [MainWP Documentation](http://do
== Changelog ==
= 0.29.10 =
* Fixed: Admin not accessible with invalid upload directory
* Added new hooks for upcoming extensions
= 0.29.9 =
* Added new hooks for upcoming extensions