Support » Plugin: WooCommerce Gift Coupon » Improvement suggestion

  • Hi,

    thanks for this very helpful plugin! I experienced a problem today, which is easily solvable and I suggest to add a small fix to the plugin, which should also improve the plugin security a bit.

    My problem was as follows: The uploaded logo image was not shown on the gift card pdf. This was because I have allow_url_fopen disabled in php for security reasons. However, it is not necessary to enable allow_url_fopen in order to fix this. A small code adjustment does the trick:

    In gs-middle-options-page.php, change line 35 from
    update_option( 'woocommerce_gift_coupon_logo', $file['url'] );'
    to
    update_option( 'woocommerce_gift_coupon_logo', $file['file'] );
    I see no reason, why the image should be accessed by url when the script is executed on the same server and can be accessed by specifying the path to the image as above.

    Of course, this breaks the logo preview in the admin panel, but this can also be solved easily. Change line 68 from
    $woocommerce_gift_coupon_logo = get_option( 'woocommerce_gift_coupon_logo' );
    to

    $woocommerce_gift_coupon_logo_dir = get_option( 'woocommerce_gift_coupon_logo' );
    $woocommerce_gift_coupon_logo = wp_upload_dir()['url'] . substr($woocommerce_gift_coupon_logo_dir, strrpos($woocommerce_gift_coupon_logo_dir,'/'));

    That’s all and it doesn’t force the server to enable allow_url_fopen.

    Another question: Why is it not possible to select an image from the media library. That would be a quick thing too and would prevent uploading the logo for a second time. Additionally, the logo could be managed from the media library as any other image. Technically not necessary, but would be nicer, I think.

    Thanks for your work on this plugin, again!

  • The topic ‘Improvement suggestion’ is closed to new replies.