Skip to content

Commit

Permalink
add a signature to the form
Browse files Browse the repository at this point in the history
  • Loading branch information
pryley committed Oct 25, 2024
1 parent 61bb07e commit ae7b43b
Show file tree
Hide file tree
Showing 17 changed files with 179 additions and 146 deletions.
17 changes: 7 additions & 10 deletions HOOKS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Actions

site-reviews/<form_name>/form (Contracts\FormContract $form)
site-reviews/action (string $hook, array $args)
site-reviews/activated ()
site-reviews/addon/register (Application $app)
Expand Down Expand Up @@ -37,7 +38,6 @@
site-reviews/review/updated/post_ids (Review $review, array $assignedPostIds)
site-reviews/review/updated/user_ids (Review $review, array $assignedUserIds)
site-reviews/review/verified (Review $review)
site-reviews/review-form (Contracts\FormContract $form)
site-reviews/route/request (Request $request, string $hook)
site-reviews/route/get/<request_type>/<route_action> (Request $request)
site-reviews/route/<request_type>/<route_action> (Request $request)
Expand All @@ -51,6 +51,12 @@

## Filters

site-reviews/<form_name>/build/fields (string $rendered, Contracts\FormContract $form): string
site-reviews/<form_name>/build/response (string $rendered, Contracts\FormContract $form): string
site-reviews/<form_name>/build/submit_button (string $rendered, Contracts\FormContract $form): string
site-reviews/<form_name>/fields/all (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/<form_name>/fields/hidden (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/<form_name>/fields/visible (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/addon/api-url (string $apiUrl): string
site-reviews/addon/documentation (array $documentation): array
site-reviews/addon/documentation/tabs (array $tabs): array
Expand Down Expand Up @@ -135,9 +141,6 @@
site-reviews/field/element/<field_element_type> (string $className, Contracts\FieldContract $field): string
site-reviews/flyoutmenu/enabled (bool $bool): bool
site-reviews/flyoutmenu/items (array $items): array
site-reviews/form/build/fields (string $rendered, Contracts\FormContract $form): string
site-reviews/form/build/response (string $rendered, Contracts\FormContract $form): string
site-reviews/form/build/submit_button (string $rendered, Contracts\FormContract $form): string
site-reviews/fusion-builder/controls/site_review (array $parameters): array
site-reviews/fusion-builder/controls/site_reviews (array $parameters): array
site-reviews/fusion-builder/controls/site_reviews_form (array $parameters): array
Expand All @@ -149,10 +152,7 @@
site-reviews/interpolate/<template_path> (array $context, string $template, array $data): array
site-reviews/is-local-server (bool $bool): bool
site-reviews/metabox-form/fields (array $fields, Contracts\FormContract $form): array
site-reviews/metabox-form/fields/all (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/metabox-form/fields/hidden (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/metabox-form/fields/order (array $order): array
site-reviews/metabox-form/fields/visible (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/notices (array $notices): array
site-reviews/notification/emails (array $emails, Review $review): array
site-reviews/notification/tag/<tag> (string $value, Review $review): string
Expand Down Expand Up @@ -196,9 +196,6 @@
site-reviews/rest-api/summary/parameters (array $parameters): array
site-reviews/rest-api/summary/schema/properties (array $properties): array
site-reviews/review-form/fields (array[] $fields, Contracts\FormContract $form): array
site-reviews/review-form/fields/all (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/review-form/fields/hidden (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/review-form/fields/visible (Contracts\FieldContract[] $fields, Contracts\FormContract $form): array
site-reviews/review-form/order (array $order): array
site-reviews/review-form/referer (string $referer): string
site-reviews/review-table/clauses (array $clauses, array $postClauses, \WP_Query $query): array
Expand Down
Binary file modified languages/site-reviews-en_US.mo
Binary file not shown.
16 changes: 10 additions & 6 deletions languages/site-reviews-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,19 @@ msgstr "This review is based on my own experience and is my genuine opinion."
msgid "Show more"
msgstr "Show more"

#: plugin/Commands/CreateReview.php:165, views/pages/documentation/support/common-problems-and-solutions.php:89
#: plugin/Commands/CreateReview.php:162, views/pages/documentation/support/common-problems-and-solutions.php:89
msgid ""
"Your review could not be submitted and the error has been logged. Please "
"notify the site administrator."
msgstr ""
"Your review could not be submitted and the error has been logged. Please "
"notify the site administrator."

#: plugin/Commands/CreateReview.php:169
#: plugin/Commands/CreateReview.php:166
msgid "Your review has been submitted!"
msgstr "Your review has been submitted!"

#: plugin/Commands/CreateReview.php:170
#: plugin/Commands/CreateReview.php:167
msgid "Your review has been submitted and is pending approval."
msgstr "Your review has been submitted and is pending approval."

Expand Down Expand Up @@ -380,11 +380,11 @@ msgstr "Write review of a user of a role"
msgid "Write review of a specific user"
msgstr "Write review of a specific user"

#: plugin/Modules/Html/Form.php:24
#: plugin/Modules/Html/Form.php:26
msgid "Submit Form"
msgstr "Submit Form"

#: plugin/Modules/Html/Form.php:25
#: plugin/Modules/Html/Form.php:27
msgid "Submitting, please wait..."
msgstr "Submitting, please wait..."

Expand Down Expand Up @@ -412,7 +412,7 @@ msgstr "The CAPTCHA verification failed, please try again."
msgid "The review submission failed. Please notify the site administrator."
msgstr "The review submission failed. Please notify the site administrator."

#: plugin/Modules/Validator/DefaultValidator.php:27
#: plugin/Modules/Validator/DefaultValidator.php:28
msgid "Please fix the form errors."
msgstr "Please fix the form errors."

Expand All @@ -428,6 +428,10 @@ msgstr "You must be logged in to submit a review."
msgid "You have already submitted a review."
msgstr "You have already submitted a review."

#: plugin/Modules/Validator/SignatureValidator.php:29
msgid "This review cannot be submitted because the form was modified."
msgstr "This review cannot be submitted because the form was modified."

#: plugin/Integrations/UltimateMember/Controllers/ProfileController.php:41
msgid "Reviews"
msgstr "Reviews"
Expand Down
16 changes: 10 additions & 6 deletions languages/site-reviews.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1886,15 +1886,15 @@ msgctxt "admin-text"
msgid "The <code>%s</code> table was successly converted to InnoDB."
msgstr ""

#: plugin/Commands/CreateReview.php:165, views/pages/documentation/support/common-problems-and-solutions.php:89
#: plugin/Commands/CreateReview.php:162, views/pages/documentation/support/common-problems-and-solutions.php:89
msgid "Your review could not be submitted and the error has been logged. Please notify the site administrator."
msgstr ""

#: plugin/Commands/CreateReview.php:169
#: plugin/Commands/CreateReview.php:166
msgid "Your review has been submitted!"
msgstr ""

#: plugin/Commands/CreateReview.php:170
#: plugin/Commands/CreateReview.php:167
msgid "Your review has been submitted and is pending approval."
msgstr ""

Expand Down Expand Up @@ -4848,11 +4848,11 @@ msgctxt "admin-text"
msgid "Unapproved Review (Site Reviews)"
msgstr ""

#: plugin/Modules/Html/Form.php:24
#: plugin/Modules/Html/Form.php:26
msgid "Submit Form"
msgstr ""

#: plugin/Modules/Html/Form.php:25
#: plugin/Modules/Html/Form.php:27
msgid "Submitting, please wait..."
msgstr ""

Expand Down Expand Up @@ -4885,7 +4885,7 @@ msgstr ""
msgid "The review submission failed. Please notify the site administrator."
msgstr ""

#: plugin/Modules/Validator/DefaultValidator.php:27
#: plugin/Modules/Validator/DefaultValidator.php:28
msgid "Please fix the form errors."
msgstr ""

Expand All @@ -4901,6 +4901,10 @@ msgstr ""
msgid "You have already submitted a review."
msgstr ""

#: plugin/Modules/Validator/SignatureValidator.php:29
msgid "This review cannot be submitted because the form was modified."
msgstr ""

#: views/integrations/multilingualpress/assigned_posts-field.php:5
msgctxt "admin-text"
msgid "Synchronize Assigned Posts"
Expand Down
5 changes: 1 addition & 4 deletions plugin/Commands/CreateReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use GeminiLabs\SiteReviews\Helpers\Str;
use GeminiLabs\SiteReviews\Helpers\Url;
use GeminiLabs\SiteReviews\Modules\Avatar;
use GeminiLabs\SiteReviews\Modules\Encryption;
use GeminiLabs\SiteReviews\Modules\Validator\CustomValidator;
use GeminiLabs\SiteReviews\Modules\Validator\DefaultValidator;
use GeminiLabs\SiteReviews\Modules\Validator\DuplicateValidator;
Expand Down Expand Up @@ -82,9 +81,7 @@ public function isRequestValid(): bool
Arr::consolidate(glsr()->settings('settings.forms.required.options')),
$this->request->toArray(),
));
$request->merge([
'excluded' => glsr(Encryption::class)->encrypt(implode(',', $excluded)),
]);
$request->merge(compact('excluded'));
$validators = glsr()->filterArray('validators', [ // order is intentional
DefaultValidator::class,
DuplicateValidator::class,
Expand Down
11 changes: 0 additions & 11 deletions plugin/Controllers/MetaboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@

class MetaboxController extends AbstractController
{
/**
* @filter site-reviews/metabox-form/fields
*/
public function filterFieldOrder(array $config): array
{
$order = array_keys($config);
$order = glsr()->filterArray('metabox-form/fields/order', $order);
$ordered = array_intersect_key(array_merge(array_flip($order), $config), $config);
return $ordered;
}

/**
* @action add_meta_boxes_{glsr()->post_type}
*/
Expand Down
10 changes: 0 additions & 10 deletions plugin/Controllers/PublicController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ public function fetchPagedReviewsAjax(Request $request): void
wp_send_json_success($response);
}

/**
* @filter site-reviews/config/forms/review-form
*/
public function filterFieldOrder(array $config): array
{
$order = array_keys($config);
$order = glsr()->filterArray('review-form/order', $order);
return array_intersect_key(array_merge(array_flip($order), $config), $config);
}

/**
* @filter site-reviews/render/view
*/
Expand Down
1 change: 1 addition & 0 deletions plugin/Defaults/CustomFieldsDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class CustomFieldsDefaults extends DefaultsAbstract
'email',
'excluded',
'form_id',
'form_signature',
'ID',
'ip_address',
'is_approved',
Expand Down
1 change: 0 additions & 1 deletion plugin/Hooks/MetaboxHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class MetaboxHooks extends AbstractHooks
public function run(): void
{
$this->hook(MetaboxController::class, [
['filterFieldOrder', 'site-reviews/metabox-form/fields', 30],
['registerMetaBoxes', "add_meta_boxes_{$this->type}"],
['removeMetaBoxes', 'do_meta_boxes'],
['renderPinnedAction', 'post_submitbox_misc_actions'],
Expand Down
1 change: 0 additions & 1 deletion plugin/Hooks/PublicHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public function run(): void
$this->hook(PublicController::class, [
['enqueueAssets', 'wp_enqueue_scripts', 999], // run after all addons
['fetchPagedReviewsAjax', 'site-reviews/route/ajax/fetch-paged-reviews'],
['filterFieldOrder', 'site-reviews/config/forms/review-form', 11],
['filterRenderView', 'site-reviews/render/view'],
['renderSchema', 'wp_footer'],
['submitReview', 'site-reviews/route/public/submit-review'],
Expand Down
Loading

0 comments on commit ae7b43b

Please sign in to comment.