| @@ -55,9 +55,9 @@ | ||
| 55 | 55 | * @param array $allowed_tags |
| 56 | 56 | * @return void |
| 57 | 57 | */ |
| 58 | 58 | function depicter_sanitize_html_tags_for_output( $allowed_tags ) { |
| 59 | - return array_merge( $allowed_tags, wp_kses_allowed_html( 'post' ) ); | |
| 59 | + return array_merge_recursive( $allowed_tags, wp_kses_allowed_html( 'post' ) ); | |
| 60 | 60 | } |
| 61 | 61 | add_filter( 'averta/wordpress/sanitize/html/tags/depicter/output', 'depicter_sanitize_html_tags_for_output' ); |
| 62 | 62 | |
| 63 | 63 | |
| @@ -98,23 +98,22 @@ | ||
| 98 | 98 | return $data; |
| 99 | 99 | } |
| 100 | 100 | add_filter( 'wp_update_attachment_metadata', 'depicter_set_svg_meta_data', 10, 2 ); |
| 101 | 101 | |
| 102 | +function depicter_clear_cache() { | |
| 103 | + \Depicter::cache('document')->clear(); | |
| 104 | +} | |
| 105 | + | |
| 102 | 106 | function depicter_clear_cache_by_cache_enabler() { |
| 103 | 107 | $cacheEnabled = !empty( $_GET['_cache'] ) && $_GET['_cache'] == 'cache-enabler' ? true : false; |
| 104 | 108 | $isClearAction = !empty( $_GET['_action'] ) && ( $_GET['_action'] == 'clear' || $_GET['_action'] == 'clearurl' ); |
| 105 | 109 | if ( $cacheEnabled && $isClearAction && !empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'cache_enabler_clear_cache_nonce' ) ) { |
| 106 | - $documents = \Depicter::documentRepository()->getList(); | |
| 107 | - if ( !empty( $documents ) ) { | |
| 108 | - foreach( $documents as $document ) { | |
| 109 | - \Depicter::cache('document')->delete( $document['id'] ); | |
| 110 | - } | |
| 111 | - } | |
| 110 | + depicter_clear_cache(); | |
| 112 | 111 | } |
| 113 | 112 | } |
| 114 | 113 | add_action( 'init', 'depicter_clear_cache_by_cache_enabler' ); |
| 114 | +add_action( 'post_updated', 'depicter_clear_cache' ); | |
| 115 | 115 | |
| 116 | - | |
| 117 | 116 | add_filter( 'style_loader_tag', 'depicter_add_preload_to_styles', 10, 2 ); |
| 118 | 117 | function depicter_add_preload_to_styles( $html, $handle ){ |
| 119 | 118 | if (strpos( $handle, 'depicter--') === 0) { |
| 120 | 119 | $html = str_replace("rel='stylesheet'", 'rel="preload" as="style" onload="this.rel=\'stylesheet\';this.onload=null"', $html); |
| @@ -128,4 +127,23 @@ | ||
| 128 | 127 | } |
| 129 | 128 | return $tag; |
| 130 | 129 | } |
| 131 | 130 | add_filter( 'script_loader_tag', 'depicter_add_defer_to_scripts', 15, 2 ); |
| 131 | + | |
| 132 | +/** | |
| 133 | + * Check if imported media deleted then remove its ID from imported assets dictionary | |
| 134 | + * | |
| 135 | + * @param int $attachment_id | |
| 136 | + * @return void | |
| 137 | + */ | |
| 138 | +function depicter_check_deleted_imported_media( $attachment_id ) { | |
| 139 | + \Depicter::media()->maybeRemoveAttachmentFromDictionary( $attachment_id ); | |
| 140 | +} | |
| 141 | +add_action( 'delete_attachment', 'depicter_check_deleted_imported_media'); | |
| 142 | + | |
| 143 | +function depicter_check_activation() { | |
| 144 | + if ( isset( $_GET['depicter_upgraded'] ) || ( isset( $_GET['page'] ) && $_GET['page'] == 'depicter-dashboard' ) || ( isset( $_GET['action'] ) && $_GET['action'] == 'depicter' ) ) { | |
| 145 | + \Depicter::client()->validateActivation(); | |
| 146 | + } | |
| 147 | +} | |
| 148 | +add_action( 'admin_init', 'depicter_check_activation' ); | |
| 149 | + | |