Skip to content

Commit

Permalink
Update for 2.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
stephywells committed Mar 10, 2015
1 parent 9d1da9c commit 9ebf712
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 160 deletions.
25 changes: 10 additions & 15 deletions installation-update-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ class FPPDF_InstallUpdater
private static $template_font_directory = FP_PDF_FONT_LOCATION;


public function install()
{
public static function install() {
if(strlen(get_option('fp_pdf_extended_installed')) == 0)
{
update_option('fp_pdf_extended_version', FP_PDF_EXTENDED_VERSION);
Expand Down Expand Up @@ -50,8 +49,7 @@ public static function update_file_paths()
/**
* Install everything required
*/
public function pdf_extended_activate()
{
public static function pdf_extended_activate() {
/*
* Initialise the Wordpress Filesystem API
*/
Expand Down Expand Up @@ -84,8 +82,8 @@ public function pdf_extended_activate()

if(FP_PDF_DEPLOY === true && $wp_filesystem->exists(self::$template_directory))
{
/* read all file names into array and unlink from active theme template folder */
foreach(glob(PDF_PLUGIN_DIR . 'templates/*.php') as $file) {
/* read all file names into array and unlink from active theme template folder */
foreach ( glob( FP_PDF_PLUGIN_DIR . 'templates/*.php') as $file ) {
$path_parts = pathinfo($file);
if($wp_filesystem->exists(self::$template_directory.$path_parts['basename']))
{
Expand Down Expand Up @@ -343,8 +341,7 @@ public function fp_pdf_not_deployed()
/**
* PDF Extended has been freshly installed
*/
public function fp_pdf_not_deployed_fresh()
{
public static function fp_pdf_not_deployed_fresh() {
if( (FP_PDF_DEPLOY === true) && !rgpost('update') )
{
if(rgget("page") == 'fp_settings' && rgget('addon') == 'PDF')
Expand Down Expand Up @@ -417,7 +414,7 @@ public function fp_pdf_template_move_err()
/*
* When switching themes copy over current active theme's PDF_EXTENDED_TEMPLATES (if it exists) to new theme folder
*/
public function fp_pdf_on_switch_theme($old_theme_name, $old_theme_object) {
public static function fp_pdf_on_switch_theme( $old_theme_name, $old_theme_object ) {

/*
* We will store the old pdf dir and new pdf directory and prompt the user to copy the PDF_EXTENDED_TEMPLATES folder
Expand Down Expand Up @@ -448,8 +445,8 @@ public static function check_theme_switch()
/*
* Add admin notification hook to move the files
*/
add_action('admin_notices', array("FPPDF_InstallUpdater", "do_theme_switch_notice"));
return true;
add_action( 'admin_notices', 'FPPDF_InstallUpdater::do_theme_switch_notice' );
return true;
}
return false;
}
Expand Down Expand Up @@ -484,8 +481,7 @@ public static function fp_pdf_theme_sync_success()
* The after_switch_theme hook is too early in the initialisation to use request_filesystem_credentials()
* so we have to call this function at a later inteval
*/
public function do_theme_switch($previous_pdf_path, $current_pdf_path)
{
public static function do_theme_switch( $previous_pdf_path, $current_pdf_path ) {
/*
* Prepare for calling the WP Filesystem
* It only allows post data to be added so we have to manually assign them
Expand Down Expand Up @@ -535,8 +531,7 @@ public function do_theme_switch($previous_pdf_path, $current_pdf_path)
* Allows you to copy entire folder structures to new location
*/

public function pdf_extended_copy_directory( $source, $destination, $copy_base = true, $delete_destination = false )
{
public static function pdf_extended_copy_directory( $source, $destination, $copy_base = true, $delete_destination = false ) {
global $wp_filesystem;

if ( $wp_filesystem->is_dir( $source ) )
Expand Down
56 changes: 36 additions & 20 deletions pdf-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public static function get_form_fields($form_id)
/*
* Check if the system is fully installed and return the correct values
*/
public static function is_fully_installed()
{
global $frmpro_is_installed;
public static function is_fully_installed() {
global $frmpro_is_installed;

if(!$frmpro_is_installed)
{
return false;
}
if ( ! $frmpro_is_installed ) {
if ( ! is_callable( 'FrmAppHelper::pro_is_installed' ) || ! FrmAppHelper::pro_is_installed() ){
return false;
}
}

if( (get_option('fp_pdf_extended_installed') != 'installed') || (!is_dir(FP_PDF_TEMPLATE_LOCATION)) )
{
Expand Down Expand Up @@ -208,20 +208,36 @@ public static function view_data($form_data)
}
}

public static function is_formidable_supported($version){
global $frmpro_is_installed;

if( class_exists('FrmProDisplay') )
{
global $frm_version;
if(version_compare($frm_version, $version, ">=") === true)
{
if($frmpro_is_installed)
{
return true;
}
public static function is_formidable_supported( $version ) {
if ( ! class_exists('FrmProDisplay') ) {
return false;
}

global $frm_version;
if ( $frm_version ) {
/**
* Get the plugin version when < 2.0
*/
$current_frm_version = $frm_version;
} else if ( is_callable( 'FrmAppHelper::plugin_version' ) ) {
/**
* Get the plugin version when > 2.0
*/
$current_frm_version = FrmAppHelper::plugin_version();
}

if ( version_compare( $current_frm_version, $version, '>=' ) === true ) {
global $frmpro_is_installed;
if ( $frmpro_is_installed ) {
return true;
}
}

/**
* Check if pro is installed in 2.0+
*/
return ( is_callable( 'FrmAppHelper::pro_is_installed' ) && FrmAppHelper::pro_is_installed() );
}

return false;
}

Expand Down
21 changes: 5 additions & 16 deletions pdf-configuration-indexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,11 @@ private function pdf_config()
/*
* Set the configuration index so it's faster to access template configuration information
*/
private function set_form_pdfs()
{
foreach($this->configuration as $key => $config)
{
if(!is_array($config['form_id']))
{
$this->assign_index($config['form_id'], $key);
}
else
{
foreach($config['form_id'] as $id)
{
$this->assign_index($id, $key);
}
private function set_form_pdfs() {
foreach ( $this->configuration as $key => $config ) {
foreach ( (array) $config['form_id'] as $id ) {
$this->assign_index( $id, $key );
}

}
}

Expand All @@ -145,7 +134,7 @@ public function assign_index($id, $key)
* Assign the outter array with the form ID and the value as the configuration key
*/
$this->index[$id][] = $key;
}
}
}

/*
Expand Down
2 changes: 1 addition & 1 deletion pdf-custom-display.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Securly allow the shortcode [pdf] to be used in custom displays
*/

add_filter('frm_display_entry_content', array('FP_Custom_Display', 'entries_content'), 10, 6);
add_filter( 'frm_display_entry_content', 'FP_Custom_Display::entries_content', 10, 6 );


class FP_Custom_Display
Expand Down
6 changes: 3 additions & 3 deletions pdf-entry-detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ public static function show_entry($atts){

/* grab the HTML */
if ( !self::$frmplus_action_added ){
add_action( 'frmplus_field_value_checkbox', array('FPPDF_Entry', 'convert_checkboxes_to_image') );
add_action( 'frmplus_field_value_radio', array('FPPDF_Entry', 'convert_checkboxes_to_image') );
add_action( 'frmplus_field_value_radioline', array('FPPDF_Entry', 'convert_checkboxes_to_image') );
add_action( 'frmplus_field_value_checkbox', 'FPPDF_Entry::convert_checkboxes_to_image' );
add_action( 'frmplus_field_value_radio', 'FPPDF_Entry::convert_checkboxes_to_image' );
add_action( 'frmplus_field_value_radioline', 'FPPDF_Entry::convert_checkboxes_to_image' );
self::$frmplus_action_added = true;
}

Expand Down
5 changes: 2 additions & 3 deletions pdf-render.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class FPPDFRender
* var $lead_id integer: The entry id
* var $output string: either view, save or download
* save will save a copy of the PDF to the server using the FP_PDF_SAVE_LOCATION constant
* var $return boolean: if set to true
it will return the path of the saved PDF
* var $return boolean: if set to true it will return the path of the saved PDF
* var $template string: if you want to use multiple PDF templates - name of the template file
* var $pdfname string: allows you to pass a custom PDF name to the generator e.g. 'Application Form.pdf' (ensure .pdf is appended to the filename)
* var $fpdf boolean: custom hook to allow the FPDF engine to generate PDFs instead of DOMPDF. Premium Paid Feature.
Expand Down Expand Up @@ -241,7 +240,7 @@ public function PDF_processing($html, $filename, $id, $output = 'view', $argumen

/* load HTML block */
$mpdf->WriteHTML($html);

switch($output)
{
case 'download':
Expand Down
34 changes: 13 additions & 21 deletions pdf-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,32 @@
* Handles the Formidable Pro Settings page in Wordpress
*/

class FPPDF_Settings
{
class FPPDF_Settings {
/*
* Check if we're on the settings page
*/
public function settings_page() {
public static function settings_page() {
/*
* Initialise Formidable Settings Page
*/
if(rgget('page') == 'formidable-settings')
{
if ( rgget('page') == 'formidable-settings' ) {
/*
* Add Formidable Settings Page
*/
add_filter('frm_add_settings_section', array('FPPDF_Settings', 'add_settings_page'));
add_filter( 'frm_add_settings_section', 'FPPDF_Settings::add_settings_page' );
}

}

public static function add_settings_page($sections)
{
public static function add_settings_page( $sections ) {
$sections['PDF'] = array(
'class' => 'FPPDF_Settings',
'function' => 'fppdf_settings_page'
);
return $sections;
}

private function run_setting_routing()
{
private static function run_setting_routing() {
/*
* Check if we need to redeploy default PDF templates/styles to the theme folder
*/
Expand Down Expand Up @@ -89,13 +85,11 @@ private function run_setting_routing()
/*
* Shows the GF PDF Extended settings page
*/
public function fppdf_settings_page()
{
public static function fppdf_settings_page() {
/*
* Run the page's configuration/routing options
*/
if(self::run_setting_routing() === true)
{
if ( self::run_setting_routing() === true ) {
return;
}

Expand Down Expand Up @@ -187,18 +181,16 @@ public static function ajax_deploy()
ob_end_clean();

print json_encode(array('error' => $message));
}
else
{
print json_encode(array('message' => self::gf_fp_pdf_deploy_success()));
}
} else {
print json_encode( array( 'message' => self::pdf_deploy_success() ) );
}

exit;
}

public function gf_fp_pdf_deploy_success() {
public static function pdf_deploy_success() {
$msg = '<div id="fppdfe_message" class="updated"><p>';
$msg .= 'You\'ve successfully initialised Formidable Pro PDF Extended.';
$msg .= __( 'You\'ve successfully initialised Formidable Pro PDF Extended.', 'ffpdf' );
$msg .= '</p></div>';

return $msg;
Expand Down
Loading

0 comments on commit 9ebf712

Please sign in to comment.