@@ -45,7 +45,7 @@ |
||
45 | 45 | * @param string $path_to_config_file Le chemin vers le fichier config.json. |
46 | 46 | * @param string $plugin_slug Le SLUG du plugin définis dans le fichier principale de config.json. |
47 | 47 | * |
48 | - * @return \WP_Error|boolean { |
|
48 | + * @return \WP_Error|null { |
|
49 | 49 | * WP_Error Si le fichier est inexistant ou si le plugin ne contient pas de slug. |
50 | 50 | * boolean True si aucune erreur s'est produite. |
51 | 51 | *}. |
@@ -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\Config_Util' ) ) { |
|
18 | +if (!class_exists('\eoxia\Config_Util')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Gestion de l'objet Config_Util::$init. |
@@ -50,49 +50,49 @@ discard block |
||
50 | 50 | * boolean True si aucune erreur s'est produite. |
51 | 51 | *}. |
52 | 52 | */ |
53 | - public function init_config( $path_to_config_file, $plugin_slug = '' ) { |
|
54 | - if ( empty( $path_to_config_file ) ) { |
|
55 | - return new \WP_Error( 'broke', __( 'Unable to load file', 'eoxia' ) ); |
|
53 | + public function init_config($path_to_config_file, $plugin_slug = '') { |
|
54 | + if (empty($path_to_config_file)) { |
|
55 | + return new \WP_Error('broke', __('Unable to load file', 'eoxia')); |
|
56 | 56 | } |
57 | 57 | |
58 | - if ( ! file_exists( $path_to_config_file ) ) { |
|
59 | - return new \WP_Error( 'broke', __( sprintf( 'File %s is not found', $path_to_config_file ) ) ); |
|
58 | + if (!file_exists($path_to_config_file)) { |
|
59 | + return new \WP_Error('broke', __(sprintf('File %s is not found', $path_to_config_file))); |
|
60 | 60 | } |
61 | 61 | |
62 | - $tmp_config = JSON_Util::g()->open_and_decode( $path_to_config_file ); |
|
63 | - if ( empty( $tmp_config->slug ) ) { |
|
64 | - return new \WP_Error( 'broke', __( 'This plugin need to have a slug', 'eoxia' ) ); |
|
62 | + $tmp_config = JSON_Util::g()->open_and_decode($path_to_config_file); |
|
63 | + if (empty($tmp_config->slug)) { |
|
64 | + return new \WP_Error('broke', __('This plugin need to have a slug', 'eoxia')); |
|
65 | 65 | } |
66 | 66 | |
67 | - $type = isset( $tmp_config->modules ) ? 'main' : 'module'; |
|
67 | + $type = isset($tmp_config->modules) ? 'main' : 'module'; |
|
68 | 68 | |
69 | - if ( 'main' === $type ) { |
|
70 | - if ( $tmp_config->slug !== $plugin_slug && '' !== $plugin_slug ) { |
|
71 | - return new \WP_Error( 'broke', __( sprintf( 'Slug of plugin is not equal main config json file name %s => %s. Set correct slug in the file: %s', $plugin_slug, $tmp_config->slug, $path_to_config_file ), 'eoxia' ) ); |
|
69 | + if ('main' === $type) { |
|
70 | + if ($tmp_config->slug !== $plugin_slug && '' !== $plugin_slug) { |
|
71 | + return new \WP_Error('broke', __(sprintf('Slug of plugin is not equal main config json file name %s => %s. Set correct slug in the file: %s', $plugin_slug, $tmp_config->slug, $path_to_config_file), 'eoxia')); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - if ( ! empty( $plugin_slug ) ) { |
|
76 | - if ( ! isset( self::$init[ $plugin_slug ] ) ) { |
|
77 | - self::$init[ $plugin_slug ] = $tmp_config; |
|
75 | + if (!empty($plugin_slug)) { |
|
76 | + if (!isset(self::$init[$plugin_slug])) { |
|
77 | + self::$init[$plugin_slug] = $tmp_config; |
|
78 | 78 | } else { |
79 | - $abspath = str_replace( '\\', '/', ABSPATH ); |
|
79 | + $abspath = str_replace('\\', '/', ABSPATH); |
|
80 | 80 | |
81 | 81 | $slug = $tmp_config->slug; |
82 | - $tmp_path = str_replace( '\\', '/', self::$init[ $plugin_slug ]->path ); |
|
82 | + $tmp_path = str_replace('\\', '/', self::$init[$plugin_slug]->path); |
|
83 | 83 | $tmp_config->module_path = $tmp_config->path; |
84 | 84 | |
85 | - $tmp_config->url = str_replace( $abspath, site_url('/'), $tmp_path . $tmp_config->path ); |
|
86 | - $tmp_config->url = str_replace( '\\', '/', $tmp_config->url ); |
|
85 | + $tmp_config->url = str_replace($abspath, site_url('/'), $tmp_path . $tmp_config->path); |
|
86 | + $tmp_config->url = str_replace('\\', '/', $tmp_config->url); |
|
87 | 87 | $tmp_config->path = $tmp_path . $tmp_config->path; |
88 | - if ( isset( $tmp_config->external ) && ! empty( $tmp_config->external ) ) { |
|
88 | + if (isset($tmp_config->external) && !empty($tmp_config->external)) { |
|
89 | 89 | self::$init['external']->$slug = $tmp_config; |
90 | 90 | } else { |
91 | - self::$init[ $plugin_slug ]->$slug = $tmp_config; |
|
91 | + self::$init[$plugin_slug]->$slug = $tmp_config; |
|
92 | 92 | } |
93 | 93 | } |
94 | 94 | } else { |
95 | - self::$init[ $tmp_config->slug ] = $tmp_config; |
|
95 | + self::$init[$tmp_config->slug] = $tmp_config; |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | } |
@@ -57,7 +57,7 @@ |
||
57 | 57 | * @param string $path Le chemin du plugin. |
58 | 58 | * @param string $plugin_slug Le slug principale du plugin défini dans le fichier config.json principale. |
59 | 59 | * |
60 | - * @return WP_Error|bool { |
|
60 | + * @return \WP_Error|null { |
|
61 | 61 | * WP_Error Si le module n'existe pas dans le tableau externals du fichier principale de config.json. |
62 | 62 | * WP_Error Si le fichier n'existe pas |
63 | 63 | * bool Si aucune erreur s'est produite. |
@@ -114,16 +114,16 @@ |
||
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
117 | - * Appel la méthode 'exec' de l'objet 'External_Util' afin d'initialiser les externals. |
|
118 | - * |
|
119 | - * @since 0.1.0 |
|
120 | - * @version 1.0.0 |
|
121 | - * |
|
122 | - * @param string $path Le chemin du plugin. |
|
123 | - * @param string $plugin_slug Le slug principale du plugin défini dans le fichier config.json principale. |
|
124 | - * |
|
125 | - * @return void |
|
126 | - */ |
|
117 | + * Appel la méthode 'exec' de l'objet 'External_Util' afin d'initialiser les externals. |
|
118 | + * |
|
119 | + * @since 0.1.0 |
|
120 | + * @version 1.0.0 |
|
121 | + * |
|
122 | + * @param string $path Le chemin du plugin. |
|
123 | + * @param string $plugin_slug Le slug principale du plugin défini dans le fichier config.json principale. |
|
124 | + * |
|
125 | + * @return void |
|
126 | + */ |
|
127 | 127 | private function init_external( $path, $plugin_slug ) { |
128 | 128 | if ( empty( Config_Util::$init['external'] ) ) { |
129 | 129 | Config_Util::$init['external'] = new \stdClass(); |
@@ -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\Init_Util' ) ) { |
|
18 | +if (!class_exists('\eoxia\Init_Util')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Cette classe initialise tous les fichiers config.json |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @return void |
41 | 41 | */ |
42 | - public function exec( $path, $plugin_slug ) { |
|
43 | - self::read_core_util_file_and_include( $path, $plugin_slug ); |
|
44 | - self::init_main_config( $path, $plugin_slug ); |
|
45 | - self::init_external( $path, $plugin_slug ); |
|
42 | + public function exec($path, $plugin_slug) { |
|
43 | + self::read_core_util_file_and_include($path, $plugin_slug); |
|
44 | + self::init_main_config($path, $plugin_slug); |
|
45 | + self::init_external($path, $plugin_slug); |
|
46 | 46 | Config_Util::$init['main'] = new \stdClass(); |
47 | 47 | Config_Util::$init['main']->full_plugin_path = $path; |
48 | - self::init_module( $path, $plugin_slug ); |
|
48 | + self::init_module($path, $plugin_slug); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -63,27 +63,27 @@ discard block |
||
63 | 63 | * bool Si aucune erreur s'est produite. |
64 | 64 | *} |
65 | 65 | */ |
66 | - private function read_core_util_file_and_include( $path, $plugin_slug ) { |
|
66 | + private function read_core_util_file_and_include($path, $plugin_slug) { |
|
67 | 67 | $path_to_core_folder_util = $path . 'core/util/'; |
68 | - if ( ! file_exists( $path_to_core_folder_util ) ) { |
|
69 | - return new \WP_Error( 'broke', __( 'Impossible de charger les fichiers .utils', $plugin_slug ) ); |
|
68 | + if (!file_exists($path_to_core_folder_util)) { |
|
69 | + return new \WP_Error('broke', __('Impossible de charger les fichiers .utils', $plugin_slug)); |
|
70 | 70 | } |
71 | 71 | |
72 | - if ( ! is_dir( $path_to_core_folder_util ) ) { |
|
73 | - return new \WP_Error( 'broke', __( '$path_to_core_folder_util n\'est pas un dossier', $plugin_slug ) ); |
|
72 | + if (!is_dir($path_to_core_folder_util)) { |
|
73 | + return new \WP_Error('broke', __('$path_to_core_folder_util n\'est pas un dossier', $plugin_slug)); |
|
74 | 74 | } |
75 | 75 | |
76 | - $list_file_name = scandir( $path_to_core_folder_util ); |
|
76 | + $list_file_name = scandir($path_to_core_folder_util); |
|
77 | 77 | |
78 | - if ( ! $list_file_name || ! is_array( $list_file_name ) ) { |
|
79 | - return new \WP_Error( 'broke', __( 'Impossible de charger les fichiers .utils', $plugin_slug ) ); |
|
78 | + if (!$list_file_name || !is_array($list_file_name)) { |
|
79 | + return new \WP_Error('broke', __('Impossible de charger les fichiers .utils', $plugin_slug)); |
|
80 | 80 | } |
81 | 81 | |
82 | - if ( ! empty( $list_file_name ) ) { |
|
83 | - foreach ( $list_file_name as $file_name ) { |
|
84 | - if ( '.' !== $file_name && '..' !== $file_name && 'index.php' !== $file_name && '.git' !== $file_name && 'README.md' !== $file_name ) { |
|
85 | - $file_path = realpath( $path_to_core_folder_util . $file_name ); |
|
86 | - require_once( $file_path ); |
|
82 | + if (!empty($list_file_name)) { |
|
83 | + foreach ($list_file_name as $file_name) { |
|
84 | + if ('.' !== $file_name && '..' !== $file_name && 'index.php' !== $file_name && '.git' !== $file_name && 'README.md' !== $file_name) { |
|
85 | + $file_path = realpath($path_to_core_folder_util . $file_name); |
|
86 | + require_once($file_path); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | } |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * |
101 | 101 | * @return void |
102 | 102 | */ |
103 | - private function init_main_config( $path, $plugin_slug ) { |
|
103 | + private function init_main_config($path, $plugin_slug) { |
|
104 | 104 | $main_config_path = $plugin_slug . '.config.json'; |
105 | - $init_status = \eoxia\Config_Util::g()->init_config( $path . $main_config_path ); |
|
105 | + $init_status = \eoxia\Config_Util::g()->init_config($path . $main_config_path); |
|
106 | 106 | |
107 | - if ( \is_wp_error( $init_status ) ) { |
|
108 | - exit( $init_status->errors['broke'][0] ); |
|
107 | + if (\is_wp_error($init_status)) { |
|
108 | + exit($init_status->errors['broke'][0]); |
|
109 | 109 | } |
110 | 110 | |
111 | - if ( isset( Config_Util::$init[ $plugin_slug ] ) ) { |
|
112 | - Config_Util::$init[ $plugin_slug ]->path = $path; |
|
111 | + if (isset(Config_Util::$init[$plugin_slug])) { |
|
112 | + Config_Util::$init[$plugin_slug]->path = $path; |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -124,12 +124,12 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return void |
126 | 126 | */ |
127 | - private function init_external( $path, $plugin_slug ) { |
|
128 | - if ( empty( Config_Util::$init['external'] ) ) { |
|
127 | + private function init_external($path, $plugin_slug) { |
|
128 | + if (empty(Config_Util::$init['external'])) { |
|
129 | 129 | Config_Util::$init['external'] = new \stdClass(); |
130 | 130 | } |
131 | 131 | |
132 | - \eoxia\External_Util::g()->exec( $path, $plugin_slug ); |
|
132 | + \eoxia\External_Util::g()->exec($path, $plugin_slug); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | /** |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | * |
144 | 144 | * @return void |
145 | 145 | */ |
146 | - private function init_module( $path, $plugin_slug ) { |
|
147 | - $init_module_status = \eoxia\Module_Util::g()->exec_module( $path, $plugin_slug ); |
|
146 | + private function init_module($path, $plugin_slug) { |
|
147 | + $init_module_status = \eoxia\Module_Util::g()->exec_module($path, $plugin_slug); |
|
148 | 148 | |
149 | - if ( \is_wp_error( $init_module_status ) ) { |
|
150 | - exit( $init_module_status->errors['broke'][0] ); |
|
149 | + if (\is_wp_error($init_module_status)) { |
|
150 | + exit($init_module_status->errors['broke'][0]); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * @param string $path Le chemin vers le module externe. |
42 | 42 | * @param string $plugin_slug Le slug principale du plugin dans le fichier principale config.json. |
43 | 43 | * |
44 | - * @return \WP_Error|boolean { |
|
44 | + * @return \WP_Error|null { |
|
45 | 45 | * WP_Error Si le fichier est inexistant ou si le plugin n'a pas de submodule. |
46 | 46 | * boolean True si aucune erreur s'est produite. |
47 | 47 | *}. |
@@ -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\Module_Util' ) ) { |
|
19 | +if (!class_exists('\eoxia\Module_Util')) { |
|
20 | 20 | /** |
21 | 21 | * Gestion des modules |
22 | 22 | */ |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | * boolean True si aucune erreur s'est produite. |
47 | 47 | *}. |
48 | 48 | */ |
49 | - public function exec_module( $path, $plugin_slug ) { |
|
50 | - if ( empty( \eoxia\Config_Util::$init[ $plugin_slug ] ) ) { |
|
51 | - return new \WP_Error( 'broke', sprintf( __( 'Main config %s not init', $plugin_slug ), $plugin_slug ) ); |
|
49 | + public function exec_module($path, $plugin_slug) { |
|
50 | + if (empty(\eoxia\Config_Util::$init[$plugin_slug])) { |
|
51 | + return new \WP_Error('broke', sprintf(__('Main config %s not init', $plugin_slug), $plugin_slug)); |
|
52 | 52 | } |
53 | 53 | |
54 | - if ( ! empty( \eoxia\Config_Util::$init[ $plugin_slug ]->modules ) ) { |
|
55 | - foreach ( \eoxia\Config_Util::$init[ $plugin_slug ]->modules as $module_json_path ) { |
|
56 | - self::inc_config_module( $plugin_slug, $path . $module_json_path ); |
|
57 | - self::inc_module( $plugin_slug, $path . $module_json_path ); |
|
54 | + if (!empty(\eoxia\Config_Util::$init[$plugin_slug]->modules)) { |
|
55 | + foreach (\eoxia\Config_Util::$init[$plugin_slug]->modules as $module_json_path) { |
|
56 | + self::inc_config_module($plugin_slug, $path . $module_json_path); |
|
57 | + self::inc_module($plugin_slug, $path . $module_json_path); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | } |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @return void |
72 | 72 | */ |
73 | - public function inc_config_module( $plugin_slug, $module_json_path ) { |
|
74 | - $init_status = \eoxia\Config_Util::g()->init_config( $module_json_path, $plugin_slug ); |
|
73 | + public function inc_config_module($plugin_slug, $module_json_path) { |
|
74 | + $init_status = \eoxia\Config_Util::g()->init_config($module_json_path, $plugin_slug); |
|
75 | 75 | |
76 | - if ( \is_wp_error( $init_status ) ) { |
|
77 | - exit( $init_status->errors['broke'][0] ); |
|
76 | + if (\is_wp_error($init_status)) { |
|
77 | + exit($init_status->errors['broke'][0]); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | } |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return void |
92 | 92 | */ |
93 | - public function inc_module( $plugin_slug, $module_json_path ) { |
|
94 | - $module_name = basename( $module_json_path, '.config.json' ); |
|
95 | - $module_path = dirname( $module_json_path ); |
|
93 | + public function inc_module($plugin_slug, $module_json_path) { |
|
94 | + $module_name = basename($module_json_path, '.config.json'); |
|
95 | + $module_path = dirname($module_json_path); |
|
96 | 96 | |
97 | - if ( 'eo-framework' !== $plugin_slug ) { |
|
98 | - if ( ! isset( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name ) ) { |
|
99 | - exit( __( sprintf( '%s not exists. You need to check: 1. The folder name and file name.config.json is equal at the slug name in config.', $module_name ) ) ); |
|
97 | + if ('eo-framework' !== $plugin_slug) { |
|
98 | + if (!isset(\eoxia\Config_Util::$init[$plugin_slug]->$module_name)) { |
|
99 | + exit(__(sprintf('%s not exists. You need to check: 1. The folder name and file name.config.json is equal at the slug name in config.', $module_name))); |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | |
103 | - if ( ! isset( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->state ) || ( isset( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->state ) && \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->state ) ) { |
|
104 | - if ( ! empty( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->dependencies ) ) { |
|
103 | + if (!isset(\eoxia\Config_Util::$init[$plugin_slug]->$module_name->state) || (isset(\eoxia\Config_Util::$init[$plugin_slug]->$module_name->state) && \eoxia\Config_Util::$init[$plugin_slug]->$module_name->state)) { |
|
104 | + if (!empty(\eoxia\Config_Util::$init[$plugin_slug]->$module_name->dependencies)) { |
|
105 | 105 | $can_inc = true; |
106 | 106 | |
107 | 107 | // Vérification de la dépendence d'inclusion. |
108 | - if ( ! empty( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->dependencies_func ) ) { |
|
109 | - if ( ! empty( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->dependencies_func ) ) { |
|
110 | - foreach ( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->dependencies_func as $element ) { |
|
111 | - if ( ! call_user_func( $element ) ) { |
|
108 | + if (!empty(\eoxia\Config_Util::$init[$plugin_slug]->$module_name->dependencies_func)) { |
|
109 | + if (!empty(\eoxia\Config_Util::$init[$plugin_slug]->$module_name->dependencies_func)) { |
|
110 | + foreach (\eoxia\Config_Util::$init[$plugin_slug]->$module_name->dependencies_func as $element) { |
|
111 | + if (!call_user_func($element)) { |
|
112 | 112 | $can_inc = false; |
113 | 113 | break; |
114 | 114 | } |
@@ -116,15 +116,15 @@ discard block |
||
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
119 | - if ( $can_inc ) { |
|
120 | - foreach ( \eoxia\Config_Util::$init[ $plugin_slug ]->$module_name->dependencies as $dependence_folder => $list_option ) { |
|
119 | + if ($can_inc) { |
|
120 | + foreach (\eoxia\Config_Util::$init[$plugin_slug]->$module_name->dependencies as $dependence_folder => $list_option) { |
|
121 | 121 | $path_to_module_and_dependence_folder = $module_path . '/' . $dependence_folder . '/'; |
122 | 122 | |
123 | - if ( ! empty( $list_option->priority ) ) { |
|
124 | - $this->inc_priority_file( $path_to_module_and_dependence_folder, $dependence_folder, $list_option->priority ); |
|
123 | + if (!empty($list_option->priority)) { |
|
124 | + $this->inc_priority_file($path_to_module_and_dependence_folder, $dependence_folder, $list_option->priority); |
|
125 | 125 | } |
126 | 126 | |
127 | - \eoxia\Include_util::g()->in_folder( $path_to_module_and_dependence_folder ); |
|
127 | + \eoxia\Include_util::g()->in_folder($path_to_module_and_dependence_folder); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | * @param array $list_priority_file La liste des chemins des fichiers à inclure en priorité. |
143 | 143 | * @return void nothing |
144 | 144 | */ |
145 | - public function inc_priority_file( $path_to_module_and_dependence_folder, $dependence_folder, $list_priority_file ) { |
|
146 | - if ( ! empty( $list_priority_file ) ) { |
|
147 | - foreach ( $list_priority_file as $file_name ) { |
|
148 | - $path_file = realpath( $path_to_module_and_dependence_folder . $file_name ); |
|
145 | + public function inc_priority_file($path_to_module_and_dependence_folder, $dependence_folder, $list_priority_file) { |
|
146 | + if (!empty($list_priority_file)) { |
|
147 | + foreach ($list_priority_file as $file_name) { |
|
148 | + $path_file = realpath($path_to_module_and_dependence_folder . $file_name); |
|
149 | 149 | |
150 | - require_once( $path_file ); |
|
150 | + require_once($path_file); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | } |
@@ -162,20 +162,20 @@ discard block |
||
162 | 162 | * @param string $slug Le SLUG du module en question. |
163 | 163 | * @param bool $state true ou false. |
164 | 164 | */ |
165 | - public function set_state( $namespace, $slug, $state ) { |
|
166 | - $path_to_json = \eoxia\Config_Util::$init[ $namespace ]->$slug->path . '/' . $slug . '.config.json'; |
|
165 | + public function set_state($namespace, $slug, $state) { |
|
166 | + $path_to_json = \eoxia\Config_Util::$init[$namespace]->$slug->path . '/' . $slug . '.config.json'; |
|
167 | 167 | |
168 | - $json_content = \eoxia\JSON_Util::g()->open_and_decode( $path_to_json ); |
|
168 | + $json_content = \eoxia\JSON_Util::g()->open_and_decode($path_to_json); |
|
169 | 169 | $json_content->state = $state; |
170 | - $json_content = json_encode( $json_content, JSON_PRETTY_PRINT ); |
|
171 | - $json_content = preg_replace_callback( '/\\\\u([0-9a-f]{4})/i', function ( $matches ) { |
|
172 | - $sym = mb_convert_encoding( pack( 'H*', $matches[1] ), 'UTF-8', 'UTF-16' ); |
|
170 | + $json_content = json_encode($json_content, JSON_PRETTY_PRINT); |
|
171 | + $json_content = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', function($matches) { |
|
172 | + $sym = mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16'); |
|
173 | 173 | return $sym; |
174 | - }, $json_content ); |
|
174 | + }, $json_content); |
|
175 | 175 | |
176 | - $file = fopen( $path_to_json, 'w+' ); |
|
177 | - fwrite( $file, str_replace( '\/', '/', $json_content ) ); |
|
178 | - fclose( $file ); |
|
176 | + $file = fopen($path_to_json, 'w+'); |
|
177 | + fwrite($file, str_replace('\/', '/', $json_content)); |
|
178 | + fclose($file); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | } // End if(). |
@@ -66,7 +66,7 @@ |
||
66 | 66 | * @since 1.0.0 |
67 | 67 | * @version 1.0.0 |
68 | 68 | * |
69 | - * @param object $current L'objet complet. |
|
69 | + * @param Helper_Class $current L'objet complet. |
|
70 | 70 | */ |
71 | 71 | private function delete_model_for_print( $current ) { |
72 | 72 | if ( ! empty( $this->model ) ) { |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | |
12 | 12 | namespace eoxia; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { exit; } |
|
14 | +if (!defined('ABSPATH')) { exit; } |
|
15 | 15 | |
16 | -if ( ! class_exists( '\eoxia\Helper_Class' ) ) { |
|
16 | +if (!class_exists('\eoxia\Helper_Class')) { |
|
17 | 17 | |
18 | 18 | /** |
19 | 19 | * Classe helper pour les modèles. |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | * @return string Le nom de la classe avec le namespace si existant. |
42 | 42 | */ |
43 | 43 | public function get_class() { |
44 | - $class_name = get_class( $this ); |
|
45 | - $class_name = str_replace( 'Model', 'Class', $class_name ); |
|
46 | - $class_name = str_replace( 'model', 'Class', $class_name ); |
|
47 | - $class_name = str_replace( '\\', '/', $class_name ); |
|
44 | + $class_name = get_class($this); |
|
45 | + $class_name = str_replace('Model', 'Class', $class_name); |
|
46 | + $class_name = str_replace('model', 'Class', $class_name); |
|
47 | + $class_name = str_replace('\\', '/', $class_name); |
|
48 | 48 | |
49 | 49 | return $class_name; |
50 | 50 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | * @return string void |
56 | 56 | */ |
57 | 57 | public function __toString() { |
58 | - $this->delete_model_for_print( $this ); |
|
59 | - echo '<pre>'; print_r( $this ); echo '</pre>'; |
|
58 | + $this->delete_model_for_print($this); |
|
59 | + echo '<pre>'; print_r($this); echo '</pre>'; |
|
60 | 60 | return ''; |
61 | 61 | } |
62 | 62 | |
@@ -68,17 +68,17 @@ discard block |
||
68 | 68 | * |
69 | 69 | * @param object $current L'objet complet. |
70 | 70 | */ |
71 | - private function delete_model_for_print( $current ) { |
|
72 | - if ( ! empty( $this->model ) ) { |
|
73 | - unset( $this->model ); |
|
71 | + private function delete_model_for_print($current) { |
|
72 | + if (!empty($this->model)) { |
|
73 | + unset($this->model); |
|
74 | 74 | } |
75 | 75 | |
76 | - foreach ( $current as &$content ) { |
|
77 | - if ( is_array( $content ) ) { |
|
78 | - foreach ( $content as &$model ) { |
|
79 | - if ( ! empty( $model->model ) ) { |
|
80 | - unset( $model->model ); |
|
81 | - $this->delete_model_for_print( $model ); |
|
76 | + foreach ($current as &$content) { |
|
77 | + if (is_array($content)) { |
|
78 | + foreach ($content as &$model) { |
|
79 | + if (!empty($model->model)) { |
|
80 | + unset($model->model); |
|
81 | + $this->delete_model_for_print($model); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | } |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | * @param string $offset Parameter name. |
94 | 94 | * @return bool Whether the parameter is set. |
95 | 95 | */ |
96 | - public function offsetExists( $offset ) { |
|
97 | - return isset( $this->$offset ); |
|
96 | + public function offsetExists($offset) { |
|
97 | + return isset($this->$offset); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @param string $offset Parameter name. |
106 | 106 | * @return mixed|null Value if set, null otherwise. |
107 | 107 | */ |
108 | - public function offsetGet( $offset ) { |
|
109 | - return isset( $this->$offset ) ? $this->$offset : null; |
|
108 | + public function offsetGet($offset) { |
|
109 | + return isset($this->$offset) ? $this->$offset : null; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param string $offset Parameter name. |
118 | 118 | * @param mixed $value Parameter value. |
119 | 119 | */ |
120 | - public function offsetSet( $offset, $value ) { |
|
120 | + public function offsetSet($offset, $value) { |
|
121 | 121 | $this->$offset = $value; |
122 | 122 | } |
123 | 123 | |
@@ -128,8 +128,8 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param string $offset Parameter name. |
130 | 130 | */ |
131 | - public function offsetUnset( $offset ) { |
|
132 | - unset( $this->$offset ); |
|
131 | + public function offsetUnset($offset) { |
|
132 | + unset($this->$offset); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | * @since 1.0.0 |
37 | 37 | * @version 1.0.0 |
38 | 38 | * |
39 | - * @return string The rest api base for current element |
|
39 | + * @return boolean The rest api base for current element |
|
40 | 40 | */ |
41 | 41 | public function check_cap( $cap ) { |
42 | 42 | if ( ( ! in_array( $_SERVER['REMOTE_ADDR'], Config_Util::$init['eo-framework']->wpeo_model->allowed_ip_for_unauthentified_access_rest, true ) ) && ! current_user_can( $this->capabilities[ 'get' ] ) ) { |
@@ -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\Rest_Class' ) ) { |
|
18 | +if (!class_exists('\eoxia\Rest_Class')) { |
|
19 | 19 | /** |
20 | 20 | * Gestion des utilisateurs (POST, PUT, GET, DELETE) |
21 | 21 | */ |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * [construct description] |
26 | 26 | */ |
27 | 27 | protected function construct() { |
28 | - add_action( 'rest_api_init', array( $this, 'register_routes' ), 20 ); |
|
28 | + add_action('rest_api_init', array($this, 'register_routes'), 20); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return string The rest api base for current element |
40 | 40 | */ |
41 | - public function check_cap( $cap ) { |
|
42 | - if ( ( ! in_array( $_SERVER['REMOTE_ADDR'], Config_Util::$init['eo-framework']->wpeo_model->allowed_ip_for_unauthentified_access_rest, true ) ) && ! current_user_can( $this->capabilities[ 'get' ] ) ) { |
|
41 | + public function check_cap($cap) { |
|
42 | + if ((!in_array($_SERVER['REMOTE_ADDR'], Config_Util::$init['eo-framework']->wpeo_model->allowed_ip_for_unauthentified_access_rest, true)) && !current_user_can($this->capabilities['get'])) { |
|
43 | 43 | return false; |
44 | 44 | } |
45 | 45 | return true; |
@@ -64,57 +64,57 @@ discard block |
||
64 | 64 | * @version 1.0.0 |
65 | 65 | */ |
66 | 66 | public function register_routes() { |
67 | - $element_namespace = new \ReflectionClass( get_called_class() ); |
|
68 | - register_rest_route( $element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base . '/schema', array( |
|
67 | + $element_namespace = new \ReflectionClass(get_called_class()); |
|
68 | + register_rest_route($element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base . '/schema', array( |
|
69 | 69 | array( |
70 | 70 | 'method' => \WP_REST_Server::READABLE, |
71 | - 'callback' => array( $this, 'get_schema' ), |
|
71 | + 'callback' => array($this, 'get_schema'), |
|
72 | 72 | ), |
73 | - ) ); |
|
73 | + )); |
|
74 | 74 | |
75 | - register_rest_route( $element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base, array( |
|
75 | + register_rest_route($element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base, array( |
|
76 | 76 | array( |
77 | 77 | 'methods' => \WP_REST_Server::READABLE, |
78 | - 'callback' => array( $this, 'get_from_parent' ), |
|
79 | - 'permission_callback' => function(){ |
|
80 | - return Rest_Class::g()->check_cap( 'get' ); |
|
78 | + 'callback' => array($this, 'get_from_parent'), |
|
79 | + 'permission_callback' => function() { |
|
80 | + return Rest_Class::g()->check_cap('get'); |
|
81 | 81 | } |
82 | 82 | ), |
83 | 83 | array( |
84 | 84 | 'methods' => \WP_REST_Server::CREATABLE, |
85 | - 'callback' => array( $this, 'create_from_parent' ), |
|
86 | - 'permission_callback' => function(){ |
|
87 | - return Rest_Class::g()->check_cap( 'post' ); |
|
85 | + 'callback' => array($this, 'create_from_parent'), |
|
86 | + 'permission_callback' => function() { |
|
87 | + return Rest_Class::g()->check_cap('post'); |
|
88 | 88 | } |
89 | 89 | ), |
90 | - ), true ); |
|
90 | + ), true); |
|
91 | 91 | |
92 | - register_rest_route( $element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base . '/(?P<id>[\d]+)', array( |
|
92 | + register_rest_route($element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base . '/(?P<id>[\d]+)', array( |
|
93 | 93 | array( |
94 | 94 | 'method' => \WP_REST_Server::READABLE, |
95 | - 'callback' => array( $this, 'get_from_parent' ), |
|
96 | - 'permission_callback' => function(){ |
|
97 | - return Rest_Class::g()->check_cap( 'get' ); |
|
95 | + 'callback' => array($this, 'get_from_parent'), |
|
96 | + 'permission_callback' => function() { |
|
97 | + return Rest_Class::g()->check_cap('get'); |
|
98 | 98 | }, |
99 | 99 | ), |
100 | 100 | array( |
101 | 101 | 'methods' => \WP_REST_Server::CREATABLE, |
102 | - 'callback' => array( $this, 'create_from_parent' ), |
|
103 | - 'permission_callback' => function(){ |
|
104 | - return Rest_Class::g()->check_cap( 'put' ); |
|
102 | + 'callback' => array($this, 'create_from_parent'), |
|
103 | + 'permission_callback' => function() { |
|
104 | + return Rest_Class::g()->check_cap('put'); |
|
105 | 105 | } |
106 | 106 | ), |
107 | - ), true ); |
|
107 | + ), true); |
|
108 | 108 | |
109 | - register_rest_route( $element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base . 's/(?P<id>[\d]+)', array( |
|
109 | + register_rest_route($element_namespace->getNamespaceName() . '/v' . Config_Util::$init['eo-framework']->wpeo_model->api_version, '/' . $this->base . 's/(?P<id>[\d]+)', array( |
|
110 | 110 | array( |
111 | 111 | 'method' => \WP_REST_Server::READABLE, |
112 | - 'callback' => array( $this, 'get_parent_from_parent' ), |
|
113 | - 'permission_callback' => function(){ |
|
114 | - return Rest_Class::g()->check_cap( 'get' ); |
|
112 | + 'callback' => array($this, 'get_parent_from_parent'), |
|
113 | + 'permission_callback' => function() { |
|
114 | + return Rest_Class::g()->check_cap('get'); |
|
115 | 115 | } |
116 | 116 | ), |
117 | - ), true ); |
|
117 | + ), true); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -128,22 +128,22 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @return mixed Element list or single element if id was specified. |
130 | 130 | */ |
131 | - public function get_from_parent( $request ) { |
|
131 | + public function get_from_parent($request) { |
|
132 | 132 | $args = array(); |
133 | 133 | $single = false; |
134 | 134 | $list = null; |
135 | 135 | |
136 | - if ( ! empty( $request ) && ( ! empty( $request['id'] ) ) ) { |
|
136 | + if (!empty($request) && (!empty($request['id']))) { |
|
137 | 137 | $args['id'] = $request['id']; |
138 | 138 | $single = true; |
139 | 139 | } |
140 | 140 | |
141 | - $elements = $this->get( $args, $single ); |
|
142 | - if ( ! empty( $elements ) ) { |
|
143 | - if ( $single ) { |
|
141 | + $elements = $this->get($args, $single); |
|
142 | + if (!empty($elements)) { |
|
143 | + if ($single) { |
|
144 | 144 | $list = $elements->data; |
145 | 145 | } else { |
146 | - foreach ( $elements as $element ) { |
|
146 | + foreach ($elements as $element) { |
|
147 | 147 | $list[] = $element->data; |
148 | 148 | } |
149 | 149 | } |
@@ -162,17 +162,17 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return mixed Element list or single element if id was specified. |
164 | 164 | */ |
165 | - public function get_parent_from_parent( $request ) { |
|
165 | + public function get_parent_from_parent($request) { |
|
166 | 166 | $args = array(); |
167 | 167 | $single = false; |
168 | 168 | |
169 | - if ( ! empty( $request ) && ( ! empty( $request['id'] ) ) ) { |
|
169 | + if (!empty($request) && (!empty($request['id']))) { |
|
170 | 170 | $args['post_id'] = $request['id']; |
171 | 171 | $args['status'] = '1'; |
172 | 172 | $single = true; |
173 | 173 | } |
174 | 174 | |
175 | - return $this->get( $args, $single ); |
|
175 | + return $this->get($args, $single); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return mixed New created element. |
187 | 187 | */ |
188 | - public function create_from_parent( $request ) { |
|
189 | - return $this->update( $request->get_params() ); |
|
188 | + public function create_from_parent($request) { |
|
189 | + return $this->update($request->get_params()); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @since 6.0.0 |
120 | 120 | * |
121 | - * @param array $model_type Le type du document. |
|
121 | + * @param string $model_type Le type du document. |
|
122 | 122 | * |
123 | 123 | * @return array |
124 | 124 | */ |
@@ -268,8 +268,7 @@ discard block |
||
268 | 268 | * |
269 | 269 | * @since 1.0.0 |
270 | 270 | * |
271 | - * @param object $element L'élément pour lequel il faut créer le document |
|
272 | - * @param array $document_meta Les données a écrire dans le modèle de document |
|
271 | + * @param array $document_id Les données a écrire dans le modèle de document |
|
273 | 272 | * |
274 | 273 | * @return object Le résultat de la création du document |
275 | 274 | */ |
@@ -355,9 +354,7 @@ discard block |
||
355 | 354 | * |
356 | 355 | * @since 6.0.0 |
357 | 356 | * |
358 | - * @param string $model_path Le chemin vers le fichier modèle a utiliser pour la génération. |
|
359 | - * @param array $document_content Un tableau contenant le contenu du fichier à écrire selon l'élément en cours d'impression. |
|
360 | - * @param string $document_name Le nom du document. |
|
357 | + * @param string $document_id Le nom du document. |
|
361 | 358 | * |
362 | 359 | * array['status'] boolean True si tout s'est bien passé sinon false. |
363 | 360 | * array['message'] string Le message informatif de la méthode. |
@@ -10,11 +10,11 @@ discard block |
||
10 | 10 | |
11 | 11 | namespace eoxia; |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if (!defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
17 | -if ( ! class_exists( '\eoxia\ODT_Class' ) ) { |
|
17 | +if (!class_exists('\eoxia\ODT_Class')) { |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Gestion des ODT (POST, PUT, GET, DELETE) |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @var array |
88 | 88 | */ |
89 | - private $default_types = array( 'model', 'default_model' ); |
|
89 | + private $default_types = array('model', 'default_model'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Le nom du modèle ODT. |
@@ -107,9 +107,9 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return string Le chemin vers le document |
109 | 109 | */ |
110 | - public function get_dir_path( $path_type = 'basedir' ) { |
|
110 | + public function get_dir_path($path_type = 'basedir') { |
|
111 | 111 | $upload_dir = wp_upload_dir(); |
112 | - $response = str_replace( '\\', '/', $upload_dir[ $path_type ] ); |
|
112 | + $response = str_replace('\\', '/', $upload_dir[$path_type]); |
|
113 | 113 | return $response; |
114 | 114 | } |
115 | 115 | |
@@ -122,30 +122,30 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - public function get_default_model( $model_type ) { |
|
126 | - if ( 'zip' === $model_type ) { |
|
125 | + public function get_default_model($model_type) { |
|
126 | + if ('zip' === $model_type) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | 130 | $response = array( |
131 | 131 | 'status' => true, |
132 | 132 | 'id' => null, |
133 | - 'path' => str_replace( '\\', '/', $this->path . 'core/assets/document_template/' . $this->odt_name . '.odt' ), |
|
134 | - 'url' => str_replace( '\\', '/', $this->url . 'core/assets/document_template/' . $this->odt_name . '.odt' ), |
|
133 | + 'path' => str_replace('\\', '/', $this->path . 'core/assets/document_template/' . $this->odt_name . '.odt'), |
|
134 | + 'url' => str_replace('\\', '/', $this->url . 'core/assets/document_template/' . $this->odt_name . '.odt'), |
|
135 | 135 | // translators: Pour exemple: Le modèle utilisé est: C:\wamp\www\wordpress\wp-content\plugins\digirisk-alpha\core\assets\document_template\document_unique.odt. |
136 | - 'message' => sprintf( __( 'Le modèle utilisé est: %1$score/assets/document_template/%2$s.odt', 'digirisk' ), $this->path, $this->odt_name ), |
|
136 | + 'message' => sprintf(__('Le modèle utilisé est: %1$score/assets/document_template/%2$s.odt', 'digirisk'), $this->path, $this->odt_name), |
|
137 | 137 | ); |
138 | 138 | |
139 | 139 | // Merge tous les types ensembles. |
140 | - $types = array_merge( $this->default_types, (array) $model_type ); |
|
140 | + $types = array_merge($this->default_types, (array)$model_type); |
|
141 | 141 | |
142 | 142 | // Préparation de la query pour récupérer le modèle par défaut selon $model_type. |
143 | 143 | $tax_query = array( |
144 | 144 | 'relation' => 'AND', |
145 | 145 | ); |
146 | 146 | |
147 | - if ( ! empty( $types ) ) { |
|
148 | - foreach ( $types as $type ) { |
|
147 | + if (!empty($types)) { |
|
148 | + foreach ($types as $type) { |
|
149 | 149 | $tax_query[] = array( |
150 | 150 | 'taxonomy' => $this->get_attached_taxonomy(), |
151 | 151 | 'field' => 'slug', |
@@ -155,29 +155,29 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Lances la Query pour récupérer le document par défaut selon $model_type. |
158 | - $query = new \WP_Query( array( |
|
158 | + $query = new \WP_Query(array( |
|
159 | 159 | 'fields' => 'ids', |
160 | 160 | 'post_status' => 'inherit', |
161 | 161 | 'posts_per_page' => 1, |
162 | 162 | 'tax_query' => $tax_query, |
163 | 163 | 'post_type' => 'attachment', |
164 | - ) ); |
|
164 | + )); |
|
165 | 165 | |
166 | 166 | // Récupères le document |
167 | - if ( $query->have_posts() ) { |
|
167 | + if ($query->have_posts()) { |
|
168 | 168 | $upload_dir = wp_upload_dir(); |
169 | 169 | |
170 | 170 | $model_id = $query->posts[0]; |
171 | - $attachment_file_path = str_replace( '\\', '/', get_attached_file( $model_id ) ); |
|
171 | + $attachment_file_path = str_replace('\\', '/', get_attached_file($model_id)); |
|
172 | 172 | $response['id'] = $model_id; |
173 | - $response['path'] = str_replace( '\\', '/', $attachment_file_path ); |
|
174 | - $response['url'] = str_replace( str_replace( '\\', '/', $upload_dir['basedir'] ), str_replace( '\\', '/', $upload_dir['baseurl'] ), $attachment_file_path ); |
|
173 | + $response['path'] = str_replace('\\', '/', $attachment_file_path); |
|
174 | + $response['url'] = str_replace(str_replace('\\', '/', $upload_dir['basedir']), str_replace('\\', '/', $upload_dir['baseurl']), $attachment_file_path); |
|
175 | 175 | |
176 | 176 | // translators: Pour exemple: Le modèle utilisé est: C:\wamp\www\wordpress\wp-content\plugins\digirisk-alpha\core\assets\document_template\document_unique.odt. |
177 | - $response['message'] = sprintf( __( 'Le modèle utilisé est: %1$s', 'digirisk' ), $attachment_file_path ); |
|
177 | + $response['message'] = sprintf(__('Le modèle utilisé est: %1$s', 'digirisk'), $attachment_file_path); |
|
178 | 178 | } |
179 | 179 | |
180 | - if ( ! is_file( $response['path'] ) ) { |
|
180 | + if (!is_file($response['path'])) { |
|
181 | 181 | $response['status'] = false; |
182 | 182 | $response['message'] = 'Le modèle ' . $response['path'] . ' est introuvable.'; |
183 | 183 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @return integer La version +1 du document actuellement en cours de création. |
197 | 197 | */ |
198 | - public function get_revision( $type, $element_id ) { |
|
198 | + public function get_revision($type, $element_id) { |
|
199 | 199 | global $wpdb; |
200 | 200 | |
201 | 201 | // Récupération de la date courante. |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'posts_per_page' => -1, |
208 | 208 | 'post_parent' => $element_id, |
209 | 209 | 'post_type' => $type, |
210 | - 'post_status' => array( 'publish', 'inherit' ), |
|
210 | + 'post_status' => array('publish', 'inherit'), |
|
211 | 211 | 'date_query' => array( |
212 | 212 | array( |
213 | 213 | 'year' => $today['year'], |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | ), |
218 | 218 | ); |
219 | 219 | |
220 | - $document_revision = new \WP_Query( $args ); |
|
221 | - return ( $document_revision->post_count + 1 ); |
|
220 | + $document_revision = new \WP_Query($args); |
|
221 | + return ($document_revision->post_count + 1); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @return void |
234 | 234 | */ |
235 | - public function save_document_data( $parent_id, $document_meta, $args = array() ) { |
|
235 | + public function save_document_data($parent_id, $document_meta, $args = array()) { |
|
236 | 236 | $response = array(); |
237 | 237 | |
238 | 238 | // Récupères le modèle a utiliser pour la futur génération de l'ODT. |
239 | - $model_infos = $this->get_default_model( $this->get_type() ); |
|
239 | + $model_infos = $this->get_default_model($this->get_type()); |
|
240 | 240 | |
241 | - if ( ! $model_infos['status'] ) { |
|
241 | + if (!$model_infos['status']) { |
|
242 | 242 | $response['message'] = $model_infos['message']; |
243 | 243 | $response['path'] = $model_infos['path']; |
244 | 244 | return $response; |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | 'document_meta' => $document_meta, |
256 | 256 | ); |
257 | 257 | |
258 | - $document = $this->update( $document_args ); |
|
259 | - wp_set_object_terms( $document->data['id'], array( $this->get_type(), 'printed' ), $this->attached_taxonomy_type ); |
|
258 | + $document = $this->update($document_args); |
|
259 | + wp_set_object_terms($document->data['id'], array($this->get_type(), 'printed'), $this->attached_taxonomy_type); |
|
260 | 260 | |
261 | 261 | $response['document'] = $document; |
262 | 262 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return object Le résultat de la création du document |
275 | 275 | */ |
276 | - public function create_document( $document_id ) { |
|
276 | + public function create_document($document_id) { |
|
277 | 277 | $response = array( |
278 | 278 | 'status' => true, |
279 | 279 | 'message' => '', |
@@ -281,17 +281,17 @@ discard block |
||
281 | 281 | 'path' => '', |
282 | 282 | ); |
283 | 283 | |
284 | - $document = $this->generate_document( $document_id ); |
|
284 | + $document = $this->generate_document($document_id); |
|
285 | 285 | |
286 | - $file_info = $this->check_file( $document ); |
|
286 | + $file_info = $this->check_file($document); |
|
287 | 287 | |
288 | - if ( $file_info['exists'] ) { |
|
288 | + if ($file_info['exists']) { |
|
289 | 289 | $document->data['mime_type'] = $file_info['mime_type']['type']; |
290 | 290 | } |
291 | 291 | |
292 | 292 | $document->data['file_generated'] = true; |
293 | 293 | |
294 | - $document = $this->update( $document->data ); |
|
294 | + $document = $this->update($document->data); |
|
295 | 295 | |
296 | 296 | $response['document'] = $document; |
297 | 297 | |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @return array Tableau avec le status d'existence du fichier (True/False) et le lien de téléchargement du fichier. |
314 | 314 | */ |
315 | - public function check_file( $document ) { |
|
315 | + public function check_file($document) { |
|
316 | 316 | // Définition des valeurs par défaut. |
317 | 317 | $file_check = array( |
318 | 318 | 'exists' => false, |
@@ -321,30 +321,30 @@ discard block |
||
321 | 321 | 'link' => '', |
322 | 322 | ); |
323 | 323 | |
324 | - if ( ! empty( $document->data['link'] ) ) { |
|
325 | - $file_check['path'] = str_replace( site_url( '/' ), ABSPATH, $document->data['link'] ); |
|
324 | + if (!empty($document->data['link'])) { |
|
325 | + $file_check['path'] = str_replace(site_url('/'), ABSPATH, $document->data['link']); |
|
326 | 326 | $file_check['link'] = $document->data['link']; |
327 | 327 | } |
328 | 328 | |
329 | 329 | $upload_dir = wp_upload_dir(); |
330 | 330 | |
331 | 331 | // Vérification principale. cf 1 ci-dessus. |
332 | - if ( is_file( $file_check['path'] ) ) { |
|
332 | + if (is_file($file_check['path'])) { |
|
333 | 333 | $file_check['exists'] = true; |
334 | 334 | } |
335 | 335 | |
336 | 336 | // La vérification principale n'a pas fonctionnée. cf 2 ci-dessus. |
337 | - if ( ! $file_check['exists'] && ! empty( $document->data['_wp_attached_file'] ) ) { |
|
337 | + if (!$file_check['exists'] && !empty($document->data['_wp_attached_file'])) { |
|
338 | 338 | $file_check['path'] = $upload_dir['basedir'] . '/' . $document->data['_wp_attached_file']; |
339 | 339 | $file_check['link'] = $upload_dir['baseurl'] . '/' . $document->data['_wp_attached_file']; |
340 | - if ( is_file( $file_check['path'] ) ) { |
|
340 | + if (is_file($file_check['path'])) { |
|
341 | 341 | $file_check['exists'] = true; |
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | 345 | // Si le fichier existe on récupère le mime type. |
346 | - if ( $file_check['exists'] ) { |
|
347 | - $file_check['mime_type'] = wp_check_filetype( $file_check['path'] ); |
|
346 | + if ($file_check['exists']) { |
|
347 | + $file_check['mime_type'] = wp_check_filetype($file_check['path']); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | return $file_check; |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return array (Voir au dessus). |
368 | 368 | */ |
369 | - public function generate_document( $document_id ) { |
|
370 | - $document = $this->get( array( 'id' => $document_id ), true ); |
|
369 | + public function generate_document($document_id) { |
|
370 | + $document = $this->get(array('id' => $document_id), true); |
|
371 | 371 | |
372 | 372 | $response = array( |
373 | 373 | 'status' => false, |
@@ -376,56 +376,56 @@ discard block |
||
376 | 376 | 'url' => '', |
377 | 377 | ); |
378 | 378 | |
379 | - if ( empty( $document->data['path'] ) ) { |
|
379 | + if (empty($document->data['path'])) { |
|
380 | 380 | $response['message'] = 'Document path est vide'; |
381 | 381 | return $response; |
382 | 382 | } |
383 | 383 | |
384 | - @ini_set( 'memory_limit', '256M' ); |
|
384 | + @ini_set('memory_limit', '256M'); |
|
385 | 385 | |
386 | 386 | |
387 | 387 | require_once $this->path . '/core/external/odtPhpLibrary/odf.php'; |
388 | 388 | |
389 | 389 | $upload_dir = wp_upload_dir(); |
390 | - $directory = str_replace( '\\', '/', $upload_dir['basedir'] ); |
|
390 | + $directory = str_replace('\\', '/', $upload_dir['basedir']); |
|
391 | 391 | |
392 | 392 | $config = array( |
393 | 393 | 'PATH_TO_TMP' => $directory . '/tmp', |
394 | 394 | ); |
395 | - if ( ! is_dir( $config['PATH_TO_TMP'] ) ) { |
|
396 | - wp_mkdir_p( $config['PATH_TO_TMP'] ); |
|
395 | + if (!is_dir($config['PATH_TO_TMP'])) { |
|
396 | + wp_mkdir_p($config['PATH_TO_TMP']); |
|
397 | 397 | } |
398 | 398 | |
399 | - if ( ! is_file( $document->data['model_path'] ) ) { |
|
399 | + if (!is_file($document->data['model_path'])) { |
|
400 | 400 | $response['message'] = $document->data['model_path'] . ' est introuvable'; |
401 | 401 | return $response; |
402 | 402 | } |
403 | 403 | |
404 | 404 | |
405 | 405 | // On créé l'instance pour la génération du document odt. |
406 | - $odf_php_lib = new \DigiOdf( $document->data['model_path'], $config ); |
|
406 | + $odf_php_lib = new \DigiOdf($document->data['model_path'], $config); |
|
407 | 407 | |
408 | 408 | // Vérification de l'existence d'un contenu a écrire dans le document. |
409 | - if ( ! empty( $document->data['document_meta'] ) ) { |
|
409 | + if (!empty($document->data['document_meta'])) { |
|
410 | 410 | // Lecture du contenu à écrire dans le document. |
411 | - foreach ( $document->data['document_meta'] as $data_key => $data_value ) { |
|
412 | - if ( is_array( $data_value ) && ! empty( $data_value['raw'] ) ) { |
|
411 | + foreach ($document->data['document_meta'] as $data_key => $data_value) { |
|
412 | + if (is_array($data_value) && !empty($data_value['raw'])) { |
|
413 | 413 | $data_value = $data_value['raw']; |
414 | 414 | } |
415 | 415 | |
416 | - $odf_php_lib = $this->set_document_meta( $data_key, $data_value, $odf_php_lib ); |
|
416 | + $odf_php_lib = $this->set_document_meta($data_key, $data_value, $odf_php_lib); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | 420 | // Vérification de l'existence du dossier de destination. |
421 | - if ( ! is_dir( dirname( $document->data['path'] ) ) ) { |
|
422 | - wp_mkdir_p( dirname( $document->data['path'] ) ); |
|
421 | + if (!is_dir(dirname($document->data['path']))) { |
|
422 | + wp_mkdir_p(dirname($document->data['path'])); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | // Enregistrement du document sur le disque. |
426 | - $odf_php_lib->saveToDisk( $document->data['path'] ); |
|
426 | + $odf_php_lib->saveToDisk($document->data['path']); |
|
427 | 427 | |
428 | - if ( is_file( $document->data['path'] ) ) { |
|
428 | + if (is_file($document->data['path'])) { |
|
429 | 429 | $response['status'] = true; |
430 | 430 | $response['path'] = $document->data['path']; |
431 | 431 | } |
@@ -444,34 +444,34 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @return object Le document courant |
446 | 446 | */ |
447 | - public function set_document_meta( $data_key, $data_value, $current_odf ) { |
|
447 | + public function set_document_meta($data_key, $data_value, $current_odf) { |
|
448 | 448 | // Dans le cas où la donnée a écrire est une valeur "simple" (texte). |
449 | - if ( ! is_array( $data_value ) ) { |
|
450 | - $current_odf->setVars( $data_key, stripslashes( $data_value ), true, 'UTF-8' ); |
|
451 | - } else if ( is_array( $data_value ) && isset( $data_value[ 'type' ] ) && !empty( $data_value[ 'type' ] ) ) { |
|
452 | - switch ( $data_value[ 'type' ] ) { |
|
449 | + if (!is_array($data_value)) { |
|
450 | + $current_odf->setVars($data_key, stripslashes($data_value), true, 'UTF-8'); |
|
451 | + } else if (is_array($data_value) && isset($data_value['type']) && !empty($data_value['type'])) { |
|
452 | + switch ($data_value['type']) { |
|
453 | 453 | |
454 | 454 | case 'picture': |
455 | - $current_odf->setImage( $data_key, $data_value[ 'value' ], ( !empty( $data_value[ 'option' ] ) && !empty( $data_value[ 'option' ][ 'size' ] ) ? $data_value[ 'option' ][ 'size' ] : 0 ) ); |
|
455 | + $current_odf->setImage($data_key, $data_value['value'], (!empty($data_value['option']) && !empty($data_value['option']['size']) ? $data_value['option']['size'] : 0)); |
|
456 | 456 | break; |
457 | 457 | |
458 | 458 | case 'segment': |
459 | - $segment = $current_odf->setdigiSegment( $data_key ); |
|
460 | - |
|
461 | - if ( $segment && is_array( $data_value[ 'value' ] ) ) { |
|
462 | - foreach ( $data_value[ 'value' ] as $segment_detail ) { |
|
463 | - foreach ( $segment_detail as $segment_detail_key => $segment_detail_value ) { |
|
464 | - if ( is_array( $segment_detail_value ) && array_key_exists( 'type', $segment_detail_value ) && ( 'sub_segment' == $segment_detail_value[ 'type' ] ) ) { |
|
465 | - foreach ( $segment_detail_value[ 'value' ] as $sub_segment_data ) { |
|
466 | - foreach ( $sub_segment_data as $sub_segment_data_key => $sub_segment_data_value ) { |
|
467 | - $segment->$segment_detail_key = $this->set_document_meta( $sub_segment_data_key, $sub_segment_data_value, $segment->$segment_detail_key ); |
|
459 | + $segment = $current_odf->setdigiSegment($data_key); |
|
460 | + |
|
461 | + if ($segment && is_array($data_value['value'])) { |
|
462 | + foreach ($data_value['value'] as $segment_detail) { |
|
463 | + foreach ($segment_detail as $segment_detail_key => $segment_detail_value) { |
|
464 | + if (is_array($segment_detail_value) && array_key_exists('type', $segment_detail_value) && ('sub_segment' == $segment_detail_value['type'])) { |
|
465 | + foreach ($segment_detail_value['value'] as $sub_segment_data) { |
|
466 | + foreach ($sub_segment_data as $sub_segment_data_key => $sub_segment_data_value) { |
|
467 | + $segment->$segment_detail_key = $this->set_document_meta($sub_segment_data_key, $sub_segment_data_value, $segment->$segment_detail_key); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | $segment->$segment_detail_key->merge(); |
471 | 471 | } |
472 | 472 | } |
473 | 473 | else { |
474 | - $segment = $this->set_document_meta( $segment_detail_key, $segment_detail_value, $segment ); |
|
474 | + $segment = $this->set_document_meta($segment_detail_key, $segment_detail_value, $segment); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | } |
@@ -479,9 +479,9 @@ discard block |
||
479 | 479 | $segment->merge(); |
480 | 480 | } |
481 | 481 | |
482 | - $current_odf->mergedigiSegment( $segment ); |
|
482 | + $current_odf->mergedigiSegment($segment); |
|
483 | 483 | } |
484 | - unset( $segment ); |
|
484 | + unset($segment); |
|
485 | 485 | break; |
486 | 486 | } |
487 | 487 | } |
@@ -469,8 +469,7 @@ |
||
469 | 469 | |
470 | 470 | $segment->$segment_detail_key->merge(); |
471 | 471 | } |
472 | - } |
|
473 | - else { |
|
472 | + } else { |
|
474 | 473 | $segment = $this->set_document_meta( $segment_detail_key, $segment_detail_value, $segment ); |
475 | 474 | } |
476 | 475 |
@@ -71,7 +71,6 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @since 1.1.0 |
73 | 73 | * |
74 | - * @param array $atts [description] |
|
75 | 74 | */ |
76 | 75 | public function display( $slug, $visible_value = '', $hidden_value = '' ) { |
77 | 76 | $atts = $this->get_registered_search( $slug ); |
@@ -107,6 +106,9 @@ discard block |
||
107 | 106 | return $results; |
108 | 107 | } |
109 | 108 | |
109 | + /** |
|
110 | + * @param string $term |
|
111 | + */ |
|
110 | 112 | private function search_user( $term, $data ) { |
111 | 113 | if ( ! empty( $term ) ) { |
112 | 114 | $args = array( |
@@ -127,6 +129,9 @@ discard block |
||
127 | 129 | return $results; |
128 | 130 | } |
129 | 131 | |
132 | + /** |
|
133 | + * @param string $term |
|
134 | + */ |
|
130 | 135 | private function search_post( $term, $data ) { |
131 | 136 | $results = array(); |
132 | 137 |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | namespace eoxia; |
16 | 16 | |
17 | -defined( 'ABSPATH' ) || exit; |
|
17 | +defined('ABSPATH') || exit; |
|
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Search Class. |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected function construct() {} |
39 | 39 | |
40 | - public function register_search( $slug, $atts ) { |
|
41 | - $this->registered_search[ $slug ] = $this->construct_atts( $slug, $atts ); |
|
40 | + public function register_search($slug, $atts) { |
|
41 | + $this->registered_search[$slug] = $this->construct_atts($slug, $atts); |
|
42 | 42 | } |
43 | 43 | |
44 | - public function get_registered_search( $slug ) { |
|
45 | - return $this->registered_search[ $slug ]; |
|
44 | + public function get_registered_search($slug) { |
|
45 | + return $this->registered_search[$slug]; |
|
46 | 46 | } |
47 | 47 | |
48 | - private function construct_atts( $slug, $atts ) { |
|
48 | + private function construct_atts($slug, $atts) { |
|
49 | 49 | $default = array( |
50 | 50 | 'value' => '', |
51 | 51 | 'hidden_value' => '', |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | $atts['slug'] = $slug; |
55 | 55 | $atts['id'] = ''; |
56 | 56 | |
57 | - if ( ! empty( $atts['label'] ) ) { |
|
58 | - $atts['id'] = sanitize_title( $atts['label'] ); |
|
57 | + if (!empty($atts['label'])) { |
|
58 | + $atts['id'] = sanitize_title($atts['label']); |
|
59 | 59 | } |
60 | 60 | |
61 | - $atts = wp_parse_args( $atts, $default ); |
|
61 | + $atts = wp_parse_args($atts, $default); |
|
62 | 62 | |
63 | 63 | return $atts; |
64 | 64 | } |
@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param array $atts [description] |
75 | 75 | */ |
76 | - public function display( $slug, $visible_value = '', $hidden_value = '' ) { |
|
77 | - $atts = $this->get_registered_search( $slug ); |
|
76 | + public function display($slug, $visible_value = '', $hidden_value = '') { |
|
77 | + $atts = $this->get_registered_search($slug); |
|
78 | 78 | |
79 | - \eoxia\View_Util::exec( 'eo-framework', 'wpeo_search', 'main', array( |
|
79 | + \eoxia\View_Util::exec('eo-framework', 'wpeo_search', 'main', array( |
|
80 | 80 | 'atts' => $atts, |
81 | - ) ); |
|
81 | + )); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @return array Array of results. |
94 | 94 | */ |
95 | - public function search( $term, $type, $args ) { |
|
96 | - switch ( $type ) { |
|
95 | + public function search($term, $type, $args) { |
|
96 | + switch ($type) { |
|
97 | 97 | case "user": |
98 | - $results = $this->search_user( $term, $args ); |
|
98 | + $results = $this->search_user($term, $args); |
|
99 | 99 | break; |
100 | 100 | case "post": |
101 | - $results = $this->search_post( $term, $args ); |
|
101 | + $results = $this->search_post($term, $args); |
|
102 | 102 | break; |
103 | 103 | default: |
104 | 104 | break; |
@@ -107,54 +107,54 @@ discard block |
||
107 | 107 | return $results; |
108 | 108 | } |
109 | 109 | |
110 | - private function search_user( $term, $data ) { |
|
111 | - if ( ! empty( $term ) ) { |
|
110 | + private function search_user($term, $data) { |
|
111 | + if (!empty($term)) { |
|
112 | 112 | $args = array( |
113 | 113 | 'search' => '*' . $term . '*', |
114 | 114 | ); |
115 | 115 | |
116 | - if ( ! empty( $data['args'] ) ) { |
|
117 | - $args = array_merge( $args, $data['args'] ); |
|
116 | + if (!empty($data['args'])) { |
|
117 | + $args = array_merge($args, $data['args']); |
|
118 | 118 | } |
119 | 119 | |
120 | - $results = User_Class::g()->get( $args ); |
|
120 | + $results = User_Class::g()->get($args); |
|
121 | 121 | } else { |
122 | - $results = User_Class::g()->get( array( |
|
123 | - 'exclude' => array( 1 ), |
|
124 | - ) ); |
|
122 | + $results = User_Class::g()->get(array( |
|
123 | + 'exclude' => array(1), |
|
124 | + )); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | return $results; |
128 | 128 | } |
129 | 129 | |
130 | - private function search_post( $term, $data ) { |
|
130 | + private function search_post($term, $data) { |
|
131 | 131 | $results = array(); |
132 | 132 | |
133 | - $get_args = array( 'meta_or_title' => $term ); |
|
133 | + $get_args = array('meta_or_title' => $term); |
|
134 | 134 | |
135 | 135 | |
136 | - if ( ! empty( $data['args']['meta_query'] ) ) { |
|
137 | - $get_args['meta_query'] = $this->construct_meta_query( $term, $data['args']['meta_query'] ); |
|
136 | + if (!empty($data['args']['meta_query'])) { |
|
137 | + $get_args['meta_query'] = $this->construct_meta_query($term, $data['args']['meta_query']); |
|
138 | 138 | } |
139 | 139 | |
140 | - $get_args = array_merge( $get_args, $data['args'] ); |
|
140 | + $get_args = array_merge($get_args, $data['args']); |
|
141 | 141 | |
142 | - if ( ! empty( $data['args']['model_name'] ) ) { |
|
143 | - foreach ( $data['args']['model_name'] as $model_name ) { |
|
144 | - $results = array_merge( $results, $model_name::g()->get( $get_args ) ); |
|
142 | + if (!empty($data['args']['model_name'])) { |
|
143 | + foreach ($data['args']['model_name'] as $model_name) { |
|
144 | + $results = array_merge($results, $model_name::g()->get($get_args)); |
|
145 | 145 | } |
146 | 146 | } else { |
147 | 147 | $get_args['posts_per_page'] = -1; |
148 | - $results = get_posts( $get_args ); |
|
148 | + $results = get_posts($get_args); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $results; |
152 | 152 | } |
153 | 153 | |
154 | - private function construct_meta_query( $term, $args_meta_query ) { |
|
155 | - if ( ! empty( $args_meta_query ) ) { |
|
156 | - foreach ( $args_meta_query as &$meta_data ) { |
|
157 | - if ( ! empty( $meta_data ) && is_array( $meta_data ) ) { |
|
154 | + private function construct_meta_query($term, $args_meta_query) { |
|
155 | + if (!empty($args_meta_query)) { |
|
156 | + foreach ($args_meta_query as &$meta_data) { |
|
157 | + if (!empty($meta_data) && is_array($meta_data)) { |
|
158 | 158 | $meta_data['value'] = $term; |
159 | 159 | } |
160 | 160 | } |
@@ -11,7 +11,7 @@ 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 | |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @version 1.0.0 |
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | - add_action( 'admin_enqueue_scripts', array( $this, 'callback_mixed_enqueue_scripts' ), 9 ); |
|
33 | - add_action( 'wp_enqueue_scripts', array( $this, 'callback_mixed_enqueue_scripts' ), 9 ); |
|
34 | - add_action( 'init', array( $this, 'callback_plugins_loaded' ) ); |
|
32 | + add_action('admin_enqueue_scripts', array($this, 'callback_mixed_enqueue_scripts'), 9); |
|
33 | + add_action('wp_enqueue_scripts', array($this, 'callback_mixed_enqueue_scripts'), 9); |
|
34 | + add_action('init', array($this, 'callback_plugins_loaded')); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -43,15 +43,15 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public function callback_mixed_enqueue_scripts() { |
46 | - wp_register_script( 'wpeo-assets-scripts', Config_Util::$init['eo-framework']->core->url . 'assets/js/dest/wpeo-assets.js', array( 'jquery' ), \eoxia\Config_Util::$init['eo-framework']->version, false ); |
|
47 | - wp_enqueue_script( 'wpeo-assets-datepicker-js', Config_Util::$init['eo-framework']->core->url . 'assets/js/dest/jquery.datetimepicker.full.js', array( 'jquery' ), \eoxia\Config_Util::$init['eo-framework']->version, false ); |
|
46 | + wp_register_script('wpeo-assets-scripts', Config_Util::$init['eo-framework']->core->url . 'assets/js/dest/wpeo-assets.js', array('jquery'), \eoxia\Config_Util::$init['eo-framework']->version, false); |
|
47 | + wp_enqueue_script('wpeo-assets-datepicker-js', Config_Util::$init['eo-framework']->core->url . 'assets/js/dest/jquery.datetimepicker.full.js', array('jquery'), \eoxia\Config_Util::$init['eo-framework']->version, false); |
|
48 | 48 | |
49 | - wp_enqueue_style( 'wpeo-font-awesome-free', Config_Util::$init['eo-framework']->core->url . 'assets/css/fontawesome/fontawesome-all.min.css', array(), \eoxia\Config_Util::$init['eo-framework']->version ); |
|
50 | - wp_enqueue_style( 'wpeo-assets-styles', Config_Util::$init['eo-framework']->core->url . 'assets/css/style.min.css', \eoxia\Config_Util::$init['eo-framework']->version ); |
|
51 | - wp_enqueue_style( 'wpeo-assets-datepicker', Config_Util::$init['eo-framework']->core->url . 'assets/css/jquery.datetimepicker.css', array(), \eoxia\Config_Util::$init['eo-framework']->version ); |
|
49 | + wp_enqueue_style('wpeo-font-awesome-free', Config_Util::$init['eo-framework']->core->url . 'assets/css/fontawesome/fontawesome-all.min.css', array(), \eoxia\Config_Util::$init['eo-framework']->version); |
|
50 | + wp_enqueue_style('wpeo-assets-styles', Config_Util::$init['eo-framework']->core->url . 'assets/css/style.min.css', \eoxia\Config_Util::$init['eo-framework']->version); |
|
51 | + wp_enqueue_style('wpeo-assets-datepicker', Config_Util::$init['eo-framework']->core->url . 'assets/css/jquery.datetimepicker.css', array(), \eoxia\Config_Util::$init['eo-framework']->version); |
|
52 | 52 | |
53 | - wp_localize_script( 'wpeo-assets-scripts', 'wpeo_framework', $this->get_localize_script_data() ); |
|
54 | - wp_enqueue_script( 'wpeo-assets-scripts' ); |
|
53 | + wp_localize_script('wpeo-assets-scripts', 'wpeo_framework', $this->get_localize_script_data()); |
|
54 | + wp_enqueue_script('wpeo-assets-scripts'); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
@@ -92,10 +92,10 @@ discard block |
||
92 | 92 | * @version 1.0.0 |
93 | 93 | */ |
94 | 94 | public function callback_plugins_loaded() { |
95 | - $plugin_dir = str_replace( '\\', '/', WP_PLUGIN_DIR ); |
|
96 | - $full_plugin_path = str_replace( '\\', '/', \eoxia\Config_Util::$init['main']->full_plugin_path ); |
|
97 | - $path = str_replace( $plugin_dir, '', $full_plugin_path ); |
|
98 | - load_plugin_textdomain( 'eoxia', false, $path . 'core/external/' . PLUGIN_EO_FRAMEWORK_DIR . '/core/assets/languages/' ); |
|
95 | + $plugin_dir = str_replace('\\', '/', WP_PLUGIN_DIR); |
|
96 | + $full_plugin_path = str_replace('\\', '/', \eoxia\Config_Util::$init['main']->full_plugin_path); |
|
97 | + $path = str_replace($plugin_dir, '', $full_plugin_path); |
|
98 | + load_plugin_textdomain('eoxia', false, $path . 'core/external/' . PLUGIN_EO_FRAMEWORK_DIR . '/core/assets/languages/'); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 |
@@ -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\CSV_Util' ) ) { |
|
18 | +if (!class_exists('\eoxia\CSV_Util')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Méthodes utilitaires pour les fichiers CSV. |
@@ -43,20 +43,20 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @todo: Est-ce utile ? Utilisé par quel plugin ? |
45 | 45 | */ |
46 | - public function read_and_set_index( $csv_path, $list_index = array() ) { |
|
47 | - if ( empty( $csv_path ) ) { |
|
46 | + public function read_and_set_index($csv_path, $list_index = array()) { |
|
47 | + if (empty($csv_path)) { |
|
48 | 48 | return false; |
49 | 49 | } |
50 | 50 | |
51 | 51 | $data = array(); |
52 | - $csv_content = file( $csv_path ); |
|
53 | - if ( ! empty( $csv_content ) ) { |
|
54 | - foreach ( $csv_content as $key => $line ) { |
|
55 | - if ( 0 !== $key ) { |
|
56 | - $data[ $key ] = str_getcsv( $line ); |
|
57 | - foreach ( $data[ $key ] as $i => $entry ) { |
|
58 | - if ( ! empty( $list_index[ $i ] ) ) { |
|
59 | - $data[ $key ][ $list_index[ $i ] ] = $entry; |
|
52 | + $csv_content = file($csv_path); |
|
53 | + if (!empty($csv_content)) { |
|
54 | + foreach ($csv_content as $key => $line) { |
|
55 | + if (0 !== $key) { |
|
56 | + $data[$key] = str_getcsv($line); |
|
57 | + foreach ($data[$key] as $i => $entry) { |
|
58 | + if (!empty($list_index[$i])) { |
|
59 | + $data[$key][$list_index[$i]] = $entry; |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | } |