elementor
1 year ago
logs
2 months ago
strong-testimonials-beaver-block
1 year ago
submodules
9 months ago
class-strong-gutemberg.php
1 year ago
class-strong-log.php
1 year ago
class-strong-mail.php
1 year ago
class-strong-testimonials-average-shortcode.php
1 year ago
class-strong-testimonials-count-shortcode.php
1 year ago
class-strong-testimonials-defaults.php
3 weeks ago
class-strong-testimonials-form.php
2 months ago
class-strong-testimonials-order.php
1 year ago
class-strong-testimonials-privacy.php
1 year ago
class-strong-testimonials-render.php
2 months ago
class-strong-testimonials-templates.php
3 weeks ago
class-strong-testimonials-view-shortcode.php
1 month ago
class-strong-testimonials-view-widget.php
1 year ago
class-strong-view-display.php
6 days ago
class-strong-view-form.php
3 weeks ago
class-strong-view-slideshow.php
1 month ago
class-strong-view.php
1 month ago
class-walker-strong-category-checklist-front.php
1 year ago
deprecated.php
1 year ago
filters.php
2 months ago
functions-activation.php
3 weeks ago
functions-content.php
1 year ago
functions-image.php
7 months ago
functions-rating.php
1 year ago
functions-template-form.php
3 weeks ago
functions-template.php
3 weeks ago
functions-views.php
1 year ago
functions.php
2 weeks ago
l10n-polylang.php
1 year ago
l10n-wpml.php
1 year ago
post-types.php
1 week ago
retro.php
1 year ago
scripts.php
2 months ago
class-strong-testimonials-privacy.php
204 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; |
| 4 | } |
| 5 | |
| 6 | /** |
| 7 | * Class Strong_Testimonials_Privacy |
| 8 | * |
| 9 | * @since 2.41.0 |
| 10 | */ |
| 11 | class Strong_Testimonials_Privacy { |
| 12 | |
| 13 | public function __construct() { |
| 14 | $this->add_hooks(); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @since 2.41.0 |
| 19 | */ |
| 20 | public function add_hooks() { |
| 21 | add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporter' ) ); |
| 22 | add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_eraser' ) ); |
| 23 | add_action( 'admin_init', array( $this, 'wpmtst_register_privacy_policy_template' ) ); |
| 24 | } |
| 25 | |
| 26 | /** |
| 27 | * @since 2.41.0 |
| 28 | * @return string |
| 29 | */ |
| 30 | public function get_friendly_name() { |
| 31 | return esc_html__( 'Strong Testimonials Plugin', 'strong-testimonials' ); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * @param $email_address |
| 36 | * @param int $page |
| 37 | * |
| 38 | * @since 2.41.0 |
| 39 | * @return array |
| 40 | */ |
| 41 | public function exporter( $email_address, $page = 1 ) { |
| 42 | $number = 100; // Limit us to avoid timing out |
| 43 | $page = (int) $page; |
| 44 | |
| 45 | $export_items = array(); |
| 46 | |
| 47 | $args = array( |
| 48 | 'post_type' => 'wpm-testimonial', |
| 49 | 'post_status' => 'publish', |
| 50 | 'posts_per_page' => $number, |
| 51 | 'offset' => $number * ( $page - 1 ), |
| 52 | 'suppress_filters' => true, |
| 53 | ); |
| 54 | |
| 55 | $testimonials = get_posts( $args ); |
| 56 | |
| 57 | foreach ( (array) $testimonials as $testimonial ) { |
| 58 | $post_meta = get_post_meta( $testimonial->ID ); |
| 59 | |
| 60 | $item_id = "testimonial-{$testimonial->ID}"; |
| 61 | $group_id = 'testimonials'; |
| 62 | $group_label = esc_html__( 'Testimonials', 'strong-testimonials' ); |
| 63 | |
| 64 | $data = array(); |
| 65 | |
| 66 | foreach ( $post_meta as $key => $value ) { |
| 67 | $found = array_search( $email_address, $value, true ); |
| 68 | if ( false !== $found ) { |
| 69 | $data = array( |
| 70 | array( |
| 71 | 'name' => 'Email', |
| 72 | 'value' => $value[ $found ], |
| 73 | ), |
| 74 | array( |
| 75 | 'name' => 'Client Name', |
| 76 | 'value' => $post_meta['client_name'][0], |
| 77 | ), |
| 78 | array( |
| 79 | 'name' => 'Company Name', |
| 80 | 'value' => $post_meta['company_name'][0], |
| 81 | ), |
| 82 | ); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | if ( $data ) { |
| 87 | $export_items[] = array( |
| 88 | 'group_id' => $group_id, |
| 89 | 'group_label' => $group_label, |
| 90 | 'item_id' => $item_id, |
| 91 | 'data' => $data, |
| 92 | ); |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // Tell core if we have more comments to work on still |
| 97 | $done = count( $testimonials ) < $number; |
| 98 | |
| 99 | return array( |
| 100 | 'data' => $export_items, |
| 101 | 'done' => $done, |
| 102 | ); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @param $email_address |
| 107 | * @param int $page |
| 108 | * |
| 109 | * @since 2.41.0 |
| 110 | * @return array |
| 111 | */ |
| 112 | public function eraser( $email_address, $page = 1 ) { |
| 113 | $number = 100; // Limit us to avoid timing out |
| 114 | $page = (int) $page; |
| 115 | |
| 116 | $items_removed = false; |
| 117 | |
| 118 | $args = array( |
| 119 | 'post_type' => 'wpm-testimonial', |
| 120 | 'post_status' => 'publish', |
| 121 | 'posts_per_page' => $number, |
| 122 | 'offset' => $number * ( $page - 1 ), |
| 123 | 'suppress_filters' => true, |
| 124 | ); |
| 125 | |
| 126 | $testimonials = get_posts( $args ); |
| 127 | |
| 128 | foreach ( (array) $testimonials as $testimonial ) { |
| 129 | $post_meta = get_post_meta( $testimonial->ID ); |
| 130 | |
| 131 | foreach ( $post_meta as $key => $value ) { |
| 132 | if ( in_array( $email_address, $value, true ) ) { |
| 133 | //delete_post_meta( $testimonial->ID, $key, $email_address ); |
| 134 | wp_delete_post( $testimonial->ID ); |
| 135 | $items_removed = true; |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | // Tell core if we have more comments to work on still |
| 141 | $done = count( $testimonials ) < $number; |
| 142 | |
| 143 | return array( |
| 144 | 'items_removed' => $items_removed, |
| 145 | 'items_retained' => false, // always false in this example |
| 146 | 'messages' => array(), // no messages in this example |
| 147 | 'done' => $done, |
| 148 | ); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * @param array $exporters |
| 153 | * |
| 154 | * @since 2.41.0 |
| 155 | * @return array |
| 156 | */ |
| 157 | public function register_exporter( $exporters ) { |
| 158 | $exporters['strong-testimonials'] = array( |
| 159 | 'exporter_friendly_name' => $this->get_friendly_name(), |
| 160 | 'callback' => array( $this, 'exporter' ), |
| 161 | ); |
| 162 | |
| 163 | return $exporters; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * @param array $erasers |
| 168 | * @since 2.41.0 |
| 169 | * @return array |
| 170 | */ |
| 171 | public function register_eraser( $erasers ) { |
| 172 | $erasers['strong-testimonials'] = array( |
| 173 | 'eraser_friendly_name' => $this->get_friendly_name(), |
| 174 | 'callback' => array( $this, 'eraser' ), |
| 175 | ); |
| 176 | |
| 177 | return $erasers; |
| 178 | } |
| 179 | |
| 180 | public function wpmtst_register_privacy_policy_template() { |
| 181 | |
| 182 | if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { |
| 183 | return; |
| 184 | } |
| 185 | |
| 186 | $content = wp_kses_post( |
| 187 | apply_filters( |
| 188 | 'wpmtst_privacy_policy_content', |
| 189 | __( |
| 190 | ' |
| 191 | We collect certain pieces of information about you when you fill one of our testimonial forms. This includes your full name, e-mail address, photo, company name, and website. |
| 192 | By agreeing to these terms, you also allow us to:: |
| 193 | - Send a confirmation e-mail, to let you know your testimonial was received and approved; |
| 194 | - Send important account/ product/ service information; |
| 195 | - Set up and administer your account, provide technical/customer support, and verify your identity.', |
| 196 | 'strong-testimonials' |
| 197 | ) |
| 198 | ) |
| 199 | ); |
| 200 | |
| 201 | wp_add_privacy_policy_content( 'Strong Testimonial Privacy Policy', wpautop( $content ) ); |
| 202 | } |
| 203 | } |
| 204 |