-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable storing form data in TablePress #48
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a80f764
Simplify
kasparsd 198f5ce
Allow filtering the fields
kasparsd eabd38b
Load when all plugins have loaded
kasparsd 002a444
Add settings
kasparsd 936269b
Add tablepress
kasparsd 8b7cbd7
Pass the settings along
kasparsd fb14534
Introduce integrations concept
kasparsd 1052aab
Can stay as hidden by default
kasparsd bc4d160
Ensure we have the same columns for all rows
kasparsd 01dce43
Ensure proper headers
kasparsd 424fded
Allow testing
kasparsd 8e46b7c
Add tests
kasparsd de13beb
Per linter
kasparsd 040733c
Unused
kasparsd a5c8cae
More docs
kasparsd 143a5ad
Per linter
kasparsd d58f3d5
Do not attempt processing, if dependency not met
kasparsd 4dd4b71
Escape
kasparsd 80cc943
Explain the merge logic
kasparsd c01e60b
Include storage
kasparsd 276b20e
Mention storage
kasparsd afa7b91
Document all storage options
kasparsd 2f32cdf
Format per markdown spec
kasparsd c7d0c16
Link to the storage plugin
kasparsd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<?php | ||
|
||
/** | ||
* Form settings. | ||
*/ | ||
class Cf7_Extras_Form_Settings { | ||
|
||
/** | ||
* Default settings. | ||
* | ||
* @var array | ||
*/ | ||
private $defaults = array( | ||
'disable-css' => false, | ||
'disable-ajax' => false, | ||
'html5-disable' => false, | ||
'html5-fallback' => false, | ||
'disable-autop' => false, | ||
'redirect-success' => false, | ||
'track-ga-success' => false, | ||
'track-ga-submit' => false, | ||
'track-ga' => false, | ||
'google-recaptcha-lang' => null, | ||
); | ||
|
||
/** | ||
* Form instance. | ||
* | ||
* @var WPCF7_ContactForm | ||
*/ | ||
protected $form; | ||
|
||
/** | ||
* Setup settings for a form. | ||
* | ||
* @param WPCF7_ContactForm $form Form instance. | ||
*/ | ||
public function __construct( $form ) { | ||
$this->form = $form; | ||
} | ||
|
||
/** | ||
* Get settings for a form by ID. | ||
* | ||
* @param int $form_id Form ID. | ||
* | ||
* @return self | ||
*/ | ||
public static function from_form_id( $form_id ) { | ||
return new self( wpcf7_contact_form( $form_id ) ); | ||
} | ||
|
||
/** | ||
* Get the form ID. | ||
* | ||
* @return int | ||
*/ | ||
public function form_id() { | ||
return $this->form->id(); | ||
} | ||
|
||
/** | ||
* Get a setting value. | ||
* | ||
* @param string $key Setting key. | ||
* | ||
* @return mixed|null Return null if the setting is not found. | ||
*/ | ||
public function get( $key ) { | ||
$settings = $this->all(); | ||
|
||
if ( isset( $settings[ $key ] ) ) { | ||
return $settings[ $key ]; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
/** | ||
* Get all settings. | ||
* | ||
* @return array | ||
*/ | ||
public function all() { | ||
$settings = get_post_meta( $this->form->id(), 'extras', true ); | ||
|
||
if ( ! is_array( $settings ) ) { | ||
$settings = array(); | ||
} | ||
|
||
$settings = array_merge( $this->defaults, $settings ); | ||
|
||
// Convert legacy settings into one. | ||
if ( ! empty( $settings['track-ga-success'] ) || ! empty( $settings['track-ga-submit'] ) ) { | ||
$settings['track-ga'] = true; | ||
} | ||
|
||
return $settings; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load later to allow disabling, if needed.