Passed
Push — master ( 33e35d...452cb5 )
by Brian
08:43 queued 04:21
created
includes/admin/class-wpinv-items-report-table.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if ( ! defined( 'ABSPATH' ) ) {
9
+    exit;
10
+}
9 11
 
10 12
 // Load WP_List_Table if not loaded
11 13
 if ( ! class_exists( 'WP_List_Table' ) ) {
Please login to merge, or discard this patch.
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,129 +21,129 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Items_Report_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'item';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'item'     => __( 'Item', 'invoicing' ),
84
-			'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
88
-		);
89
-
90
-	}
91
-
92
-	/**
93
-	 * Retrieve the current page number
94
-	 *
95
-	 * @since 1.0.19
96
-	 * @return int Current page number
97
-	 */
98
-	public function get_paged() {
99
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
-	}
101
-
102
-	/**
103
-	 * Outputs the reporting views
104
-	 *
105
-	 * @since 1.0.19
106
-	 * @return void
107
-	 */
108
-	public function bulk_actions( $which = '' ) {
109
-		return array();
110
-	}
111
-
112
-	/**
113
-	 * Build all the reports data
114
-	 *
115
-	 * @since 1.0.19
116
-	 * @return array $reports_data All the data for gateway reports
117
-	 */
118
-	public function reports_data() {
119
-
120
-		$reports_data = $this->revenue_reports_data();
121
-
122
-		$prepared = array();
123
-		foreach ( $reports_data as $report_data ) {
124
-			$prepared[] = array(
125
-				'item'     => $report_data['item_name'],
126
-				'sales'    => $report_data['sales'],
127
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
130
-			);
131
-		}
132
-
133
-		return $prepared;
134
-	}
135
-
136
-	/**
137
-	 * Retrieves report data.
138
-	 *
139
-	 * @since 1.0.19
140
-	 */
141
-	public function revenue_reports_data() {
142
-		global $wpdb;
143
-
144
-		$table =  $wpdb->prefix . 'getpaid_invoice_items';
145
-		return $wpdb->get_results(
146
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'item';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'item'     => __( 'Item', 'invoicing' ),
84
+            'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
+            'total'    => __( 'Total Earnings', 'invoicing' ),
86
+            'discount' => __( 'Total Discounts', 'invoicing' ),
87
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
88
+        );
89
+
90
+    }
91
+
92
+    /**
93
+     * Retrieve the current page number
94
+     *
95
+     * @since 1.0.19
96
+     * @return int Current page number
97
+     */
98
+    public function get_paged() {
99
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
100
+    }
101
+
102
+    /**
103
+     * Outputs the reporting views
104
+     *
105
+     * @since 1.0.19
106
+     * @return void
107
+     */
108
+    public function bulk_actions( $which = '' ) {
109
+        return array();
110
+    }
111
+
112
+    /**
113
+     * Build all the reports data
114
+     *
115
+     * @since 1.0.19
116
+     * @return array $reports_data All the data for gateway reports
117
+     */
118
+    public function reports_data() {
119
+
120
+        $reports_data = $this->revenue_reports_data();
121
+
122
+        $prepared = array();
123
+        foreach ( $reports_data as $report_data ) {
124
+            $prepared[] = array(
125
+                'item'     => $report_data['item_name'],
126
+                'sales'    => $report_data['sales'],
127
+                'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
+                'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
+                'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
130
+            );
131
+        }
132
+
133
+        return $prepared;
134
+    }
135
+
136
+    /**
137
+     * Retrieves report data.
138
+     *
139
+     * @since 1.0.19
140
+     */
141
+    public function revenue_reports_data() {
142
+        global $wpdb;
143
+
144
+        $table =  $wpdb->prefix . 'getpaid_invoice_items';
145
+        return $wpdb->get_results(
146
+            "SELECT
147 147
 				SUM(quantity) as sales,
148 148
 				item_name,
149 149
 				SUM(tax) as tax,
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 			GROUP BY item_id
158 158
 			ORDER BY item_name ASC", ARRAY_A);
159 159
 
160
-	}
161
-
162
-	/**
163
-	 * Setup the final data for the table
164
-	 *
165
-	 * @since 1.0.19
166
-	 * @return void
167
-	 */
168
-	public function prepare_items() {
169
-		$columns               = $this->get_columns();
170
-		$hidden                = array(); // No hidden columns
171
-		$sortable              = $this->get_sortable_columns();
172
-		$this->_column_headers = array( $columns, $hidden, $sortable );
173
-		$this->items           = $this->reports_data();
174
-	}
160
+    }
161
+
162
+    /**
163
+     * Setup the final data for the table
164
+     *
165
+     * @since 1.0.19
166
+     * @return void
167
+     */
168
+    public function prepare_items() {
169
+        $columns               = $this->get_columns();
170
+        $hidden                = array(); // No hidden columns
171
+        $sortable              = $this->get_sortable_columns();
172
+        $this->_column_headers = array( $columns, $hidden, $sortable );
173
+        $this->items           = $this->reports_data();
174
+    }
175 175
 }
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	public function __construct() {
38 38
 
39 39
 		// Set parent defaults
40
-		parent::__construct( array(
40
+		parent::__construct(array(
41 41
 			'singular' => 'id',
42 42
 			'plural'   => 'ids',
43 43
 			'ajax'     => false,
44
-		) );
44
+		));
45 45
 
46 46
 	}
47 47
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string Column Name
69 69
 	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
70
+	public function column_default($item, $column_name) {
71
+		return wp_kses_post($item[$column_name]);
72 72
 	}
73 73
 
74 74
 	/**
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 	public function get_columns() {
81 81
 
82 82
 		return array(
83
-			'item'     => __( 'Item', 'invoicing' ),
84
-			'sales'    => __( 'Quantity Sold', 'invoicing' ),
85
-			'total'    => __( 'Total Earnings', 'invoicing' ),
86
-			'discount' => __( 'Total Discounts', 'invoicing' ),
87
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
83
+			'item'     => __('Item', 'invoicing'),
84
+			'sales'    => __('Quantity Sold', 'invoicing'),
85
+			'total'    => __('Total Earnings', 'invoicing'),
86
+			'discount' => __('Total Discounts', 'invoicing'),
87
+			'tax'      => __('Total Taxes', 'invoicing'),
88 88
 		);
89 89
 
90 90
 	}
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 * @return int Current page number
97 97
 	 */
