Plugin Directory

Changeset 3396930


Ignore:
Timestamp:
11/17/2025 06:33:31 AM (2 months ago)
Author:
essentialplugin
Message:

Fixed code conflict issue affecting widget saving.

Location:
wp-team-showcase-and-slider
Files:
126 added
3 edited

Legend:

Unmodified
Added
Removed
  • wp-team-showcase-and-slider/trunk/readme.txt

    r3394370 r3396930  
    44Requires at least: 4.0
    55Tested up to: 6.8.3
    6 Stable tag: 2.8.5
     6Stable tag: 2.8.6
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    168168== Changelog ==
    169169
     170= 2.8.6 (17, Nov 2025) =
     171* [*] Fixed code conflict issue affecting widget saving.
     172
    170173= 2.8.5 (12, Nov 2025) =
    171174* [*] Check compatibility with WordPress version 6.8.3
  • wp-team-showcase-and-slider/trunk/wp-team-showcase-and-slider.php

    r3394370 r3396930  
    77 * Description: Easy to add and display your employees, team members in Grid view, Slider view and in widget. Also work with Gutenberg shortcode block.
    88 * Author: Essential Plugin
    9  * Version: 2.8.5
     9 * Version: 2.8.6
    1010 * Author URI: https://essentialplugin.com
    1111 *
     
    1919
    2020if ( ! defined( 'WP_TSAS_VERSION' ) ) {
    21     define( 'WP_TSAS_VERSION', '2.8.5' ); // Version of plugin
     21    define( 'WP_TSAS_VERSION', '2.8.6' ); // Version of plugin
    2222}
    2323
  • wp-team-showcase-and-slider/trunk/wpos-analytics/includes/class-anylc-admin.php

    r3394370 r3396930  
    99 */
    1010
    11 if ( !defined( 'ABSPATH' ) ) {
     11if ( ! defined( 'ABSPATH' ) ) {
    1212    exit; // Exit if accessed directly
    1313}
     
    2121    public $changelog           = null;
    2222    public $release_date        = null;
     23    private $analytics_slugs = array();
    2324
    2425    function __construct() {
     
    2728
    2829        // Plugin action links
    29         if( ! empty( $wpos_analytics_module ) ) {
     30        if ( ! empty( $wpos_analytics_module ) ) {
    3031            foreach ($wpos_analytics_module as $module_key => $module) {
    31 
    3232                // Filter to add Opt In / Out row
    3333                add_filter( 'plugin_action_links_' . $module_key, array($this, 'wpos_anylc_add_action_links'), 10, 4 );
     34
     35                $product_slug = isset( $module['slug'] ) ? $module['slug'] : '';
     36               
     37                if ( !empty( $product_slug ) ) {
     38                    // Store slug for later CORS match
     39                    $this->analytics_slugs[] = $product_slug;
     40                }
    3441            }
    3542        }
     
    7683        global $menu, $submenu, $wpos_analytics_module;
    7784
    78         if( !empty( $wpos_analytics_module ) ) {
     85        if ( !empty( $wpos_analytics_module ) ) {
    7986            foreach ($wpos_analytics_module as $module_key => $module) {
    8087
    8188                $opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] );
    8289
    83                 if( !empty( $module['menu'] ) && !isset( $opt_in_data['status'] ) ) {
     90                if ( !empty( $module['menu'] ) && !isset( $opt_in_data['status'] ) ) {
    8491                    remove_menu_page( $module['menu'] );
    8592                }
     
    98105        global $menu, $submenu, $wpos_analytics_module;
    99106
    100         if( !empty( $wpos_analytics_module ) ) {
     107        if ( !empty( $wpos_analytics_module ) ) {
    101108
    102109            // WP Menu data
     
    110117
    111118                // Offers Page
    112                 if( !empty( $module['offers'] ) && $anylc_page == $module['slug'].'-offers' ) {
    113                     add_submenu_page( $module['menu'], 'WPOS Offers', '<span style="color:#2ECC71">Premium Offers</span>', 'manage_options', $module['slug'].'-offers', array($this, 'wpos_anylc_offers_html') );
     119                if ( !empty( $module['offers'] ) && $anylc_page == $module['slug'] . '-offers' ) {
     120                    add_submenu_page( $module['menu'], 'WPOS Offers', '<span style="color:#2ECC71">Premium Offers</span>', 'manage_options', $module['slug'] . '-offers', array($this, 'wpos_anylc_offers_html') );
    114121                }
    115122
    116123                // If data is set
    117                 if( $optin_status == 1 ) {
     124                if ( $optin_status == 1 ) {
    118125                    continue;
    119126                }
     
    122129                $menu_args = array();
    123130
    124                 if( $optin_status === 0 || $optin_status === 2 ) {
     131                if ( $optin_status === 0 || $optin_status === 2 ) {
    125132
    126133                    // Register admin menu
    127                     if( $anylc_page == $module['slug'] ) {
    128                         add_submenu_page( $module['menu'], $module['name'].' '.'Opt In', $module['name'].' '.'Opt In', 'manage_options', $module['slug'], array($this, 'wpos_anylc_page_html') );
     134                    if ( $anylc_page == $module['slug'] ) {
     135                        add_submenu_page( $module['menu'], $module['name'] . ' ' . 'Opt In', $module['name'] . ' ' . 'Opt In', 'manage_options', $module['slug'], array($this, 'wpos_anylc_page_html') );
    129136                    }
    130137
    131138                } else {
    132139
    133                     if( !empty( $wpos_menu_data ) ) {
     140                    if ( !empty( $wpos_menu_data ) ) {
    134141                        $orig_menu_pos = array_search( $module['menu'], $wpos_menu_data );
    135142
    136                         if( $orig_menu_pos !== false ) {
     143                        if ( $orig_menu_pos !== false ) {
    137144
    138145                            $menu_args = array(
     
    145152
    146153                    // Taking default name and icon
    147                     if( empty( $menu_args ) ) {
     154                    if ( empty( $menu_args ) ) {
    148155                        $menu_args = array(
    149156                                        'name'      => $module['name'],
     
    174181
    175182        // if no data is set then return
    176         if( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) {
     183        if ( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) {
    177184            return;
    178185        }
     
    191198        $skip_url   = wp_nonce_url( $skip_url, 'wpos_anylc_act' );
    192199
    193         require_once WPOS_ANYLC_DIR .'/templates/analytic.php';
     200        require_once WPOS_ANYLC_DIR . '/templates/analytic.php';
    194201    }
    195202
     
    208215
    209216        // if no data is set then return
    210         if( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) {
     217        if ( ! isset( $wpos_analytics_product[ $anylc_product_name ] ) ) {
    211218            return;
    212219        }
     
    217224        $opt_in         = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : null;
    218225
    219         include_once( WPOS_ANYLC_DIR .'/templates/offers.php' );
     226        include_once( WPOS_ANYLC_DIR . '/templates/offers.php' );
    220227    }
    221228
     
    234241
    235242        // If analytics module data is there
    236         if( $module_data ) {
     243        if ( $module_data ) {
    237244
    238245            $opt_in_data    = wpos_anylc_get_option( $module_data['anylc_optin'] );
     
    240247
    241248            // If user has opt in
    242             if( $opt_in == 1 ) {
    243 
    244                 $new_links['wpos_anylc'] = '<a href="#" class="wpos-anylc-opt-out-link" data-id="'.$module_data['id'].'">'.__('Opt Out', 'wpos_analytic').'</a>';
     249            if ( $opt_in == 1 ) {
     250
     251                $new_links['wpos_anylc'] = '<a href="#" class="wpos-anylc-opt-out-link" data-id="' . $module_data['id'] . '">' . __('Opt Out', 'wpos_analytic') . '</a>';
    245252
    246253            } else {
     
    248255                $opt_in_link = wpos_anylc_optin_url( $module_data, $opt_in );
    249256
    250                 $new_links['wpos_anylc'] = '<a href="'.esc_url( $opt_in_link ).'" class="wpos-anylc-opt-in-link">'.__('Opt In', 'wpos_analytic').'</a>';
     257                $new_links['wpos_anylc'] = '<a href="' . esc_url( $opt_in_link ) . '" class="wpos-anylc-opt-in-link">' . __('Opt In', 'wpos_analytic') . '</a>';
    251258            }
    252259
     
    264271    function wpos_anylc_admin_init_process() {
    265272
    266         if( isset( $_GET['message'] ) && 'wpos-anylc-dismiss-notice' == $_GET['message'] && ! empty( $_GET['anylc_id'] )
     273        if ( isset( $_GET['message'] ) && 'wpos-anylc-dismiss-notice' == $_GET['message'] && ! empty( $_GET['anylc_id'] )
    267274            && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wpos-anylc-dismiss-notice-nonce' )
    268275            ) {
     
    272279
    273280        // Flush the redirect transient
    274         if( isset( $_GET['anylc_nonce'] ) && wp_verify_nonce( $_GET['anylc_nonce'], 'wpos-anylc-redirect-nonce' ) ) {
     281        if ( isset( $_GET['anylc_nonce'] ) && wp_verify_nonce( $_GET['anylc_nonce'], 'wpos-anylc-redirect-nonce' ) ) {
    275282            update_option( 'wpos_anylc_redirect', '' );
    276283        }
     
    286293            parse_str( parse_url( $redirect, PHP_URL_QUERY ), $url_data );
    287294
    288             if( ! isset( $url_data['anylc_nonce'] ) || ( isset( $url_data['anylc_nonce'] ) && ! wp_verify_nonce( $_GET['anylc_nonce'], 'wpos-anylc-redirect-nonce' ) ) ) {
     295            if ( ! isset( $url_data['anylc_nonce'] ) || ( isset( $url_data['anylc_nonce'] ) && ! wp_verify_nonce( $_GET['anylc_nonce'], 'wpos-anylc-redirect-nonce' ) ) ) {
    289296                $redirect = add_query_arg( array( 'anylc_nonce' => wp_create_nonce( 'wpos-anylc-redirect-nonce' ) ), $redirect );
    290297            }
     
    304311    function wpos_anylc_optin_notice() {
    305312
     313        // Prevent breaking JSON/AJAX/REST responses
     314        if ( wp_doing_ajax() || wp_is_json_request() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
     315            return;
     316        }
     317       
    306318        global $current_screen, $wpos_analytics_module, $wpos_analytics_product;
     319
     320        // Ensure screen object exists
     321        if ( ! isset( $current_screen ) || ! is_object( $current_screen ) ) {
     322            return;
     323        }
    307324
    308325        // Taking some variables
    309326        $screen_id = isset( $current_screen->id ) ? $current_screen->id : '';
    310327
    311         // Plugin action links
    312         if( $screen_id == 'dashboard' && current_user_can('manage_options') && !empty( $wpos_analytics_module ) ) {
    313             foreach ($wpos_analytics_module as $module_key => $module) {
     328        // Show notices only on dashboard for admins
     329        if ( $screen_id == 'dashboard' && current_user_can('manage_options') && !empty( $wpos_analytics_module ) ) {
     330            foreach ($wpos_analytics_module as $module) {
    314331
    315332                $anylc_pdt_id       = $module['id'];
    316                 $notice_transient   = get_transient( 'wpos_anylc_optin_notice_'.$anylc_pdt_id );
    317 
    318                 if( $notice_transient == false ) {
     333                $notice_transient   = get_transient( 'wpos_anylc_optin_notice_' . $anylc_pdt_id );
     334
     335                if ( $notice_transient == false ) {
    319336
    320337                    $opt_in_data    = wpos_anylc_get_option( $module['anylc_optin'] );
     
    323340
    324341                    // If user has opt in
    325                     if( $opt_in == -1 ) {
     342                    if ( $opt_in == -1 ) {
    326343
    327344                        $anylc_pdt_name     = $module['name'];
     
    329346
    330347                        echo '<div class="updated notice wpos-anylc-notice wpos-anylc-optin-notice">
    331                         <p><strong>'.wp_kses_post( $anylc_pdt_name ).'</strong> - We made a few tweaks to the plugin, <a href="'.esc_url( $anylc_optin_url ).'">Opt in to make it Better!</a></p>
    332                         <a href="'.esc_url( $notice_link ).'" class="notice-dismiss"></a>
     348                        <p><strong>' . wp_kses_post( $anylc_pdt_name ) . '</strong> - We made a few tweaks to the plugin, <a href="' . esc_url( $anylc_optin_url ) . '">Opt in to make it Better!</a></p>
     349                        <a href="' . esc_url( $notice_link ) . '" class="notice-dismiss"></a>
    333350                        </div>';
    334351
     
    339356        } // End of if
    340357
    341         if( isset($_GET['message']) && $_GET['message'] == 'optout_success' ) {
     358        // Handle message parameter
     359        $message = isset($_GET['message']) ? sanitize_text_field($_GET['message']) : '';
     360
     361        if ( 'optout_success' == $message ) {
    342362            echo '<div class="updated notice wpos-anylc-optin-notice is-dismissible">
    343363                    <p><strong>Sorry to let you go. You are now opted out from the plugin.</strong></p>
     
    345365        }
    346366
    347         // Process Promotion Data
    348         if( !empty($_GET['message']) && $_GET['message'] == 'wpos_anylc_promotion' && !empty($_GET['wpos_anylc_pdt']) && !empty($_GET['wpos_anylc_promo_pdt']) ) {
     367         // Handle promotion download
     368        if ( 'wpos_anylc_promotion' == $message && !empty($_GET['wpos_anylc_pdt']) && !empty($_GET['wpos_anylc_promo_pdt']) ) {
    349369
    350370            $promotion              = 1;
    351371            $wpos_anylc_promo_pdt   = sanitize_text_field( $_GET['wpos_anylc_promo_pdt'] );
    352372            $promotion_pdt          = explode( ',', $wpos_anylc_promo_pdt );
     373            $promotion_pdt_data = array();
    353374
    354375            $anylc_pdt      = sanitize_text_field( $_GET['wpos_anylc_pdt'] );
    355376            $anylc_pdt_data = isset( $wpos_analytics_product[ $anylc_pdt ] ) ? $wpos_analytics_product[ $anylc_pdt ] : false;
    356377
    357             if( !empty($promotion_pdt) ) {
    358                 foreach ($promotion_pdt as $pdt_key => $pdt) {
    359                     if( isset( $anylc_pdt_data['promotion'][$pdt]['file'] ) ) {
    360                         $promotion_pdt_data[] = '<a href="'.$anylc_pdt_data['promotion'][$pdt]['file'].'">'.$anylc_pdt_data['promotion'][$pdt]['name'].'</a>';
    361                     }
    362                 }
    363             }
    364 
    365             if( $promotion_pdt_data ) {
     378            if ( !empty($promotion_pdt) ) {
     379                foreach ($promotion_pdt as $pdt) {
     380                    if ( isset( $anylc_pdt_data['promotion'][$pdt]['file'] ) ) {
     381                        $promotion_pdt_data[] = '<a href="' . $anylc_pdt_data['promotion'][$pdt]['file'] . '">' . $anylc_pdt_data['promotion'][$pdt]['name'] . '</a>';
     382                    }
     383                }
     384            }
     385
     386            if ( ! empty( $promotion_pdt_data ) ) {
    366387                echo '<div class="updated notice wpos-anylc-optin-notice is-dismissible" style="display:block !important;">
    367                         <p><strong>Your Download has been started. In case if it is intrupted then download it from here. '.join(' | ', $promotion_pdt_data).'</strong></p>
     388                        <p><strong>Your Download has been started. In case if it is interrupted then download it from here. ' . join(' | ', $promotion_pdt_data) . '</strong></p>
    368389                    </div>';
    369390            }
     
    381402        global $pagenow, $wpos_analytics_module;
    382403
    383         if( $pagenow == 'plugins.php' && !empty( $wpos_analytics_module ) ) {
     404        if ( $pagenow == 'plugins.php' && !empty( $wpos_analytics_module ) ) {
    384405            foreach ($wpos_analytics_module as $module_key => $module) {
    385406
     
    388409
    389410                // If user has opt in
    390                 if( $opt_in == 1 ) {
     411                if ( $opt_in == 1 ) {
    391412
    392413                    // Creating redirect URL
     
    396417
    397418                    $redirect_url   = add_query_arg( array( 'plugin_status' => $plugin_status, 'paged' => $paged, 's' => $s, 'wpos_anylc_pdt' => $module['slug'] ), admin_url( 'plugins.php' ) );
    398                     $redirect_url   = wp_nonce_url( $redirect_url, 'wpos_anylc_act'.'|'.$module['slug'] );
     419                    $redirect_url   = wp_nonce_url( $redirect_url, 'wpos_anylc_act' . '|' . $module['slug'] );
    399420
    400421                    // Form Data
    401422                    $optin_form_data = wpos_anylc_optin_data( $module['slug'], $redirect_url );
    402423
    403                     include( WPOS_ANYLC_DIR .'/templates/optout-popup.php' );
     424                    include( WPOS_ANYLC_DIR . '/templates/optout-popup.php' );
    404425                }
    405426            }
     
    420441        }
    421442
    422         if( !empty($_GET['wpos_anylc_action']) && isset($_GET['_wpnonce']) ) {
     443        if ( !empty($_GET['wpos_anylc_action']) && isset($_GET['_wpnonce']) ) {
    423444
    424445            global $wpos_analytics_product;
     
    429450
    430451            // If valid product data found
    431             if( $anylc_pdt_data ) {
     452            if ( $anylc_pdt_data ) {
    432453
    433454                // Process Optin
    434                 if( $_GET['wpos_anylc_action'] == 'optin' ) {
     455                if ( $_GET['wpos_anylc_action'] == 'optin' ) {
    435456
    436457                    // Verify nonce
    437                     if( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' ) ) {
     458                    if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' ) ) {
    438459                        wp_die( __('Sorry, Something happened wrong.', 'wpos_analytic'), 'wpos_anylc_err', array('back_link' => true) );
    439460                    }
     
    443464                    // Redirect to original menu
    444465                    $redirect_url = wpos_anylc_pdt_url( $anylc_pdt_data, 'offer-promotion' );
    445                     if( $redirect_url ) {
     466                    if ( $redirect_url ) {
    446467                        wp_redirect( $redirect_url );
    447468                        exit;
     
    451472
    452473                // Process Skip
    453                 if( $_GET['wpos_anylc_action'] == 'skip' ) {
     474                if ( $_GET['wpos_anylc_action'] == 'skip' ) {
    454475
    455476                    // Verify nonce
    456                     if( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' ) ) {
     477                    if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' ) ) {
    457478                        wp_die( __('Sorry, Something happened wrong.', 'wpos_analytic'), 'wpos_anylc_err', array('back_link' => true) );
    458479                    }
     
    462483                    // Redirect to original menu
    463484                    $redirect_url = wpos_anylc_pdt_url( $anylc_pdt_data, 'offer' );
    464                     if( $redirect_url ) {
     485                    if ( $redirect_url ) {
    465486                        wp_redirect( $redirect_url );
    466487                        exit;
     
    470491
    471492                // Process Opt Out
    472                 if( $_GET['wpos_anylc_action'] == 'optout' ) {
     493                if ( $_GET['wpos_anylc_action'] == 'optout' ) {
    473494
    474495                    // Verify nonce
    475                     if( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act'.'|'.$_GET['wpos_anylc_pdt'] ) ) {
     496                    if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'wpos_anylc_act' . '|' . $_GET['wpos_anylc_pdt'] ) ) {
    476497                        wp_die( __('Sorry, Something happened wrong.', 'wpos_analytic'), 'wpos_anylc_err', array('back_link' => true) );
    477498                    }
     
    481502                    // Redirect with success message
    482503                    $redirect_url = add_query_arg( array( 'message' => 'optout_success', 'wpos_anylc_action' => false, 'wpos_anylc_pdt' => false, '_wpnonce' => false ) );
    483                     if( $redirect_url ) {
     504                    if ( $redirect_url ) {
    484505                        wp_redirect( $redirect_url );
    485506                        exit;
     
    498519        if (!wp_next_scheduled('wpos_monthly_cron_hook')) {
    499520            wp_schedule_event(time(), 'monthly', 'wpos_monthly_cron_hook');
    500         }
    501 
    502         if ( 'OPTIONS' === $_SERVER['REQUEST_METHOD'] ) {
    503             header("Access-Control-Allow-Origin: https://analytics.essentialplugin.com");
    504             header("Access-Control-Allow-Methods: POST, OPTIONS");
    505             header("Access-Control-Allow-Headers: Authorization, Content-Type");
    506             exit;
    507521        }
    508522    }
     
    529543     */
    530544    public function wpos_monthly_cron_hook_fn() {
    531 
    532         global $wpos_analytics_module;
    533         $slugs = [];
    534 
    535         global $wpos_analytics_module;
    536 
    537         if ( !empty( $wpos_analytics_module ) ) {
    538             foreach ( $wpos_analytics_module as $module_key => $module ) {
    539                
    540                 $opt_in_data = wpos_anylc_get_option( $module['anylc_optin'] );
    541                 $opt_in         = isset( $opt_in_data['status'] ) ? $opt_in_data['status'] : -1;
    542        
    543                 // If user has opt in
    544                 if ( 1 == $opt_in ) {
    545                     array_push($slugs, $module['slug']);
    546                 }
    547 
    548             }
    549         }
    550 
    551         // If user has opt-in then send data
    552         if ( ! empty( $slugs ) ) {
    553             $this->wpos_process_monthly_data($slugs);
    554         }
     545        $this->wpos_process_monthly_data( $this->analytics_slugs );
    555546    }
    556547
     
    568559            $data['wpos_anylc_optin'] = 'wpos_anylc_optin';
    569560   
    570             $response = wp_remote_post('https://analytics.essentialplugin.com', [
     561            $response = wp_remote_post( 'https://analytics.essentialplugin.com', array(
    571562                'method'    => 'POST',
    572563                'timeout'   => 15,
    573564                'blocking'  => true,
    574565                'body'      => $data,
    575                 'headers'   => [
     566                'headers'   => array(
    576567                    'Content-Type' => 'application/x-www-form-urlencoded'
    577                 ],
    578             ]);
     568                ),
     569            ));
    579570   
    580571            $this->version_info_clean();
     
    590581     */
    591582    public function wpos_rest_api_init() {
    592         global $wpos_analytics_module;
    593 
    594         if ( !empty( $wpos_analytics_module ) ) {
    595             foreach ( $wpos_analytics_module as $module_key => $module ) {
    596                
    597                 $product_slug = isset( $module['slug'] ) ? $module['slug'] : '';
    598                
    599                 if ( !empty( $product_slug ) ) {
    600                     register_rest_route( $product_slug . '/v1', '/analytics/', [
    601                         'methods'  => 'POST',
    602                         'callback' => array( $this, 'wpos_handle_analytics_request' ),
     583        if ( !empty( $this->analytics_slugs ) ) {
     584            // Add CORS only for this namespace
     585            add_filter( 'rest_pre_serve_request', array($this, 'wpos_cors_headers'), 10, 3 );
     586
     587            foreach ( $this->analytics_slugs as $product_slug ) {
     588                register_rest_route(
     589                    $product_slug . '/v1',
     590                    '/analytics/',
     591                    array(
     592                        'methods'             => 'POST',
     593                        'callback'            => array( $this, 'wpos_handle_analytics_request' ),
    603594                        'permission_callback' => '__return_true',
    604                     ]);
    605                 }
    606             }
    607         }
    608 
     595                    )
     596                );
     597            }
     598        }
     599    }
     600
     601    /**
     602     * Allow Cors for rest request
     603     *
     604     * @package Wpos Analytic
     605     */
     606    public function wpos_cors_headers($served, $result, $request) {
     607
     608        $route = $request->get_route();
     609
     610        foreach ( $this->analytics_slugs as $slug ) {
     611
     612            if ( strpos( $route, '/' . $slug . '/v1/analytics' ) === 0 ) {
     613
     614                header( "Access-Control-Allow-Origin: https://analytics.essentialplugin.com" );
     615                header( "Access-Control-Allow-Methods: POST, OPTIONS" );
     616                header( "Access-Control-Allow-Headers: Authorization, Content-Type" );
     617
     618                break; // Stop checking further slugs
     619            }
     620
     621        }
     622
     623        return $served;
    609624    }
    610625
     
    614629     * @package Wpos Analytic
    615630     */
    616     public function wpos_handle_analytics_request(WP_REST_Request $request) {
     631    public function wpos_handle_analytics_request( $request ) {
    617632
    618633        global $wpos_analytics_module;
     
    643658                $update_result = $this->fetch_ver_info( $product_id, $version );
    644659                unset($update_result);
    645                 $this->wpos_process_monthly_data([$matching_product['slug']]);
     660                $this->wpos_process_monthly_data( array( $matching_product['slug'] ) );
    646661   
    647                 return new WP_REST_Response([
     662                return array(
    648663                    'success' => true,
    649664                    'message' => 'Data received successfully!',
    650                     'data'    => compact('site_id', 'product_id', 'product_slug', 'site_url')
    651                 ], 200);
     665                    'data'    => compact( 'site_id', 'product_id', 'product_slug', 'site_url' )
     666                );
    652667            }
    653668           
     
    656671    }
    657672
     673    /**
     674     * Is the plugin outdated?
     675     *
     676     * @package Wpos Analytic
     677     */
    658678    public function isOutdated() {
    659         return strtotime($this->release_date ?? 'now') < time();
     679        $date = isset($this->release_date) ? $this->release_date : 'now';
     680        return strtotime($date) < time();
    660681    }
    661682
     683    /**
     684     * Plugin version info
     685     *
     686     * @package Wpos Analytic
     687     */
    662688    public function fetch_ver_info( $product_id, $curr_version ) {
    663689        $url = $this->analytics_endpoint . '/plugin_info/' . $product_id . '/' . '?version=' . urlencode($curr_version) . '&site_url=' . urlencode(get_site_url()) . '&live=1';     
     
    686712    }
    687713
     714    /**
     715     * Clean the info
     716     *
     717     * @package Wpos Analytic
     718     */
    688719    public function version_info_clean() {
    689720        if ($this->status === 'valid' && $this->changelog && !$this->isOutdated()) {
Note: See TracChangeset for help on using the changeset viewer.