@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if (!defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\ZIP_Util' ) ) { |
|
| 18 | +if (!class_exists('\eoxia\ZIP_Util')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * Gestion des fichiers ZIP |
| 21 | 21 | */ |
@@ -47,20 +47,20 @@ discard block |
||
| 47 | 47 | * @type array $list_file Contenant plusieurs index avec le nom des fichiers dézippés. |
| 48 | 48 | * } |
| 49 | 49 | */ |
| 50 | - public function unzip( $zip_path, $destination_path ) { |
|
| 50 | + public function unzip($zip_path, $destination_path) { |
|
| 51 | 51 | $zip = new \ZipArchive; |
| 52 | - $data = array( 'state' => true, 'list_file' => array() ); |
|
| 52 | + $data = array('state' => true, 'list_file' => array()); |
|
| 53 | 53 | |
| 54 | - if ( $zip->open( $zip_path ) === true ) { |
|
| 55 | - if ( ! $zip->extractTo( $destination_path ) ) { |
|
| 54 | + if ($zip->open($zip_path) === true) { |
|
| 55 | + if (!$zip->extractTo($destination_path)) { |
|
| 56 | 56 | $data['state'] = false; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Récupérations de tous les fichiers. |
| 60 | - for ( $i = 0; $i < $zip->numFiles; $i++ ) { |
|
| 61 | - $filename = $zip->getNameIndex( 0 ); |
|
| 60 | + for ($i = 0; $i < $zip->numFiles; $i++) { |
|
| 61 | + $filename = $zip->getNameIndex(0); |
|
| 62 | 62 | |
| 63 | - if ( isset( $filename ) ) { |
|
| 63 | + if (isset($filename)) { |
|
| 64 | 64 | $data['list_file'][] = $filename; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -12,11 +12,11 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | namespace eoxia; |
| 14 | 14 | |
| 15 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 15 | +if (!defined('ABSPATH')) {
|
|
| 16 | 16 | exit; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | -if ( ! class_exists( '\eoxia\External_Util' ) ) {
|
|
| 19 | +if (!class_exists('\eoxia\External_Util')) {
|
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Gestion des externals |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | * bool Si aucune erreur s'est produite. |
| 48 | 48 | *} |
| 49 | 49 | */ |
| 50 | - public function exec( $path, $plugin_slug ) {
|
|
| 51 | - if ( empty( \eoxia\Config_Util::$init[ $plugin_slug ]->externals ) ) {
|
|
| 52 | - return new \WP_Error( 'broke', __( 'Aucun module a charger', $plugin_slug ) ); |
|
| 50 | + public function exec($path, $plugin_slug) {
|
|
| 51 | + if (empty(\eoxia\Config_Util::$init[$plugin_slug]->externals)) {
|
|
| 52 | + return new \WP_Error('broke', __('Aucun module a charger', $plugin_slug));
|
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - if ( ! empty( \eoxia\Config_Util::$init[ $plugin_slug ]->externals ) ) {
|
|
| 56 | - foreach ( \eoxia\Config_Util::$init[ $plugin_slug ]->externals as $external_json_path ) {
|
|
| 57 | - self::inc_config( $plugin_slug, $path . $external_json_path ); |
|
| 58 | - self::inc( $plugin_slug, $path . $external_json_path ); |
|
| 55 | + if (!empty(\eoxia\Config_Util::$init[$plugin_slug]->externals)) {
|
|
| 56 | + foreach (\eoxia\Config_Util::$init[$plugin_slug]->externals as $external_json_path) {
|
|
| 57 | + self::inc_config($plugin_slug, $path . $external_json_path); |
|
| 58 | + self::inc($plugin_slug, $path . $external_json_path); |
|
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @return void |
| 75 | 75 | */ |
| 76 | - public function inc_config( $plugin_slug, $module_json_path ) {
|
|
| 77 | - \eoxia\Config_Util::g()->init_config( $module_json_path, $plugin_slug ); |
|
| 76 | + public function inc_config($plugin_slug, $module_json_path) {
|
|
| 77 | + \eoxia\Config_Util::g()->init_config($module_json_path, $plugin_slug); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -88,21 +88,21 @@ discard block |
||
| 88 | 88 | * |
| 89 | 89 | * @return void |
| 90 | 90 | */ |
| 91 | - public function inc( $plugin_slug, $module_json_path ) {
|
|
| 92 | - $module_name = basename( $module_json_path, '.config.json' ); |
|
| 93 | - $module_path = dirname( $module_json_path ); |
|
| 91 | + public function inc($plugin_slug, $module_json_path) {
|
|
| 92 | + $module_name = basename($module_json_path, '.config.json'); |
|
| 93 | + $module_path = dirname($module_json_path); |
|
| 94 | 94 | |
| 95 | - if ( ! empty( \eoxia\Config_Util::$init['external'] ) ) {
|
|
| 96 | - foreach ( \eoxia\Config_Util::$init['external'] as $external_name => $config ) {
|
|
| 97 | - if ( ! empty( $config->dependencies ) ) {
|
|
| 98 | - foreach ( $config->dependencies as $folder_name => $folder_conf ) {
|
|
| 95 | + if (!empty(\eoxia\Config_Util::$init['external'])) {
|
|
| 96 | + foreach (\eoxia\Config_Util::$init['external'] as $external_name => $config) {
|
|
| 97 | + if (!empty($config->dependencies)) {
|
|
| 98 | + foreach ($config->dependencies as $folder_name => $folder_conf) {
|
|
| 99 | 99 | $path_to_module_and_dependence_folder = $config->path . '/' . $folder_name . '/'; |
| 100 | 100 | |
| 101 | - if ( ! empty( $folder_conf->priority ) ) {
|
|
| 102 | - $this->inc_priority_file( $path_to_module_and_dependence_folder, $folder_name, $folder_conf->priority ); |
|
| 101 | + if (!empty($folder_conf->priority)) {
|
|
| 102 | + $this->inc_priority_file($path_to_module_and_dependence_folder, $folder_name, $folder_conf->priority); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | - \eoxia\Include_util::g()->in_folder( $path_to_module_and_dependence_folder ); |
|
| 105 | + \eoxia\Include_util::g()->in_folder($path_to_module_and_dependence_folder); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | } |
@@ -120,13 +120,13 @@ discard block |
||
| 120 | 120 | * @param array $list_priority_file La liste des chemins des fichiers à inclure en priorité. |
| 121 | 121 | * @return void |
| 122 | 122 | */ |
| 123 | - public function inc_priority_file( $path_to_module_and_dependence_folder, $dependence_folder, $list_priority_file ) {
|
|
| 124 | - if ( ! empty( $list_priority_file ) ) {
|
|
| 125 | - foreach ( $list_priority_file as $file_name ) {
|
|
| 126 | - $path_file = realpath( $path_to_module_and_dependence_folder . $file_name . '.' . $dependence_folder . '.php' ); |
|
| 123 | + public function inc_priority_file($path_to_module_and_dependence_folder, $dependence_folder, $list_priority_file) {
|
|
| 124 | + if (!empty($list_priority_file)) {
|
|
| 125 | + foreach ($list_priority_file as $file_name) {
|
|
| 126 | + $path_file = realpath($path_to_module_and_dependence_folder . $file_name . '.' . $dependence_folder . '.php'); |
|
| 127 | 127 | |
| 128 | - if ( file_exists( $path_file ) ) {
|
|
| 129 | - require_once( $path_file ); |
|
| 128 | + if (file_exists($path_file)) {
|
|
| 129 | + require_once($path_file); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if (!defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\View_Util' ) ) { |
|
| 18 | +if (!class_exists('\eoxia\View_Util')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * Gestion des vues pour les templates. |
| 21 | 21 | */ |
@@ -45,14 +45,14 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return void |
| 47 | 47 | */ |
| 48 | - public static function exec( $namespace, $module_name, $view_path_without_ext, $args = array(), $filter = true ) { |
|
| 49 | - $path_to_view = Config_Util::$init[ $namespace ]->$module_name->path . '/view/' . $view_path_without_ext . '.view.php'; |
|
| 48 | + public static function exec($namespace, $module_name, $view_path_without_ext, $args = array(), $filter = true) { |
|
| 49 | + $path_to_view = Config_Util::$init[$namespace]->$module_name->path . '/view/' . $view_path_without_ext . '.view.php'; |
|
| 50 | 50 | |
| 51 | - if ( $filter ) { |
|
| 52 | - $args = apply_filters( $module_name . '_' . $view_path_without_ext, $args, $module_name, $view_path_without_ext ); |
|
| 51 | + if ($filter) { |
|
| 52 | + $args = apply_filters($module_name . '_' . $view_path_without_ext, $args, $module_name, $view_path_without_ext); |
|
| 53 | 53 | } |
| 54 | - extract( $args ); |
|
| 55 | - require( $path_to_view ); |
|
| 54 | + extract($args); |
|
| 55 | + require($path_to_view); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | } // End if(). |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if (!defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\Singleton_Util' ) ) { |
|
| 18 | +if (!class_exists('\eoxia\Singleton_Util')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * Le singleton |
| 21 | 21 | */ |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | * @return \eoxia\Singleton_Util L'instance courante |
| 57 | 57 | */ |
| 58 | 58 | final public static function g() { |
| 59 | - if ( ! isset( self::$instance ) || get_called_class() !== get_class( self::$instance ) ) { |
|
| 59 | + if (!isset(self::$instance) || get_called_class() !== get_class(self::$instance)) { |
|
| 60 | 60 | $class_name = get_called_class(); |
| 61 | 61 | $new_instance = new $class_name(); |
| 62 | 62 | // extending classes can set $instance to any value, so check to make sure it's still unset before giving it the default value. |
| 63 | - if ( ! isset( self::$instance ) || get_called_class() !== get_class( self::$instance ) ) { |
|
| 63 | + if (!isset(self::$instance) || get_called_class() !== get_class(self::$instance)) { |
|
| 64 | 64 | self::$instance = $new_instance; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if (!defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\JSON_Util' ) ) { |
|
| 18 | +if (!class_exists('\eoxia\JSON_Util')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * Méthodes utiles pour les fichiers JSON. |
| 21 | 21 | */ |
@@ -38,21 +38,21 @@ discard block |
||
| 38 | 38 | * |
| 39 | 39 | * @return array Les données du fichier JSON |
| 40 | 40 | */ |
| 41 | - public function open_and_decode( $path_to_json, $output = 'STDCLASS' ) { |
|
| 42 | - if ( ! file_exists( $path_to_json ) ) { |
|
| 43 | - return new \WP_Error( 'broke', __( 'Enabled to load JSON file', 'eoxia' ) ); |
|
| 41 | + public function open_and_decode($path_to_json, $output = 'STDCLASS') { |
|
| 42 | + if (!file_exists($path_to_json)) { |
|
| 43 | + return new \WP_Error('broke', __('Enabled to load JSON file', 'eoxia')); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - $config_content = file_get_contents( $path_to_json ); |
|
| 46 | + $config_content = file_get_contents($path_to_json); |
|
| 47 | 47 | |
| 48 | - if ( 'STDCLASS' === $output ) { |
|
| 49 | - $data = json_decode( $config_content ); |
|
| 50 | - } elseif ( 'ARRAY_A' === $output ) { |
|
| 51 | - $data = json_decode( $config_content, true ); |
|
| 48 | + if ('STDCLASS' === $output) { |
|
| 49 | + $data = json_decode($config_content); |
|
| 50 | + } elseif ('ARRAY_A' === $output) { |
|
| 51 | + $data = json_decode($config_content, true); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - if ( null === $data && json_last_error() !== JSON_ERROR_NONE ) { |
|
| 55 | - return new \WP_Error( 'broke', __( 'Error in JSON file', 'eoxia' ) ); |
|
| 54 | + if (null === $data && json_last_error() !== JSON_ERROR_NONE) { |
|
| 55 | + return new \WP_Error('broke', __('Error in JSON file', 'eoxia')); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | return $data; |
@@ -67,18 +67,18 @@ discard block |
||
| 67 | 67 | * @param string $json_to_decode La chaine de caractère JSON. |
| 68 | 68 | * @return array Les données décodées |
| 69 | 69 | */ |
| 70 | - public function decode( $json_to_decode ) { |
|
| 71 | - if ( ! is_string( $json_to_decode ) ) { |
|
| 70 | + public function decode($json_to_decode) { |
|
| 71 | + if (!is_string($json_to_decode)) { |
|
| 72 | 72 | return $json_to_decode; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $json_decoded = json_decode( $json_to_decode, true ); |
|
| 75 | + $json_decoded = json_decode($json_to_decode, true); |
|
| 76 | 76 | |
| 77 | - if ( ! $json_decoded ) { |
|
| 78 | - $json_to_decode = str_replace( '\\', '', $json_to_decode ); |
|
| 79 | - $json_decoded = json_decode( $json_to_decode, true ); |
|
| 77 | + if (!$json_decoded) { |
|
| 78 | + $json_to_decode = str_replace('\\', '', $json_to_decode); |
|
| 79 | + $json_decoded = json_decode($json_to_decode, true); |
|
| 80 | 80 | |
| 81 | - if ( ! $json_decoded ) { |
|
| 81 | + if (!$json_decoded) { |
|
| 82 | 82 | return $json_to_decode; |
| 83 | 83 | } |
| 84 | 84 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if (!defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\Include_Util' ) ) { |
|
| 18 | +if (!class_exists('\eoxia\Include_Util')) { |
|
| 19 | 19 | /** |
| 20 | 20 | * Gestion des inclusions. |
| 21 | 21 | */ |
@@ -39,15 +39,15 @@ discard block |
||
| 39 | 39 | * @param string $folder_path Le chemin du dossier. |
| 40 | 40 | * @return void |
| 41 | 41 | */ |
| 42 | - public function in_folder( $folder_path ) { |
|
| 43 | - $list_file_name = scandir( $folder_path ); |
|
| 42 | + public function in_folder($folder_path) { |
|
| 43 | + $list_file_name = scandir($folder_path); |
|
| 44 | 44 | |
| 45 | - if ( ! empty( $list_file_name ) ) { |
|
| 46 | - foreach ( $list_file_name as $file_name ) { |
|
| 47 | - if ( '.' !== $file_name && '..' !== $file_name && 'index.php' !== $file_name && '.git' !== $file_name && 'README.md' !== $file_name ) { |
|
| 45 | + if (!empty($list_file_name)) { |
|
| 46 | + foreach ($list_file_name as $file_name) { |
|
| 47 | + if ('.' !== $file_name && '..' !== $file_name && 'index.php' !== $file_name && '.git' !== $file_name && 'README.md' !== $file_name) { |
|
| 48 | 48 | |
| 49 | - $file_path = realpath( $folder_path . $file_name ); |
|
| 50 | - $file_success = require_once( $file_path ); |
|
| 49 | + $file_path = realpath($folder_path . $file_name); |
|
| 50 | + $file_success = require_once($file_path); |
|
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | 53 | } |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 14 | +if (!defined('ABSPATH')) {
|
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\LOG_Util' ) ) {
|
|
| 19 | - define( 'EO_NOTICE', 'EO_NOTICE' ); |
|
| 20 | - define( 'EO_RESPONSE_ERROR', 'EO_RESPONSE_ERROR' ); |
|
| 21 | - define( 'EO_RESPONSE_SUCCESS', 'EO_RESPONSE_SUCCESS' ); |
|
| 18 | +if (!class_exists('\eoxia\LOG_Util')) {
|
|
| 19 | + define('EO_NOTICE', 'EO_NOTICE');
|
|
| 20 | + define('EO_RESPONSE_ERROR', 'EO_RESPONSE_ERROR');
|
|
| 21 | + define('EO_RESPONSE_SUCCESS', 'EO_RESPONSE_SUCCESS');
|
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Méthodes utiles pour les logs. |
@@ -44,21 +44,21 @@ discard block |
||
| 44 | 44 | * EO_RESPONSE_SUCCESS = Si la réponse de la requête est correcte. |
| 45 | 45 | * }. |
| 46 | 46 | */ |
| 47 | - public static function log( $text, $file_name, $level = EO_NOTICE ) {
|
|
| 47 | + public static function log($text, $file_name, $level = EO_NOTICE) {
|
|
| 48 | 48 | $bt = debug_backtrace(); |
| 49 | 49 | |
| 50 | - if ( empty( $file_name ) ) {
|
|
| 51 | - self::log_wp_content( $text, $file_name, $level, $bt ); |
|
| 50 | + if (empty($file_name)) {
|
|
| 51 | + self::log_wp_content($text, $file_name, $level, $bt); |
|
| 52 | 52 | } else {
|
| 53 | - if ( false === ini_get( 'error_log' ) || '' == ini_get( 'error_log' ) ) {
|
|
| 54 | - self::log_wp_content( $text, $file_name, $level, $bt ); |
|
| 53 | + if (false === ini_get('error_log') || '' == ini_get('error_log')) {
|
|
| 54 | + self::log_wp_content($text, $file_name, $level, $bt); |
|
| 55 | 55 | } else {
|
| 56 | - $path = dirname( ini_get( 'error_log' ) ); |
|
| 56 | + $path = dirname(ini_get('error_log'));
|
|
| 57 | 57 | |
| 58 | - if ( ! is_dir( $path ) ) {
|
|
| 59 | - self::log_wp_content( $text, $file_name, $level, $bt ); |
|
| 58 | + if (!is_dir($path)) {
|
|
| 59 | + self::log_wp_content($text, $file_name, $level, $bt); |
|
| 60 | 60 | } else {
|
| 61 | - error_log( current_time( '[d-M-Y H:i:s e]' ) . " PHP {$level}: {$text} in " . str_replace( '\\', '/', $bt[0]['file'] ) . " line {$bt[0]['line']}\n", 3, $path . '/' . $file_name . '.log' );
|
|
| 61 | + error_log(current_time('[d-M-Y H:i:s e]') . " PHP {$level}: {$text} in " . str_replace('\\', '/', $bt[0]['file']) . " line {$bt[0]['line']}\n", 3, $path . '/' . $file_name . '.log');
|
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
@@ -79,15 +79,15 @@ discard block |
||
| 79 | 79 | * }. |
| 80 | 80 | * @param array $bt Le contexte de débogage. |
| 81 | 81 | */ |
| 82 | - public static function log_wp_content( $text, $file_name, $level = EO_NOTICE, $bt = array() ) {
|
|
| 83 | - if ( empty( $bt ) ) {
|
|
| 82 | + public static function log_wp_content($text, $file_name, $level = EO_NOTICE, $bt = array()) {
|
|
| 83 | + if (empty($bt)) {
|
|
| 84 | 84 | $bt = debug_backtrace(); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $wp_upload_dir = wp_upload_dir(); |
| 88 | - $file = fopen( $wp_upload_dir['path'] . '/' . $file_name . '.log', 'a' ); |
|
| 89 | - fwrite( $file, current_time( '[d-M-Y H:i:s e]' ) . " PHP {$level}: {$text} in " . str_replace( '\\', '/', $bt[0]['file'] ) . " line {$bt[0]['line']}\n" );
|
|
| 90 | - fclose( $file ); |
|
| 88 | + $file = fopen($wp_upload_dir['path'] . '/' . $file_name . '.log', 'a'); |
|
| 89 | + fwrite($file, current_time('[d-M-Y H:i:s e]') . " PHP {$level}: {$text} in " . str_replace('\\', '/', $bt[0]['file']) . " line {$bt[0]['line']}\n");
|
|
| 90 | + fclose($file); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 14 | +if (!defined('ABSPATH')) { |
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\File_Util' ) ) { |
|
| 18 | +if (!class_exists('\eoxia\File_Util')) { |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Gestion des fichiers |
@@ -41,33 +41,33 @@ discard block |
||
| 41 | 41 | * @param int $element_id L'ID de l'élément pour l'attachement du fichier. |
| 42 | 42 | * @return int L'id de l'attachement |
| 43 | 43 | */ |
| 44 | - public static function move_file_and_attach( $file, $element_id ) { |
|
| 45 | - if ( ! is_string( $file ) || ! is_int( $element_id ) || ! is_file( $file ) ) { |
|
| 44 | + public static function move_file_and_attach($file, $element_id) { |
|
| 45 | + if (!is_string($file) || !is_int($element_id) || !is_file($file)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $wp_upload_dir = wp_upload_dir(); |
| 50 | 50 | |
| 51 | 51 | // Transfère le thumbnail. |
| 52 | - $upload_result = wp_upload_bits( basename( $file ), null, file_get_contents( $file ) ); |
|
| 52 | + $upload_result = wp_upload_bits(basename($file), null, file_get_contents($file)); |
|
| 53 | 53 | |
| 54 | - $filetype = wp_check_filetype( basename( $upload_result['file'] ), null ); |
|
| 54 | + $filetype = wp_check_filetype(basename($upload_result['file']), null); |
|
| 55 | 55 | /** Set the default values for the current attachement */ |
| 56 | 56 | $attachment_default_args = array( |
| 57 | - 'guid' => $wp_upload_dir['url'] . '/' . basename( $upload_result['file'] ), |
|
| 57 | + 'guid' => $wp_upload_dir['url'] . '/' . basename($upload_result['file']), |
|
| 58 | 58 | 'post_mime_type' => $filetype['type'], |
| 59 | - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $upload_result['file'] ) ), |
|
| 59 | + 'post_title' => preg_replace('/\.[^.]+$/', '', basename($upload_result['file'])), |
|
| 60 | 60 | 'post_content' => '', |
| 61 | 61 | 'post_status' => 'inherit', |
| 62 | 62 | ); |
| 63 | 63 | |
| 64 | 64 | /** Save new picture into database */ |
| 65 | - $attach_id = wp_insert_attachment( $attachment_default_args, $upload_result['file'], $element_id ); |
|
| 65 | + $attach_id = wp_insert_attachment($attachment_default_args, $upload_result['file'], $element_id); |
|
| 66 | 66 | |
| 67 | 67 | /** Create the different size for the given picture and get metadatas for this picture */ |
| 68 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $upload_result['file'] ); |
|
| 68 | + $attach_data = wp_generate_attachment_metadata($attach_id, $upload_result['file']); |
|
| 69 | 69 | /** Finaly save pictures metadata */ |
| 70 | - wp_update_attachment_metadata( $attach_id, $attach_data ); |
|
| 70 | + wp_update_attachment_metadata($attach_id, $attach_data); |
|
| 71 | 71 | |
| 72 | 72 | return $attach_id; |
| 73 | 73 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | namespace eoxia; |
| 13 | 13 | |
| 14 | -if ( ! defined( 'ABSPATH' ) ) {
|
|
| 14 | +if (!defined('ABSPATH')) {
|
|
| 15 | 15 | exit; |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -if ( ! class_exists( '\eoxia\Date_Util' ) ) {
|
|
| 18 | +if (!class_exists('\eoxia\Date_Util')) {
|
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Méthodes utilitaires pour les dates. |
@@ -61,35 +61,35 @@ discard block |
||
| 61 | 61 | * } |
| 62 | 62 | * } |
| 63 | 63 | */ |
| 64 | - public function fill_date( $current_time ) {
|
|
| 64 | + public function fill_date($current_time) {
|
|
| 65 | 65 | $data = array(); |
| 66 | 66 | |
| 67 | 67 | $locale = get_locale(); |
| 68 | - $date = new \DateTime( $current_time ); |
|
| 68 | + $date = new \DateTime($current_time); |
|
| 69 | 69 | |
| 70 | 70 | $data['mysql'] = $current_time; |
| 71 | - $data['iso8601'] = mysql_to_rfc3339( $current_time ); |
|
| 71 | + $data['iso8601'] = mysql_to_rfc3339($current_time); |
|
| 72 | 72 | |
| 73 | - if ( class_exists( '\IntlDateFormatter' ) ) {
|
|
| 74 | - $formatter = new \IntlDateFormatter( $locale, \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE ); |
|
| 75 | - $data['date'] = $formatter->format( $date ); |
|
| 73 | + if (class_exists('\IntlDateFormatter')) {
|
|
| 74 | + $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::SHORT, \IntlDateFormatter::NONE); |
|
| 75 | + $data['date'] = $formatter->format($date); |
|
| 76 | 76 | |
| 77 | - $formatter = new \IntlDateFormatter( $locale, \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT ); |
|
| 78 | - $data['date_time'] = $formatter->format( $date ); |
|
| 77 | + $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT); |
|
| 78 | + $data['date_time'] = $formatter->format($date); |
|
| 79 | 79 | |
| 80 | - $formatter = new \IntlDateFormatter( $locale, \IntlDateFormatter::NONE, \IntlDateFormatter::SHORT ); |
|
| 81 | - $data['time'] = $formatter->format( $date ); |
|
| 80 | + $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::NONE, \IntlDateFormatter::SHORT); |
|
| 81 | + $data['time'] = $formatter->format($date); |
|
| 82 | 82 | |
| 83 | - $formatter = new \IntlDateFormatter( $locale, \IntlDateFormatter::FULL, \IntlDateFormatter::SHORT ); |
|
| 84 | - $data['date_human_readable'] = \ucwords( $formatter->format( $date ) ); |
|
| 83 | + $formatter = new \IntlDateFormatter($locale, \IntlDateFormatter::FULL, \IntlDateFormatter::SHORT); |
|
| 84 | + $data['date_human_readable'] = \ucwords($formatter->format($date)); |
|
| 85 | 85 | } else {
|
| 86 | - $data['date'] = $date->format( 'n/j/Y' ); |
|
| 87 | - $data['date_time'] = $date->format( 'n/j/Y, g:i A' ); |
|
| 88 | - $data['time'] = $date->format( 'g:i A' ); |
|
| 89 | - $data['date_human_readable'] = $date->format( 'l, F j, Y \A\t g:i A' ); |
|
| 86 | + $data['date'] = $date->format('n/j/Y');
|
|
| 87 | + $data['date_time'] = $date->format('n/j/Y, g:i A');
|
|
| 88 | + $data['time'] = $date->format('g:i A');
|
|
| 89 | + $data['date_human_readable'] = $date->format('l, F j, Y \A\t g:i A');
|
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - return apply_filters( 'eo_model_fill_date', $data ); |
|
| 92 | + return apply_filters('eo_model_fill_date', $data);
|
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | /** |
@@ -103,13 +103,13 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @todo: Est-ce utile ? |
| 105 | 105 | */ |
| 106 | - public function mysqldate2wordpress( $date, $with_time = true ) { |
|
| 107 | - $format = get_option( 'date_format' ); |
|
| 108 | - if ( $with_time ) { |
|
| 109 | - $format .= ' ' . get_option( 'time_format' ); |
|
| 106 | + public function mysqldate2wordpress($date, $with_time = true) { |
|
| 107 | + $format = get_option('date_format'); |
|
| 108 | + if ($with_time) { |
|
| 109 | + $format .= ' ' . get_option('time_format'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - return mysql2date( $format, $date ); |
|
| 112 | + return mysql2date($format, $date); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return string La date formatée. |
| 125 | 125 | */ |
| 126 | - function convert_to_custom_hours( $min, $display_full_min = true ) {
|
|
| 126 | + function convert_to_custom_hours($min, $display_full_min = true) {
|
|
| 127 | 127 | $minut_for_one_day = \eoxia\Config_Util::$init['eo-framework']->hour_equal_one_day * 60; |
| 128 | - $day = intval( $min / $minut_for_one_day ); |
|
| 129 | - $sub_min = $min - ( $day * $minut_for_one_day ); |
|
| 130 | - $hour = intval( $sub_min / 60 ); |
|
| 131 | - $clone_min = intval( $sub_min - ( $hour * 60 ) ); |
|
| 128 | + $day = intval($min / $minut_for_one_day); |
|
| 129 | + $sub_min = $min - ($day * $minut_for_one_day); |
|
| 130 | + $hour = intval($sub_min / 60); |
|
| 131 | + $clone_min = intval($sub_min - ($hour * 60)); |
|
| 132 | 132 | $display = ''; |
| 133 | 133 | |
| 134 | 134 | // if ( ! empty( $day ) ) {
|
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | $display .= $hour . 'h '; |
| 139 | 139 | // } |
| 140 | 140 | $display .= $clone_min . 'min'; |
| 141 | - if ( $display_full_min ) {
|
|
| 141 | + if ($display_full_min) {
|
|
| 142 | 142 | $display .= ' (' . $min . 'min)';
|
| 143 | 143 | } |
| 144 | 144 | |