Make plugin language aware
-
Hello,
I have made a patch to make your plugin language (WPML) aware. What I did is adding the option to select in which languages the popup will appear.
It is maybe not perfect but it’s a start. I cannot attach a file here so I’va copied and paste my patch below:
From 692892927647731fd4d56fa1af4c2e7a9d3dcd05 Mon Sep 17 00:00:00 2001 From: anou Date: Wed, 5 Sep 2018 12:17:36 +0200 Subject: [PATCH] Patch exit popup plugin to be WPML language aware --- app/wp-content/plugins/exit-popup/exit-popup.php | 32 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/app/wp-content/plugins/exit-popup/exit-popup.php b/app/wp-content/plugins/exit-popup/exit-popup.php index 45fd71a..a1d2bc1 100644 --- a/app/wp-content/plugins/exit-popup/exit-popup.php +++ b/app/wp-content/plugins/exit-popup/exit-popup.php @@ -103,6 +103,20 @@ function exit_popup_settings_page() { ?> </small> </td> </tr> + + <?php if( array_key_exists( 'wpml_object_id' , $GLOBALS['wp_filter']) ): // check for WPML ?> + <tr valign="top"> + <th scope="row"><?php _e('Enabled language','exitpp');?></th> + <td> + <?php $languages = apply_filters( 'wpml_active_languages', NULL, 'orderby=id&order=desc' ); + $enabled_languages = get_option('exit_popup_languages'); + foreach ($languages as $key => $value) : ?> + <label style="padding-right: 15px;"><input type="checkbox" name="exit_popup_languages[<?php echo $key;?>]" value="<?php echo $key; ?>" <?php checked( $key, $enabled_languages[$key], true); ?> /> <?php echo $value['native_name']; ?></label> + <?php endforeach; ?> + </td> + </tr> + <?php endif; ?> + <tr valign="top"> <th scope="row"><label for="exit_popup_powered_by">Show 'Powered by' Link</label></th> <td> @@ -127,6 +141,7 @@ function exit_popup_settings() { register_setting( 'exit-popup-settings', 'exit_popup_popup_title' ); register_setting( 'exit-popup-settings', 'exit_popup_popup_body' ); register_setting( 'exit-popup-settings', 'exit_popup_popup_footer' ); + register_setting( 'exit-popup-settings', 'exit_popup_languages' ); register_setting( 'exit-popup-settings', 'exit_popup_powered_by' ); } add_action( 'admin_init', 'exit_popup_settings' ); @@ -140,6 +155,7 @@ function exit_popup_deactivation() { delete_option( 'exit_popup_popup_title' ); delete_option( 'exit_popup_popup_body' ); delete_option( 'exit_popup_popup_footer' ); + delete_option( 'exit_popup_languages' ); delete_option( 'exit_popup_powered_by' ); } register_deactivation_hook( __FILE__, 'exit_popup_deactivation' ); @@ -153,9 +169,19 @@ function exit_popup_dependencies() { add_action( 'wp_enqueue_scripts', 'exit_popup_dependencies' ); function exit_popup() { - - if(!isset($_COOKIE['viewedExitPopupWP']) && $_COOKIE['viewedExitPopupWP'] != 'true') { - + // Check for language + $epp_lg = get_option('exit_popup_languages'); + $check_lg = false; + if( array_key_exists( 'wpml_object_id' , $GLOBALS['wp_filter']) ) { + $current_lg = ICL_LANGUAGE_CODE; + if( in_array($current_lg, $epp_lg) ) $check_lg = true; + } + else { + $check_lg = true; + } + + if($check_lg && !isset($_COOKIE['viewedExitPopupWP']) && $_COOKIE['viewedExitPopupWP'] != 'true') { + if(esc_attr( get_option('exit_popup_click_outside') ) == "true") { $exit_popup_click_outside = ""; } else { -- 2.10.1
- The topic ‘Make plugin language aware’ is closed to new replies.