98 98
 	public function get_paged() {
99
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
99
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @since 1.0.19
106 106
 	 * @return void
107 107
 	 */
108
-	public function bulk_actions( $which = '' ) {
108
+	public function bulk_actions($which = '') {
109 109
 		return array();
110 110
 	}
111 111
 
@@ -120,13 +120,13 @@  discard block
 block discarded – undo
120 120
 		$reports_data = $this->revenue_reports_data();
121 121
 
122 122
 		$prepared = array();
123
-		foreach ( $reports_data as $report_data ) {
123
+		foreach ($reports_data as $report_data) {
124 124
 			$prepared[] = array(
125 125
 				'item'     => $report_data['item_name'],
126 126
 				'sales'    => $report_data['sales'],
127
-				'total'    => wpinv_price( wpinv_format_amount( $report_data['total'] ) ),
128
-				'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ),
129
-				'tax'      => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ),
127
+				'total'    => wpinv_price(wpinv_format_amount($report_data['total'])),
128
+				'discount' => wpinv_price(wpinv_format_amount($report_data['discount'])),
129
+				'tax'      => wpinv_price(wpinv_format_amount($report_data['tax'])),
130 130
 			);
131 131
 		}
132 132
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function revenue_reports_data() {
142 142
 		global $wpdb;
143 143
 
144
-		$table =  $wpdb->prefix . 'getpaid_invoice_items';
144
+		$table = $wpdb->prefix . 'getpaid_invoice_items';
145 145
 		return $wpdb->get_results(
146 146
 			"SELECT
147 147
 				SUM(quantity) as sales,
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		$columns               = $this->get_columns();
170 170
 		$hidden                = array(); // No hidden columns
171 171
 		$sortable              = $this->get_sortable_columns();
172
-		$this->_column_headers = array( $columns, $hidden, $sortable );
172
+		$this->_column_headers = array($columns, $hidden, $sortable);
173 173
 		$this->items           = $this->reports_data();
174 174
 	}
175 175
 }
Please login to merge, or discard this patch.
includes/admin/class-wpinv-taxes-report-table.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if ( ! defined( 'ABSPATH' ) ) {
9
+    exit;
10
+}
9 11
 
10 12
 // Load WP_List_Table if not loaded
11 13
 if ( ! class_exists( 'WP_List_Table' ) ) {
Please login to merge, or discard this patch.
Indentation   +157 added lines, -157 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
 
10 10
 // Load WP_List_Table if not loaded
11 11
 if ( ! class_exists( 'WP_List_Table' ) ) {
12
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
15 15
 /**
@@ -21,145 +21,145 @@  discard block
 block discarded – undo
21 21
  */
22 22
 class WPInv_Taxes_Reports_Table extends WP_List_Table {
23 23
 
24
-	/**
25
-	 * @var int Number of items per page
26
-	 * @since 1.0.19
27
-	 */
28
-	public $per_page = 300;
29
-
30
-
31
-	/**
32
-	 * Get things started
33
-	 *
34
-	 * @since 1.0.19
35
-	 * @see WP_List_Table::__construct()
36
-	 */
37
-	public function __construct() {
38
-
39
-		// Set parent defaults
40
-		parent::__construct( array(
41
-			'singular' => 'id',
42
-			'plural'   => 'ids',
43
-			'ajax'     => false,
44
-		) );
45
-
46
-	}
47
-
48
-	/**
49
-	 * Gets the name of the primary column.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @access protected
53
-	 *
54
-	 * @return string Name of the primary column.
55
-	 */
56
-	protected function get_primary_column_name() {
57
-		return 'month';
58
-	}
59
-
60
-	/**
61
-	 * This function renders most of the columns in the list table.
62
-	 *
63
-	 * @since 1.0.19
64
-	 *
65
-	 * @param array $item Contains all the data of the gateways
66
-	 * @param string $column_name The name of the column
67
-	 *
68
-	 * @return string Column Name
69
-	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
72
-	}
73
-
74
-	/**
75
-	 * Retrieve the table columns
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @return array $columns Array of all the list table columns
79
-	 */
80
-	public function get_columns() {
81
-
82
-		return array(
83
-			'month'    => __( 'Month', 'invoicing' ),
84
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
85
-		);
86
-
87
-	}
88
-
89
-	/**
90
-	 * Retrieve the current page number
91
-	 *
92
-	 * @since 1.0.19
93
-	 * @return int Current page number
94
-	 */
95
-	public function get_paged() {
96
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
97
-	}
98
-
99
-	/**
100
-	 * Outputs the reporting views
101
-	 *
102
-	 * @since 1.0.19
103
-	 * @return void
104
-	 */
105
-	public function bulk_actions( $which = '' ) {
106
-		return array();
107
-	}
108
-
109
-	/**
110
-	 * Build all the reports data
111
-	 *
112
-	 * @since 1.0.19
113
-	 * @return array $reports_data All the data for taxes reports
114
-	 */
115
-	public function reports_data() {
116
-
117
-		$reports_data = $this->taxes_reports_data();
118
-		$months       = array(
119
-			'1' => __( 'January', 'invoicing' ),
120
-			'2' => __( 'February', 'invoicing' ),
121
-			'3' => __( 'March', 'invoicing' ),
122
-			'4' => __( 'April', 'invoicing' ),
123
-			'5' => __( 'May', 'invoicing' ),
124
-			'6' => __( 'June', 'invoicing' ),
125
-			'7' => __( 'July', 'invoicing' ),
126
-			'8' => __( 'August', 'invoicing' ),
127
-			'9' => __( 'September', 'invoicing' ),
128
-			'10' => __( 'October', 'invoicing' ),
129
-			'11' => __( 'November', 'invoicing' ),
130
-			'12' => __( 'December', 'invoicing' ),
131
-		);
132
-
133
-		$prepared = array();
134
-		foreach ( $months as $month => $label ) {
135
-
136
-			$tax = wpinv_price( 0 );
137
-			if ( ! empty( $reports_data[ $month ] ) ) {
138
-				$tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
139
-			}
140
-
141
-			$prepared[] = array(
142
-				'month'    => $label,
143
-				'tax'      => $tax,
144
-			);
145
-
146
-		}
147
-
148
-		return $prepared;
149
-	}
150
-
151
-	/**
152
-	 * Retrieves taxes data.
153
-	 *
154
-	 * @since 1.0.19
155
-	 */
156
-	public function taxes_reports_data() {
157
-		global $wpdb;
158
-
159
-		$table =  $wpdb->prefix . 'getpaid_invoices';
160
-		$year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
161
-		$data  = $wpdb->get_results(
162
-			"SELECT
24
+    /**
25
+     * @var int Number of items per page
26
+     * @since 1.0.19
27
+     */
28
+    public $per_page = 300;
29
+
30
+
31
+    /**
32
+     * Get things started
33
+     *
34
+     * @since 1.0.19
35
+     * @see WP_List_Table::__construct()
36
+     */
37
+    public function __construct() {
38
+
39
+        // Set parent defaults
40
+        parent::__construct( array(
41
+            'singular' => 'id',
42
+            'plural'   => 'ids',
43
+            'ajax'     => false,
44
+        ) );
45
+
46
+    }
47
+
48
+    /**
49
+     * Gets the name of the primary column.
50
+     *
51
+     * @since 1.0.19
52
+     * @access protected
53
+     *
54
+     * @return string Name of the primary column.
55
+     */
56
+    protected function get_primary_column_name() {
57
+        return 'month';
58
+    }
59
+
60
+    /**
61
+     * This function renders most of the columns in the list table.
62
+     *
63
+     * @since 1.0.19
64
+     *
65
+     * @param array $item Contains all the data of the gateways
66
+     * @param string $column_name The name of the column
67
+     *
68
+     * @return string Column Name
69
+     */
70
+    public function column_default( $item, $column_name ) {
71
+        return wp_kses_post( $item[ $column_name ] );
72
+    }
73
+
74
+    /**
75
+     * Retrieve the table columns
76
+     *
77
+     * @since 1.0.19
78
+     * @return array $columns Array of all the list table columns
79
+     */
80
+    public function get_columns() {
81
+
82
+        return array(
83
+            'month'    => __( 'Month', 'invoicing' ),
84
+            'tax'      => __( 'Total Taxes', 'invoicing' ),
85
+        );
86
+
87
+    }
88
+
89
+    /**
90
+     * Retrieve the current page number
91
+     *
92
+     * @since 1.0.19
93
+     * @return int Current page number
94
+     */
95
+    public function get_paged() {
96
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
97
+    }
98
+
99
+    /**
100
+     * Outputs the reporting views
101
+     *
102
+     * @since 1.0.19
103
+     * @return void
104
+     */
105
+    public function bulk_actions( $which = '' ) {
106
+        return array();
107
+    }
108
+
109
+    /**
110
+     * Build all the reports data
111
+     *
112
+     * @since 1.0.19
113
+     * @return array $reports_data All the data for taxes reports
114
+     */
115
+    public function reports_data() {
116
+
117
+        $reports_data = $this->taxes_reports_data();
118
+        $months       = array(
119
+            '1' => __( 'January', 'invoicing' ),
120
+            '2' => __( 'February', 'invoicing' ),
121
+            '3' => __( 'March', 'invoicing' ),
122
+            '4' => __( 'April', 'invoicing' ),
123
+            '5' => __( 'May', 'invoicing' ),
124
+            '6' => __( 'June', 'invoicing' ),
125
+            '7' => __( 'July', 'invoicing' ),
126
+            '8' => __( 'August', 'invoicing' ),
127
+            '9' => __( 'September', 'invoicing' ),
128
+            '10' => __( 'October', 'invoicing' ),
129
+            '11' => __( 'November', 'invoicing' ),
130
+            '12' => __( 'December', 'invoicing' ),
131
+        );
132
+
133
+        $prepared = array();
134
+        foreach ( $months as $month => $label ) {
135
+
136
+            $tax = wpinv_price( 0 );
137
+            if ( ! empty( $reports_data[ $month ] ) ) {
138
+                $tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
139
+            }
140
+
141
+            $prepared[] = array(
142
+                'month'    => $label,
143
+                'tax'      => $tax,
144
+            );
145
+
146
+        }
147
+
148
+        return $prepared;
149
+    }
150
+
151
+    /**
152
+     * Retrieves taxes data.
153
+     *
154
+     * @since 1.0.19
155
+     */
156
+    public function taxes_reports_data() {
157
+        global $wpdb;
158
+
159
+        $table =  $wpdb->prefix . 'getpaid_invoices';
160
+        $year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
161
+        $data  = $wpdb->get_results(
162
+            "SELECT
163 163
 				MONTH(meta.completed_date) as _month,
164 164
 				SUM(meta.tax) as tax
165 165
 			FROM $wpdb->posts as posts
@@ -171,21 +171,21 @@  discard block
 block discarded – undo
171 171
 				AND ( YEAR(meta.completed_date) = '$year' )
172 172
 			GROUP BY MONTH(meta.completed_date)");
173 173
 
174
-		return wp_list_pluck( $data, 'tax', '_month' );
175
-
176
-	}
177
-
178
-	/**
179
-	 * Setup the final data for the table
180
-	 *
181
-	 * @since 1.0.19
182
-	 * @return void
183
-	 */
184
-	public function prepare_items() {
185
-		$columns               = $this->get_columns();
186
-		$hidden                = array(); // No hidden columns
187
-		$sortable              = $this->get_sortable_columns();
188
-		$this->_column_headers = array( $columns, $hidden, $sortable );
189
-		$this->items           = $this->reports_data();
190
-	}
174
+        return wp_list_pluck( $data, 'tax', '_month' );
175
+
176
+    }
177
+
178
+    /**
179
+     * Setup the final data for the table
180
+     *
181
+     * @since 1.0.19
182
+     * @return void
183
+     */
184
+    public function prepare_items() {
185
+        $columns               = $this->get_columns();
186
+        $hidden                = array(); // No hidden columns
187
+        $sortable              = $this->get_sortable_columns();
188
+        $this->_column_headers = array( $columns, $hidden, $sortable );
189
+        $this->items           = $this->reports_data();
190
+    }
191 191
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 // Exit if accessed directly
8
-if ( ! defined( 'ABSPATH' ) ) exit;
8
+if (!defined('ABSPATH')) exit;
9 9
 
10 10
 // Load WP_List_Table if not loaded
11
-if ( ! class_exists( 'WP_List_Table' ) ) {
11
+if (!class_exists('WP_List_Table')) {
12 12
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
13 13
 }
14 14
 
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	public function __construct() {
38 38
 
39 39
 		// Set parent defaults
40
-		parent::__construct( array(
40
+		parent::__construct(array(
41 41
 			'singular' => 'id',
42 42
 			'plural'   => 'ids',
43 43
 			'ajax'     => false,
44
-		) );
44
+		));
45 45
 
46 46
 	}
47 47
 
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 	 *
68 68
 	 * @return string Column Name
69 69
 	 */
70
-	public function column_default( $item, $column_name ) {
71
-		return wp_kses_post( $item[ $column_name ] );
70
+	public function column_default($item, $column_name) {
71
+		return wp_kses_post($item[$column_name]);
72 72
 	}
73 73
 
74 74
 	/**
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
 	public function get_columns() {
81 81
 
82 82
 		return array(
83
-			'month'    => __( 'Month', 'invoicing' ),
84
-			'tax'      => __( 'Total Taxes', 'invoicing' ),
83
+			'month'    => __('Month', 'invoicing'),
84
+			'tax'      => __('Total Taxes', 'invoicing'),
85 85
 		);
86 86
 
87 87
 	}
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @return int Current page number
94 94
 	 */
95 95
 	public function get_paged() {
96
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
96
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
97 97
 	}
98 98
 
99 99
 	/**
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
 	 * @since 1.0.19
103 103
 	 * @return void
104 104
 	 */
105
-	public function bulk_actions( $which = '' ) {
105
+	public function bulk_actions($which = '') {
106 106
 		return array();
107 107
 	}
108 108
 
@@ -116,26 +116,26 @@  discard block
 block discarded – undo
116 116
 
117 117
 		$reports_data = $this->taxes_reports_data();
118 118
 		$months       = array(
119
-			'1' => __( 'January', 'invoicing' ),
120
-			'2' => __( 'February', 'invoicing' ),
121
-			'3' => __( 'March', 'invoicing' ),
122
-			'4' => __( 'April', 'invoicing' ),
123
-			'5' => __( 'May', 'invoicing' ),
124
-			'6' => __( 'June', 'invoicing' ),
125
-			'7' => __( 'July', 'invoicing' ),
126
-			'8' => __( 'August', 'invoicing' ),
127
-			'9' => __( 'September', 'invoicing' ),
128
-			'10' => __( 'October', 'invoicing' ),
129
-			'11' => __( 'November', 'invoicing' ),
130
-			'12' => __( 'December', 'invoicing' ),
119
+			'1' => __('January', 'invoicing'),
120
+			'2' => __('February', 'invoicing'),
121
+			'3' => __('March', 'invoicing'),
122
+			'4' => __('April', 'invoicing'),
123
+			'5' => __('May', 'invoicing'),
124
+			'6' => __('June', 'invoicing'),
125
+			'7' => __('July', 'invoicing'),
126
+			'8' => __('August', 'invoicing'),
127
+			'9' => __('September', 'invoicing'),
128
+			'10' => __('October', 'invoicing'),
129
+			'11' => __('November', 'invoicing'),
130
+			'12' => __('December', 'invoicing'),
131 131
 		);
132 132
 
133 133
 		$prepared = array();
134
-		foreach ( $months as $month => $label ) {
134
+		foreach ($months as $month => $label) {
135 135
 
136
-			$tax = wpinv_price( 0 );
137
-			if ( ! empty( $reports_data[ $month ] ) ) {
138
-				$tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) );
136
+			$tax = wpinv_price(0);
137
+			if (!empty($reports_data[$month])) {
138
+				$tax = wpinv_price(wpinv_format_amount($reports_data[$month]));
139 139
 			}
140 140
 
141 141
 			$prepared[] = array(
@@ -156,8 +156,8 @@  discard block
 block discarded – undo
156 156
 	public function taxes_reports_data() {
157 157
 		global $wpdb;
158 158
 
159
-		$table =  $wpdb->prefix . 'getpaid_invoices';
160
-		$year  = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' );
159
+		$table = $wpdb->prefix . 'getpaid_invoices';
160
+		$year  = isset($_GET['year']) ? absint($_GET['year']) : date('Y');
161 161
 		$data  = $wpdb->get_results(
162 162
 			"SELECT
163 163
 				MONTH(meta.completed_date) as _month,
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 				AND ( YEAR(meta.completed_date) = '$year' )
172 172
 			GROUP BY MONTH(meta.completed_date)");
173 173
 
174
-		return wp_list_pluck( $data, 'tax', '_month' );
174
+		return wp_list_pluck($data, 'tax', '_month');
175 175
 
176 176
 	}
177 177
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		$columns               = $this->get_columns();
186 186
 		$hidden                = array(); // No hidden columns
187 187
 		$sortable              = $this->get_sortable_columns();
188
-		$this->_column_headers = array( $columns, $hidden, $sortable );
188
+		$this->_column_headers = array($columns, $hidden, $sortable);
189 189
 		$this->items           = $this->reports_data();
190 190
 	}
191 191
 }
Please login to merge, or discard this patch.
includes/class-wpinv-session-handler.php 2 patches
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Session handler class.
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function __construct() {
54 54
 
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56
-        add_action( 'init', array( $this, 'init' ), -1 );
57
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
55
+	    $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH);
56
+        add_action('init', array($this, 'init'), -1);
57
+		add_action('wp_logout', array($this, 'destroy_session'));
58
+		add_action('wp', array($this, 'set_customer_session_cookie'), 10);
59
+		add_action('shutdown', array($this, 'save_data'), 20);
60 60
 
61 61
 	}
62 62
 
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
 	public function init() {
69 69
 		$this->init_session_cookie();
70 70
 
71
-		if ( ! is_user_logged_in() ) {
72
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
71
+		if (!is_user_logged_in()) {
72
+			add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'));
73 73
 		}
74 74
 	}
75 75
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	public function init_session_cookie() {
82 82
 		$cookie = $this->get_session_cookie();
83 83
 
84
-		if ( $cookie ) {
84
+		if ($cookie) {
85 85
 			$this->_customer_id        = $cookie[0];
86 86
 			$this->_session_expiration = $cookie[1];
87 87
 			$this->_session_expiring   = $cookie[2];
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 			$this->_data               = $this->get_session_data();
90 90
 
91 91
 			// If the user logs in, update session.
92
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
92
+			if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) {
93 93
 				$this->_customer_id = get_current_user_id();
94 94
 				$this->_dirty       = true;
95 95
 				$this->save_data();
96
-				$this->set_customer_session_cookie( true );
96
+				$this->set_customer_session_cookie(true);
97 97
 			}
98 98
 
99 99
 			// Update session if its close to expiring.
100
-			if ( time() > $this->_session_expiring ) {
100
+			if (time() > $this->_session_expiring) {
101 101
 				$this->set_session_expiration();
102
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
102
+				$this->update_session_timestamp($this->_customer_id, $this->_session_expiration);
103 103
 			}
104 104
 		} else {
105 105
 			$this->set_session_expiration();
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param bool $set Should the session cookie be set.
119 119
 	 */
120
-	public function set_customer_session_cookie( $set ) {
121
-		if ( $set ) {
120
+	public function set_customer_session_cookie($set) {
121
+		if ($set) {
122 122
 			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
123
+			$cookie_hash       = hash_hmac('md5', $to_hash, wp_hash($to_hash));
124 124
 			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125 125
 			$this->_has_cookie = true;
126 126
 
127
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
127
+			if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) {
128
+				$this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true);
129 129
 			}
130 130
 		}
131 131
 	}
132 132
 
133
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134
-        if ( ! headers_sent() ) {
135
-            setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
136
-        } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
137
-            headers_sent( $file, $line );
138
-            trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
133
+	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) {
134
+        if (!headers_sent()) {
135
+            setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure));
136
+        } elseif (defined('WP_DEBUG') && WP_DEBUG) {
137
+            headers_sent($file, $line);
138
+            trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine
139 139
         }
140 140
     }
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @return bool
147 147
 	 */
148 148
 	protected function use_secure_cookie() {
149
-        $is_https = false !== strstr( get_option( 'home' ), 'https:' );
150
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
149
+        $is_https = false !== strstr(get_option('home'), 'https:');
150
+		return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl());
151 151
 	}
152 152
 
153 153
 	/**
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 	 * @return bool
157 157
 	 */
158 158
 	public function has_session() {
159
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
159
+		return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160 160
 	}
161 161
 
162 162
 	/**
163 163
 	 * Set session expiration.
164 164
 	 */
165 165
 	public function set_session_expiration() {
166
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
166
+		$this->_session_expiring   = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours.
167
+		$this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours.
168 168
 	}
169 169
 
170 170
 	/**
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 */
175 175
 	public function generate_customer_id() {
176 176
 		require_once ABSPATH . 'wp-includes/class-phpass.php';
177
-		$hasher      = new PasswordHash( 8, false );
178
-		return md5( $hasher->get_random_bytes( 32 ) );
177
+		$hasher = new PasswordHash(8, false);
178
+		return md5($hasher->get_random_bytes(32));
179 179
 	}
180 180
 
181 181
 	/**
@@ -186,27 +186,27 @@  discard block
 block discarded – undo
186 186
 	 * @return bool|array
187 187
 	 */
188 188
 	public function get_session_cookie() {
189
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
189
+		$cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine.
190 190
 
191
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
191
+		if (empty($cookie_value) || !is_string($cookie_value)) {
192 192
 			return false;
193 193
 		}
194 194
 
195
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
195
+		list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
196 196
 
197
-		if ( empty( $customer_id ) ) {
197
+		if (empty($customer_id)) {
198 198
 			return false;
199 199
 		}
200 200
 
201 201
 		// Validate hash.
202 202
 		$to_hash = $customer_id . '|' . $session_expiration;
203
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
203
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
204 204
 
205
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
205
+		if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) {
206 206
 			return false;
207 207
 		}
208 208
 
209
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
209
+		return array($customer_id, $session_expiration, $session_expiring, $cookie_hash);
210 210
 	}
211 211
 
212 212
 	/**
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 	 * @return array
216 216
 	 */
217 217
 	public function get_session_data() {
218
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
218
+		return $this->has_session() ? (array) $this->get_session($this->_customer_id) : array();
219 219
 	}
220 220
 
221
-	public function generate_key($customer_id){
222
-        if(!$customer_id){
221
+	public function generate_key($customer_id) {
222
+        if (!$customer_id) {
223 223
             return;
224 224
         }
225 225
 
226
-        return 'wpi_trans_'.$customer_id;
226
+        return 'wpi_trans_' . $customer_id;
227 227
     }
228 228
 
229 229
 	/**
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
 	 */
232 232
 	public function save_data() {
233 233
 		// Dirty if something changed - prevents saving nothing new.
234
-		if ( $this->_dirty && $this->has_session() ) {
234
+		if ($this->_dirty && $this->has_session()) {
235 235
 
236
-            set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
236
+            set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
237 237
 
238 238
 			$this->_dirty = false;
239 239
 		}
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * Destroy all session data.
244 244
 	 */
245 245
 	public function destroy_session() {
246
-		$this->delete_session( $this->_customer_id );
246
+		$this->delete_session($this->_customer_id);
247 247
 		$this->forget_session();
248 248
 	}
249 249
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
 	 * Forget all session data without destroying it.
252 252
 	 */
253 253
 	public function forget_session() {
254
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
254
+		$this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true);
255 255
 
256 256
 		wpinv_empty_cart();
257 257
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	 * @param int $uid User ID.
267 267
 	 * @return string
268 268
 	 */
269
-	public function nonce_user_logged_out( $uid ) {
269
+	public function nonce_user_logged_out($uid) {
270 270
 		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
271 271
 	}
272 272
 
@@ -277,20 +277,20 @@  discard block
 block discarded – undo
277 277
 	 * @param mixed  $default Default session value.
278 278
 	 * @return string|array
279 279
 	 */
280
-	public function get_session( $customer_id, $default = false ) {
280
+	public function get_session($customer_id, $default = false) {
281 281
 
282
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
282
+		if (defined('WP_SETUP_CONFIG')) {
283 283
 			return array();
284 284
 		}
285 285
 
286 286
         $key = $this->generate_key($customer_id);
287 287
         $value = get_transient($key);
288 288
 
289
-        if ( !$value ) {
289
+        if (!$value) {
290 290
             $value = $default;
291 291
         }
292 292
 
293
-		return maybe_unserialize( $value );
293
+		return maybe_unserialize($value);
294 294
 	}
295 295
 
296 296
 	/**
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	 *
299 299
 	 * @param int $customer_id Customer ID.
300 300
 	 */
301
-	public function delete_session( $customer_id ) {
301
+	public function delete_session($customer_id) {
302 302
 
303 303
         $key = $this->generate_key($customer_id);
304 304
 
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 	 * @param string $customer_id Customer ID.
312 312
 	 * @param int    $timestamp Timestamp to expire the cookie.
313 313
 	 */
314
-	public function update_session_timestamp( $customer_id, $timestamp ) {
314
+	public function update_session_timestamp($customer_id, $timestamp) {
315 315
 
316
-        set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
316
+        set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp);
317 317
 
318 318
 	}
319 319
 }
Please login to merge, or discard this patch.
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -12,125 +12,125 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class WPInv_Session_Handler extends WPInv_Session {
14 14
 
15
-	/**
16
-	 * Cookie name used for the session.
17
-	 *
18
-	 * @var string cookie name
19
-	 */
20
-	protected $_cookie;
21
-
22
-	/**
23
-	 * Stores session expiry.
24
-	 *
25
-	 * @var int session due to expire timestamp
26
-	 */
27
-	protected $_session_expiring;
28
-
29
-	/**
30
-	 * Stores session due to expire timestamp.
31
-	 *
32
-	 * @var string session expiration timestamp
33
-	 */
34
-	protected $_session_expiration;
35
-
36
-	/**
37
-	 * True when the cookie exists.
38
-	 *
39
-	 * @var bool Based on whether a cookie exists.
40
-	 */
41
-	protected $_has_cookie = false;
42
-
43
-	/**
44
-	 * Table name for session data.
45
-	 *
46
-	 * @var string Custom session table name
47
-	 */
48
-	protected $_table;
49
-
50
-	/**
51
-	 * Constructor for the session class.
52
-	 */
53
-	public function __construct() {
54
-
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
15
+    /**
16
+     * Cookie name used for the session.
17
+     *
18
+     * @var string cookie name
19
+     */
20
+    protected $_cookie;
21
+
22
+    /**
23
+     * Stores session expiry.
24
+     *
25
+     * @var int session due to expire timestamp
26
+     */
27
+    protected $_session_expiring;
28
+
29
+    /**
30
+     * Stores session due to expire timestamp.
31
+     *
32
+     * @var string session expiration timestamp
33
+     */
34
+    protected $_session_expiration;
35
+
36
+    /**
37
+     * True when the cookie exists.
38
+     *
39
+     * @var bool Based on whether a cookie exists.
40
+     */
41
+    protected $_has_cookie = false;
42
+
43
+    /**
44
+     * Table name for session data.
45
+     *
46
+     * @var string Custom session table name
47
+     */
48
+    protected $_table;
49
+
50
+    /**
51
+     * Constructor for the session class.
52
+     */
53
+    public function __construct() {
54
+
55
+        $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56 56
         add_action( 'init', array( $this, 'init' ), -1 );
57
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
60
-
61
-	}
62
-
63
-	/**
64
-	 * Init hooks and session data.
65
-	 *
66
-	 * @since 3.3.0
67
-	 */
68
-	public function init() {
69
-		$this->init_session_cookie();
70
-
71
-		if ( ! is_user_logged_in() ) {
72
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
73
-		}
74
-	}
75
-
76
-	/**
77
-	 * Setup cookie and customer ID.
78
-	 *
79
-	 * @since 3.6.0
80
-	 */
81
-	public function init_session_cookie() {
82
-		$cookie = $this->get_session_cookie();
83
-
84
-		if ( $cookie ) {
85
-			$this->_customer_id        = $cookie[0];
86
-			$this->_session_expiration = $cookie[1];
87
-			$this->_session_expiring   = $cookie[2];
88
-			$this->_has_cookie         = true;
89
-			$this->_data               = $this->get_session_data();
90
-
91
-			// If the user logs in, update session.
92
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
93
-				$this->_customer_id = get_current_user_id();
94
-				$this->_dirty       = true;
95
-				$this->save_data();
96
-				$this->set_customer_session_cookie( true );
97
-			}
98
-
99
-			// Update session if its close to expiring.
100
-			if ( time() > $this->_session_expiring ) {
101
-				$this->set_session_expiration();
102
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
103
-			}
104
-		} else {
105
-			$this->set_session_expiration();
106
-			$this->_customer_id = $this->generate_customer_id();
107
-			$this->_data        = $this->get_session_data();
108
-		}
109
-	}
110
-
111
-	/**
112
-	 * Sets the session cookie on-demand (usually after adding an item to the cart).
113
-	 *
114
-	 * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
115
-	 *
116
-	 * Warning: Cookies will only be set if this is called before the headers are sent.
117
-	 *
118
-	 * @param bool $set Should the session cookie be set.
119
-	 */
120
-	public function set_customer_session_cookie( $set ) {
121
-		if ( $set ) {
122
-			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
124
-			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125
-			$this->_has_cookie = true;
126
-
127
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
-			}
130
-		}
131
-	}
132
-
133
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
57
+        add_action( 'wp_logout', array( $this, 'destroy_session' ) );
58
+        add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
59
+        add_action( 'shutdown', array( $this, 'save_data' ), 20 );
60
+
61
+    }
62
+
63
+    /**
64
+     * Init hooks and session data.
65
+     *
66
+     * @since 3.3.0
67
+     */
68
+    public function init() {
69
+        $this->init_session_cookie();
70
+
71
+        if ( ! is_user_logged_in() ) {
72
+            add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
73
+        }
74
+    }
75
+
76
+    /**
77
+     * Setup cookie and customer ID.
78
+     *
79
+     * @since 3.6.0
80
+     */
81
+    public function init_session_cookie() {
82
+        $cookie = $this->get_session_cookie();
83
+
84
+        if ( $cookie ) {
85
+            $this->_customer_id        = $cookie[0];
86
+            $this->_session_expiration = $cookie[1];
87
+            $this->_session_expiring   = $cookie[2];
88
+            $this->_has_cookie         = true;
89
+            $this->_data               = $this->get_session_data();
90
+
91
+            // If the user logs in, update session.
92
+            if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
93
+                $this->_customer_id = get_current_user_id();
94
+                $this->_dirty       = true;
95
+                $this->save_data();
96
+                $this->set_customer_session_cookie( true );
97
+            }
98
+
99
+            // Update session if its close to expiring.
100
+            if ( time() > $this->_session_expiring ) {
101
+                $this->set_session_expiration();
102
+                $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
103
+            }
104
+        } else {
105
+            $this->set_session_expiration();
106
+            $this->_customer_id = $this->generate_customer_id();
107
+            $this->_data        = $this->get_session_data();
108
+        }
109
+    }
110
+
111
+    /**
112
+     * Sets the session cookie on-demand (usually after adding an item to the cart).
113
+     *
114
+     * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
115
+     *
116
+     * Warning: Cookies will only be set if this is called before the headers are sent.
117
+     *
118
+     * @param bool $set Should the session cookie be set.
119
+     */
120
+    public function set_customer_session_cookie( $set ) {
121
+        if ( $set ) {
122
+            $to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
+            $cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
124
+            $cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125
+            $this->_has_cookie = true;
126
+
127
+            if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
+                $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
+            }
130
+        }
131
+    }
132
+
133
+    public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134 134
         if ( ! headers_sent() ) {
135 135
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
136 136
         } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
@@ -139,86 +139,86 @@  discard block
 block discarded – undo
139 139
         }
140 140
     }
141 141
 
142
-	/**
143
-	 * Should the session cookie be secure?
144
-	 *
145
-	 * @since 3.6.0
146
-	 * @return bool
147
-	 */
148
-	protected function use_secure_cookie() {
142
+    /**
143
+     * Should the session cookie be secure?
144
+     *
145
+     * @since 3.6.0
146
+     * @return bool
147
+     */
148
+    protected function use_secure_cookie() {
149 149
         $is_https = false !== strstr( get_option( 'home' ), 'https:' );
150
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
-	}
152
-
153
-	/**
154
-	 * Return true if the current user has an active session, i.e. a cookie to retrieve values.
155
-	 *
156
-	 * @return bool
157
-	 */
158
-	public function has_session() {
159
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160
-	}
161
-
162
-	/**
163
-	 * Set session expiration.
164
-	 */
165
-	public function set_session_expiration() {
166
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
-	}
169
-
170
-	/**
171
-	 * Generates session ids.
172
-	 *
173
-	 * @return string
174
-	 */
175
-	public function generate_customer_id() {
176
-		require_once ABSPATH . 'wp-includes/class-phpass.php';
177
-		$hasher      = new PasswordHash( 8, false );
178
-		return md5( $hasher->get_random_bytes( 32 ) );
179
-	}
180
-
181
-	/**
182
-	 * Get the session cookie, if set. Otherwise return false.
183
-	 *
184
-	 * Session cookies without a customer ID are invalid.
185
-	 *
186
-	 * @return bool|array
187
-	 */
188
-	public function get_session_cookie() {
189
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
190
-
191
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
192
-			return false;
193
-		}
194
-
195
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
196
-
197
-		if ( empty( $customer_id ) ) {
198
-			return false;
199
-		}
200
-
201
-		// Validate hash.
202
-		$to_hash = $customer_id . '|' . $session_expiration;
203
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
204
-
205
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
206
-			return false;
207
-		}
208
-
209
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
210
-	}
211
-
212
-	/**
213
-	 * Get session data.
214
-	 *
215
-	 * @return array
216
-	 */
217
-	public function get_session_data() {
218
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
219
-	}
220
-
221
-	public function generate_key($customer_id){
150
+        return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
+    }
152
+
153
+    /**
154
+     * Return true if the current user has an active session, i.e. a cookie to retrieve values.
155
+     *
156
+     * @return bool
157
+     */
158
+    public function has_session() {
159
+        return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160
+    }
161
+
162
+    /**
163
+     * Set session expiration.
164
+     */
165
+    public function set_session_expiration() {
166
+        $this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
+        $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
+    }
169
+
170
+    /**
171
+     * Generates session ids.
172
+     *
173
+     * @return string
174
+     */
175
+    public function generate_customer_id() {
176
+        require_once ABSPATH . 'wp-includes/class-phpass.php';
177
+        $hasher      = new PasswordHash( 8, false );
178
+        return md5( $hasher->get_random_bytes( 32 ) );
179
+    }
180
+
181
+    /**
182
+     * Get the session cookie, if set. Otherwise return false.
183
+     *
184
+     * Session cookies without a customer ID are invalid.
185
+     *
186
+     * @return bool|array
187
+     */
188
+    public function get_session_cookie() {
189
+        $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
190
+
191
+        if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
192
+            return false;
193
+        }
194
+
195
+        list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
196
+
197
+        if ( empty( $customer_id ) ) {
198
+            return false;
199
+        }
200
+
201
+        // Validate hash.
202
+        $to_hash = $customer_id . '|' . $session_expiration;
203
+        $hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
204
+
205
+        if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
206
+            return false;
207
+        }
208
+
209
+        return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
210
+    }
211
+
212
+    /**
213
+     * Get session data.
214
+     *
215
+     * @return array
216
+     */
217
+    public function get_session_data() {
218
+        return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
219
+    }
220
+
221
+    public function generate_key($customer_id){
222 222
         if(!$customer_id){
223 223
             return;
224 224
         }
@@ -226,62 +226,62 @@  discard block
 block discarded – undo
226 226
         return 'wpi_trans_'.$customer_id;
227 227
     }
228 228
 
229
-	/**
230
-	 * Save data.
231
-	 */
232
-	public function save_data() {
233
-		// Dirty if something changed - prevents saving nothing new.
234
-		if ( $this->_dirty && $this->has_session() ) {
229
+    /**
230
+     * Save data.
231
+     */
232
+    public function save_data() {
233
+        // Dirty if something changed - prevents saving nothing new.
234
+        if ( $this->_dirty && $this->has_session() ) {
235 235
 
236 236
             set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
237 237
 
238
-			$this->_dirty = false;
239
-		}
240
-	}
241
-
242
-	/**
243
-	 * Destroy all session data.
244
-	 */
245
-	public function destroy_session() {
246
-		$this->delete_session( $this->_customer_id );
247
-		$this->forget_session();
248
-	}
249
-
250
-	/**
251
-	 * Forget all session data without destroying it.
252
-	 */
253
-	public function forget_session() {
254
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
255
-
256
-		wpinv_empty_cart();
257
-
258
-		$this->_data        = array();
259
-		$this->_dirty       = false;
260
-		$this->_customer_id = $this->generate_customer_id();
261
-	}
262
-
263
-	/**
264
-	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
265
-	 *
266
-	 * @param int $uid User ID.
267
-	 * @return string
268
-	 */
269
-	public function nonce_user_logged_out( $uid ) {
270
-		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
271
-	}
272
-
273
-	/**
274
-	 * Returns the session.
275
-	 *
276
-	 * @param string $customer_id Customer ID.
277
-	 * @param mixed  $default Default session value.
278
-	 * @return string|array
279
-	 */
280
-	public function get_session( $customer_id, $default = false ) {
281
-
282
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
283
-			return array();
284
-		}
238
+            $this->_dirty = false;
239
+        }
240
+    }
241
+
242
+    /**
243
+     * Destroy all session data.
244
+     */
245
+    public function destroy_session() {
246
+        $this->delete_session( $this->_customer_id );
247
+        $this->forget_session();
248
+    }
249
+
250
+    /**
251
+     * Forget all session data without destroying it.
252
+     */
253
+    public function forget_session() {
254
+        $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
255
+
256
+        wpinv_empty_cart();
257
+
258
+        $this->_data        = array();
259
+        $this->_dirty       = false;
260
+        $this->_customer_id = $this->generate_customer_id();
261
+    }
262
+
263
+    /**
264
+     * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
265
+     *
266
+     * @param int $uid User ID.
267
+     * @return string
268
+     */
269
+    public function nonce_user_logged_out( $uid ) {
270
+        return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
271
+    }
272
+
273
+    /**
274
+     * Returns the session.
275
+     *
276
+     * @param string $customer_id Customer ID.
277
+     * @param mixed  $default Default session value.
278
+     * @return string|array
279
+     */
280
+    public function get_session( $customer_id, $default = false ) {
281
+
282
+        if ( defined( 'WP_SETUP_CONFIG' ) ) {
283
+            return array();
284
+        }
285 285
 
286 286
         $key = $this->generate_key($customer_id);
287 287
         $value = get_transient($key);
@@ -290,30 +290,30 @@  discard block
 block discarded – undo
290 290
             $value = $default;
291 291
         }
292 292
 
293
-		return maybe_unserialize( $value );
294
-	}
293
+        return maybe_unserialize( $value );
294
+    }
295 295
 
296
-	/**
297
-	 * Delete the session from the cache and database.
298
-	 *
299
-	 * @param int $customer_id Customer ID.
300
-	 */
301
-	public function delete_session( $customer_id ) {
296
+    /**
297
+     * Delete the session from the cache and database.
298
+     *
299
+     * @param int $customer_id Customer ID.
300
+     */
301
+    public function delete_session( $customer_id ) {
302 302
 
303 303
         $key = $this->generate_key($customer_id);
304 304
 
305
-		delete_transient($key);
306
-	}
305
+        delete_transient($key);
306
+    }
307 307
 
308
-	/**
309
-	 * Update the session expiry timestamp.
310
-	 *
311
-	 * @param string $customer_id Customer ID.
312
-	 * @param int    $timestamp Timestamp to expire the cookie.
313
-	 */
314
-	public function update_session_timestamp( $customer_id, $timestamp ) {
308
+    /**
309
+     * Update the session expiry timestamp.
310
+     *
311
+     * @param string $customer_id Customer ID.
312
+     * @param int    $timestamp Timestamp to expire the cookie.
313
+     */
314
+    public function update_session_timestamp( $customer_id, $timestamp ) {
315 315
 
316 316
         set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
317 317
 
318
-	}
318
+    }
319 319
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/hello-world.php 2 patches
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -3,102 +3,102 @@  discard block
 block discarded – undo
3 3
 class SD_Hello_World extends WP_Super_Duper {
4 4
 
5 5
 
6
-	public $arguments;
7
-
8
-	/**
9
-	 * Sets up the widgets name etc
10
-	 */
11
-	public function __construct() {
12
-
13
-		$options = array(
14
-			'textdomain'     => 'super-duper',
15
-			// textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
-			'block-icon'     => 'fas fa-globe-americas',
17
-			// Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
-			// OR font-awesome 5 class name: fas fa-globe-americas
19
-			'block-category' => 'widgets',
20
-			// the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21
-			'block-keywords' => "['hello','world']",
22
-			// used in the block search, MAX 3
23
-			'block-output'   => array( // the block visual output elements as an array
24
-				array(
25
-					'element' => 'p',
26
-					'title'   => __( 'Placeholder', 'hello-world' ),
27
-					'class'   => '[%className%]',
28
-					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29
-				)
30
-			),
31
-			'block-wrap'    => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
32
-			'class_name'     => __CLASS__,
33
-			// The calling class name
34
-			'base_id'        => 'hello_world',
35
-			// this is used as the widget id and the shortcode id.
36
-			'name'           => __( 'Hello World', 'hello-world' ),
37
-			// the name of the widget/block
38
-			'widget_ops'     => array(
39
-				'classname'   => 'hello-world-class',
40
-				// widget class
41
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
42
-				// widget description
43
-			),
44
-			'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45
-			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46
-				'after_text' => array( // this is the input name=''
47
-					'title'       => __( 'Text after hello:', 'hello-world' ),
48
-					// input title
49
-					'desc'        => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ),
50
-					// input description
51
-					'type'        => 'text',
52
-					// the type of input, test, select, checkbox etc.
53
-					'placeholder' => 'World',
54
-					// the input placeholder text.
55
-					'desc_tip'    => true,
56
-					// if the input should show the widget description text as a tooltip.
57
-					'default'     => 'World',
58
-					// the input default value.
59
-					'advanced'    => false
60
-					// not yet implemented
61
-				),
62
-			)
63
-		);
64
-
65
-		parent::__construct( $options );
66
-	}
67
-
68
-
69
-	/**
70
-	 * This is the output function for the widget, shortcode and block (front end).
71
-	 *
72
-	 * @param array $args The arguments values.
73
-	 * @param array $widget_args The widget arguments when used.
74
-	 * @param string $content The shortcode content argument
75
-	 *
76
-	 * @return string
77
-	 */
78
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
79
-
80
-		/**
81
-		 * @var string $after_text
82
-		 * @var string $another_input This is added by filter below.
83
-		 */
84
-		extract( $args, EXTR_SKIP );
85
-
86
-		/*
6
+    public $arguments;
7
+
8
+    /**
9
+     * Sets up the widgets name etc
10
+     */
11
+    public function __construct() {
12
+
13
+        $options = array(
14
+            'textdomain'     => 'super-duper',
15
+            // textdomain of the plugin/theme (used to prefix the Gutenberg block)
16
+            'block-icon'     => 'fas fa-globe-americas',
17
+            // Dash icon name for the block: https://developer.wordpress.org/resource/dashicons/#arrow-right
18
+            // OR font-awesome 5 class name: fas fa-globe-americas
19
+            'block-category' => 'widgets',
20
+            // the category for the block, 'common', 'formatting', 'layout', 'widgets', 'embed'.
21
+            'block-keywords' => "['hello','world']",
22
+            // used in the block search, MAX 3
23
+            'block-output'   => array( // the block visual output elements as an array
24
+                array(
25
+                    'element' => 'p',
26
+                    'title'   => __( 'Placeholder', 'hello-world' ),
27
+                    'class'   => '[%className%]',
28
+                    'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29
+                )
30
+            ),
31
+            'block-wrap'    => '', // You can specify the type of element to wrap the block `div` or `span` etc.. Or blank for no wrap at all.
32
+            'class_name'     => __CLASS__,
33
+            // The calling class name
34
+            'base_id'        => 'hello_world',
35
+            // this is used as the widget id and the shortcode id.
36
+            'name'           => __( 'Hello World', 'hello-world' ),
37
+            // the name of the widget/block
38
+            'widget_ops'     => array(
39
+                'classname'   => 'hello-world-class',
40
+                // widget class
41
+                'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
42
+                // widget description
43
+            ),
44
+            'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45
+            'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46
+                'after_text' => array( // this is the input name=''
47
+                    'title'       => __( 'Text after hello:', 'hello-world' ),
48
+                    // input title
49
+                    'desc'        => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ),
50
+                    // input description
51
+                    'type'        => 'text',
52
+                    // the type of input, test, select, checkbox etc.
53
+                    'placeholder' => 'World',
54
+                    // the input placeholder text.
55
+                    'desc_tip'    => true,
56
+                    // if the input should show the widget description text as a tooltip.
57
+                    'default'     => 'World',
58
+                    // the input default value.
59
+                    'advanced'    => false
60
+                    // not yet implemented
61
+                ),
62
+            )
63
+        );
64
+
65
+        parent::__construct( $options );
66
+    }
67
+
68
+
69
+    /**
70
+     * This is the output function for the widget, shortcode and block (front end).
71
+     *
72
+     * @param array $args The arguments values.
73
+     * @param array $widget_args The widget arguments when used.
74
+     * @param string $content The shortcode content argument
75
+     *
76
+     * @return string
77
+     */
78
+    public function output( $args = array(), $widget_args = array(), $content = '' ) {
79
+
80
+        /**
81
+         * @var string $after_text
82
+         * @var string $another_input This is added by filter below.
83
+         */
84
+        extract( $args, EXTR_SKIP );
85
+
86
+        /*
87 87
 		 * This value is added by filter so might not exist if filter is removed so we check.
88 88
 		 */
89
-		if ( ! isset( $another_input ) ) {
90
-			$another_input = '';
91
-		}
89
+        if ( ! isset( $another_input ) ) {
90
+            $another_input = '';
91
+        }
92 92
 
93
-		return "Hello: " . $after_text . "" . $another_input;
93
+        return "Hello: " . $after_text . "" . $another_input;
94 94
 
95
-	}
95
+    }
96 96
 
97 97
 }
98 98
 
99 99
 // register it.
100 100
 add_action( 'widgets_init', function () {
101
-	register_widget( 'SD_Hello_World' );
101
+    register_widget( 'SD_Hello_World' );
102 102
 } );
103 103
 
104 104
 
@@ -111,26 +111,26 @@  discard block
 block discarded – undo
111 111
  */
112 112
 function _my_extra_arguments( $options ) {
113 113
 
114
-	/*
114
+    /*
115 115
 	 * Add a new input option.
116 116
 	 */
117
-	$options['arguments']['another_input'] = array(
118
-		'name'        => 'another_input', // this is the input name=''
119
-		'title'       => __( 'Another input:', 'hello-world' ), // input title
120
-		'desc'        => __( 'This is an input added via filter.', 'hello-world' ), // input description
121
-		'type'        => 'text', // the type of input, test, select, checkbox etc.
122
-		'placeholder' => 'Placeholder text', // the input placeholder text.
123
-		'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
124
-		'default'     => '', // the input default value.
125
-		'advanced'    => false // not yet implemented
126
-	);
127
-
128
-	/*
117
+    $options['arguments']['another_input'] = array(
118
+        'name'        => 'another_input', // this is the input name=''
119
+        'title'       => __( 'Another input:', 'hello-world' ), // input title
120
+        'desc'        => __( 'This is an input added via filter.', 'hello-world' ), // input description
121
+        'type'        => 'text', // the type of input, test, select, checkbox etc.
122
+        'placeholder' => 'Placeholder text', // the input placeholder text.
123
+        'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
124
+        'default'     => '', // the input default value.
125
+        'advanced'    => false // not yet implemented
126
+    );
127
+
128
+    /*
129 129
 	 * Output the new option in the block output also.
130 130
 	 */
131
-	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
131
+    $options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
132 132
 
133
-	return $options;
133
+    return $options;
134 134
 }
135 135
 
136 136
 //add_filter( 'wp_super_duper_options_hello_world', '_my_extra_arguments' );
137 137
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 			'block-output'   => array( // the block visual output elements as an array
24 24
 				array(
25 25
 					'element' => 'p',
26
-					'title'   => __( 'Placeholder', 'hello-world' ),
26
+					'title'   => __('Placeholder', 'hello-world'),
27 27
 					'class'   => '[%className%]',
28 28
 					'content' => 'Hello: [%after_text%]' // block properties can be added by wrapping them in [%name%]
29 29
 				)
@@ -33,20 +33,20 @@  discard block
 block discarded – undo
33 33
 			// The calling class name
34 34
 			'base_id'        => 'hello_world',
35 35
 			// this is used as the widget id and the shortcode id.
36
-			'name'           => __( 'Hello World', 'hello-world' ),
36
+			'name'           => __('Hello World', 'hello-world'),
37 37
 			// the name of the widget/block
38 38
 			'widget_ops'     => array(
39 39
 				'classname'   => 'hello-world-class',
40 40
 				// widget class
41
-				'description' => esc_html__( 'This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world' ),
41
+				'description' => esc_html__('This is an example that will take a text parameter and output it after `Hello:`.', 'hello-world'),
42 42
 				// widget description
43 43
 			),
44 44
 			'no_wrap'       => true, // This will prevent the widget being wrapped in the containing widget class div.
45 45
 			'arguments'      => array( // these are the arguments that will be used in the widget, shortcode and block settings.
46 46
 				'after_text' => array( // this is the input name=''
47
-					'title'       => __( 'Text after hello:', 'hello-world' ),
47
+					'title'       => __('Text after hello:', 'hello-world'),
48 48
 					// input title
49
-					'desc'        => __( 'This is the text that will appear after `Hello:`.', 'hello-world' ),
49
+					'desc'        => __('This is the text that will appear after `Hello:`.', 'hello-world'),
50 50
 					// input description
51 51
 					'type'        => 'text',
52 52
 					// the type of input, test, select, checkbox etc.
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 			)
63 63
 		);
64 64
 
65
-		parent::__construct( $options );
65
+		parent::__construct($options);
66 66
 	}
67 67
 
68 68
 
@@ -75,18 +75,18 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return string
77 77
 	 */
78
-	public function output( $args = array(), $widget_args = array(), $content = '' ) {
78
+	public function output($args = array(), $widget_args = array(), $content = '') {
79 79
 
80 80
 		/**
81 81
 		 * @var string $after_text
82 82
 		 * @var string $another_input This is added by filter below.
83 83
 		 */
84
-		extract( $args, EXTR_SKIP );
84
+		extract($args, EXTR_SKIP);
85 85
 
86 86
 		/*
87 87
 		 * This value is added by filter so might not exist if filter is removed so we check.
88 88
 		 */
89
-		if ( ! isset( $another_input ) ) {
89
+		if (!isset($another_input)) {
90 90
 			$another_input = '';
91 91
 		}
92 92
 
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 }
98 98
 
99 99
 // register it.
100
-add_action( 'widgets_init', function () {
101
-	register_widget( 'SD_Hello_World' );
100
+add_action('widgets_init', function() {
101
+	register_widget('SD_Hello_World');
102 102
 } );
103 103
 
104 104
 
@@ -109,15 +109,15 @@  discard block
 block discarded – undo
109 109
  *
110 110
  * @return mixed
111 111
  */
112
-function _my_extra_arguments( $options ) {
112
+function _my_extra_arguments($options) {
113 113
 
114 114
 	/*
115 115
 	 * Add a new input option.
116 116
 	 */
117 117
 	$options['arguments']['another_input'] = array(
118 118
 		'name'        => 'another_input', // this is the input name=''
119
-		'title'       => __( 'Another input:', 'hello-world' ), // input title
120
-		'desc'        => __( 'This is an input added via filter.', 'hello-world' ), // input description
119
+		'title'       => __('Another input:', 'hello-world'), // input title
120
+		'desc'        => __('This is an input added via filter.', 'hello-world'), // input description
121 121
 		'type'        => 'text', // the type of input, test, select, checkbox etc.
122 122
 		'placeholder' => 'Placeholder text', // the input placeholder text.
123 123
 		'desc_tip'    => true, // if the input should show the widget description text as a tooltip.
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	/*
129 129
 	 * Output the new option in the block output also.
130 130
 	 */
131
-	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]";;
131
+	$options['block-output']['element::p']['content'] = $options['block-output']['element::p']['content'] . " [%another_input%]"; ;
132 132
 
133 133
 	return $options;
134 134
 }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public function getLocations()
36 36
     {
37 37
         if ($this->matchesCakeVersion('>=', '3.0.0')) {
38
-            $this->locations['plugin'] =  $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
38
+            $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
39 39
         }
40 40
         return $this->locations;
41 41
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
         }
59 59
 
60 60
         $repositoryManager = $this->composer->getRepositoryManager();
61
-        if (! $repositoryManager) {
61
+        if (!$repositoryManager) {
62 62
             return false;
63 63
         }
64 64
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-button.php 3 patches
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 			if($type=='a'){
50 50
 				$new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
51 51
 				$output .= '<a href="' . $args['href'] . '"'.$new_window;
52
-			}elseif($type=='badge'){
52
+			} elseif($type=='badge'){
53 53
 				$output .= '<span ';
54
-			}else{
54
+			} else{
55 55
 				$output .= '<button type="' . $type . '" ';
56 56
 			}
57 57
 
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 			// close
119 119
 			if($type=='a'){
120 120
 				$output .= '</a>';
121
-			}elseif($type=='badge'){
121
+			} elseif($type=='badge'){
122 122
 				$output .= '</span>';
123
-			}else{
123
+			} else{
124 124
 				$output .= '</button>';
125 125
 			}
126 126
 
Please login to merge, or discard this patch.
Indentation   +121 added lines, -121 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,143 +11,143 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Button {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'a', // a, button, badge
24
-			'href'       => '#',
25
-			'new_window' => false,
26
-			'class'      => 'btn btn-primary',
27
-			'id'         => '',
28
-			'title'      => '',
29
-			'value'      => '',
30
-			'content'    => '',
31
-			'icon'       => '',
32
-			'hover_content' => '',
33
-			'hover_icon'    => '',
34
-			'new_line_after' => true,
35
-			'no_wrap'    => true,
36
-			'onclick'    => '',
37
-			'style'  => '',
38
-			'extra_attributes'  => array(), // an array of extra attributes
39
-			'icon_extra_attributes'  => array() // an array of icon extra attributes
40
-		);
41
-
42
-		/**
43
-		 * Parse incoming $args into an array and merge it with $defaults
44
-		 */
45
-		$args   = wp_parse_args( $args, $defaults );
46
-		$output = '';
47
-		if ( ! empty( $args['type'] ) ) {
48
-			$type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49
-
50
-			// open/type
51
-			if($type=='a'){
52
-				$new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53
-				$output .= '<a href="' . $args['href'] . '"'.$new_window;
54
-			}elseif($type=='badge'){
55
-				$output .= '<span ';
56
-			}else{
57
-				$output .= '<button type="' . $type . '" ';
58
-			}
59
-
60
-			// name
61
-			if(!empty($args['name'])){
62
-				$output .= AUI_Component_Helper::name($args['name']);
63
-			}
64
-
65
-			// id
66
-			if(!empty($args['id'])){
67
-				$output .= AUI_Component_Helper::id($args['id']);
68
-			}
69
-
70
-			// title
71
-			if(!empty($args['title'])){
72
-				$output .= AUI_Component_Helper::title($args['title']);
73
-			}
74
-
75
-			// value
76
-			if(!empty($args['value'])){
77
-				$output .= AUI_Component_Helper::value($args['value']);
78
-			}
79
-
80
-			// class
81
-			$class = !empty($args['class']) ? $args['class'] : '';
82
-			$output .= AUI_Component_Helper::class_attr($class);
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'a', // a, button, badge
24
+            'href'       => '#',
25
+            'new_window' => false,
26
+            'class'      => 'btn btn-primary',
27
+            'id'         => '',
28
+            'title'      => '',
29
+            'value'      => '',
30
+            'content'    => '',
31
+            'icon'       => '',
32
+            'hover_content' => '',
33
+            'hover_icon'    => '',
34
+            'new_line_after' => true,
35
+            'no_wrap'    => true,
36
+            'onclick'    => '',
37
+            'style'  => '',
38
+            'extra_attributes'  => array(), // an array of extra attributes
39
+            'icon_extra_attributes'  => array() // an array of icon extra attributes
40
+        );
41
+
42
+        /**
43
+         * Parse incoming $args into an array and merge it with $defaults
44
+         */
45
+        $args   = wp_parse_args( $args, $defaults );
46
+        $output = '';
47
+        if ( ! empty( $args['type'] ) ) {
48
+            $type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49
+
50
+            // open/type
51
+            if($type=='a'){
52
+                $new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53
+                $output .= '<a href="' . $args['href'] . '"'.$new_window;
54
+            }elseif($type=='badge'){
55
+                $output .= '<span ';
56
+            }else{
57
+                $output .= '<button type="' . $type . '" ';
58
+            }
59
+
60
+            // name
61
+            if(!empty($args['name'])){
62
+                $output .= AUI_Component_Helper::name($args['name']);
63
+            }
64
+
65
+            // id
66
+            if(!empty($args['id'])){
67
+                $output .= AUI_Component_Helper::id($args['id']);
68
+            }
69
+
70
+            // title
71
+            if(!empty($args['title'])){
72
+                $output .= AUI_Component_Helper::title($args['title']);
73
+            }
74
+
75
+            // value
76
+            if(!empty($args['value'])){
77
+                $output .= AUI_Component_Helper::value($args['value']);
78
+            }
79
+
80
+            // class
81
+            $class = !empty($args['class']) ? $args['class'] : '';
82
+            $output .= AUI_Component_Helper::class_attr($class);
83 83
 			
84
-			// data-attributes
85
-			$output .= AUI_Component_Helper::data_attributes($args);
84
+            // data-attributes
85
+            $output .= AUI_Component_Helper::data_attributes($args);
86 86
 
87
-			// aria-attributes
88
-			$output .= AUI_Component_Helper::aria_attributes($args);
87
+            // aria-attributes
88
+            $output .= AUI_Component_Helper::aria_attributes($args);
89 89
 
90
-			// extra attributes
91
-			if(!empty($args['extra_attributes'])){
92
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93
-			}
90
+            // extra attributes
91
+            if(!empty($args['extra_attributes'])){
92
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93
+            }
94 94
 
95
-			// onclick, we don't escape this
96
-			if(!empty($args['onclick'])){
97
-				$output .= ' onclick="'.$args['onclick'].'" ';
98
-			}
95
+            // onclick, we don't escape this
96
+            if(!empty($args['onclick'])){
97
+                $output .= ' onclick="'.$args['onclick'].'" ';
98
+            }
99 99
 
100
-			// style, we don't escape this
101
-			if(!empty($args['style'])){
102
-				$output .= ' style="'.$args['style'].'" ';
103
-			}
100
+            // style, we don't escape this
101
+            if(!empty($args['style'])){
102
+                $output .= ' style="'.$args['style'].'" ';
103
+            }
104 104
 
105
-			// close opening tag
106
-			$output .= ' >';
105
+            // close opening tag
106
+            $output .= ' >';
107 107
 
108 108
 
109
-			// hover content
110
-			$hover_content = false;
111
-			if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112
-				$output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
113
-				$hover_content = true;
114
-			}
109
+            // hover content
110
+            $hover_content = false;
111
+            if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112
+                $output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
113
+                $hover_content = true;
114
+            }
115 115
 			
116
-			// content
117
-			if($hover_content){$output .= "<span class='hover-content-original'>";}
118
-			if(!empty($args['content']) || !empty($args['icon'])){
119
-				$output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
120
-			}
121
-			if($hover_content){$output .= "</span>";}
116
+            // content
117
+            if($hover_content){$output .= "<span class='hover-content-original'>";}
118
+            if(!empty($args['content']) || !empty($args['icon'])){
119
+                $output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
120
+            }
121
+            if($hover_content){$output .= "</span>";}
122 122
 					
123 123
 
124 124
 
125
-			// close
126
-			if($type=='a'){
127
-				$output .= '</a>';
128
-			}elseif($type=='badge'){
129
-				$output .= '</span>';
130
-			}else{
131
-				$output .= '</button>';
132
-			}
125
+            // close
126
+            if($type=='a'){
127
+                $output .= '</a>';
128
+            }elseif($type=='badge'){
129
+                $output .= '</span>';
130
+            }else{
131
+                $output .= '</button>';
132
+            }
133 133
 
134
-			// maybe new line after?  This adds better spacing between buttons.
135
-			if(!empty($args['new_line_after'])){
136
-				$output .= PHP_EOL;
137
-			}
134
+            // maybe new line after?  This adds better spacing between buttons.
135
+            if(!empty($args['new_line_after'])){
136
+                $output .= PHP_EOL;
137
+            }
138 138
 
139 139
 
140
-			// wrap
141
-			if(!$args['no_wrap']){
142
-				$output = AUI_Component_Input::wrap(array(
143
-					'content' => $output,
144
-				));
145
-			}
140
+            // wrap
141
+            if(!$args['no_wrap']){
142
+                $output = AUI_Component_Input::wrap(array(
143
+                    'content' => $output,
144
+                ));
145
+            }
146 146
 
147 147
 
148
-		}
148
+        }
149 149
 
150
-		return $output;
151
-	}
150
+        return $output;
151
+    }
152 152
 
153 153
 }
154 154
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function get($args = array()){
21
+	public static function get($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'a', // a, button, badge
24 24
 			'href'       => '#',
@@ -42,38 +42,38 @@  discard block
 block discarded – undo
42 42
 		/**
43 43
 		 * Parse incoming $args into an array and merge it with $defaults
44 44
 		 */
45
-		$args   = wp_parse_args( $args, $defaults );
45
+		$args   = wp_parse_args($args, $defaults);
46 46
 		$output = '';
47
-		if ( ! empty( $args['type'] ) ) {
47
+		if (!empty($args['type'])) {
48 48
 			$type = $args['type'] != 'a' ? esc_attr($args['type']) : 'a';
49 49
 
50 50
 			// open/type
51
-			if($type=='a'){
51
+			if ($type == 'a') {
52 52
 				$new_window = !empty($args['new_window']) ? ' target="_blank" ' : '';
53
-				$output .= '<a href="' . $args['href'] . '"'.$new_window;
54
-			}elseif($type=='badge'){
53
+				$output .= '<a href="' . $args['href'] . '"' . $new_window;
54
+			}elseif ($type == 'badge') {
55 55
 				$output .= '<span ';
56
-			}else{
56
+			} else {
57 57
 				$output .= '<button type="' . $type . '" ';
58 58
 			}
59 59
 
60 60
 			// name
61
-			if(!empty($args['name'])){
61
+			if (!empty($args['name'])) {
62 62
 				$output .= AUI_Component_Helper::name($args['name']);
63 63
 			}
64 64
 
65 65
 			// id
66
-			if(!empty($args['id'])){
66
+			if (!empty($args['id'])) {
67 67
 				$output .= AUI_Component_Helper::id($args['id']);
68 68
 			}
69 69
 
70 70
 			// title
71
-			if(!empty($args['title'])){
71
+			if (!empty($args['title'])) {
72 72
 				$output .= AUI_Component_Helper::title($args['title']);
73 73
 			}
74 74
 
75 75
 			// value
76
-			if(!empty($args['value'])){
76
+			if (!empty($args['value'])) {
77 77
 				$output .= AUI_Component_Helper::value($args['value']);
78 78
 			}
79 79
 
@@ -88,18 +88,18 @@  discard block
 block discarded – undo
88 88
 			$output .= AUI_Component_Helper::aria_attributes($args);
89 89
 
90 90
 			// extra attributes
91
-			if(!empty($args['extra_attributes'])){
91
+			if (!empty($args['extra_attributes'])) {
92 92
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
93 93
 			}
94 94
 
95 95
 			// onclick, we don't escape this
96
-			if(!empty($args['onclick'])){
97
-				$output .= ' onclick="'.$args['onclick'].'" ';
96
+			if (!empty($args['onclick'])) {
97
+				$output .= ' onclick="' . $args['onclick'] . '" ';
98 98
 			}
99 99
 
100 100
 			// style, we don't escape this
101
-			if(!empty($args['style'])){
102
-				$output .= ' style="'.$args['style'].'" ';
101
+			if (!empty($args['style'])) {
102
+				$output .= ' style="' . $args['style'] . '" ';
103 103
 			}
104 104
 
105 105
 			// close opening tag
@@ -108,37 +108,37 @@  discard block
 block discarded – undo
108 108
 
109 109
 			// hover content
110 110
 			$hover_content = false;
111
-			if(!empty($args['hover_content']) || !empty($args['hover_icon'])){
112
-				$output .= "<span class='hover-content'>".AUI_Component_Helper::icon($args['hover_icon'],$args['hover_content']).$args['hover_content']."</span>";
111
+			if (!empty($args['hover_content']) || !empty($args['hover_icon'])) {
112
+				$output .= "<span class='hover-content'>" . AUI_Component_Helper::icon($args['hover_icon'], $args['hover_content']) . $args['hover_content'] . "</span>";
113 113
 				$hover_content = true;
114 114
 			}
115 115
 			
116 116
 			// content
117
-			if($hover_content){$output .= "<span class='hover-content-original'>";}
118
-			if(!empty($args['content']) || !empty($args['icon'])){
119
-				$output .= AUI_Component_Helper::icon($args['icon'],$args['content'],$args['icon_extra_attributes']).$args['content'];
117
+			if ($hover_content) {$output .= "<span class='hover-content-original'>"; }
118
+			if (!empty($args['content']) || !empty($args['icon'])) {
119
+				$output .= AUI_Component_Helper::icon($args['icon'], $args['content'], $args['icon_extra_attributes']) . $args['content'];
120 120
 			}
121
-			if($hover_content){$output .= "</span>";}
121
+			if ($hover_content) {$output .= "</span>"; }
122 122
 					
123 123
 
124 124
 
125 125
 			// close
126
-			if($type=='a'){
126
+			if ($type == 'a') {
127 127
 				$output .= '</a>';
128
-			}elseif($type=='badge'){
128
+			}elseif ($type == 'badge') {
129 129
 				$output .= '</span>';
130
-			}else{
130
+			} else {
131 131
 				$output .= '</button>';
132 132
 			}
133 133
 
134 134
 			// maybe new line after?  This adds better spacing between buttons.
135
-			if(!empty($args['new_line_after'])){
135
+			if (!empty($args['new_line_after'])) {
136 136
 				$output .= PHP_EOL;
137 137
 			}
138 138
 
139 139
 
140 140
 			// wrap
141
-			if(!$args['no_wrap']){
141
+			if (!$args['no_wrap']) {
142 142
 				$output = AUI_Component_Input::wrap(array(
143 143
 					'content' => $output,
144 144
 				));
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-alert.php 3 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,81 +11,81 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Alert {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 * 
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'info',
24
-			'class'      => '',
25
-			'icon' => '',
26
-			'heading'    => '',
27
-			'content'    => '',
28
-			'footer'     => '',
29
-			'dismissible'=> false,
30
-			'data'       => '',
31
-		);
14
+    /**
15
+     * Build the component.
16
+     * 
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'info',
24
+            'class'      => '',
25
+            'icon' => '',
26
+            'heading'    => '',
27
+            'content'    => '',
28
+            'footer'     => '',
29
+            'dismissible'=> false,
30
+            'data'       => '',
31
+        );
32 32
 
33
-		/**
34
-		 * Parse incoming $args into an array and merge it with $defaults
35
-		 */
36
-		$args   = wp_parse_args( $args, $defaults );
37
-		$output = '';
38
-		if ( ! empty( $args['content'] ) ) {
39
-			$type = sanitize_html_class( $args['type'] );
40
-			if($type=='error'){$type='danger';}
41
-			$icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : '';
33
+        /**
34
+         * Parse incoming $args into an array and merge it with $defaults
35
+         */
36
+        $args   = wp_parse_args( $args, $defaults );
37
+        $output = '';
38
+        if ( ! empty( $args['content'] ) ) {
39
+            $type = sanitize_html_class( $args['type'] );
40
+            if($type=='error'){$type='danger';}
41
+            $icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : '';
42 42
 
43
-			// set default icon
44
-			if(!$icon && $args['icon']!==false && $type){
45
-				if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
46
-				elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
47
-				elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
48
-				elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
49
-			}
43
+            // set default icon
44
+            if(!$icon && $args['icon']!==false && $type){
45
+                if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
46
+                elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
47
+                elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
48
+                elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
49
+            }
50 50
 
51
-			$data = '';
52
-			$class = !empty($args['class']) ? esc_attr($args['class']) : '';
53
-			if($args['dismissible']){$class .= " alert-dismissible fade show";}
51
+            $data = '';
52
+            $class = !empty($args['class']) ? esc_attr($args['class']) : '';
53
+            if($args['dismissible']){$class .= " alert-dismissible fade show";}
54 54
 
55
-			// open
56
-			$output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>';
55
+            // open
56
+            $output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>';
57 57
 
58
-			// heading
59
-			if ( ! empty( $args['heading'] ) ) {
60
-				$output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>';
61
-			}
58
+            // heading
59
+            if ( ! empty( $args['heading'] ) ) {
60
+                $output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>';
61
+            }
62 62
 
63
-			// icon
64
-			if ( ! empty( $icon) ) {
65
-				$output .= $icon." ";
66
-			}
63
+            // icon
64
+            if ( ! empty( $icon) ) {
65
+                $output .= $icon." ";
66
+            }
67 67
 
68
-			// content
69
-			$output .= $args['content'];
68
+            // content
69
+            $output .= $args['content'];
70 70
 
71
-			// dismissible
72
-			if($args['dismissible']){
73
-				$output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">';
74
-				$output .= '<span aria-hidden="true">&times;</span>';
75
-				$output .= '</button>';
76
-			}
71
+            // dismissible
72
+            if($args['dismissible']){
73
+                $output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">';
74
+                $output .= '<span aria-hidden="true">&times;</span>';
75
+                $output .= '</button>';
76
+            }
77 77
 
78
-			// footer
79
-			if ( ! empty( $args['footer'] ) ) {
80
-				$output .= '<hr>';
81
-				$output .= '<p class="mb-0">' . $args['footer'] . '</p>';
82
-			}
78
+            // footer
79
+            if ( ! empty( $args['footer'] ) ) {
80
+                $output .= '<hr>';
81
+                $output .= '<p class="mb-0">' . $args['footer'] . '</p>';
82
+            }
83 83
 
84
-			// close
85
-			$output .= '</div>';
86
-		}
84
+            // close
85
+            $output .= '</div>';
86
+        }
87 87
 
88
-		return $output;
89
-	}
88
+        return $output;
89
+    }
90 90
 
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function get($args = array()){
21
+	public static function get($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'info',
24 24
 			'class'      => '',
@@ -33,50 +33,50 @@  discard block
 block discarded – undo
33 33
 		/**
34 34
 		 * Parse incoming $args into an array and merge it with $defaults
35 35
 		 */
36
-		$args   = wp_parse_args( $args, $defaults );
36
+		$args   = wp_parse_args($args, $defaults);
37 37
 		$output = '';
38
-		if ( ! empty( $args['content'] ) ) {
39
-			$type = sanitize_html_class( $args['type'] );
40
-			if($type=='error'){$type='danger';}
41
-			$icon = !empty($args['icon']) ? "<i class='".esc_attr($args['icon'])."'></i>" : '';
38
+		if (!empty($args['content'])) {
39
+			$type = sanitize_html_class($args['type']);
40
+			if ($type == 'error') {$type = 'danger'; }
41
+			$icon = !empty($args['icon']) ? "<i class='" . esc_attr($args['icon']) . "'></i>" : '';
42 42
 
43 43
 			// set default icon
44
-			if(!$icon && $args['icon']!==false && $type){
45
-				if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
46
-				elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
47
-				elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
48
-				elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
44
+			if (!$icon && $args['icon'] !== false && $type) {
45
+				if ($type == 'danger') {$icon = '<i class="fas fa-exclamation-circle"></i>'; }
46
+				elseif ($type == 'warning') {$icon = '<i class="fas fa-exclamation-triangle"></i>'; }
47
+				elseif ($type == 'success') {$icon = '<i class="fas fa-check-circle"></i>'; }
48
+				elseif ($type == 'info') {$icon = '<i class="fas fa-info-circle"></i>'; }
49 49
 			}
50 50
 
51 51
 			$data = '';
52 52
 			$class = !empty($args['class']) ? esc_attr($args['class']) : '';
53
-			if($args['dismissible']){$class .= " alert-dismissible fade show";}
53
+			if ($args['dismissible']) {$class .= " alert-dismissible fade show"; }
54 54
 
55 55
 			// open
56
-			$output .= '<div class="alert alert-' . $type . ' '.$class.'" role="alert" '.$data.'>';
56
+			$output .= '<div class="alert alert-' . $type . ' ' . $class . '" role="alert" ' . $data . '>';
57 57
 
58 58
 			// heading
59
-			if ( ! empty( $args['heading'] ) ) {
59
+			if (!empty($args['heading'])) {
60 60
 				$output .= '<h4 class="alert-heading">' . $args['heading'] . '</h4>';
61 61
 			}
62 62
 
63 63
 			// icon
64
-			if ( ! empty( $icon) ) {
65
-				$output .= $icon." ";
64
+			if (!empty($icon)) {
65
+				$output .= $icon . " ";
66 66
 			}
67 67
 
68 68
 			// content
69 69
 			$output .= $args['content'];
70 70
 
71 71
 			// dismissible
72
-			if($args['dismissible']){
72
+			if ($args['dismissible']) {
73 73
 				$output .= '<button type="button" class="close" data-dismiss="alert" aria-label="Close">';
74 74
 				$output .= '<span aria-hidden="true">&times;</span>';
75 75
 				$output .= '</button>';
76 76
 			}
77 77
 
78 78
 			// footer
79
-			if ( ! empty( $args['footer'] ) ) {
79
+			if (!empty($args['footer'])) {
80 80
 				$output .= '<hr>';
81 81
 				$output .= '<p class="mb-0">' . $args['footer'] . '</p>';
82 82
 			}
Please login to merge, or discard this patch.
Braces   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -42,10 +42,7 @@
 block discarded – undo
42 42
 
43 43
 			// set default icon
44 44
 			if(!$icon && $args['icon']!==false && $type){
45
-				if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';}
46
-				elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';}
47
-				elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';}
48
-				elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
45
+				if($type=='danger'){$icon = '<i class="fas fa-exclamation-circle"></i>';} elseif($type=='warning'){$icon = '<i class="fas fa-exclamation-triangle"></i>';} elseif($type=='success'){$icon = '<i class="fas fa-check-circle"></i>';} elseif($type=='info'){$icon = '<i class="fas fa-info-circle"></i>';}
49 46
 			}
50 47
 
51 48
 			$data = '';
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-dropdown.php 3 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,62 +11,62 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Dropdown {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'button',
24
-			'href'       => '#',
25
-			'class'      => 'btn btn-primary dropdown-toggle',
26
-			'wrapper_class' => '',
27
-			'dropdown_menu_class' => '',
28
-			'id'         => '',
29
-			'title'      => '',
30
-			'value'      => '',
31
-			'content'    => '',
32
-			'icon'       => '',
33
-			'hover_content' => '',
34
-			'hover_icon'    => '',
35
-			'data-toggle'   => 'dropdown',
36
-			'aria-haspopup' => 'true',
37
-			'aria-expanded' => 'false',
38
-			'dropdown_menu'          => '', // unescaped html menu (non-preferred way)
39
-			'dropdown_items'          => array(), // array of AUI calls
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'button',
24
+            'href'       => '#',
25
+            'class'      => 'btn btn-primary dropdown-toggle',
26
+            'wrapper_class' => '',
27
+            'dropdown_menu_class' => '',
28
+            'id'         => '',
29
+            'title'      => '',
30
+            'value'      => '',
31
+            'content'    => '',
32
+            'icon'       => '',
33
+            'hover_content' => '',
34
+            'hover_icon'    => '',
35
+            'data-toggle'   => 'dropdown',
36
+            'aria-haspopup' => 'true',
37
+            'aria-expanded' => 'false',
38
+            'dropdown_menu'          => '', // unescaped html menu (non-preferred way)
39
+            'dropdown_items'          => array(), // array of AUI calls
40 40
 
41
-		);
41
+        );
42 42
 
43
-		/**
44
-		 * Parse incoming $args into an array and merge it with $defaults
45
-		 */
46
-		$args   = wp_parse_args( $args, $defaults );
47
-		$output = '';
48
-		if ( ! empty( $args['type'] ) ) {
49
-			// wrapper open
50
-			$output .= '<div class="dropdown '.AUI_Component_Helper::esc_classes($args['wrapper_class']).'">';
43
+        /**
44
+         * Parse incoming $args into an array and merge it with $defaults
45
+         */
46
+        $args   = wp_parse_args( $args, $defaults );
47
+        $output = '';
48
+        if ( ! empty( $args['type'] ) ) {
49
+            // wrapper open
50
+            $output .= '<div class="dropdown '.AUI_Component_Helper::esc_classes($args['wrapper_class']).'">';
51 51
 
52
-			// button part
53
-			$output .= aui()->button($args);
52
+            // button part
53
+            $output .= aui()->button($args);
54 54
 
55
-			// dropdown-menu
56
-			if(!empty($args['dropdown_menu'])){
57
-				$output .= $args['dropdown_menu'];
58
-			}elseif(!empty($args['dropdown_items'])){
59
-				$output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">';
60
-				$output .= aui()->render($args['dropdown_items']);
61
-				$output .= '</div>';
62
-			}
55
+            // dropdown-menu
56
+            if(!empty($args['dropdown_menu'])){
57
+                $output .= $args['dropdown_menu'];
58
+            }elseif(!empty($args['dropdown_items'])){
59
+                $output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">';
60
+                $output .= aui()->render($args['dropdown_items']);
61
+                $output .= '</div>';
62
+            }
63 63
 
64
-			// wrapper close
65
-			$output .= '</div>';
64
+            // wrapper close
65
+            $output .= '</div>';
66 66
 
67
-		}
67
+        }
68 68
 
69
-		return $output;
70
-	}
69
+        return $output;
70
+    }
71 71
 
72 72
 }
73 73
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function get($args = array()){
21
+	public static function get($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'button',
24 24
 			'href'       => '#',
@@ -43,20 +43,20 @@  discard block
 block discarded – undo
43 43
 		/**
44 44
 		 * Parse incoming $args into an array and merge it with $defaults
45 45
 		 */
46
-		$args   = wp_parse_args( $args, $defaults );
46
+		$args   = wp_parse_args($args, $defaults);
47 47
 		$output = '';
48
-		if ( ! empty( $args['type'] ) ) {
48
+		if (!empty($args['type'])) {
49 49
 			// wrapper open
50
-			$output .= '<div class="dropdown '.AUI_Component_Helper::esc_classes($args['wrapper_class']).'">';
50
+			$output .= '<div class="dropdown ' . AUI_Component_Helper::esc_classes($args['wrapper_class']) . '">';
51 51
 
52 52
 			// button part
53 53
 			$output .= aui()->button($args);
54 54
 
55 55
 			// dropdown-menu
56
-			if(!empty($args['dropdown_menu'])){
56
+			if (!empty($args['dropdown_menu'])) {
57 57
 				$output .= $args['dropdown_menu'];
58
-			}elseif(!empty($args['dropdown_items'])){
59
-				$output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">';
58
+			}elseif (!empty($args['dropdown_items'])) {
59
+				$output .= '<div class="dropdown-menu ' . AUI_Component_Helper::esc_classes($args['dropdown_menu_class']) . '" aria-labelledby="' . sanitize_html_class($args['id']) . '">';
60 60
 				$output .= aui()->render($args['dropdown_items']);
61 61
 				$output .= '</div>';
62 62
 			}
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
 			// dropdown-menu
56 56
 			if(!empty($args['dropdown_menu'])){
57 57
 				$output .= $args['dropdown_menu'];
58
-			}elseif(!empty($args['dropdown_items'])){
58
+			} elseif(!empty($args['dropdown_items'])){
59 59
 				$output .= '<div class="dropdown-menu '.AUI_Component_Helper::esc_classes($args['dropdown_menu_class']).'" aria-labelledby="'.sanitize_html_class($args['id']).'">';
60 60
 				$output .= aui()->render($args['dropdown_items']);
61 61
 				$output .= '</div>';
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/example-plugin.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -16,132 +16,132 @@
 block discarded – undo
16 16
 
17 17
 // If this file is called directly, abort.
18 18
 if ( ! defined( 'WPINC' ) ) {
19
-	die;
19
+    die;
20 20
 }
21 21
 
22 22
 class AyeCode_UI_Plugin {
23 23
 
24
-	/**
25
-	 * AUI Plugin constructor.
26
-	 *
27
-	 * @since 1.0.0
28
-	 */
29
-	public function __construct() {
30
-
31
-		// load AUI
32
-		require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
33
-
34
-		// Maybe show example page
35
-		add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
36
-	}
37
-
38
-	public function maybe_show_examples(){
39
-		if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
40
-			echo "<head>";
41
-			wp_head();
42
-			echo "</head>";
43
-			echo "<body>";
44
-			echo $this->get_examples();
45
-			echo "</body>";
46
-			exit;
47
-		}
48
-	}
49
-
50
-	public function get_examples(){
51
-		$output = '';
52
-
53
-
54
-		// open form
55
-		$output .= "<form class='p-5 m-5 border rounded'>";
56
-
57
-		// input example
58
-		$output .= aui()->input(array(
59
-			'type'  =>  'text',
60
-			'id'    =>  'text-example',
61
-			'name'    =>  'text-example',
62
-			'placeholder'   => 'text placeholder',
63
-			'title'   => 'Text input example',
64
-			'value' =>  '',
65
-			'required'  => false,
66
-			'help_text' => 'help text',
67
-			'label' => 'Text input example label'
68
-		));
69
-
70
-		// input example
71
-		$output .= aui()->input(array(
72
-			'type'  =>  'url',
73
-			'id'    =>  'text-example2',
74
-			'name'    =>  'text-example',
75
-			'placeholder'   => 'url placeholder',
76
-			'title'   => 'Text input example',
77
-			'value' =>  '',
78
-			'required'  => false,
79
-			'help_text' => 'help text',
80
-			'label' => 'Text input example label'
81
-		));
82
-
83
-		// checkbox example
84
-		$output .= aui()->input(array(
85
-			'type'  =>  'checkbox',
86
-			'id'    =>  'checkbox-example',
87
-			'name'    =>  'checkbox-example',
88
-			'placeholder'   => 'checkbox-example',
89
-			'title'   => 'Checkbox example',
90
-			'value' =>  '1',
91
-			'checked'   => true,
92
-			'required'  => false,
93
-			'help_text' => 'help text',
94
-			'label' => 'Checkbox checked'
95
-		));
96
-
97
-		// checkbox example
98
-		$output .= aui()->input(array(
99
-			'type'  =>  'checkbox',
100
-			'id'    =>  'checkbox-example2',
101
-			'name'    =>  'checkbox-example2',
102
-			'placeholder'   => 'checkbox-example',
103
-			'title'   => 'Checkbox example',
104
-			'value' =>  '1',
105
-			'checked'   => false,
106
-			'required'  => false,
107
-			'help_text' => 'help text',
108
-			'label' => 'Checkbox un-checked'
109
-		));
110
-
111
-		// switch example
112
-		$output .= aui()->input(array(
113
-			'type'  =>  'checkbox',
114
-			'id'    =>  'switch-example',
115
-			'name'    =>  'switch-example',
116
-			'placeholder'   => 'checkbox-example',
117
-			'title'   => 'Switch example',
118
-			'value' =>  '1',
119
-			'checked'   => true,
120
-			'switch'    => true,
121
-			'required'  => false,
122
-			'help_text' => 'help text',
123
-			'label' => 'Switch on'
124
-		));
125
-
126
-		// switch example
127
-		$output .= aui()->input(array(
128
-			'type'  =>  'checkbox',
129
-			'id'    =>  'switch-example2',
130
-			'name'    =>  'switch-example2',
131
-			'placeholder'   => 'checkbox-example',
132
-			'title'   => 'Switch example',
133
-			'value' =>  '1',
134
-			'checked'   => false,
135
-			'switch'    => true,
136
-			'required'  => false,
137
-			'help_text' => 'help text',
138
-			'label' => 'Switch off'
139
-		));
140
-
141
-		// close form
142
-		$output .= "</form>";
143
-
144
-		return $output;
145
-	}
24
+    /**
25
+     * AUI Plugin constructor.
26
+     *
27
+     * @since 1.0.0
28
+     */
29
+    public function __construct() {
30
+
31
+        // load AUI
32
+        require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
33
+
34
+        // Maybe show example page
35
+        add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
36
+    }
37
+
38
+    public function maybe_show_examples(){
39
+        if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
40
+            echo "<head>";
41
+            wp_head();
42
+            echo "</head>";
43
+            echo "<body>";
44
+            echo $this->get_examples();
45
+            echo "</body>";
46
+            exit;
47
+        }
48
+    }
49
+
50
+    public function get_examples(){
51
+        $output = '';
52
+
53
+
54
+        // open form
55
+        $output .= "<form class='p-5 m-5 border rounded'>";
56
+
57
+        // input example
58
+        $output .= aui()->input(array(
59
+            'type'  =>  'text',
60
+            'id'    =>  'text-example',
61
+            'name'    =>  'text-example',
62
+            'placeholder'   => 'text placeholder',
63
+            'title'   => 'Text input example',
64
+            'value' =>  '',
65
+            'required'  => false,
66
+            'help_text' => 'help text',
67
+            'label' => 'Text input example label'
68
+        ));
69
+
70
+        // input example
71
+        $output .= aui()->input(array(
72
+            'type'  =>  'url',
73
+            'id'    =>  'text-example2',
74
+            'name'    =>  'text-example',
75
+            'placeholder'   => 'url placeholder',
76
+            'title'   => 'Text input example',
77
+            'value' =>  '',
78
+            'required'  => false,
79
+            'help_text' => 'help text',
80
+            'label' => 'Text input example label'
81
+        ));
82
+
83
+        // checkbox example
84
+        $output .= aui()->input(array(
85
+            'type'  =>  'checkbox',
86
+            'id'    =>  'checkbox-example',
87
+            'name'    =>  'checkbox-example',
88
+            'placeholder'   => 'checkbox-example',
89
+            'title'   => 'Checkbox example',
90
+            'value' =>  '1',
91
+            'checked'   => true,
92
+            'required'  => false,
93
+            'help_text' => 'help text',
94
+            'label' => 'Checkbox checked'
95
+        ));
96
+
97
+        // checkbox example
98
+        $output .= aui()->input(array(
99
+            'type'  =>  'checkbox',
100
+            'id'    =>  'checkbox-example2',
101
+            'name'    =>  'checkbox-example2',
102
+            'placeholder'   => 'checkbox-example',
103
+            'title'   => 'Checkbox example',
104
+            'value' =>  '1',
105
+            'checked'   => false,
106
+            'required'  => false,
107
+            'help_text' => 'help text',
108
+            'label' => 'Checkbox un-checked'
109
+        ));
110
+
111
+        // switch example
112
+        $output .= aui()->input(array(
113
+            'type'  =>  'checkbox',
114
+            'id'    =>  'switch-example',
115
+            'name'    =>  'switch-example',
116
+            'placeholder'   => 'checkbox-example',
117
+            'title'   => 'Switch example',
118
+            'value' =>  '1',
119
+            'checked'   => true,
120
+            'switch'    => true,
121
+            'required'  => false,
122
+            'help_text' => 'help text',
123
+            'label' => 'Switch on'
124
+        ));
125
+
126
+        // switch example
127
+        $output .= aui()->input(array(
128
+            'type'  =>  'checkbox',
129
+            'id'    =>  'switch-example2',
130
+            'name'    =>  'switch-example2',
131
+            'placeholder'   => 'checkbox-example',
132
+            'title'   => 'Switch example',
133
+            'value' =>  '1',
134
+            'checked'   => false,
135
+            'switch'    => true,
136
+            'required'  => false,
137
+            'help_text' => 'help text',
138
+            'label' => 'Switch off'
139
+        ));
140
+
141
+        // close form
142
+        $output .= "</form>";
143
+
144
+        return $output;
145
+    }
146 146
 }
147 147
 new AyeCode_UI_Plugin();
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 */
16 16
 
17 17
 // If this file is called directly, abort.
18
-if ( ! defined( 'WPINC' ) ) {
18
+if (!defined('WPINC')) {
19 19
 	die;
20 20
 }
21 21
 
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
 	public function __construct() {
30 30
 
31 31
 		// load AUI
32
-		require_once( dirname( __FILE__ ) . '/ayecode-ui-loader.php' );
32
+		require_once(dirname(__FILE__) . '/ayecode-ui-loader.php');
33 33
 
34 34
 		// Maybe show example page
35
-		add_action( 'template_redirect', array( $this,'maybe_show_examples' ) );
35
+		add_action('template_redirect', array($this, 'maybe_show_examples'));
36 36
 	}
37 37
 
38
-	public function maybe_show_examples(){
39
-		if(current_user_can('manage_options') && isset($_REQUEST['preview-aui'])){
38
+	public function maybe_show_examples() {
39
+		if (current_user_can('manage_options') && isset($_REQUEST['preview-aui'])) {
40 40
 			echo "<head>";
41 41
 			wp_head();
42 42
 			echo "</head>";
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 	}
49 49
 
50
-	public function get_examples(){
50
+	public function get_examples() {
51 51
 		$output = '';
52 52
 
53 53
 
Please login to merge, or discard this patch.