├── .gitignore
├── Api
├── App
│ ├── Integration
│ │ ├── TestInterface.php
│ │ └── ThemeInterface.php
│ ├── PostType
│ │ └── PostTypeRetrieverInterface.php
│ ├── ResourceConnection
│ │ └── ConfigRetrieverInterface.php
│ ├── Taxonomy
│ │ └── TaxonomyRetrieverInterface.php
│ ├── Theme
│ │ └── HashProviderInterface.php
│ ├── Url
│ │ └── UrlInterface.php
│ └── View
│ │ └── AssetProviderInterface.php
├── Block
│ └── ShortcodeRendererInterface.php
├── Controller
│ └── Action
│ │ ├── BreadcrumbsDataProviderInterface.php
│ │ └── SeoMetaDataProviderInterface.php
└── Data
│ ├── CspPolicyGeneratorInterface.php
│ ├── MetaDataProviderInterface.php
│ ├── PostCollectionGeneratorInterface.php
│ ├── PostTypeTaxonomyDataSourceInterface.php
│ ├── StoreSwitcherUrlProviderInterface.php
│ └── ViewableModelInterface.php
├── App
├── Api
│ ├── Exception
│ │ └── MissingApiDataException.php
│ ├── IntegrationDataRetriever.php
│ └── Rest
│ │ ├── RequestManager.php
│ │ └── RequestManager
│ │ └── UrlModifier.php
├── Cache.php
├── Debug
│ ├── TestInterface.php
│ ├── TestPool.php
│ └── Tests
│ │ ├── ArchiveTest.php
│ │ ├── BlogInfoTest.php
│ │ ├── CommentsTest.php
│ │ ├── FrontPageTest.php
│ │ ├── IntegrationDataTest.php
│ │ ├── MenuTest.php
│ │ ├── MiscTest.php
│ │ ├── NetworkTest.php
│ │ ├── PluginsTest.php
│ │ ├── PostTest.php
│ │ ├── SearchTest.php
│ │ ├── SidebarTest.php
│ │ ├── TaxonomyTest.php
│ │ ├── ThemeTest.php
│ │ ├── UrlTest.php
│ │ └── UserTest.php
├── DirectoryList.php
├── DirectoryList
│ └── PathResolver.php
├── Exception.php
├── HTTP
│ ├── AuthorisationKey.php
│ ├── Client
│ │ └── Curl.php
│ ├── ClientFactory.php
│ ├── Config.php
│ ├── CurlException.php
│ ├── InvalidStatusException.php
│ ├── PhpErrorExtractor.php
│ ├── RequestManager.php
│ └── RequestManager
│ │ ├── Logger.php
│ │ ├── Logger
│ │ └── Handler.php
│ │ └── UrlModifierInterface.php
├── Integration
│ ├── Exception
│ │ ├── IntegrationFatalException.php
│ │ ├── IntegrationRecoverableException.php
│ │ └── InvalidModeException.php
│ ├── Mode.php
│ ├── Mode
│ │ ├── External
│ │ │ ├── Config.php
│ │ │ └── PathResolver.php
│ │ ├── Local
│ │ │ ├── PathResolver.php
│ │ │ └── WPConfig.php
│ │ └── ObjectResolver.php
│ ├── Tests.php
│ └── Tests
│ │ ├── ApiTest.php
│ │ ├── DatabaseTest.php
│ │ ├── IntegrationTestException.php
│ │ ├── PermalinkTest.php
│ │ ├── ThemeTest.php
│ │ ├── UrlTest.php
│ │ └── YoastTest.php
├── Logger.php
├── Logger
│ └── Handler.php
├── Network.php
├── Option.php
├── Plugin.php
├── PostType.php
├── PostType
│ └── DataRetriever.php
├── RemoteActions.php
├── RemoteActions
│ ├── CacheCleanAction.php
│ ├── CachesCleanTagsAction.php
│ ├── PageCacheCleanModelAction.php
│ └── RemoteActionInterface.php
├── ResourceConnection.php
├── ResourceConnection
│ └── ConfigRetriever.php
├── Taxonomy.php
├── Taxonomy
│ └── DataRetriever.php
├── Theme.php
├── Theme
│ ├── Builder.php
│ ├── Deployer.php
│ ├── Deployment
│ │ ├── HttpUpload.php
│ │ ├── LocalCopy.php
│ │ └── Pool.php
│ ├── DeploymentException.php
│ ├── DeploymentInterface.php
│ ├── FileCollector.php
│ ├── LocalHashProvider.php
│ ├── RemoteHashProvider.php
│ └── Url.php
├── Url.php
├── Url
│ ├── HomeUrlResolver.php
│ ├── MagentoUrl.php
│ ├── Router.php
│ └── SiteUrlResolver.php
├── View
│ ├── AssetProvider.php
│ └── AssetProvider
│ │ ├── AssetCleaner.php
│ │ └── Directives.php
└── WPConfig.php
├── Block
├── AbstractBlock.php
├── AdditionalCss.php
├── Adminhtml
│ ├── Autologin.php
│ ├── Config
│ │ └── Protect.php
│ ├── Form
│ │ └── Renderer
│ │ │ └── Config
│ │ │ └── MagentoBaseUrlSelector.php
│ └── System
│ │ └── Config
│ │ ├── Form
│ │ └── Field
│ │ │ ├── Addon.php
│ │ │ └── GetAddon.php
│ │ └── IntegrationStatus.php
├── Archive
│ └── View.php
├── Catalog
│ └── Product
│ │ └── ListProduct.php
├── Context.php
├── Homepage
│ └── View.php
├── Html
│ └── HeadAdditional.php
├── Post.php
├── Post
│ ├── ListPost.php
│ ├── PostList
│ │ ├── Pager.php
│ │ └── Wrapper
│ │ │ └── AbstractWrapper.php
│ ├── View.php
│ └── View
│ │ ├── Comment
│ │ ├── AbstractComment.php
│ │ ├── Form.php
│ │ ├── Pager.php
│ │ └── Wrapper.php
│ │ └── Comments.php
├── PostType
│ └── View.php
├── Search
│ └── View.php
├── Shortcode.php
├── Sidebar.php
├── Sidebar
│ └── Widget
│ │ ├── AbstractWidget.php
│ │ ├── Archives.php
│ │ ├── Calendar.php
│ │ ├── Categories.php
│ │ ├── Cloud.php
│ │ ├── Comments.php
│ │ ├── CustomHtml.php
│ │ ├── MediaImage.php
│ │ ├── Meta.php
│ │ ├── NavMenu.php
│ │ ├── Pages.php
│ │ ├── Posts.php
│ │ ├── Search.php
│ │ └── Text.php
├── Template.php
├── Term
│ └── View.php
├── User
│ └── View.php
└── Widget
│ └── ListPosts.php
├── Console
└── Command
│ ├── BuildThemePackageCommand.php
│ ├── DebugCommand.php
│ ├── RunTestsCommand.php
│ └── SetOptionCommand.php
├── Controller
├── Action.php
├── Action
│ ├── Context.php
│ └── SeoMetaDataProvider.php
├── Adminhtml
│ ├── Autologin
│ │ └── Index.php
│ └── Theme
│ │ └── Build.php
├── Archive
│ ├── View.php
│ └── View
│ │ ├── BreadcrumbsDataProvider.php
│ │ └── SeoMetaDataProvider.php
├── Find
│ └── Index.php
├── Forwarder
│ └── View.php
├── JsonApi
│ └── View.php
├── Post
│ ├── Comment
│ │ └── Submit.php
│ ├── Password.php
│ ├── Preview.php
│ ├── View.php
│ └── View
│ │ ├── BreadcrumbsDataProvider.php
│ │ └── SeoMetaDataProvider.php
├── PostType
│ ├── View.php
│ └── View
│ │ ├── BreadcrumbsDataProvider.php
│ │ └── SeoMetaDataProvider.php
├── Router.php
├── Router
│ ├── HomepageRouter.php
│ ├── PostRouter.php
│ ├── PostWithCategoryFallbackRouter.php
│ ├── RemoteActionRouter.php
│ ├── RequestDispatcher.php
│ ├── SimpleRouter.php
│ ├── TermRouter.php
│ └── UrlHelper.php
├── Search
│ ├── Index.php
│ ├── View.php
│ └── View
│ │ ├── BreadcrumbsDataProvider.php
│ │ └── SeoMetaDataProvider.php
├── Term
│ ├── View.php
│ └── View
│ │ ├── BreadcrumbsDataProvider.php
│ │ └── SeoMetaDataProvider.php
└── User
│ ├── View.php
│ └── View
│ ├── BreadcrumbsDataProvider.php
│ └── SeoMetaDataProvider.php
├── Helper
├── Autop.php
├── BlogInfo.php
├── Core.php
├── Date.php
└── FrontPage.php
├── Model
├── AbstractMetaModel.php
├── AbstractModel.php
├── Archive.php
├── Config.php
├── Config
│ └── Source
│ │ ├── Logging
│ │ └── HTTP.php
│ │ └── MagentoBaseUrl.php
├── Context.php
├── Csp
│ ├── WhitelistPolicyCollector.php
│ └── WhitelistPolicyGenerator.php
├── Factory.php
├── Homepage.php
├── Image.php
├── Image
│ └── NoSuchSourceFileException.php
├── ImageResizer.php
├── IntegrationManager.php
├── Menu.php
├── Menu
│ └── Item.php
├── MenuRepository.php
├── MetaDataProvider.php
├── NetworkInterface.php
├── OptionManager.php
├── OptionRepository.php
├── Plugin.php
├── PluginManager.php
├── Post.php
├── Post
│ ├── Attachment.php
│ ├── Comment.php
│ ├── MetaDataProvider.php
│ └── PasswordManager.php
├── PostRepository.php
├── PostType.php
├── PostTypeManager.php
├── PostTypeRepository.php
├── Repository
│ ├── AbstractRepository.php
│ ├── DataSourceRepository.php
│ └── ModelRepository.php
├── RepositoryPool.php
├── ResourceConnection.php
├── ResourceModel
│ ├── AbstractResourceModel.php
│ ├── Archive.php
│ ├── Collection
│ │ ├── AbstractCollection.php
│ │ └── Context.php
│ ├── Context.php
│ ├── HierarchicalUrlGenerator.php
│ ├── Image.php
│ ├── Image
│ │ └── Collection.php
│ ├── Menu.php
│ ├── Menu
│ │ ├── Item.php
│ │ └── Item
│ │ │ └── Collection.php
│ ├── Meta
│ │ └── Collection
│ │ │ └── AbstractMetaCollection.php
│ ├── Post.php
│ ├── Post
│ │ ├── Attachment.php
│ │ ├── Attachment
│ │ │ └── Collection.php
│ │ ├── Collection.php
│ │ ├── Comment.php
│ │ ├── Comment
│ │ │ └── Collection.php
│ │ └── Permalink.php
│ ├── PostType.php
│ ├── Taxonomy.php
│ ├── Term.php
│ ├── Term
│ │ └── Collection.php
│ ├── User.php
│ └── User
│ │ └── Collection.php
├── Search.php
├── Session.php
├── ShortcodeManager.php
├── Sitemap
│ ├── ItemProvider.php
│ └── ItemProvider
│ │ ├── AbstractItemProvider.php
│ │ ├── FrontPageItemProvider.php
│ │ ├── PostItemProvider.php
│ │ └── TermItemProvider.php
├── Taxonomy.php
├── TaxonomyManager.php
├── TaxonomyRepository.php
├── Term.php
├── Term
│ └── MetaDataProvider.php
├── TermRepository.php
├── Url.php
├── UrlInterface.php
├── User.php
├── User
│ └── MetaDataProvider.php
├── UserRepository.php
├── WPConfig.php
├── WidgetManager.php
└── WidgetRepository.php
├── Plugin
├── FishPig
│ └── WordPress
│ │ └── Controller
│ │ └── RouterPlugin.php
└── Magento
│ ├── Config
│ └── Model
│ │ └── Config
│ │ └── Structure
│ │ └── Element
│ │ └── SectionPlugin.php
│ ├── Csp
│ └── Model
│ │ └── Collector
│ │ └── CspWhitelistXmlCollectorPlugin.php
│ ├── Framework
│ ├── App
│ │ ├── PageCache
│ │ │ └── IdentifierPlugin.php
│ │ └── Router
│ │ │ └── ActionListPlugin.php
│ └── Controller
│ │ └── ResultPlugin.php
│ └── Store
│ ├── Block
│ └── SwitcherPlugin.php
│ └── ViewModel
│ └── SwitcherUrlProviderPlugin.php
├── README.md
├── changelog
├── composer.json
├── etc
├── adminhtml
│ ├── acl.xml
│ ├── csp_whitelist.xml
│ ├── di.xml
│ ├── menu.xml
│ ├── routes.xml
│ └── system.xml
├── cache.xml
├── config.xml
├── di.xml
├── frontend
│ ├── di.xml
│ └── routes.xml
├── module.xml
└── widget.xml
├── registration.php
├── view
├── adminhtml
│ ├── layout
│ │ ├── adminhtml_system_config_edit.xml
│ │ ├── default.xml
│ │ └── wordpress_autologin_index.xml
│ ├── templates
│ │ ├── autologin.phtml
│ │ ├── integrate.phtml
│ │ └── integration-status.phtml
│ └── web
│ │ ├── css
│ │ └── source
│ │ │ └── _module.less
│ │ └── images
│ │ └── wordpress-logo.png
└── frontend
│ ├── layout
│ ├── wordpress_archive_view.xml
│ ├── wordpress_default.xml
│ ├── wordpress_homepage_view.xml
│ ├── wordpress_page_view.xml
│ ├── wordpress_post_preview.xml
│ ├── wordpress_post_type_view.xml
│ ├── wordpress_post_view.xml
│ ├── wordpress_post_view_default.xml
│ ├── wordpress_post_view_elementor_canvas.xml
│ ├── wordpress_post_view_elementor_header_footer.xml
│ ├── wordpress_post_view_elementor_theme.xml
│ ├── wordpress_post_view_template_1column.xml
│ ├── wordpress_post_view_template_2columns_left.xml
│ ├── wordpress_post_view_template_2columns_right.xml
│ ├── wordpress_post_view_template_empty.xml
│ ├── wordpress_post_view_template_full_width.xml
│ ├── wordpress_search_view.xml
│ ├── wordpress_term_view.xml
│ └── wordpress_user_view.xml
│ ├── templates
│ ├── page
│ │ └── view.phtml
│ ├── post
│ │ ├── list.phtml
│ │ ├── list
│ │ │ ├── renderer
│ │ │ │ ├── custom.phtml
│ │ │ │ └── default.phtml
│ │ │ └── wrapper.phtml
│ │ ├── protected.phtml
│ │ ├── view.phtml
│ │ └── view
│ │ │ ├── comment
│ │ │ ├── form.phtml
│ │ │ └── wrapper.phtml
│ │ │ └── comments.phtml
│ ├── shortcode
│ │ └── product.phtml
│ ├── sidebar.phtml
│ ├── sidebar
│ │ └── widget
│ │ │ ├── archives.phtml
│ │ │ ├── calendar.phtml
│ │ │ ├── categories.phtml
│ │ │ ├── cloud.phtml
│ │ │ ├── comments.phtml
│ │ │ ├── custom-html.phtml
│ │ │ ├── image.phtml
│ │ │ ├── meta.phtml
│ │ │ ├── navmenu.phtml
│ │ │ ├── pages.phtml
│ │ │ ├── posts.phtml
│ │ │ ├── rss.phtml
│ │ │ ├── search.phtml
│ │ │ ├── taxonomy.phtml
│ │ │ ├── taxonomy
│ │ │ └── renderer.phtml
│ │ │ └── text.phtml
│ └── widget
│ │ └── post
│ │ └── list.phtml
│ └── web
│ └── css
│ ├── source
│ └── _module.less
│ └── wordpress.css
└── wptheme
├── 404.php.sample
├── comments.php.sample
├── footer.php.sample
├── functions.php.sample
├── header.php.sample
├── includes
├── api.php.sample
├── authorisation-key.php.sample
├── cors.php.sample
├── fpc.php.sample
├── helper.php.sample
├── misc.php.sample
├── mu-plugins.php.sample
├── previews.php.sample
├── remote-actions.php.sample
├── setup.php.sample
├── theme.php.sample
└── version.php.sample
├── index.php.sample
├── remote-hash.php.sample
├── screenshot.png
├── sidebar.php.sample
├── style.css
├── template-1column.php.sample
├── template-2columns-left.php.sample
├── template-2columns-right.php.sample
├── template-3columns.php.sample
├── template-empty.php.sample
├── template-full-width.php.sample
└── update.flag
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | /wptheme/.git
--------------------------------------------------------------------------------
/Api/App/Integration/TestInterface.php:
--------------------------------------------------------------------------------
1 | url = $url;
25 | }
26 |
27 | /**
28 | * @param string $url
29 | * @return ?string
30 | */
31 | public function modifyUrl(?string $url = null): ?string
32 | {
33 | if ($url === null) {
34 | throw new \FishPig\WordPress\App\Exception('Invalid URL given.');
35 | }
36 |
37 | return $this->url->getRestUrl($url);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/App/Cache.php:
--------------------------------------------------------------------------------
1 | get(self::TYPE_IDENTIFIER),
38 | $tag
39 | );
40 |
41 | try {
42 | if (!$cacheState->isEnabled(self::TYPE_IDENTIFIER)) {
43 | $cacheState->setEnabled(self::TYPE_IDENTIFIER, true);
44 | $cacheState->persist();
45 | }
46 | } catch (\Throwable $e) {
47 | // Ignore
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/App/Debug/TestInterface.php:
--------------------------------------------------------------------------------
1 | blogInfo = $blogInfo;
25 | }
26 |
27 | /**
28 | * @return void
29 | */
30 | public function run(array $options = []): void
31 | {
32 | $this->blogInfo->getBlogName();
33 | $this->blogInfo->getBlogDescription();
34 | $this->blogInfo->isBlogPublic();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/App/Debug/Tests/CommentsTest.php:
--------------------------------------------------------------------------------
1 | commentCollectionFactory = $commentCollectionFactory;
25 | }
26 |
27 | /**
28 | * @return void
29 | */
30 | public function run(array $options = []): void
31 | {
32 | foreach ($this->commentCollectionFactory->create()->load() as $comment) {
33 | $comment->getId();
34 | $comment->getPost();
35 | $comment->getCommentDate('Y/m/d');
36 | $comment->getCommentTime('H:i:s');
37 | $comment->getCommentAuthorUrl();
38 | $comment->getGuid();
39 | $comment->getUrl();
40 | $comment->getCommentPageId();
41 | $comment->getChildrenComments();
42 | $comment->getAvatarUrl();
43 | $comment->isApproved();
44 | $comment->getAnchor();
45 | $comment->getPostTitle();
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/App/Debug/Tests/FrontPageTest.php:
--------------------------------------------------------------------------------
1 | frontPage = $frontPage;
25 | }
26 |
27 | /**
28 | * @return void
29 | */
30 | public function run(array $options = []): void
31 | {
32 | $this->frontPage->getFrontPage();
33 | $this->frontPage->getPostsPage();
34 | $this->frontPage->isFrontPageDefaultPostTypeArchive();
35 | $this->frontPage->isFrontPageStaticPage();
36 | $this->frontPage->getFrontPageId();
37 | $this->frontPage->getPostsPageId();
38 | $this->frontPage->getRealHomepageUrl();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/App/Debug/Tests/IntegrationDataTest.php:
--------------------------------------------------------------------------------
1 | integrationData = $integrationData;
27 | }
28 |
29 | /**
30 | * @return void
31 | */
32 | public function run(array $options = []): void
33 | {
34 | $integrationData = $this->integrationData->getData();
35 |
36 | if (!$integrationData || !is_array($integrationData)) {
37 | throw new \Exception('Integration data is missing.');
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/App/Debug/Tests/MenuTest.php:
--------------------------------------------------------------------------------
1 | menuFactory = $menuFactory;
31 | $this->termCollectionFactory = $termCollectionFactory;
32 | }
33 |
34 | /**
35 | * @return void
36 | */
37 | public function run(array $options = []): void
38 | {
39 | $menus = $this->termCollectionFactory->create()
40 | ->addTaxonomyFilter('nav_menu')
41 | ->setPageSize(1)
42 | ->load();
43 |
44 | if (count($menus) === 0) {
45 | return;
46 | }
47 |
48 | $this->menuFactory->create()
49 | ->load($menus->getFirstItem()->getId())
50 | ->getMenuTreeArray();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/App/Debug/Tests/NetworkTest.php:
--------------------------------------------------------------------------------
1 | network = $network;
25 | }
26 |
27 | /**
28 | * @return void
29 | */
30 | public function run(array $options = []): void
31 | {
32 | $this->network->isEnabled();
33 | $this->network->getBlogId();
34 | $this->network->getSiteId();
35 | $this->network->getNetworkObjects();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/App/Debug/Tests/PluginsTest.php:
--------------------------------------------------------------------------------
1 | pluginManager = $pluginManager;
25 | }
26 |
27 | /**
28 | * @return void
29 | */
30 | public function run(array $options = []): void
31 | {
32 | foreach (['hello.php', 'elementor/elementor.php', 'fake/fake.php'] as $plugin) {
33 | $this->pluginManager->isEnabled($plugin);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/App/Debug/Tests/SidebarTest.php:
--------------------------------------------------------------------------------
1 | widgetRepository = $widgetRepository;
30 | $this->layout = $layout;
31 | }
32 |
33 | /**
34 | *
35 | */
36 | public function run(array $options = []): void
37 | {
38 | if (!isset($options[TestPool::RUN_BLOCK_TESTS]) || $options[TestPool::RUN_BLOCK_TESTS] !== true) {
39 | return;
40 | }
41 |
42 | $this->layout->createBlock(\FishPig\WordPress\Block\Sidebar::class)->toHtml();
43 |
44 | // Widget Blocks
45 | foreach ($this->widgetRepository->getAll() as $widgetName => $widgetClass) {
46 | $this->layout->createBlock($widgetClass)->setWidgetName($widgetName)->setWidgetIndex(1)->toHtml();
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/App/Debug/Tests/ThemeTest.php:
--------------------------------------------------------------------------------
1 | themeTest = $themeTest;
37 | $this->themeBuilder = $themeBuilder;
38 | $this->themeDeployer = $themeDeployer;
39 | }
40 |
41 | /**
42 | * @return void
43 | */
44 | public function run(array $options = []): void
45 | {
46 | // Throws on error
47 | $this->themeBuilder->getBlob();
48 |
49 | // Get theme blob as local file
50 | $localFile = $this->themeBuilder->getLocalFile();
51 |
52 | if (!is_file($localFile)) {
53 | throw new \Exception(
54 | sprintf(
55 | 'Cannot create local theme file at "%s"',
56 | $localFile
57 | )
58 | );
59 | }
60 |
61 | unlink($localFile); // Delete file as it's good to be clean
62 |
63 | $this->themeDeployer->deploy();
64 |
65 | // Check theme version
66 | $this->themeTest->runTest();
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/App/Debug/Tests/UrlTest.php:
--------------------------------------------------------------------------------
1 | url = $url;
24 | }
25 |
26 | /**
27 | * @return void
28 | */
29 | public function run(array $options = []): void
30 | {
31 | $this->url->doUrlsMatch(
32 | $this->url->getSiteUrl(),
33 | $this->url->getHomeUrl()
34 | );
35 |
36 | $this->url->getMagentoUrl();
37 | $this->url->getFront();
38 | $this->url->getHomeUrlWithFront();
39 | $this->url->getHomeUrlWithFront('test');
40 | $this->url->hasTrailingSlash();
41 | $this->url->getBlogRoute();
42 | $this->url->getCurrentUrl();
43 | $this->url->getCurrentUrl(true);
44 | $this->url->getWpContentUrl();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/App/DirectoryList/PathResolver.php:
--------------------------------------------------------------------------------
1 | scopeConfig = $scopeConfig;
25 | }
26 |
27 | /**
28 | *
29 | */
30 | public function getCurlOptionResolve(): ?array
31 | {
32 | if (null === ($value = $this->scopeConfig->getValue('wordpress/http/curlopt_resolve'))) {
33 | return null;
34 | }
35 |
36 | $value = array_filter(array_map(
37 | 'trim',
38 | explode(',', $value)
39 | ));
40 |
41 | if (!$value) {
42 | return null;
43 | }
44 |
45 | return $value;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/App/HTTP/CurlException.php:
--------------------------------------------------------------------------------
1 | 'The URL was not properly formatted.',
21 | 6 => "Couldn't resolve host.",
22 | 7 => 'Failed to connect() to host or proxy.',
23 | 27 => 'A memory allocation request failed.',
24 | 28 => 'Operation timeout.',
25 | 35 => 'A problem occurred somewhere in the SSL/TLS handshake.',
26 | 47 => 'Too many redirects.',
27 | 48 => 'An option passed to libcurl is not recognized/known.',
28 | 51 => "The remote server's SSL certificate or SSH md5 fingerprint was deemed not OK.",
29 | 58 => 'Problem with the local client certificate.'
30 | ];
31 |
32 | return $map[$code] ?? '';
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/App/HTTP/PhpErrorExtractor.php:
--------------------------------------------------------------------------------
1 | (Fatal error|Warning|Notice|Parse error)<\/b>:(.*)\n/Uis',
21 | $str,
22 | $errors
23 | );
24 |
25 | if ($errorMatchResult) {
26 | return array_map(
27 | function ($error, $type) {
28 | return '(' . $type . ') ' . trim($error);
29 | },
30 | $errors[2],
31 | $errors[1]
32 | );
33 | }
34 |
35 | return null;
36 | }
37 |
38 | /**
39 | * @param string $str
40 | * @param string $joiner = ' '
41 | * @return ?string
42 | */
43 | public function getError(string $str, string $joiner = ' '): ?string
44 | {
45 | if ($errors = $this->getErrors($str)) {
46 | return implode($joiner, $errors);
47 | }
48 |
49 | return null;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/App/HTTP/RequestManager/Logger/Handler.php:
--------------------------------------------------------------------------------
1 | setFormatter(new \Monolog\Formatter\LineFormatter("%message%\n", null, true));
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/App/HTTP/RequestManager/UrlModifierInterface.php:
--------------------------------------------------------------------------------
1 | scopeConfig = $scopeConfig;
31 | $this->encryptor = $encryptor;
32 | }
33 |
34 | /**
35 | * @return array
36 | */
37 | public function getDatabaseConfig(): array
38 | {
39 | if ($config = (array)$this->scopeConfig->getValue('wordpress/mode_external_db')) {
40 | if (!empty($config['password'])) {
41 | $config['password'] = $this->encryptor->decrypt($config['password']);
42 | }
43 |
44 | return $config;
45 | }
46 |
47 | return [];
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/App/Integration/Mode/External/PathResolver.php:
--------------------------------------------------------------------------------
1 | scopeConfig = $scopeConfig;
26 | }
27 |
28 | /**
29 | * @param int $storeId
30 | * @return ?string
31 | */
32 | public function getPath(int $storeId): ?string
33 | {
34 | $path = trim(
35 | $this->scopeConfig->getValue(
36 | 'wordpress/setup/path',
37 | \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
38 | $storeId
39 | ) ?? ''
40 | );
41 |
42 | return $path ?? null;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/App/Integration/Mode/Local/WPConfig.php:
--------------------------------------------------------------------------------
1 | wpConfig = $wpConfig;
27 | }
28 |
29 | /**
30 | * @return array
31 | */
32 | public function getDatabaseConfig(): array
33 | {
34 | $dbHost = $this->wpConfig->getData('DB_HOST');
35 |
36 | if (strpos($dbHost, '.sock') !== false) {
37 | $dbHost = str_replace('localhost:/', '/', $dbHost);
38 | }
39 |
40 | return [
41 | 'host' => $dbHost,
42 | 'dbname' => $this->wpConfig->getData('DB_NAME'),
43 | 'username' => $this->wpConfig->getData('DB_USER'),
44 | 'password' => $this->wpConfig->getData('DB_PASSWORD'),
45 | 'charset' => $this->wpConfig->getData('DB_CHARSET', 'utf8mb4'),
46 | 'table_prefix' => $this->wpConfig->getData('DB_TABLE_PREFIX'),
47 | 'ssl' => $this->wpConfig->getData('DB_SSL') || $this->wpConfig->getData('MYSQL_CLIENT_FLAGS')
48 | ];
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/App/Integration/Tests/ApiTest.php:
--------------------------------------------------------------------------------
1 | integrationDataRetriever = $integrationDataRetriever;
28 | }
29 |
30 | /**
31 | * @return void
32 | */
33 | public function runTest(): void
34 | {
35 | try {
36 | if (!($data = $this->integrationDataRetriever->getData())) {
37 | throw new IntegrationFatalException(
38 | 'Unable to contact the WordPress API.'
39 | );
40 | }
41 | } catch (\FishPig\WordPress\App\HTTP\InvalidStatusException $e) {
42 | throw new IntegrationFatalException($e->getMessage(), $e->getCode(), $e);
43 | } catch (\FishPig\WordPress\App\Api\Exception\MissingApiDataException $e) {
44 | throw new IntegrationFatalException($e->getMessage());
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/App/Integration/Tests/DatabaseTest.php:
--------------------------------------------------------------------------------
1 | resourceConnection = $resourceConnection;
26 | }
27 |
28 | /**
29 | * @return void
30 | */
31 | public function runTest(): void
32 | {
33 | $this->resourceConnection->isConnected();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/App/Integration/Tests/IntegrationTestException.php:
--------------------------------------------------------------------------------
1 | option = $option;
27 | }
28 |
29 | /**
30 | * @return void
31 | */
32 | public function runTest(): void
33 | {
34 | $optionName = 'permalink_structure';
35 |
36 | if (!$this->option->get($optionName)) {
37 | $this->option->set($optionName, '/%postname%/');
38 |
39 | if (!$this->option->get($optionName)) {
40 | throw new IntegrationRecoverableException(
41 | sprintf(
42 | 'A custom permalink structure is not set. Set a custom permalink structure in the WP Admin',
43 | 'https://fishpig.co.uk/magento/wordpress-integration/installation/'
44 | )
45 | );
46 | }
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/App/Integration/Tests/ThemeTest.php:
--------------------------------------------------------------------------------
1 | themeDeployer = $themeDeployer;
29 | }
30 |
31 | /**
32 | * @return void
33 | */
34 | public function runTest(): void
35 | {
36 | if (!$this->themeDeployer->isLatestVersion()) {
37 | $this->themeDeployer->deploy();
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/App/Logger.php:
--------------------------------------------------------------------------------
1 | appState = $appState;
32 | parent::__construct($name, $handlers, $processors);
33 | }
34 |
35 | /**
36 | * @return bool
37 | */
38 | public function isDeveloperMode(): bool
39 | {
40 | return $this->appState->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/App/Logger/Handler.php:
--------------------------------------------------------------------------------
1 | optionRepository = $optionRepository;
25 | }
26 |
27 | /**
28 | * @return []
29 | */
30 | public function getActivePlugins(): array
31 | {
32 | return $this->optionRepository->getUnserialized('active_plugins') ?? [];
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/App/RemoteActions/CacheCleanAction.php:
--------------------------------------------------------------------------------
1 | cache = $cache;
25 | }
26 |
27 | /**
28 | * @inheritDoc
29 | */
30 | public function run(array $args = []): ?array
31 | {
32 | if (!empty($args['ids'])) {
33 | foreach ($args['ids'] as $cacheId) {
34 | $this->cache->remove($cacheId);
35 | }
36 | } elseif (!empty($args['tags'])) {
37 | $this->cache->clean(
38 | \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG,
39 | $args['tags']
40 | );
41 | } elseif (!empty($args['flush'])) {
42 | $this->cache->flush();
43 | } else {
44 | return null;
45 | }
46 |
47 | return ['status' => true];
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/App/RemoteActions/RemoteActionInterface.php:
--------------------------------------------------------------------------------
1 | getConfigDefaults(),
20 | (array)$this->getObject()->getDatabaseConfig()
21 | );
22 |
23 | if ($missingFields = array_diff_key($this->getRequiredFields(), $config)) {
24 | throw new \FishPig\WordPress\App\Exception(
25 | 'Missing database configuration fields: ' . implode(', ', array_flip($missingFields))
26 | );
27 | }
28 |
29 | return $config;
30 | }
31 |
32 | /**
33 | * @return []
34 | */
35 | private function getConfigDefaults(): array
36 | {
37 | return [
38 | 'charset' => 'utf8',
39 | ];
40 | }
41 |
42 | /**
43 | * @return []
44 | */
45 | private function getRequiredFields(): array
46 | {
47 | return array_flip(
48 | [
49 | 'host',
50 | 'dbname',
51 | 'username',
52 | 'password',
53 | 'charset',
54 | 'table_prefix',
55 | ]
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/App/Theme/Deployment/Pool.php:
--------------------------------------------------------------------------------
1 | $deployment) {
27 | if (false === ($deployment instanceof DeploymentInterface)) {
28 | throw new \InvalidArgumentException(
29 | sprintf(
30 | 'Deployment "%s" is not an instance of "%s".',
31 | $id,
32 | DeploymentInterface::class
33 | )
34 | );
35 | }
36 | }
37 |
38 | $this->deployments = $deployments;
39 | }
40 |
41 | /**
42 | *
43 | */
44 | public function get(string $id): DeploymentInterface
45 | {
46 | if (!isset($this->deployments[$id])) {
47 | throw new \Magento\Framework\Exception\NoSuchEntityException(
48 | __(
49 | 'The deployment "%1" does not exist.',
50 | $id
51 | )
52 | );
53 | }
54 |
55 | return $this->deployments[$id];
56 | }
57 |
58 | /**
59 | *
60 | */
61 | public function getAll(): array
62 | {
63 | return $this->deployments;
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/App/Theme/DeploymentException.php:
--------------------------------------------------------------------------------
1 | themeFileCollector = $themeFileCollector;
30 | }
31 |
32 | /**
33 | * @return string
34 | */
35 | public function getHash(): string
36 | {
37 | if ($this->hash === null) {
38 | $hashes = [];
39 |
40 | foreach ($this->themeFileCollector->getFiles() as $relative => $file) {
41 | // phpcs:ignore -- not cryptographic
42 | $hashes[] = md5($relative) . '::' . hash_file('md5', $file);
43 | }
44 |
45 | // phpcs:ignore -- not cryptographic
46 | $this->hash = md5(implode('', $hashes));
47 | }
48 |
49 | return $this->hash;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/App/Theme/RemoteHashProvider.php:
--------------------------------------------------------------------------------
1 | optionDataSource = $optionDataSource;
30 | }
31 |
32 | /**
33 | * Retrieve the hash using the option data source directly
34 | * This is used over the OptionRepository so that if the theme hash requires an update
35 | * We can get the hash again without the caching that the OptionRepository adds and check if it's changed
36 | *
37 | * @return string
38 | */
39 | public function getHash(): string
40 | {
41 | return $this->optionDataSource->get(self::OPTION_NAME) ?: '';
42 | }
43 |
44 | /**
45 | *
46 | */
47 | public function update(string $hash): self
48 | {
49 | $this->optionDataSource->set(self::OPTION_NAME, $hash);
50 | return $this;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/App/Theme/Url.php:
--------------------------------------------------------------------------------
1 | urlBuilder = $urlBuilder;
37 | }
38 |
39 | /**
40 | * @return string
41 | */
42 | public function getUrl(): string
43 | {
44 | return $this->urlBuilder->getUrl(
45 | '',
46 | [
47 | '_direct' => self::PATH_INFO
48 | ]
49 | );
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/App/Url/HomeUrlResolver.php:
--------------------------------------------------------------------------------
1 | option = $option;
25 | }
26 |
27 | /**
28 | * @return string
29 | */
30 | public function getUrl(): string
31 | {
32 | return $this->option->get('home');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/App/Url/SiteUrlResolver.php:
--------------------------------------------------------------------------------
1 | optionRepository = $optionRepository;
25 | }
26 |
27 | /**
28 | * @return string
29 | */
30 | public function getUrl(): string
31 | {
32 | return $this->optionRepository->get('siteurl');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Block/Adminhtml/Autologin.php:
--------------------------------------------------------------------------------
1 | getValues()) <= 1) {
20 | return '';
21 | }
22 |
23 | return parent::render($element);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Block/Archive/View.php:
--------------------------------------------------------------------------------
1 | archive === null) {
26 | $this->archive = $this->registry->registry(Archive::ENTITY);
27 | }
28 |
29 | return $this->archive;
30 | }
31 |
32 | /**
33 | * @param Archive $archive
34 | * @return self
35 | */
36 | public function setArchive(Archive $archive): self
37 | {
38 | $this->archive = $archive;
39 | return $this;
40 | }
41 |
42 | /**
43 | * @return \FishPig\WordPress\Model\ResourceModel\Post\Collection
44 | */
45 | protected function getBasePostCollection(): \FishPig\WordPress\Model\ResourceModel\Post\Collection
46 | {
47 | return $this->getArchive()->getPostCollection();
48 | }
49 |
50 | /**
51 | * @deprecated 3.0 use self::getArchive
52 | */
53 | public function getEntity()
54 | {
55 | return $this->getArchive();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Block/Homepage/View.php:
--------------------------------------------------------------------------------
1 | getRequest()->getParam('page', 1) === 1;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Block/Post/View.php:
--------------------------------------------------------------------------------
1 | getPost()) {
17 | return false;
18 | }
19 |
20 | $this->getPost()->getContent();
21 |
22 | if (!$this->getTemplate()) {
23 | $postType = $this->getPost()->getTypeInstance();
24 | $this->setTemplate('FishPig_WordPress::post/view.phtml');
25 |
26 | if ($postType->getPostType() !== 'post') {
27 | $postTypeTemplate = 'FishPig_WordPress::' . $postType->getPostType() . '/view.phtml';
28 |
29 | if ($this->getTemplateFile($postTypeTemplate)) {
30 | $this->setTemplate($postTypeTemplate);
31 | }
32 | }
33 | }
34 |
35 | return parent::_beforeToHtml();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/Block/Post/View/Comment/Wrapper.php:
--------------------------------------------------------------------------------
1 | getTemplate()) {
19 | $this->setTemplate('FishPig_WordPress::post/view/comment/wrapper.phtml');
20 | }
21 |
22 | if ($this->getCommentCount() > 0 && ($commentsBlock = $this->getChildBlock('comment_list')) !== false) {
23 | $commentsBlock->setComments($this->getComments());
24 | }
25 |
26 | if ($this->getCommentCount() > 0 && ($pagerBlock = $this->getChildBlock('pager')) !== false) {
27 | $pagerBlock->setPost($this->getPost());
28 | $pagerBlock->setCollection($this->getComments());
29 | }
30 |
31 | if (($form = $this->getChildBlock('form')) !== false) {
32 | $form->setPost($this->getPost());
33 | }
34 |
35 | parent::_beforeToHtml();
36 | }
37 |
38 | /**
39 | * Get the comments HTML
40 | *
41 | * @return string
42 | */
43 | public function getCommentsHtml()
44 | {
45 | return $this->getChildHtml('comment_list');
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/Block/Post/View/Comments.php:
--------------------------------------------------------------------------------
1 |
6 | */
7 | namespace FishPig\WordPress\Block\Post\View;
8 |
9 | class Comments extends \FishPig\WordPress\Block\Post\View\Comment\AbstractComment
10 | {
11 | /**
12 | * Setup the pager and comments form blocks
13 | */
14 | protected function _beforeToHtml()
15 | {
16 | if (!$this->getTemplate()) {
17 | $this->setTemplate('FishPig_WordPress::post/view/comments.phtml');
18 | }
19 |
20 | if ($this->getCommentCount() > 0 && ($pagerBlock = $this->getChildBlock('pager')) !== false) {
21 | $pagerBlock->setCollection($this->getComments());
22 | }
23 |
24 | if (($form = $this->getChildBlock('form')) !== false) {
25 | $form->setPost($this->getPost());
26 | }
27 |
28 | parent::_beforeToHtml();
29 | }
30 |
31 | /**
32 | * Get the HTML of the child comments
33 | *
34 | * @param \FishPig\WordPress\Model\Post\Comment $comment
35 | * @return string
36 | */
37 | public function getChildrenCommentsHtml(\FishPig\WordPress\Model\Post\Comment $comment)
38 | {
39 | return $this->getLayout()
40 | ->createBlock(get_class($this))
41 | ->setTemplate($this->getTemplate())
42 | ->setParentId($comment->getId())
43 | ->setComments($comment->getChildrenComments())
44 | ->toHtml();
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Block/Shortcode.php:
--------------------------------------------------------------------------------
1 | shortcodeRendererPool = $shortcodeRendererPool;
28 | parent::__construct($context, $data);
29 | }
30 |
31 | /**
32 | * @return string
33 | */
34 | protected function _toHtml()
35 | {
36 | if (!$this->_beforeToHtml()) {
37 | return '';
38 | }
39 |
40 | if (!($shortcode = $this->getShortcode())) {
41 | return '';
42 | }
43 |
44 | foreach ($this->shortcodeRendererPool as $shortcodeRenderer) {
45 | if ($shortcodeRenderer instanceof \FishPig\WordPress\Api\Block\ShortcodeRendererInterface) {
46 | $shortcode = $shortcodeRenderer->render($shortcode, $this->getCallback() ?: null);
47 | }
48 | }
49 |
50 | return $shortcode;
51 | }
52 |
53 | /**
54 | * @return string
55 | */
56 | public function getShortcode(): string
57 | {
58 | return str_replace("\\\"", '"', (string)$this->getData('shortcode'));
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Block/Sidebar/Widget/CustomHtml.php:
--------------------------------------------------------------------------------
1 | getTemplate()) {
27 | $this->setTemplate('FishPig_WordPress::sidebar/widget/custom-html.phtml');
28 | }
29 |
30 | return parent::_beforeToHtml();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Block/Sidebar/Widget/MediaImage.php:
--------------------------------------------------------------------------------
1 |
6 | */
7 | namespace FishPig\WordPress\Block\Sidebar\Widget;
8 |
9 | class MediaImage extends AbstractWidget
10 | {
11 | /**
12 | * Retrieve the default title
13 | *
14 | * @return string
15 | */
16 | public function getDefaultTitle()
17 | {
18 | return false;
19 | }
20 |
21 | /**
22 | * @return $this
23 | */
24 | protected function _beforeToHtml()
25 | {
26 | if (!$this->getTemplate()) {
27 | $this->setTemplate('FishPig_WordPress::sidebar/widget/image.phtml');
28 | }
29 |
30 | return parent::_beforeToHtml();
31 | }
32 |
33 | /**
34 | * @return string
35 | */
36 | public function getLinkUrl()
37 | {
38 | return $this->getData('link_url');
39 | }
40 |
41 | /**
42 | * @return string
43 | */
44 | public function getImageUrl()
45 | {
46 | return $this->getData('url');
47 | }
48 |
49 | /**
50 | * @return string
51 | */
52 | public function getLinkTarget()
53 | {
54 | foreach (['link_target', 'linktarget'] as $key) {
55 | if ($value = $this->getData($key)) {
56 | return $value;
57 | }
58 | }
59 |
60 | if ($this->getData('link_target_blank')) {
61 | return 'blank';
62 | }
63 |
64 | return '';
65 | }
66 |
67 | /**
68 | * @return string
69 | */
70 | public function getCaption()
71 | {
72 | return $this->getData('caption');
73 | }
74 |
75 | /**
76 | * @return string
77 | */
78 | public function getImageAlt()
79 | {
80 | return $this->getData('alt');
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Block/Sidebar/Widget/Meta.php:
--------------------------------------------------------------------------------
1 |
6 | */
7 | namespace FishPig\WordPress\Block\Sidebar\Widget;
8 |
9 | class Meta extends AbstractWidget
10 | {
11 | /**
12 | * Retrieve the default title
13 | *
14 | * @return string
15 | */
16 | public function getDefaultTitle()
17 | {
18 | return __('Meta');
19 | }
20 |
21 | protected function _beforeToHtml()
22 | {
23 | if (!$this->getTemplate()) {
24 | $this->setTemplate('FishPig_WordPress::sidebar/widget/meta.phtml');
25 | }
26 |
27 | return parent::_beforeToHtml();
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Block/Sidebar/Widget/Search.php:
--------------------------------------------------------------------------------
1 | searchModel = $searchModel;
26 | parent::__construct($context, $wpContext, $data);
27 | }
28 | /**
29 | * Retrieve the action URL for the search form
30 | *
31 | * @return string
32 | */
33 | public function getFormActionUrl()
34 | {
35 | return $this->_urlBuilder->getUrl('wordpress/search');
36 | }
37 |
38 | /**
39 | * Retrieve the default title
40 | *
41 | * @return string
42 | */
43 | public function getDefaultTitle()
44 | {
45 | return __('Search');
46 | }
47 |
48 | /**
49 | * Retrieve the search term used
50 | *
51 | * @return string
52 | */
53 | public function getSearchTerm()
54 | {
55 | return $this->searchModel->getSearchTerm();
56 | }
57 |
58 | /**
59 | * Ensure template is set
60 | *
61 | * @return string
62 | */
63 | protected function _beforeToHtml()
64 | {
65 | if (!$this->getTemplate()) {
66 | $this->setTemplate('FishPig_WordPress::sidebar/widget/search.phtml');
67 | }
68 |
69 | return parent::_beforeToHtml();
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Block/Sidebar/Widget/Text.php:
--------------------------------------------------------------------------------
1 | getTemplate()) {
23 | $this->setTemplate('FishPig_WordPress::sidebar/widget/text.phtml');
24 | }
25 |
26 | return parent::_beforeToHtml();
27 | }
28 |
29 | /**
30 | * @return string
31 | */
32 | public function getWidgetText()
33 | {
34 | return $this->renderShortcode($this->getData('text'));
35 | }
36 |
37 | /**
38 | * @return string
39 | */
40 | public function getText()
41 | {
42 | return $this->getWidgetText();
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/Block/Template.php:
--------------------------------------------------------------------------------
1 | term === null) {
26 | $this->term = $this->registry->registry(Term::ENTITY) ?? false;
27 | }
28 |
29 | return $this->term;
30 | }
31 |
32 | /**
33 | * @param Term $term
34 | * @return self
35 | */
36 | public function setTerm(Term $term): self
37 | {
38 | $this->term = $term;
39 | return $this;
40 | }
41 |
42 | /**
43 | * @return \FishPig\WordPress\Model\ResourceModel\Post\Collection
44 | */
45 | protected function getBasePostCollection(): \FishPig\WordPress\Model\ResourceModel\Post\Collection
46 | {
47 | return $this->getTerm()->getPostCollection();
48 | }
49 |
50 | /**
51 | * @return string
52 | */
53 | public function getDescription(): string
54 | {
55 | return (string)$this->getTerm()->getDescription();
56 | }
57 |
58 | /**
59 | * @deprecated 3.0 use self::getTerm
60 | */
61 | public function getEntity()
62 | {
63 | return $this->getTerm();
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/Block/User/View.php:
--------------------------------------------------------------------------------
1 | user === null) {
24 | $this->user = $this->registry->registry(\FishPig\WordPress\Model\User::ENTITY) ?? false;
25 | }
26 |
27 | return $this->user;
28 | }
29 |
30 | /**
31 | * @param \FishPig\WordPress\Model\User $user
32 | * @return self
33 | */
34 | public function setUser(\FishPig\WordPress\Model\User $user): self
35 | {
36 | $this->user = $user;
37 | return $this;
38 | }
39 |
40 | /**
41 | * @return \FishPig\WordPress\Model\ResourceModel\Post\Collection
42 | */
43 | protected function getBasePostCollection(): \FishPig\WordPress\Model\ResourceModel\Post\Collection
44 | {
45 | return $this->getUser()->getPostCollection();
46 | }
47 |
48 | /**
49 | * @deprecated 3.0 use self::getUser
50 | */
51 | public function getEntity()
52 | {
53 | return $this->getUser();
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Controller/Action/Context.php:
--------------------------------------------------------------------------------
1 | registry = $registry;
42 | $this->url = $url;
43 | $this->logger = $logger;
44 | }
45 |
46 | /**
47 | * @return Registry
48 | */
49 | public function getRegistry(): Registry
50 | {
51 | return $this->registry;
52 | }
53 |
54 | /**
55 | * @return UrlInterface
56 | */
57 | public function getUrl(): UrlInterface
58 | {
59 | return $this->url;
60 | }
61 |
62 | /**
63 | * @return Logger
64 | */
65 | public function getLogger(): Logger
66 | {
67 | return $this->logger;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Autologin/Index.php:
--------------------------------------------------------------------------------
1 | resultFactory->create(
22 | $this->resultFactory::TYPE_PAGE
23 | );
24 |
25 | $resultPage->setActiveMenu('FishPig_WordPress::wordpress');
26 | $resultPage->getConfig()->getTitle()->prepend(__('WordPress Admin - Auto Login'));
27 |
28 | return $resultPage;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Controller/Adminhtml/Theme/Build.php:
--------------------------------------------------------------------------------
1 | ';
32 | echo 'bin/magento fishpig:wordpress:theme --zip';
33 | exit;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Controller/Archive/View/BreadcrumbsDataProvider.php:
--------------------------------------------------------------------------------
1 | [
22 | 'label' => __($archive->getName()),
23 | 'title' => __($archive->getName())
24 | ]
25 | ];
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Controller/Archive/View/SeoMetaDataProvider.php:
--------------------------------------------------------------------------------
1 | setMetaTitleWithBlogName($archive->getName());
25 | $this->setPageTitle($archive->getName());
26 | $this->setCanonicalUrl($archive->getUrl());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Controller/JsonApi/View.php:
--------------------------------------------------------------------------------
1 | url = $url;
26 | parent::__construct($context);
27 | }
28 |
29 | /**
30 | *
31 | */
32 | public function execute()
33 | {
34 | $restUrl = $this->url->getRestUrl(
35 | $this->getRequest()->getParam('json_route_data') ?: '/'
36 | );
37 |
38 | return $this->resultFactory->create(
39 | $this->resultFactory::TYPE_REDIRECT
40 | )->setUrl(
41 | $restUrl
42 | )->setHttpResponseCode(
43 | 302
44 | );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Controller/Post/Password.php:
--------------------------------------------------------------------------------
1 | postRepository = $postRepository;
32 | $this->postPasswordManager = $postPasswordManager;
33 | parent::__construct($context);
34 | }
35 |
36 | /**
37 | * @return void
38 | */
39 | public function execute()
40 | {
41 | try {
42 | $post = $this->postRepository->get(
43 | (int)$this->getRequest()->getPost('post')
44 | );
45 | } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
46 | return $this->_forward('noRoute');
47 | }
48 |
49 | $this->postPasswordManager->setPostPassword(
50 | $this->getRequest()->getPost('post_password', null)
51 | );
52 |
53 | return $this->resultFactory->create(
54 | $this->resultFactory::TYPE_REDIRECT
55 | )->setUrl(
56 | $post->getUrl()
57 | )->setHttpResponseCode(
58 | 302
59 | );
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Controller/Post/Preview.php:
--------------------------------------------------------------------------------
1 | factory->create('Post')->load(
19 | (int)$this->getRequest()->getParam('preview_id')
20 | );
21 |
22 | if (!$post->getId()) {
23 | return false;
24 | }
25 |
26 | return $post;
27 | // return ($revision = $post->getLatestRevision()) ? $revision : $post;
28 | }
29 |
30 | /**
31 | * @return false
32 | */
33 | protected function _getForward()
34 | {
35 | return false;
36 | }
37 |
38 | /**
39 | * @return false
40 | */
41 | protected function _canPreview()
42 | {
43 | return false;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Controller/Post/View/SeoMetaDataProvider.php:
--------------------------------------------------------------------------------
1 | setMetaTitleWithBlogName($post->getName());
25 | $this->setCanonicalUrl($post->getUrl());
26 | $this->setPageTitle($post->getName());
27 |
28 | if ($description = $post->getPostExcerpt(32)) {
29 | $this->setMetaDescription($description);
30 | } elseif ($description = strip_tags($post->getContent())) {
31 | if (strlen($description) > 250) {
32 | $description = rtrim(substr($description, 0, 250));
33 | }
34 | $this->setMetaDescription($description);
35 | }
36 |
37 | if (!$post->isPublic()) {
38 | $this->setRobots('NOINDEX,NOFOLLOW');
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Controller/PostType/View/BreadcrumbsDataProvider.php:
--------------------------------------------------------------------------------
1 | isFrontPage()) {
22 | return $crumbs;
23 | }
24 |
25 | if ($postType->getPostType() === 'post') {
26 | $crumbs['post'] = [
27 | 'label' => __('Blog'),
28 | ];
29 | } else {
30 | $crumbs['post'] = [
31 | 'label' => __($postType->getName()),
32 | ];
33 | }
34 |
35 | return $crumbs;
36 | }
37 |
38 | /**
39 | * @param string $slugPart
40 | * @param \FishPig\WordPress\Model\PostType $postType
41 | * @return bool
42 | */
43 | private function isPostTypeBaseSlug(string $slugPart, \FishPig\WordPress\Model\PostType $postType): bool
44 | {
45 | if ($slugPart === $postType->getPostType()) {
46 | return true;
47 | }
48 |
49 | if ($postType->getArchiveSlug()) {
50 | return trim($postType->getArchiveSlug(), '/') === $slugPart;
51 | }
52 |
53 | return false;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Controller/PostType/View/SeoMetaDataProvider.php:
--------------------------------------------------------------------------------
1 | getPostType() === 'post') {
25 | $blogName = $this->getBlogInfo()->getBlogName();
26 |
27 | $this->setMetaTitle($blogName);
28 | $this->setPageTitle($blogName);
29 | $this->setCanonicalUrl($postType->getUrl());
30 | } else {
31 | $this->setPageTitle($postType->getName());
32 | $this->setCanonicalUrl($postType->getUrl());
33 |
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Controller/Router/RemoteActionRouter.php:
--------------------------------------------------------------------------------
1 | remoteActions = $remoteActions;
25 | }
26 |
27 | /**
28 | * @param \Magento\Framework\App\RequestInterface $request
29 | */
30 | public function match(\Magento\Framework\App\RequestInterface $request)
31 | {
32 | $this->remoteActions->listenAndExecute();
33 | return false;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Controller/Search/Index.php:
--------------------------------------------------------------------------------
1 | searchFactory = $searchFactory;
34 | $this->wpUrl = $wpUrl;
35 | }
36 |
37 | /**
38 | * @return
39 | */
40 | public function execute()
41 | {
42 | if (!($redirectUrl = $this->searchFactory->create()->getUrl())) {
43 | $redirectUrl = $this->wpUrl->getHomeUrl();
44 | }
45 |
46 | return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)
47 | ->setUrl($redirectUrl);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Controller/Search/View/BreadcrumbsDataProvider.php:
--------------------------------------------------------------------------------
1 | [
21 | 'label' => __($search->getSearchTerm()),
22 | ]
23 | ];
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Controller/Search/View/SeoMetaDataProvider.php:
--------------------------------------------------------------------------------
1 | getName();
25 |
26 | $this->setMetaTitleWithBlogName($searchName);
27 | $this->setPageTitle($searchName);
28 | $this->setCanonicalUrl($search->getUrl());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Controller/Term/View/SeoMetaDataProvider.php:
--------------------------------------------------------------------------------
1 | setMetaTitleWithBlogName($term->getName());
25 | $this->setPageTitle($term->getName());
26 | $this->setCanonicalUrl($term->getUrl());
27 |
28 | if ($description = $term->getDescription()) {
29 | $this->setMetaDescription($description);
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Controller/User/View/BreadcrumbsDataProvider.php:
--------------------------------------------------------------------------------
1 | [
21 | 'label' => __($user->getName()),
22 | 'title' => __($user->getName())
23 | ]
24 | ];
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Controller/User/View/SeoMetaDataProvider.php:
--------------------------------------------------------------------------------
1 | setMetaTitleWithBlogName($user->getName());
25 | $this->setCanonicalUrl($user->getUrl());
26 | $this->setPageTitle($user->getName());
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Helper/Autop.php:
--------------------------------------------------------------------------------
1 | optionRepository = $optionRepository;
26 | parent::__construct($context);
27 | }
28 |
29 | /**
30 | * @return string
31 | */
32 | public function getBlogName(): string
33 | {
34 | return $this->optionRepository->get('blogname', '');
35 | }
36 |
37 | /**
38 | * @return string
39 | */
40 | public function getBlogDescription(): string
41 | {
42 | return $this->optionRepository->get('blogdescription', '');
43 | }
44 |
45 | /**
46 | * @return bool
47 | */
48 | public function isBlogPublic(): bool
49 | {
50 | return (bool)$this->optionRepository->get('blog_public') ?? false;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Helper/Core.php:
--------------------------------------------------------------------------------
1 | metaDataProvider = $metaDataProvider;
31 | parent::__construct($context, $registry, $wpContext, $resource, $resourceCollection, $data);
32 | }
33 |
34 | /**
35 | * @param string $key
36 | * @param mixed $default = null
37 | * @return mixed
38 | */
39 | public function getMetaValue(string $key, $default = null)
40 | {
41 | return $this->metaDataProvider->getValue($this, $key) ?? $default;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Model/AbstractModel.php:
--------------------------------------------------------------------------------
1 | url = $wpContext->getUrl();
48 | parent::__construct($context, $registry, $resource, $resourceCollection);
49 | }
50 |
51 | /**
52 | * @return int
53 | */
54 | public function getId()
55 | {
56 | return (int)parent::getId();
57 | }
58 |
59 | /**
60 | * @retur array
61 | */
62 | public function getIdentities()
63 | {
64 | return [
65 | self::CACHE_TAG_WP,
66 | static::CACHE_TAG . '_' . $this->getId()
67 | ];
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Model/Config.php:
--------------------------------------------------------------------------------
1 | scopeConfig = $scopeConfig;
25 | }
26 |
27 | /**
28 | * @return bool
29 | */
30 | public function isThemeIntegrationEnabled(): bool
31 | {
32 | return $this->scopeConfig->isSetFlag('wordpress/setup/theme_integration');
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Model/Config/Source/Logging/HTTP.php:
--------------------------------------------------------------------------------
1 | 'Enabled',
25 | self::REDUCE => 'Reduce (Only Errors)',
26 | self::DISABLED => 'Disabled'
27 | ];
28 |
29 | /**
30 | * @return array
31 | */
32 | public function toOptionArray()
33 | {
34 | $options = [];
35 |
36 | foreach ($this->getOptions() as $value => $label) {
37 | $options[] = [
38 | 'value' => $value,
39 | 'label' => $label
40 | ];
41 | }
42 |
43 | return $options;
44 | }
45 |
46 | /**
47 | * @return array
48 | */
49 | public function getOptions(): array
50 | {
51 | return $this->options;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Model/Csp/WhitelistPolicyGenerator.php:
--------------------------------------------------------------------------------
1 | url = $url;
25 | }
26 |
27 | /**
28 | * @return array
29 | */
30 | public function getData(): array
31 | {
32 | $data = [
33 | $this->getDomain() => true
34 | ];
35 |
36 | return $data;
37 | }
38 |
39 | /**
40 | * @return string
41 | */
42 | private function getDomain(): string
43 | {
44 | $wpDomain = rtrim(
45 | str_replace(
46 | ['https://', 'http://'],
47 | '',
48 | $this->url->getSiteUrl()
49 | ),
50 | '/');
51 |
52 | if (($pos = strpos($wpDomain, '/')) !== false) {
53 | $wpDomain = substr($wpDomain, 0, $pos);
54 | }
55 |
56 | return $wpDomain;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Model/Homepage.php:
--------------------------------------------------------------------------------
1 | frontPage = $frontPage;
23 | }
24 |
25 | /**
26 | * @return
27 | */
28 | public function getFrontStaticPage()
29 | {
30 | return $this->frontPage->getFrontPage();
31 | }
32 |
33 | /**
34 | * @return int|false
35 | */
36 | public function getFrontPageId()
37 | {
38 | return $this->frontPage->getFrontPageId();
39 | }
40 |
41 | /**
42 | * @return int|false
43 | */
44 | public function getPageForPostsId()
45 | {
46 | return $this->frontPage->getPostsPageId();
47 | }
48 |
49 | /**
50 | * @return string
51 | */
52 | public function getRealHomepageUrl()
53 | {
54 | return $this->frontPage->getRealHomepageUrl();
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Model/Image/NoSuchSourceFileException.php:
--------------------------------------------------------------------------------
1 | integrationTests = $integrationTests;
22 | }
23 |
24 | /**
25 | * @return
26 | */
27 | public function runTests()
28 | {
29 | return $this->integrationTests->runTests();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Model/NetworkInterface.php:
--------------------------------------------------------------------------------
1 | optionRepository = $optionRepository;
23 | }
24 |
25 | /**
26 | *
27 | */
28 | public function getOption($key)
29 | {
30 | return $this->optionRepository->get($key);
31 | }
32 |
33 | /**
34 | *
35 | */
36 | public function optionExists($key)
37 | {
38 | return $this->optionRepository->exists($key);
39 | }
40 |
41 | /**
42 | *
43 | */
44 | public function setOption($key, $value)
45 | {
46 | return $this->optionRepository->set($key, $value);
47 | }
48 |
49 | /**
50 | * @param string $key
51 | * @return mixed
52 | */
53 | public function getSiteOption($key)
54 | {
55 | return false;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Model/PluginManager.php:
--------------------------------------------------------------------------------
1 | dataSource = $dataSource;
25 | }
26 |
27 | /**
28 | * @param string $name
29 | * @return bool
30 | */
31 | public function isEnabled(string $pluginName): bool
32 | {
33 | return in_array($pluginName, $this->dataSource->getActivePlugins());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Model/Post/MetaDataProvider.php:
--------------------------------------------------------------------------------
1 | objectFactory = $objectFactory;
29 | parent::__construct($storeManager, $idFieldName);
30 | }
31 |
32 | /**
33 | * @param int $id
34 | * @param array|string $types
35 | * @return FishPig\WordPress\Model\Post
36 | */
37 | public function getWithType($id, $types)
38 | {
39 | $post = $this->get($id);
40 |
41 | if (!in_array('*', (array)$types) && !in_array($post->getPostType(), (array)$types)) {
42 | throw new NoSuchEntityException(
43 | __(
44 | 'The WordPress post exits but failed the type check. ID is %1, type is %2',
45 | $post->getId(),
46 | $post->getPostType()
47 | )
48 | );
49 | }
50 |
51 | return $post;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Model/PostTypeManager.php:
--------------------------------------------------------------------------------
1 | postTypeRepository = $postTypeRepository;
22 | }
23 |
24 | /**
25 | * @return false|PostType
26 | */
27 | public function getPostType($type = null)
28 | {
29 | return $this->postTypeRepository->get($type);
30 | }
31 |
32 | /**
33 | * @return array
34 | */
35 | public function getPostTypes(): array
36 | {
37 | return $this->postTypeRepository->getAll();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Model/PostTypeRepository.php:
--------------------------------------------------------------------------------
1 | objectFactory = $objectFactory;
22 | parent::__construct($dataSource, $storeManager);
23 | }
24 |
25 | /**
26 | *
27 | */
28 | public function getPublic(): array
29 | {
30 | $types = [];
31 | foreach ($this->getAll() as $index => $postType) {
32 | if ($postType->isPublic()) {
33 | $types[$index] = $postType;
34 | }
35 | }
36 | return $types;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/Model/Repository/AbstractRepository.php:
--------------------------------------------------------------------------------
1 | objectFactory === null) {
29 | throw new \Magento\Framework\Exception\RuntimeException(
30 | __('Object factory not set in %1.', get_class($this))
31 | );
32 | }
33 |
34 | return $this->objectFactory;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Model/RepositoryPool.php:
--------------------------------------------------------------------------------
1 | $repository) {
32 | if ($repository instanceof AbstractRepository) {
33 | $this->pool[$id] = $repository;
34 | }
35 | }
36 | }
37 |
38 | /**
39 | * @return ?AbstractRepository
40 | */
41 | public function get(string $id): ?AbstractRepository
42 | {
43 | if ($id === 'post_type') {
44 | $id = 'postType';
45 | }
46 |
47 | return isset($this->pool[$id]) ? $this->pool[$id] : null;
48 | }
49 |
50 | /**
51 | * @return []
52 | */
53 | public function getAll(): array
54 | {
55 | return $this->pool;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Model/ResourceConnection.php:
--------------------------------------------------------------------------------
1 | resourceConnection = $resourceConnection;
23 | }
24 |
25 | /**
26 | * @param string $alias
27 | * @param bool $canBeUsedInNetwork = true
28 | * @return string
29 | */
30 | public function getTable($alias, bool $canBeUsedInNetwork = true)
31 | {
32 | return $this->resourceConnection->getTable($alias, $canBeUsedInNetwork);
33 | }
34 |
35 | /**
36 | * @param string $alias
37 | * @return string
38 | */
39 | public function getTableName($alias)
40 | {
41 | return $this->getTable($alias);
42 | }
43 |
44 | /**
45 | * @return bool
46 | */
47 | public function isConnected()
48 | {
49 | return $this->resourceConnection->isConnected();
50 | }
51 |
52 | /**
53 | *
54 | *
55 | * @return
56 | */
57 | public function getConnection()
58 | {
59 | return $this->resourceConnection->getConnection();
60 | }
61 |
62 | /**
63 | * @return
64 | */
65 | public function getTablePrefix()
66 | {
67 | return $this->resourceConnection->getTablePrefix();
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Archive.php:
--------------------------------------------------------------------------------
1 | _init('posts', 'ID');
19 | }
20 |
21 | /**
22 | * @return array
23 | */
24 | public function getDatesForWidget()
25 | {
26 | return $this->getConnection()->fetchAll(
27 | $this->getDatesForWidgetSelect()
28 | );
29 | }
30 |
31 | /**
32 | * @return \Magento\Framework\DB\Select
33 | */
34 | public function getDatesForWidgetSelect()
35 | {
36 | return $this->getConnection()
37 | ->select()
38 | ->from(
39 | ['main_table' => $this->getMainTable()],
40 | [
41 | 'post_count' => new \Zend_Db_Expr('COUNT(ID)'),
42 | 'archive_date' => new \Zend_Db_Expr(
43 | "CONCAT(SUBSTRING(post_date, 1, 4), '/', SUBSTRING(post_date, 6, 2))"
44 | )
45 | ]
46 | )->where(
47 | 'main_table.post_type=?',
48 | 'post'
49 | )->where(
50 | 'post_status = ?',
51 | 'publish'
52 | )->group(
53 | 'archive_date'
54 | )->order(
55 | 'archive_date DESC'
56 | );
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Collection/Context.php:
--------------------------------------------------------------------------------
1 | logger = $logger;
31 | $this->optionRepository = $optionRepository;
32 | }
33 |
34 | /**
35 | * @return Logger
36 | */
37 | public function getLogger(): \FishPig\WordPress\App\Logger
38 | {
39 | return $this->logger;
40 | }
41 |
42 | /**
43 | * @return \FishPig\WordPress\Model\OptionRepository
44 | */
45 | public function getOptionRepository(): \FishPig\WordPress\Model\OptionRepository
46 | {
47 | return $this->optionRepository;
48 | }
49 |
50 | /**
51 | * @return \FishPig\WordPress\Model\OptionRepository
52 | */
53 | public function getOption(): \FishPig\WordPress\Model\OptionRepository
54 | {
55 | return $this->getOptionRepository();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Image.php:
--------------------------------------------------------------------------------
1 |
6 | */
7 | namespace FishPig\WordPress\Model\ResourceModel;
8 |
9 | use FishPig\WordPress\Model\ResourceModel\Post\Attachment\AbstractAttachmentResource;
10 |
11 | class Image extends \FishPig\WordPress\Model\ResourceModel\Post\Attachment
12 | {
13 | public function isImagePostName($postName)
14 | {
15 | $select = $this->_getReadAdapter()
16 | ->select()
17 | ->from($this->getMainTable(), 'ID')
18 | ->where('post_type=?', 'attachment')
19 | ->where('post_name=?', $postName)
20 | ->limit(1);
21 |
22 | return $this->_getReadAdapter()->fetchOne($select);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Image/Collection.php:
--------------------------------------------------------------------------------
1 |
6 | */
7 | namespace FishPig\WordPress\Model\ResourceModel\Image;
8 |
9 | use FishPig\WordPress\Model\ResourceModel\Post\Attachment\Collection\AbstractAttachmentCollection;
10 |
11 | class Collection extends \FishPig\WordPress\Model\ResourceModel\Post\Attachment\Collection
12 | {
13 | /**
14 | * Load an image
15 | * Ensure that only images are returned
16 | *
17 | * @param bool $printQuery
18 | * @param bool $logQuery
19 | * @return $this
20 | */
21 | public function load($printQuery = false, $logQuery = false)
22 | {
23 | $this->getSelect()->where("post_mime_type LIKE 'image%'");
24 |
25 | return parent::load($printQuery, $logQuery);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Menu.php:
--------------------------------------------------------------------------------
1 | _init('posts', 'ID');
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Post/Attachment.php:
--------------------------------------------------------------------------------
1 | _init('posts', 'ID');
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Post/Attachment/Collection.php:
--------------------------------------------------------------------------------
1 | getSelect()
24 | ->where("post_type = ?", 'attachment')
25 | ->where("post_mime_type LIKE 'image%'");
26 |
27 | return parent::load($printQuery, $logQuery);
28 | }
29 |
30 | /**
31 | * Set the parent ID
32 | *
33 | * @param int $parentId = 0
34 | * @return $this
35 | */
36 | public function setParent($parentId = 0)
37 | {
38 | $this->getSelect()->where("post_parent = ?", $parentId);
39 |
40 | return $this;
41 | }
42 |
43 | /**
44 | * After loading the collection, unserialize data
45 | *
46 | * @return $this
47 | */
48 | protected function _afterLoad()
49 | {
50 | parent::_afterLoad();
51 |
52 | foreach ($this->_items as $item) {
53 | $item->loadSerializedData();
54 | }
55 |
56 | return $this;
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Model/ResourceModel/Post/Comment.php:
--------------------------------------------------------------------------------
1 | _init('comments', 'comment_ID');
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Model/ResourceModel/User.php:
--------------------------------------------------------------------------------
1 | _init('users', 'ID');
19 | }
20 |
21 | /**
22 | * @return string
23 | */
24 | public function getMainTable()
25 | {
26 | if (empty($this->_mainTable)) {
27 | return parent::getMainTable();
28 | }
29 |
30 | return $this->getResourceConnection()->getTable($this->_mainTable, false);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/Model/ResourceModel/User/Collection.php:
--------------------------------------------------------------------------------
1 | collectionFactory = $collectionFactory;
40 | $this->taxonomyRepository = $taxonomyRepository;
41 | parent::__construct($itemFactory, $storeManager, $logger);
42 | }
43 |
44 | /**
45 | *
46 | */
47 | protected function getCollection($storeId): iterable
48 | {
49 | return $this->collectionFactory->create()->addTaxonomyFilter(
50 | ['in' => array_keys($this->taxonomyRepository->getAll())]
51 | )->load();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Model/TaxonomyManager.php:
--------------------------------------------------------------------------------
1 | dataSource = $dataSource;
25 | }
26 |
27 | /**
28 | * @return $this
29 | */
30 | public function load()
31 | {
32 | return $this;
33 | }
34 |
35 | /**
36 | * @return false|TaxonomyModel
37 | */
38 | public function getTaxonomy($taxonomy = null)
39 | {
40 | return $this->dataSource->get($taxonomy);
41 | }
42 |
43 | /**
44 | * @return array
45 | */
46 | public function getTaxonomies(): array
47 | {
48 | return $this->dataSource->getAll();
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Model/TaxonomyRepository.php:
--------------------------------------------------------------------------------
1 | objectFactory = $objectFactory;
29 | parent::__construct($dataSource, $storeManager);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Model/Term/MetaDataProvider.php:
--------------------------------------------------------------------------------
1 | objectFactory = $objectFactory;
27 | parent::__construct($storeManager, $idFieldName);
28 | }
29 |
30 | /**
31 | * @param int $id
32 | * @param array|string $taxonomies
33 | * @return FishPig\WordPress\Model\Term
34 | */
35 | public function getWithTaxonomy($id, $taxonomies)
36 | {
37 | $object = $this->get($id);
38 |
39 | if (!in_array($object->getTaxonomy(), (array)$taxonomies)) {
40 | throw new \Magento\Framework\Exception\NoSuchEntityException(
41 | __(
42 | 'The WordPress term exists but failed the taxonomy check. ID=%1, taxonomy=%2',
43 | $object->getId(),
44 | $object->getTaxonomy()
45 | )
46 | );
47 | }
48 |
49 | return $object;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Model/UrlInterface.php:
--------------------------------------------------------------------------------
1 | objectFactory = $objectFactory;
29 | parent::__construct($storeManager, $idFieldName);
30 | }
31 |
32 | /**
33 | * @param string $name
34 | * @return \FishPig\WordPress\Model\User
35 | */
36 | public function getByNicename($name): \FishPig\WordPress\Model\User
37 | {
38 | return $this->getByField($name, 'user_nicename');
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Model/WPConfig.php:
--------------------------------------------------------------------------------
1 | wpConfig = $wpConfig;
21 | }
22 |
23 | /**
24 | * @param string|null $key = null
25 | * @return mixed
26 | */
27 | public function getData($key = null)
28 | {
29 | return $this->wpConfig->getData($key);
30 | }
31 |
32 | /**
33 | * Get the DB host
34 | * Make a small modification for working with .sock connection strings
35 | *
36 | * @return string
37 | */
38 | public function getDbHost()
39 | {
40 | $dbHost = $this->getData('DB_HOST');
41 |
42 | if (strpos($dbHost, '.sock') !== false) {
43 | $dbHost = str_replace('localhost:/', '/', $dbHost);
44 | }
45 |
46 | return $dbHost;
47 | }
48 |
49 | /**
50 | * @return string
51 | */
52 | public function getDbName()
53 | {
54 | return $this->getData('DB_NAME');
55 | }
56 |
57 | /**
58 | * @return string
59 | */
60 | public function getDbUser()
61 | {
62 | return $this->getData('DB_USER');
63 | }
64 |
65 | /**
66 | * @return string
67 | */
68 | public function getDbPassword()
69 | {
70 | return $this->getData('DB_PASSWORD');
71 | }
72 |
73 | /**
74 | * @return string
75 | */
76 | public function getDbCharset()
77 | {
78 | return $this->getData('DB_CHARSET') ?? 'utf8mb4';
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Model/WidgetManager.php:
--------------------------------------------------------------------------------
1 | get($widgetName);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Plugin/Magento/Config/Model/Config/Structure/Element/SectionPlugin.php:
--------------------------------------------------------------------------------
1 | $group) {
26 | if (empty($group['children'])) {
27 | continue;
28 | }
29 |
30 | $field = $group['children'][key($group['children'])];
31 |
32 | if (!isset($field['frontend_model']) || $field['frontend_model'] !== GetAddon::class) {
33 | continue;
34 | }
35 |
36 | if (isset($data['children'][$groupId]['fieldset_css'])) {
37 | $data['children'][$groupId]['fieldset_css'] = trim(
38 | $data['children'][$groupId]['fieldset_css'] . ' ' . self::MODULE_NOT_INSTALLED_CLASS_NAME
39 | );
40 | } else {
41 | $data['children'][$groupId]['fieldset_css'] = self::MODULE_NOT_INSTALLED_CLASS_NAME;
42 | }
43 | }
44 | }
45 |
46 | return [$data, $scope];
47 | }
48 | }
--------------------------------------------------------------------------------
/Plugin/Magento/Csp/Model/Collector/CspWhitelistXmlCollectorPlugin.php:
--------------------------------------------------------------------------------
1 | appMode = $appMode;
34 | $this->whitelistPolicyCollector = $whitelistPolicyCollector;
35 | }
36 |
37 | /**
38 | * @param CspWhitelistXmlCollector $cspWhitelistXmlCollector
39 | * @param $defaultPolicies = []
40 | * @return array
41 | */
42 | public function afterCollect(
43 | CspWhitelistXmlCollector $cspWhitelistXmlCollector,
44 | $defaultPolicies = []
45 | ): array {
46 | if ($this->appMode->isDisabled()) {
47 | return $defaultPolicies;
48 | }
49 |
50 | return $defaultPolicies + $this->whitelistPolicyCollector->collect();
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/Plugin/Magento/Framework/App/PageCache/IdentifierPlugin.php:
--------------------------------------------------------------------------------
1 | request = $request;
33 | $this->postPasswordManager = $postPasswordManager;
34 | $this->registry = $registry;
35 | }
36 |
37 | /**
38 | *
39 | */
40 | public function afterGetValue(\Magento\Framework\App\PageCache\Identifier $subject, $value)
41 | {
42 | if ($pass = $this->postPasswordManager->getPostPassword()) {
43 | $value = sha1($value . $pass);
44 | }
45 |
46 | return $value;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Plugin/Magento/Framework/App/Router/ActionListPlugin.php:
--------------------------------------------------------------------------------
1 | assetProvider = $assetProvider;
31 | $this->request = $request;
32 | }
33 |
34 | /**
35 | * @param \Magento\Framework\Controller\ResultInterface $subject,
36 | * @param \Magento\Framework\Controller\ResultInterface $result,
37 | * @param \Magento\Framework\App\Response\Http $response
38 | * @return \Magento\Framework\Controller\ResultInterface
39 | */
40 | public function afterRenderResult(
41 | \Magento\Framework\Controller\ResultInterface $subject,
42 | \Magento\Framework\Controller\ResultInterface $result,
43 | \Magento\Framework\App\Response\Http $response
44 | ): \Magento\Framework\Controller\ResultInterface {
45 | $this->assetProvider->provideAssets(
46 | $this->request,
47 | $response
48 | );
49 |
50 | return $result;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "fishpig/magento2-wordpress-integration",
3 | "description": "Securely integrate WordPress and Magento 2.",
4 | "version": "3.31.20",
5 | "require": {
6 | "php": ">=7.4",
7 | "magento/framework": "*",
8 | "magento/module-config": "*",
9 | "magento/module-store": "*",
10 | "magento/module-sitemap": "^100.3"
11 | },
12 | "suggest": {
13 | "fishpig/magento2-wordpress-integration-yoastseo": "^3.0"
14 | },
15 | "type": "magento2-module",
16 | "autoload": {
17 | "files": [
18 | "registration.php"
19 | ],
20 | "psr-4": {
21 | "FishPig\\WordPress\\": ""
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/etc/adminhtml/acl.xml:
--------------------------------------------------------------------------------
1 |
2 |
Securely login to your WordPress Admin with a single click using the Auto Login add-on module for Magento 2.
8 | -------------------------------------------------------------------------------- /view/adminhtml/templates/integrate.phtml: -------------------------------------------------------------------------------- 1 | 7 | getMessages()): ?> 8 | 15 | = $block->getAfterMessagesHtml() ?> 16 | -------------------------------------------------------------------------------- /view/adminhtml/templates/integration-status.phtml: -------------------------------------------------------------------------------- 1 | 7 | getMessages()): ?> 8 | 15 | 16 | -------------------------------------------------------------------------------- /view/adminhtml/web/images/wordpress-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bentideswell/magento2-wordpress-integration/b6897a405d70cc1f1d05c60aff70ad89c8f4199b/view/adminhtml/web/images/wordpress-logo.png -------------------------------------------------------------------------------- /view/frontend/layout/wordpress_archive_view.xml: -------------------------------------------------------------------------------- 1 | 2 |= $block->escapeHtml($text) ?>
10 | 11 | getPostListHtml())): ?> 12 | = /* @noEscape */ $postList ?> 13 | 14 |= $block->escapeHtml(__('There are no posts matching your selection.')) ?>
15 | -------------------------------------------------------------------------------- /view/frontend/templates/post/protected.phtml: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /view/frontend/templates/post/view/comment/wrapper.phtml: -------------------------------------------------------------------------------- 1 | 6 | */ 7 | ?> 8 | getPost() ?> 9 | getComments() ?> 10 |= $block->escapeHtml($block->getCaption()) ?>
22 | 23 |
= $block->escapeHtml(__('1 Comment')) ?>
14 | 15 |= $block->escapeHtml(__('%1 Comments', (int)$block->getCommentCount())) ?>
16 | 17 | = $block->getCommentsHtml() ?> 18 | = $block->getPagerHtml() ?> 19 | 20 | = $block->getFormHtml() ?> 21 |