GithubHelp home page GithubHelp logo

gravitypdf / gravity-pdf Goto Github PK

View Code? Open in Web Editor NEW
88.0 9.0 21.0 36.44 MB

Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using Gravity Forms.

Home Page: https://gravitypdf.com

PHP 69.42% JavaScript 28.28% Shell 0.41% SCSS 1.89%
wordpress-plugin gravity-forms php pdf-generation

gravity-pdf's Introduction

Gravity PDF

codecov

Gravity PDF is a GPLv2-licensed WordPress plugin that allows you to automatically generate, email and download PDF documents using the popular form-builder plugin, Gravity Forms (affiliate link). Find out more about Gravity PDF at https://gravitypdf.com.

About

This Git repository is for developers who want to contribute to Gravity PDF. Don't use it in production. For production use, download Gravity PDF from the WordPress Plugin Directory.

The development branch is considered our bleeding edge branch, with all new changes pushed to it. The master branch is our latest stable version of Gravity PDF.

Installation

Prerequisites

Setup for Docker

The Docker setup will create a fully functional development environment preconfigured for Gravity PDF.

  1. Clone the repository using git clone https://github.com/GravityPDF/gravity-pdf/ from the terminal
  2. Copy and rename .env.example to .env, then replace 00000000000000000000000000000000 with a valid Gravity Forms license key
  3. Run yarn && yarn build:production
  4. Start Docker and then run yarn env:install to setup the local development environment
  5. Access a local development site at http://localhost:8888 with the login admin and password.

If you shut down Docker and want to fire up the environment later, use yarn wp-env start. You can reset the database back to its original state with yarn wp-env clean all. When all else fails, delete everything and start again with yarn wp-env destroy.

See the WordPress Developer Handbook for more details about managing the docker environment.

Enable X-Debug

X-Debug is enabled by default for step debugging and profiling. If you need to use other X-Debug modes you can manually start the environment and pass the appropriate modes in: yarn wp-env start --xdebug=profile,trace,debug.

Switch PHP Versions

The default version that will be configured is PHP8.0. If you want to change this you can adjust the phpVersion value in the .wp-env.json file and then stop and start the environment with yarn wp-env start.

Setup without Docker

If you would rather use your own development environment, you can build Gravity PDF using the following commands.

  1. Clone the repository using git clone https://github.com/GravityPDF/gravity-pdf/
  2. Run yarn && yarn build:production
  3. Run composer install
  4. Run composer run prefix

Building JavaScript

If you are making changes to any of the JavaScript or CSS, run yarn build:dev to ensure the files automatically gets built when you make changes on the file system.

Linting

To lint your JS code use yarn lint:js, and to try automatically fix it use yarn lint:js:fix.

To lint your PHP code, use composer lint, and to try automatically fix it use composer lint:fix.

Automated Tests

The automated test suite can only be run using Docker.

E2E

Useful commands include:

yarn test:e2e
yarn test:e2e:headless

PHPUnit

Run full suite of tests using yarn test:php or yarn test:php:multisite.

JavaScript

The JavaScript unit tests can be run with yarn test:js

Documentation

All documentation can be found at https://docs.gravitypdf.com.

gravity-pdf's People

Contributors

debbieellis7 avatar jacobdb avatar jakejackson1 avatar jestonihpi avatar jestonisumande avatar salustinogonzalesjr avatar tfrommen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

gravity-pdf's Issues

Custom Fonts not saving permanently

There are reports that custom fonts aren't saving permanently. They just seem to disappear for an unknown reason.

Will need to research the hows and whys of this issue and attempt to replicate it before creating a patch.

Custom Paper Size Bug

Ensure only positive numbers are permitted in the width and height fields, otherwise throw validation error.

[Request] Filter for using site name in directory structure

As of version 3.6.0, for a specific site of a multi-site installation, the PDF templates reside in /%uploads%/PDF_EXTENDED_TEMPLATES/%site_name%/.
It would be great to be able to disable this easily, and make the templates live in /%uploads%/PDF_EXTENDED_TEMPLATES/ (just like it was before, inside the theme).

