Plugin Directory

Changeset 3102915


Ignore:
Timestamp:
06/14/2024 08:09:00 PM (22 months ago)
Author:
roberthoward
Message:

Add support for redirect url

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dailystory/trunk/includes/class-dailystory-shortcodes.php

    r3067059 r3102915  
    1919            // Add the [ds-popup] shortcode
    2020            add_shortcode('ds-popup', array( 'DailyStoryShortCodes', 'dailystory_popup_shortcode' ));
    21             // Add the [ds-test] shortcode
    22             add_shortcode('ds-test', array( 'DailyStoryShortCodes', 'dailystory_webform_test' ));
    23            
    2421        }
    2522    }
     
    9895 
    9996        // override default attributes with user attributes
    100         $webform_id = shortcode_atts(['id' => '0',], $atts, $tag);
    101         $webform_id = esc_html__($webform_id['id'], 'ds-webform') ;
     97        $atts = shortcode_atts(['id' => '0', 'redirect_url' => ''], $atts);
     98        $webform_id = esc_html__($atts['id'], 'ds-webform');
     99        $redirect_url = esc_url_raw($atts['redirect_url']);
     100
    102101        // Add the script reference, pulled from DailyStory, but eventually will be served from a CDN
    103102        wp_register_script('ds-landingpages', 'https://pages.dailystory.com/bundles/dailystory-landingpage', null,'2.0.6', true);
    104103        wp_enqueue_script('ds-landingpages');
     104
    105105        // enqueue css
    106106        wp_enqueue_style('ds-webform','https://forms.dailystory.com/content/hosted-webform-min', null, '2.0.6', 'all');
    107         // get the tenant uid
     107
     108            // get the tenant uid
    108109        $options = get_option('dailystory_settings');
    109110        $tenantuid = $options['dailystory_tenant_uid'];
     111
     112        // Build the URL with query string
     113        $url = 'https://forms.dailystory.com/webform/' . $tenantuid . '/' . $webform_id;
     114        if (!empty($redirect_url)) {
     115            $url = add_query_arg('redirectUrl', $redirect_url, $url);
     116        }
     117
    110118        // get the contents
    111         list($cc_result, $cc_error) = self::get_data('https://forms.dailystory.com/webform/' . $tenantuid . '/' . $webform_id);
     119        list($cc_result, $cc_error) = self::get_data($url);
     120
    112121        return $cc_result;
    113     }   
    114    
     122    }
    115123}
    116124?>
Note: See TracChangeset for help on using the changeset viewer.