Plugin Directory

Changeset 3205331


Ignore:
Timestamp:
12/10/2024 07:58:59 AM (16 months ago)
Author:
printapp
Message:

Switched from using Sessions to using Wordpress Transients for saving customization details.
Sessions are prone to conflicts with other plugins and systems.

Location:
printapp
Files:
2 added
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • printapp/tags/2.1.0/CHANGELOG.txt

    r3195438 r3205331  
     1= 2.1.0 =
     2Switched from using Sessions to using Wordpress Transients for saving customization details.
     3Sessions are prone to conflicts with other plugins and systems.
     4
    15== 2.0.3 =
    26Minor update to release.yml to copy functions folder
  • printapp/tags/2.1.0/README.md

    r3195438 r3205331  
    11# Print.App
    22
    3 ## Version 2.0.3 plugin
     3## Version 2.1.0 plugin
    44PrintApp is a platform that allows your customers to personalize their Print orders on any web store.
    55It provides customers, an easy to use WYSIWYG (What you see is what you get) "Do It Yourself" interface for creating artworks for Print.
  • printapp/tags/2.1.0/functions/front/carts.php

    r3195438 r3205331  
    33    namespace printapp\functions\front;
    44
     5    use printapp\functions\general as General;
     6
    57    function add_cart_item_data($cart_item_data, $product_id, $variation_id, $qty) {
    6         if (!session_id()) session_start();
    78   
    8         $session_key = PRINT_APP_SESSION_PREFIX . $product_id;
     9        $value = General\get_customization_data($product_id);
    910
    10         if (isset($_SESSION[$session_key])) {
    11             $cart_item_data[PRINT_APP_CUSTOMIZATION_KEY] = $_SESSION[$session_key];
    12             unset($_SESSION[$session_key]);
     11        if (isset($value) && $value !== FALSE) {
     12            $cart_item_data[PRINT_APP_CUSTOMIZATION_KEY] = $value;
     13            General\delete_customization_data($product_id);
    1314        }
    1415
  • printapp/tags/2.1.0/functions/front/customize_button.php

    r3195438 r3205331  
    22
    33    namespace printapp\functions\front;
     4
     5    use printapp\functions\general as General;
    46
    57    function customize_button() {
     
    1618        $user_data = get_user_data();
    1719
    18         if (!session_id()) session_start();
    19 
    2020        // get project data
    21         if (session_id()) {
    22             $session_key = PRINT_APP_SESSION_PREFIX . $post->ID;
    23             if (isset($_SESSION[$session_key])) $project_data = $_SESSION[$session_key];
    24         }
     21        $project_data = General\get_customization_data($post->ID);
    2522
    2623        // initialize the data to pass to print_app_class
     
    3027        $pa_user_id     = (get_current_user_id() === 0) ? 'guest' : get_current_user_id();
    3128
    32         if (isset($project_data)) {
     29        if (isset($project_data) && $project_data !== FALSE) {
    3330            $pa_project_id = $project_data['projectId'];
    3431            $pa_mode        = isset($project_data['mode']) ? $project_data['mode'] : 'edit-project';
     
    5552
    5653    function get_user_data() {
    57         if (!is_user_logged_in()) return 'null';
     54        if (!is_user_logged_in()) return '';
    5855
    5956        $customer = WC()->customer;
  • printapp/tags/2.1.0/functions/front/projects.php

    r3195438 r3205331  
    22
    33    namespace printapp\functions\front;
     4
     5    use printapp\functions\general as General;
    46
    57    function save_project_sess() {
     
    1214            wp_send_json_error('No product ID provided');
    1315        }
    14 
    15         if (!session_id()) {
    16             session_start();
    17             if (!session_id()) wp_send_json_error('Failed to start session.');
    18         }
    1916       
    2017        $value = json_decode(stripslashes(html_entity_decode($_POST['value'])), true);
    2118        if (json_last_error() !== JSON_ERROR_NONE) wp_send_json_error(json_last_error());
    2219
    23         $product_id = intval($_POST['product_id']);
    24         $session_key = PRINT_APP_SESSION_PREFIX . $product_id;
     20        $product_id = $_POST['product_id'];
     21        $result = General\save_customization_data($product_id, $value);
     22        if ($result !== FALSE)
     23            return wp_send_json_success('customization data saved successfully: ' . $result);
    2524
    26         $_SESSION[$session_key] = $value;
    27         wp_send_json_success('Customization data saved successfully');
    28        
     25        wp_send_json_error('Failed to save customization data');
    2926    }
    3027
     
    3431        }
    3532   
    36         if (!session_id()) {
    37             session_start();
    38             if (!session_id()) wp_send_json_error('Failed to start session');
    39         }
     33        $product_id = $_POST['product_id'];
    4034   
    41         // Sanitize product_id
    42         $product_id = intval($_POST['product_id']);
    43         $session_key = PRINT_APP_SESSION_PREFIX . $product_id;
    44    
    45         // Check if session key exists and unset it
    46         if (isset($_SESSION[$session_key])) {
    47             unset($_SESSION[$session_key]);
    48             wp_send_json_success('Customization data cleared successfully.');
    49         } else {
    50             wp_send_json_error('No customization data found for this product');
    51         }
     35        General\delete_customization_data($product_id);
     36        wp_send_json_success('Customization data cleared successfully.');
     37       
    5238    }
  • printapp/tags/2.1.0/printapp.php

    r3195438 r3205331  
    44 *  Plugin URI:         https://print.app
    55 *  Description:        Empower your customers to personalize products like Business Cards, Photo Prints, T-Shirts, Mugs, Banners, Canvases, etc. on your store before purchase
    6  *  Version:            2.0.3
     6 *  Version:            2.1.0
    77 *  Requires at least:  3.8
    88 *  Requires PHP:       5.2.4
     
    4646             *  @var string
    4747            */
    48             public $version = '2.0.3';
     48            public $version = '2.1.0';
    4949
    5050            /**
     
    114114                define('PRINT_APP_RUN_BASE_URL', 'https://run.print.app/');
    115115                define('PRINT_APP_DESIGN_SELECT_JS', plugin_dir_url( __FILE__ ) . 'js/design-select.js');
    116                 define('PRINT_APP_SESSION_PREFIX', 'print_app_sess_');
    117116                define('PRINT_APP_CUSTOMIZATION_KEY', 'print_app_customization');
    118117                define('PRINT_APP_CUSTOMIZATION_PREVIEWS_KEY', 'preview');
     118                define('PRINT_APP_CUSTOMIZATION_DURATION', MONTH_IN_SECONDS);
    119119            }
    120120           
  • printapp/tags/2.1.0/readme.txt

    r3195438 r3205331  
    44Requires at least: 3.8
    55Tested up to: 6.6
    6 Stable tag: 2.0.3
     6Stable tag: 2.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    102102== Changelog ==
    103103
     104= 2.1.0 =
     105Switched from using Sessions to using Wordpress Transients for saving customization details.
     106Sessions are prone to conflicts with other plugins and systems.
     107
    104108= 2.0.3 =
    105109Minor update to release.yml to copy functions folder
  • printapp/trunk/CHANGELOG.txt

    r3195438 r3205331  
     1= 2.1.0 =
     2Switched from using Sessions to using Wordpress Transients for saving customization details.
     3Sessions are prone to conflicts with other plugins and systems.
     4
    15== 2.0.3 =
    26Minor update to release.yml to copy functions folder
  • printapp/trunk/README.md

    r3195438 r3205331  
    11# Print.App
    22
    3 ## Version 2.0.3 plugin
     3## Version 2.1.0 plugin
    44PrintApp is a platform that allows your customers to personalize their Print orders on any web store.
    55It provides customers, an easy to use WYSIWYG (What you see is what you get) "Do It Yourself" interface for creating artworks for Print.
  • printapp/trunk/functions/front/carts.php

    r3195438 r3205331  
    33    namespace printapp\functions\front;
    44
     5    use printapp\functions\general as General;
     6
    57    function add_cart_item_data($cart_item_data, $product_id, $variation_id, $qty) {
    6         if (!session_id()) session_start();
    78   
    8         $session_key = PRINT_APP_SESSION_PREFIX . $product_id;
     9        $value = General\get_customization_data($product_id);
    910
    10         if (isset($_SESSION[$session_key])) {
    11             $cart_item_data[PRINT_APP_CUSTOMIZATION_KEY] = $_SESSION[$session_key];
    12             unset($_SESSION[$session_key]);
     11        if (isset($value) && $value !== FALSE) {
     12            $cart_item_data[PRINT_APP_CUSTOMIZATION_KEY] = $value;
     13            General\delete_customization_data($product_id);
    1314        }
    1415
  • printapp/trunk/functions/front/customize_button.php

    r3195438 r3205331  
    22
    33    namespace printapp\functions\front;
     4
     5    use printapp\functions\general as General;
    46
    57    function customize_button() {
     
    1618        $user_data = get_user_data();
    1719
    18         if (!session_id()) session_start();
    19 
    2020        // get project data
    21         if (session_id()) {
    22             $session_key = PRINT_APP_SESSION_PREFIX . $post->ID;
    23             if (isset($_SESSION[$session_key])) $project_data = $_SESSION[$session_key];
    24         }
     21        $project_data = General\get_customization_data($post->ID);
    2522
    2623        // initialize the data to pass to print_app_class
     
    3027        $pa_user_id     = (get_current_user_id() === 0) ? 'guest' : get_current_user_id();
    3128
    32         if (isset($project_data)) {
     29        if (isset($project_data) && $project_data !== FALSE) {
    3330            $pa_project_id = $project_data['projectId'];
    3431            $pa_mode        = isset($project_data['mode']) ? $project_data['mode'] : 'edit-project';
     
    5552
    5653    function get_user_data() {
    57         if (!is_user_logged_in()) return 'null';
     54        if (!is_user_logged_in()) return '';
    5855
    5956        $customer = WC()->customer;
  • printapp/trunk/functions/front/projects.php

    r3195438 r3205331  
    22
    33    namespace printapp\functions\front;
     4
     5    use printapp\functions\general as General;
    46
    57    function save_project_sess() {
     
    1214            wp_send_json_error('No product ID provided');
    1315        }
    14 
    15         if (!session_id()) {
    16             session_start();
    17             if (!session_id()) wp_send_json_error('Failed to start session.');
    18         }
    1916       
    2017        $value = json_decode(stripslashes(html_entity_decode($_POST['value'])), true);
    2118        if (json_last_error() !== JSON_ERROR_NONE) wp_send_json_error(json_last_error());
    2219
    23         $product_id = intval($_POST['product_id']);
    24         $session_key = PRINT_APP_SESSION_PREFIX . $product_id;
     20        $product_id = $_POST['product_id'];
     21        $result = General\save_customization_data($product_id, $value);
     22        if ($result !== FALSE)
     23            return wp_send_json_success('customization data saved successfully: ' . $result);
    2524
    26         $_SESSION[$session_key] = $value;
    27         wp_send_json_success('Customization data saved successfully');
    28        
     25        wp_send_json_error('Failed to save customization data');
    2926    }
    3027
     
    3431        }
    3532   
    36         if (!session_id()) {
    37             session_start();
    38             if (!session_id()) wp_send_json_error('Failed to start session');
    39         }
     33        $product_id = $_POST['product_id'];
    4034   
    41         // Sanitize product_id
    42         $product_id = intval($_POST['product_id']);
    43         $session_key = PRINT_APP_SESSION_PREFIX . $product_id;
    44    
    45         // Check if session key exists and unset it
    46         if (isset($_SESSION[$session_key])) {
    47             unset($_SESSION[$session_key]);
    48             wp_send_json_success('Customization data cleared successfully.');
    49         } else {
    50             wp_send_json_error('No customization data found for this product');
    51         }
     35        General\delete_customization_data($product_id);
     36        wp_send_json_success('Customization data cleared successfully.');
     37       
    5238    }
  • printapp/trunk/printapp.php

    r3195438 r3205331  
    44 *  Plugin URI:         https://print.app
    55 *  Description:        Empower your customers to personalize products like Business Cards, Photo Prints, T-Shirts, Mugs, Banners, Canvases, etc. on your store before purchase
    6  *  Version:            2.0.3
     6 *  Version:            2.1.0
    77 *  Requires at least:  3.8
    88 *  Requires PHP:       5.2.4
     
    4646             *  @var string
    4747            */
    48             public $version = '2.0.3';
     48            public $version = '2.1.0';
    4949
    5050            /**
     
    114114                define('PRINT_APP_RUN_BASE_URL', 'https://run.print.app/');
    115115                define('PRINT_APP_DESIGN_SELECT_JS', plugin_dir_url( __FILE__ ) . 'js/design-select.js');
    116                 define('PRINT_APP_SESSION_PREFIX', 'print_app_sess_');
    117116                define('PRINT_APP_CUSTOMIZATION_KEY', 'print_app_customization');
    118117                define('PRINT_APP_CUSTOMIZATION_PREVIEWS_KEY', 'preview');
     118                define('PRINT_APP_CUSTOMIZATION_DURATION', MONTH_IN_SECONDS);
    119119            }
    120120           
  • printapp/trunk/readme.txt

    r3195438 r3205331  
    44Requires at least: 3.8
    55Tested up to: 6.6
    6 Stable tag: 2.0.3
     6Stable tag: 2.1.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    102102== Changelog ==
    103103
     104= 2.1.0 =
     105Switched from using Sessions to using Wordpress Transients for saving customization details.
     106Sessions are prone to conflicts with other plugins and systems.
     107
    104108= 2.0.3 =
    105109Minor update to release.yml to copy functions folder
Note: See TracChangeset for help on using the changeset viewer.