Changeset 2328652
- Timestamp:
- 06/22/2020 02:18:15 PM (6 years ago)
- Location:
- thron/trunk
- Files:
-
- 14 edited
-
README.txt (modified) (2 diffs)
-
admin/class-thron-admin.php (modified) (16 diffs)
-
admin/class-thron-cron.php (modified) (3 diffs)
-
admin/class-thron-setting.php (modified) (3 diffs)
-
admin/js/collection-filter.js (modified) (4 diffs)
-
admin/js/thron-admin.js (modified) (1 diff)
-
admin/js/wp.media.library.js (modified) (3 diffs)
-
includes/class-thron.php (modified) (4 diffs)
-
languages/thron-it_IT.mo (modified) (previous)
-
languages/thron-it_IT.po (modified) (4 diffs)
-
languages/thron.pot (modified) (4 diffs)
-
public/class-thron-public.php (modified) (3 diffs)
-
public/partials/player.php (modified) (2 diffs)
-
thron.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
thron/trunk/README.txt
r2305030 r2328652 2 2 Contributors: thronspa, websolutedev 3 3 Tags: DAM 4 Stable tag: 1.0 4 Stable tag: 1.0.1 5 5 Requires at least: 5.2 6 6 Tested up to: 5.4 … … 68 68 = Setting up = 69 69 * Once the plugin is activated, go to the `THRON` settings. 70 * You ’ll be prompted to your THRON clientId, AppId and AppKey that you can find on the Wordpress Connector page in THRON.70 * Youll be prompted to your THRON clientId, AppId and AppKey that you can find on the Wordpress Connector page in THRON. 71 71 * After saving, the plugin is active and connected to the THRON platform. 72 72 -
thron/trunk/admin/class-thron-admin.php
r2304750 r2328652 232 232 wp_enqueue_script( 'thron-js', 'https://' . $thron_options['thron_clientId'] . '-cdn.thron.com/shared/lib/common/sdk/0.5.2/thron.js', array(), $this->version, true ); 233 233 234 /* 234 235 235 wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/thron-admin.js', array( 236 236 'jquery', 237 237 'media-views' 238 238 ), null, false ); 239 */ 239 240 240 241 241 /** … … 350 350 } 351 351 352 function thron_wp_ajax_query_attachments_upload( $query ) { 353 354 $request = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); 355 $thron_source = sanitize_text_field( $request['thron_source'] ); 356 357 if ( 'local' == $thron_source ) { 358 $query['meta_query'] = array( 359 array( 360 'key' => 'thron_id', 361 'compare' => 'NOT EXISTS' 362 ) 363 ); 364 } else { 365 $query['meta_query'] = array( 366 array( 367 'key' => 'thron_id', 368 'compare' => 'EXISTS' 369 ) 370 ); 371 } 372 373 return $query; 374 } 375 352 376 /** 353 377 * Carica i risultati nella finestra dei media … … 359 383 } 360 384 361 362 385 /** 363 * Es sco se non mi trovo nella pagina upload.php386 * Esco se il post__in fa riferimento ad un post in particolare 364 387 */ 365 388 if ( count( $_REQUEST['query']['post__in'] ) > 0 ) { … … 367 390 } 368 391 369 /**370 * Mostra due risultati differenti se si apre la sezione Media o se si371 * apre il frame dei media372 */373 if ( $this->thron_is_media_library() ) {374 return;375 }376 377 392 $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); 378 393 379 394 $source = sanitize_text_field( $query['thron_source'] ); 395 380 396 if ( 'local' == $source ) { 381 return $response; 397 398 $query = isset( $_REQUEST['query'] ) ? (array) $_REQUEST['query'] : array(); 399 $keys = array( 400 's', 401 'order', 402 'orderby', 403 'posts_per_page', 404 'paged', 405 'post_mime_type', 406 'post_parent', 407 'author', 408 'post__in', 409 'post__not_in', 410 'year', 411 'monthnum', 412 'meta_query' 413 ); 414 415 416 foreach ( get_taxonomies_for_attachments( 'objects' ) as $t ) { 417 if ( $t->query_var && isset( $query[ $t->query_var ] ) ) { 418 $keys[] = $t->query_var; 419 } 420 } 421 422 $query = array_intersect_key( $query, array_flip( $keys ) ); 423 $query['post_type'] = 'attachment'; 424 425 if ( 426 MEDIA_TRASH && 427 ! empty( $_REQUEST['query']['post_status'] ) && 428 'trash' === $_REQUEST['query']['post_status'] 429 ) { 430 $query['post_status'] = 'trash'; 431 } else { 432 $query['post_status'] = 'inherit'; 433 } 434 435 if ( current_user_can( get_post_type_object( 'attachment' )->cap->read_private_posts ) ) { 436 $query['post_status'] .= ',private'; 437 } 438 439 // Filter query clauses to include filenames. 440 if ( isset( $query['s'] ) ) { 441 add_filter( 'posts_clauses', '_filter_query_attachment_filenames' ); 442 } 443 444 $query['meta_query'] = array( 445 array( 446 'key' => 'thron_id', 447 'compare' => 'NOT EXISTS' 448 ) 449 ); 450 451 /** 452 * Filters the arguments passed to WP_Query during an Ajax 453 * call for querying attachments. 454 * 455 * @param array $query An array of query variables. 456 * 457 * @see WP_Query::parse_query() 458 * 459 * @since 3.7.0 460 * 461 */ 462 $query = apply_filters( 'ajax_query_attachments_args', $query ); 463 464 $query = new WP_Query( $query ); 465 466 $posts = array_map( 'wp_prepare_attachment_for_js', $query->posts ); 467 $posts = array_filter( $posts ); 468 469 wp_send_json_success( $posts ); 470 die; 382 471 } 383 472 … … 409 498 wp_send_json_success( $posts ); 410 499 die; 500 } 501 502 /** 503 * Filter attachments to correct thumbnail URLs 504 */ 505 public function wp_prepare_attachment_for_js( $attachment ) { 506 if ( ! is_array( $attachment ) ) { 507 return $attachment; 508 } 509 510 $thron_id = get_post_meta( $attachment['id'], 'thron_id', true ); 511 512 if ( ! $thron_id ) { 513 return $attachment; 514 } 515 516 if ( strpos( $attachment['mime'], 'image' ) === false ) { 517 return $attachment; 518 } 519 520 $url = get_post_meta( $attachment['id'], '_wp_attached_file', true ); 521 $filename = basename( $url ); 522 $path = str_replace( $filename, '', $url ); 523 524 foreach ( $attachment['sizes'] as $size => $item ) { 525 if ( 'full' != $size ) { 526 $width = $attachment['sizes'][ $size ]['width']; 527 $height = $attachment['sizes'][ $size ]['height']; 528 529 $attachment['sizes'][ $size ]['url'] = $path . $width . 'x' . $height . '/' . $filename; 530 } 531 } 532 533 return $attachment; 411 534 } 412 535 … … 528 651 case 'IMAGE': 529 652 530 $file_url = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $file->id . '/' . $pkey . '/std/0x0/' . $file->details->source->fileName; 653 $thron_options = get_option( 'thron_option_api_page' ); 654 $width_default = ( array_key_exists( 'thron_maxImageWidth', $thron_options ) ) ? $thron_options['thron_maxImageWidth'] : '0'; 655 656 $file_url = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $file->id . '/' . $pkey . '/std/' . strval( $width_default ) . 'x0/' . $file->details->source->fileName; 531 657 532 658 $attachment_metadata = array(); … … 534 660 'width' => null, 535 661 'height' => null, 536 'url' => $ thumbs,662 'url' => $file_url, 537 663 'crop' => false, 538 664 'mime-type' => $mime … … 641 767 } 642 768 643 /**644 * Returns true if current page is "upload.php". False otherwise.645 *646 * @return bool647 */648 private function thron_is_media_library() {649 $page = basename( $_SERVER["SCRIPT_FILENAME"], '.php' );650 651 if ( 'upload' == $page ) {652 return true;653 }654 655 return false;656 }657 658 769 function custom_media_string( $strings, $post ) { 659 770 $strings['THRONMenuTitle'] = __( 'THRON Universal Player', 'thron' ); … … 803 914 case 'IMAGE': 804 915 916 $thron_options = get_option( 'thron_option_api_page' ); 917 $width_default = ( array_key_exists( 'thron_maxImageWidth', $thron_options ) ) ? $thron_options['thron_maxImageWidth'] : '0'; 918 805 919 $thumbs = 'https://' . str_replace( '//', '', strtok( $detail->thumbUrls[0], '?' ) ); 806 920 /** … … 808 922 */ 809 923 $attached_file = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $thron_id . '/' . $pkey . '/std/' . $file_name; 810 $attached_file_full = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $thron_id . '/' . $pkey . '/std/ 0x0/' . $file_name;924 $attached_file_full = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $thron_id . '/' . $pkey . '/std/' . strval( $width_default ) . 'x0/' . $file_name; 811 925 812 926 $size = getimagesize( $attached_file_full ); 927 813 928 814 929 list ( $type, $submime ) = explode( '/', $mime ); … … 823 938 'width' => $size[0], 824 939 'height' => $size[1], 825 'file' => '0x0/' . $file_name,940 'file' => strval( $width_default ) . 'x0/' . $file_name, 826 941 'crop' => false, 827 942 'mime-type' => $mime … … 840 955 $height = intval( get_option( "{$image_size}_size_h" ) ); 841 956 842 if ( 'post-thumbnail' == $image_size ) { 843 $width = $size[0]; 844 $height = $size[1]; 957 if ( $width or $height ) { 958 if ( 'post-thumbnail' == $image_size ) { 959 $width = $size[0]; 960 $height = $size[1]; 961 } 962 963 $file = '' . $width . 'x' . $height . '/' . $file_name; 964 965 $attachment_metadata['sizes'][ $image_size ] = array( 966 'width' => $width, 967 'height' => $height, 968 'file' => $file, 969 'crop' => get_option( "{$image_size}_crop" ) ? get_option( "{$image_size}_crop" ) : false, 970 'mime-type' => $mime 971 ); 845 972 } 846 847 $file = '' . $width . 'x' . $height . '/' . $file_name;848 849 $attachment_metadata['sizes'][ $image_size ] = array(850 'width' => $width,851 'height' => $height,852 'file' => $file,853 'crop' => get_option( "{$image_size}_crop" ) ? get_option( "{$image_size}_crop" ) : false,854 'mime-type' => $mime855 );856 973 } 857 974 … … 969 1086 */ 970 1087 function filter_wp_calculate_image_srcset( $sources, $size_array, $image_src, $image_meta, $attachment_id ) { 971 // make filter magic happen here...972 1088 973 1089 $thron_id = get_post_meta( $attachment_id, 'thron_id', true ); 974 // $thron_div_area = get_post_meta( $attachment_id, 'thron_div_area', true );975 1090 976 1091 if ( ! $thron_id ) { … … 988 1103 989 1104 return $result; 990 }991 992 function wp_get_attachment_url( $url, $attachment_id ) {993 994 $post = get_post( $attachment_id );995 996 $thron_id = get_post_meta( $attachment_id, 'thron_id', true );997 998 if ( ! $thron_id ) {999 return $url;1000 }1001 1002 if ( false !== strpos( $post->post_mime_type, 'image' ) ) {1003 $url = get_post_meta( $attachment_id, '_wp_attached_file', true );1004 1005 }1006 1007 return get_post_meta( $attachment_id, '_wp_attached_file', true );1008 }1009 1010 function wp_get_attachment_image_src( $image, $attachment_id, $size, $icon ) {1011 1012 if ( $image ) {1013 $path = pathinfo( $image[0] );1014 1015 1016 $sub = explode( "/", $path['dirname'] );1017 1018 if ( end( $sub ) == 'std' ) {1019 $image[0] = $path['dirname'] . '/' . $size[0] . 'x' . $size[1] . '/' . $path['basename'];1020 }1021 }1022 1023 return $image;1024 1105 } 1025 1106 … … 1059 1140 } 1060 1141 1142 function thron_add_tci_tracking_image_block( $attributes, $content ) { 1143 1144 $content = str_replace('wp-image-', 'tci wp-image-', $content); 1145 1146 return $content; 1147 } 1148 1149 function thron_add_tci_tracking_video_block( $attributes, $content ) { 1150 1151 $content = preg_replace_callback( '/(<video) (.*video>)/i', array( 1152 $this, 1153 'process_video_audio_class' 1154 ), $content ); 1155 1156 return $content; 1157 } 1158 1159 function thron_add_tci_tracking_audio_block( $attributes, $content ) { 1160 1161 $content = preg_replace_callback( '/(<audio) (.*audio>)/i', array( 1162 $this, 1163 'process_video_audio_class' 1164 ), $content ); 1165 1166 return $content; 1167 } 1168 1169 1061 1170 function register_block_embed() { 1171 1172 register_block_type( 'core/gallery', array( 1173 'render_callback' => array( $this, 'thron_add_tci_tracking_image_block' ), 1174 ) ); 1175 1176 register_block_type( 'core/media-text', array( 1177 'render_callback' => array( $this, 'thron_add_tci_tracking_image_block' ), 1178 ) ); 1179 1180 register_block_type( 'core/audio', array( 1181 'render_callback' => array( $this, 'thron_add_tci_tracking_audio_block' ), 1182 ) ); 1183 1184 register_block_type( 'core/image', array( 1185 'render_callback' => array( $this, 'thron_add_tci_tracking_image_block' ), 1186 ) ); 1187 1188 register_block_type( 'core/video', array( 1189 'render_callback' => array( $this, 'thron_add_tci_tracking_video_block' ), 1190 ) ); 1191 1192 1062 1193 register_block_type( 1063 1194 'thron/embed', … … 1078 1209 } 1079 1210 1211 function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ) { 1212 $thron_id = get_post_meta( $id, 'thron_id', true ); 1213 1214 if ( ! $thron_id ) { 1215 return $html; 1216 } 1217 1218 $html = preg_replace_callback( '/(<img.*class="([^"]+)"[^>]*>)/i', [ $this, 'process_image_class' ], $html ); 1219 1220 $dom = new DOMDocument(); 1221 $dom->loadHTML( $html ); 1222 $imgs = $dom->getElementsByTagName( "img" ); 1223 1224 foreach ( $imgs as $img ) { 1225 1226 $thron_options = get_option( 'thron_option_api_page' ); 1227 $width_default = ( array_key_exists( 'thron_maxImageWidth', $thron_options ) ) ? $thron_options['thron_maxImageWidth'] : '0'; 1228 1229 if ( is_array( $size ) ) { 1230 $width = $size[0]; 1231 $height = $size[1]; 1232 } else { 1233 $width = intval( get_option( "{$size}_size_w" ) ); 1234 $height = intval( get_option( "{$size}_size_h" ) ); 1235 } 1236 1237 $width = $width == 0 ? $width_default : $width; 1238 1239 $file = get_post_meta( $id, '_wp_attached_file', true ); 1240 $basename = basename( $file ); 1241 $path = str_replace( $basename, '', $file ); 1242 $src = $path . $width . 'x' . $height . '/' . $basename; 1243 1244 $img->setAttribute( 'src', $src ); 1245 1246 $html = $dom->saveHTML( $img ); 1247 } 1248 1249 return $html; 1250 } 1251 1252 private function process_image_class( $matches ) { 1253 1254 $matches[1] = str_replace( $matches[2], $matches[2] . " tci", $matches[1] ); 1255 1256 return $matches[1]; 1257 } 1258 1259 private function process_video_audio_class( $matches ) { 1260 1261 return $matches[1] . ' class="tci" ' . $matches[2] ; 1262 } 1263 1080 1264 function render_block_embed( $attr ) { 1081 1082 1265 return do_shortcode( '[thron contentID="' . $attr['contentID'] . '" embedCodeId= "' . $attr['embedCode'] . '"]' ); 1083 1266 } -
thron/trunk/admin/class-thron-cron.php
r2304750 r2328652 145 145 case 'IMAGE': 146 146 147 $thron_options = get_option( 'thron_option_api_page' ); 148 $width_default = (array_key_exists('thron_maxImageWidth', $thron_options)) ? $thron_options['thron_maxImageWidth'] : '0'; 149 147 150 $thumbs = 'https://' . str_replace( '//', '', strtok( $detail->thumbUrl, '?' ) ); 148 151 /** … … 150 153 */ 151 154 $attached_file = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $detail->content->id . '/' . $pkey . '/std/' . $file_name; 152 $attached_file_full = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $detail->content->id . '/' . $pkey . '/std/ 0x0/' . $file_name;155 $attached_file_full = 'https://' . $clientId . '-cdn.thron.com/delivery/public/image/' . $clientId . '/' . $detail->content->id . '/' . $pkey . '/std/' . strval($width_default) . 'x0/' . $file_name; 153 156 154 157 $file_name = sanitize_title( $language->name ) . '.' . thron_mime2ext( $mime ); … … 167 170 'width' => $size[0], 168 171 'height' => $size[1], 169 'file' => '0x0/' . $file_name,172 'file' => strval($width_default) . 'x0/' . $file_name, 170 173 'crop' => false, 171 174 'mime-type' => $mime -
thron/trunk/admin/class-thron-setting.php
r2304750 r2328652 67 67 ) ); 68 68 69 $main_options->add_field( array( 70 'name' => __( 'Image settings', 'thron' ), 71 'desc' => '', 72 'type' => 'title', 73 'id' => 'image_title' 74 ) ); 75 76 $main_options->add_field( array( 77 'name' => __( 'Default maximum width (px)', 'thron' ), 78 'description' => __( 'Maximum default size for images imported from THRON', 'thron' ), 79 'id' => 'thron_maxImageWidth', 80 'default' => 1920, 81 'type' => 'text', 82 ) ); 83 69 84 $pkey = get_option( 'thron_pkey' ); 70 85 … … 150 165 $thron_options = get_option( 'thron_option_api_page' ); 151 166 167 152 168 $clientId = $thron_options['thron_clientId']; 153 169 $appId = $thron_options['thron_appId']; … … 161 177 162 178 function thron_admin_notices() { 179 180 $thron_options = get_option( 'thron_option_api_page' ); 181 182 if (! array_key_exists('thron_maxImageWidth', $thron_options ) or $thron_options['thron_maxImageWidth'] == '' ) { 183 $thron_options['thron_maxImageWidth'] = 1920; 184 185 update_option( 'thron_option_api_page', $thron_options ); 186 } 163 187 164 188 $thron_options = get_option( 'thron_option_api_page' ); -
thron/trunk/admin/js/collection-filter.js
r2304750 r2328652 8 8 * Create a new MediaLibraryTaxonomyFilter we later will instantiate 9 9 */ 10 var MediaLibrarySourceFilter = wp.media.view.AttachmentFilters.extend({ 11 id: 'media-attachment-thron-source-filter', 12 13 createFilters: function () { 14 15 var filters = {}; 16 17 var props = {}; 18 props['thron_source'] = 'thron'; 19 20 filters.all = { 21 text: 'THRON', 22 props: props, 23 priority: 10 24 }; 25 26 var props = {}; 27 props['thron_source'] = 'local'; 28 filters['local'] = { 29 text: 'Local files', 30 props: props 31 }; 32 33 34 this.filters = filters; 35 } 36 }); 37 38 39 /** 40 * Create a new MediaLibraryTaxonomyFilter we later will instantiate 41 */ 10 42 var MediaLibraryTaxonomyFilter = wp.media.view.AttachmentFilters.extend({ 11 id: 'media-attachment-thron-tags-filter' , 43 id: 'media-attachment-thron-tags-filter', 44 className : 'attachment-filters attachment-filters-tag', 12 45 13 46 createFilters: function () { … … 29 62 props['thron_tags_' + dataStore.tags.id] = ''; 30 63 31 console.log(ThronTagsList);;32 33 64 filters.all = { 34 65 text: ThronTagsList.lang.all + ' ' + dataStore.tags.name, … … 45 76 */ 46 77 var MediaLibraryFoldersFilter = wp.media.view.AttachmentFilters.extend({ 47 id: 'media-attachment-thron-folders-filter' ,78 id: 'media-attachment-thron-folders-filter', 48 79 49 80 createFilters: function () { … … 88 119 89 120 /** 121 * Viene creato il filtro per la sorgente 122 */ 123 t.toolbar.set('MediaLibrarySourceFilter', new MediaLibrarySourceFilter({ 124 controller: t.controller, 125 model: t.collection.props, 126 priority: -150 127 }).render()); 128 129 /** 90 130 * Viene creato il filtro per le cartelle 91 131 */ 92 t.toolbar.set('MediaLibraryFoldersFilter' , new MediaLibraryFoldersFilter({132 t.toolbar.set('MediaLibraryFoldersFilter', new MediaLibraryFoldersFilter({ 93 133 controller: t.controller, 94 134 model: t.collection.props, -
thron/trunk/admin/js/thron-admin.js
r2304750 r2328652 1 1 jQuery(document).ready(function ($) { 2 2 3 $(document).on("change", '#media-attachment-thron-source-filter', function(event) { 4 if (this.value == 'local') { 5 $('#media-attachment-thron-folders-filter').prop('disabled', 'disabled'); 6 $('.attachment-filters-tag').prop('disabled', 'disabled'); 7 8 } else { 9 $('#media-attachment-thron-folders-filter').prop('disabled', false); 10 $('.attachment-filters-tag').prop('disabled', false); 11 12 } 13 }); 14 3 15 }); 16 17 18 const setExtraPropsToBlockType = (props, blockType, attributes) => { 19 const notDefined = (typeof props.className === 'undefined' || !props.className) ? true : false 20 21 if (blockType.name === 'core/cover') { 22 return Object.assign(props, { 23 className: notDefined ? ' tci' : 'tci ' + props.className, 24 }); 25 } 26 27 return props; 28 }; 29 30 wp.hooks.addFilter( 31 'blocks.getSaveContent.extraProps', 32 'your-namespace/block-filters', 33 setExtraPropsToBlockType 34 ); -
thron/trunk/admin/js/wp.media.library.js
r2304750 r2328652 95 95 var element = collection.get(attachment.id); 96 96 97 console.log (element);98 97 99 98 $.ajax({ … … 101 100 dataType: "json", 102 101 url: myAjax.ajaxurl, 103 data: {action: "thron_file_upload", 'thron_id': attachment.id}, 102 data: { 103 action: "thron_file_upload", 104 'thron_id': attachment.id 105 }, 104 106 async: false, 105 107 success: function (response) { 106 108 if (response.success == true) { 107 108 console.log(response.data);109 console.log(response.data.url);110 109 111 110 element.set({id: response.data.ID}); … … 154 153 console.log('Fine del salvataggio...'); 155 154 156 /*157 var controller = wp.media.frame.state().get('gallery-library');158 var library = controller.get('library');159 get the shortcode and update the input field160 var new_shortcode = wp.media.gallery.shortcode(library).string();161 console.log(new_shortcode)162 */163 155 }); 164 156 -
thron/trunk/includes/class-thron.php
r2304750 r2328652 71 71 $this->version = THRON_VERSION; 72 72 } else { 73 $this->version = '1.0. 0';73 $this->version = '1.0.1'; 74 74 } 75 75 $this->plugin_name = 'thron'; … … 198 198 199 199 /** 200 * Adds the class for image tracking 201 */ 202 $this->loader->add_filter( 'image_send_to_editor', $plugin_admin, 'image_send_to_editor', 10, 8 ); 203 204 205 /** 200 206 * Perform AJAX search in the media library 201 207 */ 202 208 if ( isset($_SERVER["HTTP_REFERER"]) && strpos($_SERVER["HTTP_REFERER"], 'upload.php') === false) { 203 209 $this->loader->add_action( 'wp_ajax_query-attachments', $plugin_admin, 'thron_wp_ajax_query_attachments', 1 ); 210 } else { 211 $this->loader->add_filter( 'ajax_query_attachments_args', $plugin_admin, 'thron_wp_ajax_query_attachments_upload', 1 ); 204 212 } 213 214 215 /** 216 * Filter attachments to correct thumbnail URLs 217 */ 218 $this->loader->add_action( 'wp_prepare_attachment_for_js', $plugin_admin, 'wp_prepare_attachment_for_js', 1 ); 205 219 206 220 /** … … 231 245 */ 232 246 $this->loader->add_filter( 'wp_calculate_image_srcset', $plugin_admin, 'filter_wp_calculate_image_srcset', 10, 5 ); 233 $this->loader->add_filter( 'wp_get_attachment_url', $plugin_admin, 'wp_get_attachment_url', 10, 2 );234 $this->loader->add_filter( 'wp_get_attachment_image_src', $plugin_admin, 'wp_get_attachment_image_src', 10, 4 );235 247 236 248 /** … … 261 273 262 274 /** 263 * Adds the class for image tracking264 */265 $this->loader->add_filter( 'image_send_to_editor', $plugin_public, 'image_send_to_editor', 10, 8 );266 267 /**268 275 * Adds the shortcode to embed the player 269 276 */ 270 277 add_shortcode('thron', array($plugin_public, 'thron_shortcode')); 278 279 $this->loader->add_filter( 'wp_get_attachment_image_src', $plugin_public, 'wp_get_attachment_image_src', 10, 4 ); 280 $this->loader->add_filter( 'wp_get_attachment_url', $plugin_public, 'wp_get_attachment_url', 10, 2 ); 281 282 $this->loader->add_filter( 'wp_get_attachment_image_attributes', $plugin_public, 'filter_wp_get_attachment_image_attributes', 10, 3 ); 283 284 /** 285 * Add class tci to image 286 */ 287 $this->loader->add_filter( 'get_image_tag_class', $plugin_public, 'get_image_tag_class', 10, 3 ); 288 $this->loader->add_filter( 'wp_get_attachment_image_attributes', $plugin_public, 'wp_get_attachment_image_attributes', 10, 3 ); 289 271 290 } 272 291 -
thron/trunk/languages/thron-it_IT.po
r2304750 r2328652 2 2 msgstr "" 3 3 "Language: it_IT\n" 4 "POT-Creation-Date: 2020-0 4-16 12:08+0000\n"4 "POT-Creation-Date: 2020-05-26 16:27+0000\n" 5 5 "Plural-Forms: nplurals=2; plural=n != 1;\n" 6 "PO-Revision-Date: 2020-0 4-16 12:10+0000\n"6 "PO-Revision-Date: 2020-05-26 16:29+0000\n" 7 7 "X-Generator: Loco https://localise.biz/\n" 8 8 "Project-Id-Version: THRON\n" 9 9 "Report-Msgid-Bugs-To: \n" 10 "Last-Translator: admin <dev-email@flywheel.local>\n"10 "Last-Translator: \n" 11 11 "Language-Team: Italiano\n" 12 12 "MIME-Version: 1.0\n" 13 13 "Content-Type: text/plain; charset=UTF-8\n" 14 14 "Content-Transfer-Encoding: 8bit\n" 15 "X-Loco-Version: 2.3. 1; wp-5.4"15 "X-Loco-Version: 2.3.4; wp-5.4.1" 16 16 17 #: admin/class-thron-admin.php:27 817 #: admin/class-thron-admin.php:276 18 18 msgid "All" 19 19 msgstr "Tutti" 20 20 21 #: admin/class-thron-admin.php:27 9 admin/class-thron-admin.php:30521 #: admin/class-thron-admin.php:277 admin/class-thron-admin.php:303 22 22 msgid "All folders" 23 23 msgstr "Tutte le cartelle" 24 24 25 #: admin/class-thron-admin.php:30 625 #: admin/class-thron-admin.php:304 26 26 msgid "All content" 27 27 msgstr "Tutti i contenuti" 28 28 29 #: admin/class-thron-admin.php:30 729 #: admin/class-thron-admin.php:305 30 30 msgid "Content details" 31 31 msgstr "Dettagli del contenuto" 32 32 33 #: admin/class-thron-admin.php:30 833 #: admin/class-thron-admin.php:306 34 34 msgid "Player template" 35 35 msgstr "Template per il player" 36 36 37 #: admin/class-thron-admin.php:30 937 #: admin/class-thron-admin.php:307 38 38 msgid "--Please select a template--" 39 39 msgstr "--Seleziona un template--" 40 40 41 #: admin/class-thron-admin.php:3 1041 #: admin/class-thron-admin.php:308 42 42 msgid "Embed type" 43 43 msgstr "Tipo di embed" 44 44 45 #: admin/class-thron-admin.php:3 1145 #: admin/class-thron-admin.php:309 46 46 msgid "Fixed size" 47 47 msgstr "Dimensione fissa" 48 48 49 #: admin/class-thron-admin.php:31 249 #: admin/class-thron-admin.php:310 50 50 msgid "Width (px)" 51 51 msgstr "Larghezza (px)" 52 52 53 #: admin/class-thron-admin.php:31 353 #: admin/class-thron-admin.php:311 54 54 msgid "Height (px)" 55 55 msgstr "Altezza (px)" 56 56 57 #: admin/class-thron-admin.php: 65557 #: admin/class-thron-admin.php:736 58 58 msgid "THRON Universal Player" 59 59 msgstr "THRON Universal Player" 60 60 61 #: admin/class-thron-admin.php: 65661 #: admin/class-thron-admin.php:737 62 62 msgid "Insert" 63 63 msgstr "Inserisci" … … 100 100 msgstr "Inserisci la chiave di autenticazione del connettore" 101 101 102 #: admin/class-thron-setting.php:108 102 #: admin/class-thron-setting.php:70 103 msgid "Image settings" 104 msgstr "Opzioni immagini" 105 106 #: admin/class-thron-setting.php:77 107 msgid "Default maximum width (px)" 108 msgstr "Larghezza massima di default (px)" 109 110 #: admin/class-thron-setting.php:78 111 msgid "Maximum default size for images imported from THRON" 112 msgstr "Dimensione massima di default per le immagini importate da THRON" 113 114 #: admin/class-thron-setting.php:123 103 115 msgid "Search option" 104 116 msgstr "Opzioni di ricerca" 105 117 106 #: admin/class-thron-setting.php:1 09118 #: admin/class-thron-setting.php:124 107 119 msgid "" 108 120 "Choose whether to use tags as search filters and set the root folder of " … … 112 124 "principale dei contenuti WordPress" 113 125 114 #: admin/class-thron-setting.php:1 15126 #: admin/class-thron-setting.php:130 115 127 msgid "Enable filtering" 116 128 msgstr "Abilita il filtraggio" 117 129 118 #: admin/class-thron-setting.php:1 21130 #: admin/class-thron-setting.php:136 119 131 msgid "Enable tag filtering" 120 132 msgstr "Abilita il filtraggio per tag" 121 133 122 #: admin/class-thron-setting.php:1 22134 #: admin/class-thron-setting.php:137 123 135 msgid "Select the tags to be used for filtering" 124 136 msgstr "Seleziona le tag da utilizzare per i filtraggi" 125 137 126 #: admin/class-thron-setting.php:1 34138 #: admin/class-thron-setting.php:149 127 139 msgid "Select starting folder" 128 140 msgstr "Cartella di partenza" 129 141 130 #: admin/class-thron-setting.php:1 35142 #: admin/class-thron-setting.php:150 131 143 msgid "" 132 144 "Select the starting folder for content selection (subfolders will be " … … 136 148 "incluse anche le sottocartelle)" 137 149 138 #: admin/class-thron-setting.php:1 69150 #: admin/class-thron-setting.php:197 139 151 msgid "The connector has not been successfully configured!!" 140 152 msgstr "Il connettore non è stato configurato correttamente!" 141 153 142 #: admin/class-thron-setting.php: 191154 #: admin/class-thron-setting.php:219 143 155 msgid "THRON has not been configured!" 144 156 msgstr "THRON non è stato configurato!" 145 157 146 #: admin/class-thron-setting.php: 197158 #: admin/class-thron-setting.php:225 147 159 msgid "THRON login failed!" 148 160 msgstr "Login fallito su THRON!" 149 161 150 #: admin/class-thron-setting.php:2 03162 #: admin/class-thron-setting.php:231 151 163 msgid "" 152 164 "The application has not been configured correctly. Please contact technical " -
thron/trunk/languages/thron.pot
r2304750 r2328652 3 3 msgstr "" 4 4 "Language: \n" 5 "POT-Creation-Date: 2020-0 4-16 12:08+0000\n"5 "POT-Creation-Date: 2020-05-26 16:27+0000\n" 6 6 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" 7 7 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 8 8 "X-Generator: Loco https://localise.biz/" 9 9 10 #: admin/class-thron-admin.php:27 810 #: admin/class-thron-admin.php:276 11 11 msgid "All" 12 12 msgstr "" 13 13 14 #: admin/class-thron-admin.php:27 9 admin/class-thron-admin.php:30514 #: admin/class-thron-admin.php:277 admin/class-thron-admin.php:303 15 15 msgid "All folders" 16 16 msgstr "" 17 17 18 #: admin/class-thron-admin.php:30 618 #: admin/class-thron-admin.php:304 19 19 msgid "All content" 20 20 msgstr "" 21 21 22 #: admin/class-thron-admin.php:30 722 #: admin/class-thron-admin.php:305 23 23 msgid "Content details" 24 24 msgstr "" 25 25 26 #: admin/class-thron-admin.php:30 826 #: admin/class-thron-admin.php:306 27 27 msgid "Player template" 28 28 msgstr "" 29 29 30 #: admin/class-thron-admin.php:30 930 #: admin/class-thron-admin.php:307 31 31 msgid "--Please select a template--" 32 32 msgstr "" 33 33 34 #: admin/class-thron-admin.php:3 1034 #: admin/class-thron-admin.php:308 35 35 msgid "Embed type" 36 36 msgstr "" 37 37 38 #: admin/class-thron-admin.php:3 1138 #: admin/class-thron-admin.php:309 39 39 msgid "Fixed size" 40 40 msgstr "" 41 41 42 #: admin/class-thron-admin.php:31 242 #: admin/class-thron-admin.php:310 43 43 msgid "Width (px)" 44 44 msgstr "" 45 45 46 #: admin/class-thron-admin.php:31 346 #: admin/class-thron-admin.php:311 47 47 msgid "Height (px)" 48 48 msgstr "" 49 49 50 #: admin/class-thron-admin.php: 65550 #: admin/class-thron-admin.php:736 51 51 msgid "THRON Universal Player" 52 52 msgstr "" 53 53 54 #: admin/class-thron-admin.php: 65654 #: admin/class-thron-admin.php:737 55 55 msgid "Insert" 56 56 msgstr "" … … 93 93 msgstr "" 94 94 95 #: admin/class-thron-setting.php:108 95 #: admin/class-thron-setting.php:70 96 msgid "Image settings" 97 msgstr "" 98 99 #: admin/class-thron-setting.php:77 100 msgid "Default maximum width (px)" 101 msgstr "" 102 103 #: admin/class-thron-setting.php:78 104 msgid "Maximum default size for images imported from THRON" 105 msgstr "" 106 107 #: admin/class-thron-setting.php:123 96 108 msgid "Search option" 97 109 msgstr "" 98 110 99 #: admin/class-thron-setting.php:1 09111 #: admin/class-thron-setting.php:124 100 112 msgid "" 101 113 "Choose whether to use tags as search filters and set the root folder of " … … 103 115 msgstr "" 104 116 105 #: admin/class-thron-setting.php:1 15117 #: admin/class-thron-setting.php:130 106 118 msgid "Enable filtering" 107 119 msgstr "" 108 120 109 #: admin/class-thron-setting.php:1 21121 #: admin/class-thron-setting.php:136 110 122 msgid "Enable tag filtering" 111 123 msgstr "" 112 124 113 #: admin/class-thron-setting.php:1 22125 #: admin/class-thron-setting.php:137 114 126 msgid "Select the tags to be used for filtering" 115 127 msgstr "" 116 128 117 #: admin/class-thron-setting.php:1 34129 #: admin/class-thron-setting.php:149 118 130 msgid "Select starting folder" 119 131 msgstr "" 120 132 121 #: admin/class-thron-setting.php:1 35133 #: admin/class-thron-setting.php:150 122 134 msgid "" 123 135 "Select the starting folder for content selection (subfolders will be " … … 125 137 msgstr "" 126 138 127 #: admin/class-thron-setting.php:1 69139 #: admin/class-thron-setting.php:197 128 140 msgid "The connector has not been successfully configured!!" 129 141 msgstr "" 130 142 131 #: admin/class-thron-setting.php: 191143 #: admin/class-thron-setting.php:219 132 144 msgid "THRON has not been configured!" 133 145 msgstr "" 134 146 135 #: admin/class-thron-setting.php: 197147 #: admin/class-thron-setting.php:225 136 148 msgid "THRON login failed!" 137 149 msgstr "" 138 150 139 #: admin/class-thron-setting.php:2 03151 #: admin/class-thron-setting.php:231 140 152 msgid "" 141 153 "The application has not been configured correctly. Please contact technical " -
thron/trunk/public/class-thron-public.php
r2304750 r2328652 98 98 $tracking_context = get_option( 'thron_tracking_context' ); 99 99 100 $width = (('responsive' == $embedType) and ($atts['width'] == '')) ? 100 : $atts['width'];100 $width = ( ( 'responsive' == $embedType ) and ( $atts['width'] == '' ) ) ? 100 : $atts['width']; 101 101 102 102 $uniqID = uniqid(); … … 107 107 108 108 return $string; 109 }110 111 /**112 * Aggiunge il la classe alle immagini113 */114 public function thron_alter_att_attributes_image( $attr, $attachment ) {115 $attr['class'] = 'thron';116 117 return $attr;118 109 } 119 110 … … 132 123 } 133 124 134 function image_send_to_editor( $html, $id, $caption, $title, $align, $url, $size, $alt ) { 135 $pattern = '/(<img.*class="([^"]+)"[^>]*>)/i'; 136 137 $html = preg_replace_callback( $pattern, [ $this, 'process' ], $html ); 138 139 return $html; 140 } 141 142 private function process( $matches ) { 143 144 $matches[1] = str_replace( $matches[2], $matches[2] . " tci", $matches[1] ); 145 146 return $matches[1]; 147 125 function wp_get_attachment_image_src( $image, $attachment_id, $size, $icon ) { 126 127 $thron_id = get_post_meta( $attachment_id, 'thron_id', true ); 128 129 if ( ! $thron_id ) { 130 return $image; 131 } 132 133 $thron_options = get_option( 'thron_option_api_page' ); 134 $width_default = ( array_key_exists( 'thron_maxImageWidth', $thron_options ) ) ? $thron_options['thron_maxImageWidth'] : '0'; 135 136 if ( $image ) { 137 // $path = pathinfo( $image[0] ); 138 $path = pathinfo( get_post_meta( $attachment_id, '_wp_attached_file', true ) ); 139 140 $sub = explode( "/", $path['dirname'] ); 141 142 if ( end( $sub ) == 'std' ) { 143 $width = 0; 144 $height = 0; 145 146 if ( is_array( $size ) ) { 147 $width = $size[0]; 148 $height = $size[1]; 149 } else { 150 $width = intval( get_option( "{$size}_size_w" ) ); 151 $height = intval( get_option( "{$size}_size_h" ) ); 152 } 153 154 $width = $width == 0 ? $width_default : $width; 155 $image[0] = $path['dirname'] . '/' . $width . 'x' . $height . '/' . $path['basename']; 156 } 157 158 } 159 160 return $image; 161 } 162 163 function wp_get_attachment_url( $url, $attachment_id ) { 164 165 $thron_options = get_option( 'thron_option_api_page' ); 166 $width_default = ( array_key_exists( 'thron_maxImageWidth', $thron_options ) ) ? $thron_options['thron_maxImageWidth'] : '0'; 167 168 169 $post = get_post( $attachment_id ); 170 171 $thron_id = get_post_meta( $attachment_id, 'thron_id', true ); 172 173 if ( ! $thron_id ) { 174 return $url; 175 } 176 177 $url = get_post_meta( $attachment_id, '_wp_attached_file', true ); 178 179 if ( strpos($post->post_mime_type, 'image') === false ) { 180 return $url; 181 } 182 183 $filename = basename( $url ); 184 185 $path = str_replace( $filename, '', $url ); 186 187 return $path . $width_default . 'x0/' . $filename;; 188 } 189 190 public function filter_wp_get_attachment_image_attributes( $attr, $attachment, $size ) { 191 192 $thron_id = get_post_meta( $attachment->ID, 'thron_id', true ); 193 194 if ( ! $thron_id ) { 195 return $attr; 196 } 197 198 199 $attachment_metadata = wp_get_attachment_metadata( $attachment->ID ); 200 $attached_file = dirname( get_post_meta( $attachment->ID, '_wp_attached_file', true ) ); 201 202 if ( !is_array($attachment_metadata) or ! array_key_exists( 'sizes', $attachment_metadata ) ) { 203 return $attr; 204 } 205 206 $size_array = $attachment_metadata['sizes']; 207 $max_srcset_image_width = apply_filters( 'max_srcset_image_width', 2048, $size_array ); 208 209 $srcset = ''; 210 211 foreach ( $size_array as $size ) { 212 if ( $size['width'] and $size['width'] < $max_srcset_image_width ) { 213 $srcset .= str_replace( ' ', '%20', $attached_file . '/' . $size['file'] ) . ' ' . $size['width'] . 'w, '; 214 } 215 } 216 217 $attr['srcset'] = rtrim( $srcset, ', ' ); 218 219 return $attr; 220 } 221 222 /** 223 * Add class tci to image 224 */ 225 226 public function wp_get_attachment_image_attributes( $attr, $attachment ) { 227 $attr['class'] .= ' tci'; 228 229 return $attr; 230 } 231 232 public function get_image_tag_class($class) { 233 return strpos($class, 'tci') !== false ? $class . ' tci' : $class; 148 234 } 149 235 -
thron/trunk/public/partials/player.php
r2304750 r2328652 1 <?php if ('responsive' == $embedType ) : ?> 2 <div style="padding-top:<?= $aspectRatio; ?>%; width: 100%; position: relative"> 3 <div id="elementId_<?= $uniqID; ?>" style="width: 100%; height: 100%; position: absolute; top: 0"></div> 4 </div> 1 <?php if ( 'responsive' == $embedType ) : ?> 2 <div> 3 <div style="padding-top:<?= $aspectRatio; ?>%; width: 100%; position: relative"> 4 <div id="elementId_<?= $uniqID; ?>" style="width: 100%; height: 100%; position: absolute; top: 0"></div> 5 </div> 6 </div> 5 7 <?php else : ?> 6 <div id="elementId_<?= $uniqID;?>" style="width: <?= $width; ?>px; height: <?= $height; ?>px;"></div>8 <div id="elementId_<?= $uniqID; ?>" style="width: <?= $width; ?>px; height: <?= $height; ?>px;"></div> 7 9 <?php endif; ?> 8 10 … … 10 12 11 13 var options = { 12 <?= $tracking_context ? '"contextId": "' . $tracking_context .'",' : ''; ?>14 <?= $tracking_context ? '"contextId": "' . $tracking_context . '",' : ''; ?> 13 15 "clientId": "<?= $clientId; ?>", 14 16 "xcontentId": "<?= $contentID; ?>", -
thron/trunk/thron.php
r2304750 r2328652 17 17 * Plugin URI: 18 18 * Description: Select the assets to insert within your pages directly from the DAM library 19 * Version: 1.0. 019 * Version: 1.0.1 20 20 * Author: THRON 21 21 * Author URI: https://www.thron.com
Note: See TracChangeset
for help on using the changeset viewer.