@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | namespace digi; |
15 | 15 | |
16 | -if ( ! defined( 'ABSPATH' ) ) { |
|
16 | +if (!defined('ABSPATH')) { |
|
17 | 17 | exit; |
18 | 18 | } ?> |
19 | 19 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | namespace digi; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if (!defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } ?> |
17 | 17 |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | namespace digi; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if (!defined('ABSPATH')) { |
|
15 | 15 | exit; |
16 | 16 | } ?> |
17 | 17 |
@@ -7,17 +7,17 @@ |
||
7 | 7 | |
8 | 8 | namespace eoxia; |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | -if ( ! class_exists( '\eoxia\Init_Util' ) ) { |
|
15 | - DEFINE( 'PLUGIN_EO_FRAMEWORK_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' ); |
|
16 | - DEFINE( 'PLUGIN_EO_FRAMEWORK_URL', plugin_dir_url( basename( __DIR__ ) ) . '/' ); |
|
17 | - DEFINE( 'PLUGIN_EO_FRAMEWORK_DIR', basename( __DIR__ ) ); |
|
14 | +if (!class_exists('\eoxia\Init_Util')) { |
|
15 | + DEFINE('PLUGIN_EO_FRAMEWORK_PATH', realpath(plugin_dir_path(__FILE__)) . '/'); |
|
16 | + DEFINE('PLUGIN_EO_FRAMEWORK_URL', plugin_dir_url(basename(__DIR__)) . '/'); |
|
17 | + DEFINE('PLUGIN_EO_FRAMEWORK_DIR', basename(__DIR__)); |
|
18 | 18 | |
19 | - require_once( 'core/util/class-singleton-util.php' ); |
|
20 | - require_once( 'core/util/class-init-util.php' ); |
|
19 | + require_once('core/util/class-singleton-util.php'); |
|
20 | + require_once('core/util/class-init-util.php'); |
|
21 | 21 | |
22 | - Init_Util::g()->exec( PLUGIN_EO_FRAMEWORK_PATH, basename( __FILE__, '.php' ) ); |
|
22 | + Init_Util::g()->exec(PLUGIN_EO_FRAMEWORK_PATH, basename(__FILE__, '.php')); |
|
23 | 23 | } |
@@ -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\WPEO_Upload_Shortcode' ) ) { |
|
18 | +if (!class_exists('\eoxia\WPEO_Upload_Shortcode')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * Call the main view of the plugin. |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @version 1.0.0 |
30 | 30 | */ |
31 | 31 | protected function construct() { |
32 | - add_shortcode( 'wpeo_upload', array( $this, 'wpeo_upload' ) ); |
|
32 | + add_shortcode('wpeo_upload', array($this, 'wpeo_upload')); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -45,39 +45,39 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return HTML Le code html permettant l'affichage du module d'upload |
47 | 47 | */ |
48 | - public function wpeo_upload( $atts ) { |
|
48 | + public function wpeo_upload($atts) { |
|
49 | 49 | |
50 | 50 | // Parameters of the shortcode. |
51 | - $atts = shortcode_atts( array( |
|
52 | - 'id' => 0, // The id of the POST Element (Can be a custom post). |
|
53 | - 'title' => __( 'Upload media', 'wpeo-upload' ), // Popup title. |
|
54 | - 'mode' => 'edit', // Can be "edit" or "view". |
|
55 | - 'field_name' => 'thumbnail_id', // For use "_thumbnail_id" postmeta of WordPress let _thumbnail_id. Again for more details @see. |
|
56 | - 'model_name' => '//eoxia//Post_Class', // Say to WPEO_Model the model used. Write double slashes when use in shortcode. This method convert it from "//" to "\". |
|
57 | - 'custom_class' => '', // Add custom class. |
|
58 | - 'size' => 'thumbnail', // The size of the box (button for upload or open the gallery). |
|
59 | - 'single' => 'true', // One media or more. |
|
60 | - 'mime_type' => 'image', // Can be application, image, audio or empty for all mime types. By default "image". |
|
61 | - 'display_type' => 'box', // Can be box or list. By default box. |
|
62 | - ), $atts ); |
|
51 | + $atts = shortcode_atts(array( |
|
52 | + 'id' => 0, // The id of the POST Element (Can be a custom post). |
|
53 | + 'title' => __('Upload media', 'wpeo-upload'), // Popup title. |
|
54 | + 'mode' => 'edit', // Can be "edit" or "view". |
|
55 | + 'field_name' => 'thumbnail_id', // For use "_thumbnail_id" postmeta of WordPress let _thumbnail_id. Again for more details @see. |
|
56 | + 'model_name' => '//eoxia//Post_Class', // Say to WPEO_Model the model used. Write double slashes when use in shortcode. This method convert it from "//" to "\". |
|
57 | + 'custom_class' => '', // Add custom class. |
|
58 | + 'size' => 'thumbnail', // The size of the box (button for upload or open the gallery). |
|
59 | + 'single' => 'true', // One media or more. |
|
60 | + 'mime_type' => 'image', // Can be application, image, audio or empty for all mime types. By default "image". |
|
61 | + 'display_type' => 'box', // Can be box or list. By default box. |
|
62 | + ), $atts); |
|
63 | 63 | |
64 | 64 | // Convert "//" to "\". |
65 | - if ( ! empty( $atts['model_name'] ) ) { |
|
66 | - $atts['model_name'] = str_replace( '/', '\\', $atts['model_name'] ); |
|
65 | + if (!empty($atts['model_name'])) { |
|
66 | + $atts['model_name'] = str_replace('/', '\\', $atts['model_name']); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | // Load the POST element with WPEO_Model. |
70 | - $args = array( 'id' => $atts['id'] ); |
|
70 | + $args = array('id' => $atts['id']); |
|
71 | 71 | |
72 | - if ( empty( $atts['id'] ) ) { |
|
73 | - $args = array( 'schema' => true ); |
|
72 | + if (empty($atts['id'])) { |
|
73 | + $args = array('schema' => true); |
|
74 | 74 | } |
75 | 75 | |
76 | - $element = $atts['model_name']::g()->get( $args, true ); |
|
76 | + $element = $atts['model_name']::g()->get($args, true); |
|
77 | 77 | |
78 | 78 | $main_picture_id = $element->data['thumbnail_id']; |
79 | 79 | |
80 | - if ( empty( $main_picture_id ) ) { |
|
80 | + if (empty($main_picture_id)) { |
|
81 | 81 | $nonce_name = 'associate_file'; |
82 | 82 | } else { |
83 | 83 | $nonce_name = 'load_gallery'; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $field_name = $atts['field_name']; |
87 | 87 | |
88 | 88 | $no_file_class = ''; |
89 | - if ( empty( $main_picture_id ) && empty( $element->data['associated_document_id'][ $atts['field_name'] ] ) ) { |
|
89 | + if (empty($main_picture_id) && empty($element->data['associated_document_id'][$atts['field_name']])) { |
|
90 | 90 | $no_file_class = 'no-file'; |
91 | 91 | } else { |
92 | 92 | $nonce_name = 'load_gallery'; |
@@ -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\WPEO_Upload_Class' ) ) { |
|
18 | +if (!class_exists('\eoxia\WPEO_Upload_Class')) { |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * All methods utils for associate, dessociate and anothers things about upload. |
@@ -54,21 +54,21 @@ discard block |
||
54 | 54 | * @type integer $file_id The uploaded file ID. |
55 | 55 | * } |
56 | 56 | */ |
57 | - public function get_post_data( $nonce_name ) { |
|
57 | + public function get_post_data($nonce_name) { |
|
58 | 58 | // check_ajax_referer( $nonce_name ); |
59 | 59 | |
60 | 60 | $data = array(); |
61 | - $data['id'] = ! empty( $_POST['id'] ) ? (int) $_POST['id'] : 0; |
|
62 | - $data['title'] = ! empty( $_POST['title'] ) ? sanitize_text_field( $_POST['title'] ) : ''; |
|
63 | - $data['mode'] = ! empty( $_POST['mode'] ) ? sanitize_text_field( $_POST['mode'] ) : ''; |
|
64 | - $data['field_name'] = ! empty( $_POST['field_name'] ) ? sanitize_text_field( $_POST['field_name'] ) : ''; |
|
65 | - $data['model_name'] = ! empty( $_POST['model_name'] ) ? stripslashes( sanitize_text_field( $_POST['model_name'] ) ) : ''; |
|
66 | - $data['custom_class'] = ! empty( $_POST['custom_class'] ) ? stripslashes( sanitize_text_field( $_POST['custom_class'] ) ) : ''; |
|
67 | - $data['size'] = ! empty( $_POST['size'] ) ? sanitize_text_field( $_POST['size'] ) : 'thumbnail'; |
|
68 | - $data['single'] = ! empty( $_POST['single'] ) ? sanitize_text_field( $_POST['single'] ) : 'false'; |
|
69 | - $data['mime_type'] = ! empty( $_POST['mime_type'] ) ? sanitize_text_field( $_POST['mime_type'] ) : ''; |
|
70 | - $data['display_type'] = ! empty( $_POST['display_type'] ) ? sanitize_text_field( $_POST['display_type'] ) : ''; |
|
71 | - $data['file_id'] = ! empty( $_POST['file_id'] ) ? (int) $_POST['file_id'] : 0; |
|
61 | + $data['id'] = !empty($_POST['id']) ? (int)$_POST['id'] : 0; |
|
62 | + $data['title'] = !empty($_POST['title']) ? sanitize_text_field($_POST['title']) : ''; |
|
63 | + $data['mode'] = !empty($_POST['mode']) ? sanitize_text_field($_POST['mode']) : ''; |
|
64 | + $data['field_name'] = !empty($_POST['field_name']) ? sanitize_text_field($_POST['field_name']) : ''; |
|
65 | + $data['model_name'] = !empty($_POST['model_name']) ? stripslashes(sanitize_text_field($_POST['model_name'])) : ''; |
|
66 | + $data['custom_class'] = !empty($_POST['custom_class']) ? stripslashes(sanitize_text_field($_POST['custom_class'])) : ''; |
|
67 | + $data['size'] = !empty($_POST['size']) ? sanitize_text_field($_POST['size']) : 'thumbnail'; |
|
68 | + $data['single'] = !empty($_POST['single']) ? sanitize_text_field($_POST['single']) : 'false'; |
|
69 | + $data['mime_type'] = !empty($_POST['mime_type']) ? sanitize_text_field($_POST['mime_type']) : ''; |
|
70 | + $data['display_type'] = !empty($_POST['display_type']) ? sanitize_text_field($_POST['display_type']) : ''; |
|
71 | + $data['file_id'] = !empty($_POST['file_id']) ? (int)$_POST['file_id'] : 0; |
|
72 | 72 | |
73 | 73 | return $data; |
74 | 74 | } |
@@ -90,16 +90,16 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return mixed |
92 | 92 | */ |
93 | - public function associate_file( $data ) { |
|
93 | + public function associate_file($data) { |
|
94 | 94 | $element = null; |
95 | 95 | |
96 | - if ( ! empty( $data['id'] ) ) { |
|
97 | - $element = $data['model_name']::g()->get( array( |
|
96 | + if (!empty($data['id'])) { |
|
97 | + $element = $data['model_name']::g()->get(array( |
|
98 | 98 | 'id' => $data['id'], |
99 | - ), true ); |
|
99 | + ), true); |
|
100 | 100 | |
101 | - $element->data['associated_document_id'][ $data['field_name'] ][] = (int) $data['file_id']; |
|
102 | - $data['model_name']::g()->update( $element->data ); |
|
101 | + $element->data['associated_document_id'][$data['field_name']][] = (int)$data['file_id']; |
|
102 | + $data['model_name']::g()->update($element->data); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $element; |
@@ -122,30 +122,30 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @return mixed |
124 | 124 | */ |
125 | - public function dissociate_file( $data ) { |
|
126 | - $element = $data['model_name']::g()->get( array( |
|
125 | + public function dissociate_file($data) { |
|
126 | + $element = $data['model_name']::g()->get(array( |
|
127 | 127 | 'id' => $data['id'], |
128 | - ), true ); |
|
128 | + ), true); |
|
129 | 129 | |
130 | 130 | // Check if the file is in associated file list. |
131 | - if ( isset( $element->data['associated_document_id'] ) && isset( $element->data['associated_document_id'][ $data['field_name'] ] ) ) { |
|
132 | - $key = array_search( $data['file_id'], $element->data['associated_document_id'][ $data['field_name'] ], true ); |
|
133 | - if ( false !== $key ) { |
|
134 | - array_splice( $element->data['associated_document_id'][ $data['field_name'] ], $key, 1 ); |
|
131 | + if (isset($element->data['associated_document_id']) && isset($element->data['associated_document_id'][$data['field_name']])) { |
|
132 | + $key = array_search($data['file_id'], $element->data['associated_document_id'][$data['field_name']], true); |
|
133 | + if (false !== $key) { |
|
134 | + array_splice($element->data['associated_document_id'][$data['field_name']], $key, 1); |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Check if the file is set as thumbnail. |
139 | - if ( $data['file_id'] === $element->data['thumbnail_id'] ) { |
|
139 | + if ($data['file_id'] === $element->data['thumbnail_id']) { |
|
140 | 140 | $element->data['thumbnail_id'] = 0; |
141 | 141 | } |
142 | 142 | |
143 | 143 | // Set another thumbnail id. |
144 | - if ( empty( $element->data['thumbnail_id'] ) && ! empty( $element->data['associated_document_id'][ $data['field_name'] ] ) ) { |
|
145 | - $element->data['thumbnail_id'] = $element->data['associated_document_id'][ $data['field_name'] ][0]; |
|
144 | + if (empty($element->data['thumbnail_id']) && !empty($element->data['associated_document_id'][$data['field_name']])) { |
|
145 | + $element->data['thumbnail_id'] = $element->data['associated_document_id'][$data['field_name']][0]; |
|
146 | 146 | } |
147 | 147 | |
148 | - $data['model_name']::g()->update( $element->data ); |
|
148 | + $data['model_name']::g()->update($element->data); |
|
149 | 149 | |
150 | 150 | return $element; |
151 | 151 | } |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @return void |
176 | 176 | */ |
177 | - public function display_gallery( $data ) { |
|
178 | - $element = $data['model_name']::g()->get( array( |
|
177 | + public function display_gallery($data) { |
|
178 | + $element = $data['model_name']::g()->get(array( |
|
179 | 179 | 'id' => $data['id'], |
180 | - ), true ); |
|
180 | + ), true); |
|
181 | 181 | |
182 | 182 | $main_picture_id = $element->data['thumbnail_id']; |
183 | 183 | |
184 | - if ( empty( $main_picture_id ) ) { |
|
185 | - $main_picture_id = $element->data['associated_document_id'][ $data['field_name'] ][0]; |
|
184 | + if (empty($main_picture_id)) { |
|
185 | + $main_picture_id = $element->data['associated_document_id'][$data['field_name']][0]; |
|
186 | 186 | } |
187 | 187 | |
188 | - $list_id = ! empty( $element->data['associated_document_id'][ $data['field_name'] ] ) ? $element->data['associated_document_id'][ $data['field_name'] ] : array(); |
|
188 | + $list_id = !empty($element->data['associated_document_id'][$data['field_name']]) ? $element->data['associated_document_id'][$data['field_name']] : array(); |
|
189 | 189 | |
190 | 190 | require \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path . '/view/box/gallery/main.view.php'; |
191 | 191 | } |
@@ -207,12 +207,12 @@ discard block |
||
207 | 207 | * |
208 | 208 | * @return mixed |
209 | 209 | */ |
210 | - public function set_thumbnail( $data ) { |
|
211 | - $element = $data['model_name']::g()->get( array( 'id' => $data['id'] ), true ); |
|
210 | + public function set_thumbnail($data) { |
|
211 | + $element = $data['model_name']::g()->get(array('id' => $data['id']), true); |
|
212 | 212 | |
213 | 213 | $element->data['thumbnail_id'] = $data['file_id']; |
214 | 214 | |
215 | - $element = $data['model_name']::g()->update( $element->data ); |
|
215 | + $element = $data['model_name']::g()->update($element->data); |
|
216 | 216 | |
217 | 217 | return $element; |
218 | 218 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return void |
243 | 243 | */ |
244 | - public function out_all_attributes( $data ) { |
|
244 | + public function out_all_attributes($data) { |
|
245 | 245 | require \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path . '/view/box/gallery/attributes.view.php'; |
246 | 246 | } |
247 | 247 | } |
@@ -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\WPEO_Upload_Action' ) ) { |
|
18 | +if (!class_exists('\eoxia\WPEO_Upload_Action')) { |
|
19 | 19 | /** |
20 | 20 | * Actions for wpeo_upload. |
21 | 21 | */ |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | * @version 1.0.0 |
29 | 29 | */ |
30 | 30 | public function __construct() { |
31 | - add_action( 'admin_enqueue_scripts', array( $this, 'callback_admin_scripts' ) ); |
|
32 | - add_action( 'init', array( $this, 'callback_plugins_loaded' ) ); |
|
31 | + add_action('admin_enqueue_scripts', array($this, 'callback_admin_scripts')); |
|
32 | + add_action('init', array($this, 'callback_plugins_loaded')); |
|
33 | 33 | |
34 | - add_action( 'wp_ajax_eo_upload_associate_file', array( $this, 'callback_associate_file' ) ); |
|
35 | - add_action( 'wp_ajax_eo_upload_dissociate_file', array( $this, 'callback_dissociate_file' ) ); |
|
34 | + add_action('wp_ajax_eo_upload_associate_file', array($this, 'callback_associate_file')); |
|
35 | + add_action('wp_ajax_eo_upload_dissociate_file', array($this, 'callback_dissociate_file')); |
|
36 | 36 | |
37 | - add_action( 'wp_ajax_eo_upload_load_gallery', array( $this, 'callback_load_gallery' ) ); |
|
38 | - add_action( 'wp_ajax_eo_upload_set_thumbnail', array( $this, 'callback_set_thumbnail' ) ); |
|
37 | + add_action('wp_ajax_eo_upload_load_gallery', array($this, 'callback_load_gallery')); |
|
38 | + add_action('wp_ajax_eo_upload_set_thumbnail', array($this, 'callback_set_thumbnail')); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | * @version 1.0.0 |
46 | 46 | */ |
47 | 47 | public function callback_admin_scripts() { |
48 | - wp_enqueue_style( 'wpeo_upload_style', \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->url . '/assets/css/style.css', array() ); |
|
49 | - wp_enqueue_script( 'wpeo_upload_script', \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->url . '/assets/js/wpeo-upload.js', array( 'jquery' ), \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->version ); |
|
48 | + wp_enqueue_style('wpeo_upload_style', \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->url . '/assets/css/style.css', array()); |
|
49 | + wp_enqueue_script('wpeo_upload_script', \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->url . '/assets/js/wpeo-upload.js', array('jquery'), \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->version); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @version 1.0.0 |
57 | 57 | */ |
58 | 58 | public function callback_plugins_loaded() { |
59 | - $path = str_replace( str_replace( '\\', '/', WP_PLUGIN_DIR ), '', str_replace( '\\', '/', \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path ) ); |
|
60 | - load_plugin_textdomain( 'wpeo-upload', false, $path . '/asset/language/' ); |
|
59 | + $path = str_replace(str_replace('\\', '/', WP_PLUGIN_DIR), '', str_replace('\\', '/', \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path)); |
|
60 | + load_plugin_textdomain('wpeo-upload', false, $path . '/asset/language/'); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -72,50 +72,50 @@ discard block |
||
72 | 72 | public function callback_associate_file() { |
73 | 73 | // check_ajax_referer( 'associate_file' ); |
74 | 74 | |
75 | - $data = WPEO_Upload_Class::g()->get_post_data( 'associate_file' ); |
|
75 | + $data = WPEO_Upload_Class::g()->get_post_data('associate_file'); |
|
76 | 76 | |
77 | 77 | $view = ''; |
78 | 78 | $document_view = ''; |
79 | 79 | // If post ID is not empty. |
80 | - if ( ! empty( $data['id'] ) ) { |
|
81 | - if ( 'true' === $data['single'] ) { |
|
82 | - $element = WPEO_Upload_Class::g()->set_thumbnail( $data ); |
|
80 | + if (!empty($data['id'])) { |
|
81 | + if ('true' === $data['single']) { |
|
82 | + $element = WPEO_Upload_Class::g()->set_thumbnail($data); |
|
83 | 83 | } else { |
84 | - $element = WPEO_Upload_Class::g()->associate_file( $data ); |
|
84 | + $element = WPEO_Upload_Class::g()->associate_file($data); |
|
85 | 85 | |
86 | - if ( empty( $element->data['thumbnail_id'] ) ) { |
|
87 | - $element = WPEO_Upload_Class::g()->set_thumbnail( $data ); |
|
86 | + if (empty($element->data['thumbnail_id'])) { |
|
87 | + $element = WPEO_Upload_Class::g()->set_thumbnail($data); |
|
88 | 88 | } |
89 | 89 | } |
90 | - if ( ! empty( $element->data['id'] ) ) { |
|
90 | + if (!empty($element->data['id'])) { |
|
91 | 91 | ob_start(); |
92 | - do_shortcode( '[wpeo_upload id="' . $element->data['id'] . '" model_name="' . str_replace( '\\', '/', $data['model_name'] ) . '" field_name="' . $data['field_name'] . '" mime_type="' . $data['mime_type'] . '" single="' . $data['single'] . '" size="' . $data['size'] . '" ]' ); |
|
92 | + do_shortcode('[wpeo_upload id="' . $element->data['id'] . '" model_name="' . str_replace('\\', '/', $data['model_name']) . '" field_name="' . $data['field_name'] . '" mime_type="' . $data['mime_type'] . '" single="' . $data['single'] . '" size="' . $data['size'] . '" ]'); |
|
93 | 93 | $view = ob_get_clean(); |
94 | 94 | } |
95 | 95 | } else { |
96 | - if ( 'application' === $data['mime_type'] ) { |
|
96 | + if ('application' === $data['mime_type']) { |
|
97 | 97 | $document_view = '<div class="document"><i class="icon fas fa-paperclip"></i></div>'; |
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
101 | - if ( 'list' === $data['display_type'] ) { |
|
102 | - $filelink = get_attached_file( $data['file_id'] ); |
|
103 | - $filename_only = basename( $filelink ); |
|
104 | - $fileurl_only = wp_get_attachment_url( $data['file_id'] ); |
|
101 | + if ('list' === $data['display_type']) { |
|
102 | + $filelink = get_attached_file($data['file_id']); |
|
103 | + $filename_only = basename($filelink); |
|
104 | + $fileurl_only = wp_get_attachment_url($data['file_id']); |
|
105 | 105 | ob_start(); |
106 | 106 | require \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path . '/view/' . $data['display_type'] . '/list-item.view.php'; |
107 | 107 | $view = ob_get_clean(); |
108 | 108 | } |
109 | 109 | |
110 | - $media_view = wp_get_attachment_image( $data['file_id'], $data['size'] ); |
|
110 | + $media_view = wp_get_attachment_image($data['file_id'], $data['size']); |
|
111 | 111 | |
112 | - wp_send_json_success( array( |
|
112 | + wp_send_json_success(array( |
|
113 | 113 | 'view' => $view, |
114 | 114 | 'document_view' => $document_view, |
115 | 115 | 'id' => $data['id'], |
116 | 116 | 'display_type' => $data['display_type'], |
117 | - 'media' => ! empty( $media_view ) ? $media_view : '', |
|
118 | - ) ); |
|
117 | + 'media' => !empty($media_view) ? $media_view : '', |
|
118 | + )); |
|
119 | 119 | } |
120 | 120 | |
121 | 121 | /** |
@@ -127,20 +127,20 @@ discard block |
||
127 | 127 | * @return void |
128 | 128 | */ |
129 | 129 | public function callback_dissociate_file() { |
130 | - $data = WPEO_Upload_Class::g()->get_post_data( 'dissociate_file' ); |
|
130 | + $data = WPEO_Upload_Class::g()->get_post_data('dissociate_file'); |
|
131 | 131 | |
132 | - $element = WPEO_Upload_Class::g()->dissociate_file( $data ); |
|
132 | + $element = WPEO_Upload_Class::g()->dissociate_file($data); |
|
133 | 133 | |
134 | 134 | ob_start(); |
135 | - do_shortcode( '[wpeo_upload id="' . $element->data['date']['id'] . '" model_name="' . str_replace( '\\', '/', $data['model_name'] ) . '" field_name="' . $data['field_name'] . '" mime_type="' . $data['mime_type'] . '" single="' . $data['single'] . '" size="' . $data['size'] . '" ]' ); |
|
136 | - wp_send_json_success( array( |
|
135 | + do_shortcode('[wpeo_upload id="' . $element->data['date']['id'] . '" model_name="' . str_replace('\\', '/', $data['model_name']) . '" field_name="' . $data['field_name'] . '" mime_type="' . $data['mime_type'] . '" single="' . $data['single'] . '" size="' . $data['size'] . '" ]'); |
|
136 | + wp_send_json_success(array( |
|
137 | 137 | 'namespace' => '', |
138 | 138 | 'module' => 'gallery', |
139 | 139 | 'callback_success' => 'dissociatedFileSuccess', |
140 | 140 | 'view' => ob_get_clean(), |
141 | 141 | 'id' => $data['id'], |
142 | - 'close_popup' => ! empty( $element->data['data']['associated_document_id'][ $data['field_name'] ] ) ? false : true, |
|
143 | - ) ); |
|
142 | + 'close_popup' => !empty($element->data['data']['associated_document_id'][$data['field_name']]) ? false : true, |
|
143 | + )); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | public function callback_load_gallery() { |
155 | 155 | // check_ajax_referer( 'load_gallery' ); |
156 | 156 | |
157 | - $data = WPEO_Upload_Class::g()->get_post_data( 'load_gallery' ); |
|
157 | + $data = WPEO_Upload_Class::g()->get_post_data('load_gallery'); |
|
158 | 158 | |
159 | 159 | ob_start(); |
160 | - require( \eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path . '/view/' . $data['display_type'] . '/gallery/button-add.view.php' ); |
|
160 | + require(\eoxia\Config_Util::$init['eo-framework']->wpeo_upload->path . '/view/' . $data['display_type'] . '/gallery/button-add.view.php'); |
|
161 | 161 | $data['title'] .= ob_get_clean(); |
162 | 162 | |
163 | 163 | ob_start(); |
164 | - WPEO_Upload_Class::g()->display_gallery( $data ); |
|
165 | - wp_send_json_success( array( |
|
164 | + WPEO_Upload_Class::g()->display_gallery($data); |
|
165 | + wp_send_json_success(array( |
|
166 | 166 | 'view' => ob_get_clean(), |
167 | - ) ); |
|
167 | + )); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -177,20 +177,20 @@ discard block |
||
177 | 177 | * @return void |
178 | 178 | */ |
179 | 179 | public function callback_set_thumbnail() { |
180 | - $data = WPEO_Upload_Class::g()->get_post_data( 'set_thumbnail' ); |
|
180 | + $data = WPEO_Upload_Class::g()->get_post_data('set_thumbnail'); |
|
181 | 181 | |
182 | - $element = WPEO_Upload_Class::g()->set_thumbnail( $data ); |
|
182 | + $element = WPEO_Upload_Class::g()->set_thumbnail($data); |
|
183 | 183 | |
184 | 184 | ob_start(); |
185 | - do_shortcode( '[wpeo_upload id="' . $element->data['id'] . '" model_name="' . str_replace( '\\', '/', $data['model_name'] ) . '" field_name="' . $data['field_name'] . '" mime_type="' . $data['mime_type'] . '" single="' . $data['single'] . '" size="' . $data['size'] . '" ]' ); |
|
186 | - wp_send_json_success( array( |
|
185 | + do_shortcode('[wpeo_upload id="' . $element->data['id'] . '" model_name="' . str_replace('\\', '/', $data['model_name']) . '" field_name="' . $data['field_name'] . '" mime_type="' . $data['mime_type'] . '" single="' . $data['single'] . '" size="' . $data['size'] . '" ]'); |
|
186 | + wp_send_json_success(array( |
|
187 | 187 | 'namespace' => '', |
188 | 188 | 'module' => 'gallery', |
189 | 189 | 'callback_success' => 'successfulSetThumbnail', |
190 | 190 | 'view' => ob_get_clean(), |
191 | 191 | 'id' => $data['id'], |
192 | 192 | 'file_id' => $data['file_id'], |
193 | - ) ); |
|
193 | + )); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 |
@@ -11,20 +11,20 @@ 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 | -<span data-id="<?php echo esc_attr( $element->data['id'] ); ?>" |
|
19 | - <?php echo WPEO_Upload_Class::g()->out_all_attributes( $atts ); // WPCS: XSS is ok. ?> |
|
20 | - data-nonce="<?php echo esc_attr( wp_create_nonce( $nonce_name ) ); ?>" |
|
21 | - class="media <?php echo esc_attr( $no_file_class . ' ' . $atts['custom_class'] ); ?>"> |
|
18 | +<span data-id="<?php echo esc_attr($element->data['id']); ?>" |
|
19 | + <?php echo WPEO_Upload_Class::g()->out_all_attributes($atts); // WPCS: XSS is ok. ?> |
|
20 | + data-nonce="<?php echo esc_attr(wp_create_nonce($nonce_name)); ?>" |
|
21 | + class="media <?php echo esc_attr($no_file_class . ' ' . $atts['custom_class']); ?>"> |
|
22 | 22 | <i class="button-add animated fas fa-plus-circle"></i> |
23 | 23 | |
24 | 24 | <?php |
25 | - if ( ! empty( $main_picture_id ) ) : |
|
26 | - if ( 'image' === $atts['mime_type'] ) : |
|
27 | - echo wp_get_attachment_image( $main_picture_id, $atts['size'] ); |
|
25 | + if (!empty($main_picture_id)) : |
|
26 | + if ('image' === $atts['mime_type']) : |
|
27 | + echo wp_get_attachment_image($main_picture_id, $atts['size']); |
|
28 | 28 | else : |
29 | 29 | ?> |
30 | 30 | <div class="document default-icon-container"> |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <?php |
34 | 34 | endif; |
35 | 35 | else : |
36 | - if ( 'image' === $atts['mime_type'] ) : |
|
36 | + if ('image' === $atts['mime_type']) : |
|
37 | 37 | ?> |
38 | 38 | <div class="default default-icon-container"> |
39 | 39 | <i class="default-image far fa-image"></i> |
@@ -48,6 +48,6 @@ discard block |
||
48 | 48 | <?php |
49 | 49 | endif; |
50 | 50 | ?> |
51 | - <input type="hidden" name="<?php echo esc_attr( $atts['field_name'] ); ?>" /> |
|
51 | + <input type="hidden" name="<?php echo esc_attr($atts['field_name']); ?>" /> |
|
52 | 52 | <?php endif; ?> |
53 | 53 | </span> |
@@ -25,14 +25,17 @@ discard block |
||
25 | 25 | if ( ! empty( $main_picture_id ) ) : |
26 | 26 | if ( 'image' === $atts['mime_type'] ) : |
27 | 27 | echo wp_get_attachment_image( $main_picture_id, $atts['size'] ); |
28 | - else : |
|
28 | + else { |
|
29 | + : |
|
29 | 30 | ?> |
30 | 31 | <div class="document default-icon-container"> |
31 | 32 | <i class="icon fas fa-paperclip" aria-hidden="true"></i> |
32 | 33 | </div> |
33 | 34 | <?php |
34 | 35 | endif; |
35 | - else : |
|
36 | + } |
|
37 | + else { |
|
38 | + : |
|
36 | 39 | if ( 'image' === $atts['mime_type'] ) : |
37 | 40 | ?> |
38 | 41 | <div class="default default-icon-container"> |
@@ -47,6 +50,7 @@ discard block |
||
47 | 50 | </div> |
48 | 51 | <?php |
49 | 52 | endif; |
53 | + } |
|
50 | 54 | ?> |
51 | 55 | <input type="hidden" name="<?php echo esc_attr( $atts['field_name'] ); ?>" /> |
52 | 56 | <?php endif; ?> |
@@ -11,24 +11,24 @@ 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 | 18 | <ul class="image-list"> |
19 | - <li data-id="<?php echo esc_attr( $main_picture_id ); ?>" class="current"> |
|
19 | + <li data-id="<?php echo esc_attr($main_picture_id); ?>" class="current"> |
|
20 | 20 | <?php |
21 | - if ( 'image' === $data['mime_type'] ) : |
|
22 | - echo wp_get_attachment_image( $main_picture_id, 'full' ); |
|
21 | + if ('image' === $data['mime_type']) : |
|
22 | + echo wp_get_attachment_image($main_picture_id, 'full'); |
|
23 | 23 | else : |
24 | 24 | ?> |
25 | 25 | <div class="document"> |
26 | 26 | <i class="icon fas fa-paperclip" aria-hidden="true"></i> |
27 | 27 | |
28 | - <?php $document_name = get_attached_file( $main_picture_id ); ?> |
|
28 | + <?php $document_name = get_attached_file($main_picture_id); ?> |
|
29 | 29 | <p> |
30 | - <span><?php echo esc_html( basename( $document_name ) ); ?></span> |
|
31 | - <?php esc_html_e( 'Preview not available', 'wpeo-upload' ); ?> |
|
30 | + <span><?php echo esc_html(basename($document_name)); ?></span> |
|
31 | + <?php esc_html_e('Preview not available', 'wpeo-upload'); ?> |
|
32 | 32 | </p> |
33 | 33 | </div> |
34 | 34 | <?php |
@@ -36,22 +36,22 @@ discard block |
||
36 | 36 | ?> |
37 | 37 | </li> |
38 | 38 | |
39 | - <?php if ( ! empty( $list_id ) ) : ?> |
|
40 | - <?php foreach ( $list_id as $key => $id ) : ?> |
|
41 | - <?php if ( $main_picture_id !== $id ) : ?> |
|
42 | - <li data-id="<?php echo esc_attr( $id ); ?>" class="hidden"> |
|
39 | + <?php if (!empty($list_id)) : ?> |
|
40 | + <?php foreach ($list_id as $key => $id) : ?> |
|
41 | + <?php if ($main_picture_id !== $id) : ?> |
|
42 | + <li data-id="<?php echo esc_attr($id); ?>" class="hidden"> |
|
43 | 43 | <?php |
44 | - if ( 'image' === $data['mime_type'] ) : |
|
45 | - echo wp_get_attachment_image( $id, 'full' ); |
|
44 | + if ('image' === $data['mime_type']) : |
|
45 | + echo wp_get_attachment_image($id, 'full'); |
|
46 | 46 | else : |
47 | 47 | ?> |
48 | 48 | <div class="document"> |
49 | 49 | <i class="icon fas fa-paperclip" aria-hidden="true"></i> |
50 | 50 | |
51 | - <?php $document_name = get_attached_file( $id ); ?> |
|
51 | + <?php $document_name = get_attached_file($id); ?> |
|
52 | 52 | <p> |
53 | - <span><?php echo esc_html( basename( $document_name ) ); ?></span> |
|
54 | - <?php esc_html_e( 'Preview not available', 'wpeo-upload' ); ?> |
|
53 | + <span><?php echo esc_html(basename($document_name)); ?></span> |
|
54 | + <?php esc_html_e('Preview not available', 'wpeo-upload'); ?> |
|
55 | 55 | </p> |
56 | 56 | </div> |
57 | 57 | <?php |
@@ -20,12 +20,15 @@ discard block |
||
20 | 20 | <?php |
21 | 21 | if ( 'image' === $data['mime_type'] ) : |
22 | 22 | echo wp_get_attachment_image( $main_picture_id, 'full' ); |
23 | - else : |
|
23 | + else { |
|
24 | + : |
|
24 | 25 | ?> |
25 | 26 | <div class="document"> |
26 | 27 | <i class="icon fas fa-paperclip" aria-hidden="true"></i> |
27 | 28 | |
28 | - <?php $document_name = get_attached_file( $main_picture_id ); ?> |
|
29 | + <?php $document_name = get_attached_file( $main_picture_id ); |
|
30 | + } |
|
31 | + ?> |
|
29 | 32 | <p> |
30 | 33 | <span><?php echo esc_html( basename( $document_name ) ); ?></span> |
31 | 34 | <?php esc_html_e( 'Preview not available', 'wpeo-upload' ); ?> |
@@ -43,12 +46,15 @@ discard block |
||
43 | 46 | <?php |
44 | 47 | if ( 'image' === $data['mime_type'] ) : |
45 | 48 | echo wp_get_attachment_image( $id, 'full' ); |
46 | - else : |
|
49 | + else { |
|
50 | + : |
|
47 | 51 | ?> |
48 | 52 | <div class="document"> |
49 | 53 | <i class="icon fas fa-paperclip" aria-hidden="true"></i> |
50 | 54 | |
51 | - <?php $document_name = get_attached_file( $id ); ?> |
|
55 | + <?php $document_name = get_attached_file( $id ); |
|
56 | + } |
|
57 | + ?> |
|
52 | 58 | <p> |
53 | 59 | <span><?php echo esc_html( basename( $document_name ) ); ?></span> |
54 | 60 | <?php esc_html_e( 'Preview not available', 'wpeo-upload' ); ?> |