admin-functions.php
7 years ago
class-contact-forms-list-table.php
5 years ago
config-validator.php
4 years ago
editor.php
2 years ago
help-tabs.php
3 years ago
tag-generator.php
6 years ago
welcome-panel.php
3 years ago
welcome-panel.php
308 lines
| 1 | <?php |
| 2 | |
| 3 | abstract class WPCF7_WelcomePanelColumn { |
| 4 | |
| 5 | abstract protected function icon(); |
| 6 | abstract protected function title(); |
| 7 | abstract protected function content(); |
| 8 | |
| 9 | public function print_content() { |
| 10 | $icon = sprintf( |
| 11 | '<span class="dashicons dashicons-%s" aria-hidden="true"></span>', |
| 12 | esc_attr( $this->icon() ) |
| 13 | ); |
| 14 | |
| 15 | $title = sprintf( |
| 16 | '<h3>%1$s %2$s</h3>', |
| 17 | $icon, |
| 18 | $this->title() |
| 19 | ); |
| 20 | |
| 21 | $content = $this->content(); |
| 22 | |
| 23 | if ( is_array( $content ) ) { |
| 24 | $content = implode( "\n\n", $content ); |
| 25 | } |
| 26 | |
| 27 | $content = wp_kses_post( $content ); |
| 28 | $content = wptexturize( $content ); |
| 29 | $content = convert_chars( $content ); |
| 30 | $content = wpautop( $content ); |
| 31 | |
| 32 | echo "\n"; |
| 33 | echo '<div class="welcome-panel-column">'; |
| 34 | echo $title; |
| 35 | echo $content; |
| 36 | echo '</div>'; |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | |
| 41 | class WPCF7_WelcomePanelColumn_AntiSpam extends WPCF7_WelcomePanelColumn { |
| 42 | |
| 43 | protected function icon() { |
| 44 | return 'shield'; |
| 45 | } |
| 46 | |
| 47 | protected function title() { |
| 48 | return esc_html( |
| 49 | __( "Getting spammed? You have protection.", 'contact-form-7' ) |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | protected function content() { |
| 54 | return array( |
| 55 | esc_html( __( "Spammers target everything; your contact forms are not an exception. Before you get spammed, protect your contact forms with the powerful anti-spam features Contact Form 7 provides.", 'contact-form-7' ) ), |
| 56 | sprintf( |
| 57 | /* translators: links labeled 1: 'Akismet', 2: 'reCAPTCHA', 3: 'disallowed list' */ |
| 58 | esc_html( __( 'Contact Form 7 supports spam-filtering with %1$s. Intelligent %2$s blocks annoying spambots. Plus, using %3$s, you can block messages containing specified keywords or those sent from specified IP addresses.', 'contact-form-7' ) ), |
| 59 | wpcf7_link( |
| 60 | __( 'https://contactform7.com/spam-filtering-with-akismet/', 'contact-form-7' ), |
| 61 | __( 'Akismet', 'contact-form-7' ) |
| 62 | ), |
| 63 | wpcf7_link( |
| 64 | __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), |
| 65 | __( 'reCAPTCHA', 'contact-form-7' ) |
| 66 | ), |
| 67 | wpcf7_link( |
| 68 | __( 'https://contactform7.com/comment-blacklist/', 'contact-form-7' ), |
| 69 | __( 'disallowed list', 'contact-form-7' ) |
| 70 | ) |
| 71 | ), |
| 72 | ); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | |
| 77 | class WPCF7_WelcomePanelColumn_Donation extends WPCF7_WelcomePanelColumn { |
| 78 | |
| 79 | protected function icon() { |
| 80 | return 'megaphone'; |
| 81 | } |
| 82 | |
| 83 | protected function title() { |
| 84 | return esc_html( |
| 85 | __( "Contact Form 7 needs your support.", 'contact-form-7' ) |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | protected function content() { |
| 90 | return array( |
| 91 | esc_html( __( "It is hard to continue development and support for this plugin without contributions from users like you.", 'contact-form-7' ) ), |
| 92 | sprintf( |
| 93 | /* translators: %s: link labeled 'making a donation' */ |
| 94 | esc_html( __( 'If you enjoy using Contact Form 7 and find it useful, please consider %s.', 'contact-form-7' ) ), |
| 95 | wpcf7_link( |
| 96 | __( 'https://contactform7.com/donate/', 'contact-form-7' ), |
| 97 | __( 'making a donation', 'contact-form-7' ) |
| 98 | ) |
| 99 | ), |
| 100 | esc_html( __( "Your donation will help encourage and support the plugin’s continued development and better user support.", 'contact-form-7' ) ), |
| 101 | ); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | |
| 106 | class WPCF7_WelcomePanelColumn_Flamingo extends WPCF7_WelcomePanelColumn { |
| 107 | |
| 108 | protected function icon() { |
| 109 | return 'editor-help'; |
| 110 | } |
| 111 | |
| 112 | protected function title() { |
| 113 | return esc_html( |
| 114 | __( "Before you cry over spilt mail…", 'contact-form-7' ) |
| 115 | ); |
| 116 | } |
| 117 | |
| 118 | protected function content() { |
| 119 | return array( |
| 120 | esc_html( __( "Contact Form 7 does not store submitted messages anywhere. Therefore, you may lose important messages forever if your mail server has issues or you make a mistake in mail configuration.", 'contact-form-7' ) ), |
| 121 | sprintf( |
| 122 | /* translators: %s: link labeled 'Flamingo' */ |
| 123 | esc_html( __( 'Install a message storage plugin before this happens to you. %s saves all messages through contact forms into the database. Flamingo is a free WordPress plugin created by the same author as Contact Form 7.', 'contact-form-7' ) ), |
| 124 | wpcf7_link( |
| 125 | __( 'https://contactform7.com/save-submitted-messages-with-flamingo/', 'contact-form-7' ), |
| 126 | __( 'Flamingo', 'contact-form-7' ) |
| 127 | ) |
| 128 | ), |
| 129 | ); |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | |
| 134 | class WPCF7_WelcomePanelColumn_Integration extends WPCF7_WelcomePanelColumn { |
| 135 | |
| 136 | protected function icon() { |
| 137 | return 'superhero-alt'; |
| 138 | } |
| 139 | |
| 140 | protected function title() { |
| 141 | return esc_html( |
| 142 | __( "You have strong allies to back you up.", 'contact-form-7' ) |
| 143 | ); |
| 144 | } |
| 145 | |
| 146 | protected function content() { |
| 147 | return array( |
| 148 | sprintf( |
| 149 | /* translators: 1: link labeled 'Brevo', 2: link labeled 'Constant Contact' */ |
| 150 | esc_html( __( 'Your contact forms will become more powerful and versatile by integrating them with external APIs. With CRM and email marketing services, you can build your own contact lists (%1$s and %2$s).', 'contact-form-7' ) ), |
| 151 | wpcf7_link( |
| 152 | __( 'https://contactform7.com/sendinblue-integration/', 'contact-form-7' ), |
| 153 | __( 'Brevo', 'contact-form-7' ) |
| 154 | ), |
| 155 | wpcf7_link( |
| 156 | __( 'https://contactform7.com/constant-contact-integration/', 'contact-form-7' ), |
| 157 | __( 'Constant Contact', 'contact-form-7' ) |
| 158 | ) |
| 159 | ), |
| 160 | sprintf( |
| 161 | /* translators: 1: link labeled 'reCAPTCHA', 2: link labeled 'Stripe' */ |
| 162 | esc_html( __( 'With help from cloud-based machine learning, anti-spam services will protect your forms (%1$s). Even payment services are natively supported (%2$s).', 'contact-form-7' ) ), |
| 163 | wpcf7_link( |
| 164 | __( 'https://contactform7.com/recaptcha/', 'contact-form-7' ), |
| 165 | __( 'reCAPTCHA', 'contact-form-7' ) |
| 166 | ), |
| 167 | wpcf7_link( |
| 168 | __( 'https://contactform7.com/stripe-integration/', 'contact-form-7' ), |
| 169 | __( 'Stripe', 'contact-form-7' ) |
| 170 | ) |
| 171 | ), |
| 172 | ); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | |
| 177 | function wpcf7_welcome_panel() { |
| 178 | $columns = array(); |
| 179 | |
| 180 | $flamingo_is_active = defined( 'FLAMINGO_VERSION' ); |
| 181 | |
| 182 | $sendinblue_is_active = false; |
| 183 | |
| 184 | if ( class_exists( 'WPCF7_Sendinblue' ) |
| 185 | and $sendinblue = WPCF7_Sendinblue::get_instance() ) { |
| 186 | $sendinblue_is_active = $sendinblue->is_active(); |
| 187 | } |
| 188 | |
| 189 | if ( $flamingo_is_active and $sendinblue_is_active ) { |
| 190 | $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam(); |
| 191 | $columns[] = new WPCF7_WelcomePanelColumn_Donation(); |
| 192 | } elseif ( $flamingo_is_active ) { |
| 193 | $columns[] = new WPCF7_WelcomePanelColumn_Integration(); |
| 194 | $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam(); |
| 195 | } elseif ( $sendinblue_is_active ) { |
| 196 | $columns[] = new WPCF7_WelcomePanelColumn_Flamingo(); |
| 197 | $columns[] = new WPCF7_WelcomePanelColumn_AntiSpam(); |
| 198 | } else { |
| 199 | $columns[] = new WPCF7_WelcomePanelColumn_Flamingo(); |
| 200 | $columns[] = new WPCF7_WelcomePanelColumn_Integration(); |
| 201 | } |
| 202 | |
| 203 | $classes = 'wpcf7-welcome-panel'; |
| 204 | |
| 205 | $vers = (array) get_user_meta( get_current_user_id(), |
| 206 | 'wpcf7_hide_welcome_panel_on', true |
| 207 | ); |
| 208 | |
| 209 | if ( wpcf7_version_grep( wpcf7_version( 'only_major=1' ), $vers ) ) { |
| 210 | $classes .= ' hidden'; |
| 211 | } |
| 212 | |
| 213 | ?> |
| 214 | <div id="wpcf7-welcome-panel" class="<?php echo esc_attr( $classes ); ?>"> |
| 215 | <?php wp_nonce_field( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce', false ); ?> |
| 216 | <a class="welcome-panel-close" href="<?php echo esc_url( menu_page_url( 'wpcf7', false ) ); ?>"><?php echo esc_html( __( 'Dismiss', 'contact-form-7' ) ); ?></a> |
| 217 | |
| 218 | <div class="welcome-panel-content"> |
| 219 | <div class="welcome-panel-column-container"> |
| 220 | <?php |
| 221 | |
| 222 | foreach ( $columns as $column ) { |
| 223 | $column->print_content(); |
| 224 | } |
| 225 | |
| 226 | ?> |
| 227 | </div> |
| 228 | </div> |
| 229 | </div> |
| 230 | <?php |
| 231 | } |
| 232 | |
| 233 | |
| 234 | add_action( |
| 235 | 'wp_ajax_wpcf7-update-welcome-panel', |
| 236 | 'wpcf7_admin_ajax_welcome_panel', |
| 237 | 10, 0 |
| 238 | ); |
| 239 | |
| 240 | function wpcf7_admin_ajax_welcome_panel() { |
| 241 | check_ajax_referer( 'wpcf7-welcome-panel-nonce', 'welcomepanelnonce' ); |
| 242 | |
| 243 | $vers = get_user_meta( get_current_user_id(), |
| 244 | 'wpcf7_hide_welcome_panel_on', true |
| 245 | ); |
| 246 | |
| 247 | if ( empty( $vers ) or ! is_array( $vers ) ) { |
| 248 | $vers = array(); |
| 249 | } |
| 250 | |
| 251 | if ( empty( $_POST['visible'] ) ) { |
| 252 | $vers[] = wpcf7_version( 'only_major=1' ); |
| 253 | } else { |
| 254 | $vers = array_diff( $vers, array( wpcf7_version( 'only_major=1' ) ) ); |
| 255 | } |
| 256 | |
| 257 | $vers = array_unique( $vers ); |
| 258 | |
| 259 | update_user_meta( get_current_user_id(), |
| 260 | 'wpcf7_hide_welcome_panel_on', $vers |
| 261 | ); |
| 262 | |
| 263 | wp_die( 1 ); |
| 264 | } |
| 265 | |
| 266 | |
| 267 | add_filter( |
| 268 | 'screen_settings', |
| 269 | 'wpcf7_welcome_panel_screen_settings', |
| 270 | 10, 2 |
| 271 | ); |
| 272 | |
| 273 | function wpcf7_welcome_panel_screen_settings( $screen_settings, $screen ) { |
| 274 | |
| 275 | if ( 'toplevel_page_wpcf7' !== $screen->id ) { |
| 276 | return $screen_settings; |
| 277 | } |
| 278 | |
| 279 | $vers = (array) get_user_meta( get_current_user_id(), |
| 280 | 'wpcf7_hide_welcome_panel_on', true |
| 281 | ); |
| 282 | |
| 283 | $checkbox_id = 'wpcf7-welcome-panel-show'; |
| 284 | $checked = ! in_array( wpcf7_version( 'only_major=1' ), $vers ); |
| 285 | |
| 286 | $checkbox = sprintf( |
| 287 | '<input %s />', |
| 288 | wpcf7_format_atts( array( |
| 289 | 'id' => $checkbox_id, |
| 290 | 'type' => 'checkbox', |
| 291 | 'checked' => $checked, |
| 292 | ) ) |
| 293 | ); |
| 294 | |
| 295 | $screen_settings .= sprintf( ' |
| 296 | <fieldset class="wpcf7-welcome-panel-options"> |
| 297 | <legend>%1$s</legend> |
| 298 | <label for="%2$s">%3$s %4$s</label> |
| 299 | </fieldset>', |
| 300 | esc_html( __( 'Welcome panel', 'contact-form-7' ) ), |
| 301 | esc_attr( $checkbox_id ), |
| 302 | $checkbox, |
| 303 | esc_html( __( 'Show welcome panel', 'contact-form-7' ) ) |
| 304 | ); |
| 305 | |
| 306 | return $screen_settings; |
| 307 | } |
| 308 |