-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from helsingborg-stad/feat/acf-fronted-form
Feat/acf fronted form
- Loading branch information
Showing
6 changed files
with
150 additions
and
2 deletions.
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
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,45 @@ | ||
<?php | ||
|
||
namespace EventManager\Helper; | ||
|
||
use EventManager\Services\WPService\WPService; | ||
|
||
abstract class Module implements Hookable | ||
{ | ||
protected WPService $wp; | ||
|
||
abstract public function getModuleName(): string; | ||
abstract public function getModulePath(): string; | ||
|
||
public function __construct(WPService $wpService) | ||
{ | ||
$this->wp = $wpService; | ||
} | ||
|
||
public function addHooks(): void | ||
{ | ||
$this->wp->addAction('init', [$this, 'register']); | ||
$this->wp->addFilter('/Modularity/externalViewPath', [$this, 'addViewPath']); | ||
} | ||
|
||
public function addViewPath($paths): array | ||
{ | ||
$paths['mod-event-form'] = $this->getModulePath() . '/views'; | ||
return $paths; | ||
} | ||
|
||
public function register(): bool | ||
{ | ||
//Register the module | ||
if (function_exists('modularity_register_module')) { | ||
modularity_register_module( | ||
$this->getModulePath(), | ||
$this->getModuleName() | ||
); | ||
|
||
return true; | ||
} | ||
|
||
throw new \Exception('Modularity not found'); | ||
} | ||
} |
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,76 @@ | ||
<?php | ||
/** @noinspection PhpMissingFieldTypeInspection */ | ||
/** @noinspection PhpFullyQualifiedNameUsageInspection */ | ||
/** @noinspection PhpUndefinedClassInspection */ | ||
/** @noinspection PhpUndefinedNamespaceInspection */ | ||
|
||
namespace EventManager\Modules\FrontendForm; | ||
|
||
//use EventManager\Helper\CacheBust; | ||
|
||
/** | ||
* @property string $description | ||
* @property string $namePlural | ||
* @property string $nameSingular | ||
* @property int $ID | ||
*/ | ||
class FrontendForm extends \Modularity\Module | ||
{ | ||
public $slug = 'event-form'; | ||
public $supports = []; | ||
|
||
public function init(): void | ||
{ | ||
$this->nameSingular = __('Event Form', ); | ||
$this->namePlural = __('Event Forms', 'api-event-manager'); | ||
$this->description = __('Module for creating public event form', 'api-event-manager'); | ||
//$this->cacheTtl = 60; | ||
} | ||
|
||
public function data(): array | ||
{ | ||
$fields = $this->getFields(); | ||
|
||
return [ | ||
'formStart' => function() { | ||
|
||
}, | ||
'form' => function() { | ||
acf_form([ | ||
'post_id' => 'new_post', | ||
'post_title' => true, | ||
'post_content' => true, | ||
'new_post' => [ | ||
'post_type' => 'event', | ||
'post_status' => 'draft' | ||
], | ||
'submit_value' => __('Create Event', 'api-event-manager') | ||
]); | ||
}, | ||
'formEnd' => function() { | ||
|
||
}, | ||
]; | ||
} | ||
|
||
public function template(): string | ||
{ | ||
return 'frontend-form.blade.php'; | ||
} | ||
|
||
public function script(): void | ||
{ | ||
acf_form_head(); | ||
/*wp_enqueue_script( | ||
'frontend-form', | ||
EVENT_MANAGER_URL . '/dist/'. CacheBust::name('js/assignment-form.js') | ||
);*/ | ||
} | ||
|
||
public function style(): void { | ||
/*wp_enqueue_style( | ||
'frontend-form', | ||
EVENT_MANAGER_URL . '/dist/'. CacheBust::name('js/assignment-form.css') | ||
);*/ | ||
} | ||
} |
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,16 @@ | ||
<?php | ||
|
||
namespace EventManager\Modules\FrontendForm; | ||
|
||
use EventManager\Helper\Module; | ||
|
||
class Register extends Module | ||
{ | ||
public function getModuleName(): string { | ||
return 'FrontendForm'; | ||
} | ||
|
||
public function getModulePath(): string { | ||
return EVENT_MANAGER_PATH . 'source/php/Modules/FrontendForm/'; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
source/php/Modules/FrontendForm/views/frontend-form.blade.php
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,5 @@ | ||
@paper(['padding' => 4]) | ||
{!! $formStart() !!} | ||
{!! $form() !!} | ||
{!! $formEnd() !!} | ||
@endpaper |