@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * Main controller file for product mass modification module |
| 4 | 4 | * |
@@ -28,56 +28,56 @@ discard block |
||
| 28 | 28 | * |
| 29 | 29 | * @return string The template file path to use |
| 30 | 30 | */ |
| 31 | - public static function get_template_part( $plugin_dir_name, $main_template_dir, $side, $slug, $name=null, $debug = null ) { |
|
| 31 | + public static function get_template_part($plugin_dir_name, $main_template_dir, $side, $slug, $name = null, $debug = null) { |
|
| 32 | 32 | $path = ''; |
| 33 | 33 | |
| 34 | 34 | $templates = array(); |
| 35 | 35 | $name = (string)$name; |
| 36 | - if ( '' !== $name ) |
|
| 36 | + if ('' !== $name) |
|
| 37 | 37 | $templates[] = "{$side}/{$slug}-{$name}.php"; |
| 38 | 38 | $templates[] = "{$side}/{$slug}.php"; |
| 39 | 39 | |
| 40 | 40 | /** Check if required template exists into current theme */ |
| 41 | 41 | $check_theme_template = array(); |
| 42 | - foreach ( $templates as $template ) { |
|
| 42 | + foreach ($templates as $template) { |
|
| 43 | 43 | $check_theme_template = $plugin_dir_name . "/" . $template; |
| 44 | - $path = locate_template( $check_theme_template, false ); |
|
| 45 | - if( !empty($path) ) { |
|
| 44 | + $path = locate_template($check_theme_template, false); |
|
| 45 | + if (!empty($path)) { |
|
| 46 | 46 | break; |
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** Allow debugging */ |
| 51 | - if ( !empty( $debug ) ) { |
|
| 51 | + if (!empty($debug)) { |
|
| 52 | 52 | echo '--- Debug mode ON - Start ---<br/>'; |
| 53 | 53 | echo __FILE__ . '<br/>'; |
| 54 | 54 | echo 'Debug for display method<br/>'; |
| 55 | 55 | echo 'Asked path ' . $path . '<br/>'; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if ( empty( $path ) ) { |
|
| 59 | - foreach ( (array) $templates as $template_name ) { |
|
| 60 | - if ( !$template_name ) |
|
| 58 | + if (empty($path)) { |
|
| 59 | + foreach ((array)$templates as $template_name) { |
|
| 60 | + if (!$template_name) |
|
| 61 | 61 | continue; |
| 62 | 62 | |
| 63 | - if ( !empty( $debug ) ) { |
|
| 63 | + if (!empty($debug)) { |
|
| 64 | 64 | echo __LINE__ . ' - ' . $main_template_dir . $template_name . '<hr/>'; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - $file_exists = file_exists( $main_template_dir . $template_name ); |
|
| 68 | - if ( $file_exists ) { |
|
| 67 | + $file_exists = file_exists($main_template_dir . $template_name); |
|
| 68 | + if ($file_exists) { |
|
| 69 | 69 | $path = $main_template_dir . $template_name; |
| 70 | 70 | break; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if ( !empty( $debug ) ) { |
|
| 73 | + if (!empty($debug)) { |
|
| 74 | 74 | echo __LINE__ . ' - ' . (bool)$file_exists . '<hr/>'; |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** Allow debugging */ |
| 80 | - if ( !empty( $debug ) ) { |
|
| 80 | + if (!empty($debug)) { |
|
| 81 | 81 | echo '--- Debug mode ON - END ---<br/><br/>'; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @return mixed $sanitizedVar The var after treatment |
| 102 | 102 | */ |
| 103 | 103 | public static function varSanitizer($varToSanitize, $varDefaultValue = '', $varType = '') { |
| 104 | - $sanitizedVar = is_string( $varToSanitize ) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue ; |
|
| 104 | + $sanitizedVar = is_string($varToSanitize) && (trim(strip_tags(stripslashes($varToSanitize))) != '') ? trim(strip_tags(stripslashes(($varToSanitize)))) : $varDefaultValue; |
|
| 105 | 105 | |
| 106 | 106 | return $sanitizedVar; |
| 107 | 107 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | public static function forceDownload($Fichier_a_telecharger, $delete_after_download = false) { |
| 115 | 115 | |
| 116 | 116 | $nom_fichier = basename($Fichier_a_telecharger); |
| 117 | - switch(strrchr($nom_fichier, ".")) { |
|
| 117 | + switch (strrchr($nom_fichier, ".")) { |
|
| 118 | 118 | case ".gz": $type = "application/x-gzip"; break; |
| 119 | 119 | case ".tgz": $type = "application/x-gzip"; break; |
| 120 | 120 | case ".zip": $type = "application/zip"; break; |
@@ -131,14 +131,14 @@ discard block |
||
| 131 | 131 | header("Content-disposition: attachment; filename=$nom_fichier"); |
| 132 | 132 | header("Content-Type: application/force-download"); |
| 133 | 133 | header("Content-Transfer-Encoding: $type\n"); // Surtout ne pas enlever le \n |
| 134 | - header("Content-Length: ".filesize($Fichier_a_telecharger)); |
|
| 134 | + header("Content-Length: " . filesize($Fichier_a_telecharger)); |
|
| 135 | 135 | header("Pragma: no-cache"); |
| 136 | 136 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0, public"); |
| 137 | 137 | header("Expires: 0"); |
| 138 | 138 | ob_end_clean(); |
| 139 | 139 | readfile($Fichier_a_telecharger); |
| 140 | - if ( $delete_after_download ) { |
|
| 141 | - unlink( $Fichier_a_telecharger ); |
|
| 140 | + if ($delete_after_download) { |
|
| 141 | + unlink($Fichier_a_telecharger); |
|
| 142 | 142 | } |
| 143 | 143 | exit; |
| 144 | 144 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @return boolean |
| 149 | 149 | */ |
| 150 | 150 | public static function is_sendsms_actived() { |
| 151 | - if(is_plugin_active('wordpress-send-sms/Send-SMS.php')) { |
|
| 151 | + if (is_plugin_active('wordpress-send-sms/Send-SMS.php')) { |
|
| 152 | 152 | $configOption = get_option('sendsms_config', ''); |
| 153 | 153 | $ligne = unserialize($configOption); |
| 154 | 154 | $nicOVH = $ligne['nicOVH']; |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | * @param unknown_type $input |
| 166 | 166 | * @return Ambigous <multitype:, multitype:multitype:unknown > |
| 167 | 167 | */ |
| 168 | - public static function search_all_possibilities( $input ) { |
|
| 168 | + public static function search_all_possibilities($input) { |
|
| 169 | 169 | $result = array(); |
| 170 | 170 | |
| 171 | 171 | while (list($key, $values) = each($input)) { |
@@ -174,17 +174,17 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | if (empty($result)) { |
| 177 | - foreach($values as $value) { |
|
| 177 | + foreach ($values as $value) { |
|
| 178 | 178 | $result[] = array($key => $value); |
| 179 | 179 | } |
| 180 | 180 | } |
| 181 | 181 | else { |
| 182 | 182 | $append = array(); |
| 183 | - foreach($result as &$product) { |
|
| 183 | + foreach ($result as &$product) { |
|
| 184 | 184 | $product[$key] = array_shift($values); |
| 185 | 185 | $copy = $product; |
| 186 | 186 | |
| 187 | - foreach($values as $item) { |
|
| 187 | + foreach ($values as $item) { |
|
| 188 | 188 | $copy[$key] = $item; |
| 189 | 189 | $append[] = $copy; |
| 190 | 190 | } |
@@ -204,14 +204,14 @@ discard block |
||
| 204 | 204 | * @param boolean $code : false return sigle, true return code (€ or EUR) |
| 205 | 205 | * @return string currency code or sigle |
| 206 | 206 | */ |
| 207 | - public static function wpshop_get_currency($code=false) { |
|
| 207 | + public static function wpshop_get_currency($code = false) { |
|
| 208 | 208 | // Currency |
| 209 | 209 | global $wpdb; |
| 210 | 210 | $current_currency = get_option('wpshop_shop_default_currency'); |
| 211 | - $query = $wpdb->prepare('SELECT * FROM ' .WPSHOP_DBT_ATTRIBUTE_UNIT. ' WHERE id =%d ', $current_currency ); |
|
| 212 | - $currency_infos = $wpdb->get_row( $query ); |
|
| 213 | - if ( !empty($currency_infos) ) { |
|
| 214 | - $code = ($code) ? $currency_infos->name : $currency_infos->unit; |
|
| 211 | + $query = $wpdb->prepare('SELECT * FROM ' . WPSHOP_DBT_ATTRIBUTE_UNIT . ' WHERE id =%d ', $current_currency); |
|
| 212 | + $currency_infos = $wpdb->get_row($query); |
|
| 213 | + if (!empty($currency_infos)) { |
|
| 214 | + $code = ($code) ? $currency_infos->name : $currency_infos->unit; |
|
| 215 | 215 | return $code; |
| 216 | 216 | } |
| 217 | 217 | else { |
@@ -227,11 +227,11 @@ discard block |
||
| 227 | 227 | public static function wpshop_get_sigle($code, $column_to_return = "unit") { |
| 228 | 228 | $tmp_code = (int)$code; |
| 229 | 229 | $key_to_get = 'name'; |
| 230 | - if ( is_int($tmp_code) && !empty($tmp_code) ) { |
|
| 230 | + if (is_int($tmp_code) && !empty($tmp_code)) { |
|
| 231 | 231 | $key_to_get = 'id'; |
| 232 | 232 | } |
| 233 | 233 | $old_way_currencies = unserialize(WPSHOP_SHOP_CURRENCIES); |
| 234 | - if ( array_key_exists( $code, $old_way_currencies)) { |
|
| 234 | + if (array_key_exists($code, $old_way_currencies)) { |
|
| 235 | 235 | $code = $old_way_currencies[$code]; |
| 236 | 236 | $key_to_get = 'name'; |
| 237 | 237 | } |
@@ -246,7 +246,7 @@ discard block |
||
| 246 | 246 | * @param string $var : variable to clean |
| 247 | 247 | * @return string |
| 248 | 248 | */ |
| 249 | - public static function wpshop_clean( $var ) { |
|
| 249 | + public static function wpshop_clean($var) { |
|
| 250 | 250 | return trim(strip_tags(stripslashes($var))); |
| 251 | 251 | } |
| 252 | 252 | |
@@ -255,8 +255,8 @@ discard block |
||
| 255 | 255 | * @param string phone number |
| 256 | 256 | * @return boolean |
| 257 | 257 | */ |
| 258 | - public static function is_phone( $phone ) { |
|
| 259 | - return preg_match( '/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone ); |
|
| 258 | + public static function is_phone($phone) { |
|
| 259 | + return preg_match('/(?=.*[0-9])([ 0-9\-\+\(\)]+)/', $phone); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -264,8 +264,8 @@ discard block |
||
| 264 | 264 | * @param string postcode |
| 265 | 265 | * @return boolean |
| 266 | 266 | */ |
| 267 | - public static function is_postcode( $postcode ) { |
|
| 268 | - return preg_match( '/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode ); |
|
| 267 | + public static function is_postcode($postcode) { |
|
| 268 | + return preg_match('/(?=.*[0-9A-Za-z])([ \-A-Za-z0-9]+)/', $postcode); |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | /** |
@@ -275,14 +275,14 @@ discard block |
||
| 275 | 275 | * |
| 276 | 276 | * @return string $type The form input type to use for the given field |
| 277 | 277 | */ |
| 278 | - public static function defineFieldType($dataFieldType, $input_type, $frontend_verification){ |
|
| 278 | + public static function defineFieldType($dataFieldType, $input_type, $frontend_verification) { |
|
| 279 | 279 | $type = 'text'; |
| 280 | 280 | |
| 281 | - if ( $dataFieldType == 'datetime' ) { |
|
| 281 | + if ($dataFieldType == 'datetime') { |
|
| 282 | 282 | $type = 'text'; |
| 283 | 283 | } |
| 284 | 284 | else { |
| 285 | - switch ( $frontend_verification ) { |
|
| 285 | + switch ($frontend_verification) { |
|
| 286 | 286 | case 'phone': |
| 287 | 287 | $type = 'tel'; |
| 288 | 288 | break; |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | * |
| 303 | 303 | * @return array The different element send by request method |
| 304 | 304 | */ |
| 305 | - public static function getMethode(){ |
|
| 305 | + public static function getMethode() { |
|
| 306 | 306 | $request_method = null; |
| 307 | 307 | if ($_SERVER["REQUEST_METHOD"] == "GET") { |
| 308 | 308 | $request_method = (array)$_GET; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | $request_method = (array)$_POST; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - if ( null === $request_method ) { |
|
| 314 | + if (null === $request_method) { |
|
| 315 | 315 | die ('Invalid REQUEST_METHOD (not GET, not POST).'); |
| 316 | 316 | } |
| 317 | 317 | else { |
@@ -327,36 +327,36 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @return string $slugified The input string that was slugified with the selected method |
| 329 | 329 | */ |
| 330 | - public static function slugify($toSlugify, $slugifyType){ |
|
| 330 | + public static function slugify($toSlugify, $slugifyType) { |
|
| 331 | 331 | $slugified = ''; |
| 332 | 332 | |
| 333 | - if($toSlugify != '') |
|
| 333 | + if ($toSlugify != '') |
|
| 334 | 334 | { |
| 335 | 335 | $slugified = $toSlugify; |
| 336 | - foreach($slugifyType as $type) |
|
| 336 | + foreach ($slugifyType as $type) |
|
| 337 | 337 | { |
| 338 | - if($type == 'noAccent') |
|
| 338 | + if ($type == 'noAccent') |
|
| 339 | 339 | { |
| 340 | - $pattern = array("/é/", "/è/", "/ê/", "/ç/", "/à/", "/â/", "/î/", "/ï/", "/û/", "/ô/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ö/", "/Ù/", "/Û/", "/Ü/","/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/"); |
|
| 341 | - $rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U","e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U"); |
|
| 340 | + $pattern = array("/é/", "/è/", "/ê/", "/ç/", "/à/", "/â/", "/î/", "/ï/", "/û/", "/ô/", "/È/", "/É/", "/Ê/", "/Ë/", "/Ì/", "/Í/", "/Î/", "/Ï/", "/Ö/", "/Ù/", "/Û/", "/Ü/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/", "/�/"); |
|
| 341 | + $rep_pat = array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U", "e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "E", "E", "E", "E", "I", "I", "I", "I", "O", "U", "U", "U"); |
|
| 342 | 342 | } |
| 343 | - elseif($type == 'noSpaces') |
|
| 343 | + elseif ($type == 'noSpaces') |
|
| 344 | 344 | { |
| 345 | 345 | $pattern = array('/\s/'); |
| 346 | 346 | $rep_pat = array('_'); |
| 347 | 347 | $slugified = trim($slugified); |
| 348 | 348 | } |
| 349 | - elseif($type == 'lowerCase') |
|
| 349 | + elseif ($type == 'lowerCase') |
|
| 350 | 350 | { |
| 351 | 351 | $slugified = strtolower($slugified); |
| 352 | 352 | } |
| 353 | - elseif($type == 'noPunctuation') |
|
| 353 | + elseif ($type == 'noPunctuation') |
|
| 354 | 354 | { |
| 355 | 355 | $pattern = array("/#/", "/\{/", "/\[/", "/\(/", "/\)/", "/\]/", "/\}/", "/&/", "/~/", "/�/", "/`/", "/\^/", "/@/", "/=/", "/�/", "/�/", "/%/", "/�/", "/!/", "/�/", "/:/", "/\$/", "/;/", "/\./", "/,/", "/\?/", "/\\\/", "/\//"); |
| 356 | 356 | $rep_pat = array("_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_", "_"); |
| 357 | 357 | } |
| 358 | 358 | |
| 359 | - if(is_array($pattern) && is_array($rep_pat)) |
|
| 359 | + if (is_array($pattern) && is_array($rep_pat)) |
|
| 360 | 360 | { |
| 361 | 361 | $slugified = preg_replace($pattern, $rep_pat, utf8_decode($slugified)); |
| 362 | 362 | } |
@@ -375,17 +375,17 @@ discard block |
||
| 375 | 375 | * @return string $string The output string that was trunk if necessary |
| 376 | 376 | */ |
| 377 | 377 | public static function trunk($string, $maxlength) { |
| 378 | - if(strlen($string)>$maxlength+3) |
|
| 379 | - return substr($string,0,$maxlength).'...'; |
|
| 378 | + if (strlen($string) > $maxlength + 3) |
|
| 379 | + return substr($string, 0, $maxlength) . '...'; |
|
| 380 | 380 | else return $string; |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | /** |
| 384 | 384 | * Run a safe redirect in javascript |
| 385 | 385 | */ |
| 386 | - public static function wpshop_safe_redirect($url='') { |
|
| 387 | - $url = empty($url) ? admin_url('admin.php?page='.WPSHOP_URL_SLUG_DASHBOARD) : $url; |
|
| 388 | - echo '<script type="text/javascript">window.top.location.href = "'.$url.'"</script>'; |
|
| 386 | + public static function wpshop_safe_redirect($url = '') { |
|
| 387 | + $url = empty($url) ? admin_url('admin.php?page=' . WPSHOP_URL_SLUG_DASHBOARD) : $url; |
|
| 388 | + echo '<script type="text/javascript">window.top.location.href = "' . $url . '"</script>'; |
|
| 389 | 389 | exit; |
| 390 | 390 | } |
| 391 | 391 | |
@@ -395,9 +395,9 @@ discard block |
||
| 395 | 395 | * @param array $args : Hook arguments |
| 396 | 396 | * @return string |
| 397 | 397 | */ |
| 398 | - public static function create_custom_hook ($hook_name, $args = '') { |
|
| 398 | + public static function create_custom_hook($hook_name, $args = '') { |
|
| 399 | 399 | ob_start(); |
| 400 | - if ( !empty($args) ) { |
|
| 400 | + if (!empty($args)) { |
|
| 401 | 401 | do_action($hook_name, $args); |
| 402 | 402 | } |
| 403 | 403 | else { |
@@ -416,16 +416,16 @@ discard block |
||
| 416 | 416 | */ |
| 417 | 417 | public static function get_plugin_validation_code($plugin_name, $encrypt_base_attribute) { |
| 418 | 418 | $code = ''; |
| 419 | - if ( !function_exists( 'get_plugin_data') ) |
|
| 420 | - require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
|
| 421 | - $plug = get_plugin_data( WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php' ); |
|
| 419 | + if (!function_exists('get_plugin_data')) |
|
| 420 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
| 421 | + $plug = get_plugin_data(WP_PLUGIN_DIR . '/' . WPSHOP_PLUGIN_DIR . '/wpshop.php'); |
|
| 422 | 422 | $code_part = array(); |
| 423 | - $code_part[] = substr(hash ( "sha256" , $plugin_name ), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 424 | - $code_part[] = substr(hash ( "sha256" , $plug['Name'] ), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 425 | - $code_part[] = substr(hash ( "sha256" , 'addons' ), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 423 | + $code_part[] = substr(hash("sha256", $plugin_name), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 424 | + $code_part[] = substr(hash("sha256", $plug['Name']), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 425 | + $code_part[] = substr(hash("sha256", 'addons'), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 426 | 426 | $code = $code_part[1] . '-' . $code_part[2] . '-' . $code_part[0]; |
| 427 | 427 | $att = $encrypt_base_attribute; |
| 428 | - $code .= '-' . substr(hash ( "sha256" , $att ), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 428 | + $code .= '-' . substr(hash("sha256", $att), WPSHOP_ADDONS_KEY_IS, 5); |
|
| 429 | 429 | |
| 430 | 430 | return $code; |
| 431 | 431 | } |
@@ -436,15 +436,15 @@ discard block |
||
| 436 | 436 | * @param string $encrypt_base_attribute |
| 437 | 437 | * @return boolean |
| 438 | 438 | */ |
| 439 | - public static function check_plugin_activation_code( $plugin_name, $encrypt_base_attribute, $from = 'file') { |
|
| 439 | + public static function check_plugin_activation_code($plugin_name, $encrypt_base_attribute, $from = 'file') { |
|
| 440 | 440 | $is_valid = false; |
| 441 | 441 | $valid_activation_code = self::get_plugin_validation_code($plugin_name, $encrypt_base_attribute); |
| 442 | - $activation_code_filename = WP_PLUGIN_DIR .'/'. $plugin_name.'/encoder.txt'; |
|
| 443 | - if ( is_file($activation_code_filename) ) { |
|
| 444 | - $activation_code_file = fopen($activation_code_filename, 'r' ); |
|
| 445 | - if ( $activation_code_file !== false) { |
|
| 446 | - $activation_code = fread( $activation_code_file, filesize($activation_code_filename)); |
|
| 447 | - if ( $activation_code == $valid_activation_code ) { |
|
| 442 | + $activation_code_filename = WP_PLUGIN_DIR . '/' . $plugin_name . '/encoder.txt'; |
|
| 443 | + if (is_file($activation_code_filename)) { |
|
| 444 | + $activation_code_file = fopen($activation_code_filename, 'r'); |
|
| 445 | + if ($activation_code_file !== false) { |
|
| 446 | + $activation_code = fread($activation_code_file, filesize($activation_code_filename)); |
|
| 447 | + if ($activation_code == $valid_activation_code) { |
|
| 448 | 448 | $is_valid = true; |
| 449 | 449 | } |
| 450 | 450 | } |
@@ -457,12 +457,12 @@ discard block |
||
| 457 | 457 | * @param unknown_type $number |
| 458 | 458 | * @return string |
| 459 | 459 | */ |
| 460 | - public static function formate_number( $number ) { |
|
| 461 | - $number = number_format( $number, 2, '.', '' ); |
|
| 462 | - $exploded_number = explode( '.', $number ); |
|
| 460 | + public static function formate_number($number) { |
|
| 461 | + $number = number_format($number, 2, '.', ''); |
|
| 462 | + $exploded_number = explode('.', $number); |
|
| 463 | 463 | $number = $exploded_number[0]; |
| 464 | - if( $exploded_number[1] != '00' ) { |
|
| 465 | - $number .= '<span class="wps_number_cents">,' . $exploded_number[1]. '</span>'; |
|
| 464 | + if ($exploded_number[1] != '00') { |
|
| 465 | + $number .= '<span class="wps_number_cents">,' . $exploded_number[1] . '</span>'; |
|
| 466 | 466 | } |
| 467 | 467 | return $number; |
| 468 | 468 | } |
@@ -472,12 +472,12 @@ discard block |
||
| 472 | 472 | * @param int $page_id |
| 473 | 473 | * @return int |
| 474 | 474 | */ |
| 475 | - public static function get_page_id( $page_id ) { |
|
| 476 | - if( !empty($page_id) ) { |
|
| 477 | - if ( function_exists( 'icl_object_id' ) && defined('ICL_LANGUAGE_CODE') ) { |
|
| 478 | - $element_post_type = get_post_type( $page_id ); |
|
| 479 | - $translated_element_id = icl_object_id( $page_id, $element_post_type, true, ICL_LANGUAGE_CODE ); |
|
| 480 | - if( !empty($translated_element_id) ) { |
|
| 475 | + public static function get_page_id($page_id) { |
|
| 476 | + if (!empty($page_id)) { |
|
| 477 | + if (function_exists('icl_object_id') && defined('ICL_LANGUAGE_CODE')) { |
|
| 478 | + $element_post_type = get_post_type($page_id); |
|
| 479 | + $translated_element_id = icl_object_id($page_id, $element_post_type, true, ICL_LANGUAGE_CODE); |
|
| 480 | + if (!empty($translated_element_id)) { |
|
| 481 | 481 | $page_id = $translated_element_id; |
| 482 | 482 | } |
| 483 | 483 | } |
@@ -485,65 +485,65 @@ discard block |
||
| 485 | 485 | return $page_id; |
| 486 | 486 | } |
| 487 | 487 | |
| 488 | - public static function minutes_to_time( $minutes, $format = '%hh %imin' ) { |
|
| 489 | - $dtF = new \DateTime( '@0' ); |
|
| 490 | - $dtT = new \DateTime( '@' . ( $minutes * 60 ) ); |
|
| 491 | - return $dtF->diff($dtT)->format( $format ); |
|
| 488 | + public static function minutes_to_time($minutes, $format = '%hh %imin') { |
|
| 489 | + $dtF = new \DateTime('@0'); |
|
| 490 | + $dtT = new \DateTime('@' . ($minutes * 60)); |
|
| 491 | + return $dtF->diff($dtT)->format($format); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | public static function number_format_hack($n) { |
| 495 | 495 | return number_format($n, 5, '.', ''); |
| 496 | 496 | } |
| 497 | - public static function is_serialized( $data, $strict = true ) { |
|
| 498 | - if ( ! is_string( $data ) ) { |
|
| 497 | + public static function is_serialized($data, $strict = true) { |
|
| 498 | + if (!is_string($data)) { |
|
| 499 | 499 | return false; |
| 500 | 500 | } |
| 501 | - $data = trim( $data ); |
|
| 502 | - if ( 'N;' == $data ) { |
|
| 501 | + $data = trim($data); |
|
| 502 | + if ('N;' == $data) { |
|
| 503 | 503 | return true; |
| 504 | 504 | } |
| 505 | - if ( strlen( $data ) < 4 ) { |
|
| 505 | + if (strlen($data) < 4) { |
|
| 506 | 506 | return false; |
| 507 | 507 | } |
| 508 | - if ( ':' !== $data[1] ) { |
|
| 508 | + if (':' !== $data[1]) { |
|
| 509 | 509 | return false; |
| 510 | 510 | } |
| 511 | - if ( $strict ) { |
|
| 512 | - $lastc = substr( $data, -1 ); |
|
| 513 | - if ( ';' !== $lastc && '}' !== $lastc ) { |
|
| 511 | + if ($strict) { |
|
| 512 | + $lastc = substr($data, -1); |
|
| 513 | + if (';' !== $lastc && '}' !== $lastc) { |
|
| 514 | 514 | return false; |
| 515 | 515 | } |
| 516 | 516 | } else { |
| 517 | - $semicolon = strpos( $data, ';' ); |
|
| 518 | - $brace = strpos( $data, '}' ); |
|
| 519 | - if ( false === $semicolon && false === $brace ) { |
|
| 517 | + $semicolon = strpos($data, ';'); |
|
| 518 | + $brace = strpos($data, '}'); |
|
| 519 | + if (false === $semicolon && false === $brace) { |
|
| 520 | 520 | return false; |
| 521 | 521 | } |
| 522 | - if ( false !== $semicolon && $semicolon < 3 ) { |
|
| 522 | + if (false !== $semicolon && $semicolon < 3) { |
|
| 523 | 523 | return false; |
| 524 | 524 | } |
| 525 | - if ( false !== $brace && $brace < 4 ) { |
|
| 525 | + if (false !== $brace && $brace < 4) { |
|
| 526 | 526 | return false; |
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | $token = $data[0]; |
| 530 | - switch ( $token ) { |
|
| 530 | + switch ($token) { |
|
| 531 | 531 | case 's' : |
| 532 | - if ( $strict ) { |
|
| 533 | - if ( '"' !== substr( $data, -2, 1 ) ) { |
|
| 532 | + if ($strict) { |
|
| 533 | + if ('"' !== substr($data, -2, 1)) { |
|
| 534 | 534 | return false; |
| 535 | 535 | } |
| 536 | - } elseif ( false === strpos( $data, '"' ) ) { |
|
| 536 | + } elseif (false === strpos($data, '"')) { |
|
| 537 | 537 | return false; |
| 538 | 538 | } |
| 539 | 539 | case 'a' : |
| 540 | 540 | case 'O' : |
| 541 | - return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); |
|
| 541 | + return (bool)preg_match("/^{$token}:[0-9]+:/s", $data); |
|
| 542 | 542 | case 'b' : |
| 543 | 543 | case 'i' : |
| 544 | 544 | case 'd' : |
| 545 | 545 | $end = $strict ? '$' : ''; |
| 546 | - return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data ); |
|
| 546 | + return (bool)preg_match("/^{$token}:[0-9.E-]+;$end/", $data); |
|
| 547 | 547 | } |
| 548 | 548 | return false; |
| 549 | 549 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | 1 | <?php $wps_statistics_ctr = new wps_statistics_ctr(); $wps_statistics_ctr->wps_display_main_statistics(); ?> |
| 2 | -<?php require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'customerStats' ) ); ?> |
|
| 2 | +<?php require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'customerStats')); ?> |
|
| 3 | 3 | |
| 4 | -<center><a class="button button-primary" href="<?php echo admin_url( 'admin.php?page=wpshop_statistics' ); ?>"><span class="dashicons dashicons-chart-line"></span><?php esc_html_e( 'View all statistics', 'wpshop' ); ?></a></center> |
|
| 4 | +<center><a class="button button-primary" href="<?php echo admin_url('admin.php?page=wpshop_statistics'); ?>"><span class="dashicons dashicons-chart-line"></span><?php esc_html_e('View all statistics', 'wpshop'); ?></a></center>
|
|
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | <td class="first b"><a href="edit.php?post_type=<?php echo WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT; ?>"><?php |
| 8 | 8 | $num_posts = wp_count_posts(WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT); |
| 9 | - $number_of_products = number_format_i18n( $num_posts->publish ); |
|
| 9 | + $number_of_products = number_format_i18n($num_posts->publish); |
|
| 10 | 10 | echo $number_of_products; |
| 11 | 11 | ?></a></td> |
| 12 | 12 | <td class="t"><a href="edit.php?post_type=<?php echo WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT; ?>"><?php _e('Products', 'wpshop'); ?></a></td>
|
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | </tr> |
| 23 | 23 | <tr> |
| 24 | 24 | <?php |
| 25 | - $query = $wpdb->prepare( "SELECT COUNT( DISTINCT us.ID ) FROM {$wpdb->users} us JOIN {$wpdb->posts} ON us.ID = post_author AND post_type = %s", WPSHOP_NEWTYPE_IDENTIFIER_ORDER );
|
|
| 25 | + $query = $wpdb->prepare("SELECT COUNT( DISTINCT us.ID ) FROM {$wpdb->users} us JOIN {$wpdb->posts} ON us.ID = post_author AND post_type = %s", WPSHOP_NEWTYPE_IDENTIFIER_ORDER);
|
|
| 26 | 26 | $result = $wpdb->get_var($query); |
| 27 | 27 | ?> |
| 28 | 28 | <td class="first b"><a href="users.php"><?php echo $result; ?></a></td> |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, |
| 48 | 48 | 'post_status' => 'publish' |
| 49 | 49 | ); |
| 50 | - $orders = get_posts( $args ); |
|
| 50 | + $orders = get_posts($args); |
|
| 51 | 51 | $order_completed = $order_shipped = $order_awaiting_payment = $order_denied = $order_canceled = $order_refunded = 0; |
| 52 | - if ( $orders ) {
|
|
| 53 | - foreach ( $orders as $o ) {
|
|
| 52 | + if ($orders) {
|
|
| 53 | + foreach ($orders as $o) {
|
|
| 54 | 54 | $order = get_post_meta($o->ID, '_order_postmeta', true); |
| 55 | - if(!empty($order['order_status'])){
|
|
| 56 | - switch($order['order_status']) {
|
|
| 55 | + if (!empty($order['order_status'])) {
|
|
| 56 | + switch ($order['order_status']) {
|
|
| 57 | 57 | case 'completed': $order_completed++; break; |
| 58 | 58 | case 'shipped': $order_shipped++; break; |
| 59 | 59 | case 'awaiting_payment': $order_awaiting_payment++; break; |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | /** |
| 3 | 3 | * File for installer control class definition |
| 4 | 4 | * |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | function add_scripts() { |
| 27 | - add_action( 'admin_print_scripts', array($this, 'admin_print_script') ); |
|
| 27 | + add_action('admin_print_scripts', array($this, 'admin_print_script')); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | function admin_print_script() { |
@@ -45,15 +45,15 @@ discard block |
||
| 45 | 45 | global $order_status, $wpdb; |
| 46 | 46 | |
| 47 | 47 | $this->add_dashboard_metaboxes(); |
| 48 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard" ) ); |
|
| 48 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard")); |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | function wpshop_dashboard_orders() { |
| 52 | 52 | $output = ''; |
| 53 | - $orders = get_posts( array( 'posts_per_page' => 10, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC') ); |
|
| 53 | + $orders = get_posts(array('posts_per_page' => 10, 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'post_status' => 'publish', 'orderby' => 'post_date', 'order' => 'DESC')); |
|
| 54 | 54 | // Display orders |
| 55 | 55 | ob_start(); |
| 56 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "wps_orders_on_dashboard" ) ); |
|
| 56 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "wps_orders_on_dashboard")); |
|
| 57 | 57 | $output = ob_get_contents(); |
| 58 | 58 | ob_end_clean(); |
| 59 | 59 | |
@@ -63,24 +63,24 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | function wpshop_rss_feed() { |
| 65 | 65 | $output = ''; |
| 66 | - include_once( ABSPATH . WPINC . '/feed.php' ); |
|
| 66 | + include_once(ABSPATH . WPINC . '/feed.php'); |
|
| 67 | 67 | |
| 68 | - $rss = fetch_feed( 'http://www.wpshop.fr/feed/' ); |
|
| 69 | - if( ! is_wp_error( $rss ) ){ |
|
| 70 | - $maxitems = $rss->get_item_quantity( 4 ); |
|
| 71 | - $rss_items = $rss->get_items( 0, $maxitems ); |
|
| 68 | + $rss = fetch_feed('http://www.wpshop.fr/feed/'); |
|
| 69 | + if (!is_wp_error($rss)) { |
|
| 70 | + $maxitems = $rss->get_item_quantity(4); |
|
| 71 | + $rss_items = $rss->get_items(0, $maxitems); |
|
| 72 | 72 | } |
| 73 | 73 | else { |
| 74 | 74 | $output .= '<p>' . __('WPShop News cannot be loaded', 'wpshop') . '</p>'; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if ( $maxitems == 0 ) { |
|
| 77 | + if ($maxitems == 0) { |
|
| 78 | 78 | $output .= '<p>' . __('No WPShop new has been found', 'wpshop') . '</p>'; |
| 79 | 79 | } |
| 80 | 80 | else { |
| 81 | 81 | $output .= '<ul class="recent-orders">'; |
| 82 | - foreach ( $rss_items as $item ) { |
|
| 83 | - $output .= '<li><a href="' .$item->get_permalink() . '" title="' .$item->get_title(). '" target="_blank">' .$item->get_title(). '</a><br/>'; |
|
| 82 | + foreach ($rss_items as $item) { |
|
| 83 | + $output .= '<li><a href="' . $item->get_permalink() . '" title="' . $item->get_title() . '" target="_blank">' . $item->get_title() . '</a><br/>'; |
|
| 84 | 84 | $output .= $item->get_content(); |
| 85 | 85 | $output .= '</li>'; |
| 86 | 86 | } |
@@ -90,40 +90,40 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | function wpshop_rss_tutorial_videos() { |
| 93 | - $ini_get_checking = ini_get( 'allow_url_fopen' ); |
|
| 93 | + $ini_get_checking = ini_get('allow_url_fopen'); |
|
| 94 | 94 | |
| 95 | - if ( $ini_get_checking != 0 ) { |
|
| 96 | - $content = @file_get_contents( 'http://www.wpshop.fr/rss_video.xml' ); |
|
| 97 | - $videos_rss = ( $content !== false ) ? new SimpleXmlElement( $content ) : null; |
|
| 98 | - if ( !empty($videos_rss) && !empty($videos_rss->channel) ) { |
|
| 95 | + if ($ini_get_checking != 0) { |
|
| 96 | + $content = @file_get_contents('http://www.wpshop.fr/rss_video.xml'); |
|
| 97 | + $videos_rss = ($content !== false) ? new SimpleXmlElement($content) : null; |
|
| 98 | + if (!empty($videos_rss) && !empty($videos_rss->channel)) { |
|
| 99 | 99 | $videos_items = array(); |
| 100 | - foreach( $videos_rss->channel->item as $i => $item ) { |
|
| 100 | + foreach ($videos_rss->channel->item as $i => $item) { |
|
| 101 | 101 | $videos_items[] = $item; |
| 102 | 102 | } |
| 103 | - $rand_element = array_rand( $videos_items ); |
|
| 103 | + $rand_element = array_rand($videos_items); |
|
| 104 | 104 | |
| 105 | 105 | ob_start(); |
| 106 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard", "videos" ) ); |
|
| 106 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, "backend", "dashboard", "videos")); |
|
| 107 | 107 | $output = ob_get_contents(); |
| 108 | 108 | ob_end_clean(); |
| 109 | 109 | } |
| 110 | 110 | else { |
| 111 | - $output = __('No tutorial videos can be loaded', 'wpshop' ); |
|
| 111 | + $output = __('No tutorial videos can be loaded', 'wpshop'); |
|
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | else { |
| 115 | - $output = __( 'Your servor doesn\'t allow to open external files', 'wpshop'); |
|
| 115 | + $output = __('Your servor doesn\'t allow to open external files', 'wpshop'); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | echo $output; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | function wpshop_dashboard_get_changelog() { |
| 122 | - $readme_file = fopen( WPSHOP_DIR.'/readme.txt', 'r' ); |
|
| 123 | - if ( $readme_file ) { |
|
| 124 | - $txt = file_get_contents( WPSHOP_DIR.'/readme.txt' ); |
|
| 125 | - $pre_change_log = explode( '== Changelog ==', $txt ); |
|
| 126 | - $versions = explode( '= Version', $pre_change_log[1] ); |
|
| 122 | + $readme_file = fopen(WPSHOP_DIR . '/readme.txt', 'r'); |
|
| 123 | + if ($readme_file) { |
|
| 124 | + $txt = file_get_contents(WPSHOP_DIR . '/readme.txt'); |
|
| 125 | + $pre_change_log = explode('== Changelog ==', $txt); |
|
| 126 | + $versions = explode('= Version', $pre_change_log[1]); |
|
| 127 | 127 | |
| 128 | 128 | echo $versions[1]; |
| 129 | 129 | } |
@@ -133,16 +133,16 @@ discard block |
||
| 133 | 133 | * Add custom metaboxes to WPShop dashboard |
| 134 | 134 | */ |
| 135 | 135 | function add_dashboard_metaboxes() { |
| 136 | - add_meta_box( 'wps-right-now', '<i class="dashicons dashicons-info"></i>' . esc_html( 'Right Now', 'wpshop' ), array( $this, 'wps_dashboard_right_now' ), 'wpshop_dashboard', 'left_column' ); |
|
| 137 | - add_meta_box( 'wps-dashboard-quick-links', '<i class="dashicons dashicons-performance"></i>' . esc_html( 'Quick Links', 'wpshop' ), array( $this, 'wps_dashboard_quick_links' ), 'wpshop_dashboard', 'left_column' ); |
|
| 136 | + add_meta_box('wps-right-now', '<i class="dashicons dashicons-info"></i>' . esc_html('Right Now', 'wpshop'), array($this, 'wps_dashboard_right_now'), 'wpshop_dashboard', 'left_column'); |
|
| 137 | + add_meta_box('wps-dashboard-quick-links', '<i class="dashicons dashicons-performance"></i>' . esc_html('Quick Links', 'wpshop'), array($this, 'wps_dashboard_quick_links'), 'wpshop_dashboard', 'left_column'); |
|
| 138 | 138 | // add_meta_box( 'wps-dashboard-customer-stats', '<i class="dashicons dashicons-chart-pie"></i>' . esc_html( 'Customers stats', 'wpshop' ), array( $this, 'wps_dashboard_customer_stats' ), 'wpshop_dashboard', 'left_column' ); |
| 139 | - add_meta_box( 'wps-dashboard-export', '<i class="dashicons dashicons-download"></i>' . esc_html( 'CSV export', 'wpshop' ), array( $this, 'wps_dashboard_export' ), 'wpshop_dashboard', 'left_column' ); |
|
| 140 | - add_meta_box( 'wps-dashboard-orders', '<i class="dashicons dashicons-cart"></i>' . esc_html( 'Recent Orders', 'wpshop' ), array( $this, 'wps_dashboard_orders' ), 'wpshop_dashboard', 'left_column' ); |
|
| 139 | + add_meta_box('wps-dashboard-export', '<i class="dashicons dashicons-download"></i>' . esc_html('CSV export', 'wpshop'), array($this, 'wps_dashboard_export'), 'wpshop_dashboard', 'left_column'); |
|
| 140 | + add_meta_box('wps-dashboard-orders', '<i class="dashicons dashicons-cart"></i>' . esc_html('Recent Orders', 'wpshop'), array($this, 'wps_dashboard_orders'), 'wpshop_dashboard', 'left_column'); |
|
| 141 | 141 | |
| 142 | - add_meta_box( 'wps-dashboard-statistics', '<i class="dashicons dashicons-chart-area"></i>' . esc_html( 'Statistics', 'wpshop' ), array( $this, 'wps_dashboard_statistics' ), 'wpshop_dashboard', 'right_column' ); |
|
| 142 | + add_meta_box('wps-dashboard-statistics', '<i class="dashicons dashicons-chart-area"></i>' . esc_html('Statistics', 'wpshop'), array($this, 'wps_dashboard_statistics'), 'wpshop_dashboard', 'right_column'); |
|
| 143 | 143 | |
| 144 | - add_meta_box( 'wps-dashboard-infos', '<i class="dashicons dashicons-heart"></i>' . esc_html( 'WPShop : WordPress e-commerce', 'wpshop' ), array( $this, 'wps_dashboard_infos' ), 'wpshop_dashboard', 'right_column' ); |
|
| 145 | - add_meta_box( 'wps-dashboard-feed', '<i class="dashicons dashicons-format-status"></i>' . esc_html( 'WPShop News', 'wpshop' ), array( $this, 'wps_dashboard_feed' ), 'wpshop_dashboard', 'right_column' ); |
|
| 144 | + add_meta_box('wps-dashboard-infos', '<i class="dashicons dashicons-heart"></i>' . esc_html('WPShop : WordPress e-commerce', 'wpshop'), array($this, 'wps_dashboard_infos'), 'wpshop_dashboard', 'right_column'); |
|
| 145 | + add_meta_box('wps-dashboard-feed', '<i class="dashicons dashicons-format-status"></i>' . esc_html('WPShop News', 'wpshop'), array($this, 'wps_dashboard_feed'), 'wpshop_dashboard', 'right_column'); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -150,14 +150,14 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | function wps_dashboard_right_now() { |
| 152 | 152 | global $wpdb; |
| 153 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'right_now' ) ); |
|
| 153 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'right_now')); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
| 157 | 157 | * Display metabox with quick links |
| 158 | 158 | */ |
| 159 | 159 | function wps_dashboard_quick_links() { |
| 160 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'quicklinks' ) ); |
|
| 160 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'quicklinks')); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | /** |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | function wps_dashboard_statistics() { |
| 174 | 174 | global $wpdb; |
| 175 | 175 | |
| 176 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'statistics' ) ); |
|
| 176 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'statistics')); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -181,28 +181,28 @@ discard block |
||
| 181 | 181 | */ |
| 182 | 182 | function wps_dashboard_infos() { |
| 183 | 183 | global $wpdb; |
| 184 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'infos' ) ); |
|
| 184 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'infos')); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
| 188 | 188 | * Display metabox with shop main statistics |
| 189 | 189 | */ |
| 190 | 190 | function wps_dashboard_feed() { |
| 191 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'feed' ) ); |
|
| 191 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'feed')); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | /** |
| 195 | 195 | * Display metabox with recent orders list |
| 196 | 196 | */ |
| 197 | 197 | function wps_dashboard_orders() { |
| 198 | - require_once( wpshop_tools::get_template_part( WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'orders' ) ); |
|
| 198 | + require_once(wpshop_tools::get_template_part(WPS_DASHBOARD_DIR, WPSDASHBOARD_TPL_DIR, 'backend', 'metabox', 'orders')); |
|
| 199 | 199 | } |
| 200 | 200 | |
| 201 | 201 | /** |
| 202 | 202 | * Display metabox for export |
| 203 | 203 | */ |
| 204 | 204 | function wps_dashboard_export() { |
| 205 | - if ( class_exists( 'wps_export_ctr' ) ) { |
|
| 205 | + if (class_exists('wps_export_ctr')) { |
|
| 206 | 206 | $wps_export = new wps_export_ctr(); |
| 207 | 207 | $wps_export->wps_export_tpl(); |
| 208 | 208 | } |
@@ -1,27 +1,27 @@ discard block |
||
| 1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
| 1 | +<?php if (!defined('ABSPATH')) exit; |
|
| 2 | 2 | ?> |
| 3 | 3 | <div class="wrap wps_statistics"> |
| 4 | - <h2><span class="dashicons dashicons-chart-area" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e( 'WPShop Statistics', 'wpshop' )?></h2> |
|
| 4 | + <h2><span class="dashicons dashicons-chart-area" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e('WPShop Statistics', 'wpshop')?></h2> |
|
| 5 | 5 | |
| 6 | 6 | <div class="wps-boxed"> |
| 7 | 7 | <div class="wps-gridwrapper2-padded"> |
| 8 | 8 | <div> |
| 9 | 9 | <div> |
| 10 | 10 | <div> |
| 11 | - <span class="wps-h5"><?php _e( 'Sales statistics', 'wpshop'); ?></span> |
|
| 11 | + <span class="wps-h5"><?php _e('Sales statistics', 'wpshop'); ?></span> |
|
| 12 | 12 | <?php $this->wps_display_main_statistics(); ?> |
| 13 | 13 | </div> |
| 14 | 14 | </div> |
| 15 | 15 | <div> |
| 16 | 16 | <div> |
| 17 | - <span class="wps-h5"><?php _e( 'Orders infos', 'wpshop'); ?></span> |
|
| 18 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_average') ); ?> |
|
| 17 | + <span class="wps-h5"><?php _e('Orders infos', 'wpshop'); ?></span> |
|
| 18 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_average')); ?> |
|
| 19 | 19 | </div> |
| 20 | 20 | </div> |
| 21 | 21 | </div> |
| 22 | 22 | <div> |
| 23 | 23 | <div> |
| 24 | - <span class="wps-h5"><?php _e( 'Custom statistics', 'wpshop'); ?></span> |
|
| 24 | + <span class="wps-h5"><?php _e('Custom statistics', 'wpshop'); ?></span> |
|
| 25 | 25 | <div id="wps_statistics_custom_container" class="wps-bloc-loader" ><?php $this->wps_display_custom_statistics(); ?></div> |
| 26 | 26 | </div> |
| 27 | 27 | </div> |
@@ -31,26 +31,26 @@ discard block |
||
| 31 | 31 | <div class="wps-boxed"> |
| 32 | 32 | <div class="wps-gridwrapper3-padded"> |
| 33 | 33 | <div> |
| 34 | - <span class="wps-h5"><?php _e( 'Last orders', 'wpshop'); ?></span> |
|
| 35 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_last_orders') ); ?> |
|
| 34 | + <span class="wps-h5"><?php _e('Last orders', 'wpshop'); ?></span> |
|
| 35 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_last_orders')); ?> |
|
| 36 | 36 | </div> |
| 37 | 37 | <div> |
| 38 | - <span class="wps-h5"><?php _e( 'Most buyed products', 'wpshop'); ?></span> |
|
| 39 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_sales') ); ?> |
|
| 38 | + <span class="wps-h5"><?php _e('Most buyed products', 'wpshop'); ?></span> |
|
| 39 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_sales')); ?> |
|
| 40 | 40 | </div> |
| 41 | 41 | <div> |
| 42 | - <span class="wps-h5"><?php _e( 'Most viewed products', 'wpshop'); ?></span> |
|
| 43 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_most_viewed_products') ); ?> |
|
| 42 | + <span class="wps-h5"><?php _e('Most viewed products', 'wpshop'); ?></span> |
|
| 43 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_most_viewed_products')); ?> |
|
| 44 | 44 | </div> |
| 45 | 45 | </div> |
| 46 | 46 | <div class="wps-gridwrapper3-padded"> |
| 47 | 47 | <div> |
| 48 | - <span class="wps-h5"><?php _e( 'Best customers per amount', 'wpshop'); ?></span> |
|
| 49 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_amount') ); ?> |
|
| 48 | + <span class="wps-h5"><?php _e('Best customers per amount', 'wpshop'); ?></span> |
|
| 49 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_amount')); ?> |
|
| 50 | 50 | </div> |
| 51 | 51 | <div> |
| 52 | - <span class="wps-h5"><?php _e( 'Best customers per count', 'wpshop'); ?></span> |
|
| 53 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_count') ); ?> |
|
| 52 | + <span class="wps-h5"><?php _e('Best customers per count', 'wpshop'); ?></span> |
|
| 53 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_count')); ?> |
|
| 54 | 54 | </div> |
| 55 | 55 | </div> |
| 56 | 56 | </div> |
@@ -2,35 +2,35 @@ |
||
| 2 | 2 | /** |
| 3 | 3 | * Display the best customers list |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | +if (!defined('ABSPATH')) { |
|
| 6 | 6 | exit; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -usort( $ordered_customers, function( $a, $b ) { |
|
| 9 | +usort($ordered_customers, function($a, $b) { |
|
| 10 | 10 | if ($a['count'] == $b['count']) { |
| 11 | 11 | return 0; |
| 12 | 12 | } |
| 13 | 13 | return ($a['count'] > $b['count']) ? -1 : 1; |
| 14 | 14 | } ); |
| 15 | -$best_customers = array_slice( $ordered_customers, 0, 5 ); |
|
| 16 | -if ( !empty( $best_customers ) ) : |
|
| 15 | +$best_customers = array_slice($ordered_customers, 0, 5); |
|
| 16 | +if (!empty($best_customers)) : |
|
| 17 | 17 | ?> |
| 18 | 18 | <div class="wps-table"> |
| 19 | 19 | <div class="wps-table-header"> |
| 20 | - <div class="wps-table-cell" ><?php esc_html_e( 'Customer name', 'wpshop' ); ?></div> |
|
| 21 | - <div class="wps-table-cell" ><?php esc_html_e( 'Order count', 'wpshop' ); ?></div> |
|
| 22 | - <div class="wps-table-cell" ><?php esc_html_e( 'Order average amount', 'wpshop' ); ?></div> |
|
| 23 | - <div class="wps-table-cell" ><?php esc_html_e( 'Order total amount', 'wpshop' ); ?></div> |
|
| 20 | + <div class="wps-table-cell" ><?php esc_html_e('Customer name', 'wpshop'); ?></div> |
|
| 21 | + <div class="wps-table-cell" ><?php esc_html_e('Order count', 'wpshop'); ?></div> |
|
| 22 | + <div class="wps-table-cell" ><?php esc_html_e('Order average amount', 'wpshop'); ?></div> |
|
| 23 | + <div class="wps-table-cell" ><?php esc_html_e('Order total amount', 'wpshop'); ?></div> |
|
| 24 | 24 | </div> |
| 25 | -<?php foreach( $best_customers as $customer ) : ?> |
|
| 25 | +<?php foreach ($best_customers as $customer) : ?> |
|
| 26 | 26 | <div class="wps-table-row"> |
| 27 | - <div class="wps-table-cell textleft" ><a href="<?php echo admin_url('post.php?post=' . $customer['post_id']. '&action=edit'); ?>"><?php echo $customer['name']; ?></a></div> |
|
| 28 | - <div class="wps-table-cell" ><?php echo esc_html( $customer['count'] ); ?></div> |
|
| 29 | - <div class="wps-table-cell" ><?php echo esc_html( number_format( $customer['total_amount'] / $customer['count'], 2, '.', '' ).' '.wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
| 30 | - <div class="wps-table-cell" ><?php echo esc_html( number_format( $customer['total_amount'], 2, '.', '' ).' '.wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
| 27 | + <div class="wps-table-cell textleft" ><a href="<?php echo admin_url('post.php?post=' . $customer['post_id'] . '&action=edit'); ?>"><?php echo $customer['name']; ?></a></div> |
|
| 28 | + <div class="wps-table-cell" ><?php echo esc_html($customer['count']); ?></div> |
|
| 29 | + <div class="wps-table-cell" ><?php echo esc_html(number_format($customer['total_amount'] / $customer['count'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
| 30 | + <div class="wps-table-cell" ><?php echo esc_html(number_format($customer['total_amount'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
| 31 | 31 | </div> |
| 32 | 32 | <?php endforeach; ?> |
| 33 | 33 | </div> |
| 34 | 34 | <?php else : ?> |
| 35 | -<div class="wps-alert-info"><?php _e( 'No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 35 | +<div class="wps-alert-info"><?php _e('No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 36 | 36 | <?php endif; ?> |
@@ -6,53 +6,53 @@ |
||
| 6 | 6 | * @subpackage dashboard |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 9 | +if (!defined('ABSPATH')) { |
|
| 10 | 10 | exit; |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | ?><div class="wps-table"> |
| 14 | 14 | <div class="wps-table-header wps-table-row"> |
| 15 | 15 | <div class="wps-table-cell"> </div> |
| 16 | - <div class="wps-table-cell"><?php esc_html_e( 'Order count', 'wpshop' ); ?></div> |
|
| 17 | - <div class="wps-table-cell"><?php esc_html_e( 'Order total amount', 'wpshop' ); ?></div> |
|
| 18 | - <div class="wps-table-cell"><?php esc_html_e( 'Customer subscription', 'wpshop' ); ?></div> |
|
| 16 | + <div class="wps-table-cell"><?php esc_html_e('Order count', 'wpshop'); ?></div> |
|
| 17 | + <div class="wps-table-cell"><?php esc_html_e('Order total amount', 'wpshop'); ?></div> |
|
| 18 | + <div class="wps-table-cell"><?php esc_html_e('Customer subscription', 'wpshop'); ?></div> |
|
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <?php |
| 22 | -foreach ( $dates as $label => $date_def ) : |
|
| 23 | - if ( is_array( $date_def ) ) { |
|
| 22 | +foreach ($dates as $label => $date_def) : |
|
| 23 | + if (is_array($date_def)) { |
|
| 24 | 24 | $args = array( |
| 25 | 25 | 'date_query' => $date_def, |
| 26 | 26 | ); |
| 27 | 27 | } else { |
| 28 | 28 | $args = array(); |
| 29 | 29 | } |
| 30 | - $orders = $this->wps_stats_mdl->wps_orders_all( $args ); |
|
| 30 | + $orders = $this->wps_stats_mdl->wps_orders_all($args); |
|
| 31 | 31 | |
| 32 | - if ( null !== $orders ) : |
|
| 32 | + if (null !== $orders) : |
|
| 33 | 33 | $orders_total_amount = 0; |
| 34 | - foreach ( $orders as $order ) { |
|
| 34 | + foreach ($orders as $order) { |
|
| 35 | 35 | $order_data = $order['order_postmeta']; |
| 36 | 36 | |
| 37 | 37 | $orders_total_amount += $order_data['order_grand_total']; |
| 38 | 38 | } |
| 39 | 39 | endif; |
| 40 | 40 | |
| 41 | - $user_subscription_number = new WP_User_Query( array( |
|
| 41 | + $user_subscription_number = new WP_User_Query(array( |
|
| 42 | 42 | 'date_query' => $date_def, |
| 43 | 43 | 'count_total' => true, |
| 44 | - ) ); |
|
| 44 | + )); |
|
| 45 | 45 | ?> |
| 46 | 46 | <div class="wps-table-row"> |
| 47 | - <div class="wps-table-cell textleft"><?php echo esc_html( $label ); ?></div> |
|
| 48 | - <?php if ( null !== $orders ) : ?> |
|
| 49 | - <div class="wps-table-cell"><?php echo esc_html( count( $orders ) ); ?></div> |
|
| 50 | - <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_amount, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
| 47 | + <div class="wps-table-cell textleft"><?php echo esc_html($label); ?></div> |
|
| 48 | + <?php if (null !== $orders) : ?> |
|
| 49 | + <div class="wps-table-cell"><?php echo esc_html(count($orders)); ?></div> |
|
| 50 | + <div class="wps-table-cell"><?php echo esc_html(number_format($orders_total_amount, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
| 51 | 51 | <?php else : ?> |
| 52 | - <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); ?></div> |
|
| 52 | + <div class="wps-table-cell"><?php esc_html_e('No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 53 | 53 | <div class="wps-table-cell"> </div> |
| 54 | 54 | <?php endif; ?> |
| 55 | - <div class="wps-table-cell"><?php echo esc_html( $user_subscription_number->get_total() ); ?></div> |
|
| 55 | + <div class="wps-table-cell"><?php echo esc_html($user_subscription_number->get_total()); ?></div> |
|
| 56 | 56 | </div> |
| 57 | 57 | |
| 58 | 58 | <?php endforeach; ?> |
@@ -2,35 +2,35 @@ |
||
| 2 | 2 | /** |
| 3 | 3 | * Display the best customers list |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | +if (!defined('ABSPATH')) { |
|
| 6 | 6 | exit; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | -usort( $ordered_customers, function( $a, $b ) { |
|
| 9 | +usort($ordered_customers, function($a, $b) { |
|
| 10 | 10 | if ($a['total_amount'] == $b['total_amount']) { |
| 11 | 11 | return 0; |
| 12 | 12 | } |
| 13 | 13 | return ($a['total_amount'] > $b['total_amount']) ? -1 : 1; |
| 14 | 14 | } ); |
| 15 | -$best_customers = array_slice( $ordered_customers, 0, 5 ); |
|
| 16 | -if ( !empty( $best_customers ) ) : |
|
| 15 | +$best_customers = array_slice($ordered_customers, 0, 5); |
|
| 16 | +if (!empty($best_customers)) : |
|
| 17 | 17 | ?> |
| 18 | 18 | <div class="wps-table"> |
| 19 | 19 | <div class="wps-table-header"> |
| 20 | - <div class="wps-table-cell" ><?php esc_html_e( 'Customer name', 'wpshop' ); ?></div> |
|
| 21 | - <div class="wps-table-cell" ><?php esc_html_e( 'Order count', 'wpshop' ); ?></div> |
|
| 22 | - <div class="wps-table-cell" ><?php esc_html_e( 'Order average amount', 'wpshop' ); ?></div> |
|
| 23 | - <div class="wps-table-cell" ><?php esc_html_e( 'Order total amount', 'wpshop' ); ?></div> |
|
| 20 | + <div class="wps-table-cell" ><?php esc_html_e('Customer name', 'wpshop'); ?></div> |
|
| 21 | + <div class="wps-table-cell" ><?php esc_html_e('Order count', 'wpshop'); ?></div> |
|
| 22 | + <div class="wps-table-cell" ><?php esc_html_e('Order average amount', 'wpshop'); ?></div> |
|
| 23 | + <div class="wps-table-cell" ><?php esc_html_e('Order total amount', 'wpshop'); ?></div> |
|
| 24 | 24 | </div> |
| 25 | -<?php foreach( $best_customers as $customer ) : ?> |
|
| 25 | +<?php foreach ($best_customers as $customer) : ?> |
|
| 26 | 26 | <div class="wps-table-row"> |
| 27 | - <div class="wps-table-cell textleft" ><a href="<?php echo admin_url('post.php?post=' . $customer['post_id']. '&action=edit'); ?>"><?php echo $customer['name']; ?></a></div> |
|
| 28 | - <div class="wps-table-cell" ><?php echo esc_html( $customer['count'] ); ?></div> |
|
| 29 | - <div class="wps-table-cell" ><?php echo esc_html( number_format( $customer['total_amount'] / $customer['count'], 2, '.', '' ).' '.wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
| 30 | - <div class="wps-table-cell" ><?php echo esc_html( number_format( $customer['total_amount'], 2, '.', '' ).' '.wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
| 27 | + <div class="wps-table-cell textleft" ><a href="<?php echo admin_url('post.php?post=' . $customer['post_id'] . '&action=edit'); ?>"><?php echo $customer['name']; ?></a></div> |
|
| 28 | + <div class="wps-table-cell" ><?php echo esc_html($customer['count']); ?></div> |
|
| 29 | + <div class="wps-table-cell" ><?php echo esc_html(number_format($customer['total_amount'] / $customer['count'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
| 30 | + <div class="wps-table-cell" ><?php echo esc_html(number_format($customer['total_amount'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
| 31 | 31 | </div> |
| 32 | 32 | <?php endforeach; ?> |
| 33 | 33 | </div> |
| 34 | 34 | <?php else : ?> |
| 35 | -<div class="wps-alert-info"><?php _e( 'No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 35 | +<div class="wps-alert-info"><?php _e('No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 36 | 36 | <?php endif; ?> |
@@ -2,38 +2,38 @@ |
||
| 2 | 2 | /** |
| 3 | 3 | * Display the last order list |
| 4 | 4 | */ |
| 5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 5 | +if (!defined('ABSPATH')) { |
|
| 6 | 6 | exit; |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | $ordered_products = array(); |
| 10 | -foreach ( $shop_orders as $order ) { |
|
| 11 | - foreach ( $order['order_postmeta']['order_items'] as $product_id => $product_def ) { |
|
| 12 | - if ( ! isset( $ordered_products[ $product_id ]['count'] ) ) { |
|
| 13 | - $ordered_products[ $product_id ]['count'] = 0; |
|
| 10 | +foreach ($shop_orders as $order) { |
|
| 11 | + foreach ($order['order_postmeta']['order_items'] as $product_id => $product_def) { |
|
| 12 | + if (!isset($ordered_products[$product_id]['count'])) { |
|
| 13 | + $ordered_products[$product_id]['count'] = 0; |
|
| 14 | 14 | } |
| 15 | - $ordered_products[ $product_id ]['count']++; |
|
| 16 | - $ordered_products[ $product_id ]['id'] = $product_id; |
|
| 17 | - $ordered_products[ $product_id ]['name'] = $product_def['item_name']; |
|
| 15 | + $ordered_products[$product_id]['count']++; |
|
| 16 | + $ordered_products[$product_id]['id'] = $product_id; |
|
| 17 | + $ordered_products[$product_id]['name'] = $product_def['item_name']; |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | -usort( $ordered_products, function( $a, $b ) { |
|
| 20 | +usort($ordered_products, function($a, $b) { |
|
| 21 | 21 | if ($a['count'] == $b['count']) { |
| 22 | 22 | return 0; |
| 23 | 23 | } |
| 24 | 24 | return ($a['count'] > $b['count']) ? -1 : 1; |
| 25 | 25 | } ); |
| 26 | -$best_sales = array_slice( $ordered_products, 0, 5 ); |
|
| 27 | -if ( !empty( $best_sales ) ) : |
|
| 26 | +$best_sales = array_slice($ordered_products, 0, 5); |
|
| 27 | +if (!empty($best_sales)) : |
|
| 28 | 28 | ?> |
| 29 | 29 | <div class="wps-table"> |
| 30 | -<?php foreach( $best_sales as $product ) : ?> |
|
| 30 | +<?php foreach ($best_sales as $product) : ?> |
|
| 31 | 31 | <div class="wps-table wps-table-row"> |
| 32 | - <div class="wps-table-cell textleft" ><a href="<?php echo admin_url('post.php?post=' .$product['id']. '&action=edit'); ?>"><?php echo $product['name']; ?></a></div> |
|
| 33 | - <div class="wps-table-cell" ><?php printf( __('%s sales', 'wpshop'), $product['count']); ?></div> |
|
| 32 | + <div class="wps-table-cell textleft" ><a href="<?php echo admin_url('post.php?post=' . $product['id'] . '&action=edit'); ?>"><?php echo $product['name']; ?></a></div> |
|
| 33 | + <div class="wps-table-cell" ><?php printf(__('%s sales', 'wpshop'), $product['count']); ?></div> |
|
| 34 | 34 | </div> |
| 35 | 35 | <?php endforeach; ?> |
| 36 | 36 | </div> |
| 37 | 37 | <?php else : ?> |
| 38 | -<div class="wps-alert-info"><?php _e( 'No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 38 | +<div class="wps-alert-info"><?php _e('No orders have been placed for the moment', 'wpshop'); ?></div> |
|
| 39 | 39 | <?php endif; ?> |