Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,9 @@ public function notice_body_content() {
* @since 6.12
* @deprecated
*/
public function maybe_display_canonical_plugin_notice() {}
public function maybe_display_canonical_plugin_notice() {
_deprecated_function( __METHOD__, '6.12' );
}

/**
* Notify administrator they are not using the canonical version of Gravity PDF
Expand All @@ -510,7 +512,9 @@ public function maybe_display_canonical_plugin_notice() {}
* @since 6.12
* @deprecated
*/
public function maybe_display_canonical_plugin_notice_below_plugin( $plugin_file, $plugin_data ) {}
public function maybe_display_canonical_plugin_notice_below_plugin( $plugin_file, $plugin_data ) {
_deprecated_function( __METHOD__, '6.12' );
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/Controller/Controller_Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public function add_actions() {
* condition: The function or method to call to determine if a notice should be displayed (Boolean)
* process: The function to handle a successful action. On success the disable_route() method should be called
* view: The function used to display the notice content
* view_class: Optional classes for the notice box, including a `notice-*` state like `notice-warning`
*
* @return array
*
Expand Down Expand Up @@ -158,6 +159,11 @@ public function route_notices() {
return null;
}

/* Don't run the route conditions, which query the database, on pages that discard the notice anyway */
if ( ! $this->notices->can_display_notice_on_this_page() ) {
return null;
}

foreach ( $this->get_routes() as $route ) {

/* Before displaying check the user has the correct capabilities, the notice isn't already been dismissed and the route condition has been met */
Expand All @@ -173,8 +179,10 @@ public function route_notices() {
]
);

$class = ( isset( $route['view_class'] ) ) ? $route['view_class'] : '';
$this->notices->add_notice( call_user_func( $route['view'], $route['action'], $route['action_text'] ), $class );
$this->notices->add_notice(
call_user_func( $route['view'], $route['action'], $route['action_text'] ),
$route['view_class'] ?? ''
);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Controller_Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,6 @@ public function check_install_status() {
* @deprecated 6.0
*/
public function maybe_uninstall() {
_doing_it_wrong( __METHOD__, 'This method has been moved to Controller_Uninstall::uninstall_addon()', '6.0' );
_deprecated_function( __METHOD__, '6.0', 'Controller_Uninstall::uninstall_addon()' );
}
}
12 changes: 8 additions & 4 deletions src/Controller/Controller_PDF.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use GFPDF\Helper\Helper_PDF;
use GFPDF\Model\Model_PDF;
use GFPDF\Statics\Debug;
use GFPDF\Statics\Deprecation;
use GFPDF\View\View_PDF;
use GFPDF_Vendor\Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -204,7 +205,7 @@ public function add_filters() {
add_filter( 'gfpdf_pdf_html_output', $add_view_html_debugger, 9999, 5 );

/* Backwards compatibility for our Tier 2 plugin */
add_filter( 'gfpdfe_pre_load_template', [ 'PDFRender', 'prepare_ids' ], 1, 8 );
add_filter( 'gfpdfe_pre_load_template', Deprecation::INTERNAL_FILTER_CALLBACK, 1, 8 );

/* Pre-process our template arguments and automatically render them in PDF */
add_filter( 'gfpdf_template_args', [ $this->model, 'preprocess_template_arguments' ] );
Expand Down Expand Up @@ -292,7 +293,7 @@ public function process_legacy_pdf_endpoint() {
return null;
}

_doing_it_wrong( __METHOD__, 'Legacy PDF URLs are deprecated. Replace with the [gravitypdf] shortcode or PDF merge tags. See https://docs.gravitypdf.com/v6/users/shortcodes-and-mergetags for usage instructions.', '4.0' );
_deprecated_function( __METHOD__, '4.0', 'the [gravitypdf] shortcode or PDF merge tags, https://docs.gravitypdf.com/v6/users/shortcodes-and-mergetags' );

$config = [
'lid' => (int) explode( ',', $_GET['lid'] )[0],
Expand All @@ -310,6 +311,9 @@ public function process_legacy_pdf_endpoint() {
$this->pdf_error( $pid );
}

/* Record the hit so it can be surfaced in the System Report ahead of the 7.0 removal */
Deprecation::record_legacy_endpoint_usage( $config['fid'] );

/* Store our ids in the WP query_vars object */
$GLOBALS['wp']->query_vars['gpdf'] = 1;
$GLOBALS['wp']->query_vars['pid'] = $pid;
Expand All @@ -323,7 +327,7 @@ public function process_legacy_pdf_endpoint() {
]
);

$this->log->warning( 'Legacy PDF URLs are deprecated. Replace with the [gravitypdf] shortcode or PDF merge tags. See https://docs.gravitypdf.com/v6/users/shortcodes-and-mergetags for usage instructions.' );
$this->log->warning( sprintf( 'Legacy PDF URLs are removed in Gravity PDF %s. Replace with the [gravitypdf] shortcode or PDF merge tags. See https://docs.gravitypdf.com/v6/users/shortcodes-and-mergetags for usage instructions.', Deprecation::REMOVED_IN ) );

/* Send to our model to handle validation / authentication */
do_action( 'gfpdf_legacy_pre_view_or_download_pdf', $config['lid'], $pid, $config['action'] );
Expand Down Expand Up @@ -399,7 +403,7 @@ protected function add_pre_view_or_download_pdf_hooks( $form, $entry, $settings
* @deprecated 6.12 All buffers are auto-closed before a PDF is sent to the browser
*/
public function sgoptimizer_html_minification_fix() {
_doing_it_wrong( __METHOD__, 'This method has been removed and no alternative is available.', '6.12' );
_deprecated_function( __METHOD__, '6.12' );
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/Controller_Pdf_Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function queue_async_form_submission_tasks( $entry, $form ) {
*/
public function queue_dispatch_resend_notification_tasks( $form = null, $entry = null ) {
if ( ! is_null( $entry ) ) {
_doing_it_wrong( __METHOD__, '$entry argument ignored and now set in self::should_send_async_notification()', '6.13.5' );
_deprecated_argument( __METHOD__, '6.13.5', 'The $entry argument is ignored and now set in self::should_send_async_notification()' );
}

/* loop over all form/entries */
Expand Down Expand Up @@ -305,7 +305,7 @@ public function queue_async_tasks( $form, $entry ) {
* @deprecated 6.12.0 Caching layer + auto-purge added
*/
public function queue_cleanup_task( $form, $entry ) {
_doing_it_wrong( __METHOD__, 'This method is deprecated and no alternative is available. The temporary cache is automatically cleaned every hour using the WP Cron.', '6.12' );
_deprecated_function( __METHOD__, '6.12' );
}

/**
Expand Down Expand Up @@ -516,6 +516,6 @@ public function reset_queue() {
* @deprecated 6.11
*/
public function queue_async_resend_notification_tasks( $notification, $form, $entry ) {
_doing_it_wrong( esc_html( 'queue_async_resend_notification_tasks() was removed in Gravity PDF 6.11' ) );
_deprecated_function( __METHOD__, '6.11' );
}
}
71 changes: 70 additions & 1 deletion src/Controller/Controller_System_Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace GFPDF\Controller;

use GFPDF\Helper\Helper_Abstract_Controller;
use GFPDF\Helper\Helper_Abstract_Form;
use GFPDF\Helper\Helper_Abstract_Model;
use GFPDF\Helper\Helper_Abstract_View;
use GFPDF\Model\Model_System_Report;
Expand Down Expand Up @@ -38,12 +39,23 @@ class Controller_System_Report extends Helper_Abstract_Controller {
*/
public $view;

public function __construct( Helper_Abstract_Model $model, Helper_Abstract_View $view ) {
/**
* Holds the abstracted Gravity Forms API specific to Gravity PDF
*
* @var Helper_Abstract_Form
*
* @since 6.17.0
*/
protected $gform;

public function __construct( Helper_Abstract_Model $model, Helper_Abstract_View $view, Helper_Abstract_Form $gform ) {
$this->model = $model;
$this->model->setController( $this );

$this->view = $view;
$this->view->setController( $this );

$this->gform = $gform;
}

/**
Expand All @@ -62,6 +74,63 @@ public function init() {
*/
public function add_filters() {
add_filter( 'gform_system_report', [ $this, 'system_report' ] );
add_filter( 'site_status_tests', [ $this, 'site_status_tests' ] );
add_filter( 'debug_information', [ $this, 'debug_information' ] );
}

/**
* Register a Site Health test for any deprecated functionality in use on this site
*
* The admin notice can be dismissed for good, and the Gravity Forms system report has to be sought out. This
* puts the same detections where WordPress reports the rest of a site's problems, and keeps them there until
* they're fixed.
*
* @param array $tests
*
* @return array
* @since 6.17.0
*/
public function site_status_tests( $tests ) {
if ( ! is_array( $tests ) || ! $this->gform->has_capability( 'gravityforms_view_settings' ) ) {
return $tests;
}

$tests['direct']['gravity_pdf_deprecated_features'] = [
'label' => esc_html__( 'Deprecated Gravity PDF functionality', 'gravity-pdf' ),
'test' => [ $this, 'deprecated_features_test' ],
];

return $tests;
}

/**
* Run the deprecated functionality Site Health test
*
* @return array
* @since 6.17.0
*/
public function deprecated_features_test() {
return $this->view->get_deprecated_features_test( $this->model->get_deprecated_signals() );
}

/**
* Add the deprecated functionality to the Site Health Info tab
*
* The Info tab is what users copy into a support ticket, so the detections travel with it.
*
* @param array $info
*
* @return array
* @since 6.17.0
*/
public function debug_information( $info ) {
if ( ! is_array( $info ) || ! $this->gform->has_capability( 'gravityforms_view_settings' ) ) {
return $info;
}

$info['gravity-pdf-deprecated'] = $this->view->get_deprecated_debug_information( $this->model->get_deprecated_signals() );

return $info;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Helper/Fields/Field_Signature.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use GFFormsModel;
use GFPDF\Helper\Helper_Abstract_Fields;
use GFPDF\Statics\Deprecation;

/**
* @package Gravity PDF
Expand Down Expand Up @@ -132,7 +133,7 @@ public function value() {
* @param integer The original image width
*/
if ( $signature_details !== false ) {
$optimised_width = apply_filters( 'gfpdfe_signature_width', $signature_details[0] / 3, $signature_details[0] ); /* backwards compat */
$optimised_width = Deprecation::apply_filters( 'gfpdfe_signature_width', [ $signature_details[0] / 3, $signature_details[0] ] );

/* See https://docs.gravitypdf.com/developers/filters/gfpdf_signature_width/ for more details about this filter */
$optimised_width = apply_filters( 'gfpdf_signature_width', $optimised_width, $signature_details[0] );
Expand Down
4 changes: 4 additions & 0 deletions src/Helper/Helper_Abstract_View.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ final protected function load( $filename, $args = [], $output = true ) {

$args = array_merge( $this->data_cache, $args );

if ( isset( $args['content'] ) ) {
_deprecated_argument( esc_html( $this->view_type . '/' . $filename . '.php' ), '6.4.0', "Use \$args['callback'] instead" );
}

if ( is_readable( $path ) ) {

if ( $output ) {
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/Helper_Misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public function get_legacy_ids( $entry_id, $settings ) {
* @deprecated 6.12 compatibility code no longer required
*/
public function maybe_add_multicurrency_support() {
_doing_it_wrong( __METHOD__, 'This method has been removed and no alternative is available.', '6.12' );
_deprecated_function( __METHOD__, '6.12' );
}

/**
Expand Down
Loading
Loading