GFPDFControllerController_Shortcodes

Controller_PDF Handles the PDF display and authentication.

Defined (1)

The class is defined in the following location(s).

/src/controller/Controller_Shortcodes.php  
  1. class Controller_Shortcodes extends Helper_Abstract_Controller implements Helper_Interface_Filters { 
  2.  
  3. /** 
  4. * Holds our log class 
  5. * @var \Monolog\Logger|LoggerInterface 
  6. * @since 4.0 
  7. */ 
  8. protected $log; 
  9.  
  10. /** 
  11. * Setup our class by injecting all our dependancies 
  12. * @param Helper_Abstract_Model|\GFPDF\Model\Model_Shortcodes $model Our Shortcodes Model the controller will manage 
  13. * @param Helper_Abstract_View|\GFPDF\View\View_Shortcodes $view Our Shortcodes View the controller will manage 
  14. * @param \Monolog\Logger|LoggerInterface $log Our logger class 
  15. * @since 4.0 
  16. */ 
  17. public function __construct( Helper_Abstract_Model $model, Helper_Abstract_View $view, LoggerInterface $log ) { 
  18.  
  19. /** Assign our internal variables */ 
  20. $this->log = $log; 
  21.  
  22. /** Load our model and view */ 
  23. $this->model = $model; 
  24. $this->model->setController( $this ); 
  25.  
  26. $this->view = $view; 
  27. $this->view->setController( $this ); 
  28.  
  29. /** 
  30. * Initialise our class defaults 
  31. * @since 4.0 
  32. * @return void 
  33. */ 
  34. public function init() { 
  35.  
  36. $this->add_filters(); 
  37. $this->add_shortcodes(); 
  38.  
  39. /** Add support for the new shortcake UI currently being considered for core integration */ 
  40. if ( is_admin() ) { 
  41. $this->add_shortcake_support(); 
  42.  
  43. /** 
  44. * Apply any filters needed for the settings page 
  45. * @since 4.0 
  46. * @return void 
  47. */ 
  48. public function add_filters() { 
  49.  
  50. add_filter( 'gform_confirmation', [ $this->model, 'gravitypdf_confirmation' ], 100, 3 ); 
  51. add_filter( 'gform_notification', [ $this->model, 'gravitypdf_notification' ], 100, 3 ); 
  52. add_filter( 'gform_admin_pre_render', [ $this->model, 'gravitypdf_redirect_confirmation' ] ); 
  53.  
  54. /** Basic GravityView Support */ 
  55. add_filter( 'gravityview/fields/custom/content_before', [ $this->model, 'gravitypdf_gravityview_custom' ], 10 ); 
  56.  
  57.  
  58. /** 
  59. * Register our shortcodes 
  60. * @since 4.0 
  61. * @return void 
  62. */ 
  63. public function add_shortcodes() { 
  64. add_shortcode( 'gravitypdf', [ $this->model, 'gravitypdf' ] ); 
  65.  
  66.  
  67. /** 
  68. * Register our shortcake attributes 
  69. * See https://github.com/fusioneng/Shortcake for more details 
  70. * @since 4.0 
  71. * @return void 
  72. */ 
  73. public function add_shortcake_support() { 
  74.  
  75. /** Exist if the shortcake function doesn't exist */ 
  76. if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) { 
  77. return null; 
  78.  
  79. $this->log->addNotice( 'Enable Shortcake support.' ); 
  80.  
  81. /** Enhance further */ 
  82. shortcode_ui_register_for_shortcode( 'gravitypdf', [ 
  83. 'label' => esc_html__( 'Gravity PDF', 'gravity-forms-pdf-extended' ),  
  84.  
  85. 'listItemImage' => 'dashicons-admin-site',  
  86.  
  87. 'attrs' => [ 
  88. 'label' => 'ID',  
  89. 'attr' => 'id',  
  90. 'type' => 'text',  
  91. ],  
  92.  
  93. 'label' => 'Anchor Text',  
  94. 'attr' => 'text',  
  95. 'type' => 'text',  
  96. ],  
  97.  
  98. 'label' => 'View',  
  99. 'attr' => 'type',  
  100. 'type' => 'select',  
  101. 'default' => 'download',  
  102. 'options' => [ 
  103. 'download' => 'Download',  
  104. 'view' => 'View',  
  105. ],  
  106. ],  
  107.  
  108. 'label' => 'Anchor Class',  
  109. 'attr' => 'class',  
  110. 'type' => 'text',  
  111. 'description' => 'Optional. Add any class name * separated by a space * you want to apply to the PDF link.',  
  112. 'meta' => [ 
  113. 'placeholder' => '',  
  114. ],  
  115. ],  
  116.  
  117. 'label' => 'Entry ID',  
  118. 'attr' => 'entry',  
  119. 'type' => 'text',  
  120. 'description' => 'Optional. You can pass in a specific ID or let us auto select one.',  
  121. 'meta' => [ 
  122. 'placeholder' => '',  
  123. ],  
  124. ],  
  125. ],  
  126. ] );