Skip to content

Commit 8ac92f6

Browse files
committed
fix #14
1 parent 3d754f0 commit 8ac92f6

10 files changed

+109
-277
lines changed

admin/class-woocommerce-taxonomy-report-admin.php

+1-11
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,12 @@
44
* WooCommerce Taxonomy Report
55
*
66
* @package Woocommerce_Taxonomy_Report_Admin
7-
* @author WooThemes <lavoro@codeat.it>
7+
* @author Codeat <support@codeat.co>
88
* @license GPL-2.0+
99
* @link http://codeat.it
1010
* @copyright 2016 GPL
1111
*/
1212

13-
/**
14-
* Plugin class. This class should ideally be used to work with the
15-
* administrative side of the WordPress site.
16-
*
17-
* If you're interested in introducing public-facing
18-
* functionality, then refer to `class-woocommerce-taxonomy-report.php`
19-
*
20-
* @package Woocommerce_Taxonomy_Report_Admin
21-
* @author WooThemes <[email protected]>
22-
*/
2313
class Woocommerce_Taxonomy_Report_Admin {
2414

2515
/**

admin/includes/WC_Integration_TReport.php

+104-100
Original file line numberDiff line numberDiff line change
@@ -2,116 +2,120 @@
22

33
// If this file is called directly, abort.
44
if ( !defined( 'WPINC' ) ) {
5-
die;
5+
die;
66
}
77

88
class WC_Integration_TReport extends WC_Integration {
99

10-
/**
11-
* Init and hook in the integration.
12-
*/
13-
public function __construct() {
14-
global $woocommerce;
15-
$this->id = 'taxonomy-report';
16-
$this->method_title = __( 'Taxonomy Report', 'woocommerce-taxonomy-report' );
17-
$this->method_description = __( 'Add reports based on taxonomies.', 'woocommerce-taxonomy-report' );
18-
// Actions.
19-
add_action( 'woocommerce_update_options_integration_' . $this->id, array( $this, 'process_admin_options' ) );
20-
add_filter( 'woocommerce_admin_reports', __CLASS__ . '::add_reports' );
21-
add_action( 'woocommerce_after_register_taxonomy', array( $this, 'load_taxonomies_by_wc' ) );
22-
}
10+
/**
11+
* Init and hook in the integration.
12+
*/
13+
public function __construct() {
14+
global $woocommerce;
15+
$this->id = 'taxonomy-report';
16+
$this->method_title = __( 'Taxonomy Report', 'woocommerce-taxonomy-report' );
17+
$this->method_description = __( 'Add reports based on taxonomies.', 'woocommerce-taxonomy-report' );
18+
// Actions.
19+
add_action( 'woocommerce_update_options_integration_' . $this->id, array( $this, 'process_admin_options' ) );
20+
add_filter( 'woocommerce_admin_reports', __CLASS__ . '::add_reports' );
21+
add_action( 'woocommerce_after_register_taxonomy', array( $this, 'load_taxonomies_by_wc' ) );
22+
}
2323

24-
/**
25-
* Initialize integration settings form fields.
26-
*/
27-
public function init_form_fields() {
28-
$taxonomies = get_object_taxonomies( 'product', 'objects' );
29-
unset( $taxonomies[ 'product_shipping_class' ] );
30-
unset( $taxonomies[ 'product_type' ] );
31-
unset( $taxonomies[ 'pa_color' ] );
32-
$product_tags = array();
33-
foreach ( $taxonomies as $taxonomy ) {
34-
$product_tags[ $taxonomy->query_var ] = $taxonomy->label;
35-
}
36-
$taxonomies = get_option( 'woocommerce_taxonomy-report_settings', null );
37-
if ( isset( $taxonomies [ 'chosen' ] ) && is_array($taxonomies [ 'chosen' ]) ) {
38-
$taxonomies = $taxonomies [ 'chosen' ];
39-
foreach ( $taxonomies as $taxonomy ) {
40-
$product_tags[ $taxonomy ] = ucfirst( $taxonomy );
41-
}
42-
}
43-
$this->form_fields = array(
44-
'selected' => array(
45-
'title' => __( 'Taxonomies', 'woocommerce-taxonomy-report' ),
46-
'type' => 'multiselect',
47-
'description' => __( 'Pick multiple taxonomies with ctrl key', 'woocommerce-taxonomy-report' ),
48-
'options' => $product_tags,
49-
),
50-
'chosen' => array(
51-
'title' => __( 'Create new Taxonomies for WooCommerce', 'woocommerce-taxonomy-report' ),
52-
'type' => 'multiselect',
53-
'description' => __( 'Pick multiple taxonomies with ctrl key', 'woocommerce-taxonomy-report' ),
54-
'options' => array( 'brand' => __( 'Brands', 'woocommerce-taxonomy-report' ), 'vendor' => __( 'Vendors', 'woocommerce-taxonomy-report' ) ),
55-
),
56-
);
24+
/**
25+
* Initialize integration settings form fields.
26+
*/
27+
public function init_form_fields() {
28+
$taxonomies = get_object_taxonomies( 'product', 'objects' );
29+
unset( $taxonomies[ 'product_shipping_class' ] );
30+
unset( $taxonomies[ 'product_type' ] );
31+
unset( $taxonomies[ 'pa_color' ] );
32+
$product_tags = array();
33+
foreach ( $taxonomies as $taxonomy ) {
34+
$product_tags[ $taxonomy->query_var ] = $taxonomy->label;
35+
}
36+
$taxonomies = get_option( 'woocommerce_taxonomy-report_settings', null );
37+
if ( isset( $taxonomies [ 'chosen' ] ) && is_array( $taxonomies [ 'chosen' ] ) ) {
38+
$taxonomies = $taxonomies [ 'chosen' ];
39+
foreach ( $taxonomies as $taxonomy ) {
40+
$product_tags[ $taxonomy ] = ucfirst( $taxonomy );
5741
}
42+
}
43+
$this->form_fields = array(
44+
'selected' => array(
45+
'title' => __( 'Taxonomies', 'woocommerce-taxonomy-report' ),
46+
'type' => 'multiselect',
47+
'description' => __( 'Pick multiple taxonomies with ctrl key', 'woocommerce-taxonomy-report' ),
48+
'options' => $product_tags,
49+
),
50+
'chosen' => array(
51+
'title' => __( 'Create new Taxonomies for WooCommerce', 'woocommerce-taxonomy-report' ),
52+
'type' => 'multiselect',
53+
'description' => __( 'Pick multiple taxonomies with ctrl key', 'woocommerce-taxonomy-report' ),
54+
'options' => array(
55+
'brand' => __( 'Brands', 'woocommerce-taxonomy-report' ), 'vendor' => __( 'Vendors', 'woocommerce-taxonomy-report' ),
56+
'artist' => __( 'Artist', 'woocommerce-taxonomy-report' ), 'author' => __( 'Author', 'woocommerce-taxonomy-report' ),
57+
'state' => __( 'State', 'woocommerce-taxonomy-report' ), 'city' => __( 'City', 'woocommerce-taxonomy-report' )
58+
),
59+
),
60+
);
61+
}
5862

59-
/**
60-
* Wait the loading of initialization of wWooCommerce taxonomies
61-
*/
62-
public function load_taxonomies_by_wc() {
63-
// Load the settings.
64-
$this->init_form_fields();
65-
$this->init_settings();
66-
}
63+
/**
64+
* Wait the loading of initialization of wWooCommerce taxonomies
65+
*/
66+
public function load_taxonomies_by_wc() {
67+
// Load the settings.
68+
$this->init_form_fields();
69+
$this->init_settings();
70+
}
6771

68-
/**
69-
* Add Taxonomy reports to WC reports
70-
* @param arr $reports Existing reports
71-
* @return arr Modified reports
72-
*/
73-
public static function add_reports( $reports ) {
74-
if ( current_user_can( 'manage_options' ) ) {
75-
//get_option of WC_settings class not work with static method required for the reports part
76-
$taxonomies = get_option( 'woocommerce_taxonomy-report_settings', null );
77-
if ( isset( $taxonomies [ 'selected' ] ) ) {
78-
$taxonomies = $taxonomies [ 'selected' ];
79-
foreach ( $taxonomies as $taxonomy ) {
80-
$name = get_taxonomy( $taxonomy );
81-
$name = $name->label;
82-
$reports[ $taxonomy ] = array(
83-
'title' => $name,
84-
'reports' => array(
85-
"sales_by_" . $taxonomy => array(
86-
'title' => __( $name, 'woocommerce-taxonomy-report' ) . ' ' . __( 'Total', 'woocommerce-taxonomy-report' ),
87-
'description' => '',
88-
'hide_title' => true,
89-
'callback' => array( __CLASS__, 'get_report' )
90-
),
91-
"sales_subtotal_by_" . $taxonomy => array(
92-
'title' => __( $name, 'woocommerce-taxonomy-report' ) . ' ' . __( 'SubTotal', 'woocommerce-taxonomy-report' ),
93-
'description' => '',
94-
'hide_title' => true,
95-
'callback' => array( __CLASS__, 'get_report_subtotal' )
96-
)
97-
)
98-
);
99-
}
100-
}
101-
}
102-
return $reports;
72+
/**
73+
* Add Taxonomy reports to WC reports
74+
* @param arr $reports Existing reports
75+
* @return arr Modified reports
76+
*/
77+
public static function add_reports( $reports ) {
78+
if ( current_user_can( 'manage_options' ) ) {
79+
//get_option of WC_settings class not work with static method required for the reports part
80+
$taxonomies = get_option( 'woocommerce_taxonomy-report_settings', null );
81+
if ( isset( $taxonomies [ 'selected' ] ) ) {
82+
$taxonomies = $taxonomies [ 'selected' ];
83+
foreach ( $taxonomies as $taxonomy ) {
84+
$name = get_taxonomy( $taxonomy );
85+
$name = $name->label;
86+
$reports[ $taxonomy ] = array(
87+
'title' => $name,
88+
'reports' => array(
89+
"sales_by_" . $taxonomy => array(
90+
'title' => __( $name, 'woocommerce-taxonomy-report' ) . ' ' . __( 'Total', 'woocommerce-taxonomy-report' ),
91+
'description' => '',
92+
'hide_title' => true,
93+
'callback' => array( __CLASS__, 'get_report' )
94+
),
95+
"sales_subtotal_by_" . $taxonomy => array(
96+
'title' => __( $name, 'woocommerce-taxonomy-report' ) . ' ' . __( 'SubTotal', 'woocommerce-taxonomy-report' ),
97+
'description' => '',
98+
'hide_title' => true,
99+
'callback' => array( __CLASS__, 'get_report_subtotal' )
100+
)
101+
)
102+
);
103+
}
103104
}
105+
}
106+
return $reports;
107+
}
104108

105-
public static function get_report( $name ) {
106-
require_once( plugin_dir_path( __FILE__ ) . 'WC_Report_Sales_By_TReport.php' );
107-
$name = str_replace( 'sales_by_', '', $name );
108-
new WC_Report_Sales_By_TReport( $name );
109-
}
109+
public static function get_report( $name ) {
110+
require_once( plugin_dir_path( __FILE__ ) . 'WC_Report_Sales_By_TReport.php' );
111+
$name = str_replace( 'sales_by_', '', $name );
112+
new WC_Report_Sales_By_TReport( $name );
113+
}
110114

111-
public static function get_report_subtotal( $name ) {
112-
require_once( plugin_dir_path( __FILE__ ) . 'WC_Report_Sales_By_TReport.php' );
113-
$name = str_replace( 'sales_subtotal_by_', '', $name );
114-
new WC_Report_Sales_By_TReport( $name, '_line_subtotal' );
115-
}
115+
public static function get_report_subtotal( $name ) {
116+
require_once( plugin_dir_path( __FILE__ ) . 'WC_Report_Sales_By_TReport.php' );
117+
$name = str_replace( 'sales_subtotal_by_', '', $name );
118+
new WC_Report_Sales_By_TReport( $name, '_line_subtotal' );
119+
}
116120

117121
}

includes/load_textdomain.php

-17
This file was deleted.

languages/index.php

-1
This file was deleted.
-1.37 KB
Binary file not shown.

languages/woocommerce-taxonomy-report-it_IT.po

-62
This file was deleted.

languages/woocommerce-taxonomy-report.pot

-61
This file was deleted.

0 commit comments

Comments
 (0)