PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
← All changes | app/hooks.php +51 -11 1.3.01.9.2 View file →
@@ -18,17 +18,39 @@
18 18 }
19 19 add_action( 'after_setup_theme', 'depicter_add_thumbnail_size' );
20 20
21 21
22 -function depicter_purge_document_cache( $documentID, $properties ) {
22 +/**
23 + * Make assets and cache for slider after publishing the changes
24 + *
25 + * @param $documentID
26 + * @param $properties
27 + *
28 + * @return void
29 + */
30 +function depicter_make_document_cache( $documentID, $properties ) {
23 31 if ( $properties['status'] === 'publish' ) {
24 - \Depicter::cache('document')->delete( $documentID );
32 + \Depicter::front()->render()->flushDocumentCache( $documentID );
33 + \Depicter::front()->render()->document( $documentID, [ 'echo' => false ] );
25 34 }
26 35 }
27 -add_action( 'depicter/editor/after/store', 'depicter_purge_document_cache', 10, 2 );
36 +add_action( 'depicter/editor/after/store', 'depicter_make_document_cache', 10, 2 );
28 37
29 38
30 39 /**
40 + * Remove document cache after document was deleted
41 + *
42 + * @param $documentID
43 + *
44 + * @return void
45 + */
46 +function depicter_purge_document_cache( $documentID ) {
47 + \Depicter::front()->render()->flushDocumentCache( $documentID );
48 +}
49 +add_action( 'depicter/editor/after/delete', 'depicter_purge_document_cache', 10 );
50 +
51 +
52 +/**
31 53 * Depicter sanitize html tags for depicter slider output
32 54 *
33 55 * @param array $allowed_tags
34 56 * @return void
@@ -33,9 +55,9 @@
33 55 * @param array $allowed_tags
34 56 * @return void
35 57 */
36 58 function depicter_sanitize_html_tags_for_output( $allowed_tags ) {
37 - return array_merge( $allowed_tags, wp_kses_allowed_html( 'post' ) );
59 + return array_merge_recursive( $allowed_tags, wp_kses_allowed_html( 'post' ) );
38 60 }
39 61 add_filter( 'averta/wordpress/sanitize/html/tags/depicter/output', 'depicter_sanitize_html_tags_for_output' );
40 62
41 63
@@ -76,23 +98,22 @@
76 98 return $data;
77 99 }
78 100 add_filter( 'wp_update_attachment_metadata', 'depicter_set_svg_meta_data', 10, 2 );
79 101
102 +function depicter_clear_cache() {
103 + \Depicter::cache('document')->clear();
104 +}
105 +
80 106 function depicter_clear_cache_by_cache_enabler() {
81 107 $cacheEnabled = !empty( $_GET['_cache'] ) && $_GET['_cache'] == 'cache-enabler' ? true : false;
82 108 $isClearAction = !empty( $_GET['_action'] ) && ( $_GET['_action'] == 'clear' || $_GET['_action'] == 'clearurl' );
83 109 if ( $cacheEnabled && $isClearAction && !empty( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'cache_enabler_clear_cache_nonce' ) ) {
84 - $documents = \Depicter::documentRepository()->getList();
85 - if ( !empty( $documents ) ) {
86 - foreach( $documents as $document ) {
87 - \Depicter::cache('document')->delete( $document['id'] );
88 - }
89 - }
110 + depicter_clear_cache();
90 111 }
91 112 }
92 113 add_action( 'init', 'depicter_clear_cache_by_cache_enabler' );
114 +add_action( 'post_updated', 'depicter_clear_cache' );
93 115
94 -
95 116 add_filter( 'style_loader_tag', 'depicter_add_preload_to_styles', 10, 2 );
96 117 function depicter_add_preload_to_styles( $html, $handle ){
97 118 if (strpos( $handle, 'depicter--') === 0) {
98 119 $html = str_replace("rel='stylesheet'", 'rel="preload" as="style" onload="this.rel=\'stylesheet\';this.onload=null"', $html);
@@ -106,4 +127,23 @@
106 127 }
107 128 return $tag;
108 129 }
109 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 +