A real-life scenario where this filter is needed:
Suppose you are working together with a number of developers on a project using some sort of version control. Each developer is having an individual local testing environment. Then there is a testing and a productive server. As the site name is part of the directory structure (by default), sooner or later, the project repository will have multiple (redundant) entries, like so:

  • /%uploads%/PDF_EXTENDED_TEMPLATES/localhost_project_x/*
  • /%uploads%/PDF_EXTENDED_TEMPLATES/project_x_dev/*
  • /%uploads%/PDF_EXTENDED_TEMPLATES/project_x_testsystem_com/*
  • /%uploads%/PDF_EXTENDED_TEMPLATES/project_x_com/*

In all of these folders, you find the same templates.

If one were able to exclude the site name (meaning that all sites use the exact same templates), there would only be a single folder /%uploads%/PDF_EXTENDED_TEMPLATES/ containing these files.

I will commit a simple fix (as well as the according pull request) containing a filter gfpdf_use_site_name_in_directory_structure to decide if one would like to use the site names or not. By default, I will leave the functionality as it is now. And not using the site names in the directory structure is as simple as this:

add_filter( 'gfpdf_use_site_name_in_directory_structure', '__return_false' );

PDF not displayed when security enabled

PDF not showing when security enabled. I have enabled security to Yes & chose password from a field value. It does not showing the PDF file.

We've had the above report. Will need to investigate further.

Nginx Security

The .htaccess option only works with Apache-compatible web servers. Look at how one would protect the same directory when running alternate web servers like Nginx.

View & Download PDF always regenerates PDF

The part of pdf-render.php at the bottom of this message isn't working properly, resulting in unnecessary regeneration of already existing PDF files (located in the output folder).

$pdf_creator is always empty, because it never gets defined after it's created on line 44.
Therefore the conditions of the IF-statement never return true, so PDFs are always being regenerated despite the fact that the file might already be present in the output folder.

I forced the IF-statement to return true, but the returned value still doesn't load the existing PDF in the opening browser tab.

Any solution to this would be greatly appreciated.

        /* 
         * Check if the PDF exists and if this function has already run this season 
         */ 
        if(in_array($lead_id, $pdf_creator) && file_exists($gfpdfe_data->template_save_location . $id . '/' . $filename))
        {                   
            /* 
             * Don't generate a new PDF, use the existing one 
             */

            return $gfpdfe_data->template_save_location . $id . '/' . $filename;    
        }

Add @version support to PDF templates

In the future we'll look at notifying users of a version conflict between the core PDF and their copy in PDF_EXTENDED_TEMPLATES. The first step to supporting this is adding version numbers to all new 4.0 PDFs.

Legacy Config should check "conditional logic"

Currently we're only checking if the matched PDF setting is active. To bring this inline with the 4.0 endpoint, the legacy endpoint should also check if there is any conditional logic active.

Add PHP7 Support

PHP 7 had some issues when run through Travis. Load up a Vagrant box with PHP7 and test and fix all PHP7-related problems.

Allow individual PDF configurations to control owner security

At the moment users have global control over whether entry owner's can access the generated PDF documents. But this is an across the board setting and doesn't give control on a per-PDF basis.

I propose adding the ability for users to control if owners can access a PDF on the document level.

Default Shortcode in Notification Doesn't Work

If you copy and paste the shortcode markup to a notification ([gravitypdf id="56134195eaf75" text="Download PDF"]) you get the following error:

No Gravity Form entry ID passed to Gravity PDF. Ensure you pass the entry ID via the confirmation url query string โ€“ using either "entry" or "lid" as the query string name โ€“ or by passing an ID directly to the shortcode. (Admin Only Message)

However, if you pass in the entry parameter it does work.

[gravitypdf id="56134195eaf75" text="Download PDF" entry="{entry_id}"]

This extra step is cumbersome. Look at auto assigning the entry like we do in the confirmation section.

Tweak PDF Download Link Copy on Entry List page

When a PDF is set up the Gravity Forms entry list page for that form will show the text link "View PDF".

The same text shows up when the global setting "Entry View" is set to Download.

It would be good to have the text "View PDF" changed to "Download PDF" when the above is selected.

