acf = $acf; $this->viewMarkup = $viewMarkup; } protected static function getErrorMarkup(string $error): string { return "
{$error}
"; } protected function getAcfView(Post $dataPost, int $viewId, int $pageId): AcfView { $viewGroup = new View($viewId); $viewMarkup = $this->viewMarkup->getMarkup($viewGroup, $pageId); return new AcfView($this->acf, $viewGroup, $dataPost, $pageId, $viewMarkup); } protected function enqueueAdminAssets(array $jsData = []): void { $jsData = array_merge_recursive($jsData, [ 'markupTextarea' => [ [ 'idSelector' => View::getAcfFieldName(View::FIELD_MARKUP), 'isReadOnly' => true, 'mode' => 'htmlmixed', ], [ 'idSelector' => View::getAcfFieldName(View::FIELD_CSS_CODE), 'isReadOnly' => false, 'mode' => 'css', ], [ 'idSelector' => View::getAcfFieldName(View::FIELD_JS_CODE), 'isReadOnly' => false, 'mode' => 'javascript', ], ], 'fieldSelect' => [ [ 'mainSelectId' => Item::getAcfFieldName(Item::FIELD_GROUP), 'subSelectId' => Field::getAcfFieldName(Field::FIELD_KEY), 'identifierInputId' => Field::getAcfFieldName(Field::FIELD_ID), ], ] ]); $version = $this->getVersion(); // $version = time(); wp_enqueue_style(CPT::NAME, $this->getAssetsUrl('admin.css'), [], $version); // jquery is necessary for select2 events wp_enqueue_script(CPT::NAME, $this->getAssetsUrl('admin.js'), ['jquery',], $version); wp_localize_script(CPT::NAME, 'acf_views', $jsData); } public function getName(): string { return $this->name; } public function getSlug(): string { return $this->slug; } public function getVersion(): string { return $this->version; } public function getAssetsUrl(string $file): string { return plugin_dir_url(__FILE__) . 'assets/' . $file; } public function setHooks(): void { add_action('admin_notices', [$this, 'showWarningAboutInactiveAcfPlugin']); add_action('admin_enqueue_scripts', [$this, 'enqueueAdminScripts']); add_shortcode(Plugin::SHORTCODE, [$this, 'acfViewsShortcode']); } public function showWarningAboutInactiveAcfPlugin(): void { if (is_plugin_active('advanced-custom-fields-pro/acf.php')) { return; } echo 'ACF Views plugin requires an active Advanced Custom Fields PRO plugin.
' . '