| @@ -98,22 +98,21 @@ | ||
| 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' ); |
| 115 | - | |
| 114 | +add_action( 'post_updated', 'depicter_clear_cache' ); | |
| 116 | 115 | |
| 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) { |