Plugin Directory

Changeset 3267326


Ignore:
Timestamp:
04/05/2025 10:21:04 PM (10 months ago)
Author:
hippooo
Message:

1.0.3 - Fix modal display on home page

Location:
hippoo-popup/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • hippoo-popup/trunk/app/admin-page.php

    r3203303 r3267326  
    3333                    <th scope="row"><label for="agents"><?php echo esc_html( __( 'Agents', 'hippoo-popup' ) ); ?></label></th>
    3434                    <td>
    35                         <input type="checkbox" name="agents[windowsPhone]" <?php checked( isset( $opt['agents']['windowsPhone'] ) && $opt['agents']['windowsPhone'] == 'true' ); ?> value="true" /> Windows Phone <br>
    36                         <input type="checkbox" name="agents[android]" <?php checked( isset( $opt['agents']['android'] ) && $opt['agents']['android'] == 'true' ); ?> value="true" /> Android <br>
    37                         <input type="checkbox" name="agents[ios]" <?php checked( isset( $opt['agents']['ios'] ) && $opt['agents']['ios'] == 'true' ); ?> value="true" /> IOS <br>
    38                         <input type="checkbox" name="agents[unknown]" <?php checked( isset( $opt['agents']['unknown'] ) && $opt['agents']['unknown'] == 'true' ); ?> value="true" /> Unknown <br>
     35                        <input type="checkbox" name="agents[windowsPhone]" <?php checked( isset( $opt['agents'] ) && in_array( 'windowsPhone', $opt['agents'] ) ); ?> value="true" /> Windows Phone <br>
     36                        <input type="checkbox" name="agents[android]" <?php checked( isset( $opt['agents'] ) && in_array( 'android', $opt['agents'] ) ); ?> value="true" /> Android <br>
     37                        <input type="checkbox" name="agents[ios]" <?php checked( isset( $opt['agents'] ) && in_array( 'ios', $opt['agents'] ) ); ?> value="true" /> IOS <br>
     38                        <input type="checkbox" name="agents[unknown]" <?php checked( isset( $opt['agents'] ) && in_array( 'unknown', $opt['agents'] ) ); ?> value="true" /> Unknown <br>
    3939                    </td>
    4040                </tr>
  • hippoo-popup/trunk/app/popup-template.php

    r3203303 r3267326  
    22    if ( ! defined( 'ABSPATH' ) ) exit;
    33?>
    4 
    54<div id="gift-sheet" class="gift-sheet">
    65    <?php if ( isset( $opt['image'] ) ) : ?>
  • hippoo-popup/trunk/app/web-api-auth.php

    r3267218 r3267326  
    3737        $current = get_option( 'hippoo_popup_settings', array() );
    3838        $sanitized = hippoo_popup_recursive_sanitize( $datas );
    39         $merged = hippoo_popup_recursive_merge( $current, $sanitized );
     39        $merged = array_merge( $current, $sanitized );
    4040        update_option( 'hippoo_popup_settings', $merged );
    4141        return rest_ensure_response( $merged );
  • hippoo-popup/trunk/hippoo-popup.php

    r3267220 r3267326  
    22/**
    33 * Plugin Name: Hippoo Popup
    4  * Version: 1.0.2
     4 * Version: 1.0.3
    55 * Plugin URI: https://Hippoo.app
    66 * Description: The ultimate extension to elevate your store's engagement! With Hippoo Popup, seamlessly integrate captivating popups directly within the Hippoo app, boosting interaction and driving results like never before.
     
    1515define( 'HIPPOO_POPUP_URL', plugins_url( 'hippoo-popup' ) . '/assets' );
    1616include_once( plugin_dir_path( __FILE__ ) . 'app' . DIRECTORY_SEPARATOR . 'web-api-auth.php' );
     17
    1718
    1819// Load translation files
     
    8182
    8283            foreach ( $valid_agents as $agent ) {
    83                 $settings['agents'][ $agent ] = in_array( $agent, $agents, true );
    84             }
    85         } else {
    86             // Default values if no agents are selected
    87             foreach ( $valid_agents as $agent ) {
    88                 $settings['agents'][ $agent ] = false;
     84                if ( isset( $agents[$agent] ) && $agents[$agent] === 'true' ) {
     85                    $settings['agents'][] = $agent;
     86                }
    8987            }
    9088        }
     
    105103// Enqueue JS
    106104function hippoo_popup_enqueue_inline_external_js() {
    107     if ( ! is_admin() ) {
    108         return;
    109     }
     105    // if ( is_admin() ) {
     106    // return;
     107    // }
    110108
    111109    // Get the plugin options and sanitize them
     
    122120        $ags = array();
    123121        foreach ( $agents as $k => $v ) {
    124             if ( $v === 'true' ) {
    125                 $ags[] = sanitize_text_field( $k );
     122            if ( true === filter_var( $v, FILTER_VALIDATE_BOOLEAN ) ) {
     123                $ags[] = "'" . esc_js( sanitize_text_field( $k ) ) . "'";
    126124            }
    127125        }
    128         $ags = implode( ',', array_map( 'esc_js', $ags ) );
     126        $ags_string = ! empty( $ags ) ? "agents: [" . implode( ',', $ags ) . "]," : '';
    129127
    130128        // Sanitize and validate timeout
     
    134132        $inline_code = "
    135133        (function($) {
    136             setTimeout(() => {
    137                 $('#gift-sheet').bottomSheet({
    138                     openOnInit: " . ( isset( $opt['openOnInit'] ) && $opt['openOnInit'] === 'true' ? 'true' : 'false' ) . ",
    139                     persistent: " . ( isset( $opt['persist'] ) && $opt['persist'] === 'true' ? 'true' : 'false' ) . ",
    140                     dialogMode: " . ( isset( $opt['dialogMode'] ) && $opt['dialogMode'] === 'true' ? 'true' : 'false' ) . ",
    141                     hashTracker: '" . esc_js( isset( $opt['secondaryButtonLabel'] ) ? sanitize_text_field( $opt['secondaryButtonLabel'] ) : '' ) . "',
    142                     once: " . ( isset( $opt['once'] ) && $opt['once'] === 'true' ? 'true' : 'false' ) . ",
    143                     agents: [" . $ags . "],
    144                     cookiePrefix: null,
    145                     appendTo: 'body',
    146                     onInit: $.noop(),
    147                 });
    148             }, " . esc_js( $timeout ) . ");
     134            $(document).ready(function() {
     135                setTimeout(() => {
     136                    const \$el = $('#gift-sheet');
     137                    if (!\$el.length) {
     138                        console.warn('#gift-sheet not found');
     139                        return;
     140                    }
     141
     142                    \$el.bottomSheet({
     143                        openOnInit: " . ( isset( $opt['openOnInit'] ) && $opt['openOnInit'] === 'true' ? 'true' : 'false' ) . ",
     144                        persistent: " . ( isset( $opt['persist'] ) && $opt['persist'] === 'true' ? 'true' : 'false' ) . ",
     145                        dialogMode: " . ( isset( $opt['dialogMode'] ) && $opt['dialogMode'] === 'true' ? 'true' : 'false' ) . ",
     146                        hashTracker: '" . esc_js( isset( $opt['secondaryButtonLabel'] ) ? sanitize_text_field( $opt['secondaryButtonLabel'] ) : '' ) . "',
     147                        once: " . ( isset( $opt['once'] ) && $opt['once'] === 'true' ? 'true' : 'false' ) . ",
     148                        " . $ags_string . "
     149                        cookiePrefix: null,
     150                        appendTo: 'body',
     151                        onInit: $.noop(),
     152                    });
     153                }, " . esc_js( $timeout ) . ");
     154            });
    149155        })(jQuery);";
     156
    150157        wp_add_inline_script( 'hp-bottomSheet', $inline_code );
    151158    }
    152159}
    153 add_action( 'admin_enqueue_scripts', 'hippoo_popup_enqueue_inline_external_js', 10 );
     160add_action( 'wp_enqueue_scripts', 'hippoo_popup_enqueue_inline_external_js', 10 );
     161
    154162
    155163// Hook popup to footer
     
    158166
    159167    if ( isset( $opt['active'] ) && $opt['active'] == 'true' ) {
    160         include( plugin_dir_path( __FILE__ ) . 'app' . DIRECTORY_SEPARATOR .  'popup-template.php' );
     168        $template_file_path = plugin_dir_path( __FILE__ ) . 'app' . DIRECTORY_SEPARATOR .  'popup-template.php';
     169        require_once $template_file_path;
    161170    }
    162171}
  • hippoo-popup/trunk/readme.txt

    r3267220 r3267326  
    55Requires at least: 5.3
    66Tested up to: 6.7
    7 Stable tag: 1.0.2
     7Stable tag: 1.0.3
    88Text Domain: hippoo-popup
    99License: GPL3
     
    3535== Changelog ==
    3636
    37 = 1.0.2 =
    38 * Cleanup
    39 
    40 = 1.0.1 =
    41 * Minor updates
    42 
    43 = 1.0.0 =
    44 * Initial release.
    45 
    46 == Upgrade Notice ==
    47 
    48 = 1.0.0 =
    49 This is the initial release of the plugin.
     37* 1.0.3 - Fix modal display on home page
     38* 1.0.2 - Cleanup
     39* 1.0.1 - Minor updates
     40* 1.0.0 - Initial release.
Note: See TracChangeset for help on using the changeset viewer.