Consider changing list field htmlspecialchars to strip_tags to cater for a href links

I'm developing a plugin for Gravity Forms that converts URL's entered into the the 'list field' to clickable links in the back end.

I'm doing this by storing the values in the database as an HTML link.

For example, if the user enters

www.google.com

The plugin will store the value in the database as:

<a href="www.google.com">www.google.com</a>

I need to display the link as a clickable link in the PDF created by this plugin. However I found that pdf-entry-detail.php at line 2002 escapes the HTML before it's put in the PDF. So the code pulled into mPDF is turned into:

&lt;a href="www.google.com"&gt;www.google.com&lt;/a&gt;

I agree that the HTML needs to be escaped to stop users breaking the PDF by entering in table tags like or - but I would like to ask if you could consider changing this to allow links.

The change would be - pdf-entry-detail.php - line 2002

FROM

$list .= '<td>'.htmlspecialchars($val).'</td>';

TO

$list .= '<td>'.strip_tags($val,'<a>').'</td>';

Please let me know if this is a possibility, otherwise I will need to consider my options (other ways of creating PDF's, customising the plugin after each update/providing instructions on how to modify the plugin).

Thanks,

Enable Public Access

Sometimes site owners want to enable public access to a specific PDF configuration for a given form. Currently this feature exists but is hidden - unless a filter is used to manually enable it.

I propose to make the option to enabled public access shown by default in the advanced tab of the PDF configuration. It would need to have appropriate copy to highlight just how open users would be if they enabled this option (anyone globally could potentially access the PDF document).

I feel the benefit out ways the potential risk of mis-configuration.

Convert PDF Template Doctype to HTML5

Replace <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> doctype with <!DOCTYPE html>.

"Failed Write Permissions Check" in Loggly Logs

Loggly logs are showing the following across a number of sites:

function: create_folder_structures
file: /var/www/html/recruit/wp-content/plugins/gravity-forms-pdf-extended/src/model/Model_Install.php
line: 236
class: GFPDF\Model\Model_Install

dir: /var/www/html/wp-content/uploads/PDF_EXTENDED_TEMPLATES/fonts/

message: Failed Write Permissions Check.
level_name: ERROR

Investigate if this is a problem or not.

Add Captain Paws to Action Messages

I like the way Ninja Forms includes their logo in their notice prompts. Toy around with the idea of including our new mascot in the actions notice UI.

WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT conflict

PDFs are rendered on the front end so when we display the memory_limit setting in the backend we need to get the front-end memory limit and not the backend limit.

WordPress attempts to set a 256MB memory limit while in the backend which could throw off the actual memory limit when generating PDFs.

Fatal Error When cURL not installed

Gravity PDF 4.0-Beta:

Fatal error: Uncaught exception 'LogicException' with message 'The curl extension is needed to use the LogglyHandler' in /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php:37 Stack trace: #0 /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/src/bootstrap.php(285): Monolog\Handler\LogglyHandler->__construct('8ad317ed-213d-4...', 200) #1 /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/src/bootstrap.php(227): GFPDF\Router->maybe_run_remote_logging() #2 /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/src/bootstrap.php(129): GFPDF\Router->setup_logger() #3 /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/src/depreciated.php(81): GFPDF\Router->init() #4 /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/src/bootstrap.php(710): GFPDF_Core->__construct() #5 /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/pdf.php(152): require_once('/var/www/recrui...') #6 [internal function]: GFPDF_ in /var/www/mysite/wp-content/plugins/gravity-forms-pdf-extended/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php on line 37

Include PDF Name in Shortcode Sample

It's hard to tell which PDF shortcode is being displayed on a confirmation / notification page. Let's add a faux attribute "name" (which doesn't effect the shortcode in any way) so users can more easily distinguish which PDF the shortcode refers too.

Deleting PDF from List shows blank

When you delete the last PDF from the PDF list it shows an empty table. This should show the "No PDFs here...create one." message instead.

Speed up unit tests

At the moment the unit tests take a long time to run due to all the Gravity Forms database calls. In the future I would like to optimise this dramatically so the tests can be run much faster.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.